Skip to content

Commit

Permalink
roadgraph GUI update
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15261 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
stopa85 committed Feb 25, 2011
1 parent daf8fbd commit 3519c16
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
27 changes: 11 additions & 16 deletions src/plugins/roadgraph/linevectorlayerwidget.cpp
Expand Up @@ -83,6 +83,12 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
mcbSpeed = new QComboBox( frame ); mcbSpeed = new QComboBox( frame );
h->addWidget( l ); h->addWidget( l );
h->addWidget( mcbSpeed ); h->addWidget( mcbSpeed );
mcbUnitOfSpeed = new QComboBox( this );
h->addWidget( mcbUnitOfSpeed );

mcbUnitOfSpeed->insertItem( 0, tr( "km/h" ) );
mcbUnitOfSpeed->insertItem( 0, tr( "m/s" ) );

v->addLayout( h ); v->addLayout( h );


frame = new QFrame( tab ); frame = new QFrame( tab );
Expand Down Expand Up @@ -116,22 +122,6 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
h->addWidget( msbSpeedDefault ); h->addWidget( msbSpeedDefault );
v->addLayout( h ); v->addLayout( h );


frame = new QFrame( tab );
tab->addTab( frame, tr( "Units" ) );
v = new QVBoxLayout( frame );
h = new QHBoxLayout();
l = new QLabel( tr( "Unit of speed" ) );
mcbUnitOfSpeed = new QComboBox( this );
h->addWidget( l );
h->addWidget( mcbUnitOfSpeed );
v->addLayout( h );

mcbUnitOfSpeed->insertItem( 0, tr( "km/h" ) );
mcbUnitOfSpeed->insertItem( 0, tr( "m/s" ) );
if ( s->mSpeedUnitName == "km/h" )
mcbUnitOfSpeed->setCurrentIndex( 1 );
else if ( s->mSpeedUnitName == "m/s" )
mcbUnitOfSpeed->setCurrentIndex( 0 );


// fill list of layers // fill list of layers
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
Expand Down Expand Up @@ -177,6 +167,11 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
mcbDirectionDefault->setCurrentIndex( 2 ); mcbDirectionDefault->setCurrentIndex( 2 );
break; break;
} }
if ( s->mSpeedUnitName == "km/h" )
mcbUnitOfSpeed->setCurrentIndex( 1 );
else if ( s->mSpeedUnitName == "m/s" )
mcbUnitOfSpeed->setCurrentIndex( 0 );

} // RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget() } // RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget()


QgsVectorLayer* RgLineVectorLayerSettingsWidget::selectedLayer() QgsVectorLayer* RgLineVectorLayerSettingsWidget::selectedLayer()
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/roadgraph/roadgraphplugin.cpp
Expand Up @@ -123,7 +123,10 @@ void RoadGraphPlugin::initGui()


connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) ); connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) );
connect( mQGisIface, SIGNAL( projectRead() ), this, SLOT( projectRead() ) ); connect( mQGisIface, SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
connect( mQGisIface , SIGNAL( newProjectCreated() ), this, SLOT( newProject() ) ); connect( mQGisIface, SIGNAL( newProjectCreated() ), this, SLOT( newProject() ) );
connect( mQGisIface, SIGNAL( projectRead() ), mQShortestPathDock, SLOT( clear() ) );
connect( mQGisIface, SIGNAL( newProjectCreated() ), mQShortestPathDock, SLOT( clear() ) );

// load settings // load settings
projectRead(); projectRead();
} // RoadGraphPlugin::initGui() } // RoadGraphPlugin::initGui()
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/roadgraph/shortestpathwidget.cpp
Expand Up @@ -250,7 +250,7 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Start point doesn't tie to the road!" ) ); QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Start point doesn't tie to the road!" ) );
return false; return false;
} }
if ( p1 == QgsPoint( 0.0, 0.0 ) ) if ( p2 == QgsPoint( 0.0, 0.0 ) )
{ {
QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Stop point doesn't tie to the road!" ) ); QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Stop point doesn't tie to the road!" ) );
return false; return false;
Expand All @@ -264,7 +264,11 @@ bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPo
DijkstraFinder f( m, criterion ); DijkstraFinder f( m, criterion );


matrix = f.find( p1, p2 ); matrix = f.find( p1, p2 );

if ( matrix.find( p1 ) == matrix.end() )
{
QMessageBox::critical( this, tr( "Path not found" ), tr( "Path not found" ) );
return false;
}
return true; return true;
} }


Expand Down Expand Up @@ -310,6 +314,8 @@ void RgShortestPathWidget::clear()
mBackPointLineEdit->setText( QString() ); mBackPointLineEdit->setText( QString() );
mrbBackPoint->reset( true ); mrbBackPoint->reset( true );
mrbPath->reset(); mrbPath->reset();
mPathCostLineEdit->setText( QString() );
mPathTimeLineEdit->setText( QString() );
} }


void RgShortestPathWidget::exportPath() void RgShortestPathWidget::exportPath()
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/roadgraph/shortestpathwidget.h
Expand Up @@ -96,11 +96,12 @@ class RgShortestPathWidget : public QDockWidget
*/ */
void clear(); void clear();


private:
/** /**
* retrun path as a graph * retrun path as a graph
*/ */
bool getPath( AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2 ); bool getPath( AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2 );
private:
/** /**
* This line edit show front points coordinates * This line edit show front points coordinates
*/ */
Expand Down

0 comments on commit 3519c16

Please sign in to comment.