-
-
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 grass region definition from layer
fixed problem with grass algorithms requiring an explicit region git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@311 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf
committed
Jul 26, 2012
1 parent
488c939
commit f3f81d5
Showing
6 changed files
with
50 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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.core.SextanteConfig import SextanteConfig | ||
from sextante.grass.GrassUtils import GrassUtils | ||
|
||
class DefineGrassRegionFromLayerAction(ToolboxAction): | ||
|
||
def __init__(self): | ||
self.name="Define GRASS region from layer" | ||
self.group="Tools" | ||
|
||
def getIcon(self): | ||
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/grass.png") | ||
|
||
def execute(self): | ||
layers = QGisLayers.getAllLayers(); | ||
layersMap = {layer.name() : layer for layer in layers} | ||
layerNames = [layer.name() for layer in layers] | ||
item, ok = QtGui.QInputDialog.getItem(None, "Select a layer", "Layer selection", layerNames, editable=False) | ||
if ok: | ||
layer = layersMap[item] | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMIN, layer.extent().xMinimum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMIN, layer.extent().yMinimum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_XMAX, layer.extent().xMaximum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_REGION_YMAX, layer.extent().yMaximum()) | ||
SextanteConfig.setSettingValue(GrassUtils.GRASS_AUTO_REGION, False) | ||
s = str(layer.extent().xMinimum()) + "," + str(layer.extent().xMaximum()) + "," + str(layer.extent().yMinimum()) + "," + str(layer.extent().yMaximum()) | ||
QtGui.QMessageBox.information(None, "GRASS Region", "GRASS region set to:\n" + s + \ | ||
"\nTo set the cellsize or set back the autoregion option,\ngo to the SEXTANTE configuration.") |
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 was deleted.
Oops, something went wrong.
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