def setupUi(self, CartogramDialog): CartogramDialog.setObjectName("CartogramDialog") CartogramDialog.resize(640, 600) self.formLayout = QtWidgets.QFormLayout(CartogramDialog) self.formLayout.setObjectName("formLayout") self.layerComboBoxLabel = QtWidgets.QLabel(CartogramDialog) self.layerComboBoxLabel.setObjectName("layerComboBoxLabel") self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.layerComboBoxLabel) self.layerComboBox = gui.QgsMapLayerComboBox(CartogramDialog) self.layerComboBox.setObjectName("layerComboBox") self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.layerComboBox) self.fieldListViewLabel = QtWidgets.QLabel(CartogramDialog) self.fieldListViewLabel.setObjectName("fieldListViewLabel") self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.fieldListViewLabel) self.fieldListView = QgsFieldListView(CartogramDialog) self.fieldListView.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection) self.fieldListView.setObjectName("fieldListView") self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.fieldListView) self.stopConditionsFrameLabel = QtWidgets.QLabel(CartogramDialog) self.stopConditionsFrameLabel.setObjectName("stopConditionsFrameLabel") self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.stopConditionsFrameLabel) self.stopConditionsFrame = QtWidgets.QFrame(CartogramDialog) self.stopConditionsFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.stopConditionsFrame.setFrameShadow(QtWidgets.QFrame.Raised) self.stopConditionsFrame.setObjectName("stopConditionsFrame") self.formLayout_2 = QtWidgets.QFormLayout(self.stopConditionsFrame) self.formLayout_2.setObjectName("formLayout_2") self.iterationsSpinBoxLabel = QtWidgets.QLabel(self.stopConditionsFrame) self.iterationsSpinBoxLabel.setObjectName("iterationsSpinBoxLabel") self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.iterationsSpinBoxLabel) self.iterationsSpinBox = QtWidgets.QSpinBox(self.stopConditionsFrame) self.iterationsSpinBox.setMinimum(1) self.iterationsSpinBox.setMaximum(9999) self.iterationsSpinBox.setProperty("value", 10) self.iterationsSpinBox.setObjectName("iterationsSpinBox") self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.iterationsSpinBox) self.averageErrorDoubleSpinBoxLabel = QtWidgets.QLabel(self.stopConditionsFrame) self.averageErrorDoubleSpinBoxLabel.setObjectName("averageErrorDoubleSpinBoxLabel") self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.averageErrorDoubleSpinBoxLabel) self.averageErrorDoubleSpinBox = QtWidgets.QDoubleSpinBox(self.stopConditionsFrame) self.averageErrorDoubleSpinBox.setSingleStep(0.5) self.averageErrorDoubleSpinBox.setProperty("value", 10.0) self.averageErrorDoubleSpinBox.setObjectName("averageErrorDoubleSpinBox") self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.averageErrorDoubleSpinBox) self.conditionsExplanationLabel = QtWidgets.QLabel(self.stopConditionsFrame) self.conditionsExplanationLabel.setWordWrap(True) self.conditionsExplanationLabel.setObjectName("conditionsExplanationLabel") self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.conditionsExplanationLabel) self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.stopConditionsFrame) self.buttonBox = QtWidgets.QDialogButtonBox(CartogramDialog) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.formLayout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.buttonBox) self.retranslateUi(CartogramDialog) self.buttonBox.accepted.connect(CartogramDialog.accept) # type: ignore self.buttonBox.rejected.connect(CartogramDialog.reject) # type: ignore self.layerComboBox.layerChanged['QgsMapLayer*'].connect(self.fieldListView.setLayer) # type: ignore QtCore.QMetaObject.connectSlotsByName(CartogramDialog)
def getGlobalCommonParamsWindow(self, parent=None): window = QtWidgets.QDialog() window.setWindowTitle("Global and common parameters") scrollarea = QtWidgets.QScrollArea() form = QtWidgets.QFormLayout() form.addRow(QtWidgets.QLabel("Common Parameters:")) for param in self.common: (l1, l2) = self.getUIOneliner(param, global_common=True) form.addRow(l1, l2) form.addRow(QtWidgets.QLabel("Global Parameters:")) for param in self.globals: (l1, l2) = self.getUIOneliner(param, global_common=True) form.addRow(l1, l2) closebtn = QtWidgets.QPushButton("Close") closebtn.clicked.connect(lambda: self.closeGlobalCommonParamsWindow(window)) groupbox = QtWidgets.QGroupBox() groupbox.setLayout(form) scrollarea.setWidget(groupbox) window.setFixedHeight(600) window.setFixedWidth(600) scrollbox = QtWidgets.QVBoxLayout() scrollbox.addWidget(scrollarea) scrollbox.addWidget(closebtn) window.setLayout(scrollbox) return window
def initUI(self): self.ui = QtWidgets.QDialog() lo = QtWidgets.QFormLayout() self.ui.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum) lo.addRow(QtWidgets.QLabel("Load ALS file(s):")) self.dropspace = QpalsDropTextbox.QpalsDropTextbox( layerlist=self.layerlist) self.dropspace.setMinimumContentsLength(20) self.dropspace.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToMinimumContentsLength) self.dropspace.editingFinished.connect(self.inFileUpdated) lo.addRow(self.dropspace) self.visMethod = QtWidgets.QComboBox() self.visMethod.addItem(VISUALISATION_METHODS[0]) self.visMethod.addItem(VISUALISATION_METHODS[1]) self.visMethod.addItem(VISUALISATION_METHODS[2]) self.visMethod.addItem(VISUALISATION_METHODS[3]) self.visMethod.addItem(VISUALISATION_METHODS[4]) self.visMethod.addItem(VISUALISATION_METHODS[5]) self.visMethod.addItem(VISUALISATION_METHODS[6]) self.visMethod.addItem(VISUALISATION_METHODS[7]) self.visMethod.addItem(VISUALISATION_METHODS[8]) self.visMethod.addItem(VISUALISATION_METHODS[9]) self.visMethod.currentIndexChanged.connect(self.updatevisMethod) self.cellSizeLbl = QtWidgets.QLabel("Set cell size:") self.cellSizeBox = QtWidgets.QLineEdit() self.cellFeatLbl = QtWidgets.QLabel("Set feature:") self.cellFeatCmb = QtWidgets.QComboBox() self.cellAttrLbl = QtWidgets.QLabel("Select attribute:") self.cellAttrCmb = QtWidgets.QComboBox() self.cellAttrCmb.addItem("Z") self.cellAttrCmb.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToContents) self.isoInteLbl = QtWidgets.QLabel("Set isoline interval:") self.isoInteBox = QtWidgets.QLineEdit() self.isoInteBox.setText("10") cellInst = QpalsModuleBase.QpalsModuleBase( os.path.join(self.project.opalspath, "opalsCell.exe"), self.project) cellInst.load() for param in cellInst.params: if param.name.lower() == "cellsize": self.cellSizeBox.setText(param.val) break self.cellFeatCmb.addItems(self.features) self.cellFeatCmb.setCurrentIndex(4) lo.addRow(self.cellAttrLbl, self.cellAttrCmb) lo.addRow(self.cellSizeLbl, self.cellSizeBox) lo.addRow(self.cellFeatLbl, self.cellFeatCmb) lo.addRow(self.isoInteLbl, self.isoInteBox) lo.addRow(self.visMethod) self.okBtn = QtWidgets.QPushButton("Load") self.okBtn.clicked.connect(self.loadHelper) lo.addRow(self.okBtn) self.ui.setLayout(lo) self.ui.setWindowTitle("Open ALS file") self.visMethod.setCurrentIndex(1)
def getParamUi(self, parent=None): if not self.loaded: self.load() form = QtWidgets.QFormLayout() for param in self.params: (l1, l2) = self.getUIOneliner(param, parent=parent) form.addRow(l1, l2) return form
def __init__(self, iface, parent=None): super(tTestAnalysisDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar( self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui self.raster_filter_message = self.lblLayerFilter.text() self.pixel_size = ['0', 'm', ''] self.layer_table = build_layer_table() if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: # for use with Vertical/horizontal layout box self.layout().insertWidget(0, self.messageBar) for cbo in [ self.mcboRasterLayer, self.mcboCtrlRasterLayer, self.mcboZoneRasterLyr ]: cbo.setFilters(QgsMapLayerProxyModel.RasterLayer) cbo.setExcludedProviders(['wms']) cbo.setAllowEmptyLayer(True) cbo.setCurrentIndex(0) self.mcboPointsLayer.setFilters(QgsMapLayerProxyModel.PointLayer) self.mcboPointsLayer.setExcludedProviders(['wms']) self.mcboPointsLayer.setAllowEmptyLayer(True) self.mcboPointsLayer.setCurrentIndex(0) self.setMapLayers() self.updateUseSelected() # GUI Runtime Customisation ----------------------------------------------- self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_t-test.svg'))
def getFilteredParamUi(self, parent=None, filter=[], notfilter=[]): if not self.loaded: self.load() form = QtWidgets.QFormLayout() for param in self.params: if (len(filter) > 0 and re.match(r"(?=(" + '|'.join(filter) + '))', param.name)) or \ (len(notfilter) > 0 and not re.match(r"(?=(" + '|'.join(notfilter) + '))', param.name)): (l1, l2) = self.getUIOneliner(param, parent=parent) form.addRow(l1, l2) return form
def initUI(self): lo = QtWidgets.QFormLayout() lo.addRow(QtWidgets.QLabel("Drop something here:")) l1 = QtWidgets.QLabel("") l2 = QtWidgets.QLabel("") dropspace = QpalsDropTextbox() lo.addRow(dropspace) lo.addRow(l1) lo.addRow(l2) self.setLayout(lo) self.setWindowTitle("Hallo Alina")
def __init__(self, iface, parent=None): super(KMeansClusterDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() self.layers_df = None self.pixel_size = ['0', '', ''] # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar( self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget( 0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Runtime Customisation ----------------------------------------------- self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) # self.setMapLayers() self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_kMeansCluster.svg')) self.tabList.setColumnCount(2) self.tabList.setHorizontalHeaderItem(0, QTableWidgetItem("ID")) self.tabList.setHorizontalHeaderItem(1, QTableWidgetItem("0 Raster(s)")) self.tabList.horizontalHeader().setSectionResizeMode( QtWidgets.QHeaderView.Stretch) self.tabList.hideColumn(0) # don't need to display the unique layer ID
def getParamUi(self, parent=None): form = QtWidgets.QFormLayout() l1 = QtWidgets.QLabel("Command") self.e1 = QtWidgets.QLineEdit(self.t1) l2 = QtWidgets.QLabel("Working directory") self.e2 = QtWidgets.QLineEdit(self.t2) self.e1.editingFinished.connect(self.updateVals) self.e2.editingFinished.connect(self.updateVals) form.addRow(l1, self.e1) form.addRow(l2, self.e2) return form
def __init__(self, iface, parent=None): super(CalculateImageIndicesDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) # new layout to gui if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box self.band_mapping = BandMapping() # GUI Runtime Customisation ----------------------------------------------- self.mcboPolygonLayer.setFilters(QgsMapLayerProxyModel.PolygonLayer) self.mcboPolygonLayer.setExcludedProviders(['wms']) self.mcboPolygonLayer.setLayer(None) self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) rastlyrs_df = build_layer_table([self.mcboRasterLayer.layer(i) for i in range(self.mcboRasterLayer.count())]) if self.mcboRasterLayer.count() > 0: exc_lyrs = rastlyrs_df[rastlyrs_df['bandcount']<=1] self.mcboRasterLayer.setExceptedLayerList(exc_lyrs['layer'].tolist()) self.updateRaster() # self.chkAddToDisplay.setChecked(False) # self.chkAddToDisplay.hide() self.chkgrpIndices.setExclusive(False) # allow for multi selection self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_calcImgIndices.svg'))
def __init__(self, iface, parent=None): super(PointTrailToPolygonDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) # The qgis interface self.iface = iface # The qgis interface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() self.source_file = None if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) # Setup for validation messagebar on gui----------------------------- ''' source: https://nathanw.net/2013/08/02/death-to-the-message-box-use-the-qgis-messagebar/ Add the error messages to top of form via a message bar. ''' self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box # #save default values so they can be easily reset when a new file is selected. self.default_vals = {} for name, obj in inspect.getmembers(self): if isinstance(obj, QSpinBox): self.default_vals[obj.objectName()] = obj.value() self.stackedWidget.setCurrentIndex(0) self.stackedWidget.currentChanged.connect(self.update_prev_next_buttons) self.button_box.button(QDialogButtonBox.Ok).setVisible(False) self.mcboTargetLayer.setFilters(QgsMapLayerProxyModel.PointLayer) if hasattr(self.mcboTargetLayer, "setAllowEmptyLayer"): self.mcboTargetLayer.setAllowEmptyLayer(True) self.mcboTargetLayer.setShowCrs(True) self.mcboTargetLayer.setLayer(None) # set default to empty layer
def createUi(self): self.selectedChkBox = QtWidgets.QCheckBox("Use selected lines only") self.selectedChkBox.setCheckState(2) self.cmbLineLayer = QgsMapLayerComboBox() self.cmbLineLayer.setFilters(QgsMapLayerProxyModel.LineLayer) self.cmbOdmPath = QpalsDropTextbox.QpalsDropTextbox( layerlist=self.layerlist, filterrex=".*\.odm$") self.runBtn = QtWidgets.QPushButton("Run") self.runBtn.clicked.connect(self.runLM) self.ui = QtWidgets.QWidget() self.fl = QtWidgets.QFormLayout() self.ui.setLayout(self.fl) self.fl.addRow(QtWidgets.QLabel("Line layer:"), self.cmbLineLayer) self.fl.addRow(QtWidgets.QLabel("Point cloud:"), self.cmbOdmPath) self.fl.addRow(self.selectedChkBox) self.fl.addRow(self.runBtn)
def getUI(self): self.ui = QtWidgets.QDialog() self.ui.resize(720, 300) self.ui.setWindowTitle("qpals AttributeManager") lo = QtWidgets.QFormLayout() vb = QtWidgets.QVBoxLayout() hb = QtWidgets.QHBoxLayout() self.pointcloud = QpalsDropTextbox.QpalsDropTextbox(layerlist=self.layerlist) hb.addWidget(self.pointcloud,1) lo.addRow("ODM File", hb) vb.addLayout(lo,0) self.attable = QtWidgets.QTableView() self.newnamebox = QtWidgets.QComboBox() self.newnamebox.setEditable(True) for attr in odm_predef_attributes: self.newnamebox.addItem(attr) self.newnamebox.lineEdit().setPlaceholderText("_Name") self.typedropdown = QtWidgets.QComboBox() for type in odm_data_types: self.typedropdown.addItem(type) self.formulabox = QtWidgets.QLineEdit("") self.formulabox.setPlaceholderText("opalsAddInfo formula") self.helpbtn = QtWidgets.QPushButton('?') self.helpbtn.setMaximumWidth(self.helpbtn.fontMetrics().boundingRect("?").width() + 7) self.addchangebtn = QtWidgets.QPushButton('Add/Change attribute') self.closebtn = QtWidgets.QPushButton('Close') hb2 = QtWidgets.QHBoxLayout() hb2.addWidget(self.newnamebox) hb2.addWidget(QtWidgets.QLabel("(")) hb2.addWidget(self.typedropdown) hb2.addWidget(QtWidgets.QLabel(")")) hb2.addWidget(QtWidgets.QLabel("=")) hb2.addWidget(self.formulabox) hb2.addWidget(self.addchangebtn) hb2.addWidget(self.helpbtn) hb2.addStretch() hb2.addWidget(self.closebtn) vb.addWidget(self.attable, 1) vb.addLayout(hb2) self.ui.setLayout(vb) self.pointcloud.editingFinished.connect(self.pcChanged) self.newnamebox.editTextChanged.connect(self.newnameChanged) self.closebtn.clicked.connect(self.close) self.helpbtn.clicked.connect(self.addinfoHelp) self.addchangebtn.clicked.connect(self.fieldcalc) self.newnamebox.lineEdit().setText("_") return self.ui
def __init__(self, iface, parent=None): super(ResampleImageToBlockDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) # new layout to gui if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Runtime Customisation ----------------------------------------------- self.mcboPolygonLayer.setFilters(QgsMapLayerProxyModel.PolygonLayer) self.mcboPolygonLayer.setExcludedProviders(['wms']) self.mcboPolygonLayer.setLayer(None) self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) self.updateRaster() #https://stackoverflow.com/questions/13422995/set-qlineedit-to-accept-only-numbers #https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers regex_validator = QtGui.QRegExpValidator(QtCore.QRegExp("[-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)?")) self.lneNoDataVal.setValidator(regex_validator) self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_resampleToBlock.svg'))
def __init__(self, iface, parent=None): super(StripTrialPointsDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar( self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget( 0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Runtime Customisation ----------------------------------------------- self.mcboLineLayer.setFilters(QgsMapLayerProxyModel.LineLayer) self.mcboLineLayer.setExcludedProviders(['wms']) if self.mcboLineLayer.count() > 0: self.mcboLineLayer.setCurrentIndex(0) self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_stripTrialPoints.svg')) self.chkUseSelected.setChecked(False) self.chkUseSelected.hide()
def __init__(self, iface, parent=None): super(BlockGridDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) # The qgis interface self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.outQgsCRS = None # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) # new layout to gui if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box #self.setMapLayers() self.mcboTargetLayer.setFilters(QgsMapLayerProxyModel.PolygonLayer) self.mcboTargetLayer.setAllowEmptyLayer(False) self.mcboTargetLayer.setShowCrs(True) self.mcboTargetLayer.setLayer(None) # set default to empty layer # GUI Runtime Customisation ----------------------------------------------- self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_blockGrid.svg')) # hide some objects on the form, delete later if no longer needed. self.chkDisplayResults.hide() self.lblNoDataVal.hide() self.spnNoDataVal.hide()
def __init__(self, iface, parent=None): super(PostVesperDialog, self).__init__(iface.mainWindow()) # Set up the user interface from Designer. self.setupUi(self) # The qgis interface self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_importVesperKriging.svg')) self.validationLayout = QtWidgets.QFormLayout(self) # source: https://nathanw.net/2013/08/02/death-to-the-message-box-use-the-qgis-messagebar/ # Add the error messages to top of form via a message bar. self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box # Set Class default variables ------------------------------------- self.vesper_qgscrs = None self.vesp_dict = None self.dfCSV = None self.chkRunVesper.hide()
def __init__(self, iface, parent=None): super(RasterSymbologyDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) # The qgis interface self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui -------------------------- self.messageBar = QgsMessageBar( self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget( 0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Customisation ----------------------------------------------- self.mcboTargetLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) # self.setMapLayers() self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_rasterSymbology.svg')) self.cboType.addItems(list(rs.RASTER_SYMBOLOGY))
def __init__(self, iface, parent=None): super(RandomPixelSelectionDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) # The qgis interface self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui -------------------------- self.messageBar = QgsMessageBar(self) # leave this message bar for bailouts self.validationLayout = QtWidgets.QFormLayout(self) # new layout to gui if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: self.layout().insertWidget(0, self.messageBar) # for use with Vertical/horizontal layout box # GUI Customisation ----------------------------------------------- self.mcboTargetLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboTargetLayer.setExcludedProviders(['wms']) self.setWindowIcon(QtGui.QIcon(':/plugins/pat/icons/icon_randomPixel.svg')) last_size = read_setting(PLUGIN_NAME + "/" + self.toolKey + "/LastSampleSize") if last_size is not None and int(last_size) > 0: self.dsbSize.setValue(read_setting(PLUGIN_NAME + "/" + self.toolKey + "/LastSampleSize", int))
def __init__(self, iface, parent=None): super(PreVesperDialog, self).__init__(iface.mainWindow()) # Set up the user interface from Designer. self.setupUi(self) # The qgis interface self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() # Catch and redirect python errors directed at the log messages python # error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_vesperKriging.svg')) self.validationLayout = QtWidgets.QFormLayout(self) # source: https://nathanw.net/2013/08/02/death-to-the-message-box-use-the-qgis-messagebar/ # Add the error messages to top of form via a message bar. # leave this message bar for bailouts self.messageBar = QgsMessageBar(self) if isinstance(self.layout(), (QtWidgets.QFormLayout, QtWidgets.QGridLayout)): # create a validation layout so multiple messages can be added and # cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: # for use with Vertical/horizontal layout box self.layout().insertWidget(0, self.messageBar) # Set Class default variables ------------------------------------- self.vesp_dict = None self.dfCSV = None # this is a validation flag self.OverwriteCtrlFile = False self.cboMethod.addItems( ['High Density Kriging', 'Low Density Kriging (Advanced)']) # To allow only integers for the min number of pts. self.onlyInt = QIntValidator() self.lneMinPoint.setValidator(self.onlyInt) self.vesper_exe = check_vesper_dependency() if self.vesper_exe is None or self.vesper_exe == '': self.gbRunVesper.setTitle( 'WARNING:Vesper not found please configure using the about dialog.' ) self.gbRunVesper.setChecked(False) self.gbRunVesper.setCheckable(False) self.gbRunVesper.setEnabled(False)
def setupUi(self, ProjectSearch): ProjectSearch.setObjectName(_fromUtf8("ProjectSearch")) ProjectSearch.resize(282, 295) self.formLayout = QtWidgets.QFormLayout(ProjectSearch) self.formLayout.setFieldGrowthPolicy( QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setObjectName(_fromUtf8("formLayout")) self.label = QtWidgets.QLabel(ProjectSearch) self.label.setObjectName(_fromUtf8("label")) self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label) self.searchName = QtWidgets.QLineEdit(ProjectSearch) self.searchName.setObjectName(_fromUtf8("searchName")) self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.searchName) self.layerLabel = QtWidgets.QLabel(ProjectSearch) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.layerLabel.sizePolicy().hasHeightForWidth()) self.layerLabel.setSizePolicy(sizePolicy) self.layerLabel.setObjectName(_fromUtf8("layerLabel")) self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.layerLabel) self.layerCombo = QgsMapLayerComboBox(ProjectSearch) sizePolicy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.layerCombo.sizePolicy().hasHeightForWidth()) self.layerCombo.setSizePolicy(sizePolicy) self.layerCombo.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToContents) self.layerCombo.setObjectName(_fromUtf8("layerCombo")) self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.layerCombo) self.FieldNameLabel = QtWidgets.QLabel(ProjectSearch) self.FieldNameLabel.setObjectName(_fromUtf8("FieldNameLabel")) self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.FieldNameLabel) self.fieldExpressionWidget = QgsFieldExpressionWidget(ProjectSearch) self.fieldExpressionWidget.setObjectName( _fromUtf8("fieldExpressionWidget")) self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.fieldExpressionWidget) self.label_2 = QtWidgets.QLabel(ProjectSearch) self.label_2.setObjectName(_fromUtf8("label_2")) self.formLayout.setWidget(7, QtWidgets.QFormLayout.LabelRole, self.label_2) self.priorityBox = QtWidgets.QSpinBox(ProjectSearch) self.priorityBox.setMinimum(1) self.priorityBox.setMaximum(999) self.priorityBox.setProperty("value", 1) self.priorityBox.setObjectName(_fromUtf8("priorityBox")) self.formLayout.setWidget(7, QtWidgets.QFormLayout.FieldRole, self.priorityBox) self.progressBar = QtWidgets.QProgressBar(ProjectSearch) self.progressBar.setProperty("value", 24) self.progressBar.setObjectName(_fromUtf8("progressBar")) self.formLayout.setWidget(10, QtWidgets.QFormLayout.SpanningRole, self.progressBar) self.evaluateCheckBox = QtWidgets.QCheckBox(ProjectSearch) self.evaluateCheckBox.setChecked(True) self.evaluateCheckBox.setObjectName(_fromUtf8("evaluateCheckBox")) self.formLayout.setWidget(9, QtWidgets.QFormLayout.SpanningRole, self.evaluateCheckBox) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.cancelButton = QtWidgets.QPushButton(ProjectSearch) self.cancelButton.setObjectName(_fromUtf8("cancelButton")) self.horizontalLayout.addWidget(self.cancelButton) self.okButton = QtWidgets.QPushButton(ProjectSearch) self.okButton.setObjectName(_fromUtf8("okButton")) self.horizontalLayout.addWidget(self.okButton) self.formLayout.setLayout(11, QtWidgets.QFormLayout.SpanningRole, self.horizontalLayout) self.geometryStorageLabel = QtWidgets.QLabel(ProjectSearch) self.geometryStorageLabel.setObjectName( _fromUtf8("geometryStorageLabel")) self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.geometryStorageLabel) self.geometryStorageCombo = QtWidgets.QComboBox(ProjectSearch) self.geometryStorageCombo.setObjectName( _fromUtf8("geometryStorageCombo")) self.geometryStorageCombo.addItem(_fromUtf8("")) self.geometryStorageCombo.addItem(_fromUtf8("")) self.geometryStorageCombo.addItem(_fromUtf8("")) self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.geometryStorageCombo) self.retranslateUi(ProjectSearch) QtCore.QMetaObject.connectSlotsByName(ProjectSearch) ProjectSearch.setTabOrder(self.searchName, self.layerCombo) ProjectSearch.setTabOrder(self.layerCombo, self.geometryStorageCombo) ProjectSearch.setTabOrder(self.geometryStorageCombo, self.priorityBox) ProjectSearch.setTabOrder(self.priorityBox, self.evaluateCheckBox) ProjectSearch.setTabOrder(self.evaluateCheckBox, self.cancelButton) ProjectSearch.setTabOrder(self.cancelButton, self.okButton)
def createWidget(self): self.scrollwidget = QtWidgets.QScrollArea() self.scrollwidget.setWidgetResizable(True) self.tabs = QtWidgets.QTabWidget() self.scrollwidget.setWidget(self.tabs) self.names = [ 'Settings', 'DTM', 'Slope', '2D-Approximation', 'Topologic correction', 'Editing', '3D-Modelling', 'Editing (3D)', 'Export' ] self.widgets = {} self.settings = {} self.modules = {} for idx, name in enumerate(self.names): self.widgets[name] = QtWidgets.QDialog() ls = QtWidgets.QFormLayout() # Tab-specific options if name == "Settings": desc = QtWidgets.QLabel( "Welcome to the qpals LineModeler GUI! \nThis tool will help you to detect and " "model breaklines based on a DTM and/or a point cloud using the opals module " "opalsLineModeler.\nThe process includes manual editing in QGIS (\"Editing\") " "as well as automatic dectection and modelling.\n\n" "To begin, please enter some basic information.") desc.setWordWrap(True) ls.addRow(desc) boxRun = QtWidgets.QGroupBox( "Run multiple steps automatically:") boxVL = QtWidgets.QVBoxLayout() boxRun.setLayout(boxVL) self.settings['settings'] = OrderedDict([ ('name', QtWidgets.QLineEdit()), ('inFile', QpalsDropTextbox.QpalsDropTextbox( layerlist=self.layerlist)), ('tempFolder', QpalsDropTextbox.QpalsDropTextbox()), ('outFolder', QpalsDropTextbox.QpalsDropTextbox()), ('chkDTM', QtWidgets.QCheckBox("DTM")), ('chkSlope', QtWidgets.QCheckBox("Slope")), ('chk2D', QtWidgets.QCheckBox("2D-Approximation")), ('chktopo2D', QtWidgets.QCheckBox("Topological correction")), ('chkEditing2d', QtWidgets.QLabel( "--- Manual editing of 2D-Approximations ---")), ('chk3Dmodel', QtWidgets.QCheckBox("3D-Modelling")), ('chkEditing3d', QtWidgets.QLabel("--- Manual editing of 3D-Lines ---")), ('chkExport', QtWidgets.QCheckBox("Export")), ]) for key, value in list(self.settings['settings'].items()): if isinstance(value, QpalsDropTextbox.QpalsDropTextbox): value.setMinimumContentsLength(20) value.setSizeAdjustPolicy( QtWidgets.QComboBox.AdjustToMinimumContentsLength) if key.startswith("chk"): boxVL.addWidget(value) ls.addRow(QtWidgets.QLabel("Project name"), self.settings['settings']['name']) hbox_wrap = QtWidgets.QHBoxLayout() hbox_wrap.addWidget(self.settings['settings']['inFile'], stretch=1) ls.addRow(QtWidgets.QLabel("Input file (TIFF/LAS/ODM)"), hbox_wrap) hbox_wrap = QtWidgets.QHBoxLayout() hbox_wrap.addWidget(self.settings['settings']['tempFolder'], stretch=1) self.settings['settings']['tempFolder'].setPlaceholderText( "drop folder here (will be created if not exists)") ls.addRow(QtWidgets.QLabel("Folder for temporary files"), hbox_wrap) hbox_wrap = QtWidgets.QHBoxLayout() self.settings['settings']['outFolder'].setPlaceholderText( "drop folder here (will be created if not exists)") hbox_wrap.addWidget(self.settings['settings']['outFolder'], stretch=1) ls.addRow(QtWidgets.QLabel("Folder for output files"), hbox_wrap) ls.addRow(QtWidgets.QLabel("")) boxBtnRun = QtWidgets.QPushButton("Run selected steps now") boxBtnRun.clicked.connect(lambda: self.run_step("all")) boxBtnExp = QtWidgets.QPushButton( "Export selected steps to .bat") boxBtnExp.clicked.connect(self.createBatFile) # saveBtn = QtWidgets.QPushButton("Save to project file") # saveBtn.clicked.connect(self.save) boxVL.addWidget(boxBtnRun) boxVL.addWidget(boxBtnExp) # boxVL.addWidget(saveBtn) ls.addRow(boxRun) if name == "DTM": desc = QtWidgets.QLabel( "This first step will create a digital terrain model (DTM) from your point cloud data. " "Also, a shading of your DTM " "will be created for visualisation purposes. If the input file is not an ODM, one has to be " "created for the modelling process later on.") desc.setWordWrap(True) ls.addRow(desc) impmod, impscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsImport", "opalsImport", self.project, {'outFile': 'pointcloud.odm'}, ["inFile", "outFile"]) self.modules['dtmImp'] = impmod self.widgets['dtmImp'] = impscroll ls.addRow(impscroll) dtmmod, dtmscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsGrid", "opalsGrid", self.project, { 'interpolation': 'movingPlanes', 'gridSize': '1', 'outFile': 'DTM_1m.tif' }, [ "inFile", "outFile", "neighbours", "searchRadius", "interpolation" ]) self.modules['dtmGrid'] = dtmmod self.widgets['dtmGrid'] = dtmscroll dtmmod.afterRun = self.addDtm ls.addRow(dtmscroll) shdmod, shdscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsShade", "opalsShade", self.project, { 'inFile': 'DTM_1m.tif', 'outFile': 'DTM_1m_shd.tif' }, [ "inFile", "outFile", ]) self.modules['dtmShade'] = shdmod shdmod.afterRun = self.addShd ls.addRow(shdscroll) if name == "Slope": desc = QtWidgets.QLabel( "To automatically detect breaklines, a slope map is calculated. This map uses the neighboring 9" " pixels to estimate a plane. The gradient (steepest slope) is then taken, converted to a slope" "in degrees, and assigned to the pixel.") desc.setWordWrap(True) ls.addRow(desc) gfmod, gfscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsGridFeature", "opalsGridFeature", self.project, { 'feature': 'slpDeg', 'inFile': 'DTM_1m.tif', 'outFile': 'DTM_1m_slope.tif' }, ["inFile", "outFile", "feature"]) self.modules['slope'] = gfmod ls.addRow(gfscroll) if name == "2D-Approximation": desc = QtWidgets.QLabel( "The slope map is used to detect breaklines. For this, the algorithm by Canny (1986) is used.\n" "First, the slope map is convoluted with a gaussian kernel for smoothing, then the derivative " "is calculated. The two threshold parameters represent the upper and lower values for the " "binarization of the derivative map. Edges that have at least one pixel > upper threshold will be " "followed until they have a pixel < lower threshold.") desc.setWordWrap(True) ls.addRow(desc) edgeDmod, edgeDscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsEdgeDetect", "opalsEdgeDetect", self.project, { 'threshold': '2;4', 'sigmaSmooth': '1.8', 'inFile': 'DTM_1m_slope_slpDeg.tif', 'outFile': 'detected_edges.tif' }, ["inFile", "outFile", "threshold", "sigmaSmooth"]) self.modules['edgeDetect'] = edgeDmod ls.addRow(edgeDscroll) desc = QtWidgets.QLabel( "Since the output of opalsEdgeDetect is still a raster, we need to vectorize it:" ) desc.setWordWrap(True) ls.addRow(desc) vecmod, vecscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsVectorize", "opalsVectorize", self.project, { 'inFile': 'detected_edges.tif', 'outFile': 'detected_edges.shp' }, ["inFile", "outFile"]) self.modules['vectorize'] = vecmod ls.addRow(vecscroll) if name == "Topologic correction": desc = QtWidgets.QLabel( "Vectorized binary rasters usually need some topological cleaning. Here, this is done in three steps: \n" "1) Find the longest line and remove all lines < 10m\n" "2) Merge lines iteratively\n" "3) Clean up") desc.setWordWrap(True) ls.addRow(desc) lt1mod, lt1scroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsLineTopology", "opalsLineTopology (1)", self.project, { 'method': 'longest', 'minLength': '10', 'snapRadius': '0', 'maxTol': '0.5', 'maxAngleDev': '75;15', 'avgDist': '3', 'inFile': 'detected_edges.shp', 'outFile': 'edges1.shp' }, ["inFile", "outFile", "method", "minLength", "maxTol"]) self.modules['lt1'] = lt1mod ls.addRow(lt1scroll) lt2mod, lt2scroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsLineTopology", "opalsLineTopology (2)", self.project, { 'method': 'merge', 'minLength': '10', 'snapRadius': '3', 'maxTol': '0', 'maxAngleDev': '150;15', 'avgDist': '3', 'merge.minWeight': '0.75', 'merge.relWeightLead': '0', 'merge.maxIter': '10', 'merge.revertDist': '5', 'merge.revertInterval': '1', 'merge.searchGeneration': '4', 'merge.preventIntersection': '1', 'inFile': 'edges1.shp', 'outFile': 'edges2.shp' }, [ "inFile", "outFile", "method", "maxAngleDev", "snapRadius", "merge\..*" ]) lt2scroll.setFixedHeight(lt2scroll.height() - 200) self.modules['lt2'] = lt2mod ls.addRow(lt2scroll) lt3mod, lt3scroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsLineTopology", "opalsLineTopology (3)", self.project, { 'method': 'longest', 'minLength': '25', 'snapRadius': '0', 'maxTol': '0', 'maxAngleDev': '90;15', 'avgDist': '3', 'inFile': 'edges2.shp', 'outFile': 'edges3.shp' }, ["inFile", "outFile", "method", "minLength", "maxTol"]) self.modules['lt3'] = lt3mod ls.addRow(lt3scroll) lt3mod.afterRun = self.add2DLines if name == "Editing": desc = QtWidgets.QLabel( "Please start editing the 2D approximations that have been loaded into qgis. Here are some tools " "that might help:") desc.setWordWrap(True) ls.addRow(desc) box1 = QtWidgets.QGroupBox("QuickLineModeller") from . import QpalsQuickLM self.quicklm = QpalsQuickLM.QpalsQuickLM( project=self.project, layerlist=self.layerlist, iface=self.iface) box1.setLayout(self.quicklm.fl) ls.addRow(box1) box2 = QtWidgets.QGroupBox("qpalsSection") from . import QpalsSection self.section = QpalsSection.QpalsSection( project=self.project, layerlist=self.layerlist, iface=self.iface) self.section.createWidget() box2.setLayout(self.section.ls) box2.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) ls.addRow(box2) if name == "3D-Modelling": desc = QtWidgets.QLabel( "The 2D approximations can now be used to model 3D breaklines in the pointcloud/the DTM." ) desc.setWordWrap(True) ls.addRow(desc) lmmod, lmscroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsLineModeler", "opalsLineModeler", self.project, { #"filter": "Class[Ground]", "approxFile": "edges3.shp", "outFile": "modelled_lines.shp" }, [ "inFile", "approxFile", "outFile", "filter", "patchLength", "patchWidth", "overlap", "angle", "minLength", "pointCount", "sigmaApriori" ]) self.modules['lm'] = lmmod ls.addRow(lmscroll) lmmod.afterRun = self.add3DLines if name == "Editing (3D)": desc = QtWidgets.QLabel( "Before exporting the final product, there are a few tools to check the " "quality of the result. This includes a topological check as well as a search" "for points that have a big height difference to the DTM - and might be erraneous." ) desc.setWordWrap(True) ls.addRow(desc) self.startQualityCheckBtn = QtWidgets.QPushButton( "Start calculation") self.startQualityCheckBtn.clicked.connect( self.runProblemSearchAsync) self.QualityCheckbar = QtWidgets.QProgressBar() self.QualityCheckDtm = QgsMapLayerComboBox() self.QualityCheckDtm.setFilters( QgsMapLayerProxyModel.RasterLayer) self.QualityCheckThreshold = QtWidgets.QLineEdit("0.5") ls.addRow( QtWidgets.QLabel("DTM Layer to compare heights with"), self.QualityCheckDtm) ls.addRow( QtWidgets.QLabel("Set height difference threshold [m]"), self.QualityCheckThreshold) hb = QtWidgets.QHBoxLayout() hb.addWidget(self.QualityCheckbar) hb.addWidget(self.startQualityCheckBtn) ls.addRow(hb) line = QtWidgets.QFrame() line.setFrameShape(QtWidgets.QFrame.HLine) line.setFrameShadow(QtWidgets.QFrame.Sunken) ls.addRow(line) self.editingls = ls self.edit3d_linelayerbox = QgsMapLayerComboBox() self.edit3d_linelayerbox.setFilters( QgsMapLayerProxyModel.LineLayer) self.edit3d_pointlayerbox = QgsMapLayerComboBox() self.edit3d_pointlayerbox.setFilters( QgsMapLayerProxyModel.PointLayer) self.edit3d_dtmlayerbox = QgsMapLayerComboBox() self.edit3d_dtmlayerbox.setFilters( QgsMapLayerProxyModel.RasterLayer) self.edit3d_pointlayerbox.currentIndexChanged.connect( self.nodeLayerChanged) self.edit3d_currPointId = QSpinBox() self.edit3d_currPointId.setMinimum(0) self.edit3d_currPointId.valueChanged.connect( self.showProblemPoint) ls.addRow("Select Line Layer:", self.edit3d_linelayerbox) ls.addRow("Select Problem Point layer:", self.edit3d_pointlayerbox) self.selectNodeBtn = QtWidgets.QPushButton("Next point") self.selectNodeBtn.clicked.connect( lambda: self.edit3d_currPointId.setValue( self.edit3d_currPointId.value() + 1)) self.selectPrevNodeBtn = QtWidgets.QPushButton("Prev point") self.selectPrevNodeBtn.clicked.connect( lambda: self.edit3d_currPointId.setValue( self.edit3d_currPointId.value() - 1)) self.edit3d_countLabel = QtWidgets.QLabel() self.snapToDtmBtn = QtWidgets.QPushButton("Snap to:") self.snapToDtmBtn.clicked.connect(self.snapToDtm) self.remonveNodeBtn = QtWidgets.QPushButton("Remove") self.remonveNodeBtn.clicked.connect(self.removeNode) nextBox = QtWidgets.QHBoxLayout() nextBox.addWidget(QtWidgets.QLabel("Current point:")) nextBox.addWidget(self.edit3d_currPointId) nextBox.addWidget(QtWidgets.QLabel("/")) nextBox.addWidget(self.edit3d_countLabel) nextBox.addStretch() nextBox.addWidget(self.snapToDtmBtn) nextBox.addWidget(self.edit3d_dtmlayerbox) nextBox.addWidget(self.remonveNodeBtn) nextBox.addWidget(self.selectPrevNodeBtn) nextBox.addWidget(self.selectNodeBtn) ls.addRow(nextBox) self.nodeLayerChanged() if name == "Export": exp2mod, exp2scroll = QpalsModuleBase.QpalsModuleBase.createGroupBox( "opalsTranslate", "opalsTranslate", self.project, { 'oformat': 'shp', 'inFile': 'modelled_lines.shp', 'outFile': 'STRULI3D.shp', }, ["inFile", "outFile"]) self.modules['exp'] = exp2mod ls.addRow(exp2scroll) vl = QtWidgets.QVBoxLayout() vl.addLayout(ls, 1) navbar = QtWidgets.QHBoxLayout() next = QtWidgets.QPushButton("Next step >") next.clicked.connect(self.switchToNextTab) prev = QtWidgets.QPushButton("< Previous step") prev.clicked.connect(self.switchToPrevTab) runcurr = QtWidgets.QPushButton( "Run this step (all modules above)") runcurr.clicked.connect(lambda: self.run_step(None)) if idx > 0: navbar.addWidget(prev) navbar.addStretch() if name in [ "DTM", "Slope", "2D-Approximation", "Topologic correction", "3D-Modelling", "Export" ]: navbar.addWidget(runcurr) navbar.addStretch() if idx < len(self.names): navbar.addWidget(next) vl.addLayout(navbar) self.widgets[name].setLayout(vl) self.tabs.addTab(self.widgets[name], name) # set up connections self.tabs.currentChanged.connect(self.updateTabs) return self.scrollwidget
def __init__(self, iface, parent=None): super(PersistorDialog, self).__init__(parent) # Set up the user interface from Designer. self.setupUi(self) self.iface = iface self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS', bool) self.DEBUG = config.get_debug_mode() self.pixel_size = ['0', 'm', ''] self.layers_df = None # Catch and redirect python errors directed at the log messages python error tab. QgsApplication.messageLog().messageReceived.connect(errorCatcher) if not os.path.exists(TEMPDIR): os.mkdir(TEMPDIR) # Setup for validation messagebar on gui----------------------------- # leave this message bar for bailouts self.messageBar = QgsMessageBar(self) self.validationLayout = QtWidgets.QFormLayout( self) # new layout to gui if isinstance(self.layout(), QtWidgets.QFormLayout): # create a validation layout so multiple messages can be added and # cleaned up. self.layout().insertRow(0, self.validationLayout) self.layout().insertRow(0, self.messageBar) else: # for use with Vertical/horizontal layout box self.layout().insertWidget(0, self.messageBar) # GUI Runtime Customisation ------------------------------------------- self.setWindowIcon( QtGui.QIcon(':/plugins/pat/icons/icon_persistor.svg')) self.mcboRasterLayer.setFilters(QgsMapLayerProxyModel.RasterLayer) self.mcboRasterLayer.setExcludedProviders(['wms']) #self.setMapLayers() self.cboMethod.addItems( ['Target Probability', 'Target Over All Years']) self.cboMethod.setCurrentIndex(1) for ea_cbo in [ self.cboAllYearTargetPerc, self.cboUpperPerc, self.cboLowerPerc ]: ea_cbo.addItems(['{}%'.format(ea) for ea in range(50, -55, -5)]) ea_cbo.setCurrentIndex( ea_cbo.findText('10%', QtCore.Qt.MatchFixedString)) self.cboLowerPerc.setCurrentIndex( self.cboLowerPerc.findText('-10%', QtCore.Qt.MatchFixedString)) for ea_tab in [self.tabUpper, self.tabLower]: ea_tab.setColumnCount(2) ea_tab.hideColumn(0) # don't need to display the unique layer ID ea_tab.setHorizontalHeaderItem(0, QTableWidgetItem("ID")) ea_tab.setHorizontalHeaderItem(1, QTableWidgetItem("0 Raster(s)")) ea_tab.horizontalHeader().setSectionResizeMode( QtWidgets.QHeaderView.Stretch) ea_tab.hideColumn(0) # don't need to display the unique layer ID
def createWidget(self): self.advanced_widget = QtWidgets.QDialog() self.simple_widget = QtWidgets.QDialog() self.tabs = QtWidgets.QTabWidget() ### SIMPLE ### self.ls = QtWidgets.QFormLayout() self.ls.addRow(QtWidgets.QLabel("Choose input file:")) self.txtinfileSimple = QpalsDropTextbox.QpalsDropTextbox( layerlist=self.layerlist, filterrex=".*\.odm$") hboxsimple1 = QtWidgets.QHBoxLayout() hboxsimple1.addWidget(self.txtinfileSimple, 1) self.txtinfileSimple.textChanged.connect(self.simpleIsLoaded) self.ls.addRow(QtWidgets.QLabel("Input file (odm)"), hboxsimple1) self.linetoolBtn = QtWidgets.QPushButton("Pick section") self.linetoolBtn.clicked.connect(self.activateLineTool) self.linetoolBtn.setEnabled(False) self.ls.addRow(self.linetoolBtn) self.runSecBtnSimple = QtWidgets.QPushButton("Create section") self.runSecBtnSimple.clicked.connect(self.ltool.runsec) self.runSecBtnSimple.setEnabled(False) self.runSecBtnSimple.setStyleSheet("background-color: rgb(50,240,50)") self.runSecBtnView = QtWidgets.QPushButton("Open section in opalsView") self.runSecBtnView.clicked.connect(self.ltool.runview) self.runSecBtnView.setEnabled(False) self.runSecBtnView.setStyleSheet("background-color: rgb(100,100,240)") hb = QtWidgets.QHBoxLayout() hb.addWidget(self.runSecBtnSimple) hb.addWidget(self.runSecBtnView) self.simpleLineLayer = QgsMapLayerComboBox() self.simpleLineLayer.setFilters(QgsMapLayerProxyModel.LineLayer) self.simpleLineLayerChk = QtWidgets.QCheckBox( "Visualize (3D) Line Layer:") self.ls.addRow(self.simpleLineLayerChk, self.simpleLineLayer) self.showSection = QtWidgets.QCheckBox("Show section") self.filterStr = QtWidgets.QLineEdit("Class[Ground]") self.filterAttrBox = QCollapsibleGroupBox.QCollapsibleGroupBox( 'Show attribute selection') self.filterAttrBox.setLayout(QtWidgets.QGridLayout()) self.filterAttrBox.setChecked(False) # hide it self.filterAttrs = {} self.progress = QtWidgets.QProgressBar() self.stateSwitch = QToggleSwitch.QToggleSwitch("vispy", "matplotlib") self.showSection.stateChanged.connect(self.checkBoxChanged) self.showSection.setCheckState(2) self.showSection.setTristate(False) self.ls.addRow(self.showSection) self.ls.addRow("Filter String:", self.filterStr) self.ls.addRow(self.filterAttrBox) self.ls.addRow(hb) self.ls.addRow(self.progress) self.ls.addRow(self.stateSwitch) self.simple_widget.setLayout(self.ls) ### ADVANCED ### lo = QtWidgets.QFormLayout() ###### lo.addRow( QtWidgets.QLabel("Step 1. Choose point cloud and visualize it:")) self.txtinfile = QpalsDropTextbox.QpalsDropTextbox( layerlist=self.layerlist) hbox1 = QtWidgets.QHBoxLayout() hbox1.addWidget(self.txtinfile, 1) lo.addRow(QtWidgets.QLabel("Input file (odm)"), hbox1) self.runShdBtn = QtWidgets.QPushButton("Create shading") self.runShdBtn.clicked.connect(self.loadShading) lo.addRow(self.runShdBtn) ###### self.status = QtWidgets.QListWidgetItem("hidden status") lo.addRow(QtWidgets.QLabel("Step 2. Create sections")) self.secInst = QpalsModuleBase.QpalsModuleBase( execName=os.path.join(self.project.opalspath, "opalsSection.exe"), QpalsProject=self.project) self.secInst.load() self.secInst.listitem = self.status secUi = self.secInst.getParamUi() lo.addRow(secUi) self.runSecBtn = QtWidgets.QPushButton("Calculate sections") self.runSecBtn.clicked.connect(self.runSection) lo.addRow(self.runSecBtn) ####### lo.addRow( QtWidgets.QLabel( "Step 3. Use the Section picking tool to show Sections")) self.pickSecBtn = QtWidgets.QPushButton("Pick section") self.pickSecBtn.clicked.connect(self.activateTool) lo.addRow(self.pickSecBtn) self.advanced_widget.setLayout(lo) self.tabs.addTab(self.simple_widget, "Simple") self.tabs.addTab(self.advanced_widget, "Advanced") self.scrollwidget = QtWidgets.QScrollArea() self.scrollwidget.setWidgetResizable(True) self.scrollwidget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored) self.scrollwidget.setWidget(self.tabs) return self.scrollwidget
def createWidget(self): # Form boxleft = QtWidgets.QVBoxLayout() loadDir = QtWidgets.QPushButton("load") newProj = QtWidgets.QPushButton("new") newProj.clicked.connect(self.newProject) loadDir.clicked.connect(self.loadProject) hbox2 = QtWidgets.QHBoxLayout() hbox2.addWidget(loadDir) hbox2.addWidget(newProj) boxleft.addLayout(hbox2) self.prjBox = QtWidgets.QGroupBox("Project settings") self.prjBox.setEnabled(False) formL = QtWidgets.QFormLayout() self.prjBox.setLayout(formL) self.odmText = QpalsDropTextbox(layerlist=self.layerlist) self.odmText.currentTextChanged.connect(self.odmFileChanged) formL.addRow("odm", self.odmText) self.axisText = QpalsDropTextbox(layerlist=self.layerlist, filterrex='.*[\.shp]') formL.addRow("axis shp", self.axisText) self.widthSpin = QtWidgets.QDoubleSpinBox() self.widthSpin.setValue(15) self.widthSpin.setSingleStep(0.1) self.widthSpin.setRange(1, 50) self.widthSpin.setSuffix(" m") formL.addRow("sec width", self.widthSpin) self.depthSpin = QtWidgets.QDoubleSpinBox() self.depthSpin.setValue(5) self.depthSpin.setSingleStep(0.1) self.depthSpin.setRange(1, 50) self.depthSpin.setSuffix(" m") formL.addRow("sec depth", self.depthSpin) self.overlapSpin = QtWidgets.QDoubleSpinBox() self.overlapSpin.setValue(0) self.overlapSpin.setSingleStep(1) self.overlapSpin.setRange(0, 100) self.overlapSpin.setSuffix("%") formL.addRow("sec overlap", self.overlapSpin) self.attrSel = QtWidgets.QComboBox() formL.addRow("attribute", self.attrSel) # createShd = QtWidgets.QPushButton("create shading") # createShd.clicked.connect(self.createShd) # formL.addRow(createShd) createSec = QtWidgets.QPushButton("save && create sections") createSec.clicked.connect(self.createSec) formL.addRow(createSec) self.progress = QtWidgets.QProgressBar() formL.addRow(self.progress) boxleft.addWidget(self.prjBox) modeBox = QtWidgets.QGroupBox("Mode") modeBoxL = QtWidgets.QFormLayout() modeBox.setLayout(modeBoxL) self.modeGrp = QtWidgets.QButtonGroup() for mode in ['linear (1,2,3...)', 'alternating (farthest sampling)']: btn = QtWidgets.QRadioButton(mode) modeBoxL.addRow(btn) self.modeGrp.addButton(btn) if mode.startswith('alternating'): btn.setChecked(True) boxleft.addWidget(modeBox) saveBtn = QtWidgets.QPushButton("Save progress") saveBtn.clicked.connect(self.saveProgress) boxleft.addWidget(saveBtn) expGroup = QtWidgets.QGroupBox("Export") expGroupLayout = QtWidgets.QFormLayout() expGroup.setLayout(expGroupLayout) self.expBtn = QtWidgets.QPushButton("Export WSM") self.expBtn.clicked.connect(self.exportWSM) self.expBtn.setEnabled(False) self.expPath = QpalsDropTextbox() self.expPath.currentTextChanged.connect(self.exportChanged) expGroupLayout.addRow("Output file", self.expPath) self.dXSpin = QtWidgets.QDoubleSpinBox() self.dYSpin = QtWidgets.QDoubleSpinBox() self.dXSpin.valueChanged.connect(self.dXdYChanged) self.dYSpin.valueChanged.connect(self.dXdYChanged) self.dXSpin.setValue(1) self.dYSpin.setValue(1) self.dXSpin.setSingleStep(0.1) self.dYSpin.setSingleStep(0.1) expGroupLayout.addRow("X cell size", self.dXSpin) expGroupLayout.addRow("Y cell size", self.dYSpin) self.progress2 = QtWidgets.QProgressBar() expGroupLayout.addRow(self.progress2) expGroupLayout.addRow(self.expBtn) boxleft.addWidget(expGroup) # center figure figure = plt.figure() centerbox = QtWidgets.QVBoxLayout() self.plotcenter = FigureCanvas(figure) self.axcenter = figure.add_subplot(111) figure.subplots_adjust(left=0, right=1, top=0.99, bottom=0.01) #manager, canvas = figure.canvas.manager, figure.canvas #canvas.mpl_disconnect(manager.key_press_handler_id) # remove default key bindings (ctrl+w = close) #cid = self.plotcenter.mpl_connect('key_press_event', self.keyPressed) cid2 = self.plotcenter.mpl_connect('button_press_event', self.mousePressed) cid2 = self.plotcenter.mpl_connect('motion_notify_event', self.mouseMoved) cid3 = self.plotcenter.mpl_connect('button_release_event', self.mouseReleased) cid4 = self.plotcenter.mpl_connect('scroll_event', self.mouseScrolled) #toolbar = NavigationToolbar(self.plotcenter, self.widget) centerbox.addWidget(self.plotcenter) #centerbox.addWidget(toolbar) centerw = QtWidgets.QWidget() centerw.setLayout(centerbox) # right figure vboxright = QtWidgets.QVBoxLayout() data3d = { 'X': np.array([0]), 'Y': np.array([0]), 'Z': np.array([0]), self.attrSel.currentText(): np.array([0]) } mins = {self.attrSel.currentText(): 0} maxes = {self.attrSel.currentText(): 1} self.pltwindow_3d = mpl_plotwindow(self.project, self.iface, data3d, mins, maxes) self.plotright = self.pltwindow_3d.ui # Section Grid Buttons secGrid = QtWidgets.QGridLayout() leftup = QtWidgets.QPushButton("↑") self.hleftLbl = QtWidgets.QLabel("h=") leftdown = QtWidgets.QPushButton("↓") rightup = QtWidgets.QPushButton("↑") self.hrightLbl = QtWidgets.QLabel("h=") rightdown = QtWidgets.QPushButton("↓") symCanvas = QtWidgets.QWidget() secGrid.addWidget(leftup, 0, 0) secGrid.addWidget(self.hleftLbl, 1, 0) secGrid.addWidget(leftdown, 2, 0) secGrid.addWidget(rightup, 0, 2) secGrid.addWidget(self.hrightLbl, 1, 2) secGrid.addWidget(rightdown, 2, 2) secGrid.addWidget(symCanvas, 0, 1, 3, 1) # Navigation Buttons navGrid = QtWidgets.QGridLayout() prevBtn = QtWidgets.QPushButton("prev") nextBtn = QtWidgets.QPushButton("next") prevBtn.clicked.connect(self.prevSec) nextBtn.clicked.connect(self.nextSec) self.incbox = QtWidgets.QSpinBox() self.incbox.setMinimum(1) self.currbox = QtWidgets.QSpinBox() self.currbox.valueChanged.connect(self.currSecChanged) self.skipSeen = QtWidgets.QCheckBox("Skip already seen sections") self.skipSeen.setChecked(True) pickBtn = QtWidgets.QPushButton("pick") pickBtn.clicked.connect(self.activatePickTool) self.status = QtWidgets.QLabel("Section 0/0: 0% finished") navGrid.addWidget(prevBtn, 0, 0) navGrid.addWidget(QtWidgets.QLabel("inc"), 0, 1) navGrid.addWidget(self.incbox, 0, 2) navGrid.addWidget(nextBtn, 0, 3) navGrid.addWidget(self.skipSeen, 1, 0, 1, 4) navGrid.addWidget(QtWidgets.QLabel("Current Index:")) navGrid.addWidget(self.currbox, 2, 1) navGrid.addWidget(pickBtn, 2, 3) navGrid.addWidget(self.status, 3, 0, 1, 4) vboxright.addWidget(self.plotright, stretch=1) vboxright.addWidget(QHLine()) #vboxright.addLayout(secGrid) vboxright.addWidget(QHLine()) vboxright.addLayout(navGrid) boxleftw = QtWidgets.QWidget() boxleftw.setLayout(boxleft) vboxrightw = QtWidgets.QWidget() vboxrightw.setLayout(vboxright) self.addWidget(boxleftw) self.addWidget(centerw) self.addWidget(vboxrightw) self.setStretchFactor(0, 1) self.setStretchFactor(1, 15) self.setStretchFactor(2, 1) self.setStyleSheet("QSplitter::handle{background-color: #CCCCCC;}") self.setHandleWidth(2)