Пример #1
0
 def updateTabOrder(self):
     contentsLayout = self.__data.view.gridLayout
     if contentsLayout is not None:
         w = None
         for i in range(contentsLayout.count()):
             item = contentsLayout.itemAt(i)
             if w is not None and item.widget():
                 QWidget.setTabOrder(w, item.widget())
             w = item.widget()
Пример #2
0
 def __init__(self, parent):
     QScrollArea.__init__(self, parent)
     self.gridLayout = None
     self.contentsWidget = QWidget(self)
     self.contentsWidget.setObjectName("QwtLegendViewContents")
     self.setWidget(self.contentsWidget)
     self.setWidgetResizable(False)
     self.viewport().setObjectName("QwtLegendViewport")
     self.contentsWidget.setAutoFillBackground(False)
     self.viewport().setAutoFillBackground(False)
def delete_2D_Plotters(colorbar, visu_plotter):
    """ delete 2D plotter and associated colorbars """
    if HAS_TIMBA:
        _dprint(3, 'got 3d plot request, deleting 2-d stuff')
    colorbar[0].setParent(QWidget())
    colorbar[1].setParent(QWidget())
    colorbar = {}
    visu_plotter.setParent(QWidget())
    visu_plotter = None
    return visu_plotter
Пример #4
0
    def __init__(self, *args):
        QWidget.__init__(self, *args)
        def createScene():
            # root
            rootEntity = QEntity()
            material = QPhongMaterial(rootEntity)
            material.setDiffuse(QColor(254, 254, 254));
            #data=QUrl(); 
            data=QUrl.fromLocalFile("C:/Users/LINX/Documents/cat.stl");
            # sphere
            print(data)
            sphereEntity = QEntity(rootEntity)
            sphereMesh = QMesh()
            sphereMesh.setSource(data)
            sphereTransform = QTransform()

            controller = OrbitTransformController(sphereTransform)
            controller.setTarget(sphereTransform)
            controller.setRadius(20)
            controller.setAxis(QVector3D(1, 0, 0)
            )

            sphereRotateTransformAnimation = QPropertyAnimation(sphereTransform)
            sphereRotateTransformAnimation.setTargetObject(controller)
            sphereRotateTransformAnimation.setPropertyName(b'angle')
            sphereRotateTransformAnimation.setStartValue(0)
            sphereRotateTransformAnimation.setEndValue(-10)
            #sphereRotateTransformAnimation.setDuration(10)
            #sphereRotateTransformAnimation.setLoopCount(-1)
            sphereRotateTransformAnimation.start()

            sphereEntity.addComponent(sphereMesh)
            sphereEntity.addComponent(sphereTransform)
            sphereEntity.addComponent(material)

            return rootEntity
        view = Qt3DWindow()

        scene = createScene()

        # camera
        camera = view.camera()
        camera.lens().setPerspectiveProjection(45.0, 16.0/9.0, 0.1, 1000)
        camera.setPosition(QVector3D(0, 0, 40))
        camera.setViewCenter(QVector3D(0, 0, 0))

        # for camera control
        camController = QOrbitCameraController(scene)
        camController.setLinearSpeed( 50.0 )
        camController.setLookSpeed( 180.0 )
        camController.setCamera(camera)

        view.setRootEntity(scene)
        view.show()
Пример #5
0
    def __init__(self,
                 CurveNumber,
                 x_values,
                 y_values,
                 flags,
                 pen,
                 parent=None,
                 name=None):
        """ Initialises all the variables.  
        creates the main zoom plot
        connects the qt signals
    """

        QWidget.__init__(self, parent)
        self.setWindowTitle('Channel ' + str(CurveNumber))
        self._parent = parent
        self._d_zoomActive = self._d_zoom = False
        self._curve_number = CurveNumber
        self.curves = {}

        self._do_close = True  # enable closing by window manager
        self._do_pause = False  # pause mode is False at startup
        self._compare_max = False
        self._do_linear_scale = True  # linear Y axis scale by default
        self._do_fixed_scale = False  # auto scaling by default
        self._array_label = "Channel "

        #Create the plot for selected curve to zoom
        self._plotter = QwtImageDisplay(self)
        self._plotter.setZoomDisplay()

        self._zoom_plot_label = self._array_label + str(
            self._curve_number) + " Sequence (oldest to most recent)"

        self._max_crv = -1  # negative value used to indicate that this display
        self._min_crv = -1  # is not being used

        #####end of parameters set for the plot#######/

        # we seem to need a layout for PyQt
        box1 = QHBoxLayout(self)
        box1.addWidget(self._plotter)
        #   self.plotPrinter = plot_printer_qt5.plot_printer(self._plotter)

        self._plotter.winpaused.connect(self.Pausing)
        self._plotter.compare.connect(self.do_compare)
        #   self._plotter.do_print.connnect(self.plotPrinter.do_print)
        self._plotter.save_display.connect(self.handle_save_display)

        # insert flags ?
        self._plotter.initVellsContextMenu()
        self.update_plot(y_values, flags)
        self.show()
Пример #6
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
Пример #7
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)
Пример #8
0
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)

        self.plot = BodePlot(self)
        self.plot.setContentsMargins(5, 5, 5, 0)

        self.setContextMenuPolicy(Qt.NoContextMenu)

        self.setCentralWidget(self.plot)

        toolBar = QToolBar(self)
        self.addToolBar(toolBar)

        btnPrint = QToolButton(toolBar)
        btnPrint.setText("Print")
        btnPrint.setIcon(QIcon(QPixmap(print_xpm)))
        btnPrint.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        toolBar.addWidget(btnPrint)
        btnPrint.clicked.connect(self.print_)

        btnExport = QToolButton(toolBar)
        btnExport.setText("Export")
        btnExport.setIcon(QIcon(QPixmap(print_xpm)))
        btnExport.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        toolBar.addWidget(btnExport)
        btnExport.clicked.connect(self.exportDocument)

        btnSet = QToolButton(toolBar)
        btnSet.setText("Set")
        btnSet.setIcon(QIcon(QPixmap(print_xpm)))
        btnSet.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        toolBar.addWidget(btnSet)
        btnSet.clicked.connect(self.exportDocument)

        toolBar.addSeparator()

        dampBox = QWidget(toolBar)
        dampLayout = QHBoxLayout(dampBox)
        dampLayout.setSpacing(0)
        dampLayout.addWidget(QWidget(dampBox), 10)  # spacer
        dampLayout.addWidget(QLabel("Damping Factor", dampBox), 0)
        dampLayout.addSpacing(10)

        toolBar.addWidget(dampBox)

        self.statusBar()

        self.showInfo()
def create_ND_Controls(layout,
                       layout_parent,
                       array_shape,
                       ND_Controls,
                       ND_plotter,
                       labels=None,
                       parms=None,
                       num_axes=2):
    """ this function adds the extra GUI control buttons etc if we are
        displaying data for a Timba.array of dimension 3 or greater 
  """
    if not ND_Controls is None:
        ND_Controls.setParent(QWidget())
        ND_Controls = None
    ND_Controls = ND_Controller(array_shape, labels, parms, num_axes,
                                layout_parent)
    layout.addWidget(ND_Controls, 2, 0, 1, 2)
    if ND_Controls.get_num_selectors() > num_axes:
        ND_Controls.showDisplay(1)
    else:
        ND_Controls.showDisplay(0)
        if not ND_plotter is None:
            ND_plotter.HideNDButton()
    if HAS_TIMBA:
        _dprint(3, 'ND_Controls object should appear ', ND_Controls)
    return ND_Controls
Пример #10
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 = QHBoxLayout(self.layout_parent)
         self.set_widgets(self.layout_parent,
                          self.dataitem.caption,
                          icon=self.icon())
         self.layout_created = True
     self._wtop = self.layout_parent
     self.create_2D_plotter()
Пример #11
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;       
Пример #12
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()
Пример #13
0
def qwtSetTabOrder(first, second, with_children):
    tab_chain = [first, second]
    if with_children:
        children = second.findChildren(QWidget)
        w = second.nextInFocusChain()
        while w in children:
            while w in children:
                children.remove(w)
            tab_chain += [w]
            w = w.nextInFocusChain()
    for idx in range(len(tab_chain)-1):
        w_from = tab_chain[idx]
        w_to = tab_chain[idx+1]
        policy1, policy2 = w_from.focusPolicy(), w_to.focusPolicy()
        proxy1, proxy2 = w_from.focusProxy(), w_to.focusProxy()
        for w in (w_from, w_to):
            w.setFocusPolicy(Qt.TabFocus)
            w.setFocusProxy(None)
        QWidget.setTabOrder(w_from, w_to)
        for w, pl, px in ((w_from, policy1, proxy1), (w_to, policy2, proxy2)):
            w.setFocusPolicy(pl)
            w.setFocusProxy(px)
Пример #14
0
def make():
    demo = QWidget()
    demo.setWindowTitle('Cpu Plot')
    
    plot = CpuPlot(demo)
    plot.setTitle("History")
    
    label = QLabel("Press the legend to en/disable a curve", demo)

    layout = QVBoxLayout(demo)
    layout.addWidget(plot)
    layout.addWidget(label)

    demo.resize(600, 400)
    demo.show()
    return demo
Пример #15
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)
        list_plot.replot()
Пример #16
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)
Пример #17
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)
Пример #18
0
 def __init__(self, orientation, *args):
     QWidget.__init__(self, *args)
     self.__orientation = orientation
     self.__light = QColor(Qt.white)
     self.__dark = QColor(Qt.black)
     self.setCursor(Qt.PointingHandCursor)
Пример #19
0
class LegendView(QScrollArea):
    def __init__(self, parent):
        QScrollArea.__init__(self, parent)
        self.gridLayout = None
        self.contentsWidget = QWidget(self)
        self.contentsWidget.setObjectName("QwtLegendViewContents")
        self.setWidget(self.contentsWidget)
        self.setWidgetResizable(False)
        self.viewport().setObjectName("QwtLegendViewport")
        self.contentsWidget.setAutoFillBackground(False)
        self.viewport().setAutoFillBackground(False)
    
    def event(self, event):
        if event.type() == QEvent.PolishRequest:
            self.setFocusPolicy(Qt.NoFocus)
        if event.type() == QEvent.Resize:
            cr = self.contentsRect()
            w = cr.width()
            h = self.contentsWidget.heightForWidth(cr.width())
            if h > w:
                w -= self.verticalScrollBar().sizeHint().width()
                h = self.contentsWidget.heightForWidth(w)
            self.contentsWidget.resize(w, h)
        return QScrollArea.event(self, event)
    
    def viewportEvent(self, event):
        ok = QScrollArea.viewportEvent(self, event)
        if event.type() == QEvent.Resize:
            self.layoutContents()
        return ok
    
    def viewportSize(self, w, h):
        sbHeight = self.horizontalScrollBar().sizeHint().height()
        sbWidth = self.verticalScrollBar().sizeHint().width()
        cw = self.contentsRect().width()
        ch = self.contentsRect().height()
        vw = cw
        vh = ch
        if w > vw:
            vh -= sbHeight
        if h > vh:
            vw -= sbWidth
            if w > vw and vh == ch:
                vh -= sbHeight
        return QSize(vw, vh)
    
    def layoutContents(self):
        tl = self.gridLayout
        if tl is None:
            return
        visibleSize = self.viewport().contentsRect().size()
        margins = tl.contentsMargins()
        margin_w = margins.left() + margins.right()
        minW = int(tl.maxItemWidth()+margin_w)
        w = max([visibleSize.width(), minW])
        h = max([tl.heightForWidth(w), visibleSize.height()])
        vpWidth = self.viewportSize(w, h).width()
        if w > vpWidth:
            w = max([vpWidth, minW])
            h = max([tl.heightForWidth(w), visibleSize.height()])
        self.contentsWidget.resize(w, h)
Пример #20
0
 def __init__(self, orientation, *args):
     QWidget.__init__(self, *args)
     self.__orientation = orientation
     self.__light = QColor(Qt.white)
     self.__dark = QColor(Qt.black)
     self.setCursor(Qt.PointingHandCursor)
Пример #21
0
 def disableContextmenu(self):
   """ delete the result buffer context menu """
   if not self.menu is None:
       self.menu.setParent(QWidget())
       self.menu = None
Пример #22
0
    def __init__(self, parent=None, name="",horizontal=False,draw_scale=True,hide_slider=False, use_int=False, add_spacer=True):
#     QWidget.__init__(self, parent, name)
      QWidget.__init__(self, parent)

      self.menu_table = {
      'Adjust results buffer size': 301,
      'Display summary plot': 302,
      'X Axis': 303,
      'Y Axis': 304,
      'Z Axis': 305,
      'Show 2D Display': 306,
      'Update': 307,
      'Toggle ND Controller': 308,
      'Print to Postscript file': 309,
      'Align Camera': 310,
      'Reset Auto Scaling': 312,
      'Save Display in PNG Format': 313,
      }

      self.horizontal = horizontal
      self.hide_slider = hide_slider
      self.use_int = use_int
      self.add_spacer = add_spacer
      self.allow_emit = False
      self.allow_summary = False
      self.summary_request = True
      self.toggle_ND_Controller = 1
      self.toggle_scale_display = False
      self.draw_scale = draw_scale
      self.menu = None
      self.maxVal = 100
      self.minVal = 0
      self.scaler = 1
      self.label_info = QLabel('', self)
      self.string_info =  ' '
      self.offset_index = -1
      if self.horizontal or self.use_int:
        self.spinbox = QSpinBox(self)
      else:
        self.spinbox = QDoubleSpinBox(self)
        self.spinbox.setSingleStep(0.1)
      self.spinbox.setMinimum(self.minVal)
      self.spinbox.setMaximum(self.maxVal)

      if self.horizontal:
        self.slider = QSlider(Qt.Horizontal, self)
        if self.draw_scale:
          self.slider.setTickPosition(QSlider.TicksBelow)
          self.slider.setTickInterval(self.minVal)
        self.slider.setRange(self.minVal, self.maxVal)
        self.slider.valueChanged[int].connect(self.update_slider)
        self.spinbox.valueChanged[int].connect(self.update_spinbox)
      else:
         #print('creating standard vertical QSlider')
         self.slider = QSlider(Qt.Vertical, self)
         if not self.use_int:
           self.scaler = 10000000
         min = self.scaler * self.minVal
         max = self.scaler * self.maxVal
         if self.draw_scale:
           self.slider.setTickPosition(QSlider.TicksRight)
           step = int((max-min) /20)
           #print('slider step should me ', step)
           self.slider.setTickInterval(step)
         #print('slider min and max', min,max)
         self.slider.setRange(min, max)
         self.slider.valueChanged[int].connect(self.update_slider)

        # we may not want a slider - e.g. when selecion tab pages in collections plotter
      self.spinbox.setWrapping(True)
      #print('wrapping should be set')

      if self.hide_slider:
        self.slider.hide()

      if self.horizontal or self.use_int:
        self.spinbox.valueChanged[int].connect(self.update_spinbox)
      else:
        self.spinbox.valueChanged[float].connect(self.update_spinbox)

      if self.horizontal:
        self.label_info1 = QLabel('          ', self)
        self.layout = QHBoxLayout(self)
        if self.add_spacer:
          spacer = QSpacerItem(22,9,QSizePolicy.Expanding,QSizePolicy.Minimum)
          self.layout.addItem(spacer)
        self.layout.addWidget(self.label_info)
        self.layout.addWidget(self.spinbox)
        self.layout.addWidget(self.label_info1)
        self.layout.addWidget(self.slider)
        self.setValue()
      else:
        self.layout = QVBoxLayout(self)
        self.layout.addWidget(self.label_info)
        self.layout.addWidget(self.slider)
        self.layout.addWidget(self.spinbox)
        if self.add_spacer:
          spacer = QSpacerItem(9,22,QSizePolicy.Minimum,QSizePolicy.Expanding)
          self.layout.addItem(spacer)
        self.setValue(0,reset_auto=True)

# add on-line help
      self.setWhatsThis(results_range_help)
Пример #23
0
class ControlMenu(QMenu):
    """This is the control menu common to all the ChartPlot widgets"""
    changeComplexComponent = pyqtSignal(str)
    changeStokesComponent = pyqtSignal(str)
    changeVellsComponent = pyqtSignal(str)

    AMP = "Amplitude"
    PHASE = "Phase"
    REAL = "Real"
    IMAG = "Imaginary"
    STOKES_I = 'I'
    STOKES_Q = 'Q'
    STOKES_U = 'U'
    STOKES_V = 'V'
    ComplexComponents = (AMP, PHASE, REAL, IMAG)
    StokesComponents = (STOKES_I, STOKES_Q, STOKES_U, STOKES_V)
    ComplexComponentLabels = {
        AMP: "ampl",
        PHASE: "ph",
        REAL: "re",
        IMAG: "im"
    }
    StokesComponentLabels = {
        STOKES_I: "I",
        STOKES_Q: "Q",
        STOKES_U: "U",
        STOKES_V: "V"
    }

    def __init__(self, parent):
        QMenu.__init__(self, parent)
        self.close_window = self.addAction('Close Window')
        self.close_window.setVisible(False)

        self.reset_zoomer = self.addAction('Reset zoomer')
        self.reset_zoomer.setVisible(False)

        # the following is commented out until postscript/pdf printing works
        # properly with Qt 4 widgets
        #   self._print = self.addAction("Print",self.plotPrinter.do_print)

        self.clear_plot = self.addAction('Clear plot')

        self.close_popups = self.addAction('Close popups')
        self.close_popups.setVisible(False)

        self.show_flagged_data = self.addAction('Show flagged data')
        self.show_flagged_data.setCheckable(True)
        self.show_flagged_data.setChecked(False)

        self.autoscale = self.addAction('Automatic scaling')
        self.autoscale.setCheckable(True)
        self.autoscale.setChecked(False)
        self.autoscale.setVisible(
            False
        )  # not sure why, but this is never set to visible -- perhaps fixed scaling doesn't work at all

        self.offset_value = self.addAction('Offset Value')
        self.offset_value.setVisible(False)
        # not sure why, but this is never set to visible -- perhaps it no longer works at all

        self.show_labels = self.addAction('Show labels')
        self.show_labels.setCheckable(True)
        self.show_labels.setChecked(True)

        self.append = self.addAction('Accumulate data tracks')
        self.append.setCheckable(True)
        self.append.setChecked(True)

        # create submenu for complex data
        self.complex_menu = self.addMenu("Plot complex values as...")
        qag = QActionGroup(self.complex_menu)
        self._qas_complex = dict()
        self._tbs_complex = dict()
        for label in self.ComplexComponents:
            qa = self.complex_menu.addAction(label)
            qa.setCheckable(True)
            qag.addAction(qa)
            self._qas_complex[label] = qa
        self._qas_complex[self.AMP].setChecked(True)
        qag.triggered[QAction].connect(self._change_complex)
        self.complex_menu.menuAction().setVisible(False)
        # current complex component
        self.complex_component = self.AMP

        # create submenu for correlated data element selection
        self.vells_menu = self.addMenu('Data element selector...')
        # menu and action group will be filled when the first updateEvent occurs
        self._qag_vells = QActionGroup(self.vells_menu)
        self._qas_vells = dict()
        self._tbs_vells = dict()
        self._qag_vells.triggered[QAction].connect(self._change_vells)
        self.vells_menu.menuAction().setVisible(False)
        self.vells_component = None

        # create submenu for stokes data selection
        self.stokes_menu = self.addMenu('Select Stokes parameter...')
        # menu and action group will be filled when the first updateEvent occurs
        self._qag_stokes = QActionGroup(self.stokes_menu)
        self._qas_stokes = dict()
        self._tbs_stokes = dict()
        self._qag_stokes.triggered[QAction].connect(self._change_stokes)
        self.stokes_menu.menuAction().setVisible(False)
        self.stokes_component = None

        self.save_this = self.addAction('Save this plot page in PNG format')
        self.save_all = self.addAction('Save all pages in PNG format')

    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

    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)

    def isComplexControlVisible(self):
        return self.complex_menu.menuAction().isVisible()

    def isVellsControlVisible(self):
        return self.vells_menu.menuAction().isVisible()

    def showComplexControls(self, show=True):
        """Enables complex controls. If called at least once, they become enabled and stay visible."""
        if show:
            self.complex_menu.menuAction().setVisible(True)
            try:
                self._ds_complex and self._ds_complex.setVisible(True)
            except:
                pass

    def _change_complex(self, *dum):
        for label, qa in list(self._qas_complex.items()):
            if qa.isChecked():
                self.complex_component = label
                break
        self.autoscale.setChecked(True)
        self.changeComplexComponent.emit(self.complex_component)

    def _change_stokes(self, *dum):
        for label, qa in list(self._qas_stokes.items()):
            if qa.isChecked():
                self.stokes_component = label
                #       print(('setting Stokes to ', label))
                break
        self.autoscale.setChecked(True)
        self.changeStokesComponent.emit(self.stokes_component)

    def _change_vells(self, *dum):
        for label, qa in list(self._qas_vells.items()):
            if qa.isChecked():
                self.vells_component = label
                if label in self._tbs_vells:
                    self._tbs_vells[label].setChecked(True)
                    #print(('setting vells label to ', label))
                break
        self.autoscale.setChecked(True)
        self.changeVellsComponent.emit(self.vells_component)