connect "Save as Classification" PA to the DataViews context menu

Issue #428 closed
Andreas Janz created an issue

BJ will contact AR for details

Comments (5)

  1. Benjamin Jakimow

    Which details?

    If a use-case is common you can connect it with the layer tree context-menu that is defined in enmapbox\gui\dockmanager.py.

    Just modify the layer-tree context menu in DockManagerLayerTreeModelMenuProvider().createContextMenu(self)

        def createContextMenu(self):
    
            ...
    
            if type(node) is QgsLayerTreeLayer:
                # get parent dock node -> related map canvas
                mapNode = findParent(node, MapDockTreeNode)
                assert isinstance(mapNode, MapDockTreeNode)
                assert isinstance(mapNode.dock, MapDock)
                canvas = mapNode.dock.mCanvas
    
                lyr = node.layer()
    
                ... 
    
                if isinstance(lyr, QgsVectorLayer) and <other checks>:
                    # append your action to the context menu
                   a = menu.addAction('Save as Classification')
                   a.triggered.connect(lambda : <call your algorithm>)   
    

  2. Andreas Janz reporter

    We are now much more flexible in interpreting a raster layer as a classification layer. So Save as Classification algo has become superfluous and will be removed in a future version.

  3. Log in to comment