Skip to content
Permalink
Browse files

FEATURE: possibility to save the triangulation to shape file (but nee…

…ds a bit more error checking and polishing)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11217 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jul 30, 2009
1 parent f60b435 commit a483e578b44f17be7210a41b2a01ad3cca141ee8
@@ -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 @@ void QgsTINInterpolator::initialize()
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 )
@@ -19,6 +19,7 @@
#define QGSTININTERPOLATOR_H

#include "qgsinterpolator.h"
#include <QString>

class Triangulation;
class TriangleInterpolator;
@@ -38,11 +39,18 @@ class QgsTINInterpolator: public QgsInterpolator
@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();
@@ -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 @@ QgsTINInterpolatorDialog::~QgsTINInterpolatorDialog()
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 );
}
@@ -32,6 +32,10 @@ class QgsTINInterpolatorDialog: public QgsInterpolatorDialog, private Ui::QgsTIN
/**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
@@ -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 @@ p, li { white-space: pre-wrap; }
</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>

0 comments on commit a483e57

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