def plot(self,data1,data2,template,gtype,gname,bg,*args,**kargs): self.numberOfPlotCalls+=1 ## these are keyargs that can be reused later by the backend. returned = {} if self.bg is None: if bg: self.bg= True else: self.bg= False self.createRenWin(**kargs) if self.bg: self.renWin.SetOffScreenRendering(True) self.renWin.SetSize(self.canvas.bgX,self.canvas.bgY) self.cell_coordinates=kargs.get( 'cell_coordinates', None ) self.canvas.initLogoDrawing() if gtype == "text": tt,to = gname.split(":::") tt = vcs.elements["texttable"][tt] to = vcs.elements["textorientation"][to] gm=tt else: gm = vcs.elements[gtype][gname] tpl = vcs.elements["template"][template] if kargs.get("renderer",None) is None: if ( gtype in ["3d_scalar", "3d_dual_scalar", "3d_vector"] ) and (self.renderer <> None): ren = self.renderer else: #ren = self.createRenderer() #if not (vcs.issecondaryobject(gm) and gm.priority==0): # self.setLayer(ren,tpl.data.priority) # self.renderer = ren # self.renWin.AddRenderer(ren) pass #ren.SetPreserveDepthBuffer(True) else: ren = kargs["renderer"] vtk_backend_grid = kargs.get("vtk_backend_grid",None) vtk_backend_geo = kargs.get("vtk_backend_geo",None) pipeline = vcsvtk.createPipeline(gm, self) if pipeline is not None: returned.update(pipeline.plot(data1, data2, tpl, gm, vtk_backend_grid, vtk_backend_geo)) elif gtype in ["3d_scalar", "3d_dual_scalar", "3d_vector"]: cdms_file = kargs.get( 'cdmsfile', None ) cdms_var = kargs.get( 'cdmsvar', None ) if not cdms_var is None: raise Exception() if not cdms_file is None: gm.addPlotAttribute( 'file', cdms_file ) gm.addPlotAttribute( 'filename', cdms_file ) gm.addPlotAttribute( 'url', cdms_file ) returned.update(self.plot3D(data1,data2,tpl,gm,ren,**kargs)) elif gtype in ["text"]: if tt.priority!=0: #if not (None,None,None) in self._renderers.keys(): ren = self.createRenderer() self.renWin.AddRenderer(ren) self.setLayer(ren,1) # self._renderers[(None,None,None)]=ren #else: # ren = self._renderers[(None,None,None)] returned["vtk_backend_text_actors"] = vcs2vtk.genTextActor(ren,to=to,tt=tt) self.setLayer(ren,tt.priority) elif gtype=="line": if gm.priority!=0: actors = vcs2vtk.prepLine(self.renWin,gm) returned["vtk_backend_line_actors"]=actors for act,geo in actors: ren = self.fitToViewport(act,gm.viewport,wc=gm.worldcoordinate,geo=geo,priority=gm.priority) elif gtype=="marker": if gm.priority!=0: actors = vcs2vtk.prepMarker(self.renWin,gm) returned["vtk_backend_marker_actors"]=actors for g,gs,pd,act,geo in actors: ren = self.fitToViewport(act,gm.viewport,wc=gm.worldcoordinate,geo=geo,priority=gm.priority) if pd is None and act.GetUserTransform(): vcs2vtk.scaleMarkerGlyph(g, gs, pd, act) elif gtype=="fillarea": if gm.priority!=0: actors = vcs2vtk.prepFillarea(self.renWin,gm) returned["vtk_backend_fillarea_actors"]=actors for act,geo in actors: ren = self.fitToViewport(act,gm.viewport,wc=gm.worldcoordinate,geo=geo,priority=gm.priority) else: raise Exception,"Graphic type: '%s' not re-implemented yet" % gtype self.scaleLogo() if not kargs.get("donotstoredisplay",False) and kargs.get("render", True): self.renWin.Render() return returned
def plot(self,data1,data2,template,gtype,gname,bg,*args,**kargs): self.numberOfPlotCalls+=1 created = self.createRenWin(**kargs) if self.bg is None: if bg: self.bg= True else: self.bg= False if created: self.initialSize() if bg: self.renWin.SetOffScreenRendering(True) self.renWin.SetSize(self.canvas.bgX,self.canvas.bgY) #self.renWin.Render() #screenSize = self.renWin.GetScreenSize() if gtype in ["boxfill","meshfill","isoline","isofill","vector"]: data1 = self.trimData2D(data1) # Ok get only the last 2 dims data2 = self.trimData2D(data2) #elif vcs.isgraphicsmethod(vcs.elements[gtype][gname]): ## oneD # data1 = self.trimData1D(data1) # data2 = self.trimData1D(data2) if gtype == "text": tt,to = gname.split(":::") tt = vcs.elements["texttable"][tt] to = vcs.elements["textorientation"][to] gm=tt else: gm = vcs.elements[gtype][gname] tpl = vcs.elements["template"][template] if kargs.get("renderer",None) is None: if ( gtype in ["3d_scalar", "3d_vector"] ) and (self.renderer <> None): ren = self.renderer else: ren = vtk.vtkRenderer() r,g,b = self.canvas.backgroundcolor ren.SetBackground(r/255.,g/255.,b/255.) if not (vcs.issecondaryobject(gm) and gm.priority==0): self.renderer = ren self.renWin.AddRenderer(ren) #ren.SetPreserveDepthBuffer(True) else: ren = kargs["renderer"] if gtype in ["boxfill","meshfill","isofill","isoline"]: self.plot2D(data1,data2,tpl,gm,ren) elif gtype in ["3d_scalar", "3d_vector"]: self.plot3D(data1,data2,tpl,gm,ren) elif gtype in ["text"]: if tt.priority!=0: self.setLayer(ren,tt.priority) vcs2vtk.genTextActor(ren,to=to,tt=tt) elif gtype=="line": if gm.priority!=0: self.setLayer(ren,gm.priority) vcs2vtk.prepLine(self.renWin,ren,gm) elif gtype=="marker": if gm.priority!=0: self.setLayer(ren,gm.priority) vcs2vtk.prepMarker(self.renWin,ren,gm) elif gtype=="fillarea": if gm.priority!=0: self.setLayer(ren,gm.priority) vcs2vtk.prepFillarea(self.renWin,ren,gm) elif gtype=="oned": self.plot1D(data1,data2,tpl,gm,ren) elif gtype=="vector": self.plotVector(data1,data2,tpl,gm,ren) else: raise Exception,"Graphic type: '%s' not re-implemented yet" % gtype if not kargs.get("donotstoredisplay",False): self.renWin.Render()
def plot(self,data1,data2,template,gtype,gname,bg,*args,**kargs): self.numberOfPlotCalls+=1 if self.bg is None: if bg: self.bg= True else: self.bg= False created = self.createRenWin(**kargs) if created: self.initialSize() if self.bg: self.renWin.SetOffScreenRendering(True) self.renWin.SetSize(self.canvas.bgX,self.canvas.bgY) self.cell_coordinates=kargs.get( 'cell_coordinates', None ) #self.renWin.Render() #screenSize = self.renWin.GetScreenSize() if gtype == "text": tt,to = gname.split(":::") tt = vcs.elements["texttable"][tt] to = vcs.elements["textorientation"][to] gm=tt else: gm = vcs.elements[gtype][gname] tpl = vcs.elements["template"][template] if kargs.get("renderer",None) is None: if ( gtype in ["3d_scalar", "3d_dual_scalar", "3d_vector"] ) and (self.renderer <> None): ren = self.renderer else: ren = self.createRenderer() if not (vcs.issecondaryobject(gm) and gm.priority==0): self.setLayer(ren,tpl.data.priority) self.renderer = ren self.renWin.AddRenderer(ren) #ren.SetPreserveDepthBuffer(True) else: ren = kargs["renderer"] if gtype in ["boxfill","meshfill","isofill","isoline"]: self.plot2D(data1,data2,tpl,gm) elif gtype in ["3d_scalar", "3d_dual_scalar", "3d_vector"]: cdms_file = kargs.get( 'cdmsfile', None ) cdms_var = kargs.get( 'cdmsvar', None ) if not cdms_var is None: raise Exception() if not cdms_file is None: gm.addPlotAttribute( 'file', cdms_file ) gm.addPlotAttribute( 'filename', cdms_file ) gm.addPlotAttribute( 'url', cdms_file ) self.plot3D(data1,data2,tpl,gm,ren,**kargs) elif gtype in ["text"]: if tt.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,tt.priority) vcs2vtk.genTextActor(ren,to=to,tt=tt) elif gtype=="line": if gm.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,gm.priority) vcs2vtk.prepLine(self.renWin,ren,gm) elif gtype=="marker": if gm.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,gm.priority) vcs2vtk.prepMarker(self.renWin,ren,gm) elif gtype=="fillarea": if gm.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,gm.priority) vcs2vtk.prepFillarea(self.renWin,ren,gm) elif gtype=="1d": self.renWin.AddRenderer(ren) self.plot1D(data1,data2,tpl,gm,ren) elif gtype=="vector": self.plotVector(data1,data2,tpl,gm) else: raise Exception,"Graphic type: '%s' not re-implemented yet" % gtype if self.logo is None: self.createLogo() if self.renWin.GetSize()!=(0,0): self.scaleLogo() if not kargs.get("donotstoredisplay",False): self.renWin.Render()
def plot(self,data1,data2,template,gtype,gname,bg,*args,**kargs): self.numberOfPlotCalls+=1 if self.bg is None: if bg: self.bg= True else: self.bg= False created = self.createRenWin(**kargs) if created: self.initialSize() if self.bg: self.renWin.SetOffScreenRendering(True) self.renWin.SetSize(self.canvas.bgX,self.canvas.bgY) self.cell_coordinates=kargs.get( 'cell_coordinates', None ) #self.renWin.Render() #screenSize = self.renWin.GetScreenSize() if gtype in ["boxfill","meshfill","isoline","isofill","vector"]: data1 = self.trimData2D(data1) # Ok get only the last 2 dims if gtype!="meshfill": data2 = self.trimData2D(data2) #elif vcs.isgraphicsmethod(vcs.elements[gtype][gname]): ## oneD # data1 = self.trimData1D(data1) # data2 = self.trimData1D(data2) if gtype == "text": tt,to = gname.split(":::") tt = vcs.elements["texttable"][tt] to = vcs.elements["textorientation"][to] gm=tt else: gm = vcs.elements[gtype][gname] tpl = vcs.elements["template"][template] if kargs.get("renderer",None) is None: if ( gtype in ["3d_scalar", "3d_vector"] ) and (self.renderer <> None): ren = self.renderer else: ren = vtk.vtkRenderer() r,g,b = self.canvas.backgroundcolor ren.SetBackground(r/255.,g/255.,b/255.) if not (vcs.issecondaryobject(gm) and gm.priority==0): self.renderer = ren self.renWin.AddRenderer(ren) #ren.SetPreserveDepthBuffer(True) else: ren = kargs["renderer"] if gtype in ["boxfill","meshfill","isofill","isoline"]: self.plot2D(data1,data2,tpl,gm) elif gtype in ["3d_scalar", "3d_vector"]: cdms_file = kargs.get( 'cdmsfile', None ) cdms_var = kargs.get( 'cdmsvar', None ) if not cdms_var is None: raise Exception() if not cdms_file is None: gm.addPlotAttribute( 'file', cdms_file ) gm.addPlotAttribute( 'filename', cdms_file ) gm.addPlotAttribute( 'url', cdms_file ) self.plot3D(data1,data2,tpl,gm,ren,**kargs) elif gtype in ["text"]: if tt.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,tt.priority) vcs2vtk.genTextActor(ren,to=to,tt=tt) elif gtype=="line": if gm.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,gm.priority) vcs2vtk.prepLine(self.renWin,ren,gm) elif gtype=="marker": if gm.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,gm.priority) vcs2vtk.prepMarker(self.renWin,ren,gm) elif gtype=="fillarea": if gm.priority!=0: self.renWin.AddRenderer(ren) self.setLayer(ren,gm.priority) vcs2vtk.prepFillarea(self.renWin,ren,gm) elif gtype=="oned": self.renWin.AddRenderer(ren) self.plot1D(data1,data2,tpl,gm,ren) elif gtype=="vector": self.plotVector(data1,data2,tpl,gm) else: raise Exception,"Graphic type: '%s' not re-implemented yet" % gtype if not kargs.get("donotstoredisplay",False): self.renWin.Render()