Beispiel #1
0
    def run(self):
        # first, check posibility
        if self.checkIfOpening() == False:
            return

        #if dock not already opened, open the dock and all the necessary thing (model,doProfile...)
        if self.dockOpened == False:
            self.mdl = QStandardItemModel(0, 5)
            self.wdg = Ui_PTDockWidget(self.iface.mainWindow(), self.iface,
                                       self.mdl)
            self.wdg.showIt()
            self.doprofile = DoProfile(self.iface, self.wdg, self.tool)
            self.tableViewTool = TableViewTool()
            QObject.connect(self.wdg, SIGNAL("closed(PyQt_PyObject)"),
                            self.cleaning2)
            QObject.connect(self.wdg.tableView, SIGNAL("clicked(QModelIndex)"),
                            self._onClick)
            QObject.connect(self.wdg.pushButton_2, SIGNAL("clicked()"),
                            self.addLayer)
            QObject.connect(self.wdg.pushButton, SIGNAL("clicked()"),
                            self.removeLayer)
            QObject.connect(self.wdg.comboBox,
                            SIGNAL("currentIndexChanged(int)"),
                            self.selectionMethod)
            QObject.connect(self.wdg.comboBox_2,
                            SIGNAL("currentIndexChanged(int)"),
                            self.changePlotLibrary)
            self.tableViewTool.layerAddedOrRemoved.connect(self.refreshPlot)
            self.wdg.addOptionComboboxItems()
            self.addLayer()
            self.dockOpened = True
        #Listeners of mouse
        self.connectTool()
        #init the mouse listener comportement and save the classic to restore it on quit
        self.canvas.setMapTool(self.tool)
        #init the temp layer where the polyline is draw
        self.polygon = False
        self.rubberband = QgsRubberBand(self.canvas, self.polygon)
        self.rubberband.setWidth(2)
        self.rubberband.setColor(QColor(Qt.red))
        #init the table where is saved the poyline
        self.pointstoDraw = []
        self.pointstoCal = []
        self.lastClicked = [[-9999999999.9, 9999999999.9]]
        # The last valid line we drew to create a free-hand profile
        self.lastFreeHandPoints = []
        #Help about what doing
        if self.selectionmethod == 0:
            self.iface.mainWindow().statusBar().showMessage(self.textquit0)
        elif self.selectionmethod == 1:
            self.iface.mainWindow().statusBar().showMessage(self.textquit1)
	def removeLayer(self):
		TableViewTool().removeLayer(self.iface, self.mdl)
	def _onClick(self,index1):					#action when clicking the tableview
		TableViewTool().onClick(self.iface, self.wdg, self.mdl, self.plotlibrary, index1)
	def addLayer(self , layer1 = None):
		TableViewTool().addLayer(self.iface, self.mdl, layer1)
    def run(self):
        # first, check posibility
        if self.checkIfOpening() == False:
            return

        #if dock not already opened, open the dock and all the necessary thing (model,doProfile...)
        if self.dockOpened == False:
            self.mdl = QStandardItemModel(0, 6)
            self.wdg = PTDockWidget(self.iface.mainWindow(), self.iface,
                                    self.mdl)
            self.wdg.showIt()
            self.doprofile = DoProfile(self.iface, self.wdg, self.pointTool,
                                       self)
            self.tableViewTool = TableViewTool()
            QObject.connect(self.wdg, SIGNAL("closed(PyQt_PyObject)"),
                            self.cleaning2)
            QObject.connect(self.wdg.tableView, SIGNAL("clicked(QModelIndex)"),
                            self._onClick)
            QObject.connect(self.wdg.pushButton_2, SIGNAL("clicked()"),
                            self.addLayer)
            QObject.connect(self.wdg.pushButton, SIGNAL("clicked()"),
                            self.removeLayer)
            QObject.connect(self.wdg.comboBox,
                            SIGNAL("currentIndexChanged(int)"),
                            self.selectionMethod)
            QObject.connect(self.wdg.cboLibrary,
                            SIGNAL("currentIndexChanged(int)"),
                            self.changePlotLibrary)
            QObject.connect(self.wdg.cboXAxis,
                            SIGNAL("currentIndexChanged(int)"),
                            self.changeXAxisLabeling)
            QObject.connect(self.wdg.leXAxisSteps, SIGNAL("editingFinished()"),
                            self.changeXAxisLabeling)
            QObject.connect(self.wdg.dateTimeEditCurrentTime,
                            SIGNAL("editingFinished()"),
                            self.changeXAxisLabeling)
            QObject.connect(self.wdg.spinBoxTimeExtent,
                            SIGNAL("editingFinished()"),
                            self.changeXAxisLabeling)
            QObject.connect(self.wdg.cboTimeExtent,
                            SIGNAL("currentIndexChanged(int)"),
                            self.changeXAxisLabeling)
            QObject.connect(self.wdg.cbTimeDimension,
                            SIGNAL("stateChanged(int)"),
                            self.changeXAxisLabeling)
            self.wdg.addOptionComboboxItems()
            self.addLayer()
            self.dockOpened = True
        #Listeners of mouse
        self.connectPointMapTool()
        #init the mouse listener comportement and save the classic to restore it on quit
        self.canvas.setMapTool(self.pointTool)

        #Help about what doing
        if self.selectionmethod == TemporalSpectralProfilePlugin.POINT_SELECTION:
            self.iface.mainWindow().statusBar().showMessage(
                self.pointSelectionInstructions)
        elif self.selectionmethod == TemporalSpectralProfilePlugin.SELECTED_POLYGON:
            self.iface.mainWindow().statusBar().showMessage(
                self.selectedPolygonInstructions)

        QObject.connect(QgsMapLayerRegistry.instance(),
                        SIGNAL("layersWillBeRemoved (QStringList)"),
                        self.onLayersWillBeRemoved)