def __init__(self): VisItem.__init__(self, TYPE_VIEWPOINT_MGR, 'ViewpointMgr') self.params = coViewpointMgrParams() self.name = self.params.name # tell cover to send the default viewpoints msg = coGRKeyWordMsg("sendDefaultViewPoint", True) covise.sendRendMsg(msg.c_str())
def __init__(self): VisItem.__init__(self, TYPE_VIEWPOINT_MGR, 'ViewpointMgr') self.params = coViewpointMgrParams() self.name = self.params.name # tell cover to send the default viewpoints msg = coGRKeyWordMsg( "sendDefaultViewPoint" , True) covise.sendRendMsg(msg.c_str())
def recreate(self, negMsgHandler, parentKey, offset): """ recreate is called after all classes of the session have been unpickled """ coViewpointMgrParams.mergeDefaultParams(self.params) # explicitly call mergeDefaultParams of this class if offset>0 : for obj in self.objects: obj.params.name = str(self.key) + "_" + obj.params.name # tell cover to send the default viewpoints again msg = coGRKeyWordMsg( "sendDefaultViewPoint" , True) covise.sendRendMsg(msg.c_str()) VisItem.recreate(self, negMsgHandler, parentKey, offset) self.params.selectedKey = None if offset>0 : globalKeyHandler().getObject(globalViewpointMgrKey).merge(self) #return for obj in self.objects: if obj.params.isVisible: obj.show() self.params.currentKey = obj.key return
def recreate(self, negMsgHandler, parentKey, offset): """ recreate is called after all classes of the session have been unpickled """ coViewpointMgrParams.mergeDefaultParams( self.params) # explicitly call mergeDefaultParams of this class if offset > 0: for obj in self.objects: obj.params.name = str(self.key) + "_" + obj.params.name # tell cover to send the default viewpoints again msg = coGRKeyWordMsg("sendDefaultViewPoint", True) covise.sendRendMsg(msg.c_str()) VisItem.recreate(self, negMsgHandler, parentKey, offset) self.params.selectedKey = None if offset > 0: globalKeyHandler().getObject(globalViewpointMgrKey).merge(self) #return for obj in self.objects: if obj.params.isVisible: obj.show() self.params.currentKey = obj.key return
def setParams(self, params, negMsgHandler=None, sendToCover=False): _infoer.function = str(self.setParams) _infoer.write(" ") # change of maxIdx means shorten the history oldParams = self.params changedParams = ParamsDiff( self.params, params) if hasattr(params, 'currentStep'): diffStep = params.currentStep - oldParams.currentStep else: diffStep = params.currentKey - oldParams.currentKey coKeydObject.setParams( self, params ) if 'currentKey' in changedParams or 'reloadStep' in changedParams: if os.getenv('VR_PREPARE_DEBUG_VISITEMS_DIR'): for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key) and isinstance(globalKeyHandler().getObject(key), VisItem): globalKeyHandler().getObject(key).updateDebugFilename(self.params.currentKey) # send message presentationstep changed if diffStep == 1: msg = coGRKeyWordMsg("presForward", True) covise.sendRendMsg(msg.c_str()) elif diffStep == -1: msg = coGRKeyWordMsg("presBackward", True) covise.sendRendMsg(msg.c_str()) elif 'reloadStep' in changedParams: msg = coGRKeyWordMsg("presReload", True) covise.sendRendMsg(msg.c_str()) else: msg_str = "goToStep "+str(params.currentStep) msg = coGRKeyWordMsg(msg_str, True) covise.sendRendMsg(msg.c_str()) if negMsgHandler: #if hasattr(globalKeyHandler().getObject(self.params.currentKey).params, 'status'): key2stateParam = globalKeyHandler().getObject(self.params.currentKey).params.status project = globalKeyHandler().getObject(0) keysInProject = [] keysInProject.append(globalProjectKey) self.__addToList(project, keysInProject) orderedKeysInProject1 = [] orderedKeysInProject2 = [] for key in keysInProject: # put some objects at the beginning of the list obj = globalKeyHandler().getObject(key) #check if visItem is readyToChange otherwise send message if diffStep > 0 and hasattr(obj.params, 'nextPresStep') and not obj.params.nextPresStep and covise.coConfigIsOn("vr-prepare.SolvePresentationStep"): #roll back changes negMsgHandler.sendParams(globalPresentationMgrKey, oldParams) msg = coGRKeyWordMsg("showNotReady", True) covise.sendRendMsg(msg.c_str()) return if (obj.typeNr in [VIS_DOCUMENT, TYPE_TRACKING_MGR]): orderedKeysInProject1.append(key) else: orderedKeysInProject2.append(key) orderedKeysInProject1.extend(orderedKeysInProject2) for key in orderedKeysInProject1: if key in key2stateParam: params = key2stateParam[key] if not hasattr(params, 'flyingMode'): # do not save settings of viewpointMgr obj = globalKeyHandler().getObject(key) newparams = CopyParams(obj.getParams()) # take the objects params as base (so we have all the merged defaultParams) paramChanged = False for pkey in params.__dict__: if pkey in newparams.__dict__: if covise.coConfigIsOn("vr-prepare.DoNotUpdateCuttingSurfaces", False) \ and isinstance(obj, PartCuttingSurfaceVis. PartCuttingSurfaceVis) and pkey=='isVisible': pass elif hasattr(newparams, "isStaticParam") and newparams.isStaticParam(pkey): # skip static params pass elif pkey=='actTimeStep' and (not hasattr(params, 'version') or params.__dict__['version'] < 7): # change actual timestep for old 6.0 projects newparams.__dict__[pkey] = params.__dict__[pkey] -1 if newparams.__dict__[pkey] < 0: newparams.__dict__[pkey] = newparams.__dict__['numTimeSteps'] - 1 paramChanged = True elif (pkey=='autoActiveSensorIDs') and (len(params.autoActiveSensorIDs) > 0): # always set params if the new step has autoActiveSensorIDs newparams.__dict__[pkey] = copy.deepcopy(params.__dict__[pkey]) paramChanged = True else: if (newparams.__dict__[pkey] != params.__dict__[pkey]): newparams.__dict__[pkey] = copy.deepcopy(params.__dict__[pkey]) # need a deepcopy in case we have a list/dict paramChanged = True if (paramChanged): if key != globalProjectKey and 'currentKey' in changedParams: negMsgHandler.presentationRecvParams( key, newparams ) negMsgHandler.sendParams(key, newparams) elif key != globalProjectKey: negMsgHandler.presentationRecvParams( key, newparams, True) #TODO, ueberpruefen, ob das nach kompletter portierung noetig ist negMsgHandler.sendParams(key, newparams) else : negMsgHandler.sendParams(key, newparams) project.setParams(newparams) project.sendMessages() # hide all visItem which are not in list else: params = globalKeyHandler().getObject(key).params if params: #do not save settings of viewpointMgr if not hasattr(params, 'flyingMode'): if hasattr(params, 'isVisible') and params.isVisible: cparams = CopyParams(params) cparams.isVisible = False negMsgHandler.presentationRecvParams( key, cparams) negMsgHandler.sendParams(key, cparams)
def setParams(self, params, negMsgHandler=None, sendToCover=False): _infoer.function = str(self.setParams) _infoer.write(" ") # change of maxIdx means shorten the history oldParams = self.params changedParams = ParamsDiff(self.params, params) if hasattr(params, 'currentStep'): diffStep = params.currentStep - oldParams.currentStep else: diffStep = params.currentKey - oldParams.currentKey coKeydObject.setParams(self, params) if 'currentKey' in changedParams or 'reloadStep' in changedParams: if os.getenv('VR_PREPARE_DEBUG_VISITEMS_DIR'): for key in globalKeyHandler().getAllElements(): if globalKeyHandler().getObject(key) and isinstance( globalKeyHandler().getObject(key), VisItem): globalKeyHandler().getObject(key).updateDebugFilename( self.params.currentKey) # send message presentationstep changed if diffStep == 1: msg = coGRKeyWordMsg("presForward", True) covise.sendRendMsg(msg.c_str()) elif diffStep == -1: msg = coGRKeyWordMsg("presBackward", True) covise.sendRendMsg(msg.c_str()) elif 'reloadStep' in changedParams: msg = coGRKeyWordMsg("presReload", True) covise.sendRendMsg(msg.c_str()) else: msg_str = "goToStep " + str(params.currentStep) msg = coGRKeyWordMsg(msg_str, True) covise.sendRendMsg(msg.c_str()) if negMsgHandler: #if hasattr(globalKeyHandler().getObject(self.params.currentKey).params, 'status'): key2stateParam = globalKeyHandler().getObject( self.params.currentKey).params.status project = globalKeyHandler().getObject(0) keysInProject = [] keysInProject.append(globalProjectKey) self.__addToList(project, keysInProject) orderedKeysInProject1 = [] orderedKeysInProject2 = [] for key in keysInProject: # put some objects at the beginning of the list obj = globalKeyHandler().getObject(key) #check if visItem is readyToChange otherwise send message if diffStep > 0 and hasattr( obj.params, 'nextPresStep' ) and not obj.params.nextPresStep and covise.coConfigIsOn( "vr-prepare.SolvePresentationStep"): #roll back changes negMsgHandler.sendParams(globalPresentationMgrKey, oldParams) msg = coGRKeyWordMsg("showNotReady", True) covise.sendRendMsg(msg.c_str()) return if (obj.typeNr in [VIS_DOCUMENT, TYPE_TRACKING_MGR]): orderedKeysInProject1.append(key) else: orderedKeysInProject2.append(key) orderedKeysInProject1.extend(orderedKeysInProject2) for key in orderedKeysInProject1: if key in key2stateParam: params = key2stateParam[key] if not hasattr( params, 'flyingMode' ): # do not save settings of viewpointMgr obj = globalKeyHandler().getObject(key) newparams = CopyParams( obj.getParams() ) # take the objects params as base (so we have all the merged defaultParams) paramChanged = False for pkey in params.__dict__: if pkey in newparams.__dict__: if covise.coConfigIsOn("vr-prepare.DoNotUpdateCuttingSurfaces", False) \ and isinstance(obj, PartCuttingSurfaceVis. PartCuttingSurfaceVis) and pkey=='isVisible': pass elif hasattr( newparams, "isStaticParam" ) and newparams.isStaticParam(pkey): # skip static params pass elif pkey == 'actTimeStep' and ( not hasattr(params, 'version') or params.__dict__['version'] < 7): # change actual timestep for old 6.0 projects newparams.__dict__[ pkey] = params.__dict__[pkey] - 1 if newparams.__dict__[pkey] < 0: newparams.__dict__[ pkey] = newparams.__dict__[ 'numTimeSteps'] - 1 paramChanged = True elif (pkey == 'autoActiveSensorIDs') and (len( params.autoActiveSensorIDs) > 0): # always set params if the new step has autoActiveSensorIDs newparams.__dict__[ pkey] = copy.deepcopy( params.__dict__[pkey]) paramChanged = True else: if (newparams.__dict__[pkey] != params.__dict__[pkey]): newparams.__dict__[ pkey] = copy.deepcopy( params.__dict__[pkey] ) # need a deepcopy in case we have a list/dict paramChanged = True if (paramChanged): if key != globalProjectKey and 'currentKey' in changedParams: negMsgHandler.presentationRecvParams( key, newparams) negMsgHandler.sendParams(key, newparams) elif key != globalProjectKey: negMsgHandler.presentationRecvParams( key, newparams, True ) #TODO, ueberpruefen, ob das nach kompletter portierung noetig ist negMsgHandler.sendParams(key, newparams) else: negMsgHandler.sendParams(key, newparams) project.setParams(newparams) project.sendMessages() # hide all visItem which are not in list else: params = globalKeyHandler().getObject(key).params if params: #do not save settings of viewpointMgr if not hasattr(params, 'flyingMode'): if hasattr(params, 'isVisible') and params.isVisible: cparams = CopyParams(params) cparams.isVisible = False negMsgHandler.presentationRecvParams( key, cparams) negMsgHandler.sendParams(key, cparams)