Exemplo n.º 1
0
 def plotHeaderFields(self, logPlotData):
     logger.debug(">>plotMultiLogs()")
     WidgetUtils.removeWidgets(self.headerLayout)
     self.headerPlot = HeaderPlotMPL(depthPlot=self.depthPlot,
                                     mainPlot=self.canvas,
                                     logPlotData=logPlotData)
     self.headerLayout.addWidget(self.headerPlot)
Exemplo n.º 2
0
 def createHeaderTracks(self):
     if len(self.logTracks) > 0:
         WidgetUtils.removeWidgets(self.dataLayout)
         for track in self.logTracks:
             data = track.data(Qt.UserRole)
             if isinstance(data, ZAxisData):
                 logger.debug(
                     "--createHeaderTracks() domainZType: {0} domainZReference: {1}"
                     .format(data.z_axis_type, data.z_axis_reference_level))
                 depthHeader = self.createDepthHeader(
                     track, self.wellPlotData)
                 depthHeader.setFixedWidth(track.geometry().width())
                 self.dataLayout.addWidget(depthHeader)
             elif isinstance(data, LogTrackData):
                 plotHeader = self.createPlotHeader(track,
                                                    self.wellPlotData)
                 plotHeader.setFixedWidth(track.geometry().width())
                 self.dataLayout.addWidget(plotHeader)
                 for log in data.getLogs():
                     logger.debug(
                         "--createHeaderTracks() log name: {0} ".format(
                             log.name))
             else:
                 logger.debug(
                     "--createHeaderTracks() unrecognized data type:{0} ".
                     format(type(data)))
         self.dataLayout.addStretch(1)
     else:
         logger.debug("--createHeaderTracks() Error: no logs to plot")
Exemplo n.º 3
0
    def createCanvas(self):
        logger.debug(">>createCanvas()")

        if len(self.wellPlotData.getLogTrackDatas()) > 0:
            WidgetUtils.removeWidgets(self.dataLayout)
            tracks = self.createPyqtgraphTracks()
            for track in tracks:
                self.allTracks.append(track)
                self.dataLayout.addWidget(track)
            #if using Preferred size policy for this class need to stretch (Maximum doesn't require it)
            self.dataLayout.addStretch(1)
        else:
            logger.debug("--plotMultiLogs() Error: no logs to plot")
Exemplo n.º 4
0
    def paintEvent(self, event):
        MARGIN_PIXELS = 4

        painter = QPainter()
        (r, g, b, alpha) = ImageUtils.rbgaTointValues(self.log.rgb,
                                                      self.log.alpha)

        lineColour = QColor(r, g, b, alpha)

        assert lineColour != None
        assert self.log.line_style != None

        lineStyle = WidgetUtils.getQtPenStyle(self.log.line_style)

        assert lineStyle != None
        assert self.log.line_width != None

        lineWidth = NumberUtils.floatToIntDefault(self.log.line_width, 1)
        pen = QPen(lineColour, lineWidth, lineStyle)

        painter.begin(self)
        painter.setPen(pen)
        labelMargin = self.logName_label.margin()
        yLevel = self.logName_label.rect().bottomLeft().y()
        xStart = labelMargin
        xStop = self.track.geometry().width() - labelMargin
        #line is relative to widget not screen
        painter.drawLine(xStart, yLevel, xStop, yLevel)

        painter.end()
Exemplo n.º 5
0
    def paintEvent( self, event ) :
        MARGIN_PIXELS = 4
        
        painter = QPainter()
        (r, g, b, alpha) = ImageUtils.rbgaTointValues(self.log.rgb, self.log.alpha)
        
        lineColour = QColor(r, g, b, alpha)
        
        assert lineColour != None 
        assert self.log.line_style != None
        
        lineStyle = WidgetUtils.getQtPenStyle(self.log.line_style)
        
        assert lineStyle != None 
        assert self.log.line_width != None
        
        lineWidth = NumberUtils.floatToIntDefault(self.log.line_width, 1)
        pen = QPen(lineColour, lineWidth, lineStyle)
        
        painter.begin(self)
        painter.setPen(pen)

        yLevel = self.logName_label.rect().bottomLeft().y()
        xStart = self.xpix[0]
        xStop = self.xpix[1]
        
        #horizontal line
        #logger.debug("--paintEvent() r: {0},  g: {1},  b: {2},  a: {3}, name{4}".format(r, g, b, alpha, self.log.name))
        #logger.debug("--paintEvent() xStart: {0},  yLevel: {1},  xStop: {2},  yLevel: {3}".format(xStart, yLevel, xStop, yLevel))
        painter.drawLine( xStart, yLevel, xStop, yLevel )
        
        painter.end()
Exemplo n.º 6
0
    def createCanvas(self, logPlotData):
        logger.debug(">>createCanvas()")
        #test
        for subPlotData in logPlotData.sub_plots:
            logger.debug(
                "--createCanvas() plot_index:{0} track_width:{1} track_gap:{2}"
                .format(subPlotData.plot_index, subPlotData.track_width,
                        subPlotData.track_gap))
            for log in subPlotData._logs:
                logger.debug("--createCanvas id:{0}, name:{1}".format(
                    log.id, log.name))
        #end test
        if len(logPlotData.sub_plots) > 0:
            WidgetUtils.removeWidgets(self.dataLayout)

            #test
            #time.sleep(1) # delays for 1 second
            #end test

            #There may be a better way to link plots with the toolbar
            self.mainWidget.setLogPlotData(logPlotData)

            self.depthPlot = DepthAxis(logPlotData, self.dataWidget)
            self.dataLayout.addWidget(self.depthPlot)

            self.canvas = MultiLogCanvas(logPlotData, self.dataWidget)
            self.canvas.setAutoFillBackground(True)
            self.dataLayout.addWidget(self.canvas)

            spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                           QtGui.QSizePolicy.Minimum)
            self.dataLayout.addItem(spacerItem)
        else:
            logger.error("--plotMultiLogs() Error: no logs to plot")
            if AppSettings.isDebugMode:
                raise ValueError
Exemplo n.º 7
0
    def clearWidgets(self, wellPlotData):
        '''delete everything if existing'''
        if self.trackViewer is not None:
            WidgetUtils.removeWidgets(self.scrollArea.layout())
            self.trackViewer = None
            self.wellPlotData = wellPlotData

        if self.headerViewer is not None:
            WidgetUtils.removeWidgets(self.headerScrollArea.layout())
            self.headerViewer = None

        if (self.overviewWidget is not None) and (self.scaleWidgetLayout
                                                  is not None):
            WidgetUtils.removeWidgets(self.scaleWidgetLayout)
            self.overviewWidget = None
Exemplo n.º 8
0
    def populatePlotTab(self):
        logger.debug(">>populatePlotTab()")

        titleOnCheckState = WidgetUtils.getQtCheckObject(
            self._wellPlotData.title_on)
        self.plotTitleOnCheckBox.setCheckState(titleOnCheckState)
        self.plotTitleOnCheckBox.stateChanged.connect(self.styleChanged)
        self.plotTitleLineEdit.setText(self._wellPlotData.title)
        self.plotTitleLineEdit.textChanged.connect(self.styleChanged)
        self.plotPrintDPILineEdit.setText(str(self._wellPlotData.dpi))
        self.plotPrintDPILineEdit.textChanged.connect(self.styleChanged)
        intValidator = QtGui.QIntValidator()
        self.plotPrintDPILineEdit.setValidator(intValidator)
        #not enabled for this version
        self.plotTitleOnCheckBox.setEnabled(False)
        self.plotTitleLineEdit.setEnabled(False)
        self.plotPrintDPILineEdit.setEnabled(False)

        trackBackButtonQColor = ImageUtils.rbgToQColor(
            self._wellPlotData.plot_background_rgb)
        trackBackColorButton = QColorButton()
        trackBackColorButton.setColor(trackBackColorButton)
        self.trackBackgroundColorPushButton = trackBackColorButton
        self.trackBackgroundColorPushButton.clicked.connect(self.styleChanged)
        plotBackgroundAlpha = NumberUtils.stringToInt(
            self._wellPlotData.plot_background_alpha)
        self.trackBackgroundOpacitySpinBox.setValue(plotBackgroundAlpha)
        self.trackBackgroundOpacitySpinBox.valueChanged.connect(
            self.styleChanged)

        gridOnCheckState = WidgetUtils.getQtCheckObject(
            self._wellPlotData.grid_on)
        self.gridOnCheckBox.setCheckState(gridOnCheckState)
        self.gridOnCheckBox.stateChanged.connect(self.styleChanged)

        buttonQColor = ImageUtils.rbgToQColor(self._wellPlotData.grid_rgb)
        qColorButton = QColorButton()
        qColorButton.setColor(buttonQColor)
        self.gridColorPushButton = qColorButton
        self.gridColorPushButton.clicked.connect(self.styleChanged)

        gridAlpha = NumberUtils.stringToInt(self._wellPlotData.grid_alpha)
        self.gridOpacitySpinBox.setValue(gridAlpha)
        self.gridOpacitySpinBox.valueChanged.connect(self.styleChanged)

        index = self.gridStyleComboBox.findText(
            self._wellPlotData.grid_line_style, QtCore.Qt.MatchFixedString)
        if index >= 0:
            self.gridStyleComboBox.setCurrentIndex(index)
        self.gridStyleComboBox.currentIndexChanged.connect(self.styleChanged)

        self.gridVerticalDivSpinBox.setValue(
            self._wellPlotData.grid_vertical_divisions)
        self.gridVerticalDivSpinBox.valueChanged.connect(self.styleChanged)

        expandedCheckState = WidgetUtils.getQtCheckObject(
            self._wellPlotData.single_row_header_labels)
        self.labelsExpandedCheckBox.setCheckState(expandedCheckState)
        self.labelsExpandedCheckBox.stateChanged.connect(self.styleChanged)

        labelBackButtonQColor = ImageUtils.rbgToQColor(
            self._wellPlotData.label_background_rgb)
        labelBackColorButton = QColorButton()
        labelBackColorButton.setColor(labelBackButtonQColor)
        self.labelBackgroundColorPushButton = labelBackColorButton
        self.labelBackgroundColorPushButton.clicked.connect(self.styleChanged)

        labelBackgroundAlpha = NumberUtils.stringToInt(
            self._wellPlotData.label_background_alpha)
        self.labelBackgroundOpacitySpinBox.setValue(labelBackgroundAlpha)
        self.labelBackgroundOpacitySpinBox.valueChanged.connect(
            self.styleChanged)

        labelForegroundRGB = NumberUtils.stringToInt(
            self._wellPlotData.label_foreground_rgb)
        labelForeButtonQColor = ImageUtils.rbgToQColor(labelForegroundRGB)
        labelForeColorButton = QColorButton()
        labelForeColorButton.setColor(labelForeButtonQColor)
        self.labelForegroundColorPushButton = labelForeColorButton
        self.labelForegroundColorPushButton.clicked.connect(self.styleChanged)

        labelForegroundAlpha = NumberUtils.stringToInt(
            self._wellPlotData.label_foreground_alpha)
        self.labelForegroundOpacitySpinBox.setValue(labelForegroundAlpha)
        self.labelForegroundOpacitySpinBox.valueChanged.connect(
            self.styleChanged)
Exemplo n.º 9
0
    def saveDataState(self, wellPlotData, curveStyleWidget):
        '''called from apply/OK button, saves all data to log objects '''
        #assert twItem.data != None
        #assert isinstance(twItem.data(Qt.UserRole), tuple)
        #assert isinstance(twItem.data(Qt.UserRole)[0], LogTrackData)
        #assert isinstance(twItem.data(Qt.UserRole)[1], Log)
        allRows = curveStyleWidget.curveTableWidget.rowCount()
        for row in range(0, allRows):
            twItemName = curveStyleWidget.curveTableWidget.item(row, 0)
            trackData = twItemName.data(Qt.UserRole)[0]
            tableLog = twItemName.data(Qt.UserRole)[1]
            for track in wellPlotData.getLogTrackDatas():
                for log in track.getLogs():
                    if track.plot_index == trackData.plot_index:
                        if log.id == tableLog.id:
                            logger.debug(
                                "track.plot_index :{0}, trackData.plot_index: {1}, log.id: {2}, tableLog.id: {3}, log.name: {4}"
                                .format(track.plot_index, trackData.plot_index,
                                        log.id, tableLog.id, log.name))

                            twItemLeftScale = curveStyleWidget.curveTableWidget.item(
                                row, 4)
                            log.left_scale = NumberUtils.straightStringToFloat(
                                twItemLeftScale.text())
                            twItemRightScale = curveStyleWidget.curveTableWidget.item(
                                row, 5)
                            log.right_scale = NumberUtils.straightStringToFloat(
                                twItemRightScale.text())
                            twItemLogarithmic = curveStyleWidget.curveTableWidget.item(
                                row, 6)
                            log.logarithmic = WidgetUtils.getBoolFromQtCheck(
                                twItemLogarithmic.checkState())

                            twItemCurveColour = curveStyleWidget.curveTableWidget.cellWidget(
                                row, 7)
                            r, g, b, a = QColor(
                                twItemCurveColour.color()).getRgb()
                            rgbStr = ImageUtils.rgbToString(r, g, b)
                            log.rgb = rgbStr

                            twItemOpacity = curveStyleWidget.curveTableWidget.item(
                                row, 8)
                            log.alpha = NumberUtils.straightStringToFloat(
                                twItemOpacity.text())
                            twItemLineWidth = curveStyleWidget.curveTableWidget.item(
                                row, 9)
                            log.line_width = NumberUtils.straightStringToFloat(
                                twItemLineWidth.text())

                            twItemLineStyle = curveStyleWidget.curveTableWidget.cellWidget(
                                row, 10)
                            log.line_style = twItemLineStyle.currentText()

                            twItemPointSize = curveStyleWidget.curveTableWidget.item(
                                row, 11)
                            log.point_size = NumberUtils.straightStringToFloat(
                                twItemPointSize.text())

                            twItemPointStyle = curveStyleWidget.curveTableWidget.cellWidget(
                                row, 12)
                            log.point_style = twItemPointStyle.currentText()

                            twItemPointsOn = curveStyleWidget.curveTableWidget.item(
                                row, 13)
                            log.log_plot_points_on = WidgetUtils.getBoolFromQtCheck(
                                twItemPointsOn.checkState())
Exemplo n.º 10
0
    def populateData(self):
        logger.debug(">>populateData()")

        titleOnCheckState = WidgetUtils.getQtCheckObject(
            self._wellPlotData.title_on)
        self.plotTitleOnCheckBox.setCheckState(titleOnCheckState)
        self.plotTitleOnCheckBox.stateChanged.connect(self.styleChanged)
        self.plotTitleLineEdit.setText(self._wellPlotData.title)
        self.plotTitleLineEdit.textChanged.connect(self.styleChanged)

        #not enabled for this version
        self.plotTitleOnCheckBox.setEnabled(False)
        self.plotTitleLineEdit.setEnabled(False)
        #track background button
        trackBackButtonQColor = ImageUtils.rgbToQColor(
            self._wellPlotData.plot_background_rgb)
        hBox1 = QHBoxLayout()
        self.trackBGColourBtnHolderWidget.setLayout(hBox1)
        self.trackBackgroundColorPushButton = QColorButton()
        self.trackBackgroundColorPushButton.setColor(trackBackButtonQColor)
        hBox1.addWidget(self.trackBackgroundColorPushButton)
        self.trackBackgroundColorPushButton.clicked.connect(self.styleChanged)

        plotBackgroundAlpha = NumberUtils.stringToInt(
            self._wellPlotData.plot_background_alpha)
        self.trackBackgroundOpacitySpinBox.setValue(plotBackgroundAlpha)
        self.trackBackgroundOpacitySpinBox.valueChanged.connect(
            self.styleChanged)

        singleRowCheckState = WidgetUtils.getQtCheckObject(
            self._wellPlotData.single_row_header_labels)
        self.singleRowLabelsCheckBox.setCheckState(singleRowCheckState)
        self.singleRowLabelsCheckBox.stateChanged.connect(self.styleChanged)
        #header label background button
        labelBackButtonQColor = ImageUtils.rgbToQColor(
            self._wellPlotData.label_background_rgb)
        hBox2 = QHBoxLayout()
        self.headerLabelBGColourBtnHolderWidget.setLayout(hBox2)
        self.labelBackgroundColorPushButton = QColorButton()
        self.labelBackgroundColorPushButton.setColor(labelBackButtonQColor)
        hBox2.addWidget(self.labelBackgroundColorPushButton)
        self.labelBackgroundColorPushButton.clicked.connect(self.styleChanged)

        labelBackgroundAlpha = NumberUtils.stringToInt(
            self._wellPlotData.label_background_alpha)
        self.labelBackgroundOpacitySpinBox.setValue(labelBackgroundAlpha)
        self.labelBackgroundOpacitySpinBox.valueChanged.connect(
            self.styleChanged)

        #label foreground button

        #labelForegroundRGB = NumberUtils.stringToInt(self._wellPlotData.label_foreground_rgb)
        labelForeButtonQColor = ImageUtils.rgbToQColor(
            self._wellPlotData.label_foreground_rgb)
        hBox3 = QHBoxLayout()
        self.headerLabelTextColourBtnHolderWidget.setLayout(hBox3)
        self.labelForegroundColorPushButton = QColorButton()
        self.labelForegroundColorPushButton.setColor(labelForeButtonQColor)
        hBox3.addWidget(self.labelForegroundColorPushButton)
        self.labelForegroundColorPushButton.clicked.connect(self.styleChanged)

        labelForegroundAlpha = NumberUtils.stringToInt(
            self._wellPlotData.label_foreground_alpha)
        self.labelForegroundOpacitySpinBox.setValue(labelForegroundAlpha)
        self.labelForegroundOpacitySpinBox.valueChanged.connect(
            self.styleChanged)