[QGIS Commit] r15261 - trunk/qgis/src/plugins/roadgraph

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Feb 25 05:37:35 EST 2011


Author: stopa85
Date: 2011-02-25 02:37:35 -0800 (Fri, 25 Feb 2011)
New Revision: 15261

Modified:
   trunk/qgis/src/plugins/roadgraph/linevectorlayerwidget.cpp
   trunk/qgis/src/plugins/roadgraph/roadgraphplugin.cpp
   trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp
   trunk/qgis/src/plugins/roadgraph/shortestpathwidget.h
Log:
roadgraph GUI update

Modified: trunk/qgis/src/plugins/roadgraph/linevectorlayerwidget.cpp
===================================================================
--- trunk/qgis/src/plugins/roadgraph/linevectorlayerwidget.cpp	2011-02-24 21:01:23 UTC (rev 15260)
+++ trunk/qgis/src/plugins/roadgraph/linevectorlayerwidget.cpp	2011-02-25 10:37:35 UTC (rev 15261)
@@ -83,6 +83,12 @@
   mcbSpeed = new QComboBox( frame );
   h->addWidget( l );
   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 );
 
   frame = new QFrame( tab );
@@ -116,23 +122,7 @@
   h->addWidget( msbSpeedDefault );
   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
   QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
   QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
@@ -177,6 +167,11 @@
       mcbDirectionDefault->setCurrentIndex( 2 );
       break;
   }
+  if ( s->mSpeedUnitName == "km/h" )
+    mcbUnitOfSpeed->setCurrentIndex( 1 );
+  else if ( s->mSpeedUnitName == "m/s" )
+    mcbUnitOfSpeed->setCurrentIndex( 0 );
+
 } // RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget()
 
 QgsVectorLayer* RgLineVectorLayerSettingsWidget::selectedLayer()

Modified: trunk/qgis/src/plugins/roadgraph/roadgraphplugin.cpp
===================================================================
--- trunk/qgis/src/plugins/roadgraph/roadgraphplugin.cpp	2011-02-24 21:01:23 UTC (rev 15260)
+++ trunk/qgis/src/plugins/roadgraph/roadgraphplugin.cpp	2011-02-25 10:37:35 UTC (rev 15261)
@@ -123,7 +123,10 @@
 
   connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) );
   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
   projectRead();
 } // RoadGraphPlugin::initGui()

Modified: trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp
===================================================================
--- trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp	2011-02-24 21:01:23 UTC (rev 15260)
+++ trunk/qgis/src/plugins/roadgraph/shortestpathwidget.cpp	2011-02-25 10:37:35 UTC (rev 15261)
@@ -250,7 +250,7 @@
     QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Start point doesn't tie to the road!" ) );
     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!" ) );
     return false;
@@ -264,7 +264,11 @@
   DijkstraFinder f( m, criterion );
 
   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;
 }
 
@@ -310,6 +314,8 @@
   mBackPointLineEdit->setText( QString() );
   mrbBackPoint->reset( true );
   mrbPath->reset();
+  mPathCostLineEdit->setText( QString() );
+  mPathTimeLineEdit->setText( QString() );
 }
 
 void RgShortestPathWidget::exportPath()

Modified: trunk/qgis/src/plugins/roadgraph/shortestpathwidget.h
===================================================================
--- trunk/qgis/src/plugins/roadgraph/shortestpathwidget.h	2011-02-24 21:01:23 UTC (rev 15260)
+++ trunk/qgis/src/plugins/roadgraph/shortestpathwidget.h	2011-02-25 10:37:35 UTC (rev 15261)
@@ -96,11 +96,12 @@
      */
     void clear();
 
+  private:
     /**
      * retrun path as a graph
      */
     bool getPath( AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2 );
-  private:
+
     /**
      * This line edit show front points coordinates
      */



More information about the QGIS-commit mailing list