-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tool to define grass region on canvas git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@147 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf
committed
Apr 24, 2012
1 parent
88053cc
commit 0023d04
Showing
6 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
from PyQt4 import QtGui, QtCore | ||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
from sextante.gui.ToolboxAction import ToolboxAction | ||
from sextante.core.QGisLayers import QGisLayers | ||
from sextante.gui.RectangleMapTool import RectangleMapTool | ||
from sextante.core.SextanteConfig import SextanteConfig | ||
from sextante.grass.GrassUtils import GrassUtils | ||
|
||
class DefineGrassRegionAction(ToolboxAction): | ||
|
||
def __init__(self): | ||
self.name="Define GRASS region on canvas" | ||
self.group="Tools" | ||
canvas = QGisLayers.iface.mapCanvas() | ||
self.prevMapTool = canvas.mapTool() | ||
self.tool = RectangleMapTool(canvas) | ||
QtCore.QObject.connect(self.tool, SIGNAL("rectangleCreated()"), self.fillCoords) | ||
|
||
def getIcon(self): | ||
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/grass.png") | ||
|
||
def execute(self): | ||
QtGui.QMessageBox.information(None, "GRASS Region", "Click and drag onto map canvas to define GRASS region") | ||
canvas = QGisLayers.iface.mapCanvas() | ||
canvas.setMapTool(self.tool) | ||
|
||
def fillCoords(self): | ||
r = self.tool.rectangle() | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMIN, r.xMinimum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMIN, r.yMinimum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMAX, r.xMaximum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMAX, r.yMaximum()) | ||
s = str(r.xMinimum()) + "," + str(r.xMaximum()) + "," + str(r.yMinimum()) + "," + str(r.yMaximum()) | ||
self.tool.reset() | ||
canvas = QGisLayers.iface.mapCanvas() | ||
canvas.setMapTool(self.prevMapTool) | ||
QtGui.QMessageBox.information(None, "GRASS Region", "GRASS region set to:\n" + s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters