Exemplo n.º 1
0
    def initGui(self):
        """Customize QGIS' GUI"""
        #. Add toolbar
        self.toolBar = self.iface.addToolBar("DigitizingTools")
        self.toolBar.setObjectName("DigitizingTools")

        #. Add a menu
        self.menuLabel = QtWidgets.QApplication.translate(
            "DigitizingTools", "&DigitizingTools")
        self.digitizingtools_help = QtWidgets.QAction(
            QtWidgets.QApplication.translate("DigitizingTools", "Help"),
            self.iface.mainWindow())
        self.digitizingtools_about = QtWidgets.QAction(
            QtWidgets.QApplication.translate("DigitizingTools", "About"),
            self.iface.mainWindow())
        self.digitizingtools_about.setObjectName("DtAbout")
        self.digitizingtools_settings = QtWidgets.QAction(
            QtWidgets.QApplication.translate("DigitizingTools", "Settings"),
            self.iface.mainWindow())

        self.iface.addPluginToMenu(self.menuLabel, self.digitizingtools_about)

        #. Add the tools
        self.multiPartSplitter = dtsplitmultipart.DtSplitMultiPartTool(
            self.iface, self.toolBar)
        self.partExtractor = dtextractpart.DtExtractPartTool(
            self.iface, self.toolBar)
        self.splitfeature = dtsplitfeature.DtSplitFeature(
            self.iface, self.toolBar)
        self.merger = dtmerge.DtMerge(self.iface, self.toolBar)
        self.exchangeGeometry = dtexchangegeometry.DtExchangeGeometry(
            self.iface, self.toolBar)
        self.cutter = dtcutter.DtCutWithPolygon(self.iface, self.toolBar)
        self.clipper = dtclipper.DtClipWithPolygon(self.iface, self.toolBar)
        self.ringFiller = dtfillring.DtFillRing(self.iface, self.toolBar)
        self.gapFiller = dtfillgap.DtFillGap(self.iface, self.toolBar)
        self.gapFillerAll = dtfillgap.DtFillGapAllLayers(
            self.iface, self.toolBar)
        self.flipLine = dtflipline.DtFlipLine(self.iface, self.toolBar)
        self.moveNodeByArea = dtmovenodebyarea.DtMoveNodeByArea(
            self.iface, self.toolBar)
        self.moveSideByDistance = dtmovesidebydistance.DtMoveSideByDistance(
            self.iface, self.toolBar)
        self.moveSideByArea = dtmovesidebyarea.DtMoveSideByArea(
            self.iface, self.toolBar)
        self.medianLine = dtmedianline.DtMedianLine(self.iface, self.toolBar)

        self.digitizingtools_about.triggered.connect(self.doAbout)
Exemplo n.º 2
0
    def __init__(self, iface,  toolBar):
        # Save reference to the QGIS interface
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.gui = None
        self.multipolygon_detected = False

        # points of the selected segment
        # p1 is always the left point
        self.p1 = None
        self.p2 = None
        self.rb1 = QgsRubberBand(self.canvas,  False)
        #self.m1 = None
        self.selected_feature = None

        #create action
        self.side_mover = QtWidgets.QAction(QtGui.QIcon(":/ParallelMovePolygonSideByDistance.png"),
            QtWidgets.QApplication.translate("digitizingtools", "Parallel move of polygon side to given distance"),  self.iface.mainWindow())

        self.side_mover.triggered.connect(self.run)
        self.iface.currentLayerChanged.connect(self.enable)
        toolBar.addAction(self.side_mover)
        self.enable()

        self.tool = DtSelectSegmentTool(self.iface)
Exemplo n.º 3
0
 def initGui(self):
     """init actions plugin"""
     self.toolbar = self.iface.addToolBar(PC.PLUGIN["name"])
     self.action = PQtW.QAction(PQtG.QIcon(PC.PLUGIN["icon"]),
                                PC.PLUGIN["name"], self.iface.mainWindow())
     self.action.triggered.connect(self.run)
     self.toolbar.addAction(self.action)
     self.iface.addPluginToMenu(PC.PLUGIN["menulocation"], self.action)
     #add label to toolbar
     label = PQtW.QLabel()
     self.toolbar.addWidget(label)
     label.setText(PC.PLUGIN["toolbartext"])
     #init dropdown to switch floors
     self.projCombo = PQtW.QComboBox(self.iface.mainWindow())
     minBouwlaag = PC.PAND["minbouwlaag"]
     maxBouwlaag = PC.PAND["maxbouwlaag"]
     for i in range(maxBouwlaag - minBouwlaag + 1):
         if maxBouwlaag - i != 0:
             if maxBouwlaag - i == 1:
                 init_index = i
             self.projCombo.addItem(str(maxBouwlaag - i))
     self.projComboAction = self.toolbar.addWidget(self.projCombo)
     self.projCombo.setFixedWidth(100)
     self.projCombo.setMaxVisibleItems(30)
     #set intial index to floor 1
     self.projCombo.setCurrentIndex(init_index)
     #connect to set layer subset if the index is changed
     self.projCombo.currentIndexChanged.connect(
         self.set_layer_subset_toolbar)
     #init projectVariable to communicate from plugin to original drawing possibilities
     QC.QgsExpressionContextUtils.setProjectVariable(
         QC.QgsProject.instance(), 'actieve_bouwlaag', 1)
Exemplo n.º 4
0
    def __init__(self, iface, toolBar):
        # Save reference to the QGIS interface
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.gui = None
        self.multipolygon_detected = False

        # Points and Markers
        self.p1 = None
        self.p2 = None
        self.m1 = None
        self.m2 = None
        self.selected_feature = None

        #create action
        self.node_mover = QtWidgets.QAction(
            QtGui.QIcon(":/MovePolygonNodeByArea.png"),
            QtWidgets.QApplication.translate(
                "digitizingtools",
                "Move polygon node (along a side) to achieve target area"),
            self.iface.mainWindow())

        self.node_mover.triggered.connect(self.run)
        self.iface.currentLayerChanged.connect(self.enable)
        toolBar.addAction(self.node_mover)
        self.enable()

        self.tool = DtSelectVertexTool(self.iface, 2)
Exemplo n.º 5
0
    def __init__(self, iface, toolBar):
        # Save reference to the QGIS interface
        self.iface = iface
        self.canvas = self.iface.mapCanvas()

        #self.lineLayer = None
        self.selected_points = 0
        self.side1_x = []
        self.side1_y = []
        self.side2_x = []
        self.side2_y = []
        self.point_list = []

        #create action
        self.median_digitizer = QtWidgets.QAction(
            QtGui.QIcon(":/medianLine.png"),
            QtCore.QCoreApplication.translate(
                "digitizingtools",
                "Digitize median line between adjacent polygons"),
            self.iface.mainWindow())

        self.median_digitizer.triggered.connect(self.run)
        self.iface.currentLayerChanged.connect(self.enable)
        toolBar.addAction(self.median_digitizer)
        self.enable()
        self.tool = DtMedianLineTool(self)
        self.tool.finishedDigitizing.connect(self.digitizingFinished)
    def __init__(self, parent=None, **kwargs):
        super(CsiWebView, self).__init__(parent)
        self.kwargs = kwargs

        # Adding custom action to the widget (right-click activated)
        self.clearCacheAction = QtWidgets.QAction('Pulisci cache e cronologia',
                                                  self)
        self.clearCacheAction.triggered.connect(self.slot_clear_cache)
Exemplo n.º 7
0
    def initGui(self):
        urlPicture = ":/geoRef/logo.png"
        self.action = QtWidgets.QAction(QtGui.QIcon(urlPicture), "geoRef_DIF",
                                        self.iface.mainWindow())

        self.action.triggered.connect(self.run)

        self.iface.addToolBarIcon(self.action)
        self.iface.addPluginToMenu("&geoRef_DIF", self.action)
    def initGui(self):
        # Create action that will start plugin configuration
        self.action = QtWidgets.QAction(
            QtGui.QIcon(':/plugins/bulkvectorexportwithstyle/icon.png'),
            u"Bulk export vector layers", self.iface.mainWindow())
        # connect the action to the run method
        self.action.triggered.connect(self.run)

        # Add toolbar button and menu item
        self.iface.addToolBarIcon(self.action)
        self.iface.addPluginToMenu(u"&Bulk vector export", self.action)
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(261, 171)
        self.comboBox = QtWidgets.QComboBox(Dialog)
        self.comboBox.setGeometry(QtCore.QRect(10, 10, 241, 22))
        self.comboBox.setObjectName("comboBox")
        self.choose = QtWidgets.QAction(Dialog)
        self.choose.setObjectName("choose")

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
 def on_context_menu(self, point):
     item = self.itemAt(point)
     acts = []
     if item is None:
         a1 = QtGui.QAction('Add Folder (top level)', None)
         a1.triggered.connect(lambda: self.addNewFolder(None))
         acts.append(a1)
         a2 = QtGui.QAction('Delete Tree Contents completely', None)
         a2.triggered.connect(self.deleteAll)
         acts.append(a2)
     else:
         a1 = QtGui.QAction('Rename', None)
         a1.triggered.connect(lambda: self.renameItem(item))
         acts.append(a1)
         if item.role == self.SHOGUN_TREE_LEAF:
             a2 = QtGui.QAction('Delete Leaf', None)
             a2.triggered.connect(lambda: self.deleteLeaf(item))
             acts.append(a2)
         else:
             a2 = QtGui.QAction('New Folder (inside selected)', None)
             a2.triggered.connect(lambda: self.addNewFolder(item))
             acts.append(a2)
             a3 = QtGui.QAction('Delete Folder', None)
             a3.triggered.connect(lambda: self.deleteLeaf(item))
             acts.append(a3)
     menu = QtGui.QMenu()
     menu.addActions(acts)
     point = self.mapToGlobal(point)
     menu.exec_(point)
Exemplo n.º 11
0
 def initGui(self):
     self.action = QtWidgets.QAction(
         QtGui.QIcon(
             ':/plugins/SpreadsheetLayers/icon/mActionAddSpreadsheetLayer.svg'
         ), self.tr("Add spreadsheet layer"), self)
     self.action.triggered.connect(self.showDialog)
     if Qgis.QGIS_VERSION_INT > 20400:
         self.iface.addLayerMenu().addAction(self.action)
     else:
         menu = self.iface.layerMenu()
         for action in menu.actions():
             if action.isSeparator():
                 break
         self.iface.layerMenu().insertAction(action, self.action)
     self.iface.layerToolBar().addAction(self.action)
Exemplo n.º 12
0
def addAboutMenu(menuName, parentMenuFunction=None):
    '''
    Adds an 'about...' menu to the plugin menu.
    This method should be called from the initGui() method of the plugin

    :param menuName: The name of the plugin menu in which the about menu is to be added
    '''

    parentMenuFunction = parentMenuFunction or iface.addPluginToMenu
    namespace = _callerName().split(".")[0]
    aboutAction = QtWidgets.QAction(
        QgsApplication.getThemeIcon('/mActionHelpContents.svg'), "About...",
        iface.mainWindow())
    aboutAction.setObjectName(namespace + "about")
    aboutAction.triggered.connect(lambda: openAboutDialog(namespace))
    parentMenuFunction(menuName, aboutAction)
    global _aboutActions
    _aboutActions[menuName] = aboutAction
Exemplo n.º 13
0
def addAboutMenu(menuName, parentMenuFunction=None):
    '''
    Adds an 'about...' menu to the plugin menu.
    This method should be called from the initGui() method of the plugin

    :param menuName: The name of the plugin menu in which the about menu is to be added
    '''

    parentMenuFunction = parentMenuFunction or iface.addPluginToMenu
    namespace = _callerName().split(".")[0]
    icon = QtGui.QIcon(
        os.path.join(os.path.dirname(os.path.dirname(__file__)), "icons",
                     "help.png"))
    aboutAction = QtWidgets.QAction(icon, "About...", iface.mainWindow())
    aboutAction.setObjectName(namespace + "about")
    aboutAction.triggered.connect(lambda: openAboutDialog(namespace))
    parentMenuFunction(menuName, aboutAction)
    global _aboutActions
    _aboutActions[menuName] = aboutAction
Exemplo n.º 14
0
def addHelpMenu(menuName, parentMenuFunction=None):
    '''
    Adds a help menu to the plugin menu.
    This method should be called from the initGui() method of the plugin

    :param menuName: The name of the plugin menu in which the about menu is to be added.
    '''

    parentMenuFunction = parentMenuFunction or iface.addPluginToMenu
    namespace = _callerName().split(".")[0]
    path = "file://{}".format(
        os.path.join(os.path.dirname(_callerPath()), "docs", "html",
                     "index.html"))
    helpAction = QtWidgets.QAction(
        QgsApplication.getThemeIcon('/mActionHelpContents.svg'),
        "Plugin help...", iface.mainWindow())
    helpAction.setObjectName(namespace + "help")
    helpAction.triggered.connect(lambda: openHelp(path))
    parentMenuFunction(menuName, helpAction)
    global _helpActions
    _helpActions[menuName] = helpAction
    def __init__(self, parent=None):
        """Plugin constructor.

        :param parent: parent class or None
        """
        super(RadiationToolboxDockWidget, self).__init__(parent)
        self.setupUi(self)
        self.setWindowTitle(PLUGIN_NAME)

        # connect ui with functions
        self._createToolbarAndConnect()

        # actions
        self.actionUpdateStatsPlot = QtWidgets.QAction("UpdateStatsPlot", self)

        # generic connects
        iface.currentLayerChanged.connect(self.onLayerChanged)
        self.actionUpdateStatsPlot.triggered.connect(self.onUpdateStatsPlot)

        # settings (must be called before _initStyles()
        self._settings = QSettings("OpenGeoLabs", PLUGIN_NAME)
        # load settings
        self._loadSettings()

        # initialize internal variables
        self._initStats()
        self._initPlot()
        self._initMaps()

        # list of layers (must be defined, otherwise SafecastLayer is
        # not returned by getActiveLayer()
        self._layers = {}

        # collect supported file extensions
        if PLUGIN_TYPE == PluginType.Dev:
            self._supported_ext = ("log", "ers", "pei")
        elif PLUGIN_TYPE == PluginType.RT:
            self._supported_ext = ("ers", "pei")
        else:
            self._supported_ext = ("log")
    def setupUi(self, MainApp):
        MainApp.setObjectName(_fromUtf8("MainApp"))
        MainApp.resize(918, 332)
        MainApp.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.centralWidget = QtWidgets.QWidget(MainApp)
        self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
        self.gridLayout_4 = QtWidgets.QGridLayout(self.centralWidget)
        self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
        self.splitter = QtWidgets.QSplitter(self.centralWidget)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.stackedWidget = QtWidgets.QStackedWidget(self.splitter)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(2)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.stackedWidget.sizePolicy().hasHeightForWidth())
        self.stackedWidget.setSizePolicy(sizePolicy)
        self.stackedWidget.setObjectName(_fromUtf8("stackedWidget"))
        self.importPage = QtWidgets.QWidget()
        self.importPage.setObjectName(_fromUtf8("importPage"))
        self.gridLayout_10 = QtWidgets.QGridLayout(self.importPage)
        self.gridLayout_10.setObjectName(_fromUtf8("gridLayout_10"))
        self.scrollArea_5 = QtWidgets.QScrollArea(self.importPage)
        self.scrollArea_5.setWidgetResizable(True)
        self.scrollArea_5.setObjectName(_fromUtf8("scrollArea_5"))
        self.scrollAreaWidgetContents_5 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_5.setGeometry(QtCore.QRect(0, 0, 409, 294))
        self.scrollAreaWidgetContents_5.setObjectName(_fromUtf8("scrollAreaWidgetContents_5"))
        self.gridLayout_11 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_5)
        self.gridLayout_11.setObjectName(_fromUtf8("gridLayout_11"))
        self.widget = QtWidgets.QWidget(self.scrollAreaWidgetContents_5)
        self.widget.setObjectName(_fromUtf8("widget"))
        self.gridLayout_17 = QtWidgets.QGridLayout(self.widget)
        self.gridLayout_17.setMargin(0)
        self.gridLayout_17.setObjectName(_fromUtf8("gridLayout_17"))
        self.groupBox = QtWidgets.QGroupBox(self.widget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
        self.groupBox.setSizePolicy(sizePolicy)
        self.groupBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
        self.groupBox.setFlat(False)
        self.groupBox.setCheckable(False)
        self.groupBox.setObjectName(_fromUtf8("groupBox"))
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.groupBox)
        self.horizontalLayout_6.setSpacing(6)
        self.horizontalLayout_6.setContentsMargins(9, 7, -1, 0)
        self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6"))
        self.rb_file = QtWidgets.QRadioButton(self.groupBox)
        self.rb_file.setChecked(True)
        self.rb_file.setObjectName(_fromUtf8("rb_file"))
        self.horizontalLayout_6.addWidget(self.rb_file)
        self.rb_directory = QtWidgets.QRadioButton(self.groupBox)
        self.rb_directory.setObjectName(_fromUtf8("rb_directory"))
        self.horizontalLayout_6.addWidget(self.rb_directory)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_6.addItem(spacerItem)
        self.gridLayout_17.addWidget(self.groupBox, 0, 0, 1, 1)
        spacerItem1 = QtWidgets.QSpacerItem(20, 13, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_17.addItem(spacerItem1, 2, 0, 1, 1)
        self.gridLayout_12 = QtWidgets.QGridLayout()
        self.gridLayout_12.setObjectName(_fromUtf8("gridLayout_12"))
        self.pb_nextFile = QtWidgets.QPushButton(self.widget)
        self.pb_nextFile.setMinimumSize(QtCore.QSize(0, 0))
        self.pb_nextFile.setMaximumSize(QtCore.QSize(27, 27))
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setUnderline(False)
        font.setWeight(75)
        font.setStrikeOut(False)
        font.setKerning(False)
        self.pb_nextFile.setFont(font)
        self.pb_nextFile.setStyleSheet(_fromUtf8(""))
        self.pb_nextFile.setAutoRepeat(False)
        self.pb_nextFile.setAutoDefault(False)
        self.pb_nextFile.setDefault(False)
        self.pb_nextFile.setFlat(False)
        self.pb_nextFile.setObjectName(_fromUtf8("pb_nextFile"))
        self.gridLayout_12.addWidget(self.pb_nextFile, 0, 2, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout_12.addWidget(self.label_2, 1, 0, 1, 1)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
        self.vfkFileLineEdit = QtWidgets.QLineEdit(self.widget)
        self.vfkFileLineEdit.setObjectName(_fromUtf8("vfkFileLineEdit"))
        self.horizontalLayout_3.addWidget(self.vfkFileLineEdit)
        self.browseButton = QtWidgets.QPushButton(self.widget)
        self.browseButton.setObjectName(_fromUtf8("browseButton"))
        self.horizontalLayout_3.addWidget(self.browseButton)
        self.gridLayout_12.addLayout(self.horizontalLayout_3, 0, 1, 1, 1)
        self.budCheckBox = QtWidgets.QCheckBox(self.widget)
        self.budCheckBox.setChecked(True)
        self.budCheckBox.setObjectName(_fromUtf8("budCheckBox"))
        self.gridLayout_12.addWidget(self.budCheckBox, 2, 1, 1, 1)
        self.label = QtWidgets.QLabel(self.widget)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName(_fromUtf8("label"))
        self.gridLayout_12.addWidget(self.label, 0, 0, 1, 1)
        self.parCheckBox = QtWidgets.QCheckBox(self.widget)
        self.parCheckBox.setChecked(True)
        self.parCheckBox.setObjectName(_fromUtf8("parCheckBox"))
        self.gridLayout_12.addWidget(self.parCheckBox, 1, 1, 1, 1)
        self.l_settings = QtWidgets.QLabel(self.widget)
        self.l_settings.setMinimumSize(QtCore.QSize(69, 0))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.l_settings.setFont(font)
        self.l_settings.setObjectName(_fromUtf8("l_settings"))
        self.gridLayout_12.addWidget(self.l_settings, 3, 0, 1, 1)
        self.overwriteCheckBox = QtWidgets.QCheckBox(self.widget)
        self.overwriteCheckBox.setChecked(False)
        self.overwriteCheckBox.setObjectName(_fromUtf8("overwriteCheckBox"))
        self.gridLayout_12.addWidget(self.overwriteCheckBox, 3, 1, 1, 1)
        self.gridLayout_17.addLayout(self.gridLayout_12, 1, 0, 1, 1)
        self.labelLoading = QtWidgets.QLabel(self.widget)
        self.labelLoading.setText(_fromUtf8(""))
        self.labelLoading.setObjectName(_fromUtf8("labelLoading"))
        self.gridLayout_17.addWidget(self.labelLoading, 3, 0, 1, 1)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.progressBar = QtWidgets.QProgressBar(self.widget)
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName(_fromUtf8("progressBar"))
        self.horizontalLayout_2.addWidget(self.progressBar)
        self.loadVfkButton = QtWidgets.QPushButton(self.widget)
        self.loadVfkButton.setObjectName(_fromUtf8("loadVfkButton"))
        self.horizontalLayout_2.addWidget(self.loadVfkButton)
        self.gridLayout_17.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
        self.gridLayout_11.addWidget(self.widget, 1, 0, 1, 1)
        self.scrollArea_5.setWidget(self.scrollAreaWidgetContents_5)
        self.gridLayout_10.addWidget(self.scrollArea_5, 0, 0, 1, 1)
        self.stackedWidget.addWidget(self.importPage)
        self.changesPage = QtWidgets.QWidget()
        self.changesPage.setObjectName(_fromUtf8("changesPage"))
        self.gridLayout_15 = QtWidgets.QGridLayout(self.changesPage)
        self.gridLayout_15.setObjectName(_fromUtf8("gridLayout_15"))
        self.scrollArea_6 = QtWidgets.QScrollArea(self.changesPage)
        self.scrollArea_6.setWidgetResizable(True)
        self.scrollArea_6.setObjectName(_fromUtf8("scrollArea_6"))
        self.scrollAreaWidgetContents_6 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_6.setGeometry(QtCore.QRect(0, 0, 269, 194))
        self.scrollAreaWidgetContents_6.setObjectName(_fromUtf8("scrollAreaWidgetContents_6"))
        self.gridLayout_16 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_6)
        self.gridLayout_16.setObjectName(_fromUtf8("gridLayout_16"))
        self.widget_3 = QtWidgets.QWidget(self.scrollAreaWidgetContents_6)
        self.widget_3.setObjectName(_fromUtf8("widget_3"))
        self.gridLayout_14 = QtWidgets.QGridLayout(self.widget_3)
        self.gridLayout_14.setMargin(0)
        self.gridLayout_14.setObjectName(_fromUtf8("gridLayout_14"))
        self.gridLayout_13 = QtWidgets.QGridLayout()
        self.gridLayout_13.setObjectName(_fromUtf8("gridLayout_13"))
        self.label_4 = QtWidgets.QLabel(self.widget_3)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.gridLayout_13.addWidget(self.label_4, 0, 0, 1, 1)
        self.le_mainDb = QtWidgets.QLineEdit(self.widget_3)
        self.le_mainDb.setObjectName(_fromUtf8("le_mainDb"))
        self.gridLayout_13.addWidget(self.le_mainDb, 0, 1, 1, 1)
        self.pb_mainDb = QtWidgets.QPushButton(self.widget_3)
        self.pb_mainDb.setObjectName(_fromUtf8("pb_mainDb"))
        self.gridLayout_13.addWidget(self.pb_mainDb, 0, 2, 1, 1)
        self.label_5 = QtWidgets.QLabel(self.widget_3)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.gridLayout_13.addWidget(self.label_5, 1, 0, 1, 1)
        self.le_amendmentDb = QtWidgets.QLineEdit(self.widget_3)
        self.le_amendmentDb.setObjectName(_fromUtf8("le_amendmentDb"))
        self.gridLayout_13.addWidget(self.le_amendmentDb, 1, 1, 1, 1)
        self.pb_amendmentDb = QtWidgets.QPushButton(self.widget_3)
        self.pb_amendmentDb.setObjectName(_fromUtf8("pb_amendmentDb"))
        self.gridLayout_13.addWidget(self.pb_amendmentDb, 1, 2, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.widget_3)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.gridLayout_13.addWidget(self.label_6, 2, 0, 1, 1)
        self.le_exportDb = QtWidgets.QLineEdit(self.widget_3)
        self.le_exportDb.setObjectName(_fromUtf8("le_exportDb"))
        self.gridLayout_13.addWidget(self.le_exportDb, 2, 1, 1, 1)
        self.pb_exportDb = QtWidgets.QPushButton(self.widget_3)
        self.pb_exportDb.setObjectName(_fromUtf8("pb_exportDb"))
        self.gridLayout_13.addWidget(self.pb_exportDb, 2, 2, 1, 1)
        self.gridLayout_14.addLayout(self.gridLayout_13, 0, 0, 1, 1)
        spacerItem2 = QtWidgets.QSpacerItem(20, 38, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout_14.addItem(spacerItem2, 1, 0, 1, 1)
        self.l_status = QtWidgets.QLabel(self.widget_3)
        self.l_status.setText(_fromUtf8(""))
        self.l_status.setObjectName(_fromUtf8("l_status"))
        self.gridLayout_14.addWidget(self.l_status, 2, 0, 1, 1)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5"))
        self.progressBar_Changes = QtWidgets.QProgressBar(self.widget_3)
        self.progressBar_Changes.setProperty("value", 0)
        self.progressBar_Changes.setObjectName(_fromUtf8("progressBar_Changes"))
        self.horizontalLayout_5.addWidget(self.progressBar_Changes)
        self.pb_applyChanges = QtWidgets.QPushButton(self.widget_3)
        self.pb_applyChanges.setObjectName(_fromUtf8("pb_applyChanges"))
        self.horizontalLayout_5.addWidget(self.pb_applyChanges)
        self.gridLayout_14.addLayout(self.horizontalLayout_5, 3, 0, 1, 1)
        self.gridLayout_16.addWidget(self.widget_3, 0, 0, 1, 1)
        self.scrollArea_6.setWidget(self.scrollAreaWidgetContents_6)
        self.gridLayout_15.addWidget(self.scrollArea_6, 0, 0, 1, 1)
        self.stackedWidget.addWidget(self.changesPage)
        self.searchPage = QtWidgets.QWidget()
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.searchPage.sizePolicy().hasHeightForWidth())
        self.searchPage.setSizePolicy(sizePolicy)
        self.searchPage.setObjectName(_fromUtf8("searchPage"))
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.searchPage)
        self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
        self.label_3 = QtWidgets.QLabel(self.searchPage)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(sizePolicy)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.horizontalLayout_4.addWidget(self.label_3)
        self.searchCombo = QtWidgets.QComboBox(self.searchPage)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.searchCombo.sizePolicy().hasHeightForWidth())
        self.searchCombo.setSizePolicy(sizePolicy)
        self.searchCombo.setObjectName(_fromUtf8("searchCombo"))
        self.horizontalLayout_4.addWidget(self.searchCombo)
        self.verticalLayout_3.addLayout(self.horizontalLayout_4)
        self.searchForms = QtWidgets.QStackedWidget(self.searchPage)
        self.searchForms.setObjectName(_fromUtf8("searchForms"))
        self.page = QtWidgets.QWidget()
        self.page.setObjectName(_fromUtf8("page"))
        self.gridLayout = QtWidgets.QGridLayout(self.page)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.scrollArea = QtWidgets.QScrollArea(self.page)
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
        self.scrollAreaWidgetContents = QtWidgets.QWidget()
        self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 48, 28))
        self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
        self.gridLayout_5 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
        self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
        self.vlastniciSearchForm = VlastniciSearchForm(self.scrollAreaWidgetContents)
        self.vlastniciSearchForm.setObjectName(_fromUtf8("vlastniciSearchForm"))
        self.gridLayout_5.addWidget(self.vlastniciSearchForm, 0, 0, 1, 1)
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        self.gridLayout.addWidget(self.scrollArea, 0, 0, 1, 1)
        self.searchForms.addWidget(self.page)
        self.page_2 = QtWidgets.QWidget()
        self.page_2.setObjectName(_fromUtf8("page_2"))
        self.gridLayout_6 = QtWidgets.QGridLayout(self.page_2)
        self.gridLayout_6.setObjectName(_fromUtf8("gridLayout_6"))
        self.scrollArea_3 = QtWidgets.QScrollArea(self.page_2)
        self.scrollArea_3.setWidgetResizable(True)
        self.scrollArea_3.setObjectName(_fromUtf8("scrollArea_3"))
        self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 66, 28))
        self.scrollAreaWidgetContents_2.setObjectName(_fromUtf8("scrollAreaWidgetContents_2"))
        self.gridLayout_7 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_2)
        self.gridLayout_7.setObjectName(_fromUtf8("gridLayout_7"))
        self.parcelySearchForm = ParcelySearchForm(self.scrollAreaWidgetContents_2)
        self.parcelySearchForm.setObjectName(_fromUtf8("parcelySearchForm"))
        self.gridLayout_7.addWidget(self.parcelySearchForm, 0, 0, 1, 1)
        self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_2)
        self.gridLayout_6.addWidget(self.scrollArea_3, 0, 0, 1, 1)
        self.searchForms.addWidget(self.page_2)
        self.page_3 = QtWidgets.QWidget()
        self.page_3.setObjectName(_fromUtf8("page_3"))
        self.gridLayout_2 = QtWidgets.QGridLayout(self.page_3)
        self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
        self.scrollArea_2 = QtWidgets.QScrollArea(self.page_3)
        self.scrollArea_2.setWidgetResizable(True)
        self.scrollArea_2.setObjectName(_fromUtf8("scrollArea_2"))
        self.scrollAreaWidgetContents_3 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 66, 28))
        self.scrollAreaWidgetContents_3.setObjectName(_fromUtf8("scrollAreaWidgetContents_3"))
        self.gridLayout_3 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_3)
        self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
        self.budovySearchForm = BudovySearchForm(self.scrollAreaWidgetContents_3)
        self.budovySearchForm.setObjectName(_fromUtf8("budovySearchForm"))
        self.gridLayout_3.addWidget(self.budovySearchForm, 0, 0, 1, 1)
        self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_3)
        self.gridLayout_2.addWidget(self.scrollArea_2, 0, 0, 1, 1)
        self.searchForms.addWidget(self.page_3)
        self.page_4 = QtWidgets.QWidget()
        self.page_4.setObjectName(_fromUtf8("page_4"))
        self.gridLayout_8 = QtWidgets.QGridLayout(self.page_4)
        self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
        self.scrollArea_4 = QtWidgets.QScrollArea(self.page_4)
        self.scrollArea_4.setWidgetResizable(True)
        self.scrollArea_4.setObjectName(_fromUtf8("scrollArea_4"))
        self.scrollAreaWidgetContents_4 = QtWidgets.QWidget()
        self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 66, 28))
        self.scrollAreaWidgetContents_4.setObjectName(_fromUtf8("scrollAreaWidgetContents_4"))
        self.gridLayout_9 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents_4)
        self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
        self.jednotkySearchForm = JednotkySearchForm(self.scrollAreaWidgetContents_4)
        self.jednotkySearchForm.setObjectName(_fromUtf8("jednotkySearchForm"))
        self.gridLayout_9.addWidget(self.jednotkySearchForm, 0, 0, 1, 1)
        self.scrollArea_4.setWidget(self.scrollAreaWidgetContents_4)
        self.gridLayout_8.addWidget(self.scrollArea_4, 0, 0, 1, 1)
        self.searchForms.addWidget(self.page_4)
        self.verticalLayout_3.addWidget(self.searchForms)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem3)
        self.searchButton = QtWidgets.QPushButton(self.searchPage)
        self.searchButton.setObjectName(_fromUtf8("searchButton"))
        self.horizontalLayout.addWidget(self.searchButton)
        self.verticalLayout_3.addLayout(self.horizontalLayout)
        self.stackedWidget.addWidget(self.searchPage)
        self.widget_2 = QtWidgets.QWidget(self.splitter)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(3)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.widget_2.sizePolicy().hasHeightForWidth())
        self.widget_2.setSizePolicy(sizePolicy)
        self.widget_2.setObjectName(_fromUtf8("widget_2"))
        self.rightWidgetLayout = QtWidgets.QVBoxLayout(self.widget_2)
        self.rightWidgetLayout.setMargin(0)
        self.rightWidgetLayout.setObjectName(_fromUtf8("rightWidgetLayout"))
        self.vfkBrowser = VfkTextBrowser(self.widget_2)
        self.vfkBrowser.setObjectName(_fromUtf8("vfkBrowser"))
        self.rightWidgetLayout.addWidget(self.vfkBrowser)
        self.gridLayout_4.addWidget(self.splitter, 0, 1, 1, 1)
        MainApp.setWidget(self.centralWidget)
        self.actionVyhledavani = QtWidgets.QAction(MainApp)
        self.actionVyhledavani.setCheckable(True)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/search.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionVyhledavani.setIcon(icon)
        self.actionVyhledavani.setObjectName(_fromUtf8("actionVyhledavani"))
        self.actionImport = QtWidgets.QAction(MainApp)
        self.actionImport.setCheckable(True)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/db-add.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionImport.setIcon(icon1)
        self.actionImport.setObjectName(_fromUtf8("actionImport"))
        self.actionBack = QtWidgets.QAction(MainApp)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/arrowBack.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionBack.setIcon(icon2)
        self.actionBack.setObjectName(_fromUtf8("actionBack"))
        self.actionForward = QtWidgets.QAction(MainApp)
        self.actionForward.setEnabled(True)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/arrowForward.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionForward.setIcon(icon3)
        self.actionForward.setObjectName(_fromUtf8("actionForward"))
        self.actionExportLatex = QtWidgets.QAction(MainApp)
        self.actionExportLatex.setObjectName(_fromUtf8("actionExportLatex"))
        self.actionExportHtml = QtWidgets.QAction(MainApp)
        self.actionExportHtml.setObjectName(_fromUtf8("actionExportHtml"))
        self.actionSelectParInMap = QtWidgets.QAction(MainApp)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/selectPar.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionSelectParInMap.setIcon(icon4)
        self.actionSelectParInMap.setObjectName(_fromUtf8("actionSelectParInMap"))
        self.actionSelectBudInMap = QtWidgets.QAction(MainApp)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(_fromUtf8(":/selectBud.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionSelectBudInMap.setIcon(icon5)
        self.actionSelectBudInMap.setObjectName(_fromUtf8("actionSelectBudInMap"))
        self.actionCuzkPage = QtWidgets.QAction(MainApp)
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/cuzk.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionCuzkPage.setIcon(icon6)
        self.actionCuzkPage.setObjectName(_fromUtf8("actionCuzkPage"))
        self.actionShowInfoaboutSelection = QtWidgets.QAction(MainApp)
        self.actionShowInfoaboutSelection.setCheckable(True)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(_fromUtf8(":/showInfo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionShowInfoaboutSelection.setIcon(icon7)
        self.actionShowInfoaboutSelection.setObjectName(_fromUtf8("actionShowInfoaboutSelection"))
        self.actionShowHelpPage = QtWidgets.QAction(MainApp)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(_fromUtf8(":/vfkPlugin.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionShowHelpPage.setIcon(icon8)
        self.actionShowHelpPage.setObjectName(_fromUtf8("actionShowHelpPage"))
        self.actionZpracujZmeny = QtWidgets.QAction(MainApp)
        self.actionZpracujZmeny.setCheckable(True)
        icon9 = QtGui.QIcon()
        icon9.addPixmap(QtGui.QPixmap(_fromUtf8(":/applyChanges.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.actionZpracujZmeny.setIcon(icon9)
        self.actionZpracujZmeny.setObjectName(_fromUtf8("actionZpracujZmeny"))

        self.retranslateUi(MainApp)
        self.stackedWidget.setCurrentIndex(0)
        self.searchForms.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainApp)
Exemplo n.º 17
0
    def setAccions(self):
        act = qtWdg.QAction()
        act.setText("Defineix grup")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(self.defaultActions().addGroup)
        self.accions.afegirAccio('addGroup', act)

        act = qtWdg.QAction()
        act.setText("Afegeix capes Qgis")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))ic_beach_access_black_48dp
        act.triggered.connect(self.addLayersFromFile)
        self.accions.afegirAccio('addLayersFromFile', act)

        act = qtWdg.QAction()
        act.setText("Desa capes Qgis")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))ic_beach_access_black_48dp
        act.triggered.connect(self.saveLayersToFile)
        self.accions.afegirAccio('saveLayersToFile', act)

        act = qtWdg.QAction()
        act.setText("Canvia nom")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(
            self.renameGroupOrLayer)  # , type = Qt.DirectConnection)
        self.accions.afegirAccio('renameGroupOrLayer', act)

        #
        # TODO:
        # Sincronizar señales para que la segunda espere al final de la primera
        #

        # if self.atributs is not None:
        #   act.triggered.connect(lambda: self.atributs.tabTaula(self.currentLayer()))

        act = qtWdg.QAction()
        act.setText("Esborra capa o grup")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        if self.atributs is not None:
            act.triggered.connect(lambda: self.atributs.tancarTaules(
                qgCor.QgsLayerTreeUtils.collectMapLayersRecursive(
                    [self.currentNode()])))
        act.triggered.connect(self.removeGroupOrLayer)
        # No se usa defaultActions() porque elimina todos los seleccionados
        self.accions.afegirAccio('removeGroupOrLayer', act)

        act = qtWdg.QAction()
        act.setText("Enquadra capa")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(self.showLayerMap)
        self.accions.afegirAccio('showLayerMap', act)

        act = qtWdg.QAction()
        act.setText("Mostra contador elements")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(self.defaultActions().showFeatureCount)
        # act.setCheckable(True)
        # act.setChecked(False)
        self.accions.afegirAccio('showFeatureCount', act)

        act = qtWdg.QAction()
        act.setText("Mostra diagrama barres")
        act.triggered.connect(self.showBarChart)
        self.accions.afegirAccio('showBarChart', act)

        act = qtWdg.QAction()
        act.setText("Mostra taula dades")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(self.showFeatureTable)
        self.accions.afegirAccio('showFeatureTable', act)

        act = qtWdg.QAction()
        act.setText("Filtra elements")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(self.filterElements)
        self.accions.afegirAccio('filterElements', act)

        act = qtWdg.QAction()
        act.setText("Esborra filtre")
        # act.setIcon(QIcon(':/Icones/ic_file_upload_black_48dp.png'))
        act.triggered.connect(self.removeFilter)
        self.accions.afegirAccio('removeFilter', act)
Exemplo n.º 18
0
        #     # sourceSymbol.symbolLayers()[0].setDataDefinedProperty(
        #     #     QgsSymbolLayer.PropertyFillColor,
        #     #     QgsProperty.fromValue('#0080ff'))

        #     # Aplicar nueva simbología a la capa
        #     renderer = QgsSingleSymbolRenderer(sourceSymbol)
        #     capa.setRenderer(renderer)
        #     capa.setOpacity(0.55)
        #     capa.triggerRepaint()

        #     # Guardar los cambios en el proyecto
        #     leyenda.project.write()

        # Acciones de usuario para el menú

        act = qtWdg.QAction()
        act.setText("Read Map")
        act.triggered.connect(readMap)
        leyenda.accions.afegirAccio('readMap', act)

        act = qtWdg.QAction()
        act.setText("Test Map")
        act.triggered.connect(testMap)
        leyenda.accions.afegirAccio('testMap', act)

        act = qtWdg.QAction()
        act.setText("Save Map")
        act.triggered.connect(saveMap)
        leyenda.accions.afegirAccio('saveMap', act)

        # Adaptación del menú
    def __init__(self, parent, boundingbox):
        super(ExtentDialog, self).__init__(parent)
        self.setupUi(self)
        self.superParent = None
        temp = self.parent()
        if platform.system() != "Linux":
            font = QFont()
            font.setFamily(u"Segoe UI Symbol")
            self.setFont(font)
        while self.superParent is None:
            if issubclass(type(temp),
                          geographicinformationPanel.Ui_geographicinfo):
                self.superParent = temp
            else:
                temp = temp.parent()
        for info in self.findChildren(qwidgets.QPushButton,
                                      qcore.QRegExp('info_*')):
            info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg'))
            info.setText('')
            info.pressed.connect(self.printHelp)

        self.layers = []
        self.maxExt = None
        self.boundingbox = boundingbox
        self.outBB = False

        # Create MapCanvas
        self.canvas = gui.QgsMapCanvas(self)

        # Append to Dialog Layout
        self.toolBar = qwidgets.QToolBar()
        self.layout = qwidgets.QVBoxLayout(self.frame)
        self.layout.addWidget(self.toolBar)
        self.layout.addWidget(self.canvas)

        # Trigger on scaleChanged
        self.canvas.scaleChanged.connect(self.scaleChanged)
        # Trigger on renderStarting
        self.canvas.renderStarting.connect(self.renderStarting)

        # Create Map Tools
        actionFullExt = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/globe.svg'), "Mapa total",
            self)
        actionPan = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/pan.svg'), "Mover", self)
        actionZoomIn = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/zoom_in.svg'), "Aproximar",
            self)
        actionZoomOut = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/zoom_out.svg'), "Afastar",
            self)
        actionSelect = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/selection.svg'), 'Desenhar',
            self)
        actionFromLayer = qwidgets.QAction(
            qgui.QIcon(':/resourcesFolder/icons/layers.svg'),
            'Obter de camada', self)

        actionFullExt.setCheckable(False)
        actionPan.setCheckable(True)
        actionZoomIn.setCheckable(True)
        actionZoomOut.setCheckable(True)
        actionSelect.setCheckable(True)

        actionFullExt.triggered.connect(self.fullext)
        actionPan.triggered.connect(self.pan)
        actionZoomIn.triggered.connect(self.zoomIn)
        actionZoomOut.triggered.connect(self.zoomOut)
        actionSelect.triggered.connect(self.select)
        actionFromLayer.triggered.connect(self.chooseLayer)

        # Add to created ToolBar
        self.toolBar.addAction(actionFullExt)
        self.toolBar.addSeparator()
        self.toolBar.addAction(actionPan)
        self.toolBar.addAction(actionZoomIn)
        self.toolBar.addAction(actionZoomOut)
        self.toolBar.addAction(actionSelect)
        self.toolBar.addAction(actionFromLayer)

        self.toolFullExtent = gui.QgsMapToolPan(self.canvas)
        self.toolFullExtent.setAction(actionFullExt)
        self.toolPan = gui.QgsMapToolPan(self.canvas)
        self.toolPan.setAction(actionPan)
        self.toolZoomIn = gui.QgsMapToolZoom(self.canvas, False)  # false = in
        self.toolZoomIn.setAction(actionZoomIn)
        self.toolZoomOut = gui.QgsMapToolZoom(self.canvas, True)  # true = out
        self.toolZoomOut.setAction(actionZoomOut)
        self.toolSelect = SelectionTool(self.canvas, self)
        self.resourcebox.setChecked(True)
        self.pan()

        lugin_path = utils.pluginDirectory('EditorMetadadosMarswInforbiomares')

        # Load Vector
        layerpath = os.path.join(plugin_path, "resourcesFolder/World.shp")
        llayer = core.QgsVectorLayer(layerpath, "WorldLayer", "ogr")

        # Set Layer Symbology
        props = {
            'color_border': '0,0,0,125',
            'style': 'no',
            'style_border': 'solid'
        }
        #s = core.QgsFillSymbolV2.createSimple(props)
        s = core.QgsFillSymbol.createSimple(props)
        #llayer.setRendererV2(core.QgsSingleSymbolRendererV2(s))
        llayer.setRenderer(core.QgsSingleSymbolRenderer(s))

        # Set CRS - necessary to load Raster - it assumes this default CRS
        s = qcore.QSettings()
        oldValidation = str(
            s.value("/Projections/defaultBehaviour", "useGlobal"))
        s.setValue("/Projections/defaultBehaviour", "useGlobal")

        # Load Raster
        fileName = os.path.join(plugin_path, "resourcesFolder/GMRT.tif")
        fileInfo = qcore.QFileInfo(fileName)
        baseName = fileInfo.baseName()
        layer = core.QgsRasterLayer(fileName, baseName)
        layer.setCrs(
            core.QgsCoordinateReferenceSystem(
                4326, core.QgsCoordinateReferenceSystem.EpsgCrsId))
        s.setValue("/Projections/defaultBehaviour", oldValidation)

        # Set Raster ColorRamp
        # layer.setDrawingStyle("SingleBandPseudoColor") # deprecated remove in 2.1.0 please
        vmin = -5683.08
        vmax = 2763.86
        vrange = vmax - vmin
        vadd = vrange // 2
        vint = vmin + vadd
        colDic = {
            'brown': '#90330a',
            'lightblue': '#d5f5f9',
            'blue': '#2099d4'
        }
        valueList = [vmin, vint, vmax]

        lst = [core.QgsColorRampShader.ColorRampItem(valueList[0], qgui.QColor(colDic['blue'])), \
               core.QgsColorRampShader.ColorRampItem(valueList[1],
                                                     qgui.QColor(colDic['lightblue'])), \
               core.QgsColorRampShader.ColorRampItem(valueList[2], qgui.QColor(colDic['brown']))]
        myRasterShader = core.QgsRasterShader()
        myColorRamp = core.QgsColorRampShader()
        myColorRamp.setColorRampItemList(lst)
        myColorRamp.setColorRampType(core.QgsColorRampShader.Interpolated)
        myRasterShader.setRasterShaderFunction(myColorRamp)
        myPseudoRenderer = core.QgsSingleBandPseudoColorRenderer(
            layer.dataProvider(), layer.type(), myRasterShader)
        layer.setRenderer(myPseudoRenderer)

        ## Add vector to map
        #core.QgsMapLayerRegistry.instance().addMapLayer(llayer, False)
        core.QgsProject.instance().addMapLayer(llayer, False)
        ## Add raster to map
        #core.QgsMapLayerRegistry.instance().addMapLayer(layer, False)
        core.QgsProject.instance().addMapLayer(layer, False)

        ## Save Max Extent
        self.maxExt = core.QgsRectangle(-180., -90., 180., 90.)

        # ----------------------------------
        ## Set initial general extent to ZEE or, if one is selected, from the selected boundingbox
        if self.boundingbox.selectionModel().hasSelection() == False:
            ## Change button's title
            self.add_extent.setText(u"Adicionar")
            initialrect = core.QgsRectangle(-46.63064, 22.52146, 9.64473,
                                            47.31826)
        else:
            ## Get selected bounding box coords and resource flag
            index = self.boundingbox.selectionModel().selectedRows()[0].row()
            row = self.boundingbox.model().matrix[index]

            minx = float(row[0].replace(',', '.'))
            miny = float(row[3].replace(',', '.'))
            maxx = float(row[1].replace(',', '.'))
            maxy = float(row[2].replace(',', '.'))

            if minx == 0. and miny == 0. and maxx == 0. and maxy == 0.:
                initialrect = core.QgsRectangle(-46.63064, 22.52146, 9.64473,
                                                47.31826)
            else:
                ## Set fields with these values
                self.xMin.setValue(minx)
                self.xMax.setValue(maxx)
                self.yMin.setValue(miny)
                self.yMax.setValue(maxy)
                self.resourcebox.setChecked(bool(row[4]))

                ## Set the extent and add a bit of zoom out of the selected extent
                initialrect = core.QgsRectangle(minx - minx * 0.1,
                                                miny - miny * 0.1,
                                                maxx + maxx * 0.1,
                                                maxy + maxy * 0.1)

                ## Draw initial extent on the map
                self.toolSelect.drawRect(minx, miny, maxx, maxy)

                ## Change button's title
                self.add_extent.setText(u"Alterar")

        self.canvas.setExtent(initialrect)
        # ----------------------------------

        ## Append layers to MapCanvas
        self.layers.append(llayer)
        self.layers.append(layer)
        #self.layers.append(gui.QgsMapCanvasLayer(llayer))
        #self.layers.append(gui.QgsMapCanvasLayer(layer))
        #self.canvas.setLayerSet(self.layers)
        self.canvas.setLayers([llayer, layer])

        ## Set triggers to buttons
        self.add_extent.clicked.connect(self.add_new_extent)
        self.btn_close.clicked.connect(lambda: self.done(QDialog.Rejected))
        self.finished.connect(self.cleanup)

        ## Disabled coord fields
        self.xMin.setEnabled(False)
        self.xMax.setEnabled(False)
        self.yMin.setEnabled(False)
        self.yMax.setEnabled(False)
Exemplo n.º 20
0
    def add_action(self,
                   icon_path,
                   text,
                   callback,
                   enabled_flag=True,
                   add_to_menu=True,
                   add_to_toolbar=True,
                   status_tip=None,
                   whats_this=None,
                   parent=None):
        """Add a toolbar icon to the toolbar.

        :param icon_path: Path to the icon for this action. Can be a resource
            path (e.g. ':/plugins/foo/bar.png') or a normal file system path.
        :type icon_path: str

        :param text: Text that should be shown in menu items for this action.
        :type text: str

        :param callback: Function to be called when the action is triggered.
        :type callback: function

        :param enabled_flag: A flag indicating if the action should be enabled
            by default. Defaults to True.
        :type enabled_flag: bool

        :param add_to_menu: Flag indicating whether the action should also
            be added to the menu. Defaults to True.
        :type add_to_menu: bool

        :param add_to_toolbar: Flag indicating whether the action should also
            be added to the toolbar. Defaults to True.
        :type add_to_toolbar: bool

        :param status_tip: Optional text to show in a popup when mouse pointer
            hovers over the action.
        :type status_tip: str

        :param parent: Parent widget for the new action. Defaults None.
        :type parent: QWidget

        :param whats_this: Optional text to show in the status bar when the
            mouse pointer hovers over the action.

        :returns: The action that was created. Note that the action is also
            added to self.actions list.
        :rtype: QAction
        """

        # Create the dialog (after translation) and keep reference
        # self.dlg = GpxSegmentImporterDialog()

        icon = QIcon(icon_path)
        action = QtWidgets.QAction(icon, text, parent)
        action.triggered.connect(callback)
        action.setEnabled(enabled_flag)

        if status_tip is not None:
            action.setStatusTip(status_tip)

        if whats_this is not None:
            action.setWhatsThis(whats_this)

        if add_to_toolbar:
            self.toolbar.addAction(action)

        if add_to_menu:
            self.iface.addPluginToMenu(self.menu, action)

        self.actions.append(action)

        return action