Beispiel #1
0
 def set_layer_subset_toolbar(self):
     """laag filter aanpassen naar de geselecteerd bouwlaag"""
     subString = "bouwlaag = " + str(self.projCombo.currentText())
     UG.set_layer_substring(subString)
     project = QC.QgsProject.instance()
     QC.QgsExpressionContextUtils.setProjectVariable(
         project, 'actieve_bouwlaag', int(self.projCombo.currentText()))
 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()
 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')
 def run_tekenen(self):
     """init teken widget"""
     tekenwidget = oivTekenWidget(self)
     subString = "bouwlaag = " + str(self.comboBox.currentText())
     UG.set_layer_substring(subString)
     self.iface.addDockWidget(PQtC.Qt.RightDockWidgetArea, tekenwidget)
     self.close()
     tekenwidget.show()
 def close_object_show_base(self):
     subString = "bouwlaag = 1"
     UG.set_layer_substring(subString)
     for widget in self.children():
         if isinstance(widget, PQtW.QPushButton):
             try:
                 widget.clicked.disconnect()
             except: # pylint: disable=bare-except
                 pass
     self.close()
     self.basewidget.show()
     self.iface.actionPan().trigger()
     del self
 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)
 def run_bouwlaag(self):
     while True:
         bouwlaag, bouwlaagMax, ok = BouwlaagDialog.getBouwlagen()
         if (bouwlaag != 0 and bouwlaagMax >= bouwlaag and ok is True):
             self.close()
             bouwlaagwidget = oivBouwlaagWidget(self)
             self.iface.addDockWidget(QH.getWidgetType(), bouwlaagwidget)
             bouwlaagwidget.canvas = self.canvas
             bouwlaagwidget.iface = self.iface
             bouwlaagwidget.bouwlaagList = self.sortedList
             bouwlaagwidget.teken_bouwlaag.setText(str(bouwlaag) + ' t/m ' + str(bouwlaagMax))
             bouwlaagwidget.bouwlaag_min.setText(str(bouwlaag))
             bouwlaagwidget.bouwlaag_max.setText(str(bouwlaagMax))
             bouwlaagwidget.teken_bouwlaag.setEnabled(False)
             subString = "bouwlaag = " + str(bouwlaag)
             UG.set_layer_substring(subString)
             bouwlaagwidget.show()
             break
         elif bouwlaagMax < bouwlaag:
             MSG.showMsgBox('bouwlaagvolgorde')
         elif ok is False:
             break
Beispiel #8
0
 def run(self):
     """run the plugin, if project is not OIV object, deactivate plugin when clicked on icon"""
     project = QC.QgsProject.instance()
     projectTest = str(
         QC.QgsExpressionContextUtils.projectScope(project).variable(
             'project_title'))
     dbVersion = CH.get_app_version()
     if 'Objecten' not in projectTest:
         self.toolbar.setEnabled(False)
         self.action.setEnabled(False)
     elif PC.PLUGIN["compatibleDbVersion"][1] > dbVersion < PC.PLUGIN[
             "compatibleDbVersion"][0]:
         MSG.showMsgBox('invaliddatabaseversion')
         self.toolbar.setEnabled(False)
         self.action.setEnabled(False)
     else:
         #always start from floor 1
         self.basewidget = OB.oivBaseWidget()
         subString = "bouwlaag = 1"
         UG.set_layer_substring(subString)
         self.basewidget.oiv = self
         self.basewidget.iface = self.iface
         self.basewidget.canvas = self.canvas
         self.basewidget.pinTool = self.pinTool
         self.basewidget.pointTool = self.pointTool
         self.basewidget.selectTool = self.selectTool
         self.basewidget.identifyTool = self.identifyTool
         self.basewidget.drawTool = self.drawTool
         self.basewidget.moveTool = self.moveTool
         index = self.projCombo.findText('1', PQtC.Qt.MatchFixedString)
         if index >= 0:
             self.projCombo.setCurrentIndex(index)
         self.iface.addDockWidget(QT.getWidgetType(), self.basewidget)
         self.basewidget.show()
         self.toolbar.setEnabled(False)
         self.projCombo.setEnabled(False)
         self.checkVisibility = True
 def set_layer_subset_bouwlaag(self):
     """if index of combobox has changed set cql filter of childlayers"""
     subString = "bouwlaag = " + str(self.comboBox.currentText())
     UG.set_layer_substring(subString)
Beispiel #10
0
 def set_layer_subset_bouwlaag(self):
     """set layers substring which are a childlayer of "bouwlagen"""
     comboboxText = str(self.bouwlaag.currentText())
     if comboboxText != "":
         sub_string = "bouwlaag = " + str(self.bouwlaag.currentText())
         UG.set_layer_substring(sub_string)