coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.
MIT License
229 stars 34 forks source link

Shortcut to change output layer #52

Open Segmentoholic opened 1 day ago

Segmentoholic commented 1 day ago

Hello,

is it possible to set a shortcut to change output layer file of Geo-SAM faster?

Thank you for your help in advance!

Fanchengyan commented 1 day ago

This feature might not be essential. You can modify the code as needed. Binding a shortcut key is straightforward. Define it in tools/widgetTool.py:

https://github.com/coolzhao/Geo-SAM/blob/c2c8b86a397dc183b63d07a7a84e3127d1430720/tools/widgetTool.py#L236-L260

And then unbind it in the unload function:

https://github.com/coolzhao/Geo-SAM/blob/c2c8b86a397dc183b63d07a7a84e3127d1430720/tools/widgetTool.py#L382-L399

To find the shortcut key binding, use QT Designer to open ui/Selector.ui. Click the button you want to bind, check its objectName

image

and find the corresponding connect function in tools/widgetTool.py (self.set_vector_layer in this case).

https://github.com/coolzhao/Geo-SAM/blob/c2c8b86a397dc183b63d07a7a84e3127d1430720/tools/widgetTool.py#L178

To enable modification, you need to reload the plugin. You can install the Plugin Reloader plugin to reload the plugin without restarting QGIS.

image

image