コード例 #1
0
 def setParams( self, key, params ):
     if params:
         p = CopyParams(params)
         if not hasattr(p, 'index') or p.index == -1:
             #save index form list
             p.index = self._key2ListBoxItemIdx[key]
             self._ListBoxItemIdx2Key[p.index] = key
         else:
             # Note: The following does not work properly if the key is already present in the list and the index changed.
             #       However, this shouldn't be a problem since the index doesn't change outside the ListManager at the moment.
             #set the index in the list ... insert at this point
             # if key is allready in list, change the order
             if p.index in self._ListBoxItemIdx2Key and key!= self._ListBoxItemIdx2Key[p.index]:
                 # remeber the old key of this index
                 tmpKey = self._ListBoxItemIdx2Key[p.index]
                 # set the new key
                 self._ListBoxItemIdx2Key[p.index] = key
                 self._key2ListBoxItemIdx[key] = p.index
                 # go through the following and delete the old index of this key
                 for i in range(p.index+1, self.widget().listBox2.count()+1):
                     if i in self._ListBoxItemIdx2Key:
                         tmp2Key = self._ListBoxItemIdx2Key[i]
                         if tmp2Key == key:
                             del self._ListBoxItemIdx2Key[i]
                             break
             # key is not in list
             else:
                 self._key2ListBoxItemIdx[key] = p.index
                 self._ListBoxItemIdx2Key[p.index] = key
         self._key2Params[key] = p
         self._updateList()
         ObjectMgr().setParams( key, p )
コード例 #2
0
ファイル: PartIsoSurfaceVis.py プロジェクト: nixz/covise
    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
コード例 #3
0
ファイル: ObjectMgr.py プロジェクト: zyzwhdx/covise
 def duplicateVisualizer(self, objKey):
     # get the typ of the object
     typeNr = self.__objects[objKey].type
     # copy only 2d and 3d parts
     if not typeNr in [
             VIS_STREAMLINE, VIS_MOVING_POINTS, VIS_PATHLINES, VIS_ISOPLANE,
             VIS_VECTORFIELD, VIS_PLANE, VIS_VECTOR
     ]:
         return
     # get the parent of the object
     parent = self.getParentOfObject(objKey)
     # get the name of the object
     name = self.getParamsOfObject(objKey).name
     # copy the params
     newParams = CopyParams(self.getParamsOfObject(objKey))
     # create new name with copy at the end
     newName = name + '(Copy)'
     i = 2
     while newName in self.__copyNames:
         newName = name + '(Copy ' + str(i) + ')'
         i = i + 1
     # set the new params
     newParams.name = newName
     # send duplicate message
     request = theGuiMsgHandler().requestDuplicateObject(
         objKey, newName, typeNr, None, parent, newParams)
     theGuiMsgHandler().waitforAnswer(request)
コード例 #4
0
ファイル: coViewpointMgr.py プロジェクト: nixz/covise
 def makeOthersInvisible( self, visobj, negMsgHandler=None):
     for obj in self.objects:
         if obj!=visobj:
             p = CopyParams(obj.params)
             p.isVisible=False
             if negMsgHandler:
                 negMsgHandler.internalRecvParams( obj.key, p )
                 negMsgHandler.sendParams( obj.key, p )
         else:
             p = CopyParams(obj.params)
             p.isVisible=True
             if negMsgHandler:
                 negMsgHandler.internalRecvParams( obj.key, p )
                 negMsgHandler.sendParams( obj.key, p )
コード例 #5
0
ファイル: SceneObjectVis.py プロジェクト: zyzwhdx/covise
    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)
コード例 #6
0
ファイル: coPresentationMgr.py プロジェクト: zyzwhdx/covise
    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)
コード例 #7
0
    def updateForObject(self, keys):
        """ called from MainWindow to update the content to the choosen object key

        Default params will be shown if there is more than 1 key"""
        _infoer.function = str(self.updateForObject)
        _infoer.write("")

        if isinstance(keys, int):
            self.__keys = [keys]
        elif isinstance(keys, list) and len(keys) > 0:
            self.__keys = keys
        else:
            return

        if len(self.__keys) == 1:
            params = ObjectMgr().getParamsOfObject(self.__keys[0])
            if isinstance(params, int) or isinstance(params, coDNAItemParams):
                self.__setParams(params)

        elif len(self.__keys) > 1:
            # multi selection: show default params
            self.oldPanelParams = coDNAItemParams()
            params = CopyParams(self.oldPanelParams)
            params.name = "Multiselection"
            self.__setParams(params)
コード例 #8
0
    def emitCutChanged(self):
        _infoer.function = str(self.emitCutChanged)
        _infoer.write("")

        if len(self.__keys)>0 and ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_CUTGEOMETRY_PART:

            params = ObjectMgr().getRealParamsOfObject(self.__keys[0])
            params.alignedRectangle = self.__rectangleManager.getParams()

            if len(self.__keys)==1 :
                Application.vrpApp.key2params[self.__keys[0]] = params
                ObjectMgr().setParams(self.__keys[0], params )
                theGuiMsgHandler().runObject(self.__keys[0])

            # set params for multi selection
            if len(self.__keys)>1 :
                #find changed params
                originalParams = self.oldPanelRealParams
                realChange = ParamsDiff( originalParams, params )
                # set params for remaining selected objects
                for i in range(0, len(self.__keys)):
                    childKeyParams = ObjectMgr().getRealParamsOfObject(self.__keys[i])
                    # find the changed param in childKey and replace it with the
                    # intended attribut
                    for x in realChange :
                        childKeyParams.__dict__[x] = params.__dict__[x]
                    # set the params
                    Application.vrpApp.key2params[self.__keys[i]] = childKeyParams
                    ObjectMgr().setParams( self.__keys[i], childKeyParams )
                    theGuiMsgHandler().runObject( self.__keys[i] )
                #save params for multi selection
                self.oldPanelRealParams = CopyParams(params)
コード例 #9
0
ファイル: PartPointProbingVis.py プロジェクト: zyzwhdx/covise
    def setParamsByModule( self, mparam, mvalue):
        """ receives parameter changes from the tracer module
            return a list of objKey and their parameters to be set by the Neg2Gui class
        """
        _infoer.function = str(self.setParamsByModule)
        _infoer.write(" ")
        pChangeList = []
        newparams = CopyParams(self.params)
        if mparam == 'startpoint1':
            self.__startpoint1 = float(mvalue[0]),float(mvalue[1]),float(mvalue[2])
            return []
        if mparam == 'startpoint2':
            newparams.startpoint = (self.__startpoint1[0]+float(mvalue[0]))/2.0, (self.__startpoint1[1]+float(mvalue[1]))/2.0, (self.__startpoint1[2]+float(mvalue[2]))/2.0

        pChangeList.append( (self.key, newparams) )

        return pChangeList
コード例 #10
0
    def setParamsByModule(self, mparam, mvalue):
        """ receives parameter changes from the iso cutter 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 == 'iso_value':
            newparams.isomin = float(mvalue[0])
            newparams.isomax = float(mvalue[1])
            newparams.isovalue = float(mvalue[2])
            #print " mvalue[0] = ", float(mvalue[0]), " mvalue[1] = ", float(mvalue[1]), " mvalue[2] = ", float(mvalue[2])

        pChangeList.append((self.key, newparams))

        return pChangeList
コード例 #11
0
ファイル: PartIsoCutterVis.py プロジェクト: nixz/covise
    def setParamsByModule( self, mparam, mvalue):
        """ receives parameter changes from the iso cutter 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 == 'iso_value':
            newparams.isomin = float(mvalue[0])
            newparams.isomax = float(mvalue[1])
            newparams.isovalue = float(mvalue[2])
            #print " mvalue[0] = ", float(mvalue[0]), " mvalue[1] = ", float(mvalue[1]), " mvalue[2] = ", float(mvalue[2])

        pChangeList.append( (self.key, newparams) )

        return pChangeList
コード例 #12
0
 def setParams(self, objectKey, params, callback=None):
     """Set params for object with key objectKey."""
     requestNr = transactionKeyHandler.registerObject(callback)
     _infoer.write("setParams: reqNr: " + str(requestNr) + " objectKey: " +
                   str(objectKey))
     msg = setParamsMsg(requestNr, objectKey, CopyParams(params))
     self.sigGuiParam.emit(requestNr, msg)
     return requestNr
コード例 #13
0
ファイル: coPresentationMgr.py プロジェクト: zyzwhdx/covise
 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)
コード例 #14
0
ファイル: VrmlPanel.py プロジェクト: nixz/covise
    def __getParams(self):
        _infoer.function = str(self.__getParams)
        _infoer.write("")

        data = CopyParams(self.__params)    # use parameter values of this object that arent in this panel

        data.filename = str(self.lineEditFilename.text())

#        data.name = str(self.lineEditFilename.text())
        data.sensorIDs = []
        data.autoActiveSensorIDs = []
        for sensorID, checkBox in iter(self.__sensorCheckBox.items()):
            data.sensorIDs.append(sensorID)
            if checkBox.isChecked():
                data.autoActiveSensorIDs.append(sensorID)

        self.__params = CopyParams(data)

        return data
コード例 #15
0
ファイル: co2DPartMgr.py プロジェクト: zyzwhdx/covise
 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)
コード例 #16
0
    def setParamsByModule(self, mparam, mvalue):
        """ receives parameter changes from the iso cutter 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)

        pChangeList.append((self.key, newparams))

        return pChangeList
コード例 #17
0
ファイル: PartIsoSurfaceVis.py プロジェクト: szsteven/covise
    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
コード例 #18
0
ファイル: PartCuttingSurfaceVis.py プロジェクト: nixz/covise
    def setParamsByModule( self, mparam, mvalue):
        """ receives parameter changes from the cutting surface module
            return a list of objKey and their parameters to be set by the Neg2Gui class
        """
        _infoer.function = str(self.setParamsByModule)
        _infoer.write(" ")
        pChangeList = []
        newparams = CopyParams(self.params)
        if mparam == 'point':
            self.__point = mvalue
            return pChangeList
        if mparam == 'vertex':
            aaa = RectangleIn3d1Mid1Norm()#convertAlignedRectangleToGeneral(self.params.alignedRectangle)
            if self.__point:
                aaa.point=(float(self.__point[0]), float(self.__point[1]), float(self.__point[2]) )
            aaa.normal=(float(mvalue[0]), float(mvalue[1]), float(mvalue[2]) )
            xxx=convertCutRectangleToAlignedRectangle(aaa, self.params.alignedRectangle.orthogonalAxis)
            newparams.alignedRectangle=xxx
            self.__point=None
        if mparam == 'option':
            newparams.option= int(mvalue[0])
        if mparam == 'scale':
            newparams.scale= float(mvalue[2])
        if mparam == 'length':
            newparams.length= int(mvalue[0])

        pChangeList.append( (self.key, newparams) )

        if mparam == 'Min/Max':
            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
コード例 #19
0
ファイル: coJournalMgr.py プロジェクト: zyzwhdx/covise
    def setParams(self, params, negMsgHandler=None, sendToCover=False):
        _infoer.function = str(self.setParams)
        _infoer.write(
            "old index: %d, new_index: %d, max_index:%d " %
            (self.params.currentIdx, params.currentIdx, self.params.maxIdx))
        # change of maxIdx means shorten the history
        changedParams = ParamsDiff(self.params, params)
        if 'maxIdx' in changedParams:
            self.params.maxIdx = params.maxIdx
            for idx in range(self.__numSteps() - self.params.maxIdx - 1):
                del self.objects[0]
            self.params.currentIdx = self.params.maxIdx
            if negMsgHandler:
                negMsgHandler.sendParams(self.key, self.params)
            return

        if self.params.currentIdx == params.currentIdx:
            _infoer.write("currentIdx did not change")
            return

        old_index = self.params.currentIdx
        if params.currentIdx < -1 or params.currentIdx > self.params.maxIdx:
            _infoer.write("currentIdx out of range")
            return

        coKeydObject.setParams(self, params)

        #restore settings
        objsToRefresh = {}
        if self.params.currentIdx > old_index:
            inc = 1
        else:
            inc = -1
        for currentStepDiff in range(inc,
                                     self.params.currentIdx - old_index + inc,
                                     inc):
            pStepParams = self.objects[old_index + currentStepDiff].params
            obj = globalKeyHandler().getObject(pStepParams.key)
            #print "Setting params of object ", obj.name, pStepParams.key, pStepParams.param.__dict__

            if pStepParams.action == STEP_PARAM:
                obj.setParams(CopyParams(pStepParams.param), negMsgHandler)
                objsToRefresh[obj] = True
                if negMsgHandler:
                    negMsgHandler.sendParams(obj.key, obj.params)
                else:
                    _infoer.write("param change not send to gui")

        #auto apply
        for obj in objsToRefresh:
            obj.run(RUN_ALL, negMsgHandler)
コード例 #20
0
ファイル: ObjectMgr.py プロジェクト: nixz/covise
 def duplicateVisualizer(self, objKey):
     # get the typ of the object
     typeNr = self.__objects[objKey].type
     # copy only 2d and 3d parts
     if not typeNr in [VIS_STREAMLINE, VIS_MOVING_POINTS, VIS_PATHLINES, VIS_ISOPLANE, VIS_VECTORFIELD, VIS_PLANE, VIS_VECTOR]:
         return
     # get the parent of the object
     parent = self.getParentOfObject(objKey)
     # get the name of the object
     name = self.getParamsOfObject(objKey).name
     # copy the params 
     newParams = CopyParams(self.getParamsOfObject(objKey))
     # create new name with copy at the end
     newName = name + '(Copy)'
     i = 2
     while newName in self.__copyNames:
         newName = name+'(Copy '+str(i)+')'
         i = i+1
     # set the new params
     newParams.name = newName
     # send duplicate message
     request = theGuiMsgHandler().requestDuplicateObject( objKey, newName, typeNr, None, parent, newParams)
     theGuiMsgHandler().waitforAnswer(request)
コード例 #21
0
ファイル: GenericObjectPanel.py プロジェクト: zyzwhdx/covise
 def __getParams(self):
     params = CopyParams(ObjectMgr().getParamsOfObject(self.__key))
     for paramName, paramType in iter(params.gpTypes.items()):
         if (paramType == PARAM_TYPE_BOOL):
               params.gpValues[paramName] = self.__name2input[paramName].isChecked()
         elif (paramType == PARAM_TYPE_INT):
               params.gpValues[paramName] = getIntInLineEdit(self.__name2input[paramName])
         elif (paramType == PARAM_TYPE_FLOAT):
               params.gpValues[paramName] = getDoubleInLineEdit(self.__name2input[paramName])
         elif (paramType == PARAM_TYPE_VEC3):
               params.gpValues[paramName] = [float(x) for x in self.__name2input[paramName].text().split("/")]
         elif (paramType == PARAM_TYPE_MATRIX):
               params.gpValues[paramName] = [float(x) for x in self.__name2input[paramName].text().split("/")]
         else:
               params.gpValues[paramName] = str(self.__name2input[paramName].text())
     return params
コード例 #22
0
ファイル: PartMagmaTraceVis.py プロジェクト: nixz/covise
    def setParamsByModule( self, mparam, mvalue):
        """ receives parameter changes from the iso cutter 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 == 'len':
            try:
                newparams.length= int(mvalue[0])
            except ValueError:
                newparams.length= int(float(mvalue[0]))

        if mparam == 'skip':
            try:
                newparams.skip= int(mvalue[0])
            except ValueError:
                newparams.skip= int(float(mvalue[0]))

        pChangeList.append( (self.key, newparams) )

        return pChangeList
コード例 #23
0
ファイル: VrmlPanel.py プロジェクト: zyzwhdx/covise
    def __setParams(self, params):
        _infoer.function = str(self.__setParams)
        _infoer.write("")

        self.__params = CopyParams(params)

        #        VrmlPanelBlockSignals(self, True)
        self.blockSignals(self.tabSensors, True)

        if isinstance(params, int):
            self.__keys[0] = params
            return

        self.lineEditFilename.setText(params.filename)

        # create the sensor widgets
        # first time: add all sensors to panel
        if self.__firstTime:
            if params.sensorIDs != []:
                self.tabWidget.setTabEnabled(1, True)  # show sensor tab
            for sensorID in params.sensorIDs:
                self.addSensorWidget(self.tabSensors, sensorID, sensorID
                                     in params.autoActiveSensorIDs)
            self.__dummySensorsLayout.addItem(
                self.__verticalSpacer)  # vertical spacer
            self.__firstTime = False
            self.scrollView.setWidget(self.__dummyBox)
        # other times: if sensor not in list, create (with spacer)
        #              if sensor in list: check checkbox
        else:
            for sensorID in params.sensorIDs:
                if not sensorID in self.__sensorCheckBox:
                    self.__dummySensorsLayout.removeItem(self.__verticalSpacer)
                    self.addSensorWidget(
                        self.tabSensors, sensorID, sensorID
                        in params.autoActiveSensorIDs)
                    self.__dummySensorsLayout.addItem(
                        self.__verticalSpacer)  # vertical spacer
                else:
                    self.__sensorCheckBox[sensorID].setChecked(
                        sensorID in params.autoActiveSensorIDs)

#        VrmlPanelBlockSignals(self, False)
        self.blockSignals(self.tabSensors, False)

        # for multi selection
        if len(self.__keys) > 1:
            self.oldPanelParams = params
コード例 #24
0
ファイル: ViewpointManager.py プロジェクト: zyzwhdx/covise
 def setParams(self, key, params):
     _infoer.function = str(self.setParams)
     _infoer.write("%s %s " % (str(key), str(params)))
     if params:
         if params.isVisible:
             self._currentKey = key
         self._key2Params[key] = CopyParams(params)
         if not params.view == 'default':
             self._updateList()
         else:
             self.__buttonIds[params.name] = key
             #add an icon to iconbar
             if not params.name in self.__buttons:
                 # create the new button
                 self.__buttons[params.name] = QtWidgets.QToolButton(
                     self.iconGroup)
                 # position the new button
                 num = len(self.__buttons) - 1
                 # self.iconGroup.insert(self.__buttons[params.name], num)
                 self.__buttons[params.name].setGeometry(
                     QtCore.QRect(5 + num * 30, 5, 25, 25))
                 self.__buttons[params.name].setMaximumSize(
                     QtCore.QSize(25, 25))
                 palette = QtGui.QPalette()
                 palette.setColor(
                     self.__buttons[params.name].backgroundRole(),
                     QtGui.QColor(238, 234, 238))
                 self.__buttons[params.name].setPalette(palette)
                 # self.__buttons[params.name].setCursor(QtGui.QCursor(QtCore.Qt.CursorShape(0)))
                 # set the icon-pixmap or the name
                 if params.name in self.__iconOfViewpoints:
                     self.__buttons[params.name].setIcon(
                         QtGui.QIcon(
                             QtGui.QPixmap(
                                 self.__iconOfViewpoints[params.name])))
                 else:
                     self.__buttons[params.name].setText(str(params.name))
                 # set the tooltip
                 self.__buttons[params.name].setToolTip(
                     self.__tr("Viewpoint ") + str(params.name))
                 self.__buttons[params.name].setAutoRaise(1)
                 self.__buttons[params.name].setCheckable(True)
                 self.__buttons[params.name].show()
                 # connect the buttonsGroup of default viewpoints
                 self.__buttons[params.name].clicked.connect(
                     self.__functions[params.name])
コード例 #25
0
ファイル: coViewpointMgr.py プロジェクト: zyzwhdx/covise
 def makeOthersInvisible(self, visobj, negMsgHandler=None):
     for obj in self.objects:
         if obj != visobj:
             p = CopyParams(obj.params)
             p.isVisible = False
             if negMsgHandler:
                 negMsgHandler.internalRecvParams(obj.key, p)
                 negMsgHandler.sendParams(obj.key, p)
         else:
             p = CopyParams(obj.params)
             p.isVisible = True
             if negMsgHandler:
                 negMsgHandler.internalRecvParams(obj.key, p)
                 negMsgHandler.sendParams(obj.key, p)
コード例 #26
0
    def setParamsByModule(self, mparam, mvalue):
        """ receives parameter changes from the cutting surface module
            return a list of objKey and their parameters to be set by the Neg2Gui class
        """
        _infoer.function = str(self.setParamsByModule)
        _infoer.write(" ")
        pChangeList = []
        newparams = CopyParams(self.params)
        if mparam == 'point':
            self.__point = mvalue
            return pChangeList
        if mparam == 'vertex':
            aaa = RectangleIn3d1Mid1Norm(
            )  #convertAlignedRectangleToGeneral(self.params.alignedRectangle)
            if self.__point:
                aaa.point = (float(self.__point[0]), float(self.__point[1]),
                             float(self.__point[2]))
            aaa.normal = (float(mvalue[0]), float(mvalue[1]), float(mvalue[2]))
            xxx = convertCutRectangleToAlignedRectangle(
                aaa, self.params.alignedRectangle.orthogonalAxis)
            newparams.alignedRectangle = xxx
            self.__point = None
        if mparam == 'option':
            newparams.option = int(mvalue[0])
        if mparam == 'scale':
            newparams.scale = float(mvalue[2])
        if mparam == 'length':
            newparams.length = int(mvalue[0])

        pChangeList.append((self.key, newparams))

        if mparam == 'Min/Max':
            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
コード例 #27
0
ファイル: VrmlPanel.py プロジェクト: zyzwhdx/covise
    def __getParams(self):
        _infoer.function = str(self.__getParams)
        _infoer.write("")

        data = CopyParams(
            self.__params
        )  # use parameter values of this object that arent in this panel

        data.filename = str(self.lineEditFilename.text())

        #        data.name = str(self.lineEditFilename.text())
        data.sensorIDs = []
        data.autoActiveSensorIDs = []
        for sensorID, checkBox in iter(self.__sensorCheckBox.items()):
            data.sensorIDs.append(sensorID)
            if checkBox.isChecked():
                data.autoActiveSensorIDs.append(sensorID)

        self.__params = CopyParams(data)

        return data
コード例 #28
0
ファイル: PartMagmaTraceVis.py プロジェクト: zyzwhdx/covise
    def setParamsByModule(self, mparam, mvalue):
        """ receives parameter changes from the iso cutter 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 == 'len':
            try:
                newparams.length = int(mvalue[0])
            except ValueError:
                newparams.length = int(float(mvalue[0]))

        if mparam == 'skip':
            try:
                newparams.skip = int(mvalue[0])
            except ValueError:
                newparams.skip = int(float(mvalue[0]))

        pChangeList.append((self.key, newparams))

        return pChangeList
コード例 #29
0
ファイル: PartTracerVis.py プロジェクト: nixz/covise
    def setParamsByModule( self, mparam, mvalue):
        """ receives parameter changes from the tracer module
            return a list of objKey and their parameters to be set by the Neg2Gui class
        """
        _infoer.function = str(self.setParamsByModule)
        _infoer.write("setParamsByModule ")
        pChangeList = []
        newparams = CopyParams(self.params)
        if mparam == 'startpoint1':
            self.__startpoint1 = mvalue
            if self.params.alignedRectangle.orthogonalAxis=='line':
                newparams.alignedRectangle.setStartEndPoint( float(self.__startpoint1[0]),\
                                                             float(self.__startpoint1[1]),\
                                                             float(self.__startpoint1[2]),\
                                                             float(self.__startpoint2[0]),\
                                                             float(self.__startpoint2[1]),\
                                                             float(self.__startpoint2[2]) )
            else : return pChangeList

            #return pChangeList
        if mparam == 'startpoint2':
            self.__startpoint2 = mvalue
            if self.params.alignedRectangle.orthogonalAxis=='line':
                newparams.alignedRectangle.setStartEndPoint( float(self.__startpoint1[0]),\
                                                             float(self.__startpoint1[1]),\
                                                             float(self.__startpoint1[2]),\
                                                             float(self.__startpoint2[0]),\
                                                             float(self.__startpoint2[1]),\
                                                             float(self.__startpoint2[2]) )
            else : return pChangeList

        if mparam == 'direction':
            if not self.params.alignedRectangle.orthogonalAxis=='line':
                aaa = RectangleIn3d2Ps1Dir()#convertAlignedRectangleToGeneral(self.params.alignedRectangle)
                if self.__startpoint1:
                    aaa.pointA=(float(self.__startpoint1[0]), float(self.__startpoint1[1]), float(self.__startpoint1[2]) )
                if self.__startpoint2:
                    aaa.pointC=(float(self.__startpoint2[0]), float(self.__startpoint2[1]), float(self.__startpoint2[2]) )
                aaa.direction = (float(mvalue[0]), float(mvalue[1]), float(mvalue[2]) )
                xxx=convertGeneralToAlignedRectangle(aaa, self.params.alignedRectangle.orthogonalAxis)
                newparams.alignedRectangle=xxx
                self.__startpoint1=None
                self.__startpoint2=None
        if mparam == 'trace_len':
            newparams.len=float(mvalue[0])
        if mparam == 'no_startp':
            try:
                newparams.no_startp= int(mvalue[2])
            except ValueError:
                newparams.no_startp= int(float(mvalue[2]))
        if mparam == 'taskType':
            newparams.taskType= int(mvalue[0])
        if mparam == 'Min/Max':
            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 not hasattr(cTableObject.params, 'dependantKeys'):
                    cTableObject.params.dependantKeys = []
                if self.key not in cTableObject.params.dependantKeys:
                    cTableObject.params.dependantKeys.append(self.key)
                pChangeList.append( (cTableObject.key, cTableObject.params) )
        if mparam == 'startStyle':
            newparams.start_style = int(mvalue[0])
        if mparam == 'FreeStartPoints':
            newparams.freeStartPoints = mvalue
            self.oldFreeStartPoints = mvalue

        pChangeList.append( (self.key, newparams) )

        return pChangeList
コード例 #30
0
ファイル: coPresentationMgr.py プロジェクト: zyzwhdx/covise
    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)
コード例 #31
0
ファイル: coViewpointMgr.py プロジェクト: zyzwhdx/covise
    def setParams(self, params, negMsgHandler=None, sendToCover=True):
        _infoer.function = str(self.setParams)
        realChange = ParamsDiff(self.params, params)

        if 'newViewpoint' in realChange:
            _infoer.write("new viewpoint")
            newVp = negMsgHandler.internalRequestObject(
                TYPE_VIEWPOINT, self.key)
            newVp.params = coViewpointParams()
            newVp.params.id = params.newViewpoint[0]
            newVp.params.name = params.newViewpoint[1]
            newVp.params.view = params.newViewpoint[2]
            newVp.params.clipplane = params.newViewpoint[3]
            newVp.params.confirmed = True
            newVp.params.isVisible = True
            self.makeOthersInvisible(newVp, negMsgHandler)
            negMsgHandler.sendParams(newVp.key, newVp.params)

        elif 'newDefaultViewpoint' in realChange or (
                not hasattr(self.params, 'newDefaultViewpoint') and
            (hasattr(params, 'newDefaultViewpoint')
             and not params.newDefaultViewpoint == None)):
            _infoer.write("new default viewpoint")
            newVp = negMsgHandler.internalRequestObject(
                TYPE_VIEWPOINT, self.key)
            newVp.params = coViewpointParams()
            newVp.params.id = params.newDefaultViewpoint[0]
            newVp.params.name = params.newDefaultViewpoint[1]
            newVp.params.view = "default"
            newVp.params.clipplane = "0"
            newVp.params.confirmed = True
            negMsgHandler.sendParams(newVp.key, newVp.params)

        elif 'changedViewpoint' in realChange:
            _infoer.write("change viewpoint")
            vpId = params.changedViewpoint[0]
            vpName = params.changedViewpoint[1]
            for obj in self.objects:
                if obj.params.id == vpId and obj.params.name == vpName:
                    p = CopyParams(obj.params)
                    p.view = params.changedViewpoint[2]
                    p.changed = True
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams(obj.key, p)
                        negMsgHandler.sendParams(obj.key, p)
                    break

        elif ('changeID' in realChange) or (hasattr(params, 'changeID')
                                            and params.changeID):
            _infoer.write("change id")
            for obj in self.objects:
                if obj.params.id == params.oldID and obj.params.confirmed == False:
                    p = CopyParams(obj.params)
                    p.id = params.newID
                    p.confirmed = True
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams(obj.key, p)
                        negMsgHandler.sendParams(obj.key, p)
            self.params.changedID = False

        elif 'flyingMode' in realChange:
            _infoer.write("change flying Mode")
            self.params.flyingMode = params.flyingMode
            self.sendFlyingMode()

        #elif 'clipplaneMode' in realChange:
        #    _infoer.write("change clipplane Mode")
        #    self.params.clipplaneMode = params.clipplaneMode
        #    self.sendClipplaneMode()
        self.params.clipplaneMode = True
        self.sendClipplaneMode()

        if 'selectedKey' in realChange:
            _infoer.write("selected new viewpoint")
            for obj in self.objects:
                if obj.params.id != params.selectedKey:
                    p = CopyParams(obj.params)
                    p.isVisible = False
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams(obj.key, p)
                        negMsgHandler.sendParams(obj.key, p)
                else:
                    p = CopyParams(obj.params)
                    p.isVisible = True
                    self.params.currentKey = params.selectedKey
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams(obj.key, p)
                        negMsgHandler.sendParams(obj.key, p)
コード例 #32
0
ファイル: ObjectMgr.py プロジェクト: nixz/covise
 def duplicatePart(self, objKey, rotX, rotY, rotZ, rotAngle, transX, transY, transZ):
     # get the typ of the object
     typeNr = self.__objects[objKey].type
     # copy only 2d and 3d parts
     if not typeNr in [TYPE_2D_PART, TYPE_3D_PART]:
         return
     # get the parent of the object
     # parent means 2d_group odr 3d_group
     parent = self.getParentOfObject(objKey)
     while not (self.__objects[parent].type == TYPE_2D_GROUP or self.__objects[parent].type == TYPE_3D_GROUP):
         parent = self.getParentOfObject(parent)
     # get the name of the object
     name = self.getParamsOfObject(objKey).name
     # copy the params 
     newParams = CopyParams(self.getParamsOfObject(objKey))
     # create new name with copy at the end
     newName = name + '(Copy)'
     i = 2
     while newName in self.__copyNames:
         newName = name+'(Copy '+str(i)+')'
         i = i+1
     # set the new params
     newParams.name = newName
     newParams.rotX = rotX
     newParams.rotY = rotY
     newParams.rotZ = rotZ
     newParams.rotAngle = rotAngle
     if hasattr(newParams, 'transX'):
         newParams.transX = newParams.transX + transX
         newParams.transY = newParams.transY + transY
         newParams.transZ = newParams.transZ + transZ
     else:
         newParams.transX = transX
         newParams.transY = transY
         newParams.transZ = transZ
     # send duplicate message
     request = theGuiMsgHandler().requestDuplicateObject( objKey, newName, typeNr, None, parent, newParams)
     theGuiMsgHandler().waitforAnswer(request)
コード例 #33
0
ファイル: coPresentationMgr.py プロジェクト: nixz/covise
    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)
コード例 #34
0
 def setTempParams(self, objectKey, params, callback=None):
     """Set params for object with key objectKey."""
     requestNr = transactionKeyHandler.registerObject(callback)
     msg = setTempParamsMsg(requestNr, objectKey, CopyParams(params))
     self.sigTmpParam.emit(requestNr, msg)
     return requestNr
コード例 #35
0
ファイル: coSceneGraphMgr.py プロジェクト: xyuan/covise
    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)
コード例 #36
0
ファイル: ObjectMgr.py プロジェクト: zyzwhdx/covise
 def duplicatePart(self, objKey, rotX, rotY, rotZ, rotAngle, transX, transY,
                   transZ):
     # get the typ of the object
     typeNr = self.__objects[objKey].type
     # copy only 2d and 3d parts
     if not typeNr in [TYPE_2D_PART, TYPE_3D_PART]:
         return
     # get the parent of the object
     # parent means 2d_group odr 3d_group
     parent = self.getParentOfObject(objKey)
     while not (self.__objects[parent].type == TYPE_2D_GROUP
                or self.__objects[parent].type == TYPE_3D_GROUP):
         parent = self.getParentOfObject(parent)
     # get the name of the object
     name = self.getParamsOfObject(objKey).name
     # copy the params
     newParams = CopyParams(self.getParamsOfObject(objKey))
     # create new name with copy at the end
     newName = name + '(Copy)'
     i = 2
     while newName in self.__copyNames:
         newName = name + '(Copy ' + str(i) + ')'
         i = i + 1
     # set the new params
     newParams.name = newName
     newParams.rotX = rotX
     newParams.rotY = rotY
     newParams.rotZ = rotZ
     newParams.rotAngle = rotAngle
     if hasattr(newParams, 'transX'):
         newParams.transX = newParams.transX + transX
         newParams.transY = newParams.transY + transY
         newParams.transZ = newParams.transZ + transZ
     else:
         newParams.transX = transX
         newParams.transY = transY
         newParams.transZ = transZ
     # send duplicate message
     request = theGuiMsgHandler().requestDuplicateObject(
         objKey, newName, typeNr, None, parent, newParams)
     theGuiMsgHandler().waitforAnswer(request)
コード例 #37
0
ファイル: coSceneGraphMgr.py プロジェクト: zyzwhdx/covise
    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)
コード例 #38
0
ファイル: coViewpointMgr.py プロジェクト: nixz/covise
    def setParams( self, params, negMsgHandler=None, sendToCover=True):
        _infoer.function = str(self.setParams)
        realChange = ParamsDiff( self.params, params )

        if 'newViewpoint' in realChange :
            _infoer.write("new viewpoint")
            newVp = negMsgHandler.internalRequestObject(TYPE_VIEWPOINT, self.key)
            newVp.params = coViewpointParams()
            newVp.params.id   = params.newViewpoint[0]
            newVp.params.name = params.newViewpoint[1]
            newVp.params.view = params.newViewpoint[2]
            newVp.params.clipplane = params.newViewpoint[3]
            newVp.params.confirmed = True
            newVp.params.isVisible = True
            self.makeOthersInvisible(newVp, negMsgHandler)
            negMsgHandler.sendParams( newVp.key, newVp.params )

        elif 'newDefaultViewpoint' in realChange or (not hasattr(self.params, 'newDefaultViewpoint') and (hasattr(params, 'newDefaultViewpoint') and not params.newDefaultViewpoint == None)):
            _infoer.write("new default viewpoint")
            newVp = negMsgHandler.internalRequestObject(TYPE_VIEWPOINT, self.key)
            newVp.params = coViewpointParams()
            newVp.params.id   = params.newDefaultViewpoint[0]
            newVp.params.name = params.newDefaultViewpoint[1]
            newVp.params.view = "default"
            newVp.params.clipplane = "0"
            newVp.params.confirmed = True
            negMsgHandler.sendParams( newVp.key, newVp.params )

        elif 'changedViewpoint' in realChange :
            _infoer.write("change viewpoint")
            vpId   = params.changedViewpoint[0]
            vpName = params.changedViewpoint[1]
            for obj in self.objects:
                if obj.params.id == vpId and obj.params.name == vpName:
                    p = CopyParams(obj.params)
                    p.view = params.changedViewpoint[2]
                    p.changed = True
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams( obj.key, p )
                        negMsgHandler.sendParams( obj.key, p )
                    break

        elif ('changeID' in realChange) or (hasattr(params, 'changeID') and params.changeID):
            _infoer.write("change id")
            for obj in self.objects:
                if obj.params.id == params.oldID and obj.params.confirmed==False:
                    p = CopyParams(obj.params)
                    p.id = params.newID
                    p.confirmed = True
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams( obj.key, p )
                        negMsgHandler.sendParams( obj.key, p )
            self.params.changedID = False

        elif 'flyingMode' in realChange:
            _infoer.write("change flying Mode")
            self.params.flyingMode = params.flyingMode
            self.sendFlyingMode()

        #elif 'clipplaneMode' in realChange:
        #    _infoer.write("change clipplane Mode")
        #    self.params.clipplaneMode = params.clipplaneMode
        #    self.sendClipplaneMode()
        self.params.clipplaneMode = True
        self.sendClipplaneMode()

        if 'selectedKey' in realChange:
            _infoer.write("selected new viewpoint")
            for obj in self.objects:
                if obj.params.id != params.selectedKey:
                    p = CopyParams(obj.params)
                    p.isVisible=False
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams( obj.key, p )
                        negMsgHandler.sendParams( obj.key, p )
                else:
                    p = CopyParams(obj.params)
                    p.isVisible=True
                    self.params.currentKey = params.selectedKey
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams( obj.key, p )
                        negMsgHandler.sendParams( obj.key, p )
コード例 #39
0
    def setParamsByModule(self, mparam, mvalue):
        """ receives parameter changes from the tracer module
            return a list of objKey and their parameters to be set by the Neg2Gui class
        """
        _infoer.function = str(self.setParamsByModule)
        _infoer.write("setParamsByModule ")
        pChangeList = []
        newparams = CopyParams(self.params)
        if mparam == 'startpoint1':
            self.__startpoint1 = mvalue
            if self.params.alignedRectangle.orthogonalAxis == 'line':
                newparams.alignedRectangle.setStartEndPoint( float(self.__startpoint1[0]),\
                                                             float(self.__startpoint1[1]),\
                                                             float(self.__startpoint1[2]),\
                                                             float(self.__startpoint2[0]),\
                                                             float(self.__startpoint2[1]),\
                                                             float(self.__startpoint2[2]) )
            else:
                return pChangeList

            #return pChangeList
        if mparam == 'startpoint2':
            self.__startpoint2 = mvalue
            if self.params.alignedRectangle.orthogonalAxis == 'line':
                newparams.alignedRectangle.setStartEndPoint( float(self.__startpoint1[0]),\
                                                             float(self.__startpoint1[1]),\
                                                             float(self.__startpoint1[2]),\
                                                             float(self.__startpoint2[0]),\
                                                             float(self.__startpoint2[1]),\
                                                             float(self.__startpoint2[2]) )
            else:
                return pChangeList

        if mparam == 'direction':
            if not self.params.alignedRectangle.orthogonalAxis == 'line':
                aaa = RectangleIn3d2Ps1Dir(
                )  #convertAlignedRectangleToGeneral(self.params.alignedRectangle)
                if self.__startpoint1:
                    aaa.pointA = (float(self.__startpoint1[0]),
                                  float(self.__startpoint1[1]),
                                  float(self.__startpoint1[2]))
                if self.__startpoint2:
                    aaa.pointC = (float(self.__startpoint2[0]),
                                  float(self.__startpoint2[1]),
                                  float(self.__startpoint2[2]))
                aaa.direction = (float(mvalue[0]), float(mvalue[1]),
                                 float(mvalue[2]))
                xxx = convertGeneralToAlignedRectangle(
                    aaa, self.params.alignedRectangle.orthogonalAxis)
                newparams.alignedRectangle = xxx
                self.__startpoint1 = None
                self.__startpoint2 = None
        if mparam == 'trace_len':
            newparams.len = float(mvalue[0])
        if mparam == 'no_startp':
            try:
                newparams.no_startp = int(mvalue[2])
            except ValueError:
                newparams.no_startp = int(float(mvalue[2]))
        if mparam == 'taskType':
            newparams.taskType = int(mvalue[0])
        if mparam == 'Min/Max':
            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 not hasattr(cTableObject.params, 'dependantKeys'):
                    cTableObject.params.dependantKeys = []
                if self.key not in cTableObject.params.dependantKeys:
                    cTableObject.params.dependantKeys.append(self.key)
                pChangeList.append((cTableObject.key, cTableObject.params))
        if mparam == 'startStyle':
            newparams.start_style = int(mvalue[0])
        if mparam == 'FreeStartPoints':
            newparams.freeStartPoints = mvalue
            self.oldFreeStartPoints = mvalue

        pChangeList.append((self.key, newparams))

        return pChangeList
コード例 #40
0
    def updateForObject( self, keys ):
        """ called from MainWindow to update the content to the choosen object key

        Default params will be shown if there is more than 1 key"""
        _infoer.function = str(self.updateForObject)
        _infoer.write("")

        if isinstance( keys, int ) :
            self.__keys = [keys]
        elif isinstance( keys, list ) and len(keys)>0 :
            self.__keys = keys
        else :
            return
        # if a type_2d_composed_part disable the first two tabs (coloring and shader)
        if len(self.__keys)==1 :
            # enable the visualization and the transform tab
            self.TabWidgetGeneralAdvanced.setTabEnabled(0, True)
            self.TabWidgetGeneralAdvanced.setTabEnabled(1, True)
            self.TabWidgetGeneralAdvanced.setTabEnabled(2, True)
            self.TabWidgetGeneralAdvanced.setTabEnabled(3, True)

            if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_COMPOSED_PART:
                self.TabWidgetGeneralAdvanced.setTabEnabled(0, False)
                self.TabWidgetGeneralAdvanced.setTabEnabled(1, False)
            # if not a type_2d_part disable the transform tab
            if ObjectMgr().getTypeOfObject(self.__keys[0]) != TYPE_2D_PART:
                self.TabWidgetGeneralAdvanced.setTabEnabled(3, False)
            # if not a type_2d_cutgeometry_part disable the cut tab
            if ObjectMgr().getTypeOfObject(self.__keys[0]) != TYPE_2D_CUTGEOMETRY_PART:
                self.TabWidgetGeneralAdvanced.setTabEnabled(4, False)

        elif len(self.__keys) > 1 : # multi selection
            # always show first tab
            self.TabWidgetGeneralAdvanced.setCurrentIndex(0)
            # disable the visualization and the transform tab
            self.TabWidgetGeneralAdvanced.setTabEnabled(2, False)
            self.TabWidgetGeneralAdvanced.setTabEnabled(3, False)

        # set the variables of first key
        self.__setScalarVariables(ObjectMgr().getPossibleScalarVariablesForType(self.__keys[0]))
        self.__setVectorVariables(ObjectMgr().getPossibleVectorVariablesForType(self.__keys[0]))

        # apply params
        if len(self.__keys) == 1 :
            realparams = ObjectMgr().getRealParamsOfObject(self.__keys[0])
            params = ObjectMgr().getParamsOfObject(self.__keys[0])
            params.name = realparams.name
            #params.boundingBox = realparams.boundingBox
            if isinstance(params, int) or isinstance(params, Part2DRawVisParams):
                self.__setParams( params )
            self.__setRealParams( realparams )
            # update
            Visualization2DPanel.updateForObject(self, self.__keys[0])
        elif len(self.__keys) > 1 :
            # multi selection: show default params
            self.oldPanelParams = Part2DRawVisParams()
            params = CopyParams(self.oldPanelParams)
            self.__setParams( params )
            if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_PART:
                self.oldPanelRealParams = co2DPartMgrParams()
            if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_COMPOSED_PART:
                self.oldPanelRealParams = co2DComposedPartMgrParams()
            if ObjectMgr().getTypeOfObject(self.__keys[0]) == TYPE_2D_CUTGEOMETRY_PART:
                self.oldPanelRealParams = co2DCutGeometryPartMgrParams()
                #self.oldPanelRealParams.name = coTranslate("Multiselection")
                self.oldPanelRealParams.name = "Multiselection"
            realparams = CopyParams(self.oldPanelRealParams)
            self.__setRealParams( realparams )
            # set ComboBoxVariable on default value
            self.vrpComboBoxVariable_2.setCurrentIndex(0)