Beispiel #1
0
 def updateProfileToControls(self):
     self._machineSize = numpy.array([
         profile.getMachineSettingFloat('machine_width'),
         profile.getMachineSettingFloat('machine_depth'),
         profile.getMachineSettingFloat('machine_height')
     ])
     self._objColor = profile.getPreferenceColor('model_color')
Beispiel #2
0
	def updateProfileToControls(self):
		self._machineSize = numpy.array([profile.getMachineSettingFloat('machine_width'), profile.getMachineSettingFloat('machine_depth'), profile.getMachineSettingFloat('machine_height')])
		self._objColor = profile.getPreferenceColor('model_color')
Beispiel #3
0
	def _drawMachine(self):
		glEnable(GL_BLEND)
		machine_model_path = profile.getMachineSettingPath('machine_model_path')
		glEnable(GL_CULL_FACE)
		#-- Draw Platform
		if machine_model_path in self._platformMesh:
			self._platformMesh[machine_model_path]._mesh.vbo.release()

		mesh = meshLoader.loadMesh(machine_model_path)
		if mesh is not None:
			self._platformMesh[machine_model_path] = mesh
		else:
			self._platformMesh[machine_model_path] = None
		self._platformMesh[machine_model_path]._drawOffset = numpy.array([0,0,8.05], numpy.float32)
		glColor4f(0.6,0.6,0.6,0.5)
		self._objectShader.bind()
		self._renderObject(self._platformMesh[machine_model_path])
		self._objectShader.unbind()
		glDisable(GL_CULL_FACE)

		glDepthMask(False)
		
		machine_shape = profile.getMachineSetting('machine_shape')

		if machine_shape == 'Circular':
			size = numpy.array([profile.getMachineSettingFloat('roi_diameter'),
								profile.getMachineSettingFloat('roi_diameter'),
								profile.getMachineSettingFloat('roi_height')], numpy.float32)
		elif machine_shape == 'Rectangular':
			size = numpy.array([profile.getMachineSettingFloat('roi_width'),
								profile.getMachineSettingFloat('roi_depth'),
								profile.getMachineSettingFloat('roi_height')], numpy.float32)

		if profile.getMachineSettingBool('view_roi'):
			polys = profile.getSizePolygons(size, machine_shape)
			height = profile.getMachineSettingFloat('roi_height')

			# Draw the sides of the build volume.
			glBegin(GL_QUADS)
			for n in xrange(0, len(polys[0])):
				if machine_shape == 'Rectangular':
					if n % 2 == 0:
						glColor4ub(5, 171, 231, 96)
					else:
						glColor4ub(5, 171, 231, 64)
				elif machine_shape == 'Circular':
					glColor4ub(5, 171, 231, 96)
					#glColor4ub(200, 200, 200, 150)

				glVertex3f(polys[0][n][0], polys[0][n][1], height)
				glVertex3f(polys[0][n][0], polys[0][n][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], 0)
				glVertex3f(polys[0][n-1][0], polys[0][n-1][1], height)
			glEnd()

			#Draw bottom and top of build volume.
			glColor4ub(5, 171, 231, 150)#128)
			#glColor4ub(200, 200, 200, 200)
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], 0)
			glEnd()
			glBegin(GL_TRIANGLE_FAN)
			for p in polys[0][::-1]:
				glVertex3f(p[0], p[1], height)
			glEnd()

			quadric=gluNewQuadric();
			gluQuadricNormals(quadric, GLU_SMOOTH);
			gluQuadricTexture(quadric, GL_TRUE);
			glColor4ub(0, 100, 200, 150)
			
			gluCylinder(quadric,6,6,1,32,16);
			gluDisk(quadric, 0.0, 6, 32, 1); 

			glTranslate(0,0,height-1)
			gluDisk(quadric, 0.0, 6, 32, 1); 
			gluCylinder(quadric,6,6,1,32,16);
			glTranslate(0,0,-height+1)

		polys = profile.getMachineSizePolygons(profile.getMachineSetting("machine_shape"))
		
		#-- Draw checkerboard
		if self._platformTexture is None:
			self._platformTexture = openglHelpers.loadGLTexture('checkerboard.png')
			glBindTexture(GL_TEXTURE_2D, self._platformTexture)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
		glColor4f(1,1,1,0.5)
		glBindTexture(GL_TEXTURE_2D, self._platformTexture)
		glEnable(GL_TEXTURE_2D)
		glBegin(GL_TRIANGLE_FAN)
		for p in polys[0]:
			glTexCoord2f(p[0]/20, p[1]/20)
			glVertex3f(p[0], p[1], 0)
		glEnd()
		glDisable(GL_TEXTURE_2D)

		glDepthMask(True)
		glDisable(GL_BLEND)