[QGIS Commit] r15476 - in trunk/qgis/python/plugins/GdalTools: . tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Mar 14 13:17:37 EDT 2011


Author: brushtyler
Date: 2011-03-14 10:17:37 -0700 (Mon, 14 Mar 2011)
New Revision: 15476

Modified:
   trunk/qgis/python/plugins/GdalTools/__init__.py
   trunk/qgis/python/plugins/GdalTools/tools/doWarp.py
   trunk/qgis/python/plugins/GdalTools/tools/widgetWarp.ui
Log:
added -cutline option to gdaltools warp tool, to fix #3066


Modified: trunk/qgis/python/plugins/GdalTools/__init__.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/__init__.py	2011-03-14 16:47:41 UTC (rev 15475)
+++ trunk/qgis/python/plugins/GdalTools/__init__.py	2011-03-14 17:17:37 UTC (rev 15476)
@@ -22,7 +22,7 @@
 def description():
   return "Integrate gdal tools into qgis"
 def version(): 
-  return "Version 1.2.22" 
+  return "Version 1.2.23" 
 def qgisMinimumVersion():
   return "1.0"
 def icon():

Modified: trunk/qgis/python/plugins/GdalTools/tools/doWarp.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doWarp.py	2011-03-14 16:47:41 UTC (rev 15475)
+++ trunk/qgis/python/plugins/GdalTools/tools/doWarp.py	2011-03-14 17:17:37 UTC (rev 15476)
@@ -40,7 +40,9 @@
           (self.cacheSpin, SIGNAL("valueChanged(int)"), self.cacheCheck),
           ( [self.widthSpin, self.heightSpin], SIGNAL( "valueChanged(int)" ), self.resizeGroupBox ),
           (self.multithreadCheck, SIGNAL("stateChanged(int)")),
-          (self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck)
+          (self.noDataEdit, SIGNAL( "textChanged( const QString & )" ), self.noDataCheck), 
+          (self.cutlineLayerCombo, [SIGNAL("currentIndexChanged(int)"), SIGNAL("editTextChanged(const QString &)")], self.cutlineCheck, "1.6.0"), 
+          (self.selectCutlineFileButton, None, self.cutlineCheck, "1.6.0")
         ]
       )
 
@@ -49,6 +51,7 @@
       self.connect(self.selectOutputFileButton, SIGNAL("clicked()"), self.fillOutputFileEdit)
       self.connect(self.selectSourceSRSButton, SIGNAL("clicked()"), self.fillSourceSRSEdit)
       self.connect(self.selectTargetSRSButton, SIGNAL("clicked()"), self.fillTargetSRSEdit)
+      self.connect(self.selectCutlineFileButton, SIGNAL("clicked()"), self.fillCutlineFile)
       self.connect( self.batchCheck, SIGNAL( "stateChanged( int )" ), self.switchToolMode )
 
 
@@ -90,12 +93,19 @@
 
   def onLayersChanged(self):
       self.fillInputLayerCombo()
+      self.fillCutlineLayerCombo()
 
   def fillInputLayerCombo(self):
       self.inputLayerCombo.clear()
-      ( self.layers, names ) = Utils.LayerRegistry.instance().getRasterLayers()
+      ( self.inputLayers, names ) = Utils.LayerRegistry.instance().getRasterLayers()
       self.inputLayerCombo.addItems( names )
 
+  def fillCutlineLayerCombo(self):
+      self.cutlineLayerCombo.clear()
+      ( self.cutlineLayers, names ) = Utils.LayerRegistry.instance().getVectorLayers()
+      self.cutlineLayerCombo.addItems( names )
+
+
   def fillInputFile(self):
       lastUsedFilter = Utils.FileFilter.lastUsedRasterFilter()
       inputFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the input file for Warp" ), Utils.FileFilter.allRastersFilter(), lastUsedFilter )
@@ -119,6 +129,17 @@
       self.outputFormat = Utils.fillRasterOutputFormat( lastUsedFilter, outputFile )
       self.outputFileEdit.setText(outputFile)
 
+  def fillCutlineFile(self):
+      lastUsedFilter = Utils.FileFilter.lastUsedVectorFilter()
+      cutlineFile = Utils.FileDialog.getOpenFileName(self, self.tr( "Select the cutline file" ), Utils.FileFilter.allVectorsFilter(), lastUsedFilter )
+      if cutlineFile.isEmpty():
+        return
+      Utils.FileFilter.setLastUsedVectorFilter(lastUsedFilter)
+
+      self.cutlineLayerCombo.setCurrentIndex(-1)
+      self.cutlineLayerCombo.setEditText(cutlineFile)
+
+
   def fillInputDir( self ):
       inputDir = Utils.FileDialog.getExistingDirectory( self, self.tr( "Select the input directory with files to Warp" ))
       if inputDir.isEmpty():
@@ -187,6 +208,13 @@
         if not nodata.isEmpty():
           arguments << "-dstnodata"
           arguments << nodata
+      if self.cutlineCheck.isChecked():
+        cutline = self.getCutlineFileName()
+        if not cutline.isEmpty():
+          arguments << "-q"
+          arguments << "-cutline"
+          arguments << cutline
+          arguments << "-dstalpha"
       if self.isBatchEnabled():
         return arguments
 
@@ -199,12 +227,17 @@
 
   def getInputFileName(self):
       if self.inputLayerCombo.currentIndex() >= 0:
-        return self.layers[self.inputLayerCombo.currentIndex()].source()
+        return self.inputLayers[self.inputLayerCombo.currentIndex()].source()
       return self.inputLayerCombo.currentText()
 
   def getOutputFileName(self):
       return self.outputFileEdit.text()
 
+  def getCutlineFileName(self):
+      if self.cutlineLayerCombo.currentIndex() >= 0:
+        return self.cutlineLayers[self.cutlineLayerCombo.currentIndex()].source()
+      return self.cutlineLayerCombo.currentText()
+
   def addLayerIntoCanvas(self, fileInfo):
       self.iface.addRasterLayer(fileInfo.filePath())
 

Modified: trunk/qgis/python/plugins/GdalTools/tools/widgetWarp.ui
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/widgetWarp.ui	2011-03-14 16:47:41 UTC (rev 15475)
+++ trunk/qgis/python/plugins/GdalTools/tools/widgetWarp.ui	2011-03-14 17:17:37 UTC (rev 15476)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>415</width>
-    <height>417</height>
+    <height>453</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -19,15 +19,15 @@
   <property name="windowTitle">
    <string>Warp</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
     <widget class="QCheckBox" name="batchCheck">
      <property name="text">
       <string>Batch mode (for processing whole directory)</string>
      </property>
     </widget>
    </item>
-   <item>
+   <item row="1" column="0">
     <layout class="QGridLayout" name="gridLayout_2">
      <item row="0" column="0">
       <widget class="QLabel" name="label">
@@ -203,14 +203,14 @@
        </property>
       </widget>
      </item>
-     <item row="6" column="0">
+     <item row="7" column="0">
       <widget class="QCheckBox" name="cacheCheck">
        <property name="text">
         <string>&amp;Memory used for caching</string>
        </property>
       </widget>
      </item>
-     <item row="6" column="1">
+     <item row="7" column="1">
       <widget class="QSpinBox" name="cacheSpin">
        <property name="suffix">
         <string>MB</string>
@@ -223,9 +223,43 @@
        </property>
       </widget>
      </item>
+     <item row="6" column="0">
+      <widget class="QCheckBox" name="cutlineCheck">
+       <property name="text">
+        <string>Cutline</string>
+       </property>
+      </widget>
+     </item>
+     <item row="6" column="1">
+      <layout class="QHBoxLayout" name="horizontalLayout_5">
+       <item>
+        <widget class="QComboBox" name="cutlineLayerCombo">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="editable">
+          <bool>true</bool>
+         </property>
+         <property name="insertPolicy">
+          <enum>QComboBox::NoInsert</enum>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="selectCutlineFileButton">
+         <property name="text">
+          <string>Select...</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
     </layout>
    </item>
-   <item>
+   <item row="2" column="0">
     <widget class="QGroupBox" name="resizeGroupBox">
      <property name="title">
       <string>Resize</string>
@@ -283,10 +317,10 @@
      </layout>
     </widget>
    </item>
-   <item>
+   <item row="3" column="0">
     <widget class="QProgressBar" name="progressBar"/>
    </item>
-   <item>
+   <item row="4" column="0">
     <widget class="QCheckBox" name="multithreadCheck">
      <property name="text">
       <string>Use m&amp;ultithreaded warping implementation</string>



More information about the QGIS-commit mailing list