Esempio n. 1
0
 def create_layout_stuff(self):
   """ create grid layouts into which plotter widgets are inserted """
   if self.layout_parent is None or not self.layout_created:
     self.layout_parent = QWidget(self.wparent())
     self.layout = QGridLayout(self.layout_parent)
     self.QTextEdit = QTextEdit(self.layout_parent)
     self.layout.addWidget(self.QTextEdit, 0, 1)
     self.QTextEdit.hide()
     self.QTextEdit.setReadOnly(True)
     self.set_widgets(self.layout_parent,self.dataitem.caption,icon=self.icon())
     self.layout_created = True
   self._wtop = self.layout_parent;       
Esempio n. 2
0
    def createDataSelectorWidgets(self, parent, parent_layout):
        """Creates toolbuttons for complex values and Vells selection"""

        #print('in createDataSelectionWidgets')
        self._ds_top = top = QWidget(parent)
        parent_layout.addWidget(top)
        self._ds_lo = lotop = QVBoxLayout(top)
        lotop.setContentsMargins(0, 0, 0, 0)
        self._ds_complex = QWidget(top)
        self._ds_complex.setVisible(False)
        lotop.addWidget(self._ds_complex)
        lo = QVBoxLayout(self._ds_complex)
        lo.setContentsMargins(0, 0, 0, 0)
        lab = QLabel("complex:")
        lab.setAlignment(Qt.AlignHCenter)
        lo.addWidget(lab)
        # add complex selector
        lo0 = QHBoxLayout()
        lo0.setContentsMargins(0, 0, 0, 0)
        lo.addLayout(lo0)
        lo1 = QGridLayout()
        lo1.setContentsMargins(0, 0, 0, 0)
        lo1.setHorizontalSpacing(0)
        lo1.setVerticalSpacing(0)
        #   lo0.addStretch(1);
        lo0.addLayout(lo1)
        #   lo0.addStretch(1);
        bgrp = QButtonGroup(self._ds_complex)
        #   tbdesc = { self.AMP:(u"\u007Ca\u007C",0,0),self.PHASE:(u"\u03D5",0,1),self.REAL:("Re",1,0),self.IMAG:("Im",1,1) };
        #   tbdesc = { self.AMP:("\\u007Ca\\u007C",0,0),self.PHASE:("\\u0278",0,1),self.REAL:("Re",1,0),self.IMAG:("Im",1,1) };
        tbdesc = {
            self.AMP: ("Amp", 0, 0),
            self.PHASE: ("Pha", 0, 1),
            self.REAL: ("Re", 1, 0),
            self.IMAG: ("Im", 1, 1)
        }
        for label, qa in list(self._qas_complex.items()):
            tbtext, row, col = tbdesc[label]
            tb = QToolButton(self._ds_complex)
            lo1.addWidget(tb, row, col)
            bgrp.addButton(tb)
            tb.setText(tbtext)
            tb.setToolButtonStyle(Qt.ToolButtonTextOnly)
            tb.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
            tb.setCheckable(True)
            tb.setChecked(label is self.complex_component)
            tb.setMinimumWidth(32)
            tb.clicked[bool].connect(qa.setChecked)
            tb.clicked[bool].connect(self._change_complex)
            qa.triggered[bool].connect(tb.setChecked)
            self._tbs_complex[label] = tb
Esempio n. 3
0
 def __init__(self,
              array_shape=None,
              axis_label=None,
              axis_parms=None,
              num_axes=2,
              parent=None,
              name=""):
     QWidget.__init__(self, parent)
     # set default number of selectable axes to use 2-D QWT-based display
     self.selectable_axes = num_axes
     # create grid layout
     self.layout = QGridLayout(self)
     self.setWhatsThis(controller_instructions)
     self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
     self.construct_selectors(array_shape, axis_label, axis_parms)
Esempio n. 4
0
 def setup(self, points, *args):
     x = np.linspace(.001, 20., points)
     y = (np.sin(x)/x)*np.cos(20*x)
     layout = QGridLayout()
     nbcol, col, row = 2, 0, 0
     for style, symbol in self.params(*args):
        layout.addWidget(BMPlot(style, x, y, getattr(QwtPlotCurve, style),
                                symbol=symbol), row, col)
        col += 1
        if col >= nbcol:
            row +=1
            col = 0
     self.text = QLineEdit()
     self.text.setReadOnly(True)
     self.text.setAlignment(Qt.AlignCenter)
     self.text.setText("Rendering plot...")
     layout.addWidget(self.text, row+1, 0, 1, 2)
     self.setLayout(layout)           
Esempio n. 5
0
    def __init__(self, *args):
        QWidget.__init__(self, *args)
        layout = QGridLayout(self)        
        # try to create a plot for SciPy arrays

        # make a curve and copy the data
        numpy_curve = QwtPlotCurve('y = lorentzian(x)')
        x = np.arange(0.0, 10.0, 0.01)
        y = lorentzian(x)
        numpy_curve.setData(x, y)
        # here, we know we can plot NumPy arrays
        numpy_plot = QwtPlot(self)
        numpy_plot.setTitle('numpy array')
        numpy_plot.setCanvasBackground(Qt.white)
        numpy_plot.plotLayout().setCanvasMargin(0)
        numpy_plot.plotLayout().setAlignCanvasToScales(True)
        # insert a curve and make it red
        numpy_curve.attach(numpy_plot)
        numpy_curve.setPen(QPen(Qt.red))
        layout.addWidget(numpy_plot, 0, 0)
        numpy_plot.replot()

        # create a plot widget for lists of Python floats
        list_plot = QwtPlot(self)
        list_plot.setTitle('Python list')
        list_plot.setCanvasBackground(Qt.white)
        list_plot.plotLayout().setCanvasMargin(0)
        list_plot.plotLayout().setAlignCanvasToScales(True)
        x = drange(0.0, 10.0, 0.01)
        y = [lorentzian(item) for item in x]
        # insert a curve, make it red and copy the lists
        list_curve = QwtPlotCurve('y = lorentzian(x)')
        list_curve.attach(list_plot)
        list_curve.setPen(QPen(Qt.red))
        list_curve.setData(x, y)
        layout.addWidget(list_plot, 0, 1)
        layout.addWidget(DataPlot(self),1,1)
        layout.addWidget(3dstl(self), 1, 0)
        list_plot.replot()
Esempio n. 6
0
    def __init__(self, ax_number=1, axis_parms=None, parent=None, name=""):
        """ specify the layout of the spinbox and the slider """
        QWidget.__init__(self, parent)

        self.button = QPushButton(' ', self)
        self.ax_number = ax_number
        self.is_on = False
        self.axis_parms = axis_parms
        self.button_label = None

        self.spinbox = QSpinBox(self)
        self.spinbox.setMinimum(0)
        self.spinbox.setMaximum(99)
        self.spinbox.setWrapping(True)
        self.maxVal = 99

        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setTickPosition(QSlider.TicksBelow)
        self.slider.setTickInterval(10)
        self.slider.setRange(0, 99)
        self.maxVal = 99
        self.active = False

        self.label_info = QLabel(' ', self)

        self.resetValue()

        self.button.clicked.connect(self.emit_axis_number)
        self.slider.valueChanged.connect(self.update_slider)
        self.spinbox.valueChanged.connect(self.update_spinbox)

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.label_info, 0, 0)
        self.layout.addWidget(self.button, 1, 0)
        self.layout.addWidget(self.spinbox, 0, 2)
        self.layout.addWidget(self.slider, 1, 2)
Esempio n. 7
0
    def setVellsElementLabels(self, labels, dims):
        # do nothing when only one label, or when already set
        if len(labels) < 2 or self._qas_vells:
            return
        # make menu items
#   print 'in setVellsElementLabels, labels = ', labels
        for label in labels:
            # make menu action
            self._qas_vells[label] = va = self._qag_vells.addAction(str(label))
            va.setCheckable(True)
            # if first QAction, then check it
            if len(self._qas_vells) == 1:
                va.setChecked(True)
                self.vells_component = label
            self.vells_menu.addAction(va)
        self.vells_menu.menuAction().setVisible(True)

        # following does nothing at the moment
        for label in self.StokesComponents:
            self._qas_stokes[label] = vs = self._qag_stokes.addAction(label)
            vs.setCheckable(True)
            self.stokes_menu.addAction(vs)
        self.stokes_menu.menuAction().setVisible(True)
        # make grid of selector buttons, if dims are not too big

        if len(dims) == 1:
            dims = (1, dims[0])
        if len(dims) == 2 and min(*dims) >= 2 and max(*dims) <= 6:
            # for dims=1, make it 1xN
            # add vells selector
            self._ds_lo.addSpacing(16)
            self._ds_vells = QWidget(self._ds_top)
            self._ds_lo.addWidget(self._ds_vells)
            self._ds_stokes = QWidget(self._ds_top)
            self._ds_lo.addWidget(self._ds_stokes)
            self._ds_stokes.setVisible(False)
            lo = QVBoxLayout(self._ds_vells)
            lo.setContentsMargins(0, 0, 0, 0)
            lab = QLabel("element:")
            lab.setAlignment(Qt.AlignHCenter)
            lo.addWidget(lab)
            # add data selectors for correlations and Stokes
            lo0 = QVBoxLayout()
            lo0.setContentsMargins(0, 0, 0, 0)
            lo.addLayout(lo0)
            lo1 = QGridLayout()
            lo1.setContentsMargins(0, 0, 0, 0)
            lo1.setHorizontalSpacing(0)
            lo1.setVerticalSpacing(0)
            lo0.addLayout(lo1)
            bgrp = QButtonGroup(self._ds_vells)
            # make the labels
            for ilabel, label in enumerate(labels):
                # make toolbutton
                tb = QToolButton(self._ds_vells)
                bgrp.addButton(tb)
                self._tbs_vells[label] = tb
                tb.setText(str(label))
                tb.setToolButtonStyle(Qt.ToolButtonTextOnly)
                tb.setCheckable(True)
                tb.setChecked(label is self.vells_component)
                tb.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.Minimum)
                #      tb.setMinimumWidth(32);
                qa = self._qas_vells[label]
                tb.clicked[bool].connect(qa.setChecked)
                tb.clicked[bool].connect(self._change_vells)
                qa.triggered[bool].connect(tb.setChecked)
                # add to layout in correct place
                row, col = divmod(ilabel, dims[1])
                if dims[1] > 3:
                    col, row = row, col
                lo1.addWidget(tb, row, col)
            # show/hide controls
            self._ds_vells.setVisible(len(labels) > 1)

            lab = QLabel("stokes:")
            lab.setAlignment(Qt.AlignHCenter)
            lo0.addWidget(lab)

            lo2 = QGridLayout()
            lo2.setContentsMargins(0, 0, 0, 0)
            lo2.setHorizontalSpacing(0)
            lo2.setVerticalSpacing(0)
            lo0.addLayout(lo2)
            bgrp = QButtonGroup(self._ds_stokes)
            stdesc = {
                self.STOKES_I: ("I", 0, 0),
                self.STOKES_Q: ("Q", 0, 1),
                self.STOKES_U: ("U", 1, 0),
                self.STOKES_V: ("V", 1, 1)
            }
            for label, qa in list(self._qas_stokes.items()):
                tbtext, row, col = stdesc[label]
                tb = QToolButton(self._ds_stokes)
                lo2.addWidget(tb, row, col)
                bgrp.addButton(tb)
                tb.setText(tbtext)
                tb.setToolButtonStyle(Qt.ToolButtonTextOnly)
                tb.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.Minimum)
                tb.setCheckable(True)
                tb.setChecked(label is self.stokes_component)
                qa = self._qas_stokes[label]
                tb.clicked[bool].connect(qa.setChecked)
                tb.clicked[bool].connect(self._change_stokes)
                qa.triggered[bool].connect(tb.setChecked)
                self._tbs_complex[label] = tb
            # show/hide controls
            self._ds_stokes.setVisible(len(labels) > 1)