Skip to content
Permalink
Browse files

GdalTools overview : update for qgis and sip api, remove old widgets

  • Loading branch information
etiennesky committed Jun 4, 2013
1 parent 54b2efd commit 014d872f071bebacccd5df12f9fa01214fcf1c4b
@@ -162,6 +162,7 @@ def onRun(self):
self.enableRun(False)
self.setCursor(Qt.WaitCursor)
if not self.commandIsEditable():
#print(self.command+' '+str(self.arguments))
self.process.start(self.command, self.arguments, QIODevice.ReadOnly)
else:
self.process.start(self.textEditCommand.toPlainText(), QIODevice.ReadOnly)
@@ -46,7 +46,6 @@ def __init__( self, iface ):

# set the default QSpinBoxes and QProgressBar value
self.progressBar.setValue(0)
self.jpegQualitySpin.setValue(80)

self.progressBar.hide()
# we don't need load to canvas functionality
@@ -55,13 +54,6 @@ def __init__( self, iface ):
self.setParamsStatus(
[
( self.inSelector, SIGNAL("filenameChanged()")),
( self.algorithmCombo, SIGNAL( "currentIndexChanged( int )" ), self.algorithmCheck ),
( self.levelsEdit, SIGNAL( "textChanged( const QString & )" ) ),
( self.roModeCheck, SIGNAL( "stateChanged( int )" ), None, 1600 ),
( self.rrdCheck, SIGNAL( "stateChanged(int)" ) ),
( self.jpegQualitySpin, SIGNAL( "valueChanged (int)" ) ),
( self.jpegQualityContainer, None, self.tiffjpegCheck),
( self.jpegQualityContainer, None, None, 1700),
( self.cleanCheck, SIGNAL( "stateChanged(int)" ), None, 1700 ),
( self.mPyramidOptionsWidget, SIGNAL( "overviewListChanged()" )),
( self.mPyramidOptionsWidget, SIGNAL( "someValueChanged()" ))
@@ -73,6 +65,11 @@ def __init__( self, iface ):

self.init = False #workaround bug that pyramid options widgets are not initialized at first

# make sure we get a command line when dialog appears
def show_(self):
BaseBatchWidget.show_(self)
self.someValueChanged()

# switch to batch or normal mode
def switchToolMode( self ):
self.setCommandViewerEnabled( not self.batchCheck.isChecked() )
@@ -98,7 +95,7 @@ def onLayersChanged(self):
def fillInputFile( self ):
lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
inputFile = Utils.FileDialog.getOpenFileName( self, self.tr( "Select the input file" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
if inputFile.isEmpty():
if inputFile == '':
return
Utils.FileFilter.setLastUsedRasterFilter( lastUsedFilter )

@@ -108,39 +105,45 @@ def fillInputFile( self ):

def fillInputDir( self ):
inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files" ))
if inputDir.isEmpty():
if inputDir == '':

This comment has been minimized.

Copy link
@NathanW2

NathanW2 Jun 4, 2013

Member

You can also do: if not inputDir:

return

self.inSelector.setFilename( inputDir )

def getArguments( self ):
arguments = QStringList()
arguments = []

arguments << "-r"
arguments << self.mPyramidOptionsWidget.resamplingMethod();
arguments.append("-r")
arguments.append(self.mPyramidOptionsWidget.resamplingMethod())

format = self.mPyramidOptionsWidget.pyramidsFormat()
if format == QgsRasterDataProvider.PyramidsGTiff:
arguments << "-ro"
elif format == QgsRasterDataProvider.PyramidsErdas:
arguments << "--config" << "USE_RRD" << "YES"
if format == QgsRaster.PyramidsGTiff:
arguments.append("-ro")
elif format == QgsRaster.PyramidsErdas:
arguments.append("--config")
arguments.append("USE_RRD")
arguments.append("YES")

for option in self.mPyramidOptionsWidget.configOptions():
(k,v) = option.split("=")
arguments << "--config" << str(k) << str(v)
arguments.append("--config")
arguments.append(str(k))
arguments.append(str(v))

if self.cleanCheck.isChecked():
arguments << "-clean"
arguments.append("-clean")

# TODO fix batch enabled, argument order is wrong, levels not at end
if self.isBatchEnabled():
return arguments

arguments << self.getInputFileName()
arguments.append(self.getInputFileName())

if len(self.mPyramidOptionsWidget.overviewList()) == 0:
arguments << "[levels]"
for level in self.mPyramidOptionsWidget.overviewList():
arguments << str(level)
arguments.append(self.tr("[select levels]"))
else:
for level in self.mPyramidOptionsWidget.overviewList():
arguments.append(str(level))

# set creation options filename/layer for validation
if self.init:
@@ -166,11 +169,12 @@ def addLayerIntoCanvas(self, fileInfo):

def getBatchArguments(self, inFile, outFile = None):
arguments = self.getArguments()
arguments << inFile
if not self.levelsEdit.text().isEmpty():
arguments << self.levelsEdit.text().split( " " )
arguments.append(inFile)
if len(self.mPyramidOptionsWidget.overviewList()) == 0:
arguments.extend(["2", "4", "8", "16", "32"])
else:
arguments << "2" << "4" << "8" << "16" << "32"
for level in self.mPyramidOptionsWidget.overviewList():
arguments.append(str(level))
return arguments

def isBatchEnabled(self):
@@ -182,8 +186,8 @@ def onFinished(self, exitCode, status):
BasePluginWidget.onFinished(self, exitCode, status)
return

msg = QString.fromLocal8Bit( self.base.process.readAllStandardError() )
if not msg.isEmpty():
msg = str( self.base.process.readAllStandardError() )
if msg != '':
self.errors.append( ">> " + self.inFiles[self.batchIndex] + "<br>" + msg.replace( "\n", "<br>" ) )

self.base.process.close()
@@ -38,10 +38,10 @@ def __init__(self, iface, commandName):

def getBatchArguments(self, inFile, outFile = None):
arguments = []
arguments.append( self.getArguments() )
arguments.extend( self.getArguments() )
arguments.append( inFile )
if outFile != None:
arguments << outFile
arguments.append(outFile)
return arguments

def isBatchEnabled(self):
@@ -113,7 +113,7 @@ def onFinished(self, exitCode, status):
return

msg = bytes.decode( bytes( self.base.process.readAllStandardError() ) )
if not msg.isEmpty():
if msg != '':
self.errors.append( ">> " + self.inFiles[self.batchIndex] + "<br>" + msg.replace( "\n", "<br>" ) )

self.base.process.close()
@@ -133,7 +133,7 @@ def onFinished(self, exitCode, status):
def batchFinished( self ):
self.base.stop()

if not self.errors.isEmpty():
if len(self.errors) > 0:
msg = u"Processing of the following files ended with error: <br><br>" + "<br><br>".join( self.errors )
QErrorMessage( self ).showMessage( msg )

@@ -22,6 +22,9 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="batchCheck">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Batch mode (for processing whole directory)</string>
</property>
@@ -55,183 +58,13 @@
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<widget class="QgsRasterPyramidsOptionsWidget" name="mPyramidOptionsWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>old</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Levels (space delimited)</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="rrdCheck">
<property name="toolTip">
<string>Alternate overview format using Erdas Imagine format,
placing the overviews in an associated .aux file
suitable for direct use with Imagine,ArcGIS, GDAL.</string>
</property>
<property name="text">
<string>Use Imagine format (.aux file)</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QFrame" name="jpegQualityContainer">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>24</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="jpegQualityLabel">
<property name="toolTip">
<string>For JPEG compressed external overviews,
the JPEG quality can be set.</string>
</property>
<property name="text">
<string>JPEG Quality (1-100)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="jpegQualitySpin">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>For JPEG compressed external overviews,
the JPEG quality can be set.</string>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="levelsEdit"/>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="tiffjpegCheck">
<property name="toolTip">
<string>Create external overviews in TIFF format, compressed using JPEG.</string>
</property>
<property name="text">
<string>Overviews in TIFF format with JPEG compression</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="roModeCheck">
<property name="toolTip">
<string>In order to generate external overview (for GeoTIFF especially).</string>
</property>
<property name="text">
<string>Open in read-only mode</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="algorithmCheck">
<property name="text">
<string>Resampling method</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="algorithmCombo">
<item>
<property name="text">
<string>nearest</string>
</property>
</item>
<item>
<property name="text">
<string>average</string>
</property>
</item>
<item>
<property name="text">
<string>gauss</string>
</property>
</item>
<item>
<property name="text">
<string>cubic</string>
</property>
</item>
<item>
<property name="text">
<string>average_mp</string>
</property>
</item>
<item>
<property name="text">
<string>average_magphase</string>
</property>
</item>
<item>
<property name="text">
<string>mode</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>new</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QgsRasterPyramidsOptionsWidget" name="mPyramidOptionsWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>

0 comments on commit 014d872

Please sign in to comment.
You can’t perform that action at this time.