def __init__(self,nx=(1,1,1),ox=(0.0,0.0,0.0),dx=(1.0,1.0,1.0),linecolor=black,linewidth=None,planecolor=white,alpha=0.5,lines=True,planes=True,**kargs): Actor.__init__(self,**kargs) self.linecolor = saneColor(linecolor) self.planecolor = saneColor(planecolor) self.linewidth = linewidth self.alpha = alpha self.opak = False self.lines = lines self.planes = planes self.nx = asarray(nx) self.x0 = asarray(ox) self.x1 = self.x0 + self.nx * asarray(dx)
def __init__(self,nx=(1,1,1),ox=(0.0,0.0,0.0),dx=(1.0,1.0,1.0),linecolor=black,linewidth=None,planecolor=white,alpha=0.5,lines=True,planes=True,**kargs): Actor.__init__(self,**kargs) self.linecolor = saneColor(linecolor) self.planecolor = saneColor(planecolor) self.linewidth = linewidth self.alpha = alpha self.trans = True self.lines = lines self.planes = planes self.nx = asarray(nx) self.x0 = asarray(ox) self.x1 = self.x0 + self.nx * asarray(dx)
def __init__(self,nx=(2,2,2),ox=(0.,0.,0.),size=((0.0,1.0,1.0),(0.0,1.0,1.0)),linecolor=black,linewidth=None,planecolor=white,alpha=0.5,lines=True,planes=True,**kargs): """A plane perpendicular to the x-axis at the origin.""" Actor.__init__(self,**kargs) self.linecolor = saneColor(linecolor) self.planecolor = saneColor(planecolor) self.linewidth = linewidth self.alpha = alpha self.trans = True self.lines = lines self.planes = planes self.nx = asarray(nx) ox = asarray(ox) sz = asarray(size) self.x0,self.x1 = ox-sz[0], ox+sz[1]
def __init__(self,nx=(2,2,2),ox=(0.,0.,0.),size=((0.0,1.0,1.0),(0.0,1.0,1.0)),linecolor=black,linewidth=None,planecolor=white,alpha=0.5,lines=True,planes=True,**kargs): """A plane perpendicular to the x-axis at the origin.""" Actor.__init__(self,**kargs) self.linecolor = saneColor(linecolor) self.planecolor = saneColor(planecolor) self.linewidth = linewidth self.alpha = alpha self.opak = False self.lines = lines self.planes = planes self.nx = asarray(nx) ox = asarray(ox) sz = asarray(size) self.x0,self.x1 = ox-sz[0], ox+sz[1]
def __init__(self, data, color=None, **kargs): from gui.drawable import saneColor Actor.__init__(self) self.object = data self.color = saneColor(color) self.samplingTolerance = 1.0
def __init__(self,cs=None,size=1.0,color=[red,green,blue],colored_axes=True,draw_planes=False,linewidth=None,**kargs): Actor.__init__(self,**kargs) if cs is None: cs = CoordinateSystem() self.cs = cs self.color = saneColorArray(saneColor(color),(3,1)) self.colored_axes = colored_axes self.draw_planes = draw_planes self.linewidth = linewidth self.setSize(size)
def __init__(self,cs=None,size=1.0,psize=0.5,color=[red,green,blue],colored_axes=True,draw_planes=True,draw_reverse=True,linewidth=2,alpha=0.5,**kargs): Actor.__init__(self,**kargs) if cs is None: cs = coordsys.CoordinateSystem() self.cs = cs self.color = saneColorArray(saneColor(color),(3,1)) self.alpha = alpha self.opak = False self.nolight = True self.colored_axes = colored_axes self.draw_planes = draw_planes self.draw_reverse = draw_reverse self.linewidth = linewidth self.setSize(size,psize)
def drawGL(self,canvas=None,mode=None,color=None,**kargs): """Draw the geometry on the specified canvas. The drawing parameters not provided by the Actor itself, are derived from the canvas defaults. mode and color can be overridden for the sole purpose of allowing the recursive use for modes ending on 'wire' ('smoothwire' or 'flatwire'). In these cases, two drawing operations are done: one with mode='wireframe' and color=black, and one with mode=mode[:-4]. """ from canvas import glLineStipple if canvas is None: canvas = pf.canvas if mode is None: mode = self.mode if mode is None: mode = canvas.rendermode if mode.endswith('wire'): self.drawGL(mode=mode[:-4]) # draw the lines without lights canvas.glLight(False) self.drawGL(mode='wireframe',color=asarray(black)) return ############# set drawing attributes ######### alpha = self.alpha if alpha is None: alpha = canvas.settings.alpha if color is None: color,colormap = self.color,self.colormap bkcolor, bkcolormap = self.bkcolor,self.bkcolormap else: # THIS OPTION IS ONLY MEANT FOR OVERRIDING THE COLOR # WITH THE EDGECOLOR IN ..wire DRAWING MODES # SO NO NEED TO SET bkcolor color,colormap = saneColor(color),None bkcolor, bkcolormap = None,None # convert color index to full colors if color is not None and color.dtype.kind == 'i': color = colormap[color] if bkcolor is not None and bkcolor.dtype.kind == 'i': bkcolor = bkcolormap[bkcolor] linewidth = self.linewidth if linewidth is None: linewidth = canvas.settings.linewidth if self.linewidth is not None: GL.glLineWidth(self.linewidth) if self.linestipple is not None: glLineStipple(*self.linestipple) if mode.startswith('smooth'): if hasattr(self,'specular'): fill_mode = GL.GL_FRONT import colors if color is not None: spec = color * self.specular# * pf.canvas.specular spec = append(spec,1.) else: spec = colors.GREY(self.specular)# * pf.canvas.specular GL.glMaterialfv(fill_mode,GL.GL_SPECULAR,spec) GL.glMaterialfv(fill_mode,GL.GL_EMISSION,spec) GL.glMaterialfv(fill_mode,GL.GL_SHININESS,self.specular) ################## draw the geometry ################# nplex = self.nplex() if nplex == 1: marksize = self.marksize if marksize is None: marksize = canvas.settings.pointsize # THIS SHOULD GO INTO drawPoints if self.elems is None: coords = self.coords else: coords = self.coords[self.elems] drawPoints(coords,color,alpha,marksize) elif nplex == 2: drawLines(self.coords,self.elems,color) # beware: some Formex eltypes are strings and may not # represent a valid Mesh elementType # THis is only here for Formex type. # We can probably remove it if we avoid eltype 'curve' elif nplex == 3 and self.eltype in ['curve','line3']: drawQuadraticCurves(self.coords,self.elems,color) elif self.eltype is None: # polygons if mode=='wireframe' : drawPolyLines(self.coords,self.elems,color) else: if bkcolor is not None: GL.glEnable(GL.GL_CULL_FACE) GL.glCullFace(GL.GL_BACK) drawPolygons(self.coords,self.elems,mode,color,alpha) if bkcolor is not None: GL.glCullFace(GL.GL_FRONT) drawPolygons(self.coords,self.elems,mode,bkcolor,alpha) GL.glDisable(GL.GL_CULL_FACE) else: el = elementType(self.eltype) if mode=='wireframe' or el.ndim < 2: for edges in el.getDrawEdges(el.name() in pf.cfg['draw/quadline']): drawEdges(self.coords,self.elems,edges,edges.eltype,color) else: for faces in el.getDrawFaces(el.name() in pf.cfg['draw/quadsurf']): print faces.report() if bkcolor is not None: # Enable drawing front and back with different colors GL.glEnable(GL.GL_CULL_FACE) GL.glCullFace(GL.GL_BACK) # Draw the front sides drawFaces(self.coords,self.elems,faces,faces.eltype,mode,color,alpha) if bkcolor is not None: # Draw the back sides GL.glCullFace(GL.GL_FRONT) drawFaces(self.coords,self.elems,faces,faces.eltype,mode,bkcolor,alpha) GL.glDisable(GL.GL_CULL_FACE)
def drawGL(self,canvas=None,mode=None,color=None,**kargs): """Draw the geometry on the specified canvas. The drawing parameters not provided by the Actor itself, are derived from the canvas defaults. mode and color can be overridden for the sole purpose of allowing the recursive use for modes ending on 'wire' ('smoothwire' or 'flatwire'). In these cases, two drawing operations are done: one with mode='wireframe' and color=black, and one with mode=mode[:-4]. """ if canvas is None: canvas = pf.canvas if mode is None: mode = self.mode if mode is None: mode = canvas.rendermode if mode != canvas.rendermode: canvas.overrideMode(mode) ############# set drawing attributes ######### avgnormals = self.avgnormals if avgnormals is None: avgnormals = canvas.settings.avgnormals lighting = canvas.settings.lighting alpha = self.alpha if alpha is None: alpha = canvas.settings.transparency bkalpha = self.bkalpha if bkalpha is None: bkalpha = canvas.settings.transparency if color is None: color,colormap = self.color,self.colormap bkcolor, bkcolormap = self.bkcolor,self.bkcolormap else: # THIS OPTION IS ONLY MEANT FOR OVERRIDING THE COLOR # WITH THE EDGECOLOR IN ..wire DRAWING MODES # SO NO NEED TO SET bkcolor # # NOT SURE IF WE STILL NEED THIS ! YES!!! # #raise ValueError,"THIS ERROR SHOULD NOT OCCUR: Contact mainitainers" color,colormap = saneColor(color),None bkcolor, bkcolormap = None,None # convert color index to full colors if color is not None and color.dtype.kind == 'i': color = colormap[color] if bkcolor is not None and bkcolor.dtype.kind == 'i': bkcolor = bkcolormap[bkcolor] linewidth = self.linewidth if linewidth is None: linewidth = canvas.settings.linewidth if self.linewidth is not None: GL.glLineWidth(self.linewidth) if self.linestipple is not None: glLineStipple(*self.linestipple) if mode.startswith('smooth'): if hasattr(self,'specular'): fill_mode = GL.GL_FRONT import colors if color is not None: spec = color * self.specular# * pf.canvas.specular spec = append(spec,1.) else: spec = colors.GREY(self.specular)# * pf.canvas.specular GL.glMaterialfv(fill_mode,GL.GL_SPECULAR,spec) GL.glMaterialfv(fill_mode,GL.GL_EMISSION,spec) GL.glMaterialfv(fill_mode,GL.GL_SHININESS,self.specular) ################## draw the geometry ################# nplex = self.nplex() if nplex == 1: marksize = self.marksize if marksize is None: marksize = canvas.settings.pointsize # THIS SHOULD GO INTO drawPoints if self.elems is None: coords = self.coords else: coords = self.coords[self.elems] drawPoints(coords,color,alpha,marksize) elif nplex == 2: drawLines(self.coords,self.elems,color) # beware: some Formex eltypes are strings and may not # represent a valid Mesh elementType # This is only here for Formex type. # We can probably remove it if we avoid eltype 'curve' elif nplex == 3 and self.eltype == 'curve': drawQuadraticCurves(self.coords,self.elems,color) elif self.eltype is None: # polygons if mode=='wireframe' : drawPolyLines(self.coords,self.elems,color) else: if bkcolor is not None: GL.glEnable(GL.GL_CULL_FACE) GL.glCullFace(GL.GL_BACK) drawPolygons(self.coords,self.elems,color,alpha,self.texture,None,None,lighting,avgnormals) if bkcolor is not None: GL.glCullFace(GL.GL_FRONT) drawPolygons(self.coords,self.elems,bkcolor,bkalpha,None,None,None,lighting,avgnormals) GL.glDisable(GL.GL_CULL_FACE) else: el = elementType(self.eltype) if mode=='wireframe' or el.ndim < 2: for edges in el.getDrawEdges(el.name() in pf.cfg['draw/quadline']): drawEdges(self.coords,self.elems,edges,edges.eltype,color) else: for faces in el.getDrawFaces(el.name() in pf.cfg['draw/quadsurf']): if bkcolor is not None: # Enable drawing front and back with different colors GL.glEnable(GL.GL_CULL_FACE) GL.glCullFace(GL.GL_BACK) drawFaces(self.coords,self.elems,faces,faces.eltype,color,alpha,self.texture,None,self.normals,lighting,avgnormals) if bkcolor is not None: # Draw the back sides GL.glCullFace(GL.GL_FRONT) drawFaces(self.coords,self.elems,faces,faces.eltype,bkcolor,bkalpha,None,None,self.normals,lighting,avgnormals) GL.glDisable(GL.GL_CULL_FACE)