예제 #1
0
    def _refresh_mpl_widget(self):
        """ Create the mpl widget and update the underlying control.

        """
        # Delete the old widgets in the layout, it's just shenanigans
        # to try to reuse the old widgets when the figure changes.
        widget = self.widget
        layout = widget.layout()
        while layout.count():
            layout_item = layout.takeAt(0)
            layout_item.widget().deleteLater()

        # Create the new figure and toolbar widgets. It seems that key
        # events will not be processed without an mpl figure manager.
        # However, a figure manager will create a new toplevel window,
        # which is certainly not desired in this case. This appears to
        # be a limitation of matplotlib. The canvas is manually set to
        # visible, or QVBoxLayout will ignore it for size hinting.
        figure = self.declaration.figure
        if figure:
            canvas = FigureCanvasQTAgg(figure)
            canvas.setParent(widget)
            canvas.setFocusPolicy(Qt.ClickFocus)
            canvas.setVisible(True)
            toolbar = NavigationToolbar2QTAgg(canvas, widget)
            toolbar.setVisible(self.declaration.toolbar_visible)
            layout.addWidget(toolbar)
            layout.addWidget(canvas)
예제 #2
0
파일: _MplPlot.py 프로젝트: cth7/mricoils
    def __init__(self,
                 complexData,
                 parent=None,
                 dataType=None,
                 initMarkerPosn=None,
                 colors=None,
                 title=None):
        #
        # Qt related initialization
        #
        self.fig = mpl.figure.Figure()
        FigureCanvas.__init__(self, self.fig)
        self.setParent(
            parent
        )  #the FigureCanvas class doesn't have the option to pass the parent to the __init__() constructer, must set it manually
        FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        self.setMinimumSize(200, 200)
        FigureCanvas.updateGeometry(self)

        #
        # Event related initialization
        #
        self.mpl_connect('button_press_event', self.PressEvent)
        #self.setFocusPolicy(QtCore.Qt.StrongFocus)
        #self.mpl_connect('key_press_event',self.keyPressEventsdd)

        #
        # Internal data model initialization
        #
        self.setComplexData(complexData)
        if dataType is None:
            self.setDataType(dd.ImageType.mag)
        else:
            self.setDataType(dataType)
        self.setMarkerPosn(initMarkerPosn)

        #
        #Initialize internal variables that determine how visualization objects display data model
        #
        self.colors = colors
        if self.colors == None:
            self.colors = dd.PlotColours.colours

        #
        # Initialize objects visualizing the internal data model
        #
        #1d plot
        self.axes = self.fig.add_subplot(111)
        if title is not None:
            self.axes.set_title(title)
        #zoom functionality
        self.toolbar = NavigationToolbar2QTAgg(self, self)
        self.toolbar.hide()
        self.toolbar.zoom()
        #initialization of lines and markers
        self.createLines()
        self.createMarkers()
예제 #3
0
 def __init__(self):
     super(MPLPlotWidget, self).__init__()
     layout = QtGui.QVBoxLayout(self)
     fig = Figure()
     self.axes = fig.add_subplot(111)
     self.axes.hold(False)
     self.canvas = FigureCanvasQTAgg(fig)
     self.navbar = NavigationToolbar2QTAgg(self.canvas, self)
     layout.addWidget(self.canvas)
     layout.addWidget(self.navbar)
예제 #4
0
 def _create_canvas(self, parent):
     """ Create the MPL canvas. """
     # matplotlib commands to create a canvas
     frame = QtGui.QWidget()
     mpl_canvas = FigureCanvas(self.value)
     mpl_canvas.setParent(frame)
     mpl_toolbar = NavigationToolbar2QTAgg(mpl_canvas, frame)
     vbox = QtGui.QVBoxLayout()
     vbox.addWidget(mpl_canvas)
     vbox.addWidget(mpl_toolbar)
     frame.setLayout(vbox)
     return frame
예제 #5
0
    def __init__(self, arcdisplay, hmin=150, wmin=450, name=None, parent=None):
        super(errWidget, self).__init__(parent)

        # Add FITS display widget with mouse interaction and overplotting
        self.arcdisplay = arcdisplay
        self.arcdisplay.errfigure.setMinimumHeight(hmin)
        self.arcdisplay.errfigure.setMinimumWidth(wmin)
        self.arcdisplay.plotErr()

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.arcdisplay.errfigure, self)

        # set up the information panel
        self.infopanel = QtGui.QWidget()

        # add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel("%s" % name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                          | QtGui.QFrame.Sunken)

        # add the rows that are extracted
        self.aveLabel = QtGui.QLabel("Average:")
        self.aveLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.aveValueLabel = QtGui.QLabel("")
        self.aveValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                         | QtGui.QFrame.Sunken)
        self.stdLabel = QtGui.QLabel("Std:")
        self.stdLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.stdValueLabel = QtGui.QLabel("")
        self.stdValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                         | QtGui.QFrame.Sunken)

        # provide the full layout of the information panel
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)
        infoLayout.addWidget(self.aveLabel, 1, 0)
        infoLayout.addWidget(self.aveValueLabel, 1, 1)
        infoLayout.addWidget(self.stdLabel, 1, 2)
        infoLayout.addWidget(self.stdValueLabel, 1, 3)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.arcdisplay.errfigure)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)

        self.connect(self.arcdisplay, QtCore.SIGNAL('fitUpdate()'),
                     self.fitUpdate)
예제 #6
0
    def __init__(self, parent = None, subplots = [1,1,1] , sharex = None, sharey = None, title = 'No Title' , No_Toolbar = False):
        self.__name__="MyMplWidget"  

        QtGui.QWidget.__init__(self, parent)
        self.setWindowTitle(title) 
        self.canvas = MyMplCanvas(subplots=subplots,sharex=sharex,sharey=sharey)
        
        self.canvas.Object_Selection_Mode = None
        self.toolbar = NavigationToolbar2QTAgg(self.canvas, self.canvas)
        self.toolbar.setMinimumSize(300,30) #du coup la figure aura aussi cette taille minimum

        self.Status = QtGui.QLabel(self.canvas)
        self.Status.setMinimumSize(300,30) 
        
        if No_Toolbar == True:
            self.toolbar.hide()
        
        self.vbox = QtGui.QVBoxLayout()
        self.vbox.addWidget(self.canvas)
        self.vbox.addWidget(self.toolbar)#pour que la toolbar soit en bas
        self.vbox.addWidget(self.Status)#pour que la toolbar soit en bas
        self.setLayout(self.vbox)
        

        ##########################
        self.hZoom = QtGui.QAction("Zoom",  self)
        self.hZoom.setShortcut("CTRL+Z")
        self.addAction(self.hZoom)
        QtCore.QObject.connect(self.hZoom,QtCore.SIGNAL("triggered()"), self.ZoomToggle)
        
        self.untag = QtGui.QAction("Untag",  self)
        self.untag.setShortcut("CTRL+Del")
        self.addAction(self.untag)
        QtCore.QObject.connect(self.untag,QtCore.SIGNAL("triggered()"), self.Untag_Selected_Sweep)   
         
        self.actionAutoScale = QtGui.QAction("AutoScale",  self)#self.MainWindow)
        self.actionAutoScale.setShortcut("Ctrl+A")
        self.addAction(self.actionAutoScale)
        QtCore.QObject.connect(self.actionAutoScale,QtCore.SIGNAL("triggered()"), self.autoscale_plot)
        
        self.canvas.mpl_connect('button_press_event', self.canvas.Clicked_Object) 
        
        self.print_button = QtGui.QPushButton()
        self.print_button.setText('Print Figure')
        self.print_button.setToolTip("Print the figure")
        self.toolbar.addWidget(self.print_button)
        self.connect(self.print_button, QtCore.SIGNAL('clicked()'), self.Print) 
        
        try:
            QtCore.QObject.connect(Main.Autoscale, QtCore.SIGNAL("stateChanged()"),self.canvas.Update_Figure)
        except:
            pass
예제 #7
0
    def __setup_GUI(self):
        """
        Add matplotlib canvas, some buttons and stuff...
        """
        self.setWindowTitle("Title of main window...")
        self.setGeometry(300, 300, 500, 500)
        main = QtGui.QWidget()
        self.setCentralWidget(main)
        # add matplotlib canvas and setup layouts to put buttons in
        vlayout = QtGui.QVBoxLayout()
        vlayout.addStretch(1)
        main.setLayout(vlayout)
        canv = QMplCanvas()
        vlayout.addWidget(canv)
        hlayout = QtGui.QHBoxLayout()
        hlayout.addStretch(1)
        vlayout.addLayout(hlayout)

        # add some buttons
        self.qDoubleSpinBox_low = QtGui.QDoubleSpinBox()
        self.qDoubleSpinBox_low.setValue(self.options.low)
        hlayout.addWidget(QtGui.QLabel("low"))
        hlayout.addWidget(self.qDoubleSpinBox_low)

        self.qDoubleSpinBox_high = QtGui.QDoubleSpinBox()
        self.qDoubleSpinBox_high.setValue(self.options.high)
        hlayout.addWidget(QtGui.QLabel("high"))
        hlayout.addWidget(self.qDoubleSpinBox_high)

        self.qCheckBox_zerophase = QtGui.QCheckBox()
        self.qCheckBox_zerophase.setChecked(self.options.zerophase)
        self.qCheckBox_zerophase.setText("zerophase")
        hlayout.addWidget(self.qCheckBox_zerophase)

        qToolBar = QtGui.QToolBar()
        self.toolbar = NavigationToolbar2QTAgg(canv, qToolBar)
        qToolBar.addWidget(self.toolbar)
        qToolBar.setMovable(False)
        qToolBar.setFloatable(False)
        self.addToolBar(Qt.BottomToolBarArea, qToolBar)

        # make matplotlib stuff available
        self.canv = canv
        self.fig = canv.figure
        self.ax = self.fig.add_subplot(111)
예제 #8
0
def addMPLToolBar(window, canvas):
    qToolBar = QtGui.QToolBar()
    qToolBar.addWidget(NavigationToolbar2QTAgg(canvas, qToolBar))
    qToolBar.setMovable(False)
    qToolBar.setFloatable(False)
    window.addToolBar(Qt.BottomToolBarArea, qToolBar)
예제 #9
0
    def __init__(self,
                 arcdisplay,
                 hmin=150,
                 wmin=450,
                 name=None,
                 x1=0,
                 w1=0,
                 y1=None,
                 y2=None,
                 parent=None):
        super(arcWidget, self).__init__(parent)

        # Add FITS display widget with mouse interaction and overplotting
        self.arcdisplay = arcdisplay
        self.arcdisplay.arcfigure.setMinimumHeight(hmin)
        self.arcdisplay.arcfigure.setMinimumWidth(wmin)
        self.arcdisplay.plotArc()

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.arcdisplay.arcfigure, self)

        # set up the information panel
        self.infopanel = QtGui.QWidget()

        # add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel("%s" % name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                          | QtGui.QFrame.Sunken)

        # add the rows that are extracted
        self.y1Label = QtGui.QLabel("Y1:")
        self.y1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y1ValueLabel = QtGui.QLabel("%6i" % y1)
        self.y1ValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                        | QtGui.QFrame.Sunken)
        self.y2Label = QtGui.QLabel("Y2:")
        self.y2Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y2ValueLabel = QtGui.QLabel("%6i" % y2)
        self.y2ValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                        | QtGui.QFrame.Sunken)

        # add in what the value is for a x and w position
        self.x1Label = QtGui.QLabel("X1:")
        self.x1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.w1Label = QtGui.QLabel("w1:")
        self.w1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.x1ValueLabel = QtGui.QLabel("%6.2f" % x1)
        self.x1ValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                        | QtGui.QFrame.Sunken)
        w1 = self.arcdisplay.ws.value(x1)
        self.w1ValueEdit = QtGui.QLineEdit("%6i" % w1)
        self.addButton = QtGui.QPushButton("Add")
        self.addButton.clicked.connect(self.addpoints)

        # add in radio buttons for pixel or wavelength
        self.pixelradio = QtGui.QRadioButton("Pixel")
        self.wavelengthradio = QtGui.QRadioButton("Wavelength")
        self.pixelradio.setChecked(True)

        # add in information about the order and type of solution
        self.funcLabel = QtGui.QLabel("Function:")
        self.funcLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.funcValueLabel = QtGui.QLabel("%s" % self.arcdisplay.ws.function)
        self.funcValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                          | QtGui.QFrame.Sunken)
        self.orderLabel = QtGui.QLabel("Order:")
        self.orderLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.orderValueLabel = QtGui.QLabel("%2i" % self.arcdisplay.ws.order)
        self.orderValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                           | QtGui.QFrame.Sunken)

        # provide the full layout of the information panel
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)
        infoLayout.addWidget(self.y1Label, 1, 0, 1, 1)
        infoLayout.addWidget(self.y1ValueLabel, 1, 1, 1, 1)
        infoLayout.addWidget(self.y2Label, 1, 2, 1, 1)
        infoLayout.addWidget(self.y2ValueLabel, 1, 3, 1, 1)
        infoLayout.addWidget(self.x1Label, 2, 0, 1, 1)
        infoLayout.addWidget(self.x1ValueLabel, 2, 1, 1, 1)
        infoLayout.addWidget(self.w1Label, 2, 2, 1, 1)
        infoLayout.addWidget(self.w1ValueEdit, 2, 3)
        infoLayout.addWidget(self.addButton, 2, 4, 1, 1)
        infoLayout.addWidget(self.pixelradio, 3, 0, 1, 2)
        infoLayout.addWidget(self.wavelengthradio, 3, 2, 1, 2)
        infoLayout.addWidget(self.funcLabel, 4, 0, 1, 1)
        infoLayout.addWidget(self.funcValueLabel, 4, 1, 1, 1)
        infoLayout.addWidget(self.orderLabel, 4, 2, 1, 1)
        infoLayout.addWidget(self.orderValueLabel, 4, 3, 1, 1)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.arcdisplay.arcfigure)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)

        self.connect(self.arcdisplay, QtCore.SIGNAL('keyPressEvent(string)'),
                     self.keyPressEvent)
        self.connect(self.arcdisplay, QtCore.SIGNAL('updatex(float)'),
                     self.updatexlabel)
예제 #10
0
    def __init__(self,
                 imarr,
                 y1=None,
                 y2=None,
                 nrows=1,
                 nsteps=100,
                 hmin=150,
                 wmin=400,
                 name=None,
                 cmap='Gray',
                 scale='zscale',
                 contrast=0.1,
                 parent=None):
        super(imageWidget, self).__init__(parent)

        self.y1 = y1
        self.y2 = y2
        self.x1 = 0
        self.x2 = len(imarr[0])
        self.nrows = nrows
        self.nsteps = nsteps

        # Add FITS display widget with mouse interaction and overplotting
        self.imdisplay = ImageDisplay()
        self.imdisplay.setMinimumHeight(hmin)
        self.imdisplay.setMinimumWidth(wmin)

        # Set colormap
        self.imdisplay.setColormap(cmap)

        # Set scale mode for dynamic range
        self.imdisplay.scale = scale
        self.imdisplay.contrast = contrast
        self.imdisplay.aspect = 'auto'
        self.imdisplay.loadImage(imarr)
        self.imdisplay.drawImage()
        self.y1line, = self.imdisplay.axes.plot([self.x1, self.x2],
                                                [self.y1, self.y1],
                                                ls='-',
                                                color='#00FF00')
        self.y2line, = self.imdisplay.axes.plot([self.x1, self.x2],
                                                [self.y2, self.y2],
                                                ls='-',
                                                color='#00FF00')

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.imdisplay, self)

        # set up the information panel
        self.infopanel = QtGui.QWidget()

        # add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel("%s" % name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                          | QtGui.QFrame.Sunken)

        # add the rows that are extracted
        self.y1Label = QtGui.QLabel("Y1:")
        self.y1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y1ValueEdit = QtGui.QLineEdit("%6i" % self.y1)
        self.y2Label = QtGui.QLabel("Y2:")
        self.y2Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y2ValueEdit = QtGui.QLineEdit("%6i" % self.y2)
        self.updateButton = QtGui.QPushButton("Update")
        self.updateButton.clicked.connect(self.updatesection)

        # add the update for automatically updating it
        self.nrLabel = QtGui.QLabel("nrows:")
        self.nrLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.nrValueEdit = QtGui.QLineEdit("%5i" % self.nrows)
        self.nsLabel = QtGui.QLabel("nsteps:")
        self.nsLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.nsValueEdit = QtGui.QLineEdit("%6i" % self.nsteps)
        self.nextButton = QtGui.QPushButton("Next")
        self.nextButton.clicked.connect(self.nextsection)

        # set up the info panel layout
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)
        infoLayout.addWidget(self.y1Label, 1, 0, 1, 1)
        infoLayout.addWidget(self.y1ValueEdit, 1, 1, 1, 1)
        infoLayout.addWidget(self.y2Label, 1, 2, 1, 1)
        infoLayout.addWidget(self.y2ValueEdit, 1, 3, 1, 1)
        infoLayout.addWidget(self.updateButton, 1, 4, 1, 1)
        infoLayout.addWidget(self.nrLabel, 2, 0, 1, 1)
        infoLayout.addWidget(self.nrValueEdit, 2, 1, 1, 1)
        infoLayout.addWidget(self.nsLabel, 2, 2, 1, 1)
        infoLayout.addWidget(self.nsValueEdit, 2, 3, 1, 1)
        infoLayout.addWidget(self.nextButton, 2, 4, 1, 1)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.imdisplay)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)
예제 #11
0
    def __init__(self,
                 warr,
                 farr,
                 snarr,
                 name='',
                 y1=1010,
                 y2=1030,
                 hmin=150,
                 wmin=400,
                 smooth=5,
                 parent=None):
        super(SpectraViewWidget, self).__init__(parent)

        self.y1 = y1
        self.y2 = y2
        self.smooth = smooth
        self.name = name

        #set up the arc display
        self.arcfigure = MplCanvas()

        # Add central axes instance
        self.axes = self.arcfigure.figure.add_subplot(111)

        #set up the variables
        self.loaddata(warr, farr, snarr, name)

        #force a re-draw
        self.redraw_canvas()

        # Add navigation toolbars for each widget to enable zooming
        self.toolbar = NavigationToolbar2QTAgg(self.arcfigure, self)

        #set up the information panel
        self.infopanel = QtGui.QWidget()

        #add the name of the file
        self.NameLabel = QtGui.QLabel("Filename:")
        self.NameLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.NameValueLabel = QtGui.QLabel(self.name)
        self.NameValueLabel.setFrameStyle(QtGui.QFrame.Panel
                                          | QtGui.QFrame.Sunken)

        #add extraction window

        self.y1Label = QtGui.QLabel("y1:")
        self.y1Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y1ValueLabel = QtGui.QLineEdit(str(self.y1))
        self.y2Label = QtGui.QLabel("y2:")
        self.y2Label.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.y2ValueLabel = QtGui.QLineEdit(str(self.y2))
        self.apButton = QtGui.QPushButton('Extract')
        self.apButton.clicked.connect(self.extractspectra)

        #add default button
        self.defaultBox = QtGui.QCheckBox('Use values as default')
        self.defaultBox.stateChanged.connect(self.updatedefaults)

        #add smoothing
        self.smoothLabel = QtGui.QLabel("Smooth")
        self.smoothLabel.setFrameStyle(QtGui.QFrame.Panel
                                       | QtGui.QFrame.Raised)
        self.smoothValueLabel = QtGui.QLineEdit(str(self.smooth))
        self.smoothValueLabel.textChanged.connect(self.updatesmooth)

        #set up the info panel layout
        infoLayout = QtGui.QGridLayout(self.infopanel)
        infoLayout.addWidget(self.NameLabel, 0, 0, 1, 1)
        infoLayout.addWidget(self.NameValueLabel, 0, 1, 1, 5)
        infoLayout.addWidget(self.y1Label, 1, 0, 1, 1)
        infoLayout.addWidget(self.y1ValueLabel, 1, 1, 1, 1)
        infoLayout.addWidget(self.y2Label, 1, 2, 1, 1)
        infoLayout.addWidget(self.y2ValueLabel, 1, 3, 1, 1)
        infoLayout.addWidget(self.apButton, 1, 4, 1, 1)
        infoLayout.addWidget(self.defaultBox, 2, 0, 1, 2)
        infoLayout.addWidget(self.smoothLabel, 2, 2, 1, 1)
        infoLayout.addWidget(self.smoothValueLabel, 2, 3, 1, 1)

        # Set up the layout
        mainLayout = QtGui.QVBoxLayout()
        mainLayout.addWidget(self.arcfigure)
        mainLayout.addWidget(self.toolbar)
        mainLayout.addWidget(self.infopanel)
        self.setLayout(mainLayout)
예제 #12
0
    def __setup_GUI(self):
        """
        Add matplotlib canvas, some boxs and stuff...
        """
        self.setWindowTitle("FitResp")
        self.setGeometry(300, 300, 500, 500)
        main = QtGui.QWidget()
        self.setCentralWidget(main)
        # add matplotlib canvas and setup layouts to put boxes in
        vlayout = QtGui.QVBoxLayout()
        vlayout.addStretch(1)
        main.setLayout(vlayout)
        canv = QMplCanvas()
        vlayout.addWidget(canv)
        hlayout_poles = QtGui.QHBoxLayout()
        hlayout_poles.addStretch(1)
        vlayout.addLayout(hlayout_poles)
        hlayout_zeros = QtGui.QHBoxLayout()
        hlayout_zeros.addStretch(1)
        vlayout.addLayout(hlayout_zeros)
        hlayout_normfac = QtGui.QHBoxLayout()
        hlayout_normfac.addStretch(1)
        vlayout.addLayout(hlayout_normfac)

        # add boxes for corner frequencies
        if self.corn_freqs != 0:
            # add layout
            hlayout_cf = QtGui.QHBoxLayout()
            hlayout_cf.addStretch(1)
            vlayout.addLayout(hlayout_cf)
            # add boxes
            self.boxes_corn_freqs = []
            self.boxes_dampings = []
            for _i in xrange(self.corn_freqs):
                if _i == 0:
                    freq, damping = 1.0, 0.707
                elif _i == 1:
                    freq, damping = 10.0, 0.707
                box_cornfreq, box_damping = \
                        self.__add_doublespinboxes_cornfreq(hlayout_cf, freq,
                                                            damping)
                self.boxes_corn_freqs.append(box_cornfreq)
                self.boxes_dampings.append(box_damping)

        # add some boxes
        self.boxes_poles_real = []
        self.boxes_poles_imag = []
        for i, pole in enumerate(self.paz['poles']):
            box_real, box_imag = self.__add_doublespinboxes(
                hlayout_poles, pole, "Pole", i + 1)
            self.boxes_poles_real.append(box_real)
            self.boxes_poles_imag.append(box_imag)
        self.boxes_zeros_real = []
        self.boxes_zeros_imag = []
        for i, zero in enumerate(self.paz['zeros']):
            box_real, box_imag = self.__add_doublespinboxes(
                hlayout_zeros, zero, "Zero", i + 1)
            self.boxes_zeros_real.append(box_real)
            self.boxes_zeros_imag.append(box_imag)
        # add box for normalization factor
        box_norm = QtGui.QDoubleSpinBox()
        box_norm.setMaximum(1e10)
        box_norm.setMinimum(-1e10)
        box_norm.setSingleStep(self.options.step)
        box_norm.setValue(self.paz['gain'])
        hlayout_normfac.addWidget(QtGui.QLabel("Norm.Fac."))
        hlayout_normfac.addWidget(box_norm)
        self.box_norm = box_norm

        qToolBar = QtGui.QToolBar()
        self.toolbar = NavigationToolbar2QTAgg(canv, qToolBar)
        qToolBar.addWidget(self.toolbar)
        qToolBar.setMovable(False)
        qToolBar.setFloatable(False)
        self.addToolBar(Qt.BottomToolBarArea, qToolBar)

        # make matplotlib stuff available
        self.canv = canv
        self.fig = canv.figure
        self.ax1 = self.fig.add_subplot(121)
        self.ax2 = self.fig.add_subplot(122)