Exemplo n.º 1
0
 def bouwlagen_to_combobox(self, objectId, actieveBouwlaag):
     """fill combobox with existing floors"""
     runLayer = PC.PAND["bouwlaaglayername"]
     tempLayer = UC.getlayer_byname(runLayer)
     objectId = self.pand_id.text()
     foreignKey = CH.get_foreign_key_bl(runLayer)
     tempLayer.setSubsetString('')
     #request all existing floors of object feature
     request = QC.QgsFeatureRequest().setFilterExpression(foreignKey + " = '" + str(objectId) + "'")
     tempFeatureIt = tempLayer.getFeatures(request)
     #create unique list of existing floors and sort it from small to big
     bouwlaagList = [it["bouwlaag"] for it in tempFeatureIt]
     self.sortedList = UC.create_unique_sorted_list(bouwlaagList)
     #block signal of combobox to add existing floors
     self.comboBox.blockSignals(True)
     self.comboBox.clear()
     for bouwlaag in reversed(self.sortedList):
         self.comboBox.addItem(str(bouwlaag))
     #if there are existing floors "tekenen" can be enabled
     if self.sortedList:
         self.tekenen.setEnabled(True)
         if actieveBouwlaag is None:
             actieveBouwlaag = min(reversed(self.sortedList), key=abs)
     else:
         self.tekenen.setEnabled(False)
         actieveBouwlaag = 1
     self.comboBox.blockSignals(False)
     #set substring of childlayers
     subString = "bouwlaag = " + str(actieveBouwlaag)
     UG.set_layer_substring(subString)
     index = self.comboBox.findText(str(actieveBouwlaag), PQtC.Qt.MatchFixedString)
     if index >= 0:
         self.comboBox.setCurrentIndex(index)
     self.iface.actionPan().trigger()
Exemplo n.º 2
0
 def import_bouwlaag(self, bouwlaagFeature):
     """after the checks the import of the floor can start"""
     childFeature = QC.QgsFeature()
     layerName = 'Bouwlagen'
     layer = UC.getlayer_byname(layerName)
     #get necessary attributes from config file
     foreignKey = CH.get_foreign_key_bl(layerName)
     #construct QgsFeature to save
     childFeature.setGeometry(bouwlaagFeature.geometry())
     fields = layer.fields()
     childFeature.initAttributes(fields.count())
     childFeature.setFields(fields)
     childFeature[foreignKey] = str(self.object_id.text())
     childFeature["bouwlaag"] = int(self.bouwlaag.text())
     newFeatureId = UC.write_layer(layer, childFeature)
     self.bouwlaag_id.setText(str(newFeatureId))
     self.iface.actionPan().trigger()
     self.label2.setVisible(False)
     self.selectId.setVisible(False)
     self.label3.setVisible(True)
     self.label4.setVisible(True)
     self.label5a.setVisible(True)
     self.label5b.setVisible(True)
     self.import_laag.setVisible(True)
     self.check.setVisible(True)
     self.type.setVisible(True)
Exemplo n.º 3
0
 def draw_feature(self, points, _dummy):
     """create the floor feature and save to the floors layer"""
     minBouwlaag = int(self.bouwlaag_min.text())
     maxBouwlaag = int(self.bouwlaag_max.text())
     childFeature = QC.QgsFeature()
     layerName = PC.PAND["bouwlaaglayername"]
     layer = UC.getlayer_byname(layerName)
     foreignKey = CH.get_foreign_key_bl(layerName)
     #construct QgsFeature to save
     for i in range(minBouwlaag, maxBouwlaag + 1):
         if i != 0:
             childFeature.setGeometry(QC.QgsGeometry.fromPolygonXY([points
                                                                    ]))
             fields = layer.fields()
             childFeature.initAttributes(fields.count())
             childFeature.setFields(fields)
             childFeature[foreignKey] = self.objectId
             childFeature["bouwlaag"] = i
             UC.write_layer(layer, childFeature)
             #block the signals of changing the comboBox to add the new floor
             self.bouwlaag.blockSignals(True)
             self.bouwlaag.clear()
             if i not in self.bouwlaagList:
                 self.bouwlaagList.append(i)
     self.bouwlaagList.sort()
     self.bouwlagen_to_combobox()
     self.bouwlaag.blockSignals(False)
     self.iface.actionPan().trigger()
     #set all layers substring to the right floor
     sub_string = "bouwlaag = " + str(minBouwlaag)
     UG.set_layer_substring(sub_string)
     if maxBouwlaag != minBouwlaag:
         MSG.showMsgBox('bouwlaagcreated')
Exemplo n.º 4
0
 def run_bouwlaag_bewerken(self):
     runLayer = PC.PAND["bouwlaaglayername"]
     ilayer = UC.getlayer_byname(runLayer)
     objectId = self.pand_id.text()
     foreignKey = CH.get_foreign_key_bl(runLayer)
     request = QC.QgsFeatureRequest().setFilterExpression(foreignKey + " = '" + str(objectId) + "'")
     ifeature = next(ilayer.getFeatures(request))
     self.run_edit_bouwlagen(ilayer, ifeature)
Exemplo n.º 5
0
 def copy_bag_bouwlaag(self, ilayer, ifeature):
     """copy the floor drom the BAG features"""
     if ilayer.name() == PC.PAND["bouwlaaglayername"] or ilayer.name(
     ) == PC.PAND["bagpandlayername"]:
         childFeature = QC.QgsFeature()
         layerName = PC.PAND["bouwlaaglayername"]
         #get active floor from dockwidget
         minBouwlaag = int(self.bouwlaag_min.text())
         maxBouwlaag = int(self.bouwlaag_max.text())
         layer = UC.getlayer_byname(layerName)
         #get necessary attributes from config file
         foreignKey = CH.get_foreign_key_bl(layerName)
         #construct QgsFeature to save
         for i in range(minBouwlaag, maxBouwlaag + 1):
             if i != 0:
                 childFeature.setGeometry(ifeature.geometry())
                 fields = layer.fields()
                 childFeature.initAttributes(fields.count())
                 childFeature.setFields(fields)
                 childFeature[foreignKey] = self.objectId
                 childFeature["bouwlaag"] = i
                 newFeatureId = UC.write_layer(layer, childFeature)
                 #copy also the selected layers
                 if ilayer.name() == PC.PAND["bouwlaaglayername"]:
                     self.copy_selected_layers(ifeature, newFeatureId, i)
                 #block the signals of changing the comboBox to add the new floor
                 self.bouwlaag.blockSignals(True)
                 self.bouwlaag.clear()
                 if i not in self.bouwlaagList:
                     self.bouwlaagList.append(i)
         self.bouwlaagList.sort()
         self.bouwlagen_to_combobox()
         self.bouwlaag.blockSignals(False)
         self.iface.actionPan().trigger()
         #set all layers substring to the right floor
         sub_string = "bouwlaag = " + str(minBouwlaag)
         UG.set_layer_substring(sub_string)
         try:
             self.parent.selectTool.geomSelected.disconnect()
         except:  # pylint: disable=bare-except
             pass
         if maxBouwlaag >= minBouwlaag:
             MSG.showMsgBox('bouwlaagcreated')
     else:
         MSG.showMsgBox('nobouwlaagselected')
         try:
             self.parent.selectTool.geomSelected.disconnect()
         except:  # pylint: disable=bare-except
             pass
         self.parent.selectTool.geomSelected.connect(self.copy_bag_bouwlaag)