示例#1
0
def drawBoundingBox(width, height, depth):
    """ Draw bounding box use C side for easy of vertex arrays """

    GL.glPushAttrib(GL.GL_LIGHTING_BIT)
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, [1.0, 1.0, 1.0, 1.0])
    GLUtil.glDrawBoundingBox(width, height, depth)
    GL.glPopAttrib()
示例#2
0
def drawBoundingBox(width, height, depth):
	""" Draw bounding box use C side for easy of vertex arrays """
	
	GL.glPushAttrib(GL.GL_LIGHTING_BIT)
	GL.glMaterialfv(GL.GL_FRONT, GL.GL_EMISSION, [1.0,1.0,1.0,1.0])
	GLUtil.glDrawBoundingBox(width, height, depth)
	GL.glPopAttrib()
示例#3
0
    def render(self):
        """
		This is the method to call to render the node and its child nodes. 
		It calls self.renderNode() to render the current node. 
		Usually, this method is unchanged in subclasses. 
		"""
        if not self.is_visible:
            return  #Also applies to subtree rooted at this node

        if self.transform.is_identity():
            GL.glPushName(self.intname)
            self.renderNode()
            for child in self.children:
                child.render()
            GL.glPopName()
        else:
            GL.glPushMatrix()
            GL.glPushName(self.intname)
            GLUtil.glMultMatrix(self.transform)  #apply the transformation

            self.renderNode()
            for child in self.children:
                child.render()
            GL.glPopName()
            GL.glPopMatrix()

        if self.item_inspector != None and self.is_selected:
            self.item_inspector.updateItemControls()
示例#4
0
	def render(self):
		"""
		This is the method to call to render the node and its child nodes. 
		It calls self.renderNode() to render the current node. 
		Usually, this method is unchanged in subclasses. 
		"""
		if not self.is_visible:
			return #Also applies to subtree rooted at this node

		if self.transform.is_identity():
			GL.glPushName(self.intname)
			self.renderNode()
			for child in self.children:
				child.render()
			GL.glPopName()
		else:
			GL.glPushMatrix()
			GL.glPushName(self.intname)
			GLUtil.glMultMatrix(self.transform) #apply the transformation
			
			self.renderNode()
			for child in self.children:
				child.render()
			GL.glPopName()
			GL.glPopMatrix()

		if self.item_inspector != None and self.is_selected: 
				self.item_inspector.updateItemControls()
示例#5
0
    def gen_texture(self):
        if (self.texture == False): return
        if (self.tex_name != 0):
            glDeleteTextures(self.tex_name)

        if (self.data_copy == None):
            self.tex_name = GLUtil.gen_gl_texture(self.data)
        else:
            self.tex_name = GLUtil.gen_gl_texture(self.data_copy)
示例#6
0
	def gen_texture(self):
		if ( self.texture == False ): return
		if ( self.tex_name != 0 ):
			glDeleteTextures(self.tex_name)
		
		if ( self.data_copy == None ):
			self.tex_name = GLUtil.gen_gl_texture(self.data)
		else:
			self.tex_name = GLUtil.gen_gl_texture(self.data_copy)
示例#7
0
    def changed(self):
        """This should be called whenever the image needs to be redisplayed. If the actual image
		data changes, setdata should be called again"""

        if not self.data:
            return
        # 		print "  %s (%f %f) (%f %f)                \r"%(str(self.origin),self.mingrayval,self.maxgrayval,self.data.get_attr("minimum"),self.data.get_attr("maximum")),
        # 		sys.stdout.flush()
        if self.origin[0] < 0:
            self.origin[0] = 0
        if self.origin[1] < 0:
            self.origin[1] = 0
        d = GLUtil.render_amp8(
            self.data,
            self.origin[0],
            self.origin[1],
            self.GetSize()[0],
            self.GetSize()[1],
            self.GetSize()[0] * 3,
            self.scale,
            1,
            254,
            self.mingrayval,
            self.maxgrayval,
            1,
        )

        image = wx.EmptyImage(self.GetSize()[0], self.GetSize()[1])
        image.SetDataBuffer(d)
        self.bm = image.ConvertToBitmap()

        self.Refresh(0)
        self.Update()
        self.changec = self.data.get_attr("changecount")
示例#8
0
	def get_iso_dl(self):
		# create the isosurface display list
		self.isorender.set_surface_value(self.isothr)
		self.isorender.set_sampling(self.smpval)
		
		if ( self.texture ):
			if ( self.tex_name == 0 ):
				self.update_data_and_texture()
		
		face_z = False
		if self.data.get_zsize() <= 2:
			face_z = True
		
		if ( self.texture  ):
			self.isodl = GLUtil.get_isosurface_dl(self.isorender, self.tex_name,face_z)
		else:
			self.isodl = GLUtil.get_isosurface_dl(self.isorender, 0,face_z)
示例#9
0
	def get_iso_dl(self):
		# create the isosurface display list
		self.isorender.set_surface_value(self.isothr)
		self.isorender.set_sampling(self.smpval)
		
		if ( self.texture ):
			if ( self.tex_name == 0 ):
				self.update_data_and_texture()
		
		face_z = False
		if self.data.get_zsize() <= 2:
			face_z = True
		
		if ( self.texture  ):
			self.isodl = GLUtil.get_isosurface_dl(self.isorender, self.tex_name,face_z)
		else:
			self.isodl = GLUtil.get_isosurface_dl(self.isorender, 0,face_z)
示例#10
0
    def changed(self):
        """This should be called whenever the image needs to be redisplayed. If the actual image
		data changes, setdata should be called again"""

        if not self.data: return

        x_offset = (self.GetSize()[0] / 2 / self.scale) / self.emdatasize[0]
        y_offset = (self.GetSize()[1] / 2 / self.scale) / self.emdatasize[1]

        render_x = int(((self.x_per - x_offset) * self.emdatasize[0]))
        render_y = int(((self.y_per - y_offset) * self.emdatasize[1]))

        d = GLUtil.render_amp8(self.data, render_x, render_y,
                               self.GetSize()[0],
                               self.GetSize()[1],
                               self.GetSize()[0] * 3, self.scale, 1, 254,
                               self.mingrayval, self.maxgrayval, 1)

        #print "... "
        #print render_x
        #print render_y
        #print self.GetSize()[0]
        #print self.GetSize()[1]

        # debug stuff.... sums of int values in image
        #p = [ord(c) for c in d]
        #print sum(p)
        #print len(d)

        image = wx.EmptyImage(self.GetSize()[0], self.GetSize()[1])
        image.SetDataBuffer(d)

        self.bm = image.ConvertToBitmap()

        if self.control:
            self.control.update_canvas_per()

        self.Refresh(0)
        self.Update()
        self.changec = self.data.get_attr("changecount")
示例#11
0
	def changed(self):
		"""This should be called whenever the image needs to be redisplayed. If the actual image
		data changes, setdata should be called again"""
		
		if not self.data: return

		x_offset = (self.GetSize()[0]/2 / self.scale) / self.emdatasize[0]
		y_offset = (self.GetSize()[1]/2 / self.scale) / self.emdatasize[1]

		render_x = int( ((self.x_per - x_offset) * self.emdatasize[0]) ) 
		render_y = int( ((self.y_per - y_offset) * self.emdatasize[1]) ) 

		d=GLUtil.render_amp8(self.data,render_x,render_y,self.GetSize()[0],self.GetSize()[1],self.GetSize()[0]*3,self.scale,1,254, self.mingrayval,self.maxgrayval,1)

		#print "... "
		#print render_x
		#print render_y
		#print self.GetSize()[0]
		#print self.GetSize()[1]

		# debug stuff.... sums of int values in image
		#p = [ord(c) for c in d]
		#print sum(p)
		#print len(d)
	
		image=wx.EmptyImage(self.GetSize()[0],self.GetSize()[1])
		image.SetDataBuffer(d)

		self.bm=image.ConvertToBitmap()


		if self.control: 
			self.control.update_canvas_per()

		self.Refresh(0)
		self.Update()
		self.changec=self.data.get_attr("changecount")
示例#12
0
	def render_node(self):
		# So I can see the box
		
		glPushMatrix()
		GLUtil.glMultMatrix(self.nodematrix)
		
		# Material properties of the box
		glMaterialfv(GL_FRONT, GL_DIFFUSE, [0.5,0.5,0.5,1.0])
		glMaterialfv(GL_FRONT, GL_SPECULAR, [1.0,1.0,1.0,1.0])
		glMaterialf(GL_FRONT, GL_SHININESS, 25.0)
		glMaterialfv(GL_FRONT, GL_AMBIENT, [1.0, 1.0, 1.0, 1.0])
		# The box itself anlong with normal vectors
		glBegin(GL_QUADS)

		glNormal3f(self.xi, self.yi, self.zi + 1)
		glVertex3f(self.xi, self.yi, self.zi)
		glNormal3f(self.xf, self.yi, self.zi + 1)
		glVertex3f(self.xf, self.yi, self.zi)
		glNormal3f(self.xf, self.yf, self.zi + 1)
		glVertex3f(self.xf, self.yf, self.zi)
		glNormal3f(self.xi, self.yf, self.zi + 1)
		glVertex3f(self.xi, self.yf, self.zi)

		glNormal3f(self.xi - 1, self.yi, self.zi)
		glVertex3f(self.xi, self.yi, self.zi)
		glNormal3f(self.xi - 1, self.yi, self.zf)
		glVertex3f(self.xi, self.yi, self.zf)
		glNormal3f(self.xi - 1, self.yf, self.zf)
		glVertex3f(self.xi, self.yf, self.zf)
		glNormal3f(self.xi - 1, self.yf, self.zi)
		glVertex3f(self.xi, self.yf, self.zi)

		glNormal3f(self.xi, self.yi, self.zf - 1)
		glVertex3f(self.xi, self.yi, self.zf)
		glNormal3f(self.xi, self.yf, self.zf - 1)
		glVertex3f(self.xi, self.yf, self.zf)
		glNormal3f(self.xf, self.yf, self.zf - 1)
		glVertex3f(self.xf, self.yf, self.zf)
		glNormal3f(self.xf, self.yi, self.zf - 1)
		glVertex3f(self.xf, self.yi, self.zf)

		glNormal3f(self.xf + 1, self.yf, self.zf)
		glVertex3f(self.xf, self.yf, self.zf)
		glNormal3f(self.xf + 1, self.yf, self.zi)
		glVertex3f(self.xf, self.yf, self.zi)
		glNormal3f(self.xf + 1, self.yi, self.zi)
		glVertex3f(self.xf, self.yi, self.zi)
		glNormal3f(self.xf + 1, self.yi, self.zf)
		glVertex3f(self.xf, self.yi, self.zf)

		glNormal3f(self.xi, self.yf + 1, self.zi)
		glVertex3f(self.xi, self.yf, self.zi)
		glNormal3f(self.xi, self.yf + 1, self.zf)
		glVertex3f(self.xi, self.yf, self.zf)
		glNormal3f(self.xf, self.yf + 1, self.zf)
		glVertex3f(self.xf, self.yf, self.zf)
		glNormal3f(self.xf, self.yf + 1, self.zi)
		glVertex3f(self.xf, self.yf, self.zi)

		glNormal3f(self.xi, self.yi - 1, self.zi)
		glVertex3f(self.xi, self.yi, self.zi)
		glNormal3f(self.xi, self.yi - 1, self.zf)
		glVertex3f(self.xi, self.yi, self.zf)
		glNormal3f(self.xf, self.yi - 1, self.zf)
		glVertex3f(self.xf, self.yi, self.zf)
		glNormal3f(self.xf, self.yi - 1, self.zi)
		glVertex3f(self.xf, self.yi, self.zi)

		glEnd()
		glPopMatrix()