def __init__(self, parent, edit_these, new_item, title, **kwargs):
        QtGui.QMainWindow.__init__(self, parent)
        self.helper = HelpHandler(self)
        option_section = parent.project.find_section('OPTIONS')
        if option_section.infiltration=="HORTON" or option_section.infiltration=="MODIFIED_HORTON":
            self.help_topic = "swmm/src/src/hortoninfiltrationparameters.htm"
        elif option_section.infiltration=="GREEN_AMPT" or option_section.infiltration=="MODIFIED_GREEN_AMPT":
            self.help_topic = "swmm/src/src/green_amptinfiltrationparame.htm"
        elif option_section.infiltration=="CURVE_NUMBER":
            self.help_topic = "swmm/src/src/curvenumberinfiltrationpara.htm"
        self.setupUi(self)
        self.setWindowTitle(title)
        QtCore.QObject.connect(self.cmdOK, QtCore.SIGNAL("clicked()"), self.cmdOK_Clicked)
        QtCore.QObject.connect(self.cmdCancel, QtCore.SIGNAL("clicked()"), self.cmdCancel_Clicked)
        QtCore.QObject.connect(self.cboInfilModel, QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.cboInfilModel_currentIndexChanged)

        self.defaults = None
        if kwargs.has_key("defaults"):
            self.defaults = kwargs["defaults"]
        enum_val = E_InfilModel.HORTON
        if self.defaults is not None:
            enum_val = E_InfilModel[self.defaults.properties_sub_values[self.defaults.infil_model_key]]
            # self.infil_model = self.qsettings.value(self.default_key, None)
            # if self.infil_model is None:
            #     self.infil_model = HortonInfiltration()
            #     self.infil_model.set_defaults()
            # else:
            #     enum_val = self.infil_model.model_type()
            #     if enum_val == E_InfilModel.HORTON or \
            #        enum_val == E_InfilModel.MODIFIED_HORTON:
            #         self.infil_model_horton.__dict__.update(self.infil_model.__dict__)
            #     elif enum_val == E_InfilModel.GREEN_AMPT or \
            #          enum_val == E_InfilModel.MODIFIED_GREEN_AMPT:
            #         self.infil_model_ga.__dict__.update(self.infil_model.__dict__)
            #     elif enum_val == E_InfilModel.CURVE_NUMBER:
            #         self.infil_model_cn.__dict__.update(self.infil_model.__dict__)

            self.cboInfilModel.setEnabled(True)
            if self.lblNotes:
                self.tblGeneric.currentCellChanged.connect(self.table_currentCellChanged)
            self.tblGeneric.itemChanged.connect(self.table_itemChanged)
            pass
        else:
            self.backend = PropertyEditorBackend(self.tblGeneric, self.lblNotes, parent, edit_these, new_item)
            #self.lblTop.setText("Infiltration Method:  " + parent.project.find_section('OPTIONS').infiltration)
            proj_infilmodel = parent.project.find_section('OPTIONS').infiltration
            enum_val = E_InfilModel[proj_infilmodel.upper()]
            self.cboInfilModel.setEnabled(False)

        set_combo_items(type(enum_val), self.cboInfilModel)
        set_combo(self.cboInfilModel, enum_val)

        self.corner_label = QtGui.QLabel("Property", self.tblGeneric)
        self.corner_label.setAlignment(QtCore.Qt.AlignCenter)
        self.corner_label.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
        QtCore.QObject.connect(self.tblGeneric.verticalHeader(),
                               QtCore.SIGNAL("geometriesChanged()"), self.resizeCorner)
        QtCore.QObject.connect(self.tblGeneric.horizontalHeader(),
                               QtCore.SIGNAL("geometriesChanged()"), self.resizeCorner)
Esempio n. 2
0
    def set_tab_hydraulics(self):
        """
        setup the hydraulic parameter defaults tab entries
        Returns:
        """
        properties = [
            "Node Invert", "Node Max. Depth", "Node Ponded Area",
            "Conduit Length", "Conduit Geometry", "Conduit Roughness",
            "Flow Units", "Link Offsets", "Routing Method",
            "Force Main Equation"
        ]
        #self.parameters_def_values = [0, 0, 0, 400, "CIRCULAR", 0.01, "CFS", "DEPTH", "KINWAVE", "H_W"]
        self.tbl_3.setColumnCount(1)
        self.tbl_3.setRowCount(len(self.defaults.parameters_keys))
        self.tbl_3.setHorizontalHeaderLabels(["Default Value"])
        self.tbl_3.setVerticalHeaderLabels(properties)
        for i in range(0, len(self.defaults.parameters_keys)):
            combobox = None
            key = self.defaults.parameters_keys[i]
            def_val = self.defaults.parameters_values[key]
            if "flow_units" in key.lower():
                combobox = QComboBox()
                enum_val = FlowUnits[def_val]
            elif "link_offsets" in key.lower():
                combobox = QComboBox()
                enum_val = LinkOffsets[def_val]
            elif "routing_model" in key.lower():
                combobox = QComboBox()
                enum_val = FlowRouting[def_val.upper()]
            elif "force_main" in key.lower():
                combobox = QComboBox()
                if def_val.upper() == "H-W":
                    enum_val = ForceMainEquation['H_W']
                if def_val.upper() == "D-W":
                    enum_val = ForceMainEquation['D_W']

            if combobox is not None:
                combobox.setObjectName(key + "|" + str(i) + "|0")
                set_combo_items(type(enum_val), combobox)
                set_combo(combobox, enum_val)
                combobox.currentIndexChanged.connect(self.sm_hydraulics.map)
                self.sm_hydraulics.setMapping(combobox, i)
                self.tbl_3.setCellWidget(i, 0, combobox)
            else:
                if "conduit_shape" in key.lower():
                    self.set_channel_cell(0)
                else:
                    self.tbl_3.setItem(i, 0, QTableWidgetItem(str(def_val)))
        pass
Esempio n. 3
0
    def set_tab_hydraulics(self):
        """
        setup the hydraulic parameter defaults tab entries
        Returns:
        """
        #self.parameters = ["Flow Units", "Headloss Formula", "Specific Gravity", "Relative Viscosity",
        #                   "Maximum Trials", "Accuracy", "If Unbalanced", "Default Pattern", "Demand Multiplier",
        #                   "Emitter Exponent", "Status Report", "Check Frequency", "Max Check", "Damp Limit"]
        #self.parameters_def_values = ["GPM", "H_W", 1.0, 1.0, 40, 0.001, "Continue", 1, 1.0, 0.5, "Yes",
        #                              "", "", ""]
        self.tbl_3.setColumnCount(1)
        self.tbl_3.setRowCount(len(self.defaults.parameters_keys))
        self.tbl_3.setHorizontalHeaderLabels(["Default Value"])
        self.tbl_3.setVerticalHeaderLabels(self.defaults.parameters_keys)
        for i in range(0, len(self.defaults.parameters_keys) - 1):
            combobox = None
            #def_val = self.parameters_def_values[self.parameters.index(self.parameters[i])]
            def_val = self.defaults.parameters_values[
                self.defaults.parameters_keys[i]]
            #if self.qsettings:
            #    def_val = unicode(self.qsettings.value("Defaults/" + self.parameters[i], def_val))
            key = self.defaults.parameters_keys[i].lower()
            if "flow units" in key:
                combobox = QtGui.QComboBox()
                enum_val = FlowUnits[def_val]
            elif "headloss" in key:
                combobox = QtGui.QComboBox()
                enum_val = HeadLoss[def_val.replace("-", "_")]
            elif "unbalanced" in key:
                combobox = QtGui.QComboBox()
                enum_val = Unbalanced[def_val.upper()]
            elif "status report" in key:
                combobox = QtGui.QComboBox()
                enum_val = StatusWrite[def_val.upper()]

            if combobox is not None:
                combobox.setObjectName(key + "|" + str(i) + "|0")
                set_combo_items(type(enum_val), combobox)
                set_combo(combobox, enum_val)
                QtCore.QObject.connect(
                    combobox, QtCore.SIGNAL("currentIndexChanged(int)"),
                    self.sm_hydraulics, QtCore.SLOT("map()"))
                self.sm_hydraulics.setMapping(combobox, i)
                self.tbl_3.setCellWidget(i, 0, combobox)
            else:
                self.tbl_3.setItem(i, 0,
                                   QtGui.QTableWidgetItem(unicode(def_val)))
        pass
Esempio n. 4
0
    def set_tab_hydraulics(self):
        """
        setup the hydraulic parameter defaults tab entries
        Returns:
        """
        #self.parameters = ["Node Invert", "Node Max. Depth", "Node Ponded Area", "Conduit Length", "Conduit Geometry",
        #                   "Conduit Roughness", "Flow Units", "Link Offsets", "Routing Method", "Force Main Equation"]
        #self.parameters_def_values = [0, 0, 0, 400, "CIRCULAR", 0.01, "CFS", "DEPTH", "KINWAVE", "H_W"]
        self.tbl_3.setColumnCount(1)
        self.tbl_3.setRowCount(len(self.defaults.parameters_keys))
        self.tbl_3.setHorizontalHeaderLabels(["Default Value"])
        self.tbl_3.setVerticalHeaderLabels(self.defaults.parameters_keys)
        for i in range(0, len(self.defaults.parameters_keys)):
            combobox = None
            key = self.defaults.parameters_keys[i]
            def_val = self.defaults.parameters_values[key]
            if "flow units" in key.lower():
                combobox = QtGui.QComboBox()
                enum_val = FlowUnits[def_val]
            elif "link offsets" in key.lower():
                combobox = QtGui.QComboBox()
                enum_val = LinkOffsets[def_val]
            elif "routing method" in key.lower():
                combobox = QtGui.QComboBox()
                enum_val = FlowRouting[def_val.upper()]
            elif "force main" in key.lower():
                combobox = QtGui.QComboBox()
                enum_val = ForceMainEquation[def_val.upper()]

            if combobox is not None:
                combobox.setObjectName(key + "|" + str(i) + "|0")
                set_combo_items(type(enum_val), combobox)
                set_combo(combobox, enum_val)
                QtCore.QObject.connect(
                    combobox, QtCore.SIGNAL("currentIndexChanged(int)"),
                    self.sm_hydraulics, QtCore.SLOT("map()"))
                self.sm_hydraulics.setMapping(combobox, i)
                self.tbl_3.setCellWidget(i, 0, combobox)
            else:
                if "conduit geometry" in key.lower():
                    self.set_channel_cell(0)
                else:
                    self.tbl_3.setItem(
                        i, 0, QtGui.QTableWidgetItem(unicode(def_val)))
        pass
Esempio n. 5
0
 def set_tab_properties(self):
     """
     setup object property defaults tab entries
     Returns:
     """
     #self.properties = {"Node Elevation" : 0, "Tank Diameter" : 50, "Tank Height" : 20, "Pipe Length" : 1000,
     #                   "Pipe Diameter" : 12, "Pipe Roughness" : 100, "Auto Length" : "Off"}
     #self.properties = ["Node Elevation", "Tank Diameter", "Tank Height", "Pipe Length",
     #                   "Pipe Diameter", "Pipe Roughness", "Auto Length"]
     #self.properties_def_values = [0, 50, 20, 1000, 12, 100, "Off"]
     self.tbl_2.setColumnCount(1)
     self.tbl_2.setRowCount(len(self.defaults.properties_keys))
     self.tbl_2.setHorizontalHeaderLabels(["Default Value"])
     self.tbl_2.setVerticalHeaderLabels(self.defaults.properties_keys)
     for i in range(0, len(self.defaults.properties_keys)):
         def_val = self.defaults.properties_values[
             self.defaults.properties_keys[i]]
         #if self.qsettings:
         #    def_val = unicode(self.qsettings.value("Defaults/" + self.properties[i], def_val))
         key = self.defaults.properties_keys[i].lower()
         if "auto" in key:
             self.autolen_on = "Off"
             if def_val is not None:
                 self.autolen_on = def_val
             #if self.qsettings:
             #    self.autolen_on = unicode(
             #        self.qsettings.value("Defaults/" + self.properties[len(self.properties) - 1], "Off"))
             #self.tbl_2.setItem(self.tbl_2.rowCount() - 1, 0, QtGui.QTableWidgetItem(self.autolen_on))
             combobox = QtGui.QComboBox()
             combobox.addItem("On")
             combobox.addItem("Off")
             set_combo(combobox, self.autolen_on)
             combobox.setObjectName(key + "|" + str(i) + "|0")
             QtCore.QObject.connect(
                 combobox, QtCore.SIGNAL("currentIndexChanged(int)"),
                 self.sm_property, QtCore.SLOT("map()"))
             self.sm_property.setMapping(combobox, i)
             self.tbl_2.setCellWidget(i, 0, combobox)
         else:
             self.tbl_2.setItem(i, 0,
                                QtGui.QTableWidgetItem(unicode(def_val)))
     pass