Пример #1
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')
Пример #2
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'))
     try:
         layer = UC.getlayer_byname('applicatie')
         request = QC.QgsFeatureRequest().setFilterExpression('"id" = 1')
         dbVersion = next(layer.getFeatures(request))["db_versie"]
     except:
         dbVersion = 0
     if 'Objecten' not in projectTest:
         self.toolbar.setEnabled(False)
         self.action.setEnabled(False)
     elif PLUGIN["compatibleDbVersion"]["max"] < dbVersion < PLUGIN[
             "compatibleDbVersion"]["min"]:
         MSG.showMsgBox('invaliddatabaseversion')
         self.toolbar.setEnabled(False)
         self.action.setEnabled(False)
     else:
         # always start from floor 1
         self.basewidget = OB.oivBaseWidget(self)
         subString = "bouwlaag = 1"
         UG.set_layer_substring(subString)
         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
Пример #3
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()))
Пример #4
0
 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()
Пример #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.bagpand_layername():
         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)
Пример #6
0
 def close_object_show_base(self):
     subString = "bouwlaag = 1"
     UG.set_layer_substring(subString)
     self.helpBtn.clicked.disconnect()
     self.floatBtn.clicked.disconnect()
     for widget in self.children():
         if isinstance(widget, PQtW.QPushButton):
             try:
                 widget.clicked.disconnect()
             except:  # pylint: disable=bare-except
                 pass
     self.close()
     self.parent.show()
     self.iface.actionPan().trigger()
     del self
Пример #7
0
 def run_bouwlaag(self):
     while True:
         bouwlaag, bouwlaagMax, ok = BouwlaagDialog.getBouwlagen()
         if (bouwlaag != 0 and bouwlaagMax >= bouwlaag and ok is True):
             bouwlaagwidget = oivBouwlaagWidget(self, bouwlaag, bouwlaagMax)
             self.iface.addDockWidget(QT.getWidgetType(), bouwlaagwidget)
             subString = "bouwlaag = " + str(bouwlaag)
             UG.set_layer_substring(subString)
             bouwlaagwidget.show()
             self.close()
             break
         elif bouwlaagMax < bouwlaag:
             MSG.showMsgBox('bouwlaagvolgorde')
         elif ok is False:
             break
Пример #8
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()
Пример #9
0
 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)
Пример #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)