Beispiel #1
0
    def processCommand(self, terms):
        print " -- processCommand: %s " % str( terms )
        if terms[0] == "reltimestep":
            relTimeValue = float( terms[1] )  
            relTimeIndex = float( terms[2] )  
            useTimeIndex = bool(terms[3]) 
            displayText =  terms[4] 
            if self.current_pipeline:
                for module in self.current_pipeline.module_list:
                    persistentCellModule = ModuleStore.getModule( module.id ) 
                    if persistentCellModule: persistentCellModule.updateAnimation( [ relTimeValue, relTimeIndex, useTimeIndex ], displayText  )
        elif terms[0] == "pipelineHelper":
            if self.current_config_function:
                if self.current_config_function.type == 'leveling':
                    range = list( self.current_config_function.range )
                    cmd_args = terms[1].split('-')
                    iRangeArg = int( cmd_args[1] )
                    range[ iRangeArg ] = float( terms[2] )
#                    print " --- PipelineHelper: set range = ", str( range )
                    self.current_config_function.broadcastLevelingData( range  )
                else:
                    pass
#                    print " --- PipelineHelper, config type: ", self.current_config_function.type
        else:
            if self.current_pipeline:
                for module in self.current_pipeline.module_list:
                    persistentCellModule = ModuleStore.getModule( module.id ) 
                    if persistentCellModule: persistentCellModule.updateConfigurationObserver( terms[0], terms[1:] )
Beispiel #2
0
    def processCommand(self, terms):
        print " -- processCommand: %s " % str(terms)
        if terms[0] == "reltimestep":
            relTimeValue = float(terms[1])
            relTimeIndex = float(terms[2])
            useTimeIndex = bool(terms[3])
            displayText = terms[4]
            if self.current_pipeline:
                for module in self.current_pipeline.module_list:
                    persistentCellModule = ModuleStore.getModule(module.id)
                    if persistentCellModule:
                        persistentCellModule.updateAnimation(
                            [relTimeValue, relTimeIndex, useTimeIndex],
                            displayText)
        elif terms[0] == "pipelineHelper":
            if self.current_config_function:
                if self.current_config_function.type == 'leveling':
                    range = list(self.current_config_function.range)
                    cmd_args = terms[1].split('-')
                    iRangeArg = int(cmd_args[1])
                    range[iRangeArg] = float(terms[2])
                    #                    print " --- PipelineHelper: set range = ", str( range )
                    self.current_config_function.broadcastLevelingData(range)
                else:
                    pass
#                    print " --- PipelineHelper, config type: ", self.current_config_function.type
        else:
            if self.current_pipeline:
                for module in self.current_pipeline.module_list:
                    persistentCellModule = ModuleStore.getModule(module.id)
                    if persistentCellModule:
                        persistentCellModule.updateConfigurationObserver(
                            terms[0], terms[1:])
Beispiel #3
0
 def finalizePlot( self, plot_name ):
     from packages.vtDV3D import ModuleStore
     from packages.vtDV3D.CDMS_VariableReaders import CDMSTransientVariable
     from core.db.action import create_action
     proj_controller = self.app.uvcdatWindow.get_current_project_controller()
     controller = self.app.get_controller()
     plot = proj_controller.plot_registry.add_plot( plot_name, 'DV3D', None, None )
     action = create_action( self.port_ops ) 
     controller.add_new_action(action)
     controller.perform_action(action)
     controller.select_latest_version()
     current_version = controller.current_version
     proj_controller.plot_was_dropped( (plot, self.sheetName, self.row, self.col) )
     proj_controller.execute_plot( current_version )
     controller.change_selected_version( current_version )
     proj_controller.update_plot_configure( self.sheetName, self.row, self.col )
     cell = proj_controller.sheet_map[ self.sheetName ][ ( self.row, self.col ) ]
     cell.current_parent_version = current_version
       
     cell_address = "%s%s" % ( chr(ord('A') + self.col ), self.row + 1 )
     sheetName = proj_controller.current_sheetName
     cell_location = [ proj_controller.name, sheetName, cell_address ]                
     pipeline = controller.current_pipeline              
     for mid in pipeline.modules.keys():
         pmod = ModuleStore.getModule( mid ) 
         if pmod: pmod.setCellLocation( cell_location )
     
     for ( name, var ) in self.variables:
         dvar = CDMSTransientVariable.from_module( var )
         proj_controller.defined_variables[ name ] = dvar
     proj_controller.emit( QtCore.SIGNAL("update_cell"), self.sheetName, self.row, self.col, None, None, 'DV3D', current_version )
Beispiel #4
0
 def getPersistentModule( self, **args ):
     mid = self.moduleInfo['moduleId']
     force = args.get('force',False)
     module = ModuleStore.getModule( mid ) 
     if force and ( module == None ):
         module = ModuleStore.forceGetModule(  mid, self.__class__.PersistentModuleClass( mid, **args ) ) 
     if module:     
         invalidate = args.get('invalidate',False)
         if invalidate:  module.invalidateWorkflowModule( self )
         else:           module.setWorkflowModule( self ) 
     return module
Beispiel #5
0
 def getPersistentModule(self, **args):
     mid = self.moduleInfo['moduleId']
     force = args.get('force', False)
     module = ModuleStore.getModule(mid)
     if force and (module == None):
         module = ModuleStore.forceGetModule(
             mid, self.__class__.PersistentModuleClass(mid, **args))
     if module:
         invalidate = args.get('invalidate', False)
         if invalidate: module.invalidateWorkflowModule(self)
         else: module.setWorkflowModule(self)
     return module
Beispiel #6
0
    def finalizePlot(self, plot_name):
        from packages.vtDV3D import ModuleStore
        from packages.vtDV3D.CDMS_VariableReaders import CDMSTransientVariable
        from core.db.action import create_action
        proj_controller = self.app.uvcdatWindow.get_current_project_controller(
        )
        controller = self.app.get_controller()
        plot = proj_controller.plot_registry.add_plot(plot_name, 'DV3D', None,
                                                      None)
        action = create_action(self.port_ops)
        controller.add_new_action(action)
        controller.perform_action(action)
        controller.select_latest_version()
        current_version = controller.current_version
        proj_controller.plot_was_dropped(
            (plot, self.sheetName, self.row, self.col))
        proj_controller.execute_plot(current_version)
        controller.change_selected_version(current_version)
        proj_controller.update_plot_configure(self.sheetName, self.row,
                                              self.col)
        cell = proj_controller.sheet_map[self.sheetName][(self.row, self.col)]
        cell.current_parent_version = current_version

        cell_address = "%s%s" % (chr(ord('A') + self.col), self.row + 1)
        sheetName = proj_controller.current_sheetName
        cell_location = [proj_controller.name, sheetName, cell_address]
        pipeline = controller.current_pipeline
        for mid in pipeline.modules.keys():
            pmod = ModuleStore.getModule(mid)
            if pmod: pmod.setCellLocation(cell_location)

        for (name, var) in self.variables:
            dvar = CDMSTransientVariable.from_module(var)
            proj_controller.defined_variables[name] = dvar
        proj_controller.emit(QtCore.SIGNAL("update_cell"), self.sheetName,
                             self.row, self.col, None, None, 'DV3D',
                             current_version)
Beispiel #7
0
    def processEvent(self, terms):
        """processEvent(message: String) -> None
        decodifies the event received by the server and posts it to QT's event handler. In order
        to do this, we must send three events: the first one disables this client's method that
        would send events to the server. The second is the actual event we want processed and the third
        reenables event sending to the server. This must be done to avoid a deadlock"""
        def decodeMouseEvent( event, screenDims ):
            """decodeMouseEvent(event: String) -> QtGui.QMouseEvent
            this method receives a string and returns the corresponding mouse event"""
            pos = ( int( float( event[2] ) * screenDims[0] ), int( float( event[3] ) * screenDims[1] ) )
            if event[1] == "left":
                button = QtCore.Qt.LeftButton
            elif event[1] == "right":
                button = QtCore.Qt.RightButton

            if event[0] == "singleClick": 
                t = QtCore.QEvent.MouseButtonPress
            elif event[0] == "mouseMove": 
                t = QtCore.QEvent.MouseMove
                button = QtCore.Qt.NoButton
            elif event[0] == "mouseRelease": 
                t = QtCore.QEvent.MouseButtonRelease

            button = QtCore.Qt.MouseButton(button)
            m = QtCore.Qt.NoModifier
            if event[4] == "shift": 
                m = QtCore.Qt.ShiftModifier
            elif event[4] == "ctrl": 
                m = QtCore.Qt.ControlModifier
            elif event[4] == "alt": 
                m = QtCore.Qt.AltModifier
#            print " Client process %s %s event: pos = %s, screenDims=%s " % ( button, event[0], str( pos ), str( screenDims ) )

            return QtGui.QMouseEvent(t, QtCore.QPoint(pos[0], pos[1]), button, button, m)

        def decodeKeyEvent(event):
            """decodeKeyEvent(event: String) -> QtGui.QKeyEvent
            this method receives a string and returns the corresponding Key event"""
            type = None
            if event[0] == "keyPress":
                type = QtCore.QEvent.KeyPress
            elif event[0] == "keyRelease":
                type = QtCore.QEvent.KeyRelease
                
            key = int( event[1] )
            
            m = QtCore.Qt.NoModifier
            if event[2] == "shift": 
                m = QtCore.Qt.ShiftModifier
            elif event[2] == "ctrl": 
                m = QtCore.Qt.ControlModifier
            elif event[2] == "alt": 
                m = QtCore.Qt.AltModifier
#            print " Client process key event: %s " % str( event )

            return QtGui.QKeyEvent( type, key, QtCore.Qt.KeyboardModifiers(m) )

        app = QtCore.QCoreApplication.instance()
        newTab = self.updateCurrentTab()
        widget = self.currentTab.getCellWidget( 0, 0 ) if self.currentTab else None
                  
#        print " ------------- QiVisClient.processEvent: %s  ---------------------" % ( str(terms) )
        sys.stdout.flush()
        
        if terms[2] == "interactionState":           
            if self.current_pipeline:
                state =   terms[3] if ( len(terms) > 3 ) else None
                altMode = terms[4] if ( len(terms) > 4 ) else None
                print " ~~~~~ Setting Client Interaction State: ", str(state), str(altMode)
                sys.stdout.flush()
                for module in self.current_pipeline.module_list:
                    persistentModule = ModuleStore.getModule( module.id ) 
                    if persistentModule:
                        cf = persistentModule.updateInteractionState( state, altMode ) 
                        if cf: self.current_config_function = cf  
                    else: print "Can't find client persistentModule: ", module.id        
        else: 
            newEvent = None      
            if terms[2] == "singleClick":
                cellModules = self.getCellModules()
                cpos = [ float(terms[i]) for i in range(7,10) ]
                cfol = [ float(terms[i]) for i in range(10,13) ]
                cup  = [ float(terms[i]) for i in range(13,16) ]
    #            print " >>> QiVisClient.cellModules: %s, modules: %s" % ( str( [ cellMod.id for cellMod in cellModules ] ), str( ModuleStore.getModuleIDs() ) )           
                for cellMod in cellModules:
                    persistentCellModule = ModuleStore.getModule( cellMod.id ) 
                    if persistentCellModule: persistentCellModule.syncCamera( cpos, cfol, cup )            
            if terms[2] in ["singleClick", "mouseMove", "mouseRelease"]:
                if self.currentTab:
                    screenRect = self.currentTab.getCellRect( 0, 0 )
                    screenDims = ( screenRect.width(), screenRect.height() )
                    newEvent = decodeMouseEvent( terms[2:], screenDims )
            elif terms[2] in ["keyPress", "keyRelease" ]:
                newEvent = decodeKeyEvent(terms[2:])
    
            if widget and newEvent: 
                cellWidget = widget.widget()
                app.postEvent( cellWidget, newEvent)
                cellWidget.setFocus()
                cellWidget.update()
Beispiel #8
0
    def processEvent(self, terms):
        """processEvent(message: String) -> None
        decodifies the event received by the server and posts it to QT's event handler. In order
        to do this, we must send three events: the first one disables this client's method that
        would send events to the server. The second is the actual event we want processed and the third
        reenables event sending to the server. This must be done to avoid a deadlock"""
        def decodeMouseEvent(event, screenDims):
            """decodeMouseEvent(event: String) -> QtGui.QMouseEvent
            this method receives a string and returns the corresponding mouse event"""
            pos = (int(float(event[2]) * screenDims[0]),
                   int(float(event[3]) * screenDims[1]))
            if event[1] == "left":
                button = QtCore.Qt.LeftButton
            elif event[1] == "right":
                button = QtCore.Qt.RightButton

            if event[0] == "singleClick":
                t = QtCore.QEvent.MouseButtonPress
            elif event[0] == "mouseMove":
                t = QtCore.QEvent.MouseMove
                button = QtCore.Qt.NoButton
            elif event[0] == "mouseRelease":
                t = QtCore.QEvent.MouseButtonRelease

            button = QtCore.Qt.MouseButton(button)
            m = QtCore.Qt.NoModifier
            if event[4] == "shift":
                m = QtCore.Qt.ShiftModifier
            elif event[4] == "ctrl":
                m = QtCore.Qt.ControlModifier
            elif event[4] == "alt":
                m = QtCore.Qt.AltModifier
#            print " Client process %s %s event: pos = %s, screenDims=%s " % ( button, event[0], str( pos ), str( screenDims ) )

            return QtGui.QMouseEvent(t, QtCore.QPoint(pos[0], pos[1]), button,
                                     button, m)

        def decodeKeyEvent(event):
            """decodeKeyEvent(event: String) -> QtGui.QKeyEvent
            this method receives a string and returns the corresponding Key event"""
            type = None
            if event[0] == "keyPress":
                type = QtCore.QEvent.KeyPress
            elif event[0] == "keyRelease":
                type = QtCore.QEvent.KeyRelease

            key = int(event[1])

            m = QtCore.Qt.NoModifier
            if event[2] == "shift":
                m = QtCore.Qt.ShiftModifier
            elif event[2] == "ctrl":
                m = QtCore.Qt.ControlModifier
            elif event[2] == "alt":
                m = QtCore.Qt.AltModifier
#            print " Client process key event: %s " % str( event )

            return QtGui.QKeyEvent(type, key, QtCore.Qt.KeyboardModifiers(m))

        app = QtCore.QCoreApplication.instance()
        newTab = self.updateCurrentTab()
        widget = self.currentTab.getCellWidget(0,
                                               0) if self.currentTab else None

        #        print " ------------- QiVisClient.processEvent: %s  ---------------------" % ( str(terms) )
        sys.stdout.flush()

        if terms[2] == "interactionState":
            if self.current_pipeline:
                state = terms[3] if (len(terms) > 3) else None
                altMode = terms[4] if (len(terms) > 4) else None
                print " ~~~~~ Setting Client Interaction State: ", str(
                    state), str(altMode)
                sys.stdout.flush()
                for module in self.current_pipeline.module_list:
                    persistentModule = ModuleStore.getModule(module.id)
                    if persistentModule:
                        cf = persistentModule.updateInteractionState(
                            state, altMode)
                        if cf: self.current_config_function = cf
                    else:
                        print "Can't find client persistentModule: ", module.id
        else:
            newEvent = None
            if terms[2] == "singleClick":
                cellModules = self.getCellModules()
                cpos = [float(terms[i]) for i in range(7, 10)]
                cfol = [float(terms[i]) for i in range(10, 13)]
                cup = [float(terms[i]) for i in range(13, 16)]
                #            print " >>> QiVisClient.cellModules: %s, modules: %s" % ( str( [ cellMod.id for cellMod in cellModules ] ), str( ModuleStore.getModuleIDs() ) )
                for cellMod in cellModules:
                    persistentCellModule = ModuleStore.getModule(cellMod.id)
                    if persistentCellModule:
                        persistentCellModule.syncCamera(cpos, cfol, cup)
            if terms[2] in ["singleClick", "mouseMove", "mouseRelease"]:
                if self.currentTab:
                    screenRect = self.currentTab.getCellRect(0, 0)
                    screenDims = (screenRect.width(), screenRect.height())
                    newEvent = decodeMouseEvent(terms[2:], screenDims)
            elif terms[2] in ["keyPress", "keyRelease"]:
                newEvent = decodeKeyEvent(terms[2:])

            if widget and newEvent:
                cellWidget = widget.widget()
                app.postEvent(cellWidget, newEvent)
                cellWidget.setFocus()
                cellWidget.update()