Beispiel #1
0
    def __init__(self, parent=None, **args):
        QDialog.__init__( self, parent )
        self.setWindowTitle("Transfer Function Configuration")
        self.graph = GraphWidget( size=(400,300), nticks=(5,5) )
        self.connect( self.graph, GraphWidget.nodeMovedSignal, self.graphAdjusted )
        self.connect( self.graph, GraphWidget.moveCompletedSignal, self.doneConfig )
        self.functions = {} 
        self.setLayout(QVBoxLayout())
        self.defaultTransferFunctionType = args.get( 'default_type', AbsValueTransferFunction )
        self.tf_map = { "Pos Value" : PosValueTransferFunction, "Neg Value" : NegValueTransferFunction, "Absolute Value" : AbsValueTransferFunction }
        self.currentTransferFunction = None
        
        tf_type_layout = QHBoxLayout()
        tf_type_label = QLabel( "Transfer Function Type:"  )
        tf_type_layout.addWidget( tf_type_label ) 

        tf_type_combo =  QComboBox ( self )
        tf_type_label.setBuddy( tf_type_combo )
        tf_type_combo.setMaximumHeight( 30 )
        tf_type_layout.addWidget( tf_type_combo )
        current_index, index = 0, 0
        for tf_name in self.tf_map.keys():
            if self.tf_map[tf_name] == self.defaultTransferFunctionType:
                current_index = index 
            tf_type_combo.addItem( tf_name )
            index = index + 1  
        tf_type_combo.setCurrentIndex( current_index )   
        self.connect( tf_type_combo, SIGNAL("currentIndexChanged(QString)"), self.updateTransferFunctionType )  
        self.layout().addLayout( tf_type_layout )
                
        self.closeButton = QPushButton('Ok', self)
        self.layout().addWidget( self.graph )         
        self.layout().addWidget(self.closeButton)
        self.connect(self.closeButton, SIGNAL('clicked(bool)'), self.close)
        self.closeButton.setShortcut('Enter')
Beispiel #2
0
class TransferFunctionConfigurationDialog(QDialog):
    def __init__(self, parent=None, **args):
        QDialog.__init__(self, parent)
        self.setWindowTitle("Transfer Function Configuration")
        self.graph = GraphWidget(size=(400, 300), nticks=(5, 5))
        self.connect(self.graph, GraphWidget.nodeMovedSignal,
                     self.graphAdjusted)
        self.connect(self.graph, GraphWidget.moveCompletedSignal,
                     self.doneConfig)
        self.functions = {}
        self.setLayout(QVBoxLayout())
        self.defaultTransferFunctionType = args.get('default_type',
                                                    AbsValueTransferFunction)
        self.tf_map = {
            "Pos Value": PosValueTransferFunction,
            "Neg Value": NegValueTransferFunction,
            "Absolute Value": AbsValueTransferFunction
        }
        self.currentTransferFunction = None

        tf_type_layout = QHBoxLayout()
        tf_type_label = QLabel("Transfer Function Type:")
        tf_type_layout.addWidget(tf_type_label)

        tf_type_combo = QComboBox(self)
        tf_type_label.setBuddy(tf_type_combo)
        tf_type_combo.setMaximumHeight(30)
        tf_type_layout.addWidget(tf_type_combo)
        current_index, index = 0, 0
        for tf_name in self.tf_map.keys():
            if self.tf_map[tf_name] == self.defaultTransferFunctionType:
                current_index = index
            tf_type_combo.addItem(tf_name)
            index = index + 1
        tf_type_combo.setCurrentIndex(current_index)
        self.connect(tf_type_combo, SIGNAL("currentIndexChanged(QString)"),
                     self.updateTransferFunctionType)
        self.layout().addLayout(tf_type_layout)

        self.closeButton = QPushButton('Ok', self)
        self.layout().addWidget(self.graph)
        self.layout().addWidget(self.closeButton)
        self.connect(self.closeButton, SIGNAL('clicked(bool)'), self.close)
        self.closeButton.setShortcut('Enter')

    def closeEvent(self, closeEvent):
        self.emit(SIGNAL('close()'))
        QDialog.closeEvent(self, closeEvent)

    def doneConfig(self):
        self.emit(SIGNAL('doneConfig()'))

    def addTransferFunction(self, name, **args):
        self.currentTransferFunction = TransferFunction(
            self.defaultTransferFunctionType, **args)
        self.functions[name] = self.currentTransferFunction
        self.graph.buildGraph()

    def initLeveling(self, range):
        pass

    def graphAdjusted(self, index, value0, value1, value2):
        self.emit(SIGNAL('config(int,float,float,float)'), index, value0,
                  value1, value2)

    def updateGraph(self, xbounds, ybounds, data):
        self.graph.redrawGraph(xbounds, ybounds, data)

    def updateTransferFunctionType(self, value):
        if self.currentTransferFunction:
            self.currentTransferFunction.setType(self.tf_map[str(value)])
        self.emit(SIGNAL('update'))

    def setTransferFunctionType(self, tf_type):
        if self.currentTransferFunction:
            if tf_type in self.tf_map.values():
                self.currentTransferFunction.type = tf_type

    def getTransferFunctionType(self):
        if self.currentTransferFunction:
            return self.currentTransferFunction.type
        return self.defaultTransferFunctionType
class TransferFunctionConfigurationDialog( QDialog ): 
     
    def __init__(self, parent=None, **args):
        QDialog.__init__( self, parent )
        self.setWindowTitle("Transfer Function Configuration")
        self.graph = GraphWidget( size=(400,300), nticks=(5,5) )
        self.connect( self.graph, GraphWidget.nodeMovedSignal, self.graphAdjusted )
        self.connect( self.graph, GraphWidget.moveCompletedSignal, self.doneConfig )
        self.functions = {} 
        self.setLayout(QVBoxLayout())
        self.defaultTransferFunctionType = args.get( 'default_type', AbsValueTransferFunction )
        self.tf_map = { "Pos Value" : PosValueTransferFunction, "Neg Value" : NegValueTransferFunction, "Absolute Value" : AbsValueTransferFunction }
        self.currentTransferFunction = None
        
        tf_type_layout = QHBoxLayout()
        tf_type_label = QLabel( "Transfer Function Type:"  )
        tf_type_layout.addWidget( tf_type_label ) 

        tf_type_combo =  QComboBox ( self )
        tf_type_label.setBuddy( tf_type_combo )
        tf_type_combo.setMaximumHeight( 30 )
        tf_type_layout.addWidget( tf_type_combo )
        current_index, index = 0, 0
        for tf_name in self.tf_map.keys():
            if self.tf_map[tf_name] == self.defaultTransferFunctionType:
                current_index = index 
            tf_type_combo.addItem( tf_name )
            index = index + 1  
        tf_type_combo.setCurrentIndex( current_index )   
        self.connect( tf_type_combo, SIGNAL("currentIndexChanged(QString)"), self.updateTransferFunctionType )  
        self.layout().addLayout( tf_type_layout )
                
        self.closeButton = QPushButton('Ok', self)
        self.layout().addWidget( self.graph )         
        self.layout().addWidget(self.closeButton)
        self.connect(self.closeButton, SIGNAL('clicked(bool)'), self.close)
        self.closeButton.setShortcut('Enter')
        
    def closeEvent( self, closeEvent ):
        self.emit( SIGNAL('close()') )
        QDialog.closeEvent( self, closeEvent )  
        
    def doneConfig( self ):
        self.emit( SIGNAL('doneConfig()') )    
        
    def addTransferFunction( self, name, **args ):
        self.currentTransferFunction = TransferFunction( self.defaultTransferFunctionType, **args ) 
        self.functions[ name ]  = self.currentTransferFunction
        self.graph.buildGraph() 
        
    def initLeveling(self, range ):
        pass
    
    def graphAdjusted(self, index, value0, value1, value2 ):
        self.emit( SIGNAL('config(int,float,float,float)'), index, value0, value1, value2 )
    
    def updateGraph( self, xbounds, ybounds, data ):
        self.graph.redrawGraph( xbounds, ybounds, data )
                
    def updateTransferFunctionType( self, value ):
        if self.currentTransferFunction: self.currentTransferFunction.setType( self.tf_map[ str(value) ] )
        self.emit( SIGNAL('update') )
        
    def setTransferFunctionType( self, tf_type ):
        if self.currentTransferFunction:
            if tf_type in self.tf_map.values(): 
                self.currentTransferFunction.type = tf_type

    def getTransferFunctionType( self ):
        if self.currentTransferFunction: return self.currentTransferFunction.type
        return self.defaultTransferFunctionType