[QGIS Commit] r11217 - trunk/qgis/src/plugins/interpolation

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Jul 30 10:23:26 EDT 2009


Author: mhugent
Date: 2009-07-30 10:23:25 -0400 (Thu, 30 Jul 2009)
New Revision: 11217

Modified:
   trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp
   trunk/qgis/src/plugins/interpolation/qgstininterpolator.h
   trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.cpp
   trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.h
   trunk/qgis/src/plugins/interpolation/qgstininterpolatordialogbase.ui
Log:
FEATURE: possibility to save the triangulation to shape file (but needs a bit more error checking and polishing)

Modified: trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp	2009-07-30 13:54:10 UTC (rev 11216)
+++ trunk/qgis/src/plugins/interpolation/qgstininterpolator.cpp	2009-07-30 14:23:25 UTC (rev 11217)
@@ -31,7 +31,7 @@
 #endif
 
 QgsTINInterpolator::QgsTINInterpolator( const QList<LayerData>& inputData, bool showProgressDialog ): QgsInterpolator( inputData ), mTriangulation( 0 ), \
-    mTriangleInterpolator( 0 ), mIsInitialized( false ), mShowProgressDialog( showProgressDialog )
+    mTriangleInterpolator( 0 ), mIsInitialized( false ), mShowProgressDialog( showProgressDialog ), mExportTriangulationToFile( false )
 {
 }
 
@@ -123,7 +123,10 @@
   mIsInitialized = true;
 
   //debug
-  //theDualEdgeTriangulation->saveAsShapefile("/home/marco/tmp/tin.shp");
+  if ( mExportTriangulationToFile )
+  {
+    theDualEdgeTriangulation->saveAsShapefile( mTriangulationFilePath );
+  }
 }
 
 int QgsTINInterpolator::insertData( QgsFeature* f, bool zCoord, int attr, InputType type )

Modified: trunk/qgis/src/plugins/interpolation/qgstininterpolator.h
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgstininterpolator.h	2009-07-30 13:54:10 UTC (rev 11216)
+++ trunk/qgis/src/plugins/interpolation/qgstininterpolator.h	2009-07-30 14:23:25 UTC (rev 11217)
@@ -19,6 +19,7 @@
 #define QGSTININTERPOLATOR_H
 
 #include "qgsinterpolator.h"
+#include <QString>
 
 class Triangulation;
 class TriangleInterpolator;
@@ -38,11 +39,18 @@
        @return 0 in case of success*/
     int interpolatePoint( double x, double y, double& result );
 
+    void setExportTriangulationToFile( bool e ) {mExportTriangulationToFile = e;}
+    void setTriangulationFilePath( const QString& filepath ) {mTriangulationFilePath = filepath;}
+
   private:
     Triangulation* mTriangulation;
     TriangleInterpolator* mTriangleInterpolator;
     bool mIsInitialized;
     bool mShowProgressDialog;
+    /**If true: export triangulation to shapefile after initialisation*/
+    bool mExportTriangulationToFile;
+    /**File path to export the triangulation*/
+    QString mTriangulationFilePath;
 
     /**Create dual edge triangulation*/
     void initialize();

Modified: trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.cpp
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.cpp	2009-07-30 13:54:10 UTC (rev 11216)
+++ trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.cpp	2009-07-30 14:23:25 UTC (rev 11217)
@@ -17,13 +17,20 @@
 
 #include "qgstininterpolatordialog.h"
 #include "qgstininterpolator.h"
+#include <QFileDialog>
 
 QgsTINInterpolatorDialog::QgsTINInterpolatorDialog( QWidget* parent, QgisInterface* iface ): QgsInterpolatorDialog( parent, iface )
 {
   setupUi( this );
+
+  //don't export triangulation by default
+  mExportTriangulationCheckBox->setCheckState( Qt::Unchecked );
+  mTriangulationFileEdit->setEnabled( false );
+  mTriangulationFileButton->setEnabled( false );
+
   //enter available interpolation methods
   mInterpolationComboBox->insertItem( 0, tr( "Linear interpolation" ) );
-  //mInterpolationComboBox->insertItem(1, tr("Clough-Toucher interpolation"));
+  //mInterpolationComboBox->insertItem(1, tr("Clough-Toucher interpolation")); //to come...
 }
 
 QgsTINInterpolatorDialog::~QgsTINInterpolatorDialog()
@@ -34,5 +41,34 @@
 QgsInterpolator* QgsTINInterpolatorDialog::createInterpolator() const
 {
   QgsTINInterpolator* theInterpolator = new QgsTINInterpolator( mInputData, true );
+  if ( mExportTriangulationCheckBox->checkState() == Qt::Checked )
+  {
+    theInterpolator->setExportTriangulationToFile( true );
+    theInterpolator->setTriangulationFilePath( mTriangulationFileEdit->text() );
+  }
+  else
+  {
+    theInterpolator->setExportTriangulationToFile( false );
+  }
   return theInterpolator;
 }
+
+void QgsTINInterpolatorDialog::on_mExportTriangulationCheckBox_stateChanged( int state )
+{
+  if ( state == Qt::Checked )
+  {
+    mTriangulationFileEdit->setEnabled( true );
+    mTriangulationFileButton->setEnabled( true );
+  }
+  else
+  {
+    mTriangulationFileEdit->setEnabled( false );
+    mTriangulationFileButton->setEnabled( false );
+  }
+}
+
+void QgsTINInterpolatorDialog::on_mTriangulationFileButton_clicked()
+{
+  QString filename = QFileDialog::getSaveFileName( 0, tr( "Save triangulation to file" ), QString(), "*shp" );
+  mTriangulationFileEdit->setText( filename );
+}

Modified: trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.h
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.h	2009-07-30 13:54:10 UTC (rev 11216)
+++ trunk/qgis/src/plugins/interpolation/qgstininterpolatordialog.h	2009-07-30 14:23:25 UTC (rev 11217)
@@ -32,6 +32,10 @@
     /**Method that returns an interpolator object from the settings or 0 in case of error.
      The calling method takes ownership of the created interpolator and is responsible for its proper destruction*/
     QgsInterpolator* createInterpolator() const;
+
+  private slots:
+    void on_mExportTriangulationCheckBox_stateChanged( int state );
+    void on_mTriangulationFileButton_clicked();
 };
 
 #endif

Modified: trunk/qgis/src/plugins/interpolation/qgstininterpolatordialogbase.ui
===================================================================
--- trunk/qgis/src/plugins/interpolation/qgstininterpolatordialogbase.ui	2009-07-30 13:54:10 UTC (rev 11216)
+++ trunk/qgis/src/plugins/interpolation/qgstininterpolatordialogbase.ui	2009-07-30 14:23:25 UTC (rev 11217)
@@ -5,25 +5,26 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>198</height>
+    <width>394</width>
+    <height>240</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>Triangle based interpolation</string>
   </property>
-  <layout class="QGridLayout" >
-   <item row="0" column="0" >
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" colspan="2" >
     <widget class="QTextBrowser" name="mDescriptionTextBrowser" >
      <property name="html" >
-      <string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+      <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
 p, li { white-space: pre-wrap; }
-&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:12pt; font-weight:400; font-style:normal;">
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This interpolator provides different methods for interpolation in a triangular irregular network (TIN).&lt;/p>&lt;/body>&lt;/html></string>
+&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:12pt;">This interpolator provides different methods for interpolation in a triangular irregular network (TIN).&lt;/p>&lt;/body>&lt;/html></string>
      </property>
     </widget>
    </item>
-   <item row="1" column="0" >
+   <item row="1" column="0" colspan="2" >
     <layout class="QHBoxLayout" >
      <item>
       <widget class="QLabel" name="mInterpolationMethodLabel" >
@@ -37,13 +38,30 @@
      </item>
     </layout>
    </item>
-   <item row="2" column="0" >
+   <item row="2" column="0" colspan="2" >
+    <widget class="QCheckBox" name="mExportTriangulationCheckBox" >
+     <property name="text" >
+      <string>Export triangulation to shapefile after interpolation</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" >
+    <widget class="QLineEdit" name="mTriangulationFileEdit" />
+   </item>
+   <item row="3" column="1" >
+    <widget class="QPushButton" name="mTriangulationFileButton" >
+     <property name="text" >
+      <string>...</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="0" colspan="2" >
     <widget class="QDialogButtonBox" name="buttonBox" >
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
      <property name="standardButtons" >
-      <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
      </property>
     </widget>
    </item>



More information about the QGIS-commit mailing list