Example #1
0
    def generatePlot(self, logTrackData, log, xData, yData):

        #pw = pg.PlotWidget(name='Plot1')  ## giving the plots names allows us to link their axes together
        self.getAxis('left').setStyle(tickTextOffset=self.TICK_TEXT_OFFSET,
                                      showValues=True)
        self.getAxis('bottom').setStyle(showValues=False)
        #store data for header to retrieve
        self.setData(Qt.UserRole, logTrackData)
        #see http://stackoverflow.com/questions/5036700/how-can-you-dynamically-create-variables-in-python-via-a-while-loop

        self.show()

        firstLogId = logTrackData.getLogs()[0]
        log = logTrackData.getLogs()[0]

        #note PlotItem is coming from parent
        #hide the A button see https://groups.google.com/forum/#!topic/pyqtgraph/5cc0k6TG89k
        self.plotItem.hideButtons()
        self.plotItem.setRange(xRange=(log.log_plot_left, log.log_plot_right),
                               padding=0,
                               disableAutoRange=True)
        plt = self.plotItem.plot(y=yData, x=xData)
        #temp set alpga to semi tranparent
        rgbaColor = ImageUtils.rbgaToQColor(log.rgb, 100)
        plt.setPen(rgbaColor)

        self.invertY()
        pixelWidth = WellPlotUtils.convertmmToDPI(logTrackData.track_width)

        self.setFixedWidth(pixelWidth)
        self.setSizePolicy(QtGui.QSizePolicy.Maximum,
                           QtGui.QSizePolicy.Expanding)
        #self.setLimits(yMin = 0, yMax=4000)

        #self.proxy = pg.SignalProxy(self.plotItem.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoveEvent)
        #self.plotItem.sigRangeChanged.connect(self.updateRegion)

        #region
        self._region = pg.LinearRegionItem(
            orientation=pg.LinearRegionItem.Horizontal)
        #The Z value decides the stacking order of sibling (neighboring) items. High Z = on top
        self._region.setZValue(10)
        self.setInitialRange()
        self.plotItem.addItem(self._region)
        #send signal to slots that range has been set
        #if if remove finished signal need to enable this instead
        #self.updateOnRegionChange()
        self.updateOnRegionChangeFinished()
        self.connectSlots()
Example #2
0
    def generatePlot(self, logTrackData, wellPlotData):

        #pw = pg.PlotWidget(name='Plot1')  ## giving the plots names allows us to link their axes together
        self.getAxis('left').setStyle(showValues=False)
        self.getAxis('bottom').setStyle(showValues=False)
        #store data for header to retrieve
        self.setData(Qt.UserRole, logTrackData)
        #see http://stackoverflow.com/questions/5036700/how-can-you-dynamically-create-variables-in-python-via-a-while-loop

        self.show()
        #Reset the dict to empty
        self.plotItemDict = {}
        axisDict = {}
        i = 0
        firstLogId = logTrackData.getLogs()[0]
        for log in logTrackData.getLogs():
            if i == 0:
                self.yData = log.z_measure_data
                self.plotItemDict[log.id] = self.plotItem
                #hide the A button see https://groups.google.com/forum/#!topic/pyqtgraph/5cc0k6TG89k
                self.plotItemDict[log.id].hideButtons()
                self.plotItemDict[log.id].setRange(xRange=(log.log_plot_left,
                                                           log.log_plot_right),
                                                   padding=0,
                                                   disableAutoRange=True)
                plt = self.plotItemDict[log.id].plot(y=log.z_measure_data,
                                                     x=log.log_data)
                rgbaColor = ImageUtils.rbgaToQColor(log.rgb, log.alpha)
                plt.setPen(rgbaColor)
            elif i == 1:
                self.plotItemDict[log.id] = pg.ViewBox()
                self.plotItemDict[log.id].setRange(xRange=(log.log_plot_left,
                                                           log.log_plot_right),
                                                   padding=0,
                                                   disableAutoRange=True)
                self.plotItemDict[firstLogId].scene().addItem(
                    self.plotItemDict[log.id])
                self.plotItemDict[firstLogId].getAxis('left').linkToView(
                    self.plotItemDict[log.id])
                self.plotItemDict[log.id].setXLink(
                    self.plotItemDict[firstLogId])

                plotCurveItem = pg.PlotCurveItem()
                plotCurveItem.setData(y=log.z_measure_data, x=log.log_data)
                rgbaColor = ImageUtils.rbgaToQColor(log.rgb, log.alpha)
                plotCurveItem.setPen(rgbaColor)
                self.plotItemDict[log.id].addItem(plotCurveItem)
            else:
                self.plotItemDict[log.id] = pg.ViewBox()
                self.plotItemDict[log.id].setRange(xRange=(log.log_plot_left,
                                                           log.log_plot_right),
                                                   padding=0,
                                                   disableAutoRange=True)
                axisDict[i] = pg.AxisItem('top')
                self.plotItemDict[firstLogId].layout.addItem(axisDict[i])
                self.plotItemDict[firstLogId].scene().addItem(
                    self.plotItemDict[log.id])
                axisDict[i].linkToView(self.plotItemDict[log.id])
                self.plotItemDict[log.id].setYLink(
                    self.plotItemDict[firstLogId])

                plotCurveItem = pg.PlotCurveItem()
                plotCurveItem.setData(y=log.z_measure_data, x=log.log_data)
                rgbaColor = ImageUtils.rbgaToQColor(log.rgb, log.alpha)
                plotCurveItem.setPen(rgbaColor)
                self.plotItemDict[log.id].addItem(plotCurveItem)
            i += 1

        self.invertY()
        pixelWidth = WellPlotUtils.convertmmToDPI(logTrackData.track_width)

        self.setFixedWidth(pixelWidth)
        self.setSizePolicy(QtGui.QSizePolicy.Maximum,
                           QtGui.QSizePolicy.Expanding)