Esempio n. 1
0
    def initUI(self):
        dir = PathClass()

        pixmap = QPixmap(os.path.join(dir.getPath(), 'icons\hidrantes.svg'))
        self.dp_hid_1.setPixmap(pixmap)

        pixmap_2 = QPixmap(
            os.path.join(dir.getPath(), 'icons\hidrante_vista.svg'))
        self.dp_hid_2.setPixmap(pixmap_2)

        pixmap_3 = QPixmap(
            os.path.join(dir.getPath(), 'icons\camara_limpieza.svg'))
        self.dp_hid_3.setPixmap(pixmap_3)

        pixmap_4 = QPixmap(
            os.path.join(dir.getPath(), 'icons\grifo_publico.svg'))
        self.dp_hid_4.setPixmap(pixmap_4)

        pixmap_5 = QPixmap(
            os.path.join(dir.getPath(), 'icons/valvula_aire.svg'))
        self.dp_hid_5.setPixmap(pixmap_5)

        pixmap_6 = QPixmap(os.path.join(dir.getPath(), 'icons/boca_riego.svg'))
        self.dp_hid_6.setPixmap(pixmap_6)

        pixmap_7 = QPixmap(os.path.join(dir.getPath(),
                                        'icons/valvula_seg.svg'))
        self.dp_hid_7.setPixmap(pixmap_7)

        pixmap_8 = QPixmap(
            os.path.join(dir.getPath(), 'icons/val_con_golpe.svg'))
        self.dp_hid_8.setPixmap(pixmap_8)

        pixmap_9 = QPixmap(
            os.path.join(dir.getPath(), 'icons/tanque_hidron.svg'))
        self.dp_hid_9.setPixmap(pixmap_9)

        pixmap_10 = QPixmap(
            os.path.join(dir.getPath(), 'icons\camara_rompec.svg'))
        self.dp_hid_10.setPixmap(pixmap_10)

        pixmap_11 = QPixmap(
            os.path.join(dir.getPath(), 'icons/valv_reg_presion.svg'))
        self.dp_hid_11.setPixmap(pixmap_11)

        pixmap_12 = QPixmap(
            os.path.join(dir.getPath(), 'icons/valv_reg_caudal.svg'))
        self.dp_hid_12.setPixmap(pixmap_12)

        pixmap_13 = QPixmap(
            os.path.join(dir.getPath(), 'icons/medidor_caudal.svg'))
        self.dp_hid_13.setPixmap(pixmap_13)
    def initGui(self):
        icon = QIcon()
        icon.addPixmap(
            QPixmap(
                "C:/Roberto/Visual_Studio_Code/GisBike/programa/IMG/Qgis.png"),
            QIcon.Normal, QIcon.Off)
        self.setWindowIcon(icon)
        self.setWindowModality(Qt.WindowModal)
        self.setWindowFlags(Qt.Window
                            | Qt.WindowSystemMenuHint
                            | Qt.WindowMinimizeButtonHint
                            | Qt.WindowMaximizeButtonHint
                            | Qt.WindowCloseButtonHint)

        self.resize(1200, 600)

        self.verticalLayout_2 = QVBoxLayout(self)
        self.splitter = QSplitter(self)
        self.splitter.setOrientation(Qt.Horizontal)

        self.actionZoomIn = QPushButton("Zoom in", self.splitter)
        self.actionZoomOut = QPushButton("Zoom out", self.splitter)
        self.actionPan = QPushButton("Pan", self.splitter)
        self.actionFile = QPushButton("File", self.splitter)

        self.project = QgsProject.instance()
        self.project.read('C:/Users/Fcc/Desktop/QGis/pruebas2.qgz')
        self.root = QgsProject.instance().layerTreeRoot()
        self.bridge = QgsLayerTreeMapCanvasBridge(self.root, self.canvas)

        self.bridge.setCanvasLayers()
        self.bridge.setAutoSetupOnFirstLayer(True)

        #https://gis.stackexchange.com/questions/141516/adding-legend-to-canvas-in-standalone-pyqgis-application
        self.model = QgsLayerTreeModel(self.root)
        self.model.setFlag(QgsLayerTreeModel.AllowNodeReorder)
        self.model.setFlag(QgsLayerTreeModel.AllowNodeRename)
        self.model.setFlag(QgsLayerTreeModel.AllowNodeChangeVisibility)
        self.model.setFlag(QgsLayerTreeModel.ShowLegend)
        self.view = QgsLayerTreeView(self.splitter)
        self.view.setModel(self.model)
        self.view.setFixedWidth(150)
        #self.view.resize(150,600)

        self.widget = QWidget(self.splitter)
        self.verticalLayout = QVBoxLayout(self.widget)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.addWidget(self.actionZoomIn)
        self.horizontalLayout.addWidget(self.actionZoomOut)
        self.horizontalLayout.addWidget(self.actionPan)
        self.horizontalLayout.addWidget(self.actionFile)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.verticalLayout.addWidget(self.canvas)
        self.verticalLayout_2.addWidget(self.splitter)

        self.actionZoomIn.clicked.connect(self.zoomIn)
        self.actionZoomOut.clicked.connect(self.zoomOut)
        self.actionPan.clicked.connect(self.pan)
        self.actionFile.clicked.connect(self.file)

        # create the map tools
        self.toolPan = QgsMapToolPan(self.canvas)
        self.toolZoomIn = QgsMapToolZoom(self.canvas, False)  # false = in
        self.toolZoomOut = QgsMapToolZoom(self.canvas, True)  # true = out
Esempio n. 3
0
    def __init__(self, parent):
        super().__init__(parent)
        
        self.canvas = iface.mapCanvas()
        self.dlg = BazaWMSDialog()
        self.curServiceData = None

        self.project = QgsProject.instance()
        #Load WMS services list from json file
        with open(path.join(path.dirname(__file__), 'services.json'), encoding='utf-8') as servicesJson:
            self.services = json.load(servicesJson)

        #Models
        servicesProxyModel = ServicesProxyModel()
        servicesProxyModel.sort(0)
        servicesProxyModel.setSourceModel(ServicesTableModel())
        self.dlg.servicesTableView.setModel(servicesProxyModel)
        self.servicesTableModel = self.dlg.servicesTableView.model().sourceModel()
        self.dlg.servicesTableView.setSortingEnabled(False)


        #Initialize table headers
        self.dlg.servicesTableView.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)
        self.dlg.servicesTableView.horizontalHeader().setSectionResizeMode(1, QHeaderView.Interactive)
        self.dlg.servicesTableView.horizontalHeader().setSectionResizeMode(2, QHeaderView.Interactive)
        self.dlg.servicesTableView.horizontalHeader().setSectionResizeMode(3, QHeaderView.Stretch)
        self.dlg.servicesTableView.horizontalHeader().resizeSection(1, 100)
        self.dlg.servicesTableView.horizontalHeader().resizeSection(2, 250)

        self.dlg.layersTableWidget.setHorizontalHeaderLabels(['Nr', 'Nazwa', 'Tytuł', 'Streszczenie'])
        self.dlg.layersTableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeToContents)
        self.dlg.layersTableWidget.setColumnCount(4)
        self.dlg.layersTableWidget.setColumnWidth(0, 20)
        self.dlg.layersTableWidget.setColumnWidth(1, 70)
        self.dlg.layersTableWidget.setColumnWidth(2, 170)
        self.dlg.layersTableWidget.setColumnWidth(3, 170)
        self.dlg.layersTableWidget.setColumnWidth(4, 90)

        #Connect slots to signals
        self.dlg.searchLineEdit.textChanged.connect(servicesProxyModel.setFilterRegExp)
        self.dlg.getLayersButton.clicked.connect(self.loadLayers)
        self.dlg.servicesTableView.doubleClicked.connect(self.loadLayers)
        self.dlg.layersTableWidget.itemSelectionChanged.connect(self.enableAddToMap)
        self.dlg.layersTableWidget.doubleClicked.connect(self.addToMap)
        self.dlg.addLayersButton.clicked.connect(self.addToMap)

        self.updateServicesList()
        
        #Zarejestrowanie we wtyczce

        self.dlg.lblInfo.setPixmap(QPixmap(':/plugins/plugin/info.png'))
        self.dlg.lblInfo.setToolTip((
            "Brakuje adresu WMS, którego szukasz?\n"
            "Napisz do nas: [email protected]"))
        
        self.parent.add_action(
            ":/plugins/gissupport_plugin/wms/wms.svg",
            self.module_name,
            callback = self.dlg.show,
            checkable = False,
            parent = iface.mainWindow(),
            add_to_topmenu=True 
        )
    def __init__(self, canvas, layer):

        super(QgsMapToolIdentify, self).__init__(canvas)
        self.canvas = canvas
        self.layer = layer
        self.cursor = QCursor(QPixmap(Cursor), 1, 6)
Esempio n. 5
0
    def set_widgets(self):
        """Set widgets on the Aggregation Layer From Browser tab."""
        self.tvBrowserAggregation_selection_changed()

        # Set icon
        self.lblIconIFCWAggregationFromBrowser.setPixmap(QPixmap(None))
Esempio n. 6
0
 def set_widgets(self):
     """Set widgets on the Aggregation Layer Disjoint tab."""
     self.lblIconDisjoint_2.setPixmap(
         QPixmap(resources_path('img', 'wizard', 'icon-stop.svg')))
Esempio n. 7
0
 def __init__(self):
     super(NewSplashScreen, self).__init__()
     self.setPixmap(QPixmap('./images/splash.png'))
Esempio n. 8
0
 def set_icon(self, icon_path):
     self.__ds_icon = icon_path
     self.iconPreview.setPixmap(QPixmap(self.__ds_icon))
 def setDataPublished(self, server):
     self.labelData.setPixmap(QPixmap(self.iconPath(server)))
 def iconDownloaded(self, reply):
     img = QImage()
     img.loadFromData(reply.readAll())
     pixmap = QPixmap(img)
     thumb = pixmap.scaled(48, 48, Qt.KeepAspectRatio, Qt.SmoothTransformation)
     self.iconLabel.setPixmap(thumb)
Esempio n. 11
0
    def initUI(self):
        dir = PathClass()

        pixmap = QPixmap(os.path.join(dir.getPath(), 'icons\DP.svg'))
        self.dp_inicio_1.setPixmap(pixmap)

        pixmap_pp = QPixmap(os.path.join(dir.getPath(), 'icons\PP.svg'))
        self.pp_inicio_2.setPixmap(pixmap_pp)

        pixmap_te = QPixmap(os.path.join(dir.getPath(), 'icons\TE.svg'))
        self.te_inicio_3.setPixmap(pixmap_te)

        pixmap_ts = QPixmap(os.path.join(dir.getPath(), 'icons\TS.svg'))
        self.ts_inicio_4.setPixmap(pixmap_ts)

        pixmap_tp = QPixmap(os.path.join(dir.getPath(), 'icons\TP.svg'))
        self.tp_inicio_5.setPixmap(pixmap_tp)

        pixmap_rs = QPixmap(os.path.join(dir.getPath(), 'icons\RS.svg'))
        self.rs_inicio_6.setPixmap(pixmap_rs)

        pixmap_rd = QPixmap(os.path.join(dir.getPath(), 'icons\RD.svg'))
        self.rd_inicio_7.setPixmap(pixmap_rd)

        pixmap_ve = QPixmap(os.path.join(dir.getPath(), 'icons\VE.svg'))
        self.ve_inicio_8.setPixmap(pixmap_ve)

        pixmap_vm = QPixmap(os.path.join(dir.getPath(), 'icons\VM.png'))
        self.vm_inicio_9.setPixmap(pixmap_vm)

        pixmap_vr = QPixmap(os.path.join(dir.getPath(), 'icons\VR.png'))
        self.vr_inicio_10.setPixmap(pixmap_vr)

        pixmap_vg = QPixmap(os.path.join(dir.getPath(), 'icons\VG.svg'))
        self.vg_inicio_11.setPixmap(pixmap_vg)
Esempio n. 12
0
 def __init__(self, canvas, button):
     QgsMapTool.__init__(self,canvas)
     self.canvas = canvas
     #self.cursor = QCursor(Qt.CrossCursor)
     self.cursor = QCursor(QPixmap(identify_cursor), 1, 1)
     self.button = button
Esempio n. 13
0
    def __init__(self, parent, interface, drawTool, projectHandler):
        """
        :type drawTool: gui.mapMarker.MapMarkerTool
        :type projectHandler: projectHandler.ProjectConfHandler
        """
        QDialog.__init__(self, parent)
        self.iface = interface
        self.projectHandler = projectHandler
        self.drawTool = drawTool
        self.setWindowTitle(self.tr('Gelaendelinie'))
        self.setWindowModality(Qt.WindowModal)
        
        self.profile = None
        # Array with properties fixed poles
        self.poleData = []
        # Array with sections without poles
        self.noPoleSection = []
        # Profile data
        self.xdata = None
        self.zdata = None
        self.profileMin = 0
        self.profileMax = None

        # Plot
        self.sc = ProfilePlot(self)
        # Pan/Zoom Tools for diagram
        tbar = MyNavigationToolbar(self.sc, self)
        tbar.pan()
        self.sc.setToolbar(tbar)

        # Layout
        main_widget = QWidget(self)
        self.container = QVBoxLayout(main_widget)
        self.outerLayout = QVBoxLayout()

        # GUI fields
        stueTitle = QLabel('<b>' + self.tr('Stuetzenoptimierung einschraenken') + '</b>')
        hbox = QHBoxLayout()
        line1 = QFrame()
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        # Create labels and buttons
        self.fixStueAdd = QPushButton(self.tr('Fixe Stuetze definieren'))
        self.noStueAdd = QPushButton(self.tr('Abschnitt ohne Stuetzen definieren'))
        self.noStueDel = QPushButton()
        icon = QIcon()
        icon.addPixmap(
            QPixmap(':/plugins/SeilaplanPlugin/gui/icons/icon_bin.png'),
            QIcon.Normal, QIcon.Off)
        self.noStueDel.setIcon(icon)
        self.noStueDel.setIconSize(QSize(16, 16))
        self.fixStueAdd.setToolTip(self.tr('Tooltip Fixe Stuetzen'))
        self.noStueAdd.setToolTip(self.tr('Tooltip Abschnitte ohne Stuetzen'))
        self.noStueDel.setToolTip(self.tr('Tooltip Abschnitte loeschen'))
        spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                        QSizePolicy.Minimum)
        hbox.addWidget(self.fixStueAdd)
        hbox.addItem(spacerItem1)
        hbox.addWidget(self.noStueAdd)
        hbox.addWidget(self.noStueDel)
        hbox.setAlignment(self.noStueAdd, Qt.AlignRight)
        btnBoxSpacer = QSpacerItem(40, 40, QSizePolicy.Fixed,
                                        QSizePolicy.Fixed)
        self.buttonBox = QDialogButtonBox(main_widget)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        # Build up Gui
        self.container.addWidget(self.sc)
        self.container.addWidget(tbar, alignment=Qt.AlignHCenter | Qt.AlignTop)
        self.container.addWidget(line1)
        self.container.addWidget(stueTitle)
        self.container.addLayout(hbox)
        self.container.addLayout(self.outerLayout)
        self.container.addItem(btnBoxSpacer)
        self.container.addWidget(self.buttonBox)

        # Connect signals
        self.fixStueAdd.clicked.connect(self.sc.acitvateCrosshairPole)
        self.noStueAdd.clicked.connect(self.sc.activateCrosshairSection)
        self.noStueDel.clicked.connect(self.deleteSections)
        self.buttonBox.accepted.connect(self.Apply)
        self.setLayout(self.container)
        
        # Gui's functionality for fixed pole gui fields
        self.buildPoleHeader()
        self.poleLayout = CustomPoleWidget(self, self.outerLayout, self.poleData)
        self.poleLayout.sig_updatePole.connect(self.updatePole)
        self.poleLayout.sig_deletePole.connect(self.deletePole)
Esempio n. 14
0
    def onAbout(self):
        self.about_dlg = QWidget()
        vlayout = QVBoxLayout()
        l = QLabel("""
        <h1>QGIS GML Application Schema Toolbox</h1>
        <h3>Version: {}</h3>
        <p>This plugin is a prototype aiming at experimenting with the manipulation of <b>Complex Features</b> streams.</p>
        <p>Two modes are available:
        <ul><li>A mode where the <b>initial XML hierarchical view</b> is preserved. In this mode, an XML instance
        is represented by a unique QGIS vector layer with a column that stores the XML subtree for each feature.
        Augmented tools are available to identify a feature or display the attribute table of the layer.</li>
        <li>A mode where the XML hierarchical data is first <b>converted to a relational database</b>.
        In this mode, the data is spread accross different QGIS layers. Links between tables are declared
        as QGIS relations and "relation reference" widgets. It then allows to use the standard QGIS attribute
        table (in "forms" mode) to navigate the relationel model.</li>
        </ul>
        <p>Custom Qt-based viewers can be run on XML elements of given types.</p>

        <p>Teams involved in the development of the current plugin:
        <ul>
        <li><a href="http://www.oslandia.com">Oslandia</a> (current version of the QGIS plugin, and first proof of concept)</li>
        <li><a href="http://www.spatialys.com">Spatialys</a> (GMLAS driver in OGR)</li>
        <li><a href="http://www.camptocamp.com">camptocamp</a> (former version of the plugin)</li>
        </ul>
        </p>
        <p>Funders involved:
        <ul>
        <li><a href="http://www.brgm.fr">BRGM</a></li>
        <li><a href="https://www.eea.europa.eu/">European Environment Agency</a> (Copernicus funding)</li>
        <li><b>The Association of Finnish Local and Regional Authorities</b> (through <a href="http://www.gispo.fi">Gispo.fi</a>)</li>
        </ul>
        </p>
        """.format(plugin_version()))
        l.setWordWrap(True)
        vlayout.addWidget(l)
        hlayout = QHBoxLayout()
        hlayout2 = QHBoxLayout()
        l2 = QLabel()
        l2.setPixmap(
            QPixmap(os.path.join(os.path.dirname(__file__),
                                 "logo_brgm.svg")).scaledToWidth(
                                     200, Qt.SmoothTransformation))
        l3 = QLabel()
        l3.setPixmap(
            QPixmap(os.path.join(os.path.dirname(__file__),
                                 "logo_eea.png")).scaledToWidth(
                                     200, Qt.SmoothTransformation))
        l4 = QLabel()
        l4.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(__file__),
                             "logo_oslandia.png")).scaledToWidth(
                                 150, Qt.SmoothTransformation))
        l5 = QLabel()
        l5.setPixmap(
            QPixmap(
                os.path.join(os.path.dirname(__file__),
                             "logo_spatialys.png")).scaledToWidth(
                                 100, Qt.SmoothTransformation))
        l6 = QLabel()
        l6.setPixmap(
            QPixmap(os.path.join(os.path.dirname(__file__),
                                 "logo_c2c.svg")).scaledToWidth(
                                     100, Qt.SmoothTransformation))
        hlayout.addWidget(l2)
        hlayout.addWidget(l3)
        vlayout.addLayout(hlayout)
        hlayout2.addWidget(l4)
        hlayout2.addWidget(l5)
        hlayout2.addWidget(l6)
        vlayout.addLayout(hlayout2)
        self.about_dlg.setLayout(vlayout)
        self.about_dlg.setWindowTitle(plugin_name())
        self.about_dlg.setWindowModality(Qt.WindowModal)
        self.about_dlg.show()
        self.about_dlg.resize(600, 800)
    def photoDetails_field(self, restrictionDialog, currRestrictionLayer, currRestriction):

        # Function to deal with photo fields

        self.demandDialog = restrictionDialog
        self.currDemandLayer = currRestrictionLayer
        self.currFeature = currRestriction

        TOMsMessageLog.logMessage("In photoDetails", level=Qgis.Info)

        photoPath = QgsExpressionContextUtils.projectScope(QgsProject.instance()).variable('PhotoPath')
        projectFolder = QgsExpressionContextUtils.projectScope(QgsProject.instance()).variable('project_folder')

        path_absolute = os.path.join(projectFolder, photoPath)

        if path_absolute == None:
            reply = QMessageBox.information(None, "Information", "Please set value for PhotoPath.", QMessageBox.Ok)
            return

        # Check path exists ...
        if os.path.isdir(path_absolute) == False:
            reply = QMessageBox.information(None, "Information", "PhotoPath folder " + str(
                path_absolute) + " does not exist. Please check value.", QMessageBox.Ok)
            return

        # if cv2 is available, check camera nr
        try:
            cameraNr = int(self.params.setParam("CameraNr"))
        except Exception as e:
            TOMsMessageLog.logMessage("In photoDetails_field: cameraNr issue: {}".format(e), level=Qgis.Info)
            if cv2_available:
                cameraNr = QMessageBox.information(None, "Information", "Please set value for CameraNr.", QMessageBox.Ok)
            cameraNr = None

        TOMsMessageLog.logMessage("In photoDetails_field: cameraNr is: {}".format(cameraNr), level=Qgis.Info)

        layerName = self.currDemandLayer.name()

        # Generate the full path to the file

        fileName1 = "Photos_01"
        fileName2 = "Photos_02"
        fileName3 = "Photos_03"

        idx1 = self.currDemandLayer.fields().indexFromName(fileName1)
        idx2 = self.currDemandLayer.fields().indexFromName(fileName2)
        idx3 = self.currDemandLayer.fields().indexFromName(fileName3)

        TOMsMessageLog.logMessage("In photoDetails. idx1: " + str(idx1) + "; " + str(idx2) + "; " + str(idx3),
                                 level=Qgis.Info)

        if cameraNr is not None:
            TOMsMessageLog.logMessage("Camera TRUE", level=Qgis.Info)
            takePhoto = True
        else:
            TOMsMessageLog.logMessage("Camera FALSE", level=Qgis.Info)
            takePhoto = False

        FIELD1 = self.demandDialog.findChild(QLabel, "Photo_Widget_01")
        FIELD2 = self.demandDialog.findChild(QLabel, "Photo_Widget_02")
        FIELD3 = self.demandDialog.findChild(QLabel, "Photo_Widget_03")

        if FIELD1:
            TOMsMessageLog.logMessage("In photoDetails. FIELD 1 exists",
                                     level=Qgis.Info)
            if self.currFeature[idx1]:
                newPhotoFileName1 = os.path.join(path_absolute, self.currFeature[idx1])
                TOMsMessageLog.logMessage("In photoDetails. photo1: {}".format(newPhotoFileName1), level=Qgis.Info)
            else:
                newPhotoFileName1 = None

            pixmap1 = QPixmap(newPhotoFileName1)
            if pixmap1.isNull():
                pass
                # FIELD1.setText('Picture could not be opened ({path})'.format(path=newPhotoFileName1))
            else:

                tab = FIELD1.parentWidget()
                grid = FIELD1.parentWidget().layout()

                photo_Widget1 = imageLabel(tab)
                TOMsMessageLog.logMessage(
                    "In photoDetails. FIELD 1 w: {}; h: {}".format(FIELD1.width(), FIELD1.height()), level=Qgis.Info)
                photo_Widget1.setObjectName("Photo_Widget_01")
                photo_Widget1.setText("No photo is here")
                #photo_Widget1 = imageLabel(tab)
                grid.addWidget(photo_Widget1, 0, 0, 1, 1)

                FIELD1.hide()
                FIELD1.setParent(None)
                FIELD1 = photo_Widget1
                FIELD1.set_Pixmap(pixmap1)

                TOMsMessageLog.logMessage("In photoDetails. FIELD 1 Photo1: " + str(newPhotoFileName1), level=Qgis.Info)
                TOMsMessageLog.logMessage("In photoDetails.pixmap1 size: {}".format(pixmap1.size()),
                                          level=Qgis.Info)

                FIELD1.pixmapUpdated.connect(functools.partial(self.displayPixmapUpdated, FIELD1))
                #ZOOM_IN_1 = self.demandDialog.findChild(QPushButton, "pb_zoomIn_01")
                #ZOOM_IN_1.clicked.connect(FIELD1._zoomInButton)

                #ZOOM_OUT_1 = self.demandDialog.findChild(QPushButton, "pb_zoomOut_01")
                #ZOOM_OUT_1.clicked.connect(FIELD1._zoomOutButton)

            if takePhoto:
                START_CAMERA_1 = self.demandDialog.findChild(QPushButton, "startCamera1")
                TAKE_PHOTO_1 = self.demandDialog.findChild(QPushButton, "getPhoto1")
                TAKE_PHOTO_1.setEnabled(False)

                self.camera1 = formCamera(path_absolute, newPhotoFileName1, cameraNr)
                START_CAMERA_1.clicked.connect(
                    functools.partial(self.camera1.useCamera, START_CAMERA_1, TAKE_PHOTO_1, FIELD1))
                self.camera1.notifyPhotoTaken.connect(functools.partial(self.savePhotoTaken, idx1))

        if FIELD2:
            TOMsMessageLog.logMessage("In photoDetails. FIELD 2 exisits",
                                     level=Qgis.Info)
            if self.currFeature[idx2]:
                newPhotoFileName2 = os.path.join(path_absolute, self.currFeature[idx2])
                TOMsMessageLog.logMessage("In photoDetails. Photo1: " + str(newPhotoFileName2), level=Qgis.Info)
            else:
                newPhotoFileName2 = None

            # newPhotoFileName2 = os.path.join(path_absolute, str(self.currFeature[idx2]))
            # newPhotoFileName2 = os.path.join(path_absolute, str(self.currFeature.attribute(fileName2)))
            # TOMsMessageLog.logMessage("In photoDetails. Photo2: " + str(newPhotoFileName2), level=Qgis.Info)
            pixmap2 = QPixmap(newPhotoFileName2)
            if pixmap2.isNull():
                pass
                # FIELD1.setText('Picture could not be opened ({path})'.format(path=newPhotoFileName1))
            else:

                tab = FIELD2.parentWidget()
                grid = FIELD2.parentWidget().layout()

                photo_Widget2 = imageLabel(tab)
                TOMsMessageLog.logMessage(
                    "In photoDetails. FIELD 2 w: {}; h: {}".format(FIELD2.width(), FIELD2.height()), level=Qgis.Info)
                photo_Widget2.setObjectName("Photo_Widget_02")
                photo_Widget2.setText("No photo is here")
                #photo_Widget2 = imageLabel(tab)
                grid.addWidget(photo_Widget2, 0, 0, 1, 1)

                FIELD2.hide()
                FIELD2.setParent(None)
                FIELD2 = photo_Widget2
                FIELD2.set_Pixmap(pixmap2)

                TOMsMessageLog.logMessage("In photoDetails. FIELD 2 Photo2: " + str(newPhotoFileName2), level=Qgis.Info)
                TOMsMessageLog.logMessage("In photoDetails.pixmap2 size: {}".format(pixmap2.size()),
                                          level=Qgis.Info)

                FIELD2.pixmapUpdated.connect(functools.partial(self.displayPixmapUpdated, FIELD2))
                #ZOOM_IN_2 = self.demandDialog.findChild(QPushButton, "pb_zoomIn_02")
                #ZOOM_IN_2.clicked.connect(FIELD2._zoomInButton)

                #ZOOM_OUT_2 = self.demandDialog.findChild(QPushButton, "pb_zoomOut_02")
                #ZOOM_OUT_2.clicked.connect(FIELD2._zoomOutButton)

                """
                FIELD2.setPixmap(pixmap2)
                FIELD2.setScaledContents(True)
                TOMsMessageLog.logMessage("In photoDetails. Photo2: " + str(newPhotoFileName2), level=Qgis.Info)"""

            if takePhoto:
                START_CAMERA_2 = self.demandDialog.findChild(QPushButton, "startCamera2")
                TAKE_PHOTO_2 = self.demandDialog.findChild(QPushButton, "getPhoto2")
                TAKE_PHOTO_2.setEnabled(False)

                self.camera2 = formCamera(path_absolute, newPhotoFileName2, cameraNr)
                START_CAMERA_2.clicked.connect(
                    functools.partial(self.camera2.useCamera, START_CAMERA_2, TAKE_PHOTO_2, FIELD2))
                self.camera2.notifyPhotoTaken.connect(functools.partial(self.savePhotoTaken, idx2))

        if FIELD3:
            TOMsMessageLog.logMessage("In photoDetails. FIELD 3 exisits",
                                     level=Qgis.Info)

            if self.currFeature[idx3]:
                newPhotoFileName3 = os.path.join(path_absolute, self.currFeature[idx3])
                TOMsMessageLog.logMessage("In photoDetails. Photo1: " + str(newPhotoFileName3), level=Qgis.Info)
            else:
                newPhotoFileName3 = None

            # newPhotoFileName3 = os.path.join(path_absolute, str(self.currFeature[idx3]))
            # newPhotoFileName3 = os.path.join(path_absolute,
            #                                 str(self.currFeature.attribute(fileName3)))
            # newPhotoFileName3 = os.path.join(path_absolute, str(layerName + "_Photos_03"))

            # TOMsMessageLog.logMessage("In photoDetails. Photo3: " + str(newPhotoFileName3), level=Qgis.Info)
            pixmap3 = QPixmap(newPhotoFileName3)
            if pixmap3.isNull():
                pass
                # FIELD1.setText('Picture could not be opened ({path})'.format(path=newPhotoFileName1))
            else:
                
                tab = FIELD3.parentWidget()
                grid = FIELD3.parentWidget().layout()

                photo_Widget3 = imageLabel(tab)
                TOMsMessageLog.logMessage(
                    "In photoDetails. FIELD 3 w: {}; h: {}".format(FIELD3.width(), FIELD3.height()), level=Qgis.Info)
                photo_Widget3.setObjectName("Photo_Widget_03")
                photo_Widget3.setText("No photo is here")
                #photo_Widget3 = imageLabel(tab)
                grid.addWidget(photo_Widget3, 0, 0, 1, 1)

                FIELD3.hide()
                FIELD3.setParent(None)
                FIELD3 = photo_Widget3
                FIELD3.set_Pixmap(pixmap3)

                TOMsMessageLog.logMessage("In photoDetails. FIELD 3 Photo3: " + str(newPhotoFileName3), level=Qgis.Info)
                TOMsMessageLog.logMessage("In photoDetails.pixmap3 size: {}".format(pixmap3.size()),
                                          level=Qgis.Info)

                FIELD3.pixmapUpdated.connect(functools.partial(self.displayPixmapUpdated, FIELD3))
                #ZOOM_IN_3 = self.demandDialog.findChild(QPushButton, "pb_zoomIn_03")
                #ZOOM_IN_3.clicked.connect(FIELD3._zoomInButton)

                #ZOOM_OUT_3 = self.demandDialog.findChild(QPushButton, "pb_zoomOut_03")
                #ZOOM_OUT_3.clicked.connect(FIELD3._zoomOutButton)

                """FIELD3.setPixmap(pixmap3)
                FIELD3.setScaledContents(True)
                TOMsMessageLog.logMessage("In photoDetails. Photo3: " + str(newPhotoFileName3), level=Qgis.Info)"""

            if takePhoto:
                START_CAMERA_3 = self.demandDialog.findChild(QPushButton, "startCamera3")
                TAKE_PHOTO_3 = self.demandDialog.findChild(QPushButton, "getPhoto3")
                TAKE_PHOTO_3.setEnabled(False)

                self.camera3 = formCamera(path_absolute, newPhotoFileName3, cameraNr)
                START_CAMERA_3.clicked.connect(
                    functools.partial(self.camera3.useCamera, START_CAMERA_3, TAKE_PHOTO_3, FIELD3))
                self.camera3.notifyPhotoTaken.connect(functools.partial(self.savePhotoTaken, idx3))

        pass
Esempio n. 16
0
 def cursor(name):
     pix = QPixmap(name)
     pix = pix.scaled(QSize(24, 24))
     return QCursor(pix)
Esempio n. 17
0
    def __init__(self, parent=None):
        """
        Constructor
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)

        # Set icons
        item = self.listWidget.item(0)
        item.setIcon(QIcon(resources_path('quick.png')))
        item = self.listWidget.item(1)
        item.setIcon(QIcon(resources_path('edit.png')))
        item = self.listWidget.item(2)
        item.setIcon(QIcon(resources_path('open.png')))
        item = self.listWidget.item(3)
        item.setIcon(QIcon(resources_path('general.svg')))
        item = self.listWidget.item(4)
        item.setIcon(QIcon(resources_path('info.png')))
        self.label_gnu.setPixmap(QPixmap(resources_path('gnu.png')))

        # Disabled in QGIS3
        # self.set_help_web_view()
        self.restore_queries_group.setVisible(False)
        self.timestamp_group.setVisible(False)
        self.output_format_option.setVisible(False)

        self.help_file = None

        # Connect
        # noinspection PyUnresolvedReferences
        # self.pushButton_homeHelp.clicked.connect(self.get_root_help) QGIS 3
        # noinspection PyUnresolvedReferences
        # self.pushButton_OAPI_timestamp.clicked.connect(
        #     self.get_timestamp_overpass_api)
        # noinspection PyUnresolvedReferences
        self.comboBox_default_OAPI.currentIndexChanged[int].connect(
            self.set_server_overpass_api)
        self.query.signal_new_query_successful.connect(
            self.signal_new_query_successful.emit)
        # self.my_queries.signal_delete_query_successful.connect(
        #     self.signal_delete_query_successful.emit)
        # noinspection PyUnresolvedReferences
        self.pushButton_restoreQueries.clicked.connect(
            self.restore_default_queries)
        # noinspection PyUnresolvedReferences
        self.radioButton_outputJson.toggled.connect(self.set_output_format)

        # Set settings about the overpass API
        self.defaultServer = get_setting('defaultOAPI')
        if self.defaultServer:
            index = self.comboBox_default_OAPI.findText(self.defaultServer)
            self.comboBox_default_OAPI.setCurrentIndex(index)
        else:
            self.defaultServer = self.comboBox_default_OAPI.currentText()
            set_setting('defaultOAPI', self.defaultServer)

        # Set settings about the output
        self.outputFormat = get_setting('outputFormat')
        if self.outputFormat == "geojson":
            self.radioButton_outputJson.setChecked(True)
        elif self.outputFormat == "shape":
            self.radioButton_outputShape.setChecked(True)
        else:
            set_setting('outputFormat', 'shape')
            self.radioButton_outputShape.setChecked(True)

        # Set minimum width for the menu
        self.listWidget.setMinimumWidth(
            self.listWidget.sizeHintForColumn(0) + 10)
Esempio n. 18
0
    def __init__(self, parent, confHandler):
        """
        :type confHandler: configHandler.ConfigHandler
        """
        QDialog.__init__(self, parent)
        self.confHandler = confHandler
        self.doSave = False

        self.setWindowTitle(self.tr('Output Optionen'))
        main_widget = QWidget(self)

        # Build up gui

        # Project title
        hbox1 = QHBoxLayout()
        projectNameLabel = QLabel(self.tr('Projektname'))
        projectNameLabel.setMinimumWidth(100)
        self.projectField = QLineEdit()
        self.projectField.setMinimumWidth(400)
        self.projectField.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
        hbox1.addWidget(projectNameLabel)
        hbox1.addWidget(self.projectField)

        # Save path
        hbox2 = QHBoxLayout()
        saveLabel = QLabel(self.tr('Speicherpfad'))
        saveLabel.setMinimumWidth(100)
        self.pathField = QComboBox()
        self.pathField.setMinimumWidth(400)
        self.pathField.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))

        openButton = QPushButton()
        openButton.setMaximumSize(QSize(27, 27))
        icon = QIcon()
        iconPath = os.path.join(os.path.dirname(__file__), 'icons',
                                'icon_open.png')
        icon.addPixmap(QPixmap(iconPath), QIcon.Normal, QIcon.Off)
        openButton.setIcon(icon)
        openButton.setIconSize(QSize(24, 24))
        openButton.clicked.connect(self.onOpenDialog)

        hbox2.addWidget(saveLabel)
        hbox2.addWidget(self.pathField)
        hbox2.addWidget(openButton)
        # Create checkboxes
        questionLabel = QLabel(
            self.tr('Welche Produkte sollen erzeugt werden?'))
        self.checkBoxShortReport = QCheckBox(self.tr('Kurzbericht'))
        self.checkBoxReport = QCheckBox(self.tr('Technischer Bericht'))
        self.checkBoxPlot = QCheckBox(self.tr('Diagramm'))
        self.checkBoxGeodata = QCheckBox(
            self.tr('Shape-Daten der Stuetzen und Seillinie'))
        self.checkBoxKML = QCheckBox(
            self.tr('KML-Daten der Stuetzen und Seillinie'))
        self.checkBoxCoords = QCheckBox(
            self.tr('Koordinaten-Tabellen der Stuetzen und Seillinie'))

        # Set tick correctly
        self.checkBoxShortReport.setChecked(
            self.confHandler.outputOptions['shortReport'])
        self.checkBoxReport.setChecked(
            self.confHandler.outputOptions['report'])
        self.checkBoxPlot.setChecked(self.confHandler.outputOptions['plot'])
        self.checkBoxGeodata.setChecked(
            self.confHandler.outputOptions['geodata'])
        self.checkBoxKML.setChecked(self.confHandler.outputOptions['kml'])
        self.checkBoxCoords.setChecked(
            self.confHandler.outputOptions['coords'])
        # Create Ok/Cancel Button and connect signal
        buttonBox = QDialogButtonBox(main_widget)
        buttonBox.setStandardButtons(QDialogButtonBox.Save
                                     | QDialogButtonBox.Cancel)
        buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Speichern"))
        buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Abbrechen"))
        buttonBox.button(QDialogButtonBox.Cancel).clicked.connect(
            self.onCancel)
        buttonBox.button(QDialogButtonBox.Save).clicked.connect(self.onSave)
        # Layout
        container = QVBoxLayout(main_widget)
        container.addLayout(hbox1)
        container.addLayout(hbox2)
        container.addWidget(QLabel(''))
        container.addWidget(questionLabel)
        container.addWidget(self.checkBoxShortReport)
        container.addWidget(self.checkBoxReport)
        container.addWidget(self.checkBoxPlot)
        container.addWidget(self.checkBoxGeodata)
        container.addWidget(self.checkBoxKML)
        container.addWidget(self.checkBoxCoords)
        container.addWidget(buttonBox)
        container.setAlignment(Qt.AlignLeft)
        self.setLayout(container)

        self.fillInData()
Esempio n. 19
0
# Isogeo formats
li_formats_vect = ("shp", "dxf", "dgn", "filegdb", "tab")
li_formats_rastr = (
    "esriasciigrid",
    "geotiff",
    "intergraphgdb",
    "jpeg",
    "png",
    "xyz",
    "ecw",
)

# Qt icons
# see https://github.com/qgis/QGIS/blob/master/images/images.qrc
pix_point = QPixmap(":/images/themes/default/mIconPointLayer.svg")
pix_polyg = QPixmap(":/images/themes/default/mIconPolygonLayer.svg")
pix_line = QPixmap(":/images/themes/default/mIconLineLayer.svg")
pix_rastr = QPixmap(":/images/themes/default/mIconRaster.svg")
pix_multi = QPixmap(":/plugins/Isogeo/resources/multi.svg").scaledToWidth(20)
pix_nogeo = QPixmap(":/plugins/Isogeo/resources/none.svg").scaledToWidth(20)
pix_serv = QPixmap(
    ":/plugins/Isogeo/resources/results/cloud.svg").scaledToWidth(20)
ico_efs = QIcon(":/images/themes/default/mIconAfs.svg")
ico_ems = QIcon(":/images/themes/default/mIconAms.svg")
ico_wfs = QIcon(":/images/themes/default/mIconWfs.svg")
ico_wms = QIcon(":/images/themes/default/mIconWms.svg")
ico_wmts = QIcon(":/images/themes/default/mIconWcs.svg")
ico_pgis = QIcon(":/images/themes/default/mIconPostgis.svg")
ico_file = QIcon(":/images/themes/default/mActionFileNew.svg")
Esempio n. 20
0
    def __init__(self, iface, parent=None):
        """Constructor."""
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.iface = iface

        self.query_menu_index = 1

        # Table mapping

        # Explaining quickly, these letters are referring to the panel
        # in the UI:
        # qq : Quick Query
        # q : Query
        # f : file
        self.external_panels = {
            Panels.QuickQuery: QuickQueryPanel(self),
            Panels.Query: QueryPanel(self),
            Panels.File: OsmFilePanel(self),
            Panels.Configuration: ConfigurationPanel(self),
        }
        self.places_edits = {
            Panels.QuickQuery: self.line_place_qq,
            Panels.Query: self.line_place_q,
        }
        self.query_type_buttons = {
            Panels.QuickQuery: self.combo_query_type_qq,
            Panels.Query: self.combo_query_type_q,
        }
        self.layers_buttons = {
            Panels.QuickQuery: self.combo_extent_layer_qq,
            Panels.Query: self.combo_extent_layer_q,
        }
        self.run_buttons = {
            Panels.QuickQuery: self.button_run_query_qq,
            Panels.Query: self.button_run_query_q,
            Panels.File: self.button_run_file,
        }
        self.output_buttons = {
            Panels.QuickQuery: [
                self.checkbox_points_qq, self.checkbox_lines_qq,
                self.checkbox_multilinestrings_qq,
                self.checkbox_multipolygons_qq
            ],
            Panels.Query: [
                self.checkbox_points_q,
                self.checkbox_lines_q,
                self.checkbox_multilinestrings_q,
                self.checkbox_multipolygons_q,
            ],
            Panels.File: [
                self.checkbox_points_f,
                self.checkbox_lines_f,
                self.checkbox_multilinestrings_f,
                self.checkbox_multipolygons_f,
            ]
        }
        self.output_directories = {
            Panels.QuickQuery: self.output_directory_qq,
            Panels.Query: self.output_directory_q,
            Panels.File: self.output_directory_f
        }
        self.prefix_edits = {
            Panels.QuickQuery: self.line_file_prefix_qq,
            Panels.Query: self.line_file_prefix_q,
            Panels.File: self.line_file_prefix_file,
        }
        self.advanced_panels = {
            Panels.QuickQuery: self.advanced_qq,
            Panels.Query: self.advanced_q,
        }

        item = self.menu_widget.item(0)
        item.setIcon(QIcon(resources_path('icons', 'quick.png')))
        item = self.menu_widget.item(1)
        item.setIcon(QIcon(resources_path('icons', 'edit.png')))
        item = self.menu_widget.item(2)
        item.setIcon(QIcon(resources_path('icons', 'open.png')))
        item = self.menu_widget.item(3)
        item.setIcon(QIcon(resources_path('icons', 'general.svg')))
        item = self.menu_widget.item(4)
        item.setIcon(QIcon(resources_path('icons', 'info.png')))
        self.label_gnu.setPixmap(QPixmap(resources_path('icons', 'gnu.png')))

        # Set minimum width for the menu
        self.menu_widget.setMinimumWidth(
            self.menu_widget.sizeHintForColumn(0) + 10)

        self.progress_text.setText('')

        self.menu_widget.currentRowChanged['int'].connect(
            self.stacked_panels_widget.setCurrentIndex)

        for panel in self.external_panels.values():
            panel.setup_panel()
        self.menu_widget.setCurrentRow(0)
    def fill_gallery(self, visit_id, event_id):

        self.img_path_list = []
        self.img_path_list1D = []

        # Get all pictures for event_id | visit_id
        sql = (f"SELECT value FROM om_visit_event_photo"
               f" WHERE event_id = '{event_id}' AND visit_id = '{visit_id}'")
        rows = self.controller.get_rows(sql, commit=True)
        num = len(rows)
        for m in range(0, num):
            self.img_path_list1D.append(rows[m][0])

        # Add picture to gallery
        # Fill one-dimensional array till the end with "0"
        self.num_events = len(self.img_path_list1D)

        # Fill the rest of the fields in gallery with 0
        limit = self.num_events % 9
        limit = 9 - limit
        for k in range(0, limit):  # @UnusedVariable
            self.img_path_list1D.append(0)

        # Inicialization of two-dimensional array
        columns = 9
        rows = self.num_events
        # noinspection PyUnusedLocal
        self.img_path_list = [[0 for x in range(columns)] for x in range(rows)]

        # Convert one-dimensional array to two-dimensional array
        # Fill self.img_path_list with values from self.img_path_list1D
        idx = 0
        if rows == 1:
            for br in range(0, len(self.img_path_list1D)):
                self.img_path_list[0][br] = self.img_path_list1D[br]
        else:
            for h in range(0, rows):
                for r in range(0, columns - 1):
                    if idx >= columns:
                        break
                    self.img_path_list[h][r] = self.img_path_list1D[idx]
                    idx = idx + 1

        # List of pointers(in memory) of clicableLabels
        self.list_widget = []
        self.list_labels = []

        # Fill first slide of gallery
        for i in range(0, 9):
            widget_name = "img_" + str(i)
            widget = self.dlg_gallery.findChild(QLabel, widget_name)
            if widget:
                # Set image to QLabel

                # Parse a URL into components
                url = urllib.parse.urlsplit(str(self.img_path_list[0][i]))

                # Check if path is URL
                if url.scheme == "http" or url.scheme == "https":
                    url = str(self.img_path_list[0][i])
                    data = urllib.request.urlopen(url).read()
                    pixmap = QPixmap()
                    pixmap.loadFromData(data)
                else:
                    pixmap = QPixmap(str(self.img_path_list[0][i]))

                pixmap = pixmap.scaled(171, 151, Qt.IgnoreAspectRatio,
                                       Qt.SmoothTransformation)
                widget_extended = GwExtendedQLabel(widget)
                widget_extended.setPixmap(pixmap)
                widget_extended.clicked.connect(
                    partial(self.zoom_img, i, visit_id, event_id))
                self.list_widget.append(widget_extended)
                self.list_labels.append(widget)

        txt_visit_id = self.dlg_gallery.findChild(QLineEdit, 'visit_id')
        txt_visit_id.setText(str(visit_id))
        txt_event_id = self.dlg_gallery.findChild(QLineEdit, 'event_id')
        txt_event_id.setText(str(event_id))

        self.start_indx = 0
        self.btn_next = self.dlg_gallery.findChild(QPushButton, "btn_next")
        self.btn_next.clicked.connect(self.next_gallery)
        self.btn_previous = self.dlg_gallery.findChild(QPushButton,
                                                       "btn_previous")
        self.btn_previous.clicked.connect(self.previous_gallery)
        set_icon(self.btn_previous, "109")
        set_icon(self.btn_next, "108")
        self.btn_close = self.dlg_gallery.findChild(QPushButton, "btn_close")
        self.btn_close.clicked.connect(partial(close_dialog, self.dlg_gallery))

        # If all images set in one page, disable button next
        if num <= 9:
            self.btn_next.setDisabled(True)

        # Open dialog
        open_dialog(self.dlg_gallery,
                    dlg_name='visit_gallery',
                    maximize_button=False)
Esempio n. 22
0
    def pop_layer(self):

        # get all layers

        self.iface.mapCanvas().refreshAllLayers()
        networks = self.get_layers(1)
        unlinks = self.get_layers(0)

        # get active layers
        self.dockwidget.networkCombo.blockSignals(True)
        self.dockwidget.networkCombo.clear()
        self.dockwidget.networkCombo.addItems(networks)

        active_network_idx = self.dockwidget.networkCombo.findText(
            self.dockwidget.activatedNetwork)  # TODOD test if multiple
        if active_network_idx == -1:
            active_network_idx = 0
        print('active_network_idx', self.dockwidget.activatedNetwork, networks)

        # TODO: if the network changes - do not block signals - setup snapping
        # if self.dockwidget.activatedNetwork =

        self.dockwidget.networkCombo.setCurrentIndex(active_network_idx)

        if networks.count(self.dockwidget.activatedNetwork) > 1:
            self.iface.messageBar().pushMessage(
                "Drawing Tool: ",
                "Rename network layers in the layers panel that have the same names!",
                level=Qgis.Warning,
                duration=5)

        self.dockwidget.settings[0] = self.dockwidget.networkCombo.currentText()
        self.dockwidget.networkCombo.blockSignals(False)

        self.dockwidget.unlinksCombo.blockSignals(True)
        self.dockwidget.unlinksCombo.clear()
        self.dockwidget.unlinksCombo.addItems(['no unlinks'] + unlinks)
        active_unlinks_idx = self.dockwidget.unlinksCombo.findText(
            self.dockwidget.activatedUnlinks)  # TODOD test if multiple
        if active_unlinks_idx == -1:
            active_unlinks_idx = 0

        # print 'active_unlinks_idx', active_unlinks_idx, unlinks

        if active_unlinks_idx == 0 and self.dockwidget.unlink_mode:
            self.iface.messageBar().pushMessage("Unlinks layer not specified!", Qgis.Critical, duration=5)
            self.dockwidget.unlink_mode = False
            unlink_icon = QPixmap(os.path.dirname(__file__) + "/custom_icons/unlink_disabled.png")
            self.dockwidget.unlinksButton.setIcon(QIcon(unlink_icon))
            self.dockwidget.unlinksButton.setIconSize(QSize(40, 40))

        self.dockwidget.unlinksCombo.setCurrentIndex(active_unlinks_idx)

        self.dockwidget.networkCombo.setCurrentIndex(active_network_idx)
        if unlinks.count(self.dockwidget.activatedUnlinks) > 1:
            self.iface.messageBar().pushMessage(
                "Drawing Tool: ",
                "Rename point layers in the layers panel that have the same names!",
                level=Qgis.Warning,
                duration=5)

        self.dockwidget.settings[1] = self.dockwidget.networkCombo.currentText()
        self.dockwidget.unlinksCombo.blockSignals(False)
        if len(networks) == 0 or self.dockwidget.networkCombo.currentText() == '':
            self.lockGUI(True)
        else:
            self.lockGUI(False)
        return
Esempio n. 23
0
 def set_widgets(self):
     """Set widgets on the Extent Disjoint tab."""
     self.lblIconDisjoint_3.setPixmap(
         QPixmap(resources_path('img', 'wizard', 'icon-stop.svg')))
Esempio n. 24
0
    def hacer5(self):
        self.tempdir = configuracioQvista.tempdir
        fic_tmp = os.path.join(self.tempdir, "temporal.png")
        self.pixmap = QPixmap(fic_tmp)
        # self.pixmap=self.canvas.grab() # no acaba de ir bien, me carga en pixmap tambien el circulo pintado
        # tamaño del pixmap
        hp = self.pixmap.height()  # alto imagen
        wp = self.pixmap.width()  # ancho imagen salvada
        # radio.
        if hp < wp:
            self.rP = hp / 2
        else:
            self.rP = wp / 2

        self.xcP = wp / 2
        self.ycP = hp / 2
        # self.rP = math.sqrt(math.pow((self.xcP-self.xrP), 2) + math.pow((self.ycP-self.yrP), 2))  # radio pantalla
        pcX = self.xcP - self.rP
        pcY = self.ycP - self.rP  # punto inicio crop
        self.an = 2 * self.rP
        self.al = self.an  # an, ancho para crop   al, alto para crop
        # escala= self.rP /self.rM                                                   # escala, como relacion de radiopantalla a radiomundo
        # pmin= QPoint();
        # pmin.setX(pcX);
        # pmin.setY(pcY+self.al);
        # self.Pmin = self.toMapCoordinates(pmin)
        # pmax= QPoint();
        # pmax.setX(pcX+self.an);
        # pmax.setY(pcY);
        # self.Pmax = self.toMapCoordinates(pmax)

        # calculo area de recorte para hacer el crop
        rect = QRect(pcX, pcY, self.an, self.al)
        # hago crop
        cropped_pixmap = self.pixmap.copy(rect)

        # escalo el pixmap al tamaño que quiero
        self.scaled_pixmap = cropped_pixmap.scaled(
            self.lado, self.lado, Qt.KeepAspectRatioByExpanding,
            Qt.SmoothTransformation)
        # de pixmap a image
        image = QImage(self.scaled_pixmap.toImage())
        image = image.convertToFormat(QImage.Format_ARGB32)

        # preparo imagen de salida transparente y del tamaño del de entrada....
        out_img = QImage(image.width(), image.width(), QImage.Format_ARGB32)
        out_img.fill(Qt.transparent)

        # Create a texture brush and paint a circle with the original image onto
        # the output image: Chapeau!!
        brush = QBrush(image)  # Create texture brush
        painter = QPainter(out_img)  # Paint the output image
        painter.setBrush(brush)  # Use the image texture brush
        # painter.setPen(Qt.NoPen)     # Don't draw an outline
        # pen= QPen(QColor(121,144,155),  1, Qt.SolidLine)    #qVista claro
        pen = QPen(self.color, 1, Qt.SolidLine)  #qVista claro
        painter.setPen(pen)
        painter.setRenderHint(QPainter.Antialiasing, True)  # Use AA
        painter.drawEllipse(0, 0, image.width(),
                            image.width())  # Actually draw the circle
        painter.end()  # We are done (segfault if you forget this)

        # de out_img a pixmap
        self.scaled_pixmap = QPixmap.fromImage(out_img)

        # muestro ese pixmap en label...
        self.label.setPixmap(self.scaled_pixmap)

        # y lo salvo como temporal2
        fic_tmp = os.path.join(self.tempdir, "temporal2.png")
        self.fileName = fic_tmp

        if self.fileName:
            # Guardo el pixmap como png
            self.scaled_pixmap.save(self.fileName)
            # Calculo info para el PQW
            # rango mundo x e y

            xdist = self.xmax - self.xmin
            ydist = self.ymax - self.ymin
            # ancho y alto de la imagen
            iheight = self.scaled_pixmap.height()
            iwidth = self.scaled_pixmap.width()

            # Preparo nombre del PGW
            split_nombre = os.path.splitext(self.fileName)
            filenamePgw = split_nombre[0] + ".pgw"

            # Escribo PGW
            wld = open(filenamePgw, "w")
            wld.writelines("%s\n" % (xdist / iwidth))
            wld.writelines("0.0\n")
            wld.writelines("0.0\n")
            wld.writelines("%s\n" % (ydist / iheight))
            wld.writelines("%s\n" % self.xmin)
            wld.writelines("%s\n" % self.ymin)
            wld.close

        # #  muestro datos de georeferenciacion
        # literal= "xmin,ymin=" + str(round(self.Pmin.x(),3)) +"  "+ str(round(self.Pmin.y(),3))
        # self.parent.xmin_ymin.setText(literal)
        # literal= "xmax,ymax=" + str(round(self.Pmax.x(),3)) +"  "+ str(round(self.Pmax.y(),3))
        # self.parent.xmax_ymax.setText(literal)

        try:
            self.reset()
        except:
            pass