Skip to content
Permalink
Browse files

Add progress bar.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15330 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
stopa85
stopa85 committed Mar 4, 2011
1 parent 4c0c165 commit 86aae02d462dcd5d70fc5cdf61dc3e6ae7974f9b
@@ -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
@@ -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;
@@ -16,6 +16,7 @@
#define ROADGRAPH_GRAPHDIRECTOR

//QT4 includes
#include <QObject>

//QGIS includes
#include <qgsrectangle.h>
@@ -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() { };
@@ -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;
@@ -117,6 +120,7 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder, const QVecto
pt1 = pt2;
isFirstPoint = false;
}
emit buildProgress( ++step, featureCount );
}
// end: tie points to graph

@@ -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;
@@ -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 )

@@ -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() );
{
@@ -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;

@@ -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()
@@ -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;

0 comments on commit 86aae02

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