def testTransientReduceSetData(self): moduleCount = theNet().moduleCount() gip_core = self._TransientGroup() gip = ImportGroupReduceSet(gip_core) gip.setReductionFactor(2) value = 'Pressure' c = Colors() theNet().add(c) connect(gip.dataConnectionPoint(value), ConnectionPoint(c, 'Data')) coll = Collect() theNet().add(coll) connect(gip.geoConnectionPoint(), ConnectionPoint(coll, 'grid')) theNet().connect(c, 'texture', coll, 'textures') theNet().connect(coll, 'geometry', globalRenderer()._module, 'RenderData') gip.executeGeo() gip.executeData(value) (a, b) = gip.getDataMinMax(value) self.assertEqual((a, b), (-0.018360999999999999, 2.0)) # delete theNet().remove(c) theNet().remove(coll) gip.delete() gip_core.delete() self._RemoveImportGroupModules() self.assertEqual(theNet().moduleCount(), moduleCount)
def _update(self, negMsgHandler): ''' _update is called from the run method to update the module parameter before execution + do init the module if necessary update module parameters should be realized in the parent class''' self._init(negMsgHandler) if not hasattr(self, 'importModule'): return # update input # vec variable # vec variable is not changable from the Gui at the moment #scalar variable if not self._lastScalarConnection == None: for scalarInput in self._scalarInputNames: disconnect(self._lastScalarConnection, ConnectionPoint(self._module, scalarInput)) if hasattr(self.params, 'secondVariable') and len( self._scalarInputNames ) > 0 and not self.params.secondVariable == None: self.importModule.executeData(self.params.secondVariable) scalarInConnect = self.importModule.dataConnectionPoint( self.params.secondVariable) if scalarInConnect: for scalarInput in self._scalarInputNames: connect(scalarInConnect, ConnectionPoint(self._module, scalarInput)) self._lastScalarConnection = scalarInConnect # starting points from 2d part if not self._last2DPartConnection == None: part2D = globalKeyHandler().getObject(self.params.use2DPartKey) if not part2D or not self._last2DPartConnection == part2D.importModule.geoConnectionPoint( ): for partInput in self._2DPartInputNames: disconnect(self._last2DPartConnection, ConnectionPoint(self._module, partInput)) self._last2DPartConnection = None if len( self._2DPartInputNames ) > 0 and self.params.use2DPartKey != None and self.params.use2DPartKey >= 0 and self._last2DPartConnection == None: # sampling removed at the moment part2D = globalKeyHandler().getObject(self.params.use2DPartKey) part2D.importModule.executeGeo() for partInput in self._2DPartInputNames: connect(part2D.importModule.geoConnectionPoint(), ConnectionPoint(self._module, partInput)) if self._firstGeoForVars: self._firstGeoForVars = False #setTransform to module negMsgHandler.run(self.params.use2DPartKey) self._last2DPartConnection = part2D.importModule.geoConnectionPoint( ) self._module.setTitle(self.params.name)
def __init(self): """ start COVISE Module and connect output to COVER """ if self.__addAttribute == None: self.__addAttribute = AddAttribute() theNet().add(self.__addAttribute) self.__addAttribute.set_attrName("COLOR") addAttributeIn = ConnectionPoint(self.__addAttribute, 'inObject') self.__addAttributeOut = ConnectionPoint(self.__addAttribute, 'outObject') connect(self.importModule.geoConnectionPoint(), addAttributeIn) VisItem.connectToCover(self, self)
def __init(self): """ start COVISE modules and connect output to COVER """ if self.__colors == None and self.__collect == None: self.__colors = Colors() theNet().add(self.__colors) self.__colorsIn = ConnectionPoint(self.__colors, 'GridIn0') self.__collect = Collect() theNet().add(self.__collect) self.__collectOut = ConnectionPoint(self.__collect, 'GeometryOut0') connect(self.importModule.geoConnectionPoint(), ConnectionPoint(self.__collect, 'GridIn0')) VisItem.connectToCover(self, self)
def testGroupData(gip): value = 'Temperature' c = Colors() theNet().add(c) connect( gip.dataConnectionPoint(value), ConnectionPoint( c, 'Data' ) ) gip.executeData(value) coll = Collect() theNet().add(coll) connect( gip.geoConnectionPoint(value), ConnectionPoint( coll, 'grid' ) ) theNet().connect( c, 'texture', coll, 'textures' ) r = Renderer() theNet().add(r) theNet().connect( coll, 'geometry', r, 'RenderData') c.execute()
def connectionPoint(self): """ return the object to be displayed called by the class VisItem """ _infoer.function = str(self.connectionPoint) _infoer.write("") if self.coverDocument: return ConnectionPoint(self.coverDocument, 'Document')
def getBox(self, forceExecute = False): """ return the bounding box """ if self._bb==None: self._bb = BoundingBox() theNet().add( self._bb) connect( self.geoConnectionPoint(), ConnectionPoint( self._bb, 'GridIn0' ) ) # Clear info queue so we dont read a previous BB output. # (If something goes wrong with the queue, this could be the reason.) coviseStartup.globalReceiverThread.infoQueue.clear() if not self.executeGeo(): saveExecute(self._bb) boxParser = BoundingBoxParser() boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue) self._boundingBox = boxParser.getBox() elif forceExecute: # Clear info queue so we dont read a previous BB output. # (If something goes wrong with the queue, this could be the reason.) coviseStartup.globalReceiverThread.infoQueue.clear() if not self.executeGeo(): saveExecute(self._bb) boxParser = BoundingBoxParser() boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue) try: oldbb = self._boundingBox self._boundingBox = boxParser.getBox() except (ValueError): self._boundingBox = oldbb return self._boundingBox
def __init(self): """ start COVISE ReadCAD Module """ if self.__readCad == None: self.__readCad = ReadCAD() theNet().add(self.__readCad) self.__readCadPolyOut = ConnectionPoint(self.__readCad, 'mesh') self.__readCadNormalsOut = ConnectionPoint(self.__readCad, 'Normals') self.__readCadColorsOut = ConnectionPoint(self.__readCad, 'colorOut') self.__readCad.set_catia_server('obie') self.__readCad.set_catia_server_port('7000') self.__readCad.set_partIndex(self.__index) self.__readCad.set_file_path(self.__filename) self.__collect = Collect() theNet().add(self.__collect) connect(self.__readCadPolyOut, ConnectionPoint(self.__collect, 'GridIn0')) connect(self.__readCadNormalsOut, ConnectionPoint(self.__collect, 'DataIn1')) connect(self.__readCadColorsOut, ConnectionPoint(self.__collect, 'DataIn0')) self.__connectGeoOut = ConnectionPoint(self.__collect, 'GeometryOut0')
def _init(self, negMsgHandler, module, colorMapPortName = 'ColormapIn0'): '''_init is called from _update connect color map ''' # check if ColorCreator already exists if len(self.objects)==0: self._initColor(negMsgHandler) if len(self.objects)>0 and self.__colorMap: self._visualizerColorCP = ConnectionPoint(module, colorMapPortName) connect( (self.objects[0]).colorMapConnectionPoint(), self._visualizerColorCP )
def _initSample(self, varname=None, outside=USER_DEFINED): if self._sample==None: self._sample = Sample() theNet().add(self._sample) # connect( Import2DModule.geoConnectionPoint(self), ConnectionPoint(self._sample, 'GridIn') ) connect( ParentClass2D.geoConnectionPoint(self), ConnectionPoint(self._sample, 'GridIn') ) self._showgrid = ShowGrid() theNet().add(self._showgrid) connect( ConnectionPoint(self._sample, 'GridOut'), ConnectionPoint(self._showgrid, 'meshIn') ) sample = self._sample if not ParentClass2D.executeOct(self) and not ParentClass2D.executeData(self, varname): saveExecute(sample) # reconnect Sample # print "RECONNECTING 2D SAMPLE" theNet().disconnectAllFromModulePort(self._sample, 'GridIn') connect( ParentClass2D.geoConnectionPoint(self), ConnectionPoint(self._sample, 'GridIn') )
def testGroupData(self): moduleCount = theNet().moduleCount() gip = self._LargeSimpleGroup() value = 'Temperature' c = Colors() theNet().add(c) connect(gip.dataConnectionPoint(value), ConnectionPoint(c, 'Data')) coll = Collect() theNet().add(coll) connect(gip.geoConnectionPoint(), ConnectionPoint(coll, 'grid')) theNet().connect(c, 'texture', coll, 'textures') theNet().connect(coll, 'geometry', globalRenderer()._module, 'RenderData') gip.executeGeo() gip.executeData(value) # delete theNet().remove(c) theNet().remove(coll) gip.delete() self._RemoveImportGroupModules() self.assertEqual(theNet().moduleCount(), moduleCount)
def _initSample( self, varname, outside ): if not (varname,outside) in self._sample: self._sample[(varname,outside)] = Sample() theNet().add(self._sample[(varname,outside)]) self._bbox[(varname,USER_DEFINED)] = Box() self._bbox[(varname,MAX_FLT)] = Box() # connect( Import3DModule.geoConnectionPoint(self), ConnectionPoint(self._sample[(varname,outside)], 'GridIn') ) # connect( Import3DModule.dataConnectionPoint(self, varname), ConnectionPoint(self._sample[(varname,outside)], 'DataIn') ) connect( ParentClass3D.geoConnectionPoint(self), ConnectionPoint(self._sample[(varname,outside)], 'GridIn') ) connect( ParentClass3D.dataConnectionPoint(self, varname), ConnectionPoint(self._sample[(varname,outside)], 'DataIn') ) sample = self._sample[(varname,outside)] sample.set_outside(outside) if not ParentClass3D.executeOct(self) and not ParentClass3D.executeData(self, varname): saveExecute(sample) # reconnect Sample # print "RECONNECTING 3D SAMPLE" theNet().disconnectAllFromModulePort(self._sample[(varname,outside)], 'GridIn') theNet().disconnectAllFromModulePort(self._sample[(varname,outside)], 'DataIn') connect( ParentClass3D.geoConnectionPoint(self), ConnectionPoint(self._sample[(varname,outside)], 'GridIn') ) connect( ParentClass3D.dataConnectionPoint(self, varname), ConnectionPoint(self._sample[(varname,outside)], 'DataIn') )
def __update(self, negMsgHandler): """ __update is called from the run method to update the module parameter before execution + do init + update module parameters """ self.__init(negMsgHandler) PartModuleVis._update(self, negMsgHandler) if self.params.color==VARIABLE: PartColoredVis._update(self, negMsgHandler) self._setTransform() if not hasattr(self, 'importModule'): return #set color for variable if not self.__lastColorConnection==None: disconnect(self.__lastColorConnection, ConnectionPoint(self._module, 'DataIn0')) self.__lastColorConnection=None if self.__lastColorConnection==None and self.params.variable!=None \ and self.params.variable!='Select a variable' and self.params.color == VARIABLE and len(self.objects)>0: _infoer.function = str(self.__update) _infoer.write("connection color for variable %s " % self.params.variable) self.__lastColorConnection = (self.objects[0]).colorContConnectionPoint() connect(self.__lastColorConnection, ConnectionPoint(self._module, 'DataIn0'))
def getDataMinMax(self, variable): """ return min and max value of variable """ if variable==None: return if self._minMax==None: self._minMax = Colors() theNet().add(self._minMax) theNet().disconnectAllFromModulePort( self._minMax, 'DataIn0' ) connect(self.dataConnectionPoint(variable), ConnectionPoint(self._minMax, 'DataIn0')) self.executeData( variable ) saveExecute(self._minMax) return ( float(self._minMax.getParamValue('MinMax')[0]),\ float(self._minMax.getParamValue('MinMax')[1]) )
def getBoxFromGeoRWCovise(self): """ return the bounding box from the originally unfiltered geometry """ if self.__boundingBoxFromGeoRWCovise == None: self.__bbFromGeoRWCovise = BoundingBox() theNet().add(self.__bbFromGeoRWCovise) connect(self._geo.connectionPoint(), ConnectionPoint(self.__bbFromGeoRWCovise, 'GridIn0')) # Clear info queue so we dont read a previous BB output. # (If something goes wrong with the queue, this could be the reason.) coviseStartup.globalReceiverThread.infoQueue_.clear() saveExecute(self.__bbFromGeoRWCovise) boxParser = BoundingBoxParser() boxParser.parseQueue(coviseStartup.globalReceiverThread.infoQueue_) self.__boundingBoxFromGeoRWCovise = boxParser.getBox() return self.__boundingBoxFromGeoRWCovise
def _initOct(self): self._initGeo() if self._oct == None: # create or use disk-cached octtrees if enableCachedOctTrees == True and self._dim == 3: basename, extension = os.path.splitext(self._part.filename) self._octTreeFileName = basename + ".octtree" + extension print("self._octTreeFileName = ", self._octTreeFileName) if os.path.isfile(self._octTreeFileName) == False: # create disk-cached octtree self._octTreeFileExists = False self._oct = MakeOctTree() theNet().add(self._oct) self._octIn = ConnectionPoint(self._oct, 'inGrid') self._octOut = ConnectionPoint(self._oct, 'outOctTree') connect(self.geoConnectionPoint(), self._octIn) # connect RWCovise to MakeOctTree self._octTreeWriter = RWCovise() # writable theNet().add(self._octTreeWriter) self._octTreeWriter.set_grid_path(self._octTreeFileName) connect(self._octOut, ConnectionPoint(self._octTreeWriter, 'mesh_in')) else: # use disk-cached octtree self._octTreeFileExists = True self._oct = RWCovise() theNet().add(self._oct) self._oct.set_grid_path(self._octTreeFileName) # cached octtrees must never get an input connection (RWCovise!) self._octIn = None # ConnectionPoint(self._oct, 'mesh_in') self._octOut = ConnectionPoint(self._oct, 'mesh') else: self._oct = MakeOctTree() theNet().add(self._oct) self._octIn = ConnectionPoint(self._oct, 'inGrid') self._octOut = ConnectionPoint(self._oct, 'outOctTree') connect(self.geoConnectionPoint(), self._octIn) else: if enableCachedOctTrees == True and self._octTreeFileExists == True: # no reconnect necessary, if using disk-cached octtree pass else: # reconnect OctTree theNet().disconnectAllFromModulePort(self._oct, 'inGrid') connect(self.geoConnectionPoint(), self._octIn)
def connectionPoint(self): """ return the object to be displayed called by the class VisItem """ if self.performerScene: return ConnectionPoint(self.performerScene, 'model')
def connectionPoint(self): """ return the object to be displayed called by the class VisItem """ if self.performerScene: return ConnectionPoint(self.addAttribute, 'outObject')
def octConnectionPoint(self): self._initOct() self._octOut = ConnectionPoint(self._oct, 'outOctTree') connect(self.geoConnectionPoint(), ConnectionPoint(self._oct, 'inGrid')) return self._octOut
def boundingBoxConnectionPoint(self): self.getBox() return ConnectionPoint(self._bb, 'GridOut0')
def _init(self, negMsgHandler, sampleType=None): '''called from _update if module exists connect output of it to COVER ''' if not sampleType == None: self._sampleType = sampleType if self._module == None and hasattr( self, 'importModule') and self.__firstTime: self.__firstTime = False self._module = self._moduleName() theNet().add(self._module) # need to execute blockcollect for geo if type(self.importModule ) == ImportGroupManager.ImportGroup3DModule: self.importModule.executeGeo() for geoInput in self._geoInputNames: connect(self.importModule.geoConnectionPoint(), ConnectionPoint(self._module, geoInput)) if self.__createOcttree: if len(self._octtreeInputNames) > 0: for octtree in self._octtreeInputNames: connect(self.importModule.octTreeConnectionPoint(), ConnectionPoint(self._module, octtree)) self.importModule.executeOct() if (len(self._dataInputNames) > 0): if hasattr( self.params, 'variable' ) and self.params.variable and self.params.variable != 'Select a variable' and self.params.variable != 'unset': for dataInput in self._dataInputNames: connect( self.importModule.dataConnectionPoint( self.params.variable), ConnectionPoint(self._module, dataInput)) if len(self._geoSampleNames ) > 0 and not self.importModule.getIsTransient(): if hasattr( self.params, 'variable' ) and self.params.variable and self.params.variable != 'Select a variable' and self.params.variable != 'unset': assert self.params.variable != 'Select a variable' self.importModule.executeSampleData( self.params.variable, None, self._sampleType) for geoSample in self._geoSampleNames: connect( self.importModule.geoSampleConnectionPoint( self.params.variable, self._sampleType), ConnectionPoint(self._module, geoSample)) if len(self._dataSampleNames ) > 0 and not self.importModule.getIsTransient(): if hasattr( self.params, 'variable' ) and self.params.variable and self.params.variable != 'Select a variable' and self.params.variable != 'unset': assert self.params.variable != 'Select a variable' for dataSample in self._dataSampleNames: connect( self.importModule.dataSampleConnectionPoint( self.params.variable, self._sampleType), ConnectionPoint(self._module, dataSample)) self.reloadBBox() # optionally connect to COVER if not covise.coConfigIsOn("vr-prepare.InvisibleConnectToRenderer", True): # only connect to COVER if this visualizer really is visible if self.params.isVisible and not self.__connectedToCOVER: VisItem.connectToCover(self, self) self.__connectedToCOVER = True else: VisItem.connectToCover(self, self) self.__connectedToCOVER = True # refresh all connections as they might have changed if self._module != None and hasattr(self, 'importModule'): for geoInput in self._geoInputNames: theNet().disconnectAllFromModulePort( self._module, geoInput) # remove all connections at the inport connect(self.importModule.geoConnectionPoint(), ConnectionPoint(self._module, geoInput)) if self.__createOcttree: for octtree in self._octtreeInputNames: theNet().disconnectAllFromModulePort( self._module, octtree) # remove all connections at the inport connect(self.importModule.octTreeConnectionPoint(), ConnectionPoint(self._module, octtree)) if (len(self._dataInputNames) > 0): if hasattr( self.params, 'variable' ) and self.params.variable and self.params.variable != 'Select a variable' and self.params.variable != 'unset': for dataInput in self._dataInputNames: theNet().disconnectAllFromModulePort( self._module, dataInput) connect( self.importModule.dataConnectionPoint( self.params.variable), ConnectionPoint(self._module, dataInput)) if hasattr( self.params, 'variable' ) and self.params.variable and self.params.variable != 'Select a variable' and self.params.variable != 'unset': if self.params.variable != 'Select a variable' and not self.importModule.getIsTransient( ): for geoSample in self._geoSampleNames: theNet().disconnectAllFromModulePort( self._module, geoSample) connect( self.importModule.geoSampleConnectionPoint( self.params.variable, self._sampleType), ConnectionPoint(self._module, geoSample)) if hasattr( self.params, 'variable' ) and self.params.variable and self.params.variable != 'Select a variable' and self.params.variable != 'unset': if self.params.variable != 'Select a variable' and not self.importModule.getIsTransient( ): for dataSample in self._dataSampleNames: theNet().disconnectAllFromModulePort( self._module, dataSample) connect( self.importModule.dataSampleConnectionPoint( self.params.variable, self._sampleType), ConnectionPoint(self._module, dataSample)) self.reloadBBox() # connect to COVER if visible and wasnt done initially if self.params.isVisible and not self.__connectedToCOVER: VisItem.connectToCover(self, self) self.__connectedToCOVER = True
def connectionPoint(self, outputName='GeometryOut0'): ''' return the object to be displayed the parent class is called by the class VisItem parentClass connectionPoint should call this funtion''' if self._module: return ConnectionPoint(self._module, outputName)
def geoSampleConnectionPoint(self, varname=None, outside=USER_DEFINED): if not covise.coConfigIsOn("vr-prepare.UseSamplingModules", False): return self._initSample(varname, outside) return ConnectionPoint(self._showgrid, 'points')
def dataSampleConnectionPoint(self, varname=None, outside=USER_DEFINED): if not covise.coConfigIsOn("vr-prepare.UseSamplingModules", False): return self._initSample( varname, outside) return ConnectionPoint(self._sample[(varname,outside)], 'DataOut')
def setParams( self, params, negMsgHandler=None, sendToCover=True): """ set parameters from outside + init tracer module if necessary + mainly receive parameter changes from Gui + send status messages to COVER if state has changed """ _infoer.function = str(self.setParams) _infoer.write(" ") # save the old variable to delete from colorTable oldVariable = self.currentVariable() oldTable = None if oldVariable!=None and oldVariable!= 'Select a variable': if hasattr(self.params.colorTableKey, oldVariable): oldTable = globalKeyHandler().getObject(self.params.colorTableKey[oldVariable]) realChange = ParamsDiff( self.params, params ) PartModuleVis.setParams(self, params, negMsgHandler, sendToCover, realChange) if self.params.color == VARIABLE: PartColoredVis.setParams(self, params, negMsgHandler, sendToCover, realChange) PartTransform.setParams(self, params, negMsgHandler, sendToCover, realChange) needsTransparency = False needsShader = False if hasattr (params, 'color') and (params.color == NO_COLOR) \ and ('color' in realChange): # disconnect colors module and run the collect module # (we dont want to call run since we dont need the children to be executed) if not self.__lastColorConnection==None: disconnect(self.__lastColorConnection, ConnectionPoint(self._module, 'DataIn0')) self.__lastColorConnection=None PartModuleVis.run(self, RUN_ALL, negMsgHandler) needsTransparency = True elif hasattr (params, 'color') and (params.color==RGB_COLOR) \ and (('color' in realChange) or ('r' in realChange) or ('g' in realChange) or ('b' in realChange)): self.__sendColor() needsTransparency = True elif hasattr (params, 'color') and (params.color==MATERIAL) \ and (('color' in realChange) or ('r' in realChange) or ('g' in realChange) or ('b' in realChange) \ or ('ambient' in realChange) or ('specular' in realChange) or ('shininess' in realChange)): self.__sendMaterial() needsTransparency = True elif hasattr(params, 'transparency') and ('transparency' in realChange): needsTransparency = True if 'variable' in realChange: # if variable changed append key to colorTable dependant keys # make sure this part is updated if colormap changes if params.variable!=None and params.variable!= 'Select a variable' and params.color == VARIABLE: # delete key from old colorTable if not oldTable == None and self.key in oldTable.params.dependantKeys: oldTable.params.dependantKeys.remove(self.key) # add key to new colorTable cTableObject = globalKeyHandler().getObject(params.colorTableKey[params.variable]) params.baseObjectName = params.name if self.key not in cTableObject.params.dependantKeys: cTableObject.params.dependantKeys.append(self.key) if negMsgHandler: negMsgHandler.internalRecvParams( cTableObject.key, cTableObject.params ) negMsgHandler.sendParams( cTableObject.key, cTableObject.params ) if ('shaderFilename' in realChange): needsTransparency = True needsShader = True # always send transparency before shader: # sendTransparency will ignore any shader transparency but sendShader respects the regular transparency if possible if needsTransparency and (params.shaderFilename != ""): needsShader = True if needsTransparency: self.__sendTransparency() if needsShader: self.__sendShader()
def connectionPoint(self): """ return the connection (module/outport) to be connected to COVER called by the class VisItem """ return ConnectionPoint(self.__myCollect, 'GeometryOut0')
def connectionPoint(self): """ return the object to be displayed called by the class VisItem """ if self.rwCovise: return ConnectionPoint(self.rwCovise, 'mesh')