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 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 changeGenericParamFromRenderer(self, paramName, value): self.params.gpValues[paramName] = self.__toCorrectType(value, self.params.gpTypes[paramName]) # send to GUI Neg2Gui.theNegMsgHandler().sendParams(self.key, self.params ) # set NEXT_PRES_STEP_ALLOWED if (paramName == NEXT_PRES_STEP_ALLOWED): self.params.nextPresStep = self.__toCorrectType(value, PARAM_TYPE_BOOL)
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 changeGenericParamFromRenderer(self, paramName, value): self.params.gpValues[paramName] = self.__toCorrectType( value, self.params.gpTypes[paramName]) # send to GUI Neg2Gui.theNegMsgHandler().sendParams(self.key, self.params) # set NEXT_PRES_STEP_ALLOWED if (paramName == NEXT_PRES_STEP_ALLOWED): self.params.nextPresStep = self.__toCorrectType( value, PARAM_TYPE_BOOL)
def setReductionFactor(self, reduction): self.redFactor = reduction if reduction: self.importModule.setReductionFactor(-1) Neg2Gui.theNegMsgHandler().internalRecvReductionFactor( self.importModule.getReductionFactor(), self.importModule.getNumTimeSteps()) Neg2Gui.theNegMsgHandler().internalRecvReductionFactor( None, self.importModule.getNumTimeSteps())
def __init(self): # key which is defined by COVER self.covise_key = 'No key' # the module that can check if a covise_key is created by this VisItem self.__creationModule = None # the module that writes the covise object into a file for testing self.__debugRwModule = None # register ui action Neg2Gui.theNegMsgHandler().registerVisItem(self)
def _sendMatrix(self): return if self.covise_key == 'No key': return if not hasattr(self.params, 'rotX'): return if self.params.rotX==0.0 and self.params.rotY==0.0 and self.params.rotZ==0.0 and \ self.params.transX==0.0 and self.params.transY==0.0 and self.params.transZ==0.0 and \ self.params.scaleX==0.0 and self.params.scaleY==0.0 and self.params.scaleZ==0.0: return matrix = transformationMatrix(self.params) # transform the bbox and send to children bbox = self.importModule.getBox() bboxVec1 = [bbox.getXMin(), bbox.getYMin(), bbox.getZMin()] bboxVec2 = [bbox.getXMax(), bbox.getYMax(), bbox.getZMax()] if not (self.params.rotX == 0.0 and self.params.rotY == 0.0 and self.params.rotZ == 0.0): mat = numpy.array(matrix[0:3, 0:3]) bboxVec1 = multMatVec(mat, bboxVec1) bboxVec2 = multMatVec(mat, bboxVec2) #sort vecs min/max if bboxVec1[0] > bboxVec2[0]: tmp = bboxVec1[0] bboxVec1[0] = bboxVec2[0] bboxVec2[0] = tmp if bboxVec1[1] > bboxVec2[1]: tmp = bboxVec1[1] bboxVec1[1] = bboxVec2[1] bboxVec2[1] = tmp if bboxVec1[2] > bboxVec2[2]: tmp = bboxVec1[2] bboxVec1[2] = bboxVec2[2] bboxVec2[2] = tmp if not (self.params.transX == 0.0 and self.params.transY == 0.0 and self.params.transZ == 0.0): bboxVec1[0] = bboxVec1[0] + self.params.transX bboxVec2[0] = bboxVec2[0] + self.params.transX bboxVec1[1] = bboxVec1[1] + self.params.transY bboxVec2[1] = bboxVec2[1] + self.params.transY bboxVec1[2] = bboxVec1[2] + self.params.transZ bboxVec2[2] = bboxVec2[2] + self.params.transZ bbox.setXMinMax([bboxVec1[0], bboxVec2[0]]) bbox.setYMinMax([bboxVec1[1], bboxVec2[1]]) bbox.setZMinMax([bboxVec1[2], bboxVec2[2]]) Neg2Gui.theNegMsgHandler().sendBBox(self.key, bbox) # send transformation to COVER msg = coGRObjTransformMsg(self.covise_key, *numpy.reshape(matrix, (16, ))) covise.sendRendMsg(msg.c_str())
def registerCOVISEkey( self, covise_keys): """ called during registration if key received from COVER """ _infoer.function = str(self.registerCOVISEkey) _infoer.write("")#for printout #_infoer.write("%s" % covise_key) """ looking for the prefix DNA_ID_STRING """ coviseKeyFound = covise_keys.find(DNA_ID_STRING) if coviseKeyFound >-1: """ Separating the message into a list of tuples [key ;; parentkey] """ key_list = covise_keys.split('\t') del key_list[0] for relation in key_list: """ split key from parent key """ keys = relation.split(';;') covise_key = keys[0] if len(keys) > 1: if not covise_key in self.params.openCOVER2key: parent_key = keys[1] """ Attach to parent if found """ if parent_key in self.params.openCOVER2key: obj = Neg2Gui.theNegMsgHandler().internalRequestObject( TYPE_DNA_ITEM, self.params.openCOVER2key[parent_key], None) else: obj = Neg2Gui.theNegMsgHandler().internalRequestObject( TYPE_DNA_ITEM, self.key, None) obj.covise_key = covise_key self.params.openCOVER2key[ covise_key ] = obj.key """ cutting of suffix string for GUI """ #suffix_found = covise_key.find("_OUT"); obj.params.name = re.sub(r'_' + DNA_APPENDIX_ID_STRING + '_\d+$', '', covise_key) # covise_key obj.sendParams() else: #### for recreate obj = globalKeyHandler().getObject(self.params.openCOVER2key[covise_key]) obj.covise_key = covise_key # send to COVER obj.sendTransformation() obj.sendVisibility() for conn in obj.params.connectionPoints: obj.sendConnections(conn, [obj.params.connectionPoints[conn],obj.params.connectionPointsDisable[conn]]) # send to GUI obj.sendParams() return (True, True) return (False, False)
def _sendMatrix(self): return if self.covise_key == 'No key': return if not hasattr( self.params, 'rotX'): return if self.params.rotX==0.0 and self.params.rotY==0.0 and self.params.rotZ==0.0 and \ self.params.transX==0.0 and self.params.transY==0.0 and self.params.transZ==0.0 and \ self.params.scaleX==0.0 and self.params.scaleY==0.0 and self.params.scaleZ==0.0: return matrix = transformationMatrix(self.params) # transform the bbox and send to children bbox = self.importModule.getBox() bboxVec1 = [bbox.getXMin(), bbox.getYMin(), bbox.getZMin()] bboxVec2 = [bbox.getXMax(), bbox.getYMax(), bbox.getZMax()] if not (self.params.rotX==0.0 and self.params.rotY==0.0 and self.params.rotZ==0.0): mat = numpy.array(matrix[0:3,0:3]) bboxVec1 = multMatVec(mat, bboxVec1) bboxVec2 = multMatVec(mat, bboxVec2) #sort vecs min/max if bboxVec1[0] > bboxVec2[0]: tmp = bboxVec1[0] bboxVec1[0] = bboxVec2[0] bboxVec2[0] = tmp if bboxVec1[1] > bboxVec2[1]: tmp = bboxVec1[1] bboxVec1[1] = bboxVec2[1] bboxVec2[1] = tmp if bboxVec1[2] > bboxVec2[2]: tmp = bboxVec1[2] bboxVec1[2] = bboxVec2[2] bboxVec2[2] = tmp if not (self.params.transX==0.0 and self.params.transY==0.0 and self.params.transZ==0.0): bboxVec1[0] = bboxVec1[0] + self.params.transX bboxVec2[0] = bboxVec2[0] + self.params.transX bboxVec1[1] = bboxVec1[1] + self.params.transY bboxVec2[1] = bboxVec2[1] + self.params.transY bboxVec1[2] = bboxVec1[2] + self.params.transZ bboxVec2[2] = bboxVec2[2] + self.params.transZ bbox.setXMinMax([bboxVec1[0], bboxVec2[0]]) bbox.setYMinMax([bboxVec1[1], bboxVec2[1]]) bbox.setZMinMax([bboxVec1[2], bboxVec2[2]]) Neg2Gui.theNegMsgHandler().sendBBox(self.key, bbox) # send transformation to COVER msg = coGRObjTransformMsg(self.covise_key, *numpy.reshape(matrix, (16,))) covise.sendRendMsg(msg.c_str())
def addGenericParamFromRenderer(self, paramName, paramType, defaultValue): # add param or update param if nescessary self.params.gpTypes[paramName] = paramType self.params.gpDefaultValues[paramName] = self.__toCorrectType(defaultValue, paramType) if paramName in self.params.gpValues: self.sendParamChangeToCover(paramName) # if we already know this param, we send the current value back to Cover else: self.params.gpValues[paramName] = self.params.gpDefaultValues[paramName] # if the param is new, we use the default value # send to GUI Neg2Gui.theNegMsgHandler().sendParams(self.key, self.params ) # set NEXT_PRES_STEP_ALLOWED if (paramName == NEXT_PRES_STEP_ALLOWED): self.params.nextPresStep = self.__toCorrectType(defaultValue, PARAM_TYPE_BOOL)
def init( self, partcase, reductionFactor=None ): self.importModule = ImportSample2DModule( partcase ) varNotFound = self.importModule.readPartcase() for var in varNotFound: Neg2Gui.theNegMsgHandler().raiseVariableNotFound(var) self.params.partcase = partcase if reductionFactor!=None: self.setReductionFactor(reductionFactor) if self.importModule.getIsTransient(): Neg2Gui.theNegMsgHandler().sendIsTransient(True) if not self.redFactor: return False #else: #Neg2Gui.theNegMsgHandler().sendIsTransient(False) return True
def init( self, partcase, reductionFactor=None ): self.importModule = ImportSample3DModule( partcase ) varNotFound = self.importModule.readPartcase() for var in varNotFound: Neg2Gui.theNegMsgHandler().raiseVariableNotFound(var) if reductionFactor!=None: self.setReductionFactor(reductionFactor) # need for composed grid - otherwise the order of modules is wrong self.importModule.geoConnectionPoint() self.params.partcase = partcase if self.importModule.getIsTransient(): Neg2Gui.theNegMsgHandler().sendIsTransient(True) if not self.redFactor: return False #else: #Neg2Gui.theNegMsgHandler().sendIsTransient(False) return True
def init(self, partcase, reductionFactor=None): self.importModule = ImportSample3DModule(partcase) varNotFound = self.importModule.readPartcase() for var in varNotFound: Neg2Gui.theNegMsgHandler().raiseVariableNotFound(var) if reductionFactor != None: self.setReductionFactor(reductionFactor) # need for composed grid - otherwise the order of modules is wrong self.importModule.geoConnectionPoint() self.params.partcase = partcase if self.importModule.getIsTransient(): Neg2Gui.theNegMsgHandler().sendIsTransient(True) if not self.redFactor: return False #else: #Neg2Gui.theNegMsgHandler().sendIsTransient(False) return True
def addGenericParamFromRenderer(self, paramName, paramType, defaultValue): # add param or update param if nescessary self.params.gpTypes[paramName] = paramType self.params.gpDefaultValues[paramName] = self.__toCorrectType( defaultValue, paramType) if paramName in self.params.gpValues: self.sendParamChangeToCover( paramName ) # if we already know this param, we send the current value back to Cover else: self.params.gpValues[paramName] = self.params.gpDefaultValues[ paramName] # if the param is new, we use the default value # send to GUI Neg2Gui.theNegMsgHandler().sendParams(self.key, self.params) # set NEXT_PRES_STEP_ALLOWED if (paramName == NEXT_PRES_STEP_ALLOWED): self.params.nextPresStep = self.__toCorrectType( defaultValue, PARAM_TYPE_BOOL)
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 sendChildren(self): """ send list of children to plugin """ if not self.covise_key=='No key': for childKey in self.params.children: covise_key_child = Neg2Gui.theNegMsgHandler().internalRequestObjectCoviseKey(childKey) if covise_key_child == 'No key': child = globalKeyHandler().getObject(childKey) if child: child.parentCoviseKeyToSend = self.covise_key else: msg = coGRObjAddChildMsg( self.covise_key, covise_key_child, 0) covise.sendRendMsg(msg.c_str())
def __update(self): """ __update is called from the run method to update the module parameter before execution + update module parameters """ if self.performerScene == None: self.performerScene = PerformerScene() theNet().add(self.performerScene) self.addAttribute = AddAttribute() theNet().add(self.addAttribute) theNet().connect(self.performerScene, 'model', self.addAttribute, 'inObject') # we dont get a register message for some filetypes so dont expect one! if self.params.filename.split(".")[-1].lower() in [ "via", "vim", "vis", # Molecules Plugin "dyn", "geoall", "str", "sensor" # VRAnim Plugin ]: Neg2Gui.theGrMsgHandler().decreaseNumVisItemsToBeRegistered() # update params self.performerScene.set_modelPath(self.params.filename) self.performerScene.set_scale(self.params.scale) if (self.params.backface == True): self.performerScene.set_backface('TRUE') else: self.performerScene.set_backface('FALSE') if (self.params.orientation_iv == True): self.performerScene.set_orientation_iv('TRUE') else: self.performerScene.set_orientation_iv('FALSE') if (self.params.convert_xforms_iv == True): self.performerScene.set_convert_xforms_iv('TRUE') else: self.performerScene.set_convert_xforms_iv('FALSE') # add attribute self.addAttribute.set_attrName('SCENEGRAPHITEMS_STARTINDEX') self.addAttribute.set_attrVal( str(self.params.sceneGraphItems_startIndex))
def __update(self): """ __update is called from the run method to update the module parameter before execution + update module parameters """ if self.performerScene == None: self.performerScene = PerformerScene() theNet().add(self.performerScene) self.addAttribute = AddAttribute() theNet().add(self.addAttribute) theNet().connect(self.performerScene, "model", self.addAttribute, "inObject") # we dont get a register message for some filetypes so dont expect one! if self.params.filename.split(".")[-1].lower() in [ "via", "vim", "vis", # Molecules Plugin "dyn", "geoall", "str", "sensor", # VRAnim Plugin ]: Neg2Gui.theGrMsgHandler().decreaseNumVisItemsToBeRegistered() # update params self.performerScene.set_modelPath(self.params.filename) self.performerScene.set_scale(self.params.scale) if self.params.backface == True: self.performerScene.set_backface("TRUE") else: self.performerScene.set_backface("FALSE") if self.params.orientation_iv == True: self.performerScene.set_orientation_iv("TRUE") else: self.performerScene.set_orientation_iv("FALSE") if self.params.convert_xforms_iv == True: self.performerScene.set_convert_xforms_iv("TRUE") else: self.performerScene.set_convert_xforms_iv("FALSE") # add attribute self.addAttribute.set_attrName("SCENEGRAPHITEMS_STARTINDEX") self.addAttribute.set_attrVal(str(self.params.sceneGraphItems_startIndex))
def sendChildren(self): """ send list of children to plugin """ if not self.covise_key == 'No key': for childKey in self.params.children: covise_key_child = Neg2Gui.theNegMsgHandler( ).internalRequestObjectCoviseKey(childKey) if covise_key_child == 'No key': child = globalKeyHandler().getObject(childKey) if child: child.parentCoviseKeyToSend = self.covise_key else: msg = coGRObjAddChildMsg(self.covise_key, covise_key_child, 0) covise.sendRendMsg(msg.c_str())
def sendParams(self): """ send Params to Gui """ Neg2Gui.theNegMsgHandler().sendParams(self.key, self.params)
def registerCOVISEkey(self, covise_keys): """ called during registration if key received from COVER """ _infoer.function = str(self.registerCOVISEkey) _infoer.write("") #for printout #_infoer.write("%s" % covise_key) """ looking for the prefix SCENEGRAPH_ID_STRING """ coviseKeyFound = covise_keys.find(SCENEGRAPH_ID_STRING) if coviseKeyFound == -1: return (False, False) # Separating the message into a list of lists [[key, nodeClass, parentkey], ...] key_list = covise_keys.split('\t') del key_list[0] # idString relations = [s.split(";;") for s in key_list if s.count(";;") == 2] ####################################################################################### # UPDATE OLD PROJECTS (part 1/2: delete old objects and remember params) update = ( globalKeyHandler().getObject(globalProjectKey).params.coprjVersion < 2) global update_counter if update and (update_counter == -1 ): # do just once for all SceneGraphMgr registrations print("Updating SceneGraphItems") update_counter = 0 # prepare global update_oldindex2params update_oldindex2params = {} global update_oldindex2params_steps update_oldindex2params_steps = {} # store params for coverkey, key in iter(self.params.openCOVER2key.items()): oldindex = int(coverkey[coverkey.rfind("_") + 1:]) update_oldindex2params[oldindex] = CopyParams( globalKeyHandler().getObject(key).params) for step in globalKeyHandler().getObject( globalPresentationMgrKey).objects: if not step in update_oldindex2params_steps: update_oldindex2params_steps[step] = {} if key in step.params.status: update_oldindex2params_steps[step][ oldindex] = CopyParams(step.params.status[key]) else: update_oldindex2params_steps[step][oldindex] = None # delete objects for key in self.params.openCOVER2key.values(): obj = globalKeyHandler().getObject(key) if obj: obj.delete(True, Neg2Gui.theNegMsgHandler()) # create set of parents global update_setOfParents update_setOfParents = frozenset([r[2] for r in relations]) ####################################################################################### isRoot = True for relation in relations: __covise_key = relation[0] __covise_name = __covise_key[0:__covise_key. find("_" + SCENEGRAPH_APPENDIX_ID_STRING + "_")] __covise_index = int(__covise_key[__covise_key.rfind("_") + 1:]) __classname = relation[1] __parent_covise_key = relation[2] if (__covise_name != "") and ( __covise_name + "_" + SCENEGRAPH_APPENDIX_ID_STRING + "_" + str(__covise_index) != __covise_key): # we add a * if a node was sent multiple times ("Example_SCGR_07_SCGR_09" -> index is 09, name should be "Example *") __covise_name = __covise_name + " *" self.sceneGraphItems_maximumIndex = max( self.sceneGraphItems_maximumIndex, __covise_index) if not __covise_key in self.params.openCOVER2key: # attach to parent if found (to the corresponding VRML_VIS otherwise) if __parent_covise_key in self.params.openCOVER2key: parentKey = self.params.openCOVER2key[__parent_covise_key] else: parentKey = self.key allVrmlVis = [] for item in globalKeyHandler().getAllElements(): parentObj = globalKeyHandler().getObject(item) if (parentObj.typeNr == VIS_VRML): allVrmlVis.append(item) if (len(allVrmlVis) > 0): parentKey = allVrmlVis[-1] if update: # in old projects: get the first VRML without children as fallback for i in allVrmlVis: if (len(globalKeyHandler().getObject( i).objects) == 0): parentKey = i break # then use the name to identify the VRML for i in allVrmlVis: if __covise_name in globalKeyHandler( ).getObject(i).params.name: parentKey = i break else: # in new projects: simply use the index to identify the VRML for i in allVrmlVis: if (globalKeyHandler().getObject( i).params.sceneGraphItems_startIndex == __covise_index): parentKey = i break obj = Neg2Gui.theNegMsgHandler().internalRequestObject( TYPE_SCENEGRAPH_ITEM, parentKey, None) obj.covise_key = __covise_key self.params.openCOVER2key[__covise_key] = obj.key ####################################################################################### # UPDATE OLD PROJECTS (part 2/2: use old params) if update: # get old index oldindex = -1 if (update_counter in update_oldindex2params) and ( isRoot or ((__covise_name != "") and (__covise_key in update_setOfParents))): oldindex = update_counter update_counter = update_counter + 1 # use existing params if (oldindex != -1): obj.setParams(update_oldindex2params[oldindex]) obj.sendAfterRecreate( ) # send to COVER (since we are using stored params for our new object) # copy coloring options from parent (since we now have the Geode and want the information there) if (__classname == "Geode"): parentObj = globalKeyHandler().getObject(parentKey) if parentObj and isinstance(parentObj, coSceneGraphItem): params = CopyParams(obj.params) params.transparency = parentObj.params.transparency params.transparencyOn = parentObj.params.transparencyOn params.color = parentObj.params.color params.r = parentObj.params.r params.g = parentObj.params.g params.b = parentObj.params.b params.ambient = parentObj.params.ambient params.specular = parentObj.params.specular params.shininess = parentObj.params.shininess obj.setParams(params) obj.sendAfterRecreate( ) # send to COVER (since we are using stored params for our new object) # add params to presentation steps for step in globalKeyHandler().getObject( globalPresentationMgrKey).objects: if (oldindex == -1): step.params.status[obj.key] = CopyParams( obj.params) elif (update_oldindex2params_steps[step][oldindex] != None): step.params.status[ obj.key] = update_oldindex2params_steps[step][ oldindex] # copy coloring options from parent (since we now have the Geode and want the information there) if (__classname == "Geode") and (parentKey in step.params.status): parentParams = step.params.status[parentKey] if (isinstance(parentParams, coSceneGraphItemParams)): step.params.status[ obj. key].transparency = parentParams.transparency step.params.status[ obj. key].transparencyOn = parentParams.transparencyOn step.params.status[ obj.key].color = parentParams.color step.params.status[obj.key].r = parentParams.r step.params.status[obj.key].g = parentParams.g step.params.status[obj.key].b = parentParams.b step.params.status[ obj.key].ambient = parentParams.ambient step.params.status[ obj.key].specular = parentParams.specular step.params.status[ obj.key].shininess = parentParams.shininess ####################################################################################### if (__covise_name == ""): obj.params.name = "[unnamed " + __classname + "]" else: obj.params.name = __covise_name obj.params.nodeClassName = __classname obj.sendParams() # send to GUI else: obj = globalKeyHandler().getObject( self.params.openCOVER2key[__covise_key]) obj.covise_key = __covise_key obj.sendAfterRecreate() # send to COVER obj.sendParams() # send to GUI isRoot = False return (True, True)
def sendParams(self): """ send Params to Gui """ Neg2Gui.theNegMsgHandler().sendParams(self.key, self.params )
def registerCOVISEkey(self, covise_keys): """ called during registration if key received from COVER """ _infoer.function = str(self.registerCOVISEkey) _infoer.write("") #for printout #_infoer.write("%s" % covise_key) """ looking for the prefix DNA_ID_STRING """ coviseKeyFound = covise_keys.find(DNA_ID_STRING) if coviseKeyFound > -1: """ Separating the message into a list of tuples [key ;; parentkey] """ key_list = covise_keys.split('\t') del key_list[0] for relation in key_list: """ split key from parent key """ keys = relation.split(';;') covise_key = keys[0] if len(keys) > 1: if not covise_key in self.params.openCOVER2key: parent_key = keys[1] """ Attach to parent if found """ if parent_key in self.params.openCOVER2key: obj = Neg2Gui.theNegMsgHandler( ).internalRequestObject( TYPE_DNA_ITEM, self.params.openCOVER2key[parent_key], None) else: obj = Neg2Gui.theNegMsgHandler( ).internalRequestObject(TYPE_DNA_ITEM, self.key, None) obj.covise_key = covise_key self.params.openCOVER2key[covise_key] = obj.key """ cutting of suffix string for GUI """ #suffix_found = covise_key.find("_OUT"); obj.params.name = re.sub( r'_' + DNA_APPENDIX_ID_STRING + '_\d+$', '', covise_key) # covise_key obj.sendParams() else: #### for recreate obj = globalKeyHandler().getObject( self.params.openCOVER2key[covise_key]) obj.covise_key = covise_key # send to COVER obj.sendTransformation() obj.sendVisibility() for conn in obj.params.connectionPoints: obj.sendConnections(conn, [ obj.params.connectionPoints[conn], obj.params.connectionPointsDisable[conn] ]) # send to GUI obj.sendParams() return (True, True) return (False, False)
def registerCOVISEkey( self, covise_keys): """ called during registration if key received from COVER """ _infoer.function = str(self.registerCOVISEkey) _infoer.write("")#for printout #_infoer.write("%s" % covise_key) """ looking for the prefix SCENEGRAPH_ID_STRING """ coviseKeyFound = covise_keys.find(SCENEGRAPH_ID_STRING) if coviseKeyFound == -1: return (False, False) # Separating the message into a list of lists [[key, nodeClass, parentkey], ...] key_list = covise_keys.split('\t') del key_list[0] # idString relations = [s.split(";;") for s in key_list if s.count(";;") == 2] ####################################################################################### # UPDATE OLD PROJECTS (part 1/2: delete old objects and remember params) update = (globalKeyHandler().getObject(globalProjectKey).params.coprjVersion < 2) global update_counter if update and (update_counter == -1): # do just once for all SceneGraphMgr registrations print("Updating SceneGraphItems") update_counter = 0 # prepare global update_oldindex2params update_oldindex2params = {} global update_oldindex2params_steps update_oldindex2params_steps = {} # store params for coverkey, key in iter(self.params.openCOVER2key.items()): oldindex = int(coverkey[coverkey.rfind("_")+1:]) update_oldindex2params[oldindex] = CopyParams(globalKeyHandler().getObject(key).params) for step in globalKeyHandler().getObject(globalPresentationMgrKey).objects: if not step in update_oldindex2params_steps: update_oldindex2params_steps[step] = {} if key in step.params.status: update_oldindex2params_steps[step][oldindex] = CopyParams(step.params.status[key]) else: update_oldindex2params_steps[step][oldindex] = None # delete objects for key in self.params.openCOVER2key.values(): obj = globalKeyHandler().getObject(key) if obj: obj.delete(True, Neg2Gui.theNegMsgHandler()) # create set of parents global update_setOfParents update_setOfParents = frozenset([r[2] for r in relations]) ####################################################################################### isRoot = True for relation in relations: __covise_key = relation[0] __covise_name = __covise_key[0:__covise_key.find("_"+SCENEGRAPH_APPENDIX_ID_STRING+"_")] __covise_index = int(__covise_key[__covise_key.rfind("_")+1:]) __classname = relation[1] __parent_covise_key = relation[2] if (__covise_name != "") and (__covise_name + "_" + SCENEGRAPH_APPENDIX_ID_STRING + "_" + str(__covise_index) != __covise_key): # we add a * if a node was sent multiple times ("Example_SCGR_07_SCGR_09" -> index is 09, name should be "Example *") __covise_name = __covise_name + " *" self.sceneGraphItems_maximumIndex = max(self.sceneGraphItems_maximumIndex, __covise_index) if not __covise_key in self.params.openCOVER2key: # attach to parent if found (to the corresponding VRML_VIS otherwise) if __parent_covise_key in self.params.openCOVER2key: parentKey = self.params.openCOVER2key[__parent_covise_key] else: parentKey = self.key allVrmlVis = [] for item in globalKeyHandler().getAllElements(): parentObj = globalKeyHandler().getObject(item) if (parentObj.typeNr == VIS_VRML): allVrmlVis.append(item) if (len(allVrmlVis) > 0): parentKey = allVrmlVis[-1] if update: # in old projects: get the first VRML without children as fallback for i in allVrmlVis: if (len(globalKeyHandler().getObject(i).objects) == 0): parentKey = i break # then use the name to identify the VRML for i in allVrmlVis: if __covise_name in globalKeyHandler().getObject(i).params.name: parentKey = i break else: # in new projects: simply use the index to identify the VRML for i in allVrmlVis: if (globalKeyHandler().getObject(i).params.sceneGraphItems_startIndex == __covise_index): parentKey = i break obj = Neg2Gui.theNegMsgHandler().internalRequestObject( TYPE_SCENEGRAPH_ITEM, parentKey, None) obj.covise_key = __covise_key self.params.openCOVER2key[ __covise_key ] = obj.key ####################################################################################### # UPDATE OLD PROJECTS (part 2/2: use old params) if update: # get old index oldindex = -1 if (update_counter in update_oldindex2params) and (isRoot or ((__covise_name != "") and (__covise_key in update_setOfParents))): oldindex = update_counter update_counter = update_counter + 1 # use existing params if (oldindex != -1): obj.setParams(update_oldindex2params[oldindex]) obj.sendAfterRecreate() # send to COVER (since we are using stored params for our new object) # copy coloring options from parent (since we now have the Geode and want the information there) if (__classname == "Geode"): parentObj = globalKeyHandler().getObject(parentKey) if parentObj and isinstance(parentObj, coSceneGraphItem): params = CopyParams(obj.params) params.transparency = parentObj.params.transparency params.transparencyOn = parentObj.params.transparencyOn params.color = parentObj.params.color params.r = parentObj.params.r params.g = parentObj.params.g params.b = parentObj.params.b params.ambient = parentObj.params.ambient params.specular = parentObj.params.specular params.shininess = parentObj.params.shininess obj.setParams(params) obj.sendAfterRecreate() # send to COVER (since we are using stored params for our new object) # add params to presentation steps for step in globalKeyHandler().getObject(globalPresentationMgrKey).objects: if (oldindex == -1): step.params.status[obj.key] = CopyParams(obj.params) elif (update_oldindex2params_steps[step][oldindex] != None): step.params.status[obj.key] = update_oldindex2params_steps[step][oldindex] # copy coloring options from parent (since we now have the Geode and want the information there) if (__classname == "Geode") and (parentKey in step.params.status): parentParams = step.params.status[parentKey] if (isinstance(parentParams, coSceneGraphItemParams)): step.params.status[obj.key].transparency = parentParams.transparency step.params.status[obj.key].transparencyOn = parentParams.transparencyOn step.params.status[obj.key].color = parentParams.color step.params.status[obj.key].r = parentParams.r step.params.status[obj.key].g = parentParams.g step.params.status[obj.key].b = parentParams.b step.params.status[obj.key].ambient = parentParams.ambient step.params.status[obj.key].specular = parentParams.specular step.params.status[obj.key].shininess = parentParams.shininess ####################################################################################### if (__covise_name == ""): obj.params.name = "[unnamed " + __classname + "]" else: obj.params.name = __covise_name obj.params.nodeClassName = __classname obj.sendParams() # send to GUI else: obj = globalKeyHandler().getObject(self.params.openCOVER2key[__covise_key]) obj.covise_key = __covise_key obj.sendAfterRecreate() # send to COVER obj.sendParams() # send to GUI isRoot = False return (True, True)
def _sendBox(self): if self._box != self.importModule.getBox(True): self._box = self.importModule.getBox(False) Neg2Gui.theNegMsgHandler().sendBBox(self.key, self._box)
def setReductionFactor(self, reduction): self.redFactor = reduction if reduction: self.importModule.setReductionFactor(-1) Neg2Gui.theNegMsgHandler().internalRecvReductionFactor(self.importModule.getReductionFactor(), self.importModule.getNumTimeSteps()) Neg2Gui.theNegMsgHandler().internalRecvReductionFactor(None, self.importModule.getNumTimeSteps())