Пример #1
0
 def accept(self):
     logger.debug(">>accept()")
     index = self.wellsComboBox.currentIndex()
     data = self.wellsComboBox.itemData(index)
     if data is not None:
         if isinstance(data, Well):
             logs = LogDao.getWellLogs(data.id)
             if logs != None:
                 wellPlotSetupDialog = WellPlotSetupDialog(logs,
                                                           well=data,
                                                           logSet=None)
                 wellPlotSetupDialog.exec_()
                 self.close()
         else:
             logger.debug("type(data):{0}".format(type(data)))
     else:
         logger.debug("Data is None")
Пример #2
0
    def __init__(self, wellPlotData, selectedWell, logSet=None, parent=None):
        super(TemplateSettingsDialog, self).__init__(parent)
        assert selectedWell is not None

        self.setWindowTitle(self.__str__())
        self._well = selectedWell
        self._logSet = logSet
        self._wellPlotData = wellPlotData
        self._template = None
        if self._wellPlotData is not None:
            self._initialPlotList = copy.deepcopy(
                wellPlotData.getLogTrackDatas())
        self._logs = LogDao.getWellLogsOptSession(self._well, self._logSet)

        self.wellPlotSignals = WellPlotSignals()

        self.isDirty = False
        #added this flag so don't disconnect from slot while in the slot
        self.changeingLogTrack = False

        #For now use what is working
        self.useCheckboxLayout = False

        self._overviewLayoutWidget = None
        self._trackLayoutWidget = None
        self._wellPlotStyleWidget = None
        self._trackStyleWidget = None
        self._curveStyleWidget = None
        self._itemWidget = None
        #scale tab widgets
        self._tracksScaleWidget = None
        self._primaryZTypeWidget = None
        self._overviewRangeWidget = None

        self.setupUi(self)
        self.setupTabs()
        self.setTemplate()
        #set details after template as requires template to setup
        self.setupDetailsTab()
        self.connectSlots()
        self.setContentsMargins(0, 0, 0, 0)
        self.tabWidget.setContentsMargins(0, 0, 0, 0)
Пример #3
0
    def getWellPlotdata(self):

        self.dummyDbSetup.setupDatabase()
        templates = WellPlotTemplateDao.getAllWellPlotTemplates()
        assert 9 == len(templates), "Incorrect template number: {0}".format(len(templates))

        templates = WellPlotTemplateDao.getAllWellPlotTemplates()
        
        well = self.dummyDbSetup.createWell()
        self.dummyDbSetup.create1Log(well.id)
        logs = LogDao.getWellLogs(well.id)
        wellPlotModelAccess = WellPlotModelAccess()
        uid = 42
        templateDao = WellPlotTemplateDao()
        #allTemplates = templateDao.getAllWellPlotTemplates()
        template = templateDao.getWellPlotTemplateFromUid("alllogs")
        #template = allTemplates[0]
        template.__init__()
        wellPlotData = wellPlotModelAccess.createWellPlotData(logs, uid, well, template)
        return wellPlotData
Пример #4
0
    def selectActiveLogsClicked(self):
        ''' set checkboxes as checked diagonally down the layout matrix '''
        logger.debug(">>selectActiveLogsClicked()")
        #self._curveStyleWidget.chkboxTableWidget.blockSignals(True)

        try:
            logger.debug(
                "--selectActiveLogsClicked() disconnecting from changeLogTrack"
            )
            self._curveStyleWidget.chkboxTableWidget.itemChanged.disconnect(
                self._curveStyleWidget.changeLogTrack)
            logger.debug(
                "--selectActiveLogsClicked() disconnecting from changeLogTrack"
            )
        except TypeError as ex:
            # will be disconnected on first run, log it and continue
            logger.debug(str(ex))

        #clear all checkboxes first
        self.clearAllCheckboxes()
        if (self._curveStyleWidget._logs != None) and (len(
                self._curveStyleWidget._logs) > 0):
            activeLogIds = LogDao.getActiveLogIds(self._curveStyleWidget._logs)

            allRows = self._curveStyleWidget.chkboxTableWidget.rowCount()
            allColumns = self._curveStyleWidget.chkboxTableWidget.columnCount()
            for row in range(allRows):
                tw = self._curveStyleWidget.chkboxTableWidget.item(row, 0)
                logger.debug("--selectActiveLogsClicked() row: " + str(row))
                log = tw.data(Qt.UserRole)
                if (tw != None) and (log.id in activeLogIds):
                    tw.setCheckState(QtCore.Qt.Checked)
        else:
            logger.debug("<<selectActiveLogsClicked logs == None")

        self._curveStyleWidget.chkboxTableWidget.itemChanged.connect(
            self._curveStyleWidget.changeLogTrack)
        logger.debug(
            "--selectActiveLogsClicked() reconnected to changeLogTrack")
Пример #5
0
    def test_tickDisplayedLogs(self):
        #test that all input logs are automatically checked in the table
        logger.debug(
            "================================================================="
        )
        logger.debug(">>test_tickDisplayedLogs() ")
        app = QApplication(sys.argv)

        well, logPlotData = self.generateLogPlotData()

        layoutDialog = WellPlotSettingsDialog(logPlotData, well)
        rows = layoutDialog.chkboxTableWidget.rowCount()
        cols = layoutDialog.chkboxTableWidget.columnCount()

        logs = LogDao.getWellLogsOptSession(well, logSet=None)
        self.assertEquals(3, len(logs))
        #number of logs=3 + Log name column plus extra column
        self.assertEquals(5, cols)
        chkBoxItem = layoutDialog.chkboxTableWidget.item(0, 0)
        self.assertIsNotNone(chkBoxItem)
        plotList = layoutDialog._wellPlotData.sub_plots
        self.assertEquals(3, len(plotList))

        for row, log in enumerate(logs):
            for subPlotData in plotList:
                for plotLog in subPlotData.getLogs():
                    if log.id == plotLog.id:
                        logger.debug(
                            "--test_tickDisplayedLogs() match found id: {0}".
                            format(log.id))
                        chkState = layoutDialog.chkboxTableWidget.item(
                            row, subPlotData.plot_index).checkState()
                        self.assertEquals(QtCore.Qt.Checked, chkState)
        logger.debug(
            "================================================================="
        )
Пример #6
0
    def test_removeEmptyColumns(self):
        #test that on column removal all indexes are set correctly
        logger.debug(
            "================================================================="
        )
        logger.debug(">>test_removeEmptyColumns() ")
        app = QApplication(sys.argv)
        well, logPlotData = self.generateLogPlotData()
        layoutDialog = WellPlotSettingsDialog(logPlotData, well)

        plotLogs = self.getCurrentlyPlottedLogs(logPlotData)
        self.assertEquals(3, len(plotLogs))
        logs = LogDao.getLogNamesCSV(plotLogs)
        logger.debug("--test_removeEmptyColumns() initial logs: " + logs)

        allRows = layoutDialog.chkboxTableWidget.rowCount()
        allColumns = layoutDialog.chkboxTableWidget.columnCount()
        self.assertEquals(3, allRows)
        self.assertEquals(5, allColumns)
        #unselect first log
        chkBoxItem = layoutDialog.chkboxTableWidget.item(0, 1)
        log = chkBoxItem.data(Qt.UserRole)
        logger.debug(
            "--test_removeEmptyColumns() unchecking first cell log name: " +
            str(log.name))
        chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
        newPlotLogs = self.getCurrentlyPlottedLogs(logPlotData)
        newLogs = LogDao.getLogNamesCSV(newPlotLogs)
        self.assertEquals("2DT,3SP", newLogs)

        self.getCheckbxTableStatus(layoutDialog)
        allRows = layoutDialog.chkboxTableWidget.rowCount()
        allColumns = layoutDialog.chkboxTableWidget.columnCount()
        self.assertEquals(3, allRows)
        self.assertEquals(4, allColumns)

        chkBoxItem = layoutDialog.chkboxTableWidget.item(1, 1)
        log = chkBoxItem.data(Qt.UserRole)
        logger.debug(
            "--test_removeEmptyColumns() unchecking second cell log name: " +
            str(log.name))
        #unselect another log
        chkBoxItem.setCheckState(QtCore.Qt.Unchecked)

        newPlotLogs = self.getCurrentlyPlottedLogs(logPlotData)
        newLogs = LogDao.getLogNamesCSV(newPlotLogs)
        allRows = layoutDialog.chkboxTableWidget.rowCount()
        allColumns = layoutDialog.chkboxTableWidget.columnCount()

        self.assertEquals(3, allRows)
        self.assertEquals(3, allColumns)
        self.assertEquals("3SP", newLogs)
        self.getCheckbxTableStatus(layoutDialog)

        plotList = logPlotData.sub_plots
        #self.assertEquals(2, len(plotList))

        firstPlot = plotList[0]
        firstPlotLogs = []
        for log in firstPlot.getLogs():
            firstPlotLogs.append(log)
        #self.assertEquals(1, len(firstPlotLogs))
        #self.assertEquals("2DT", firstPlotLogs[0].name)

        secondPlot = plotList[1]
        secondPlotLogs = []
        for log in secondPlot.getLogs():
            secondPlotLogs.append(log)
        #self.assertEquals(1, len(secondPlotLogs))
        #self.assertEquals("3PEF", secondPlotLogs[1].name)

        logger.debug(
            "================================================================="
        )
Пример #7
0
    def createSingleRowLabelBox(self):
        logger.debug("--setupUI() single row label")
        self.logValLeft_label = QtGui.QLabel()
        self.logValLeft_label.setText(str(self.log.log_plot_left))
        logValLeftWidth = self.logValLeft_label.fontMetrics().boundingRect(
            self.logValLeft_label.text()).width()

        #see http://stackoverflow.com/questions/8633433/qt-get-the-pixel-length-of-a-string-in-a-qlabel
        #add 10% padding as bounding rect may not give exact width
        paddedLeftWidth = int(logValLeftWidth +
                              logValLeftWidth / self.VALUE_PADDING)
        self.logValLeft_label.setFixedWidth(paddedLeftWidth)
        assert self.log.log_plot_left != None
        assert self.log.log_plot_left != ""

        self.logName_label = QtGui.QLabel()
        units = LogDao.getUnits(self.log)
        assert units != None
        if units != None:
            labelText = self.log.name.strip() + " (" + units.strip() + ")"
        else:
            labelText = self.log.name.strip()
        self.logName_label.setText(labelText)
        logNameWidth = self.logName_label.fontMetrics().boundingRect(
            self.logName_label.text()).width()
        paddedNameWidth = int(logNameWidth + logNameWidth / self.NAME_PADDING)

        self.logValRight_label = QtGui.QLabel()
        self.logValRight_label.setText(str(self.log.log_plot_right))
        logValRightWidth = self.logValRight_label.fontMetrics().boundingRect(
            self.logValRight_label.text()).width()
        paddedRightWidth = int(logValRightWidth +
                               logValRightWidth / self.VALUE_PADDING)
        self.logValRight_label.setFixedWidth(paddedRightWidth)
        assert self.log.log_plot_right != None
        assert self.log.log_plot_right != ""

        fullLabelWidths = (paddedLeftWidth + paddedNameWidth +
                           paddedRightWidth)
        labelList = []
        #drop units if doesn't fit
        if self.track.geometry().width() < fullLabelWidths:
            self.logName_label.setText(self.log.name)
            logNameWidthNoUnit = self.logName_label.fontMetrics().boundingRect(
                self.logName_label.text()).width()
            paddedNameWidthNoUnit = int(logNameWidthNoUnit +
                                        logNameWidthNoUnit / 10)
            labelWidths = (paddedLeftWidth + paddedNameWidthNoUnit +
                           paddedRightWidth)
            #drop l and R vals if still doesn't fit
            if self.track.geometry().width() < labelWidths:
                self.logName_label.setFixedWidth(paddedNameWidthNoUnit)
                labelList.append(self.logName_label)

            else:
                self.logName_label.setFixedWidth(paddedNameWidthNoUnit)
                labelList.append(self.logValLeft_label)
                labelList.append(self.logName_label)
                labelList.append(self.logValRight_label)
        else:
            self.logName_label.setFixedWidth(paddedNameWidth)
            labelList.append(self.logValLeft_label)
            labelList.append(self.logName_label)
            labelList.append(self.logValRight_label)

        hbox = self.createHBoxWithLabels(labelList, True)
        return hbox
Пример #8
0
    def setupUI(self):
        PREFFERED_SPACER_HEIGHT = 6
        
        if self.logPlotData.single_row_header_labels:
            logger.debug("--setupUI() expanded label")
            vBox = QtGui.QVBoxLayout()
            vBox.setMargin(0)
        
            hbox = QtGui.QHBoxLayout()
            hbox.setMargin(0)
            
            self.logName_label = QtGui.QLabel()
            self.logName_label.setText(self.log.name)
            logNameWidth = self.logName_label.geometry().width()

            if (self.widget_width - logNameWidth) >0:
                preferredSpace = (self.widget_width - logNameWidth)/2
            else:
                preferredSpace = (self.widget_width)/2
            
            labelLspacerItem = QtGui.QSpacerItem(preferredSpace, PREFFERED_SPACER_HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            
            hbox.addItem(labelLspacerItem)          
            hbox.addWidget(self.logName_label)
            
            labelRspacerItem = QtGui.QSpacerItem(preferredSpace, PREFFERED_SPACER_HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            hbox.addItem(labelRspacerItem)
            
            valHbox = QtGui.QHBoxLayout()
            valHbox.setMargin(0)
            
            self.logValLeft_label = QtGui.QLabel()
            self.logValLeft_label.setText(str(self.log.log_plot_left))
            
            units = self.getUnits(self.log)
            
            assert units != None
            
            self.logUnit_label = QtGui.QLabel()
            self.logUnit_label.setText(units)
            
            self.logValRight_label = QtGui.QLabel()
            self.logValRight_label.setText(str(self.log.log_plot_right))
            
            logValLeftWidth = self.logValLeft_label.geometry().width()
            logValRightWidth = self.logValRight_label.geometry().width()
            logUnitWidth = self.logUnit_label.geometry().width()
            labelWidths =  (logValLeftWidth + logValRightWidth + logUnitWidth)
            if (self.widget_width - labelWidths) >0:
                preferredSpace = (self.widget_width - labelWidths)/2
            else:
                preferredSpace = (self.widget_width)/2
            
            valueLSpacerItem = QtGui.QSpacerItem(preferredSpace, PREFFERED_SPACER_HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            valueRSpacerItem = QtGui.QSpacerItem(preferredSpace, PREFFERED_SPACER_HEIGHT, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            
            valHbox.addWidget(self.logValLeft_label)
            valHbox.addItem(valueLSpacerItem)
            valHbox.addWidget(self.logUnit_label)
            valHbox.addItem(labelRspacerItem)        
            valHbox.addWidget(self.logValRight_label)
            
            vBox.addLayout(hbox)
            vBox.addLayout(valHbox)
            
            self.setLayout(vBox)

        else:
            logger.debug("--setupUI() compressed label")
            hbox = QtGui.QHBoxLayout()
            hbox.setMargin(0)
            
            self.logValLeft_label = QtGui.QLabel()
            self.logValLeft_label.setText(str(self.log.log_plot_left))
            
            self.logName_label = QtGui.QLabel()
            units = LogDao.getUnits(self.log)
            if units != None:
                labelText = self.log.name + " (" + units +")"
            else:
                labelText = self.log.name
            self.logName_label.setText(labelText)
            
            self.logValRight_label = QtGui.QLabel()
            self.logValRight_label.setText(str(self.log.log_plot_right))
            
            logValLeftWidth = self.logValLeft_label.geometry().width()
            logValRightWidth = self.logValRight_label.geometry().width()
            logNameWidth = self.logName_label.geometry().width()
            
            labelWidths =  (logValLeftWidth + logValRightWidth + logNameWidth)
            if (self.widget_width - labelWidths) >0:
                preferredSpace = (self.widget_width - labelWidths)/2
            else:
                preferredSpace = (self.widget_width)/2
                
            labelLspacerItem = QtGui.QSpacerItem(preferredSpace, 10, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            labelRspacerItem = QtGui.QSpacerItem(preferredSpace, 10, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            
            hbox.addWidget(self.logValLeft_label)
            hbox.addItem(labelLspacerItem)
            hbox.addWidget(self.logName_label)
            hbox.addItem(labelRspacerItem)
            hbox.addWidget(self.logValRight_label)
            self.setLayout(hbox)

        self.setFixedWidth(self.widget_width)

        #set colours
        pal=QtGui.QPalette()
        role = QtGui.QPalette.Background
        backgroundQColor = ImageUtils.rgbToQColor(self.logPlotData.label_background_rgb)
        pal.setColor(role, backgroundQColor)
        role = QtGui.QPalette.Foreground
        foregroundQColor = ImageUtils.rgbToQColor(self.logPlotData.label_foreground_rgb)
        pal.setColor(role, foregroundQColor)
        self.setPalette(pal)