def __init__(self, element, model): super(ModelerGraphicItem, self).__init__(None) self.model = model self.element = element if isinstance(element, ModelerParameter): icon = QIcon(os.path.join(pluginPath, 'images', 'input.png')) self.pixmap = icon.pixmap(20, 20, state=QIcon.On) self.text = element.param.description elif isinstance(element, ModelerOutput): # Output name icon = QIcon(os.path.join(pluginPath, 'images', 'output.png')) self.pixmap = icon.pixmap(20, 20, state=QIcon.On) self.text = element.description else: self.text = element.description self.pixmap = element.algorithm.getIcon().pixmap(15, 15) self.arrows = [] self.setFlag(QGraphicsItem.ItemIsMovable, True) self.setFlag(QGraphicsItem.ItemIsSelectable, True) self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True) self.setZValue(1000) if not isinstance(element, ModelerOutput): icon = QIcon(os.path.join(pluginPath, 'images', 'edit.png')) pt = QPointF( ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - FlatButtonGraphicItem.HEIGHT / 2 + 1) self.editButton = FlatButtonGraphicItem(icon, pt, self.editElement) self.editButton.setParentItem(self) icon = QIcon(os.path.join(pluginPath, 'images', 'delete.png')) pt = QPointF( ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, -ModelerGraphicItem.BOX_HEIGHT / 2 + FlatButtonGraphicItem.HEIGHT / 2 + 1) self.deleteButton = FlatButtonGraphicItem(icon, pt, self.removeElement) self.deleteButton.setParentItem(self) if isinstance(element, Algorithm): alg = element.algorithm if alg.parameters: pt = self.getLinkPointForParameter(-1) pt = QPointF(0, pt.y() + 2) self.inButton = FoldButtonGraphicItem( pt, self.foldInput, self.element.paramsFolded) self.inButton.setParentItem(self) if alg.outputs: pt = self.getLinkPointForOutput(-1) pt = QPointF(0, pt.y() + 2) self.outButton = FoldButtonGraphicItem( pt, self.foldOutput, self.element.outputsFolded) self.outButton.setParentItem(self)
def __init__(self, element, model): super(ModelerGraphicItem, self).__init__(None) self.model = model self.element = element if isinstance(element, ModelerParameter): icon = QIcon(os.path.join(pluginPath, 'images', 'input.png')) self.pixmap = icon.pixmap(20, 20, state=QIcon.On) self.text = element.param.description elif isinstance(element, ModelerOutput): # Output name icon = QIcon(os.path.join(pluginPath, 'images', 'output.png')) self.pixmap = icon.pixmap(20, 20, state=QIcon.On) self.text = element.description else: self.text = element.description self.pixmap = element.algorithm.getIcon().pixmap(15, 15) self.arrows = [] self.setFlag(QGraphicsItem.ItemIsMovable, True) self.setFlag(QGraphicsItem.ItemIsSelectable, True) self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True) self.setZValue(1000) if not isinstance(element, ModelerOutput): icon = QIcon(os.path.join(pluginPath, 'images', 'edit.png')) pt = QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, ModelerGraphicItem.BOX_HEIGHT / 2 - FlatButtonGraphicItem.HEIGHT / 2 + 1) self.editButton = FlatButtonGraphicItem(icon, pt, self.editElement) self.editButton.setParentItem(self) icon = QIcon(os.path.join(pluginPath, 'images', 'delete.png')) pt = QPointF(ModelerGraphicItem.BOX_WIDTH / 2 - FlatButtonGraphicItem.WIDTH / 2, - ModelerGraphicItem.BOX_HEIGHT / 2 + FlatButtonGraphicItem.HEIGHT / 2 + 1) self.deleteButton = FlatButtonGraphicItem(icon, pt, self.removeElement) self.deleteButton.setParentItem(self) if isinstance(element, Algorithm): alg = element.algorithm if alg.parameters: pt = self.getLinkPointForParameter(-1) pt = QPointF(0, pt.y() + 2) self.inButton = FoldButtonGraphicItem(pt, self.foldInput, self.element.paramsFolded) self.inButton.setParentItem(self) if alg.outputs: pt = self.getLinkPointForOutput(-1) pt = QPointF(0, pt.y() + 2) self.outButton = FoldButtonGraphicItem(pt, self.foldOutput, self.element.outputsFolded) self.outButton.setParentItem(self)
def add_central_toolbar_button(self): widget = QWidget() widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) layout = QHBoxLayout() layout.addStretch() self.btnLogin = QPushButton() palette = self.btnLogin.palette() palette.setColor(QPalette.Button, PLANET_COLOR) self.btnLogin.setPalette(palette) self.btnLogin.setText("Log in") #self.btnLogin.setAutoRaise(True) self.btnLogin.setAttribute(Qt.WA_TranslucentBackground) self.btnLogin.clicked.connect(self.btn_login_clicked) icon = QIcon( os.path.join(plugin_path, "resources", "planet-logo-p.svg")) labelIcon = QLabel() labelIcon.setPixmap(icon.pixmap(QSize(16, 16))) layout.addWidget(labelIcon) self.labelLoggedIn = QLabel() self.labelLoggedIn.setText("") layout.addWidget(self.labelLoggedIn) layout.addWidget(self.btnLogin) layout.addStretch() widget.setLayout(layout) self.toolbar.addWidget(widget)
def __get_custom_widget_item_for_result(self, qr_result): label = QLabel() if not qr_result: style = WIDGET_STYLE_QUALITY_RULE_INITIAL_STATE label.setText("0%") elif qr_result.level == EnumQualityRuleResult.SUCCESS: style = WIDGET_STYLE_QUALITY_RULE_SUCCESS icon = QIcon( ":/Asistente-LADM-COL/resources/images/qr_validation.svg") label.setPixmap(icon.pixmap(QSize(16, 16))) elif qr_result.level == EnumQualityRuleResult.ERRORS: style = WIDGET_STYLE_QUALITY_RULE_ERRORS label.setText(str(qr_result.record_count)) elif qr_result.level == EnumQualityRuleResult.UNDEFINED: style = WIDGET_STYLE_QUALITY_RULE_UNDEFINED else: # EnumQualityRuleResult.CRITICAL style = WIDGET_STYLE_QUALITY_RULE_CRITICAL label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) label.setStyleSheet("QLabel{}".format(style)) return label
def __init__(self, controller, parent=None): QgsPanelWidget.__init__(self, parent) self.setupUi(self) self.__controller = controller self.parent = parent self.logger = Logger() self.__selected_item = None # t_id of the qr error self.txt_search.addAction( QIcon(":/Asistente-LADM-COL/resources/images/search.png"), QLineEdit.LeadingPosition) self.setDockMode(True) self.setPanelTitle( QCoreApplication.translate("QualityRulesErrorResultsPanelWidget", "Errors")) self.tbw_errors.setColumnCount(4) self.tbw_errors.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) self.tbw_errors.horizontalHeader().setSectionResizeMode( CHECK_COLUMN, QHeaderView.ResizeToContents) self.tbw_errors.horizontalHeader().setSectionResizeMode( QRE_COLUMN, QHeaderView.ResizeToContents) # TODO: uncomment the following block when implemented self.btn_exception.setEnabled(False) self.btn_fix_error.setEnabled(False) self.txt_search.textChanged.connect(self.__search_text_changed) #self.btn_open_report.clicked.connect(self.__controller.open_report) #self.btn_view_error_results.clicked.connect(self.__view_error_results_clicked) self.btn_help.clicked.connect(self.__show_help) self.tbw_errors.itemSelectionChanged.connect(self.__selection_changed) # Set icon and QR name in the panel header qr = self.__controller.get_selected_qr() icon_names = [ 'schema.png', 'points.png', 'lines.png', 'polygons.png', 'relationships.svg' ] icon_name = icon_names[qr.type().value] icon = QIcon( ":/Asistente-LADM-COL/resources/images/{}".format(icon_name)) self.lbl_icon_type.setPixmap(icon.pixmap(QSize(24, 24))) self.lbl_icon_type.setToolTip( self.__controller.get_tr_string(qr.type())) self.lbl_qr_name.setText(qr.name()) self.lbl_qr_name.setToolTip(qr.id()) self.__column_labels = [ "", self.__controller.get_uuids_display_name(), QCoreApplication.translate("QualityRulesErrorResultsPanelWidget", "Error"), QCoreApplication.translate("QualityRulesErrorResultsPanelWidget", "Details") ] # Load available rules for current role and current db models self.__load_available_errors()
def initGui(self): _ = self.add_action( 'serval_icon.svg', text=u'Show Serval Toolbars', add_to_menu=True, callback=self.show_toolbar, always_on=True, ) _ = self.add_action( 'serval_icon.svg', text=u'Hide Serval Toolbars', add_to_menu=True, callback=self.hide_toolbar, always_on=True, ) self.probe_btn = self.add_action( 'probe.svg', text="Probe raster", callback=self.activate_probing, add_to_toolbar=self.toolbar, checkable=True, ) self.map_tool_btn[self.probe_tool] = self.probe_btn self.color_btn = QgsColorButton() self.color_btn.setColor(Qt.gray) self.color_btn.setMinimumSize(QSize(40, 24)) self.color_btn.setMaximumSize(QSize(40, 24)) self.toolbar.addWidget(self.color_btn) self.color_picker_connection(connect=True) self.color_btn.setDisabled(True) self.toolbar.addWidget(QLabel("Band:")) self.bands_cbo = QComboBox() self.bands_cbo.addItem("1", 1) self.toolbar.addWidget(self.bands_cbo) self.bands_cbo.currentIndexChanged.connect(self.update_active_bands) self.bands_cbo.setDisabled(True) self.spin_boxes = BandBoxes() self.toolbar.addWidget(self.spin_boxes) self.spin_boxes.enter_hit.connect(self.apply_spin_box_values) self.draw_btn = self.add_action( 'draw.svg', text="Apply Value(s) To Single Cell", callback=self.activate_drawing, add_to_toolbar=self.toolbar, checkable=True, ) self.map_tool_btn[self.draw_tool] = self.draw_btn self.apply_spin_box_values_btn = self.add_action( 'apply_const_value.svg', text="Apply Value(s) to Selection", callback=self.apply_spin_box_values, add_to_toolbar=self.toolbar, ) self.gom_btn = self.add_action( 'apply_nodata_value.svg', text="Apply NoData to Selection", callback=self.apply_nodata_value, add_to_toolbar=self.toolbar, ) self.exp_dlg_btn = self.add_action( 'apply_expression_value.svg', text="Apply Expression Value To Selection", callback=self.define_expression, add_to_toolbar=self.toolbar, checkable=False, ) self.low_pass_filter_btn = self.add_action( 'apply_low_pass_filter.svg', text="Apply Low-Pass 3x3 Filter To Selection", callback=self.apply_low_pass_filter, add_to_toolbar=self.toolbar, checkable=False, ) self.undo_btn = self.add_action( 'undo.svg', text="Undo", callback=self.undo, add_to_toolbar=self.toolbar, ) self.redo_btn = self.add_action( 'redo.svg', text="Redo", callback=self.redo, add_to_toolbar=self.toolbar, ) self.set_nodata_btn = self.add_action( 'set_nodata.svg', text="Edit Raster NoData Values", callback=self.set_nodata, add_to_toolbar=self.toolbar, ) self.settings_btn = self.add_action( 'edit_settings.svg', text="Serval Settings", callback=self.edit_settings, add_to_toolbar=self.toolbar, always_on=True, ) self.show_help = self.add_action( 'help.svg', text="Help", add_to_menu=True, callback=self.show_website, add_to_toolbar=self.toolbar, always_on=True, ) # Selection Toolbar line_width_icon = QIcon(icon_path("line_width.svg")) line_width_lab = QLabel() line_width_lab.setPixmap(line_width_icon.pixmap(22, 12)) self.sel_toolbar.addWidget(line_width_lab) self.line_width_sbox = QgsDoubleSpinBox() self.line_width_sbox.setMinimumSize(QSize(50, 24)) self.line_width_sbox.setMaximumSize(QSize(50, 24)) # self.line_width_sbox.setButtonSymbols(QAbstractSpinBox.NoButtons) self.line_width_sbox.setValue(1) self.line_width_sbox.setMinimum(0.01) self.line_width_sbox.setShowClearButton(False) self.line_width_sbox.setToolTip("Selection Line Width") self.line_width_sbox.valueChanged.connect(self.update_selection_tool) self.width_unit_cbo = QComboBox() self.width_units = ("map units", "pixel width", "pixel height", "hairline",) for u in self.width_units: self.width_unit_cbo.addItem(u) self.width_unit_cbo.setToolTip("Selection Line Width Unit") self.sel_toolbar.addWidget(self.line_width_sbox) self.sel_toolbar.addWidget(self.width_unit_cbo) self.width_unit_cbo.currentIndexChanged.connect(self.update_selection_tool) self.line_select_btn = self.add_action( 'select_line.svg', text="Select Raster Cells by Line", callback=self.activate_line_selection, add_to_toolbar=self.sel_toolbar, checkable=True, ) self.polygon_select_btn = self.add_action( 'select_polygon.svg', text="Select Raster Cells by Polygon", callback=self.activate_polygon_selection, add_to_toolbar=self.sel_toolbar, checkable=True, ) self.selection_from_layer_btn = self.add_action( 'select_from_layer.svg', text="Create Selection From Layer", callback=self.selection_from_layer, add_to_toolbar=self.sel_toolbar, ) self.selection_to_layer_btn = self.add_action( 'selection_to_layer.svg', text="Create Memory Layer From Selection", callback=self.selection_to_layer, add_to_toolbar=self.sel_toolbar, ) self.clear_selection_btn = self.add_action( 'clear_selection.svg', text="Clear selection", callback=self.clear_selection, add_to_toolbar=self.sel_toolbar, ) self.toggle_all_touched_btn = self.add_action( 'all_touched.svg', text="Toggle All Touched Get Selected", callback=self.toggle_all_touched, checkable=True, checked=True, add_to_toolbar=self.sel_toolbar, ) self.all_touched = True self.enable_toolbar_actions(enable=False) self.check_undo_redo_btns()