def __autoSync( self, project, baseobj, offset ): # synchronize two similiar project files for obj in baseobj.objects: self.__autoSync( project, obj, offset ) if baseobj.typeNr in [TYPE_CASE, TYPE_VIEWPOINT_MGR, TYPE_PRESENTATION]: # don't synchronize these objects return for paramname in baseobj.params.__dict__: if not paramname in ["name", "colorTableKey"]: if( globalKeyHandler().hasKey(baseobj.key+offset) ): if hasattr( globalKeyHandler().getObject(baseobj.key+offset).params, paramname): if not (baseobj.key, paramname) in project.params.sync: project.params.sync[ (baseobj.key,paramname) ] = [] project.params.sync[ (baseobj.key,paramname) ].append( (baseobj.key+offset,paramname) ) if not (baseobj.key+offset, paramname) in project.params.sync: project.params.sync[ (baseobj.key+offset,paramname) ] = [] project.params.sync[ (baseobj.key+offset,paramname) ].append( (baseobj.key,paramname) ) # set synchronized parameters of appended project to parameters of "master" project globalKeyHandler().getObject(baseobj.key+offset).params.__dict__[paramname] = globalKeyHandler().getObject(baseobj.key).params.__dict__[paramname] # call sendParams to inform the GUI of a parameter change if( globalKeyHandler().hasKey(baseobj.key+offset) ): Neg2Gui.theNegMsgHandler().sendParams(baseobj.key + offset, globalKeyHandler().getObject(baseobj.key+offset).params)
def delete(self, isInitialized, negMsgHandler=None): if isInitialized: scgrMgr = globalKeyHandler().getObject( globalKeyHandler().globalSceneGraphMgrKey) if scgrMgr: # if no scgrMgr exists, it has already been deleted (no need to delete the key) scgrMgr.deleteKey(self.key) return VisItem.delete(self, isInitialized, negMsgHandler)
def recreate( self, msgHandler, aFilename, offset=0, replaceInPathList = [], reductionFactor=None, autoSync=False): auxName= os.path.basename(aFilename) self.name = auxName[0: auxName.rfind('.')] self.pathToCaseFile = os.path.dirname(aFilename) project = unpickleProjectFile(aFilename, replaceInPathList) msgHandler.setInRecreation(True) if offset==0: self.__project = project try: self.__project.recreate(msgHandler,-1, offset) except: # halt on every exception msgHandler.setInRecreation(False) self.__project.delete(False, msgHandler) # key handler should be deleted while recreate globalKeyHandler().delete() del self.__project raise self.__project.run(RUN_OCT, msgHandler) self.__project.run(RUN_ALL, msgHandler) else : self.__checkDuplicateCaseNames(project) project.recreate(msgHandler,-1, offset) if autoSync: self.__autoSync( self.__project, self.__project, offset) project.run(RUN_OCT, msgHandler) project.run(RUN_ALL, msgHandler) msgHandler.setInRecreation(False)
def change(self): # for change viewpoint send msg to COVER with ViewpointID # get COVER id of viewpoint for message id = -1 for key, param in self.params.status.items(): # viewpoints have parameter 'view', the viewpoint connected to this step is visible if hasattr(param, 'view') and hasattr(param, 'isVisible') and param.isVisible == True: id = param.id # send ChangeViewpointMsg if id != -1: msg = coGRChangeViewpointMsg( id ) covise.sendRendMsg(msg.c_str()) # find the number of all keys numkeys = len(globalKeyHandler().getAllElements()) if numkeys <1: # if that goes wrong, use only the keys in this step numkeys = self.key # walk through all keys, even if they are not allready in the step for key in range(numkeys): obj = globalKeyHandler().getObject(key) if obj: if not hasattr(obj.params, 'view') and objIsRelevant(obj): self.params.status[key] = CopyParams(obj.params)
def setParams( self, params, negMsgHandler=None, sendToCover=True): _infoer.function = str(self.setParams) _infoer.write(" ") self.sendImagePathToWebserver() realChange = ParamsDiff( self.params, params ) # make sure, variable change is removed from params again if hasattr(self.params, 'changed'): oldChanged = self.params.changed else: oldChanged = False VisItem.setParams(self, params) self.params.changed = oldChanged #if 'imageName' in realChange and sendToCover: # self.sendImageName() # self.sendPosition() # self.sendVisibility() if 'pageNo' in realChange and sendToCover: self.sendPageNo() if 'size' in realChange and sendToCover: self.sendSize() if 'scaling' in realChange and sendToCover: self.sendScaling() if 'pos' in realChange and sendToCover: self.sendPosition() # changed in realChange happens when doc is changed in gui if 'changed' in realChange: # tell the coPresentationMgr that doc has changed globalKeyHandler().getObject(globalPresentationMgrKey).documentChanged(self.params.documentName, self.params.pos, self.params.isVisible, self.params.scaling, self.params.size, negMsgHandler)
def change(self): # for change viewpoint send msg to COVER with ViewpointID # get COVER id of viewpoint for message id = -1 for key, param in self.params.status.items(): # viewpoints have parameter 'view', the viewpoint connected to this step is visible if hasattr(param, 'view') and hasattr( param, 'isVisible') and param.isVisible == True: id = param.id # send ChangeViewpointMsg if id != -1: msg = coGRChangeViewpointMsg(id) covise.sendRendMsg(msg.c_str()) # find the number of all keys numkeys = len(globalKeyHandler().getAllElements()) if numkeys < 1: # if that goes wrong, use only the keys in this step numkeys = self.key # walk through all keys, even if they are not allready in the step for key in range(numkeys): obj = globalKeyHandler().getObject(key) if obj: if not hasattr(obj.params, 'view') and objIsRelevant(obj): self.params.status[key] = CopyParams(obj.params)
def setReductionFactor(self, rf, negMsgHandler): if rf != self.params.reductionFactor: self.params.reductionFactor = rf for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key).typeNr in [TYPE_3D_PART, TYPE_2D_PART]: # set params for import, but dont execute globalKeyHandler().getObject(key).importModule.setReductionFactor(rf)
def setSelectionString(self, selectionString): if selectionString != self.params.selectionString: self.selectionString = selectionString for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key).typeNr in [TYPE_3D_PART, TYPE_2D_PART]: # set params for import, but dont execute globalKeyHandler().getObject(key).importModule.setSelectionString(selectionString)
def setCropMax(self, x, y, z): if self.params.cropMax != [x, y, z]: self.params.cropMax = [x, y, z] for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key).typeNr in [TYPE_3D_PART, TYPE_2D_PART]: # set params for import, but dont execute globalKeyHandler().getObject(key).importModule.setCropMax(x, y, z)
def moveSelectKey(self, key): """ selects a scene graph item and deselects a previous one """ objNewKey = globalKeyHandler().getObject(key) objOldKey = None if self.params.moveSelectedSceneGraphItemKey == None: msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = key elif self.params.moveSelectedSceneGraphItemKey == key: msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) else: objOldKey = globalKeyHandler().getObject( self.params.moveSelectedSceneGraphItemKey) # new key toggled to false, old key currently true -> comes from presentation-mgr, old key was toggled on before if objNewKey.params.isMoveSelected == False and objOldKey.params.isMoveSelected == True: pass # new key toggled to false, old key currently false -> comes from presentation-mgr or user. turn off normally elif objNewKey.params.isMoveSelected == False and objOldKey.params.isMoveSelected == False: msg = coGRObjSetMoveSelectedMsg( coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = None # new key toggled to true, old key currently true -> comes from presentation-mgr or user. turn on normally, deselect old key elif objNewKey.params.isMoveSelected == True and objOldKey.params.isMoveSelected == True: # deselect old key objOldKey.params.isMoveSelected = False objOldKey.sendParams() # tell COVER to deselect msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objOldKey.covise_key, False) covise.sendRendMsg(msg.c_str()) msg = coGRObjSetMoveSelectedMsg( coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = key # new key toggled to true, old key currently false -> comes from presentation-mgr or user. turn on normally elif objNewKey.params.isMoveSelected == True and objOldKey.params.isMoveSelected == False: msg = coGRObjSetMoveSelectedMsg( coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = key
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 getPartsBoundingBox(self): """ get the bounding box from all originally unfiltered/untransformed/unreduced/un... import modules """ box = Box( (0,0),(0,0),(0,0) ) for key in globalKeyHandler().getAllElements(): # get bounding box of all parts if globalKeyHandler().getObject(key) and globalKeyHandler().getObject(key).typeNr in [TYPE_3D_PART, TYPE_2D_PART]: tmpBB = globalKeyHandler().getObject(key).importModule.getBoxFromGeoRWCovise() box = box + tmpBB return box
def __init__(self): VisItem.__init__(self, VIS_VRML, self.__class__.__name__) self.params = VrmlVisParams() self.params.isVisible = True sgm = globalKeyHandler().getObject(globalKeyHandler().globalSceneGraphMgrKey) # immediately increase maximumIndex by at least 1, so if for some reason we don't get any SceneGraphItems, the next VrmlVis still uses another startIndex sgm.sceneGraphItems_maximumIndex = sgm.sceneGraphItems_maximumIndex + 1 self.params.sceneGraphItems_startIndex = sgm.sceneGraphItems_maximumIndex self.__initBase()
def setReductionFactor(self, rf, negMsgHandler): if rf != self.params.reductionFactor: self.params.reductionFactor = rf for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key).typeNr in [ TYPE_3D_PART, TYPE_2D_PART ]: # set params for import, but dont execute globalKeyHandler().getObject( key).importModule.setReductionFactor(rf)
def setCropMax(self, x, y, z): if self.params.cropMax != [x, y, z]: self.params.cropMax = [x, y, z] for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key).typeNr in [ TYPE_3D_PART, TYPE_2D_PART ]: # set params for import, but dont execute globalKeyHandler().getObject(key).importModule.setCropMax( x, y, z)
def setSelectionString(self, selectionString): if selectionString != self.params.selectionString: self.selectionString = selectionString for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key).typeNr in [ TYPE_3D_PART, TYPE_2D_PART ]: # set params for import, but dont execute globalKeyHandler().getObject( key).importModule.setSelectionString(selectionString)
def delete(self, isInitialized, negMsgHandler=None): if isInitialized: for key in list(globalKeyHandler().getAllElements().keys()): obj = globalKeyHandler().getObject(key) if obj: # remove composed parts containing this part as well if (obj.typeNr == TYPE_2D_COMPOSED_PART) and (self.key in obj.params.subKeys): obj.delete(isInitialized, negMsgHandler) if hasattr(self, "importModule") and self.importModule: self.importModule.delete() coKeydObject.delete(self, isInitialized, negMsgHandler)
def setParams( self, params, negMsgHandler=None, sendToCover=True): _infoer.function = str(self.setParams) _infoer.write("%s" % params.isVisible) if params.id == None: return realChange = ParamsDiff( self.params, params ) oldID = self.params.id if hasattr(self.params, 'confirmed'): oldConfirmed = self.params.confirmed else: oldConfirmed = True if hasattr(self.params, 'changed'): oldChanged = self.params.changed else: oldChanged = False VisItem.setParams(self, params, negMsgHandler, sendToCover) self.params.confirmed = oldConfirmed self.params.changed = oldChanged # confirmed and id in realChange happens when loading a project and having different default viewpoints if 'confirmed' in realChange and 'id' in realChange: self.params.confirmed = True if self.params.isVisible: self.show() # tell the coPresentationMgr that viewpoint is now confirmed and the id has changed globalKeyHandler().getObject(globalPresentationMgrKey).changeUnconfirmedViewpointID(oldID, params.id, negMsgHandler) else: if 'confirmed' in realChange: self.params.confirmed = True if self.params.isVisible: self.show() # tell the coPresentationMgr that viewpoint is confirmed globalKeyHandler().getObject(globalPresentationMgrKey).setViewpointConfirmed(params.id, negMsgHandler) if 'id' in realChange: # tell the presenterManager that my id has changed globalKeyHandler().getObject(globalPresentationMgrKey).changeViewPointID(oldID, params.id, negMsgHandler) if hasattr(self.params, 'delete'): self.delete(False, negMsgHandler) return if 'isVisible' in realChange and sendToCover and params.isVisible and hasattr(self.params, 'confirmed') and self.params.confirmed: _infoer.function = str(self.setParams) _infoer.write("send viewpoint") self.show() globalKeyHandler().getObject(self.parentKey).makeOthersInvisible(self, negMsgHandler) if 'name' in realChange and sendToCover: #send new name to cover msg = coGRChangeViewpointNameMsg( self.params.id, params.name ) covise.sendRendMsg(msg.c_str()) # changed in realChange happens when viewpoint is changed in gui if 'changed' in realChange: # tell the coPresentationMgr that obj has changed globalKeyHandler().getObject(globalPresentationMgrKey).viewpointChanged(self.params.id, self.params.view, negMsgHandler)
def delete(self, isInitialized, negMsgHandler=None): if isInitialized: for key in list(globalKeyHandler().getAllElements().keys()): obj = globalKeyHandler().getObject(key) if obj: # remove composed parts containing this part as well if (obj.typeNr == TYPE_3D_COMPOSED_PART) and ( self.key in obj.params.subKeys): obj.delete(isInitialized, negMsgHandler) if hasattr(self, "importModule") and self.importModule: self.importModule.delete() coKeydObject.delete(self, isInitialized, negMsgHandler)
def __init__(self): VisItem.__init__(self, VIS_VRML, self.__class__.__name__) self.params = VrmlVisParams() self.params.isVisible = True sgm = globalKeyHandler().getObject( globalKeyHandler().globalSceneGraphMgrKey) # immediately increase maximumIndex by at least 1, so if for some reason we don't get any SceneGraphItems, the next VrmlVis still uses another startIndex sgm.sceneGraphItems_maximumIndex = sgm.sceneGraphItems_maximumIndex + 1 self.params.sceneGraphItems_startIndex = sgm.sceneGraphItems_maximumIndex self.__initBase()
def getPartsBoundingBox(self): """ get the bounding box from all originally unfiltered/untransformed/unreduced/un... import modules """ box = Box((0, 0), (0, 0), (0, 0)) for key in globalKeyHandler().getAllElements(): # get bounding box of all parts if globalKeyHandler().getObject(key) and globalKeyHandler( ).getObject(key).typeNr in [TYPE_3D_PART, TYPE_2D_PART]: tmpBB = globalKeyHandler().getObject( key).importModule.getBoxFromGeoRWCovise() box = box + tmpBB return box
def updateForObject(self, key): self.__key = key scalar = ObjectMgr().getPossibleScalarVariablesForType(self.__key) vector = ObjectMgr().getPossibleVectorVariablesForType(self.__key) if covise.coConfigIsOn("vr-prepare.UseComposedVelocity", False): myObject = globalKeyHandler().getObject(key) while (myObject.typeNr == TYPE_2D_CUTGEOMETRY_PART): myObject = globalKeyHandler().getObject(myObject.parentKey) if (myObject.typeNr == TYPE_2D_COMPOSED_PART): scalar.append(COMPOSED_VELOCITY) self._setScalarVariables(scalar) self._setVectorVariables(vector) self.setGridName(ObjectMgr().getNameOfType(self.__key))
def updateForObject( self, key): self.__key = key scalar = ObjectMgr().getPossibleScalarVariablesForType(self.__key) vector = ObjectMgr().getPossibleVectorVariablesForType(self.__key) if covise.coConfigIsOn("vr-prepare.UseComposedVelocity", False): myObject = globalKeyHandler().getObject(key) while (myObject.typeNr == TYPE_2D_CUTGEOMETRY_PART): myObject = globalKeyHandler().getObject(myObject.parentKey) if (myObject.typeNr == TYPE_2D_COMPOSED_PART): scalar.append(COMPOSED_VELOCITY) self._setScalarVariables(scalar) self._setVectorVariables(vector) self.setGridName(ObjectMgr().getNameOfType(self.__key))
def getVectorVariablesIntersectionForType(self, key): myObject = globalKeyHandler().getObject(key) while (myObject.typeNr == TYPE_2D_CUTGEOMETRY_PART): myObject = globalKeyHandler().getObject(myObject.parentKey) intersection = [] if myObject and hasattr(myObject, 'importModule') and hasattr(myObject.importModule, 'getParts'): for curImportModule in myObject.importModule.getParts(): if hasattr(curImportModule, 'getPartCase'): partWithVars = curImportModule.getPartCase() if intersection == []: intersection = set( coviseCase.getVectorVariableNames(partWithVars) ) else: intersection = intersection & set( coviseCase.getVectorVariableNames(partWithVars) ) return list(intersection)
def delete(self, isInitialized, negMsgHandler=None): ''' delete this CoviseVis: remove the module ''' _infoer.function = str(self.delete) _infoer.write(" ") if isInitialized: # Manually remove the object from any parent object it is mounted to. # This is not very elegant because when an object (child) is deleted, the unmounting # done in OpenCOVER will send a removeChildMessage to the parent. However, because # it's a separate process, the child will already be fully deleted in vr-prepare # when receiving this message and the coverKey of the child is not known anymore. sceneObjects = [ obj for obj in globalKeyHandler().getAllElements().itervalues() if hasattr(obj, "typeNr") and (obj.typeNr == VIS_SCENE_OBJECT) ] for obj in sceneObjects: if self.key in obj.params.children: params = CopyParams(obj.params) params.children.remove(self.key) negMsgHandler.internalRecvParams(obj.key, params) negMsgHandler.sendParams(obj.key, params) self.sendDelete() theNet().remove(self.performerScene) VisItem.delete(self, isInitialized, negMsgHandler)
def setParamsByModule(self, mparam, mvalue): """ receives parameter changes from the iso surface module return a list of objKey and their parameters to be set by the Neg2Gui class """ _infoer.function = str(self.setParamsByModule) _infoer.write("param: %s, value: %s" % (mparam, str(mvalue))) pChangeList = [] newparams = CopyParams(self.params) if mparam == 'vector': newparams.vector = int(mvalue[0]) if mparam == 'isovalue': newparams.isomin = float(mvalue[0]) newparams.isomax = float(mvalue[1]) newparams.isovalue = float(mvalue[2]) pChangeList.append((self.key, newparams)) if mparam == 'isovalue': cTableObject = globalKeyHandler().getObject( self.params.colorTableKey[self.currentVariable()]) if cTableObject.params.baseMin != float( mvalue[0]) or cTableObject.params.baseMax != float( mvalue[1]): cTableObject.params.baseObjectName = self.params.name cTableObject.params.baseMin = float(mvalue[0]) cTableObject.params.baseMax = float(mvalue[1]) if self.key not in cTableObject.params.dependantKeys: cTableObject.params.dependantKeys.append(self.key) pChangeList.append((cTableObject.key, cTableObject.params)) return pChangeList
def setParamsByModule( self, mparam, mvalue): """ receives parameter changes from the iso surface module return a list of objKey and their parameters to be set by the Neg2Gui class """ _infoer.function = str(self.setParamsByModule) _infoer.write("param: %s, value: %s" % (mparam, str(mvalue))) pChangeList = [] newparams = CopyParams(self.params) if mparam == 'vector': newparams.vector = int(mvalue[0]) if mparam == 'isovalue': newparams.isomin = float(mvalue[0]) newparams.isomax = float(mvalue[1]) newparams.isovalue = float(mvalue[2]) pChangeList.append( (self.key, newparams) ) if mparam == 'isovalue': cTableObject = globalKeyHandler().getObject(self.params.colorTableKey[self.currentVariable()]) if cTableObject.params.baseMin != float(mvalue[0]) or cTableObject.params.baseMax != float(mvalue[1]): cTableObject.params.baseObjectName = self.params.name cTableObject.params.baseMin = float(mvalue[0]) cTableObject.params.baseMax = float(mvalue[1]) if self.key not in cTableObject.params.dependantKeys: cTableObject.params.dependantKeys.append(self.key) pChangeList.append( (cTableObject.key, cTableObject.params) ) return pChangeList
def recreate(self, negMsgHandler, parentKey, offset): coTrackingMgrParams.mergeDefaultParams(self.params) # explicitly call mergeDefaultParams of this class coKeydObject.recreate(self, negMsgHandler, parentKey, offset) globalKeyHandler().globalTrackingMgrKey = self.key self.__readButtonConfig() self.__setupTimeout() self.sendParamsToCover()
def __addSubPart(self, key, value=None): _infoer.function = str(self.setParams) _infoer.write("__addSubPart %s" % key) if self.importModule == None: self.importModule = ImportGroup2DModule() self.importModule.addImport( globalKeyHandler().getObject(key).importModule, value)
def recreate(self, negMsgHandler, parentKey, offset): self.__initBase() PartTransform.recreate(self, negMsgHandler, parentKey, offset) PartModuleVis.recreate(self, negMsgHandler, parentKey, offset, BoundingBox, ['GridIn0'],[],[],[],[],[],[]) if (self.params.name == "Part3DBoundingBoxVisParams") or (self.params.name == "BoundingBox"): # The name of Part3DBoundingBoxVis was never changed in previous versions. Copy it from parent if it's the default name. self.params.name = globalKeyHandler().getObject(parentKey).params.name
def addGenericParamFromRenderer(self, objectName, paramName, paramType, defaultValue): # create objects if nescessary parentKey = self.key currentPath = "" currentName = "" shrinkingPath = objectName while (shrinkingPath != ""): pos = shrinkingPath.find(".") if (pos > -1): currentName = shrinkingPath[0:pos] shrinkingPath = shrinkingPath[pos + 1:] else: currentName = shrinkingPath shrinkingPath = "" if (currentPath != ""): currentPath = currentPath + "." currentPath = currentPath + currentName if (currentPath in self.params.name2key): obj = globalKeyHandler().getObject( self.params.name2key[currentPath]) else: obj = Neg2Gui.theNegMsgHandler().internalRequestObject( TYPE_GENERIC_OBJECT, parentKey) obj.params.name = currentName obj.params.path = currentPath self.params.name2key[currentPath] = obj.key Neg2Gui.theNegMsgHandler().sendParams(obj.key, obj.params) parentKey = obj.key # add the param obj.addGenericParamFromRenderer(paramName, paramType, defaultValue)
def setCOVERParams(self, msg): """ setting the COVER params""" _infoer.function = str(self.setCOVERParams) _infoer.write("") #_infoer.write("%s" % msg) # if recreated file, we dont want to overwrite the parameters if (not self.__inRecreation): idStringFound = msg.find(SCENEGRAPH_PARAMS_STRING) if idStringFound > -1: """ Separating the message into a list of tuples [key ;; parentkey] """ key_list = msg.split('\t') del key_list[0] #idString del key_list[-1] #last tab for item in key_list: #split key from parent key itemlist = item.split(';;') key = itemlist[0] transparency = float(itemlist[1]) if (key in self.params.openCOVER2key): #set transparency for obj with key obj = globalKeyHandler().getObject( self.params.openCOVER2key[key]) if obj: obj.params.transparency = transparency obj.sendParams()
def addGenericParamFromRenderer(self, objectName, paramName, paramType, defaultValue): # create objects if nescessary parentKey = self.key currentPath = "" currentName = "" shrinkingPath = objectName while (shrinkingPath != ""): pos = shrinkingPath.find(".") if (pos > -1): currentName = shrinkingPath[0:pos] shrinkingPath = shrinkingPath[pos+1:] else: currentName = shrinkingPath shrinkingPath = "" if (currentPath != ""): currentPath = currentPath + "." currentPath = currentPath + currentName if (currentPath in self.params.name2key): obj = globalKeyHandler().getObject(self.params.name2key[currentPath]) else: obj = Neg2Gui.theNegMsgHandler().internalRequestObject( TYPE_GENERIC_OBJECT, parentKey) obj.params.name = currentName obj.params.path = currentPath self.params.name2key[currentPath] = obj.key Neg2Gui.theNegMsgHandler().sendParams(obj.key, obj.params ) parentKey = obj.key # add the param obj.addGenericParamFromRenderer(paramName, paramType, defaultValue)
def updateForObject( self, keys ): if isinstance( keys, int): self.__keys = [keys] else: self.__keys = keys # set the variables if len(self.__keys)==1 : # enable the visualization and the transform tab self.tabWidget.setTabEnabled(0, True) self.tabWidget.setTabEnabled(1, True) scalar = ObjectMgr().getPossibleScalarVariablesForType(self.__keys[0]) vector = ObjectMgr().getPossibleVectorVariablesForType(self.__keys[0]) if covise.coConfigIsOn("vr-prepare.UseComposedVelocity", False): myObject = globalKeyHandler().getObject(self.__keys[0]) if (myObject.typeNr == TYPE_3D_COMPOSED_PART): vector.append(COMPOSED_VELOCITY) self._setUnsetVariable(True) self._setScalarVariables(scalar) self._setVectorVariables(vector) self.setGridName(ObjectMgr().getNameOfType(self.__keys[0]) ) else : # multi selection # disable the visualization and the transform tab self.tabWidget.setTabEnabled(0, False) self.tabWidget.setTabEnabled(1, False) # apply params params = ObjectMgr().getParamsOfObject(self.__keys[0]) params.name = ObjectMgr().getNameOfType(self.__keys[0]) #if self.__key in Application.vrpApp.guiKey2visuKey: # params.isVisible = ObjectMgr().getParamsOfObject(Application.vrpApp.guiKey2visuKey[self.__key]).isVisible self.__setParams( params )
def delete(self, isInitialized, negMsgHandler=None): ''' delete this CoviseVis: remove the module ''' _infoer.function = str(self.delete) _infoer.write(" ") if isInitialized: # Manually remove the object from any parent object it is mounted to. # This is not very elegant because when an object (child) is deleted, the unmounting # done in OpenCOVER will send a removeChildMessage to the parent. However, because # it's a separate process, the child will already be fully deleted in vr-prepare # when receiving this message and the coverKey of the child is not known anymore. sceneObjects = [obj for obj in globalKeyHandler().getAllElements().itervalues() if hasattr(obj,"typeNr") and (obj.typeNr == VIS_SCENE_OBJECT)] for obj in sceneObjects: if self.key in obj.params.children: params = CopyParams(obj.params) params.children.remove(self.key) negMsgHandler.internalRecvParams( obj.key, params ) negMsgHandler.sendParams( obj.key, params ) self.sendDelete() theNet().remove(self.performerScene) VisItem.delete(self, isInitialized, negMsgHandler)
def setCOVERParams( self, msg): """ setting the COVER params""" _infoer.function = str(self.setCOVERParams) _infoer.write("") #_infoer.write("%s" % msg) # if recreated file, we dont want to overwrite the parameters if( not self.__inRecreation ): idStringFound = msg.find(SCENEGRAPH_PARAMS_STRING) if idStringFound >-1: """ Separating the message into a list of tuples [key ;; parentkey] """ key_list = msg.split('\t') del key_list[0] #idString del key_list[-1] #last tab for item in key_list: #split key from parent key itemlist = item.split(';;') key= itemlist[0] transparency = float(itemlist[1]) if (key in self.params.openCOVER2key): #set transparency for obj with key obj = globalKeyHandler().getObject(self.params.openCOVER2key[key]) if obj: obj.params.transparency = transparency obj.sendParams()
def __update(self, negMsgHandler): """ __update is called from the run method to update the module parameter before execution + do init if the cutting surface module if necessary + update module parameters """ self.__init(negMsgHandler) PartModuleVis._update(self, negMsgHandler) PartColoredVis._update(self, negMsgHandler) PartInteractorVis._update(self, negMsgHandler) # other parameters aRectangleIn3d1Mid1Norm = convertAlignedRectangleToCutRectangle( self.params.alignedRectangle) self._module.set_point(*aRectangleIn3d1Mid1Norm.point) self._module.set_vertex(*aRectangleIn3d1Mid1Norm.normal) self._module.set_option(1) self._module.set_vector(self.params.vector) if globalKeyHandler().getObject(self.params.colorTableKey[self.currentVariable()]).params.mode==coColorTableParams.LOCAL : self._module.set_autoScales('TRUE') else : self._module.set_autoScales('FALSE') self._module.setTitle( self.params.name ) # init params in case of arrows if hasattr(self.params, 'length'): self._module.set_length(self.params.length) if hasattr(self.params, 'scale'): self._module.set_scale(0.0, 1.0, self.params.scale) self._module.set_num_sectors(3) if hasattr(self.params, 'arrow_head_factor'): self._module.set_arrow_head_factor(self.params.arrow_head_factor) if hasattr(self.params, 'project_arrows'): self._module.set_project_lines(str(self.params.project_arrows))
def __update(self, negMsgHandler): """ __update is called from the run method to update the module parameter before execution + do init if the cutting surface module if necessary + update module parameters """ self.__init(negMsgHandler) PartModuleVis._update(self, negMsgHandler) PartColoredVis._update(self, negMsgHandler) PartInteractorVis._update(self, negMsgHandler) # other parameters aRectangleIn3d1Mid1Norm = convertAlignedRectangleToCutRectangle( self.params.alignedRectangle) self._module.set_point(*aRectangleIn3d1Mid1Norm.point) self._module.set_vertex(*aRectangleIn3d1Mid1Norm.normal) self._module.set_option(1) self._module.set_vector(self.params.vector) if globalKeyHandler().getObject( self.params.colorTableKey[self.currentVariable( )]).params.mode == coColorTableParams.LOCAL: self._module.set_autoScales('TRUE') else: self._module.set_autoScales('FALSE') self._module.setTitle(self.params.name) # init params in case of arrows if hasattr(self.params, 'length'): self._module.set_length(self.params.length) if hasattr(self.params, 'scale'): self._module.set_scale(0.0, 1.0, self.params.scale) self._module.set_num_sectors(3) if hasattr(self.params, 'arrow_head_factor'): self._module.set_arrow_head_factor(self.params.arrow_head_factor) if hasattr(self.params, 'project_arrows'): self._module.set_project_lines(str(self.params.project_arrows))
def __init__(self): VisItem.__init__(self, TYPE_SCENEGRAPH_MGR, 'SceneGraphMgr') globalKeyHandler().globalSceneGraphMgrKey = self.key self.params = coSceneGraphMgrParams() self.__inRecreation = False self.sceneGraphItems_maximumIndex = -1 global update_counter update_counter = -1
def recreate(self, negMsgHandler, parentKey, offset): coDNAMgrParams.mergeDefaultParams(self.params) # explicitly call mergeDefaultParams of this class # discard mapping from coprj, since we get different registered scene graph items from COVER #self.params.openCOVER2key = {} VisItem.recreate(self, negMsgHandler, parentKey, offset) globalKeyHandler().globalDNAMgrKey = self.key self.sendVisibility()
def getVectorVariablesIntersectionForType(self, key): myObject = globalKeyHandler().getObject(key) while (myObject.typeNr == TYPE_2D_CUTGEOMETRY_PART): myObject = globalKeyHandler().getObject(myObject.parentKey) intersection = [] if myObject and hasattr(myObject, 'importModule') and hasattr( myObject.importModule, 'getParts'): for curImportModule in myObject.importModule.getParts(): if hasattr(curImportModule, 'getPartCase'): partWithVars = curImportModule.getPartCase() if intersection == []: intersection = set( coviseCase.getVectorVariableNames(partWithVars)) else: intersection = intersection & set( coviseCase.getVectorVariableNames(partWithVars)) return list(intersection)
def moveSelectKey(self, key): """ selects a scene graph item and deselects a previous one """ objNewKey = globalKeyHandler().getObject(key) objOldKey = None if self.params.moveSelectedSceneGraphItemKey == None: msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = key elif self.params.moveSelectedSceneGraphItemKey == key: msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) else: objOldKey = globalKeyHandler().getObject(self.params.moveSelectedSceneGraphItemKey) # new key toggled to false, old key currently true -> comes from presentation-mgr, old key was toggled on before if objNewKey.params.isMoveSelected == False and objOldKey.params.isMoveSelected == True: pass # new key toggled to false, old key currently false -> comes from presentation-mgr or user. turn off normally elif objNewKey.params.isMoveSelected == False and objOldKey.params.isMoveSelected == False: msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = None # new key toggled to true, old key currently true -> comes from presentation-mgr or user. turn on normally, deselect old key elif objNewKey.params.isMoveSelected == True and objOldKey.params.isMoveSelected == True: # deselect old key objOldKey.params.isMoveSelected = False objOldKey.sendParams() # tell COVER to deselect msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objOldKey.covise_key, False) covise.sendRendMsg(msg.c_str()) msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = key # new key toggled to true, old key currently false -> comes from presentation-mgr or user. turn on normally elif objNewKey.params.isMoveSelected == True and objOldKey.params.isMoveSelected == False: msg = coGRObjSetMoveSelectedMsg(coGRMsg.SET_MOVE_SELECTED, objNewKey.covise_key, objNewKey.params.isMoveSelected) covise.sendRendMsg(msg.c_str()) self.params.moveSelectedSceneGraphItemKey = key
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): coKeydObject.__init__(self, TYPE_PRESENTATION_STEP, 'Presentation') self.params = coPresentationStepParams() # walk throgh all keys (assuming own key is last in list) for key in range(self.key): obj = globalKeyHandler().getObject(key) if obj: if objIsRelevant(obj): self.params.status[key] = CopyParams(obj.params)
def recreate(self, negMsgHandler, parentKey, offset): coDNAMgrParams.mergeDefaultParams( self.params) # explicitly call mergeDefaultParams of this class # discard mapping from coprj, since we get different registered scene graph items from COVER #self.params.openCOVER2key = {} VisItem.recreate(self, negMsgHandler, parentKey, offset) globalKeyHandler().globalDNAMgrKey = self.key self.sendVisibility()
def __init__(self): coKeydObject.__init__(self, TYPE_TRACKING_MGR, 'Tracking Manager') globalKeyHandler().globalTrackingMgrKey = self.key self.params = coTrackingMgrParams() self.name = self.params.name self.__readButtonConfig() self.__setupTimeout() self.sendParamsToCover()
def recreate(self, negMsgHandler, parentKey, offset): self.__inRecreation = True self.sceneGraphItems_maximumIndex = -1 coSceneGraphMgrParams.mergeDefaultParams(self.params) # explicitly call mergeDefaultParams of this class VisItem.recreate(self, negMsgHandler, parentKey, offset) globalKeyHandler().globalSceneGraphMgrKey = self.key global update_counter update_counter = -1 self.sendVisibility()
def recreate(self, negMsgHandler, parentKey, offset): self.__initBase() self.params.mergeDefaultParams() PartColoredVis.recreate(self, negMsgHandler, parentKey, offset) PartColoredVis.setColorMap(self,False) PartTransform.recreate(self, negMsgHandler, parentKey, offset) PartModuleVis.recreate(self, negMsgHandler, parentKey, offset, Collect, ['GridIn0'],[],[],[],[],[],[],1,False, False ) if (self.params.name == "Part2DRawVisParams") or (self.params.name == "Appearance"): # The name of Part2DRawVis was never changed in previous versions. Copy it from parent if it's the default name. self.params.name = globalKeyHandler().getObject(parentKey).params.name
def delete(self, isInitialized, negMsgHandler=None): if isInitialized: for key in list(globalKeyHandler().getAllElements().keys()): obj = globalKeyHandler().getObject(key) if obj: # remove composed parts containing this part as well if (obj.typeNr == TYPE_2D_COMPOSED_PART) and (self.key in obj.params.subKeys): obj.delete(isInitialized, negMsgHandler) # remove startFrom2DPart association if obj.typeNr in [VIS_STREAMLINE, VIS_MOVING_POINTS, VIS_PATHLINES] and (obj.params.use2DPartKey == self.key): newParams = CopyParams(obj.params) newParams.use2DPartKey = None obj.setParams(newParams) if negMsgHandler: negMsgHandler.sendParams(obj.key, newParams) obj.run(RUN_ALL, negMsgHandler) if hasattr(self, "importModule") and self.importModule: self.importModule.delete() coKeydObject.delete(self, isInitialized, negMsgHandler)
def __getCaseName(self): caseName = None key = self.parentKey #for i in range(3): while key >= 0 and caseName == None: parent = globalKeyHandler().getObject(key) if isinstance(parent, coCaseMgr.coCaseMgr): caseName = parent.params.name else: key = parent.parentKey return caseName
def recreate(self, negMsgHandler, parentKey, offset): self.__inRecreation = True self.sceneGraphItems_maximumIndex = -1 coSceneGraphMgrParams.mergeDefaultParams( self.params) # explicitly call mergeDefaultParams of this class VisItem.recreate(self, negMsgHandler, parentKey, offset) globalKeyHandler().globalSceneGraphMgrKey = self.key global update_counter update_counter = -1 self.sendVisibility()
def __getCaseName(self): caseName = None key = self.parentKey #for i in range(3): while key >= 0 and caseName==None: parent = globalKeyHandler().getObject(key) if isinstance(parent,coCaseMgr.coCaseMgr ): caseName = parent.params.name else : key = parent.parentKey return caseName
def __init__(self): #only for saving (has to be before coKeydObject.recreate because the KeyHandler will be deleted) self.__keyHandler = globalKeyHandler(None, True) coKeydObject.__init__(self, TYPE_PROJECT, 'Project') self.params = coProjectMgrParams() self.name = self.params.name # new projects already have latest coprj file format -> overwrite default coprjVersion=0 self.params.coprjVersion = coprjVersion.version self.params.originalCoprjVersion = coprjVersion.version