Esempio n. 1
0
 def __init__(self, *args, **kwargs):
     super(InteractiveGRWidget, self).__init__(*args, **kwargs)
     guiConn = GUIConnector(self)
     guiConn.connect(qtgr.events.MouseEvent.MOUSE_MOVE, self.mouseMove)
     guiConn.connect(qtgr.events.MouseEvent.MOUSE_PRESS, self.mousePress)
     guiConn.connect(qtgr.events.MouseEvent.MOUSE_RELEASE,
                     self.mouseRelease)
     guiConn.connect(qtgr.events.WheelEvent.WHEEL_MOVE, self.wheelMove)
     guiConn.connect(qtgr.events.PickEvent.PICK_MOVE, self.pickMove)
     self.setMouseTracking(True)
     self._mouseLeft = False
     self._mouseRight = False
     self._startPoint = None
     self._curPoint = None
     self._logXinDomain = None
     self._logYinDomain = None
     self._pickMode = False
     self._pickEvent = None
     self._lstPlot = []
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        super(InteractiveGRWidget, self).__init__(*args, **kwargs)
        self._recognizers = []
        # register gesture recognizers
        for recognizer in self.GESTURE_RECOGNIZERS:
            instance = recognizer()
            self.grabGesture(recognizer.registerRecognizer(instance))
            # keep a reference on existing QGestureRecognizers in order
            # to circumvent that they will be accidentially freed when
            # using PyQt4 versions which will not handle the membership
            # correctly, e.g. PyQt4 4.9.1 shipped with Ubuntu 12.04.
            self._recognizers.append(instance)

        guiConn = GUIConnector(self)
        guiConn.connect(MouseEvent.MOUSE_MOVE, self.mouseMove)
        guiConn.connect(MouseEvent.MOUSE_PRESS, self.mousePress)
        guiConn.connect(MouseEvent.MOUSE_RELEASE, self.mouseRelease)
        guiConn.connect(WheelEvent.WHEEL_MOVE, self.wheelMove)
        guiConn.connect(PickEvent.PICK_MOVE, self.pickMove)
        guiConn.connect(MouseGestureEvent.MOUSE_PAN, self._mousePan)
        guiConn.connect(MouseGestureEvent.MOUSE_SELECT, self._mouseSelect)
        self.setMouseTracking(True)
        self._tselect = None  # select point tuple
        self._logXinDomain = None
        self._logYinDomain = None
        self._pickMode = False
        self._pickEvent = None
        self._selectEnabled, self._panEnabled = True, True
        self._roiEnabled = True
        self._zoomEnabled = True
        self._lstPlot = []
Esempio n. 3
0
    def __init__(self, *args, **kwargs):
        super(InteractiveGRWidget, self).__init__(*args, **kwargs)
        self._recognizers = []
        # register gesture recognizers
        for recognizer in self.GESTURE_RECOGNIZERS:
            instance = recognizer()
            self.grabGesture(recognizer.registerRecognizer(instance))
            # keep a reference on existing QGestureRecognizers in order
            # to circumvent that they will be accidentially freed when
            # using PyQt4 versions which will not handle the membership
            # correctly, e.g. PyQt4 4.9.1 shipped with Ubuntu 12.04.
            self._recognizers.append(instance)

        guiConn = GUIConnector(self)
        guiConn.connect(MouseEvent.MOUSE_MOVE, self.mouseMove)
        guiConn.connect(MouseEvent.MOUSE_PRESS, self.mousePress)
        guiConn.connect(MouseEvent.MOUSE_RELEASE, self.mouseRelease)
        guiConn.connect(WheelEvent.WHEEL_MOVE, self.wheelMove)
        guiConn.connect(PickEvent.PICK_MOVE, self.pickMove)
        guiConn.connect(MouseGestureEvent.MOUSE_PAN, self._mousePan)
        guiConn.connect(MouseGestureEvent.MOUSE_SELECT, self._mouseSelect)
        self.setMouseTracking(True)
        self._tselect = None  # select point tuple
        self._logXinDomain = None
        self._logYinDomain = None
        self._pickMode = False
        self._pickEvent = None
        self._selectEnabled, self._panEnabled = True, True
        self._roiEnabled = True
        self._zoomEnabled = True
        self._lstPlot = []
Esempio n. 4
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                "qtgrdemo.ui"), self)

        dictPrintType = dict(gr.PRINT_TYPE)
        map(dictPrintType.pop, [gr.PRINT_JPEG, gr.PRINT_TIF])
        self._saveTypes = (";;".join(dictPrintType.values()) + ";;" +
                           ";;".join(gr.GRAPHIC_TYPE.values()))
        self._saveName = None
        self._title = unicode(self.windowTitle())
        self._startupTime = time.time()

        self._chkLogX.stateChanged.connect(self._logXClicked)
        self._chkLogY.stateChanged.connect(self._logYClicked)
        self._chkGrid.stateChanged.connect(self._gridClicked)
        self._chkErr.stateChanged.connect(self._errorsClicked)
        self._chkKeepRatio.stateChanged.connect(self._keepRatioClicked)
        self._btnReset.clicked.connect(self._resetClicked)
        self._btnPick.clicked.connect(self._pickClicked)
        self._shell.returnPressed.connect(self._shellEx)
        self._actionSave.triggered.connect(self.save)
        self._actionPrint.triggered.connect(self.printGR)
        self._gr.logXinDomain.connect(self._logXinDomain)
        self._gr.logYinDomain.connect(self._logYinDomain)
        self._gr.modePick.connect(self._pickModeChanged)

        guiConn = GUIConnector(self._gr)
        guiConn.connect(MouseEvent.MOUSE_MOVE, self.mouseMoveGr)
        guiConn.connect(PickEvent.PICK_PRESS, self.pointPickGr)
        guiConn.connect(LegendEvent.ROI_CLICKED, self.legendClick)
        guiConn.connect(LegendEvent.ROI_OVER, self.legendOver)

        x = [-3.3 + t * .1 for t in range(66)]
        y = [t ** 5 - 13 * t ** 3 + 36 * t for t in x]
        x2 = [-3.5 + i * .5 for i in range(0, 15)]
        y2 = x2

        dneg = map(lambda y: y - 0.25 * abs(y), y)
        dpos = map(lambda y: y + 0.25 * abs(y), y)
        self._errBar = ErrorBar(x, y, dneg, dpos)

        self._curveFoo = PlotCurve(x, y, legend="foo bar")
        axes = PlotAxes().addCurves(self._curveFoo)
        axes.setXtickCallback(self._xtickCallBack)
        self._plot = Plot((.1, .92, .2, .88)).addAxes(axes,
                                    PlotAxes(drawX=False).plot(x2, y2))
        self._plot.offsetXLabel = -.1
        self._plot2 = Plot((.1, .95, .15, .88)).addAxes(PlotAxes().addCurves(PlotCurve(x2, y2,
                                                           legend="second")))

        self._plot.title = "QtGR Demo"
        self._plot.subTitle = "Multiple Axes Example"
        self._plot.xlabel = "x"
        self._plot.ylabel = "f(x)"
        self._plot.setLegend(True)
        self._gr.addPlot(self._plot)

        self._plot2.title = "Second Widget"
        self._plot2.subTitle = "Linear Example (less interactive)"
        self._plot2.xlabel = "x2"
        self._plot2.ylabel = "f2(x2)"
        self._plot2.setLegend(True)
        self._plot2.setGrid(False)
        self._gr2.addPlot(self._plot2)
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     super(InteractiveGRWidget, self).__init__(*args, **kwargs)
     guiConn = GUIConnector(self)
     guiConn.connect(qtgr.events.MouseEvent.MOUSE_MOVE, self.mouseMove)
     guiConn.connect(qtgr.events.MouseEvent.MOUSE_PRESS, self.mousePress)
     guiConn.connect(qtgr.events.MouseEvent.MOUSE_RELEASE, self.mouseRelease)
     guiConn.connect(qtgr.events.WheelEvent.WHEEL_MOVE, self.wheelMove)
     guiConn.connect(qtgr.events.PickEvent.PICK_MOVE, self.pickMove)
     self.setMouseTracking(True)
     self._mouseLeft = False
     self._mouseRight = False
     self._startPoint = None
     self._curPoint = None
     self._logXinDomain = None
     self._logYinDomain = None
     self._pickMode = False
     self._pickEvent = None
     self._selectEnabled, self._panEnabled = True, True
     self._zoomEnabled = True
     self._lstPlot = []