[QGIS Commit] r15330 - trunk/qgis/src/plugins/roadgraph
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Mar 4 08:09:51 EST 2011
Author: stopa85
Date: 2011-03-04 05:09:51 -0800 (Fri, 04 Mar 2011)
New Revision: 15330
Modified:
trunk/qgis/src/plugins/roadgraph/CMakeLists.txt
trunk/qgis/src/plugins/roadgraph/graphbuilder.h
trunk/qgis/src/plugins/roadgraph/graphdirector.h
trunk/qgis/src/plugins/roadgraph/linevectorlayerdirector.cpp
trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp
trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.cpp
trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.h
Log:
Add progress bar.
Modified: trunk/qgis/src/plugins/roadgraph/CMakeLists.txt
===================================================================
--- trunk/qgis/src/plugins/roadgraph/CMakeLists.txt 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/CMakeLists.txt 2011-03-04 13:09:51 UTC (rev 15330)
@@ -19,6 +19,7 @@
#SET ([pluginlcasename]_UIS [pluginlcasename]guibase.ui)
SET (VRP_MOC_HDRS
+ graphdirector.h
roadgraphplugin.h
settingsdlg.h
shortestpathwidget.h
Modified: trunk/qgis/src/plugins/roadgraph/graphbuilder.h
===================================================================
--- trunk/qgis/src/plugins/roadgraph/graphbuilder.h 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/graphbuilder.h 2011-03-04 13:09:51 UTC (rev 15330)
@@ -56,7 +56,7 @@
/**
* add arc
*/
- virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed ) = 0;
+ virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed, int featureId ) = 0;
private:
QgsCoordinateReferenceSystem mCrs;
Modified: trunk/qgis/src/plugins/roadgraph/graphdirector.h
===================================================================
--- trunk/qgis/src/plugins/roadgraph/graphdirector.h 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/graphdirector.h 2011-03-04 13:09:51 UTC (rev 15330)
@@ -16,6 +16,7 @@
#define ROADGRAPH_GRAPHDIRECTOR
//QT4 includes
+#include <QObject>
//QGIS includes
#include <qgsrectangle.h>
@@ -27,8 +28,14 @@
* \class RgGraphDirector
* \brief Determine making the graph
*/
-class RgGraphDirector
+class RgGraphDirector : public QObject
{
+ Q_OBJECT
+
+ signals:
+ void buildProgress( int, int ) const;
+ void buildMessage( QString ) const;
+
public:
//! Destructor
virtual ~RgGraphDirector() { };
Modified: trunk/qgis/src/plugins/roadgraph/linevectorlayerdirector.cpp
===================================================================
--- trunk/qgis/src/plugins/roadgraph/linevectorlayerdirector.cpp 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/linevectorlayerdirector.cpp 2011-03-04 13:09:51 UTC (rev 15330)
@@ -69,6 +69,9 @@
if ( vl == NULL )
return;
+ int featureCount = ( int ) vl->featureCount() * 2;
+ int step = 0;
+
QgsCoordinateTransform ct( vl->crs(), builder->destinationCrs() );
QgsDistanceArea da;
@@ -117,6 +120,7 @@
pt1 = pt2;
isFirstPoint = false;
}
+ emit buildProgress( ++step, featureCount );
}
// end: tie points to graph
@@ -212,12 +216,12 @@
if ( directionType == 1 ||
directionType == 3 )
{
- builder->addArc( pt1, pt2, cost, speed*su.multipler() );
+ builder->addArc( pt1, pt2, cost, speed*su.multipler(), feature.id() );
}
if ( directionType == 2 ||
directionType == 3 )
{
- builder->addArc( pt2, pt1, cost, speed*su.multipler() );
+ builder->addArc( pt2, pt1, cost, speed*su.multipler(), feature.id() );
}
}
pt1 = pt2;
@@ -227,7 +231,7 @@
pt1 = pt2;
isFirstPoint = false;
} // for (it = pl.begin(); it != pl.end(); ++it)
-
+ emit buildProgress( ++step, featureCount );
} // while( vl->nextFeature(feature) )
} // makeGraph( RgGraphBuilder *builder, const QgsRectangle& rt )
Modified: trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp
===================================================================
--- trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp 2011-03-04 13:09:51 UTC (rev 15330)
@@ -222,7 +222,11 @@
bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPoint& p2 )
{
if ( mFrontPointLineEdit->text().isNull() || mBackPointLineEdit->text().isNull() )
+ {
+ QMessageBox::critical( this, tr( "Point not selected" ), tr( "Frist, select start and stop points." ) );
return false;
+ }
+
RgSimpleGraphBuilder builder( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs(),
mPlugin->topologyToleranceFactor() );
{
@@ -232,6 +236,9 @@
QMessageBox::critical( this, tr( "Plugin isn't configured" ), tr( "Plugin isn't configured!" ) );
return false;
}
+ connect( director, SIGNAL( buildProgress( int, int ) ), mPlugin->iface()->mainWindow(), SLOT( showProgress( int, int ) ) );
+ connect( director, SIGNAL( buildMessage( QString ) ), mPlugin->iface()->mainWindow(), SLOT( showStatusMessage( QString ) ) );
+
QVector< QgsPoint > points;
QVector< QgsPoint > tiedPoint;
Modified: trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.cpp
===================================================================
--- trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.cpp 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.cpp 2011-03-04 13:09:51 UTC (rev 15330)
@@ -53,9 +53,9 @@
return pt;
}
-void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed )
+void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed, int featureId )
{
- mMatrix[ pt1 ][ pt2 ] = ArcAttributes( cost, cost / speed, 0 );
+ mMatrix[ pt1 ][ pt2 ] = ArcAttributes( cost, cost / speed, featureId );
}
AdjacencyMatrix RgSimpleGraphBuilder::adjacencyMatrix()
Modified: trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.h
===================================================================
--- trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.h 2011-03-04 07:14:17 UTC (rev 15329)
+++ trunk/qgis/src/plugins/roadgraph/simplegraphbuilder.h 2011-03-04 13:09:51 UTC (rev 15330)
@@ -44,7 +44,7 @@
* MANDATORY BUILDER PROPERTY DECLARATION
*/
QgsPoint addVertex( const QgsPoint& pt );
- void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed );
+ void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed, int featureId );
/**
* return Adjacecncy matrix;
More information about the QGIS-commit
mailing list