Exemplo n.º 1
0
    def setParams(self, params, negMsgHandler=None, sendToCover=True):
        """ set parameters from outside """
        _infoer.function = str(self.setParams)
        _infoer.write("setParams")

        if not params.isVisible == self.params.isVisible:
            if params.isVisible and not self.__connected:
                connect(self.connectionPoint(),
                        globalRenderer().connectionPoint())
                self.__connected = True
            elif not params.isVisible and self.__connected:
                disconnect(self.connectionPoint(),
                           globalRenderer().connectionPoint())
                self.__connected = False

        realChange = ParamsDiff(self.params, params)
        VisItem.setParams(self, params, negMsgHandler, sendToCover)

        if params.clickedSensorID != None:
            msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, params.filename,
                                        params.clickedSensorID, True, True)
            covise.sendRendMsg(msg.c_str())
            msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, params.filename,
                                        params.clickedSensorID, True, False)
            covise.sendRendMsg(msg.c_str())

            # clickedSensorButtonEvent was handled and can be removed
            self.params.clickedSensorID = None
            self.sendParams()
Exemplo n.º 2
0
    def setParams(self, params, negMsgHandler=None, sendToCover=True):
        """ set parameters from outside """
        _infoer.function = str(self.setParams)
        _infoer.write("setParams")

        if not params.isVisible == self.params.isVisible:
            if params.isVisible and not self.__connected:
                connect(self.connectionPoint(), globalRenderer().connectionPoint())
                self.__connected = True
            elif not params.isVisible and self.__connected:
                disconnect(self.connectionPoint(), globalRenderer().connectionPoint())
                self.__connected = False

        realChange = ParamsDiff(self.params, params)
        VisItem.setParams(self, params, negMsgHandler, sendToCover)

        if params.clickedSensorID != None:
            msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, params.filename, params.clickedSensorID, True, True)
            covise.sendRendMsg(msg.c_str())
            msg = coGRObjSensorEventMsg(coGRMsg.SENSOR_EVENT, params.filename, params.clickedSensorID, True, False)
            covise.sendRendMsg(msg.c_str())

            # clickedSensorButtonEvent was handled and can be removed
            self.params.clickedSensorID = None
            self.sendParams()
Exemplo n.º 3
0
    def setRotation(self, angle, x, y, z, execute=True):
        self.__rotX = x
        self.__rotY = y
        self.__rotZ = z
        self.__rotAngle = angle

        # create new module if necessary
        if self.__rotation == None:
            self.__rotation = TransformModule()
            connect(self.iGroupModule.geoConnectionPoint(),
                    self.__rotation.geoInConnectionPoint())
            if self.__translation == None:
                pass
            else:
                disconnect(self.iGroupModule.geoConnectionPoint(),
                           self.__translation.geoInConnectionPoint())
                connect(self.__rotation.geoOutConnectionPoint(),
                        self.__translation.geoInConnectionPoint())
                connect(self.__rotation.data0OutConnectionPoint(),
                        self.__translation.data0InConnectionPoint())
                connect(self.__rotation.data1OutConnectionPoint(),
                        self.__translation.data1InConnectionPoint())
                connect(self.__rotation.data2OutConnectionPoint(),
                        self.__translation.data2InConnectionPoint())
                connect(self.__rotation.data3OutConnectionPoint(),
                        self.__translation.data3InConnectionPoint())

        self.__rotation.setRotation(self.__rotAngle, self.__rotX, self.__rotY,
                                    self.__rotZ)
        if execute:
            self.__rotation.execute()
            return True
        return False
Exemplo n.º 4
0
    def setRotation(self, angle, x,y,z , execute=True):
        self.__rotX = x
        self.__rotY = y
        self.__rotZ = z
        self.__rotAngle = angle

        # create new module if necessary
        if self.__rotation == None:
            self.__rotation = TransformModule()
            connect( self.iGroupModule.geoConnectionPoint(), self.__rotation.geoInConnectionPoint() )
            if self.__translation == None:
                pass
            else:
                disconnect(self.iGroupModule.geoConnectionPoint(), self.__translation.geoInConnectionPoint())
                connect(self.__rotation.geoOutConnectionPoint(), self.__translation.geoInConnectionPoint())
                connect(self.__rotation.data0OutConnectionPoint(), self.__translation.data0InConnectionPoint())
                connect(self.__rotation.data1OutConnectionPoint(), self.__translation.data1InConnectionPoint())
                connect(self.__rotation.data2OutConnectionPoint(), self.__translation.data2InConnectionPoint())
                connect(self.__rotation.data3OutConnectionPoint(), self.__translation.data3InConnectionPoint())
        
        self.__rotation.setRotation(self.__rotAngle, self.__rotX, self.__rotY, self.__rotZ)
        if execute:
            self.__rotation.execute()
            return True
        return False
Exemplo n.º 5
0
    def __update(self):
        """ do init if necessary; update module parameters """
        self.__init()

        # update input
        dataInConnect = self.importModule.dataConnectionPoint(
            self.params.variable)
        if not self.__lastDataConnection == None:
            disconnect(self.__lastDataConnection, self.__colorsIn)
        else:
            theNet().connect(self.__colors, 'TextureOut0', self.__collect,
                             'TextureIn0')

        if dataInConnect:
            connect(
                self.importModule.dataConnectionPoint(self.params.variable),
                self.__colorsIn)
        self.__lastDataConnection = self.importModule.dataConnectionPoint(
            self.params.variable)

        _infoer.function = str(self.__update)
        _infoer.write(": updating to variable " + self.params.variable)

        # update colormap settings
        self.__colors.set_numSteps(self.params.numSteps)
Exemplo n.º 6
0
    def _update(self, negMsgHandler):
        ''' _update is called from the run method to update the module parameter before execution
            + do init the module if necessary
            update module parameters should be realized in the parent class'''
        self._init(negMsgHandler)

        if not hasattr(self, 'importModule'):
            return

        # update input
        # vec variable
        # vec variable is not changable from the Gui at the moment

        #scalar variable
        if not self._lastScalarConnection == None:
            for scalarInput in self._scalarInputNames:
                disconnect(self._lastScalarConnection,
                           ConnectionPoint(self._module, scalarInput))
        if hasattr(self.params, 'secondVariable') and len(
                self._scalarInputNames
        ) > 0 and not self.params.secondVariable == None:
            self.importModule.executeData(self.params.secondVariable)
            scalarInConnect = self.importModule.dataConnectionPoint(
                self.params.secondVariable)
            if scalarInConnect:
                for scalarInput in self._scalarInputNames:
                    connect(scalarInConnect,
                            ConnectionPoint(self._module, scalarInput))
                self._lastScalarConnection = scalarInConnect

        # starting points from 2d part
        if not self._last2DPartConnection == None:
            part2D = globalKeyHandler().getObject(self.params.use2DPartKey)
            if not part2D or not self._last2DPartConnection == part2D.importModule.geoConnectionPoint(
            ):
                for partInput in self._2DPartInputNames:
                    disconnect(self._last2DPartConnection,
                               ConnectionPoint(self._module, partInput))
                self._last2DPartConnection = None
        if len(
                self._2DPartInputNames
        ) > 0 and self.params.use2DPartKey != None and self.params.use2DPartKey >= 0 and self._last2DPartConnection == None:
            # sampling removed at the moment
            part2D = globalKeyHandler().getObject(self.params.use2DPartKey)
            part2D.importModule.executeGeo()
            for partInput in self._2DPartInputNames:
                connect(part2D.importModule.geoConnectionPoint(),
                        ConnectionPoint(self._module, partInput))
                if self._firstGeoForVars:
                    self._firstGeoForVars = False
                    #setTransform to module
                    negMsgHandler.run(self.params.use2DPartKey)
            self._last2DPartConnection = part2D.importModule.geoConnectionPoint(
            )

        self._module.setTitle(self.params.name)
Exemplo n.º 7
0
    def run(self, runmode, negMsgHandler, module, afterRecreation=False):
        if os.getenv('VR_PREPARE_DEBUG_RUN'):
            print("PartColoredVis.run")
        '''create a new visulisation'''
        #assert negMsgHandler

        if runmode==RUN_ALL:
            if not hasattr(self, 'importModule'):
                return False

            _infoer.function = str(self.run)
            _infoer.write("go colored vis for %s" % self.params.variable)


            PartColoredVis._update(self, negMsgHandler)

            #update colortable at the first time after recreation
            #if afterRecreation and len(self.objects)>0:
            #    colorCreator = self.objects[0]
            #    return colorCreator.run(RUN_ALL)

            #if not self.__needExecute:
            #    # TODO: self.__needExecute zu oft auf False -> geaenderte color map wird nicht uebernommen
            #    #return False
            #self.__needExecute = False

            """
            # to be sure that the import module loaded all data
            self.importModule.executeOct()

            if not self.importModule.executeData(self.currentVariable()):
                if len(self.objects)>0:
                    colorCreator = self.objects[0]
                    # the colorCreator contains a colors module which is connected to the import of the tracer
                    # implicit execution of the tracer module
                    colorCreator.run(RUN_ALL)
                    return True
                #else:
                #    module.execute()
            """

            if len(self.objects)>0:
                colorCreator = self.objects[0]
                if self._visualizerColorCP:
                    # Since we dont know if the visualizers module is actually ready to execute,
                    # we dont want it to be executed along with the colors module.
                    # Therefore the disconnect.
                    disconnect(colorCreator.colorMapConnectionPoint(), self._visualizerColorCP)
                colorCreator.run(RUN_ALL)
                if self._visualizerColorCP:
                    connect(colorCreator.colorMapConnectionPoint(), self._visualizerColorCP)

            return False # always return False because the visualizers module is disconnected and wont be executed
Exemplo n.º 8
0
    def _update(self, negMsgHandler):
        ''' _update is called from the run method to update the module parameter before execution
            + do init the module if necessary
            update module parameters should be realized in the parent class'''
        self._init(negMsgHandler)

        if not hasattr(self, 'importModule'):
            return
            
        # update input
        # vec variable
        # vec variable is not changable from the Gui at the moment

        #scalar variable
        if not self._lastScalarConnection==None :
            for scalarInput in self._scalarInputNames:
                disconnect( self._lastScalarConnection,  ConnectionPoint(self._module, scalarInput))
        if hasattr(self.params, 'secondVariable') and len(self._scalarInputNames)>0 and not self.params.secondVariable==None:
            self.importModule.executeData(self.params.secondVariable)
            scalarInConnect = self.importModule.dataConnectionPoint(self.params.secondVariable)
            if scalarInConnect:
                for scalarInput in self._scalarInputNames:
                    connect( scalarInConnect, ConnectionPoint(self._module, scalarInput) )
                self._lastScalarConnection=scalarInConnect

        # starting points from 2d part     
        if not self._last2DPartConnection==None:
            part2D = globalKeyHandler().getObject(self.params.use2DPartKey)
            if not part2D or not self._last2DPartConnection==part2D.importModule.geoConnectionPoint():
                for partInput in self._2DPartInputNames:
                    disconnect( self._last2DPartConnection,  ConnectionPoint(self._module, partInput))
                self._last2DPartConnection = None
        if len(self._2DPartInputNames)>0 and self.params.use2DPartKey!=None and self.params.use2DPartKey>=0 and self._last2DPartConnection==None:
            # sampling removed at the moment
            part2D = globalKeyHandler().getObject(self.params.use2DPartKey)
            part2D.importModule.executeGeo()         
            for partInput in self._2DPartInputNames:
                connect( part2D.importModule.geoConnectionPoint(), ConnectionPoint(self._module, partInput) )
                if self._firstGeoForVars:
                    self._firstGeoForVars = False
                    #setTransform to module
                    negMsgHandler.run(self.params.use2DPartKey)
            self._last2DPartConnection=part2D.importModule.geoConnectionPoint()

        self._module.setTitle( self.params.name )
Exemplo n.º 9
0
    def __update(self):
        """ do init if necessary; update module parameters """
        self.__init()

        # update input
        dataInConnect = self.importModule.dataConnectionPoint(self.params.variable)
        if not self.__lastDataConnection==None :
            disconnect( self.__lastDataConnection, self.__colorsIn )
        else :
            theNet().connect(self.__colors, 'TextureOut0', self.__collect, 'TextureIn0')

        if dataInConnect:
            connect( self.importModule.dataConnectionPoint(self.params.variable), self.__colorsIn )
        self.__lastDataConnection=self.importModule.dataConnectionPoint(self.params.variable)

        _infoer.function = str(self.__update)
        _infoer.write(": updating to variable " + self.params.variable )

        # update colormap settings
        self.__colors.set_numSteps(self.params.numSteps)
Exemplo n.º 10
0
    def __update(self, negMsgHandler):
        """ __update is called from the run method to update the module parameter before execution
            + do init
            + update module parameters """
        self.__init(negMsgHandler)

        PartModuleVis._update(self, negMsgHandler)
        if self.params.color==VARIABLE:
            PartColoredVis._update(self, negMsgHandler)
        self._setTransform()

        if not hasattr(self, 'importModule'):
            return

        #set color for variable
        if not self.__lastColorConnection==None:
            disconnect(self.__lastColorConnection, ConnectionPoint(self._module, 'DataIn0'))
            self.__lastColorConnection=None
        if self.__lastColorConnection==None and self.params.variable!=None \
            and self.params.variable!='Select a variable' and self.params.color == VARIABLE and len(self.objects)>0:
            _infoer.function = str(self.__update)
            _infoer.write("connection color for variable %s " % self.params.variable)
            self.__lastColorConnection =  (self.objects[0]).colorContConnectionPoint()
            connect(self.__lastColorConnection, ConnectionPoint(self._module, 'DataIn0'))
Exemplo n.º 11
0
    def setParams( self, params, negMsgHandler=None, sendToCover=True):
        """ set parameters from outside
            + init tracer module if necessary
            + mainly receive parameter changes from Gui
            + send status messages to COVER if state has changed
        """
        _infoer.function = str(self.setParams)
        _infoer.write(" ")
        # save the old variable to delete from colorTable
        oldVariable = self.currentVariable()
        oldTable = None
        if oldVariable!=None and oldVariable!= 'Select a variable':
            if hasattr(self.params.colorTableKey, oldVariable):
                oldTable = globalKeyHandler().getObject(self.params.colorTableKey[oldVariable])

        realChange = ParamsDiff( self.params, params )

        PartModuleVis.setParams(self, params, negMsgHandler, sendToCover, realChange)
        if self.params.color == VARIABLE:
            PartColoredVis.setParams(self, params, negMsgHandler, sendToCover, realChange)
        PartTransform.setParams(self, params, negMsgHandler, sendToCover, realChange)

        needsTransparency = False
        needsShader = False

        if hasattr (params, 'color') and (params.color == NO_COLOR) \
                and ('color' in realChange):
            # disconnect colors module and run the collect module
            # (we dont want to call run since we dont need the children to be executed)
            if not self.__lastColorConnection==None:
                disconnect(self.__lastColorConnection, ConnectionPoint(self._module, 'DataIn0'))
                self.__lastColorConnection=None
            PartModuleVis.run(self, RUN_ALL, negMsgHandler)
            needsTransparency = True
        elif hasattr (params, 'color') and (params.color==RGB_COLOR) \
                and (('color' in realChange) or ('r' in realChange) or ('g' in realChange) or ('b' in realChange)):
            self.__sendColor()
            needsTransparency = True
        elif hasattr (params, 'color') and (params.color==MATERIAL) \
                and (('color' in realChange) or ('r' in realChange) or ('g' in realChange) or ('b' in realChange) \
                  or ('ambient' in realChange) or ('specular' in realChange) or ('shininess' in realChange)):
            self.__sendMaterial()
            needsTransparency = True
        elif hasattr(params, 'transparency') and ('transparency' in realChange):
            needsTransparency = True

        if 'variable' in realChange:
            # if variable changed append key to colorTable dependant keys
            # make sure this part is updated if colormap changes
            if params.variable!=None and params.variable!= 'Select a variable' and params.color == VARIABLE:
                # delete key from old colorTable
                if not  oldTable == None and self.key in oldTable.params.dependantKeys:
                    oldTable.params.dependantKeys.remove(self.key)
                # add key to new colorTable
                cTableObject = globalKeyHandler().getObject(params.colorTableKey[params.variable])
                params.baseObjectName = params.name
                if self.key not in cTableObject.params.dependantKeys:
                    cTableObject.params.dependantKeys.append(self.key)
                    if negMsgHandler:
                        negMsgHandler.internalRecvParams( cTableObject.key, cTableObject.params  )
                        negMsgHandler.sendParams( cTableObject.key, cTableObject.params )

        if ('shaderFilename' in realChange):
            needsTransparency = True
            needsShader = True

        # always send transparency before shader:
        # sendTransparency will ignore any shader transparency but sendShader respects the regular transparency if possible
        if needsTransparency and (params.shaderFilename != ""):
            needsShader = True
        if needsTransparency:
            self.__sendTransparency()
        if needsShader:
            self.__sendShader()