Artelia / Mesh_tools

GNU General Public License v3.0
7 stars 4 forks source link

[Culvert] Improve validity tests #31

Open nicogodet opened 2 years ago

nicogodet commented 2 years ago

Some values can not be equal to 0, some can not be negative, etc...

Some times ago, I initiate a work on this by rewriting completely self.culv_flds

self.culv_flds= {
            # Variable, Type, Connexion SpinBox, Position V6, Position V7, Position V8 (-1 : la variable n'existe pas pour la version donnée)
            "!Nom": {
                "fieldType": QVariant.String,
                "widget": self.lineEdit_culName,
                "attrIDV6": 0,
                "attrIDV7": 0,
                "attrIDV8": 0,
                "len": 250,
                "prec": 0,
                "conditions": [],
            },
            self.N1: {
                "fieldType": QVariant.Int,
                "widget": self.spinBox_culN1,
                "attrIDV6": 1,
                "attrIDV7": 1,
                "attrIDV8": 1,
                "len": 10,
                "prec": 0,
                "conditions": ["{v} != NULL"],
            },
            self.N2: {
                "fieldType": QVariant.Int,
                "widget": self.spinBox_culN2,
                "attrIDV6": 2,
                "attrIDV7": 2,
                "attrIDV8": 2,
                "len": 10,
                "prec": 0,
                "conditions": ["{v} != NULL"],
            },
            "CE1": {
                "fieldType": QVariant.Double,
                "widget": self.doubleSpinBox_culCE1,
                "attrIDV6": 3,
                "attrIDV7": 3,
                "attrIDV8": 3,
                "len": 4,
                "prec": 2,
                "conditions": ["{v} != NULL", "{v} > 0"],
            },
            "CE2": {
                "fieldType": QVariant.Double,
                "widget": self.doubleSpinBox_culCE2,
                "attrIDV6": 4,
                "attrIDV7": 4,
                "attrIDV8": 4,
                "len": 4,
                "prec": 2,
                "conditions": ["{v} != NULL", "{v} > 0"],
            },
            "CS1": {
                "fieldType": QVariant.Double,
                "widget": self.doubleSpinBox_culCS1,
                "attrIDV6": 5,
                "attrIDV7": 5,
                "attrIDV8": 5,
                "len": 4,
                "prec": 2,
                "conditions": ["{v} != NULL", "{v} > 0"],
            },
            "CS2": {
                "fieldType": QVariant.Double,
                "widget": self.doubleSpinBox_culCS2,
                "attrIDV6": 6,
                "attrIDV7": 6,
                "attrIDV8": 6,
                "len": 4,
                "prec": 2,
                "conditions": ["{v} != NULL", "{v} > 0"],
            },
            "LARG": {
                "fieldType": QVariant.Double,
                "widget": self.doubleSpinBox_culL,
                "attrIDV6": 7,
                "attrIDV7": 7,
                "attrIDV8": 7,
                "len": 10,
                "prec": 2,
                "conditions": ["{v} != NULL", "{v} > 0"],
            },
            "HAUT": {
                "fieldType": QVariant.Double,
                "widget": self.doubleSpinBox_culH,
                "attrIDV6": 8,
                "attrIDV7": 8,
                "attrIDV8": 8,
                "len": 10,
                "prec": 2,
                "conditions": ["{v} != NULL", "{v} > 0"],
            },
...

"conditions" contains all conditions that should be verified to have a valid culvert.

Even if some values are not possible du to widget min/max value limits, it worth checking again. Especially if we import an existing culvert file.