[QGIS-Developer] Using setMapTool with native rotate feature method in Advanced Digitizing Toolbar

Catania, Luke A ERDC-RDE-GRL-VA CIV Luke.A.Catania at erdc.dren.mil
Thu Jun 6 16:05:30 PDT 2024


I use the statement:

facility_placement_tool = FacilityPlacementTool(iface.mapCanvas(), vlayer_crs)
iface.mapCanvas().setMapTool(facility_placement_tool)

to set a custom tool on the map canvas. It allows me to move a feature layer around the map canvas using the translateFeature method of the layer using the canvasMoveEvent of FacilityPlacementTool until I click on the left mouse button.  Once the user clicks the left mouse, I detect that event and I run a method, rotateFeature, below that allows me to use the native QGIS rotate method.  I can then rotate the feature.  Expecting this to happen, it then seems that the rotate tool takes over the map canvas events from my FacilityPlacementTool  so when I right click to end the rotate on the feature that's all that happens. But I want the right click to end editing which have in the canvasPressEvent method in FacilityPlacementTool.   Is there a way after the code below runs and the user ends the rotate tool by right clicking that right click even can then be passed onto the FacilityPlacementTool tool or I can just run some other method that closes out the edit session.
  Also wondering why I have to get to the rotate feature tool with the code below, but there is a iface.actionMoveFeature().trigger() statement I can call to move a feature  Why isn't there a iface.actionRotateFeature().trigger() method.

def rotateFeature(self):
        # Get all actions
        actions = iface.mainWindow().findChildren(QAction)

        # Check the action
        action = [x for x in actions if x.objectName()=='mActionRotateFeature'][0]

        # Run the action
        action.trigger()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240606/ded6cd24/attachment.htm>


More information about the QGIS-Developer mailing list