-
-
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 file selector for vector and raster layers fixed bug with numbers and string in modeler dialog added RenderingStyleFilePanel git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@73 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf@gmail.com
committed
Apr 12, 2012
1 parent
4d25fbe
commit 5d225c3
Showing
13 changed files
with
395 additions
and
38 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
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,33 @@ | ||
from PyQt4 import QtGui, QtCore | ||
|
||
class InputLayerSelectorPanel(QtGui.QWidget): | ||
|
||
def __init__(self, options): | ||
super(InputLayerSelectorPanel, self).__init__(None) | ||
self.setObjectName("ILSPanel") | ||
self.horizontalLayout = QtGui.QHBoxLayout(self) | ||
self.horizontalLayout.setSpacing(2) | ||
self.horizontalLayout.setMargin(0) | ||
self.horizontalLayout.setObjectName("hLayout") | ||
self.text = QtGui.QComboBox() | ||
#self.text.setEditable(True) | ||
for name, value in options: | ||
self.text.addItem(name, value) | ||
self.text.setObjectName("label") | ||
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) | ||
self.horizontalLayout.addWidget(self.text) | ||
self.pushButton = QtGui.QPushButton() | ||
self.pushButton.setObjectName("pushButton") | ||
self.pushButton.setText("...") | ||
self.pushButton.clicked.connect(self.showSelectionDialog) | ||
self.horizontalLayout.addWidget(self.pushButton) | ||
self.setLayout(self.horizontalLayout) | ||
|
||
def showSelectionDialog(self): | ||
filename = QtGui.QFileDialog.getOpenFileName(self, "All files", "", "*.*") | ||
if filename: | ||
self.text.addItem(filename, filename) | ||
self.text.setCurrentIndex(self.text.count() - 1) | ||
|
||
def getValue(self): | ||
return self.text.itemData(self.text.currentIndex()).toPyObject() |
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,36 @@ | ||
from PyQt4 import QtGui, QtCore | ||
import os.path | ||
from sextante.core.SextanteConfig import SextanteConfig | ||
|
||
|
||
class RenderingStyleFilePanel(QtGui.QWidget): | ||
|
||
def __init__(self): | ||
super(RenderingStyleFilePanel, self).__init__(None) | ||
self.setObjectName("RSFPanel") | ||
self.horizontalLayout = QtGui.QHBoxLayout(self) | ||
self.horizontalLayout.setSpacing(2) | ||
self.horizontalLayout.setMargin(0) | ||
self.horizontalLayout.setObjectName("hLayout") | ||
self.text = QtGui.QLineEdit() | ||
self.text.setObjectName("label") | ||
self.text.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) | ||
self.horizontalLayout.addWidget(self.text) | ||
self.pushButton = QtGui.QPushButton() | ||
self.pushButton.setObjectName("pushButton") | ||
self.pushButton.setText("...") | ||
self.pushButton.clicked.connect(self.showSelectionDialog) | ||
self.horizontalLayout.addWidget(self.pushButton) | ||
self.setLayout(self.horizontalLayout) | ||
|
||
def showSelectionDialog(self): | ||
filename = QtGui.QFileDialog.getOpenFileName(self, "Select style file", "", "*.qml") | ||
if filename: | ||
self.text.setText(str(filename)) | ||
|
||
def setText(self, text): | ||
self.text.setText(str(text)) | ||
|
||
def getValue(self): | ||
filename = str(self.text.text()) | ||
return filename |
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,97 @@ | ||
import os | ||
from qgis.core import * | ||
from PyQt4.QtCore import * | ||
from PyQt4.QtGui import * | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
from sextante.parameters.ParameterTable import ParameterTable | ||
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput | ||
from sextante.parameters.ParameterRaster import ParameterRaster | ||
from sextante.outputs.OutputRaster import OutputRaster | ||
from sextante.parameters.ParameterVector import ParameterVector | ||
from sextante.parameters.ParameterBoolean import ParameterBoolean | ||
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException | ||
from sextante.core.SextanteLog import SextanteLog | ||
from sextante.parameters.ParameterFactory import ParameterFactory | ||
from sextante.outputs.OutputFactory import OutputFactory | ||
from sextante.core.SextanteUtils import SextanteUtils | ||
from sextante.otb.OTBUtils import OTBUtils | ||
|
||
class OTBAlgorithm(GeoAlgorithm): | ||
|
||
def __init__(self, descriptionfile): | ||
GeoAlgorithm.__init__(self) | ||
self.descriptionFile = descriptionfile | ||
self.defineCharacteristicsFromFile() | ||
self.numExportedLayers = 0 | ||
|
||
def __deepcopy__(self,memo): | ||
newone = OTBAlgorithm(self.descriptionFile) | ||
newone.provider = self.provider | ||
return newone | ||
|
||
def getIcon(self): | ||
return QIcon(os.path.dirname(__file__) + "/../images/otb.png") | ||
|
||
|
||
def defineCharacteristicsFromFile(self): | ||
lines = open(self.descriptionFile) | ||
line = lines.readline().strip("\n").strip() | ||
self.cliName = line | ||
line = lines.readline().strip("\n").strip() | ||
self.name = line | ||
line = lines.readline().strip("\n").strip() | ||
self.group = line | ||
while line != "": | ||
try: | ||
line = line.strip("\n").strip() | ||
if line.startswith("Parameter"): | ||
self.addParameter(ParameterFactory.getFromString(line)) | ||
else: | ||
self.addOutput(OutputFactory.getFromString(line)) | ||
line = lines.readline().strip("\n").strip() | ||
except Exception,e: | ||
SextanteLog.addToLog(SextanteLog.LOG_ERROR, "Could not open OTB algorithm: " + self.descriptionFile + "\n" + line) | ||
raise e | ||
lines.close() | ||
|
||
|
||
def processAlgorithm(self, progress): | ||
if SextanteUtils.isWindows(): | ||
path = OTBUtils.otbPath() | ||
libpath = OTBUtils.otbLibPath() | ||
if path == "" or libpath == "": | ||
raise GeoAlgorithmExecutionException("OTB folder is not configured.\nPlease configure it before running OTB algorithms.") | ||
|
||
commands = [] | ||
commands.append(path + os.sep + self.cliName) | ||
|
||
for param in self.parameters: | ||
if param.value == None: | ||
continue | ||
if isinstance(param, (ParameterRaster, ParameterVector)): | ||
commands.append(param.name) | ||
commands.append(param.value) | ||
elif isinstance(param, ParameterMultipleInput): | ||
commands.append(param.name) | ||
commands.append(str(param.value.replace(";"," "))) | ||
elif isinstance(param, ParameterBoolean): | ||
if param.value: | ||
commands.append(param.name) | ||
commands.append(str(param.value).lower()) | ||
else: | ||
commands.append(param.name) | ||
commands.append(str(param.value)) | ||
|
||
for out in self.outputs: | ||
commands.append(out.name) | ||
commands.append(out.value); | ||
|
||
|
||
loglines = [] | ||
loglines.append("OTB execution command") | ||
for line in commands: | ||
loglines.append(line) | ||
SextanteLog.addToLog(SextanteLog.LOG_INFO, loglines) | ||
OTBUtils.executeOtb(commands, progress) | ||
|
||
|
Oops, something went wrong.