Skip to content

Commit

Permalink
Add progress bar.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15330 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
stopa85 committed Mar 4, 2011
1 parent 42ee960 commit bfd6379
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/plugins/roadgraph/CMakeLists.txt
Expand Up @@ -19,6 +19,7 @@ SET (VRP_SRCS
#SET ([pluginlcasename]_UIS [pluginlcasename]guibase.ui)

SET (VRP_MOC_HDRS
graphdirector.h
roadgraphplugin.h
settingsdlg.h
shortestpathwidget.h
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/roadgraph/graphbuilder.h
Expand Up @@ -56,7 +56,7 @@ class RgGraphBuilder
/**
* 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;
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/roadgraph/graphdirector.h
Expand Up @@ -16,6 +16,7 @@
#define ROADGRAPH_GRAPHDIRECTOR

//QT4 includes
#include <QObject>

//QGIS includes
#include <qgsrectangle.h>
Expand All @@ -27,8 +28,14 @@ class RgGraphBuilder;
* \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() { };
Expand Down
10 changes: 7 additions & 3 deletions src/plugins/roadgraph/linevectorlayerdirector.cpp
Expand Up @@ -69,6 +69,9 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
if ( vl == NULL )
return;

int featureCount = ( int ) vl->featureCount() * 2;
int step = 0;

QgsCoordinateTransform ct( vl->crs(), builder->destinationCrs() );

QgsDistanceArea da;
Expand Down Expand Up @@ -117,6 +120,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
pt1 = pt2;
isFirstPoint = false;
}
emit buildProgress( ++step, featureCount );
}
// end: tie points to graph

Expand Down Expand Up @@ -212,12 +216,12 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
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;
Expand All @@ -227,7 +231,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
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 )

Expand Down
7 changes: 7 additions & 0 deletions src/plugins/roadgraph/shortestpathwidget.cpp
Expand Up @@ -222,7 +222,11 @@ void RgShortestPathWidget::setBackPoint( const QgsPoint& pt )
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() );
{
Expand All @@ -232,6 +236,9 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
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;

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/roadgraph/simplegraphbuilder.cpp
Expand Up @@ -53,9 +53,9 @@ QgsPoint RgSimpleGraphBuilder::addVertex( const QgsPoint& pt )
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()
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/roadgraph/simplegraphbuilder.h
Expand Up @@ -44,7 +44,7 @@ class RgSimpleGraphBuilder : public RgGraphBuilder
* 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;
Expand Down

0 comments on commit bfd6379

Please sign in to comment.