Esempio n. 1
0
    def __init__( self, parent=None, aortc=None ): # This is what happens when an object of this class is called. It's a kind of init.
        QtGui.QWidget.__init__( self, parent )
        self.aortc = aortc   # aortc is the VLT Connection to the work station
        self.ui = Ui_MainWindow() #ui. is the GUI
        self.ui.setupUi( self ) # Just do it
        
        self.SelectedGain = 0

        QtCore.QObject.connect( self.ui.BackgroundButton, QtCore.SIGNAL("clicked()"), self.measureBackground)  # Connects the "Take Background" button with the correct plumbing

        self.ui.GainSelectorGroup = QButtonGroup()
        self.ui.GainSelectorGroup.addButton(self.ui.Both_GainSelector)   # How do I set this to default?
        self.ui.GainSelectorGroup.addButton(self.ui.TT_GainSelector)
        self.ui.GainSelectorGroup.addButton(self.ui.HO_GainSelector)
        
        QtCore.QObject.connect(self.ui.Both_GainSelector, QtCore.SIGNAL("clicked()"), self.gainSelector)
        QtCore.QObject.connect(self.ui.TT_GainSelector, QtCore.SIGNAL("clicked()"), self.gainSelector)
        QtCore.QObject.connect(self.ui.HO_GainSelector, QtCore.SIGNAL("clicked()"), self.gainSelector)
        QtCore.QObject.connect( self.ui.SetGain, QtCore.SIGNAL("clicked()"), self.setGain)  # Connects the "Take Background" button with the correct plumbing

        """
Esempio n. 2
0
class Graffiti_ui_class( QtGui.QMainWindow ):
    #=========================================================================================
    #          Here we define the class of the main Ui we will manipulate in python.
    #=========================================================================================
    def __init__( self, parent=None, aortc=None ): # This is what happens when an object of this class is called. It's a kind of init.
        QtGui.QWidget.__init__( self, parent )
        self.aortc = aortc   # aortc is the VLT Connection to the work station
        self.ui = Ui_MainWindow() #ui. is the GUI
        self.ui.setupUi( self ) # Just do it
        
        self.SelectedGain = 0

        QtCore.QObject.connect( self.ui.BackgroundButton, QtCore.SIGNAL("clicked()"), self.measureBackground)  # Connects the "Take Background" button with the correct plumbing

        self.ui.GainSelectorGroup = QButtonGroup()
        self.ui.GainSelectorGroup.addButton(self.ui.Both_GainSelector)   # How do I set this to default?
        self.ui.GainSelectorGroup.addButton(self.ui.TT_GainSelector)
        self.ui.GainSelectorGroup.addButton(self.ui.HO_GainSelector)
        
        QtCore.QObject.connect(self.ui.Both_GainSelector, QtCore.SIGNAL("clicked()"), self.gainSelector)
        QtCore.QObject.connect(self.ui.TT_GainSelector, QtCore.SIGNAL("clicked()"), self.gainSelector)
        QtCore.QObject.connect(self.ui.HO_GainSelector, QtCore.SIGNAL("clicked()"), self.gainSelector)
        QtCore.QObject.connect( self.ui.SetGain, QtCore.SIGNAL("clicked()"), self.setGain)  # Connects the "Take Background" button with the correct plumbing

        """
        #Initialize attributes of the GUI
        self.ui.nbPushed = 0 # nb of times the push button was pushed
        self.ui.twoStateButtonStatus = "released" #Current state of 2 state button
        self.ui.nbItemsComboBox = 0 # Current number of items in the combo box
        
        # We group the 4 radio buttons so that when one is checked all the others are unchecked automaticallly
        #self.ui.group = QButtonGroup()
        #self.ui.group.addButton(self.ui.radioButton_1)
        #self.ui.group.addButton(self.ui.radioButton_2)
        #self.ui.group.addButton(self.ui.radioButton_3)
        #self.ui.group.addButton(self.ui.radioButton_4)
        
        
        #We connect objects with the proper signal to interact with them...
        QtCore.QObject.connect( self.ui.loadfitsButton,  QtCore.SIGNAL("clicked()"), self.selectFITS ) #Connects "loadfitsButton" button to the "selectFITS" method
        self.ui.twoStateButton.setCheckable(True)     
        self.ui.twoStateButton.clicked[bool].connect(self.twoStateButtonIsPushed) # We define the 2 state buttons here... 
        QtCore.QObject.connect( self.ui.pushButton,  QtCore.SIGNAL("clicked()"), self.theButtonIsPushed ) #Connects "pushButton" to the "theButtonIsPushed" method
        QtCore.QObject.connect( self.ui.plotRandom,  QtCore.SIGNAL("clicked()"), self.theButtonPlotRandomIsPushed ) #Connects "plotRandom" to the "theButtonPlotRandomIsPushed" method
        QtCore.QObject.connect( self.ui.okButton,  QtCore.SIGNAL("clicked()"), self.theButtonOKIsClicked ) #Connects "OK" button to the "theButtonOKIsClicked" method
        QtCore.QObject.connect( self.ui.resetCombobox,  QtCore.SIGNAL("clicked()"), self.resetComboboxClicked ) #Connects "OK" button to the "theButtonOKIsClicked" method

        #We connect here all the radiobutton to the "radioButtonWasClicked" method 
        QtCore.QObject.connect( self.ui.radioButton_1,  QtCore.SIGNAL("clicked()"), self.radioButtonWasClicked ) 
        QtCore.QObject.connect( self.ui.radioButton_2,  QtCore.SIGNAL("clicked()"), self.radioButtonWasClicked ) 
        QtCore.QObject.connect( self.ui.radioButton_3,  QtCore.SIGNAL("clicked()"), self.radioButtonWasClicked ) 
        QtCore.QObject.connect( self.ui.radioButton_4,  QtCore.SIGNAL("clicked()"), self.radioButtonWasClicked ) 

        #Connects the signal when the combobox is changed
        QtCore.QObject.connect(self.ui.ComboBox, QtCore.SIGNAL("currentIndexChanged(QString)"), self.getComboBox)

        #End of GUI Class initialization

        #"""
            
    def measureBackground(self):
        print "Let's measure a background!"
        self.aortc.changePixelTapPoint("RAW")
        self.aortc.updateAcq()
        self.aortc.measureBackground(10)
        self.aortc.changePixelTapPoint("CALIB")
        self.aortc.updateAcq()

    def gainSelector(self):
        if(self.ui.Both_GainSelector.isChecked()):
            self.SelectedGain = 0
        elif(self.ui.TT_GainSelector.isChecked()):
            self.SelectedGain = 1
        elif(self.ui.HO_GainSelector.isChecked()):
            self.SelectedGain = 2


    def setGain(self):
        try:
            gain = self.ui.Gain.text().toFloat()[0]
            if (gain < 1.0) & (gain > 0.0):
                if self.SelectedGain == 0:
                    self.aortc.set_TT_gain(-gain)
                    self.aortc.set_HO_gain(-gain)
                elif self.SelectedGain == 1:
                    self.aortc.set_TT_gain(-gain)
                elif self.SelectedGain == 2:
                    self.aortc.set_HO_gain(-gain)
                else:
                    print("How in the world did I get here?")
            else:
                print("Error! Gain must be between 1.0 and 0.0!!")
        except:
            print("Error!  Parsing error!")

        """
                         _     ____        _   _              
         _ __  _   _ ___| |__ | __ ) _   _| |_| |_ ___  _ __  
        | '_ \| | | / __| '_ \|  _ \| | | | __| __/ _ \| '_ \ 
        | |_) | |_| \__ \ | | | |_) | |_| | |_| || (_) | | | |
        | .__/ \__,_|___/_| |_|____/ \__,_|\__|\__\___/|_| |_|
        |_|                                                   

        """
        
    def theButtonIsPushed(self):
    #=========================================================================================
    #          This method is called when the push button is clicked
    #=========================================================================================
        self.ui.nbPushed+=1
        mess = "This button has been pushed %d time(s)" % self.ui.nbPushed
        print mess
        self.ui.dialogBox.setText(mess) #Shows the message in the GUI dialogbox        
                
        
    def theButtonPlotRandomIsPushed(self):
    #=========================================================================================
    #          This method is called when the plot random image in window # is clicked
    #=========================================================================================
        winnum = self.ui.winNumber.value() # Retrieves the desired window number
        pliInGui(np.random.rand(256,256), win=winnum) # Displays random array in the desired matplotlib embedded window


        """
                       _ _       ____        _   _              
         _ __ __ _  __| (_) ___ | __ ) _   _| |_| |_ ___  _ __  
        | '__/ _` |/ _` | |/ _ \|  _ \| | | | __| __/ _ \| '_ \ 
        | | | (_| | (_| | | (_) | |_) | |_| | |_| || (_) | | | |
        |_|  \__,_|\__,_|_|\___/|____/ \__,_|\__|\__\___/|_| |_|
                                                                
                
        """
    def radioButtonWasClicked(self):
    #==============================================================================
    #         This method is Called when one of the radiobuttons are clicked
    #==============================================================================
        if(self.ui.radioButton_1.isChecked()):
            mess = "No!   God outstands. Eric does not count."
        elif(self.ui.radioButton_2.isChecked()):
            mess= "No!    Even a master Jedi is not as good as him!"
        elif(self.ui.radioButton_3.isChecked()):
            mess= "Almost....    Fab is second in the list (will be 1st soon ;-) )"
        elif(self.ui.radioButton_4.isChecked()):
            mess= "Yes!   Zozo = The best   ;-)"
        else:
            mess="Oups I shoudn't be there..."
        self.ui.dialogBox.setText(mess) #Shows the message in the GUI dialogbox        
   
            
            
        """ 
         ____      _        _       ____        _   _              
        |___ \ ___| |_ __ _| |_ ___| __ ) _   _| |_| |_ ___  _ __  
          __) / __| __/ _` | __/ _ \  _ \| | | | __| __/ _ \| '_ \ 
         / __/\__ \ || (_| | ||  __/ |_) | |_| | |_| || (_) | | | |
        |_____|___/\__\__,_|\__\___|____/ \__,_|\__|\__\___/|_| |_|
                                                                   
        
        """
    def twoStateButtonIsPushed(self, pressed):
    #==============================================================================
    #         This method is Called when the 2 state button is clicked
    #==============================================================================
        if(pressed):
            self.ui.twoStateButtonStatus = "pushed" #if pressed we set the twoStateButtonStatus attribute to pushed
        else:
            self.ui.twoStateButtonStatus = "released" #if pressed we set the twoStateButtonStatus attribute to released
        self.ui.twoStateButton.setText("2 state Button (%s)" % self.ui.twoStateButtonStatus) # update the label of the button with proper status
        mess = "2 state buttton is now %s" % self.ui.twoStateButtonStatus
        print mess
        self.ui.dialogBox.setText( mess ) # displays message in dialogbox
        

        
        """
          __ _ _        ____       _           _             
         / _(_) | ___  / ___|  ___| | ___  ___| |_ ___  _ __ 
        | |_| | |/ _ \ \___ \ / _ \ |/ _ \/ __| __/ _ \| '__|
        |  _| | |  __/  ___) |  __/ |  __/ (__| || (_) | |   
        |_| |_|_|\___| |____/ \___|_|\___|\___|\__\___/|_|   
                                                             
         """

        
    def selectFITS(self):
    #==============================================================================
    #         This method is called when the "load fits file"button is called
    #==============================================================================        
        filepath = QtGui.QFileDialog.getOpenFileName( self, "Select FITS file", "./data/", "FITS files (*.fits);;All Files (*)") #Note: Use getOpenFileNames method (with a "s") to enable multiple file selection
        print filepath        
        if(filepath!=''):
            print (str(filepath))
            data = pyfits.getdata(str(filepath)) # Load fits file using the pyfits library
            pliInGui(data) # Displays the data in the GUI.
            mess = filepath+" displayed in window 1"
        else:
            mess = "No File selected skipping..."
            print mess
        self.ui.dialogBox.setText(mess) # displays message
    
        
        """
                             _           ____            
          ___ ___  _ __ ___ | |__   ___ | __ )  _____  __
         / __/ _ \| '_ ` _ \| '_ \ / _ \|  _ \ / _ \ \/ /
        | (_| (_) | | | | | | |_) | (_) | |_) | (_) >  < 
         \___\___/|_| |_| |_|_.__/ \___/|____/ \___/_/\_\
                                                         
        """
    def theButtonOKIsClicked(self):
    #==============================================================================
    #         This method is called when "ok" button is clicked
    #==============================================================================                
        text = str(self.ui.textEdit.toPlainText()) #Get the text from the text edit Field entry
        self.ui.ComboBox.addItem(text)# Adds the text in combo box. Note: Use currentText() to get the current Text in the combobox
        mess = "Added Message: %s in Combobox" % text
        print mess
        self.ui.dialogBox.setText(mess) # prints some messages...
        self.ui.nbItemsComboBox += 1 # updates the "nbItemsComboBox" attribute
        self.ui.ComboBox.setCurrentIndex(self.ui.nbItemsComboBox-1) # sets the current item to the last one entered

    def resetComboboxClicked(self):
    #==============================================================================
    #         This method is called when "reset ComboBox" button is clicked
    #==============================================================================           
        nb = self.ui.ComboBox.count() # retrieves the nb of items in the combo box
        for i in range(nb):
            self.ui.ComboBox.removeItem(0) # removes the first item "nb" times => i.e clear all items
        self.ui.nbItemsComboBox = 0 #upodates the attribute
        
    def getComboBox(self):
    #==============================================================================
    #         This method is called when the combo selector is changed by the user
    #==============================================================================   
        currText=self.ui.ComboBox.currentText() #Retrieves the ciurrent text displayed in comboBox
        mess = "ComboBox changed to: %s" % currText
        self.ui.dialogBox.setText(mess) #displays message