Exemplo n.º 1
0
        def __init__(self, iface,  toolBar, menu):
            # Save reference to the QGIS interface
            self.iface = iface
            self.canvas = self.iface.mapCanvas()
            mc = self.canvas
            self.tool = None
            
            # Create actions 
            self.act_console = QAction(QIcon(":/plugins/cadtools/icons/cadconsole2.png"), QCoreApplication.translate("CadTools","Cad Console"), self.iface.mainWindow() )
            self.act_ortho = QAction(QIcon(":/plugins/cadtools/icons/ortho2.png"), QCoreApplication.translate("ctools", "Capture Orthogonal Lines/Polygons"),  self.iface.mainWindow())
            self.act_ortho.setEnabled(False)
            self.act_ortho.setCheckable(True)            
            
            # Connect to signals for button behaviour
            self.act_ortho.triggered.connect(self.orthodigitize)
            self.iface.currentLayerChanged.connect(self.toggle)
            mc.mapToolSet.connect(self.deactivate)
            self.act_console.triggered.connect(self.showCadConsole)
            
            # Add actions to the toolbar
            toolBar.addSeparator()
            toolBar.addAction(self.act_ortho)
            
            # Add the console to the menu and to the toolbar
            toolBar.addSeparator()
            toolBar.addAction(self.act_console)
#            menu.addAction( self.act_console )
            
            # Get the tool
            self.tool = OrthogonalDigitizer(self.canvas)
    def showCadConsole(self):
        if self.tool == None:
            self.tool = OrthogonalDigitizer(self.canvas)

        self.dockWidget = CadConsole(self, self.tool)
        self.dockWidget.initGui()
        self.iface.addDockWidget(Qt.BottomDockWidgetArea, self.dockWidget)
Exemplo n.º 3
0
    def __init__(self, iface, toolBar):
        # Save reference to the QGIS interface
        self.iface = iface
        self.canvas = self.iface.mapCanvas()
        self.layer = self.iface.activeLayer()
        self.mc = self.canvas
        self.tool = None

        self.act_ortho = QAction(
            QIcon(":/plugins/QuickDigitize/icon.png"),
            QCoreApplication.translate("ctools",
                                       "Capture Orthogonal Lines/Polygons"),
            self.iface.mainWindow())

        self.act_ortho.setCheckable(True)

        try:
            if self.layer.isEditable():
                self.act_ortho.setEnabled(True)
                self.layer.editingStopped.connect(self.toggle)
        except:
            pass

        else:
            self.act_ortho.setEnabled(False)
            self.layer.editingStarted.connect(self.toggle)

        # Connect to signals for button behaviour
        self.count_1 = 0
        self.count_1 += 1
        if self.count_1 == 1:

            self.act_ortho.triggered.connect(self.orthodigitize)
            self.count_1 -= 1

        if self.count_1 == 0:
            self.canvas.mapToolSet.connect(self.deactivate)
            self.count_1 += 1
        # Connect to signals for button behaviour

        # Add actions to the toolbar
        toolBar.addSeparator()
        toolBar.addAction(self.act_ortho)

        # Get the tool
        self.tool = OrthogonalDigitizer(self.canvas)