Skip to content

Commit 86aae02

Browse files
author
stopa85
committed
Add progress bar.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15330 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4c0c165 commit 86aae02

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

src/plugins/roadgraph/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ SET (VRP_SRCS
1919
#SET ([pluginlcasename]_UIS [pluginlcasename]guibase.ui)
2020

2121
SET (VRP_MOC_HDRS
22+
graphdirector.h
2223
roadgraphplugin.h
2324
settingsdlg.h
2425
shortestpathwidget.h

src/plugins/roadgraph/graphbuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class RgGraphBuilder
5656
/**
5757
* add arc
5858
*/
59-
virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed ) = 0;
59+
virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed, int featureId ) = 0;
6060

6161
private:
6262
QgsCoordinateReferenceSystem mCrs;

src/plugins/roadgraph/graphdirector.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define ROADGRAPH_GRAPHDIRECTOR
1717

1818
//QT4 includes
19+
#include <QObject>
1920

2021
//QGIS includes
2122
#include <qgsrectangle.h>
@@ -27,8 +28,14 @@ class RgGraphBuilder;
2728
* \class RgGraphDirector
2829
* \brief Determine making the graph
2930
*/
30-
class RgGraphDirector
31+
class RgGraphDirector : public QObject
3132
{
33+
Q_OBJECT
34+
35+
signals:
36+
void buildProgress( int, int ) const;
37+
void buildMessage( QString ) const;
38+
3239
public:
3340
//! Destructor
3441
virtual ~RgGraphDirector() { };

src/plugins/roadgraph/linevectorlayerdirector.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
6969
if ( vl == NULL )
7070
return;
7171

72+
int featureCount = ( int ) vl->featureCount() * 2;
73+
int step = 0;
74+
7275
QgsCoordinateTransform ct( vl->crs(), builder->destinationCrs() );
7376

7477
QgsDistanceArea da;
@@ -117,6 +120,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
117120
pt1 = pt2;
118121
isFirstPoint = false;
119122
}
123+
emit buildProgress( ++step, featureCount );
120124
}
121125
// end: tie points to graph
122126

@@ -212,12 +216,12 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
212216
if ( directionType == 1 ||
213217
directionType == 3 )
214218
{
215-
builder->addArc( pt1, pt2, cost, speed*su.multipler() );
219+
builder->addArc( pt1, pt2, cost, speed*su.multipler(), feature.id() );
216220
}
217221
if ( directionType == 2 ||
218222
directionType == 3 )
219223
{
220-
builder->addArc( pt2, pt1, cost, speed*su.multipler() );
224+
builder->addArc( pt2, pt1, cost, speed*su.multipler(), feature.id() );
221225
}
222226
}
223227
pt1 = pt2;
@@ -227,7 +231,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
227231
pt1 = pt2;
228232
isFirstPoint = false;
229233
} // for (it = pl.begin(); it != pl.end(); ++it)
230-
234+
emit buildProgress( ++step, featureCount );
231235
} // while( vl->nextFeature(feature) )
232236
} // makeGraph( RgGraphBuilder *builder, const QgsRectangle& rt )
233237

src/plugins/roadgraph/shortestpathwidget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ void RgShortestPathWidget::setBackPoint( const QgsPoint& pt )
222222
bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPoint& p2 )
223223
{
224224
if ( mFrontPointLineEdit->text().isNull() || mBackPointLineEdit->text().isNull() )
225+
{
226+
QMessageBox::critical( this, tr( "Point not selected" ), tr( "Frist, select start and stop points." ) );
225227
return false;
228+
}
229+
226230
RgSimpleGraphBuilder builder( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs(),
227231
mPlugin->topologyToleranceFactor() );
228232
{
@@ -232,6 +236,9 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
232236
QMessageBox::critical( this, tr( "Plugin isn't configured" ), tr( "Plugin isn't configured!" ) );
233237
return false;
234238
}
239+
connect( director, SIGNAL( buildProgress( int, int ) ), mPlugin->iface()->mainWindow(), SLOT( showProgress( int, int ) ) );
240+
connect( director, SIGNAL( buildMessage( QString ) ), mPlugin->iface()->mainWindow(), SLOT( showStatusMessage( QString ) ) );
241+
235242
QVector< QgsPoint > points;
236243
QVector< QgsPoint > tiedPoint;
237244

src/plugins/roadgraph/simplegraphbuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ QgsPoint RgSimpleGraphBuilder::addVertex( const QgsPoint& pt )
5353
return pt;
5454
}
5555

56-
void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed )
56+
void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed, int featureId )
5757
{
58-
mMatrix[ pt1 ][ pt2 ] = ArcAttributes( cost, cost / speed, 0 );
58+
mMatrix[ pt1 ][ pt2 ] = ArcAttributes( cost, cost / speed, featureId );
5959
}
6060

6161
AdjacencyMatrix RgSimpleGraphBuilder::adjacencyMatrix()

src/plugins/roadgraph/simplegraphbuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class RgSimpleGraphBuilder : public RgGraphBuilder
4444
* MANDATORY BUILDER PROPERTY DECLARATION
4545
*/
4646
QgsPoint addVertex( const QgsPoint& pt );
47-
void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed );
47+
void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double cost, double speed, int featureId );
4848

4949
/**
5050
* return Adjacecncy matrix;

0 commit comments

Comments
 (0)