def accept(self, *args, **kwargs):
        """ Save mapping data, from widget to list"""
        try:
            self.planHeatDMM.data.protectionLevelMap = []

            for x in range(0, self.protectionLevelMapTable.rowCount(), 1):
                data = ProtectionLevelMap()

                for y in range(0, self.protectionLevelMapTable.columnCount(),
                               1):

                    if y == 0:
                        item = self.protectionLevelMapTable.item(x, y)
                        data.user_definition_protection = "" if item is None else item.text(
                        )

                    elif y == 1:
                        cell = self.protectionLevelMapTable.cellWidget(x, y)
                        data.DMM_protection_level = 0 if cell is None else int(
                            cell.currentText())

                self.planHeatDMM.data.protectionLevelMap.append(data)

            return QtWidgets.QDialog.accept(self, *args, **kwargs)

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "ProtectionLevelMapDialog - accept Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "ProtectionLevelMapDialog - accept Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #2
0
 def __init__(self, planHeatDMM):
     """Constructor Dialog"""
     
     super(LogFileDialog, self).__init__(None)
     # Set up the user interface from Designer.
     # After setupUI you can access any designer object by doing
     # self.<objectname>, and you can use autoconnect slots - see
     # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
     # #widgets-and-dialogs-with-auto-connect
     self.setupUi(self)
     
     try:
         self.setWindowIcon(QtGui.QIcon(planHeatDMM.plugin_dir + os.path.sep + 'resources/logo.ico'))
         #self.setWindowFlags(self.windowFlags() & QtCore.Qt.WindowMinimizeButtonHint)
         self.setWindowModality(QtCore.Qt.ApplicationModal)
         self.setFixedSize(800,500)
         
         self.planHeatDMM = planHeatDMM
         
         self.setSystemDependantFontSize()
         self.showLogFile()
         
         
         
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","LogFileDialog - Constructor Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"LogFileDialog - Constructor Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         raise    
Пример #3
0
 def deleteAllRecordsTable(self):
     """ Reset All records from widget
     
     """
     try:
         records = self.fieldUserMapTable.rowCount()
         if records > 0:
             message = "{} rows reset, are you sure?".format(records)
             if showQuestiondialog(self, "Reset All Records",
                                   message) == QtWidgets.QMessageBox.Yes:
                 for rowPosition in range(
                         self.fieldUserMapTable.rowCount()):
                     combo = self.fieldUserMapTable.cellWidget(
                         rowPosition, 1)
                     combo.setCurrentText("None")
                 #while (self.fieldUserMapTable.rowCount() > 0):
                 #self.fieldUserMapTable.removeRow(0)
     except:
         self.planHeatDMM.resources.log.write_log(
             "ERROR",
             "FieldUserMapDialog - deleteAllRecordsTable Unexpected error:"
             + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(
             self.planHeatDMM.dlg,
             "FieldUserMapDialog - deleteAllRecordsTable Unexpected error:",
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
    def eventFilter(self, widget, event):
        """ Manage Event filter for keypress Enter in Toolbuttons """
        try:
            if event.type() == QEvent.KeyPress and event.key(
            ) == QtCore.Qt.Key_Return:
                #  print(widget.objectName())
                if widget.objectName() == "loadFileToolButton":
                    openLoadFileDialog(self.planHeatDMM)
                elif widget.objectName() == "saveFileToolButton":
                    openSaveFileDialog(self.planHeatDMM)
                elif widget.objectName() == "DTMToolButton":
                    openLoadFileDialogDTM(self.planHeatDMM)
                elif widget.objectName() == "DSMToolButton":
                    openLoadFileDialogDSM(self.planHeatDMM)
                elif widget.objectName() == "retrofittedScenariosToolbutton":
                    openRetrofittedScenarioDialog(self.planHeatDMM)
                elif widget.objectName() == "fieldAddToolButton":
                    openFieldUserMapDialog(self.planHeatDMM)
                elif widget.objectName() == "buildUseAddToolButton":
                    openBuildingUseMapDialog(self.planHeatDMM)
                elif widget.objectName() == "protectionAddToolButton":
                    openProtectionLevelMapDialog(self.planHeatDMM)
                elif widget.objectName() == "loadScenario":
                    loadScenario(self.planHeatDMM)

            return QtWidgets.QDialog.eventFilter(self, widget, event)
        except:
            showErrordialog(
                self.planHeatDMM.dlg,
                "PlanHeatDMM_dialog_base - eventFilter Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #5
0
    def accept(self, *args, **kwargs):
        """ Save mapping data, from widget to list"""
        try:
            self.planHeatDMM.data.shpDMMFieldsMap = []

            self.planHeatDMM.data.shpDMMFieldsMap = self.retrieveDataCSVInputFieldData(
            )
            shpDMMFieldsMapList = self.retrieveDataCSVInputFieldData(True)

            # UPDATE Mandatory Fields
            for shpDMMFieldsMap in shpDMMFieldsMapList:
                for shp_map_csv_field in self.planHeatDMM.data.shp_map_csv_fields:
                    if shpDMMFieldsMap.fieldName == shp_map_csv_field.fieldName:
                        shp_map_csv_field.fieldState = shpDMMFieldsMap.fieldState

            return QtWidgets.QDialog.accept(self, *args, **kwargs)

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR", "FieldUserMapDialog - accept Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "FieldUserMapDialog - accept Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #6
0
    def validateSelectedData(self, period_text, selectedValue):
        """ Validate refurbishment level from period """
        try:
            period = self.periodsDict[period_text]

            refurbishmentPeriodLevels = [
                level.refurbishment_level for level in
                self.planHeatDMM.data.refurbishment_level_periods[period]
            ]

            if selectedValue in refurbishmentPeriodLevels:
                return True
            else:
                return False

        except KeyError:
            return False

        except:
            self.__log.write_log(
                "ERROR",
                "RetrofitScenarioWidget - validateSelectedData Unexpected error:"
                + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "RetrofitScenarioWidget - validateSelectedData Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            return False
Пример #7
0
    def changeFieldState(self, fieldName, state, position):
        try:
            if position != -1:
                if state.lower() == "mandatory":
                    self.fieldUserMapTable.item(position, 2).setText(state)
                    #self.fieldUserMapTable.setItem(position , 2, QTableWidgetItem(state))
                    self.fieldUserMapTable.item(position, 2).setForeground(
                        QtGui.QColor(255, 0, 0))
                else:
                    #self.fieldUserMapTable.setItem(position , 2, QTableWidgetItem(state))
                    self.fieldUserMapTable.item(position, 2).setText(state)
                    self.fieldUserMapTable.item(position,
                                                2).setForeground(self.brush)
                    #self.fieldUserMapTable.item(position,2).setForeground(QtGui.QColor(0,0,0))

                self.fieldUserMapTable.setUpdatesEnabled(True)
                self.fieldUserMapTable.repaint()
                self.fieldUserMapTable.update()

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "FieldUserMapDialog - changeFieldState Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "FieldUserMapDialog - changeFieldState Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #8
0
    def addRecordsTable(self):
        """ Add Records to the Table Widget"""
        
        try:
            
            for user_use in self.planHeatDMM.data.inputSHPFieldBuildingUseValues:
                self.combo = QtWidgets.QComboBox(self)
                self.combo.setMouseTracking(False)
                self.combo.setObjectName("userFieldCombo")
                for data in self.planHeatDMM.data.buildingUse:
                    self.combo.addItem(data.use)
                
                
                l = [x for x in self.planHeatDMM.data.buildingUseMap if x.user_definition_use == user_use and x.DMM_use not in ("","Not evaluate")] 
                if l:
                    self.combo.setCurrentText(l[0].DMM_use)
                
                
                rowPosition = self.buildUseMapTable.rowCount()
                self.buildUseMapTable.insertRow(rowPosition)     
                self.buildUseMapTable.setItem(rowPosition , 0, QTableWidgetItem(user_use))
                self.buildUseMapTable.setCellWidget(rowPosition,1,self.combo)
                     
    

            
        except:
            self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - addRecordTable Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - addRecordTable Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #9
0
 def accept(self, *args, **kwargs):
     
     """ Save mapping data, from widget to list"""
     
     try:
         self.planHeatDMM.data.buildingUseMap = []
              
         for x in range(0,self.buildUseMapTable.rowCount(),1):
             data = BuildingUseMap()
             
             for y in range(0,self.buildUseMapTable.columnCount(),1):
                 
                 if y == 0:
                     item = self.buildUseMapTable.item(x,y)
                     data.user_definition_use = ""  if item is None else item.text()
                    
                 elif y == 1:
                     cell = self.buildUseMapTable.cellWidget(x,y)
                     data.DMM_use = ""  if cell is None else cell.currentText()
                     for building_use in  self.planHeatDMM.data.buildingUse:
                         if building_use.use == data.DMM_use:  
                             data.building_use_id = building_use.id  
                             data.non_office      = building_use.non_office
                             data.floor_height    = building_use.floor_height
                             #print(str(data))
                             break
                 
             self.planHeatDMM.data.buildingUseMap.append(data)        
         
             
         return QtWidgets.QDialog.accept(self, *args, **kwargs)     
     
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - accept Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - accept Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))    
Пример #10
0
    def accept(self, *args, **kwargs):
        """ Save mapping data, from widget tabs to tabData"""

        try:

            self.planHeatDMM.data.refurbishmentTabDataList = []

            for tabIndex in range(self.checkableTabWidget.count()):
                tab = self.checkableTabWidget.widget(tabIndex)
                tabData = self.checkableTabWidget.refurbishmentTempTabDataList[
                    tabIndex]
                tabData.rows = tab.retrieveTabData()

                self.planHeatDMM.data.refurbishmentTabDataList.append(tabData)

            self.planHeatDMM.data.futureScenarioYear = int(
                self.futureScenarioYearSpinBox.value())

            return QtWidgets.QDialog.accept(self, *args, **kwargs)

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "CompleteRetrofitScenarioDialog - accept Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "CompleteRetrofitScenarioDialog - accept Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
        return QtWidgets.QDialog.accept(self, *args, **kwargs)
    def __init__(self, planHeatDMM):
        """Dialog Constructor """

        super(ProtectionLevelMapDialog, self).__init__(None)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.setupUi(self)

        try:
            self.setWindowIcon(
                QtGui.QIcon(planHeatDMM.plugin_dir + os.path.sep +
                            'resources/logo.ico'))
            #self.setWindowFlags(self.windowFlags() & QtCore.Qt.WindowMinimizeButtonHint)
            self.setWindowModality(QtCore.Qt.ApplicationModal)
            #self.setFixedSize(600,350)

            self.planHeatDMM = planHeatDMM

            self.multiChange = []

            self.refreshToolButton.setIcon(
                planHeatDMM.resources.icon_refresh_icon)
            self.deleteToolButton.setIcon(planHeatDMM.resources.icon_del_icon)
            self.deleteAllToolButton.setIcon(
                planHeatDMM.resources.icon_trash_icon)
            self.multiMapToolButton.setIcon(
                planHeatDMM.resources.icon_multi_map_icon)

            self.refreshToolButton.clicked.connect(self.refreshRecordsTable)
            self.deleteToolButton.clicked.connect(self.deleteRecordTable)
            self.deleteAllToolButton.clicked.connect(
                self.deleteAllRecordsTable)
            self.multiMapToolButton.clicked.connect(self.multiMapDialog)
            self.protectionLevelMapTable.cellClicked.connect(self.clickCell)
            self.protectionLevelMapTable.pressed.connect(self.pressedCell)
            self.protectionLevelMapTable.verticalHeader(
            ).sectionClicked.connect(self.clickRow)
            self.protectionLevelMapTable.horizontalHeader(
            ).sectionClicked.connect(self.clickAllRows)

            self.protectionLevelMapTable.installEventFilter(self)

            self.setSystemDependantFontSize()
            self.setHeaders()

            self.addRecordsTable()

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "ProtectionLevelMapDialog - Constructor Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "ProtectionLevelMapDialog - Constructor Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            raise
    def multiMapDialog(self):
        try:
            modelIndex = self.protectionLevelMapTable.selectionModel(
            ).selectedRows()
            self.multiChange = [index.row() for index in modelIndex]

            levels = [
                str(level.protectionLevel)
                for level in self.planHeatDMM.data.protectionLevels
            ]
            dialog = MultiMapDialog(self.planHeatDMM, levels)

            dialog.show()
            dialogResult = dialog.exec_()

            if dialogResult == QtWidgets.QDialog.Accepted:
                for rowPosition in self.multiChange:
                    combo = self.protectionLevelMapTable.cellWidget(
                        rowPosition, 1)
                    combo.setCurrentText(
                        self.planHeatDMM.data.listSelectedValue)

            self.planHeatDMM.data.listSelectedValue = None

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "ProtectionLevelMapDialog - multiMapDialog Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "ProtectionLevelMapDialog - multiMapDialog Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #13
0
 def eventFilter(self, widget, event):
     """ Manage lost focus event on QTablewidget, avoiding deselect rows """
     try:
         if event.type() == QEvent.FocusOut:return True     
         return QtWidgets.QDialog.eventFilter(self, widget, event)    
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - eventFilter Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - eventFilter Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))      
Пример #14
0
    def addRecordsTable(self):
        """ Add Records to the Table Widget"""

        try:
            self.previousValueList = ["None"] * len(
                self.planHeatDMM.data.shp_map_csv_fields)
            for data in self.planHeatDMM.data.shp_map_csv_fields:
                if data.calculateModel in (
                        self.planHeatDMM.data.calculateMethod, "Both"):

                    self.combo = QtWidgets.QComboBox()

                    self.combo.addItem(str("None"))
                    for shapeField in self.planHeatDMM.data.originShapeFields:
                        self.combo.addItem(str(shapeField[0]))

                    if data.user_format_match == True:
                        self.combo.currentTextChanged.connect(
                            self.checkFieldDataFormat)

                    rowPosition = self.fieldUserMapTable.rowCount()
                    self.fieldUserMapTable.insertRow(rowPosition)

                    self.combo.setObjectName(str(rowPosition))
                    self.combo.currentTextChanged.connect(
                        self.checkHeightMandatoryField)

                    self.fieldUserMapTable.setItem(
                        rowPosition, 0, QTableWidgetItem(data.fieldName))
                    self.fieldUserMapTable.setCellWidget(
                        rowPosition, 1, self.combo)
                    self.fieldUserMapTable.setItem(
                        rowPosition, 2, QTableWidgetItem(data.fieldState))

                    l = [
                        x for x in self.planHeatDMM.data.shpDMMFieldsMap
                        if x.fieldName == data.fieldName
                        and x.user_definition_field.lower not in ("", "none")
                    ]
                    if l:
                        self.combo.setCurrentText(l[0].user_definition_field)
                        self.previousValueList[rowPosition] = l[
                            0].user_definition_field

                    if data.fieldState.lower() in ('mandatory'):
                        self.fieldUserMapTable.item(
                            rowPosition,
                            2).setForeground(QtGui.QColor(255, 0, 0))

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "FieldUserMapDialog - addRecordTable Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "FieldUserMapDialog - addRecordTable Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #15
0
    def multiMapDialog(self):
        """ Choose values to apply selected rows - Dialog"""
        try:

            modelIndex = self.retrofitScenarioTable.selectionModel(
            ).selectedRows()
            self.multiChange = [index.row() for index in modelIndex]

            dialog = RetroFitMultiMapDialog(self.planHeatDMM,
                                            self.refurbishmentLevelList)

            dialog.show()
            dialogResult = dialog.exec_()

            if dialogResult == QtWidgets.QDialog.Accepted:
                for rowPosition in self.multiChange:

                    item = self.retrofitScenarioTable.item(rowPosition, 0)
                    combo = self.retrofitScenarioTable.cellWidget(
                        rowPosition, 1)
                    roofSpinBox = self.retrofitScenarioTable.cellWidget(
                        rowPosition, 2)
                    wallSpinBox = self.retrofitScenarioTable.cellWidget(
                        rowPosition, 3)
                    windowSpinBox = self.retrofitScenarioTable.cellWidget(
                        rowPosition, 4)

                    period_text = item.text()

                    result = self.validateSelectedData(
                        period_text, self.planHeatDMM.data.listSelectedValue)

                    if result:
                        combo.setCurrentText(
                            self.planHeatDMM.data.listSelectedValue)
                        roofSpinBox.setValue(
                            self.planHeatDMM.data.roofSpinBoxSelectedValue)
                        wallSpinBox.setValue(
                            self.planHeatDMM.data.wallSpinBoxSelectedValue)
                        windowSpinBox.setValue(
                            self.planHeatDMM.data.windowSpinBoxSelectedValue)
                    else:
                        self.resetRow(rowPosition)

            self.planHeatDMM.data.listSelectedValue = None
            self.planHeatDMM.data.roofSpinBoxSelectedValue = None
            self.planHeatDMM.data.wallSpinBoxSelectedValue = None
            self.planHeatDMM.data.windowSpinBoxSelectedValue = None

        except:
            self.__log.write_log(
                "ERROR",
                "RetrofitScenarioWidget - multiMapDialog Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "RetrofitScenarioWidget - multiMapDialog Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #16
0
 def resizeEvent(self, event):
     try:
         #print(event.size().width())
         self.buildUseMapTable.setGeometry(55,20,event.size().width()-70,240)
         #self.buildUseMapTable.resizeColumnsToContents()
         return QtWidgets.QDialog.resizeEvent(self,event)
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - resizeEvent Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - resizeEvent Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))      
Пример #17
0
 def clickAllRows(self):
     try:
         
         self.buildUseMapTable.selectAll()
         self.selectedRows()
             
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - clickAllRows Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - clickAllRows Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #18
0
    def checkFieldDataFormat(self, text):
        """ Control of the data format between the field defined by the end user and the needs for the application process """

        try:
            DMM_definition_field = None
            shapeField = None
            cell = None
            previousValue = "None"

            if text.lower() not in ('none'):
                dataList = [
                    shapeField
                    for shapeField in self.planHeatDMM.data.originShapeFields
                    if str(shapeField[0]) == text
                ]
                if dataList: shapeField = dataList[0]

                #Select row table position for type control field
                rowPosition = int(self.sender().objectName())
                item = self.fieldUserMapTable.item(rowPosition, 0)
                DMM_definition_field_text = "" if item is None else item.text()
                cell = self.fieldUserMapTable.cellWidget(rowPosition, 1)
                previousValue = self.previousValueList[rowPosition]
                dataList = [
                    data for data in self.planHeatDMM.data.shp_map_csv_fields
                    if data.fieldName == DMM_definition_field_text
                ]
                if dataList: DMM_definition_field = dataList[0]

                if DMM_definition_field and shapeField:
                    if DMM_definition_field.format == 'F':
                        DMM_definition_field.format = 'N'
                    if shapeField[1] == 'F': shapeField[1] = 'N'
                    if DMM_definition_field.format != shapeField[1]:
                        showErrordialog(
                            self.planHeatDMM.dlg,
                            "FieldUserMapDialog - checkFieldDataFormat:",
                            "Cadaster Column type:{} is not compatible with PlanHeat definition format required for application:{}"
                            .format(
                                self.shapeFormat[shapeField[1]],
                                self.shapeFormat[DMM_definition_field.format]))
                        cell.setCurrentText(previousValue)
                    else:
                        self.previousValueList[rowPosition] = text
                else:
                    self.previousValueList[rowPosition] = text

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "FieldUserMapDialog - checkFieldDataFormat Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "FieldUserMapDialog - checkFieldDataFormat Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #19
0
    def statusBar(self):
        try:
            self.statusMessageLabel.setEnabled(True)
            self.statusProcessButton.setVisible(False)
            self.statusProgressBar.setVisible(False)

        except:
            showErrordialog(
                self.planHeatDMM.dlg, "statusBar",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
    def addRecordsTable(self):
        """ Add Records to the Table Widget"""
        try:

            for user_protection in self.planHeatDMM.data.inputSHPFieldProtectionDegreeValues:

                model = QtGui.QStandardItemModel()

                for data in self.planHeatDMM.data.protectionLevels:
                    protection_level = QtGui.QStandardItem(
                        str(data.protectionLevel))
                    description = QtGui.QStandardItem(data.description)
                    model.appendRow([protection_level, description])

                view = QtWidgets.QTreeView()
                view.setMouseTracking(False)
                view.header().hide()
                view.setRootIsDecorated(False)

                self.comboProtectionLevel = QtWidgets.QComboBox()
                self.comboProtectionLevel.setMouseTracking(False)
                self.comboProtectionLevel.setView(view)
                self.comboProtectionLevel.setModel(model)

                #self.comboProtectionLevel = QtWidgets.QComboBox()
                #for data in self.planHeatDMM.data.protectionLevels:
                #    self.comboProtectionLevel.addItem(str(data.protectionLevel))

                rowPosition = self.protectionLevelMapTable.rowCount()
                self.protectionLevelMapTable.insertRow(rowPosition)

                if self.planHeatDMM.data.protectionLevelMap:
                    l = [
                        x for x in self.planHeatDMM.data.protectionLevelMap
                        if x.user_definition_protection == user_protection
                        and x.DMM_protection_level not in ("", "Not evaluate")
                    ]
                    if l:
                        self.comboProtectionLevel.setCurrentText(
                            str(l[0].DMM_protection_level))

                self.protectionLevelMapTable.setItem(
                    rowPosition, 0, QTableWidgetItem(user_protection))
                self.protectionLevelMapTable.setCellWidget(
                    rowPosition, 1, self.comboProtectionLevel)

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "ProtectionLevelMapDialog - addRecordsTable Unexpected error:"
                + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "ProtectionLevelMapDialog - addRecordsTable Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #21
0
    def __init__(self, planHeatDMM):
        """ Dialog Constructor"""

        super(CompleteRetrofitScenarioDialog, self).__init__(None)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.setupUi(self)

        try:

            self.setWindowIcon(
                QtGui.QIcon(planHeatDMM.plugin_dir + os.path.sep +
                            'resources/logo.ico'))
            #self.setWindowFlags(self.windowFlags() & QtCore.Qt.WindowMinimizeButtonHint)
            self.setWindowModality(QtCore.Qt.ApplicationModal)
            self.setFixedSize(650, 425)

            self.planHeatDMM = planHeatDMM

            self.layout = QtWidgets.QVBoxLayout()
            self.setLayout(self.layout)

            self.centralLayout = QtWidgets.QVBoxLayout()

            refurbishmentTempTabDataList = deepcopy(
                self.planHeatDMM.data.refurbishmentTabDataList)
            self.checkableTabWidget = CheckableTabWidget(
                self.planHeatDMM, refurbishmentTempTabDataList, self)
            self.centralLayout.addWidget(self.checkableTabWidget)
            self.layout.addLayout(self.centralLayout)
            self.layout.addWidget(self.buttonBox)

            self.layout.addWidget(self.checkableTabWidget)

            year = int(datetime.datetime.now().strftime('%Y'))

            if self.planHeatDMM.data.futureScenarioYear > 0:
                year = self.planHeatDMM.data.futureScenarioYear

            self.futureScenarioYearSpinBox.setValue(year)

            self.setSystemDependantFontSize()

        except:
            self.planHeatDMM.resources.log.write_log(
                "ERROR",
                "CompleteRetrofitScenarioDialog - Constructor Unexpected error:"
                + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "CompleteRetrofitScenarioDialog - Constructor Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
 def clickRow(self, rowNum):
     try:
         self.selectedRows()
     except:
         self.planHeatDMM.resources.log.write_log(
             "ERROR", "UserFieldShapeDialog - clickRow Unexpected error:" +
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(
             self.planHeatDMM.dlg,
             "UserFieldShapeDialog - clickRow Unexpected error:",
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #23
0
    def addRecordsTable(self):
        try:

            for period in self.planHeatDMM.data.periods:
                combo = QComboBoxRetrofitWidget(self)
                options = [
                    refurbishmentLevelPeriod.refurbishment_level
                    for refurbishmentLevelPeriod in self.planHeatDMM.data.
                    refurbishment_level_periods[period.id]
                ]
                combo.addItems(options)

                spinRoof = QSpinBoxRetrofitWidget(self.planHeatDMM)
                spinWall = QSpinBoxRetrofitWidget(self.planHeatDMM)
                spinWindow = QSpinBoxRetrofitWidget(self.planHeatDMM)

                spinRoof.setObjectName("spinRoof")
                spinWall.setObjectName("spinWall")
                spinWindow.setObjectName("spinWindow")

                spinRoof.installEventFilter(self)
                spinWall.installEventFilter(self)
                spinWindow.installEventFilter(self)

                if self.tabData.rows:
                    for data in self.tabData.rows:
                        if data.row_period_text == period.period_text:
                            combo.setCurrentText(data.row_refurbishment_level)
                            spinRoof.setValue(data.row_roof_percentage)
                            spinWall.setValue(data.row_wall_percentage)
                            spinWindow.setValue(data.row_window_percentage)
                            break

                rowPosition = self.retrofitScenarioTable.rowCount()
                self.retrofitScenarioTable.insertRow(rowPosition)
                self.retrofitScenarioTable.setItem(
                    rowPosition, 0, QTableWidgetItem(period.period_text))
                self.retrofitScenarioTable.setCellWidget(rowPosition, 1, combo)
                self.retrofitScenarioTable.setCellWidget(
                    rowPosition, 2, spinRoof)
                self.retrofitScenarioTable.setCellWidget(
                    rowPosition, 3, spinWall)
                self.retrofitScenarioTable.setCellWidget(
                    rowPosition, 4, spinWindow)

        except:
            self.__log.write_log(
                "ERROR",
                "RetrofitScenarioWidget - addRecordsTable Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg,
                "RetrofitScenarioWidget - addRecordsTable Unexpected error:",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #24
0
    def keyPressEvent(self, event):
        try:
            if event.key() == QtCore.Qt.Key_Return:
                return None
            else:
                event.accept()

        except:
            showErrordialog(
                self.planHeatDMM.dlg,
                "PlanHeatDMM_dialog_base - keyPressEvent",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
 def pressedCell(self):
     try:
         self.selectedRows()
     except:
         self.planHeatDMM.resources.log.write_log(
             "ERROR",
             "ProtectionLevelMapDialog - pressedCell Unexpected error:" +
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(
             self.planHeatDMM.dlg,
             "ProtectionLevelMapDialog - pressedCell Unexpected error:",
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #26
0
 def selectedRows(self):
     try:
         modelIndex = self.buildUseMapTable.selectionModel().selectedRows()
         if modelIndex:
             self.multiMapToolButton.setEnabled(True)
             
         else:
             self.multiMapToolButton.setEnabled(False)    
             self.multiChange = []    
             
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - selectedRows Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - selectedRows Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))        
Пример #27
0
 def pressedCell(self):
     """ Mouse left button pressed for select rows  """
     try:
         self.selectedRows()
     except:
         self.planHeatDMM.resources.log.write_log(
             "ERROR",
             "RetrofitScenarioWidget - pressedCell Unexpected error:" +
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(
             self.planHeatDMM.dlg,
             "RetrofitScenarioWidget - pressedCell Unexpected error:",
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #28
0
 def refreshRecordsTable(self):
     """ Refresh all records from the last saving operation , or initial state """
     
     try:
             message = "Discard, not saved changes, are you sure?"
             if showQuestiondialog(self,"Discard Changes",message) == QtWidgets.QMessageBox.Yes:
                 #self.deleteAllRecordsTable(showMessageDialog=False)
                 while (self.buildUseMapTable.rowCount() > 0):
                     self.buildUseMapTable.removeRow(0)
                 self.addRecordsTable()
     except:
         self.planHeatDMM.resources.log.write_log("ERROR","BuildingUseMapDialog - refreshRecordsTable Unexpected error:" + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(self.planHeatDMM.dlg,"BuildingUseMapDialog - refreshRecordsTable Unexpected error:",str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #29
0
 def clickRow(self, rowNum):
     """ Click row from table - Slot """
     try:
         self.selectedRows()
     except:
         self.__log.write_log(
             "ERROR",
             "RetrofitScenarioWidget - clickRow Unexpected error:" +
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
         showErrordialog(
             self.planHeatDMM.dlg,
             "RetrofitScenarioWidget - clickRow Unexpected error:",
             str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
Пример #30
0
    def addTab(self, position, icon_file, title):
        try:

            tabData = None

            checkBox = QtWidgets.QCheckBox()
            checkBox.setChecked(True)
            checkBox.stateChanged.connect(
                lambda: self.__emitStateChanged(checkBox))
            self.checkBoxList.append(checkBox)

            if title not in self.tabDataNames:
                tabData = RefurbishmentTabData(position, title, True)
                self.refurbishmentTempTabDataList.append(tabData)
            else:
                for data in self.refurbishmentTempTabDataList:
                    if data.tab_name == title:
                        tabData = data
                        checkBox.setChecked(data.tab_check)
                        break

            page = RetrofitScenarioWidget(title, self.planHeatDMM, tabData,
                                          self)

            if icon_file:
                try:
                    icon = QtGui.QIcon(self.planHeatDMM.resources.plugin_dir +
                                       os.path.sep + "resources" +
                                       os.path.sep + icon_file)
                    QtWidgets.QTabWidget.addTab(self, page, icon, title)
                except:
                    QtWidgets.QTabWidget.addTab(self, page, title)

            else:
                QtWidgets.QTabWidget.addTab(self, page, title)

            self.tabBar().setTabButton(self.tabBar().count() - 1,
                                       QtWidgets.QTabBar.RightSide, checkBox)

            #self.connect(checkBox, QtCore.SIGNAL('stateChanged(int)'), lambda checkState: self.__emitStateChanged(checkBox, checkState))
        except:
            self.__log.write_log(
                "ERROR", "CheckableTabWidget addTab Unexpected error:" +
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            showErrordialog(
                self.planHeatDMM.dlg, "CheckableTabWidget addTab",
                str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
            self.planHeatDMM.dlg.statusMessageLabel.setText(
                "Error: " + str(sys.exc_info()[0]) + " " +
                str(sys.exc_info()[1]))