Skip to content
Permalink
Browse files

Road-Graph plugin added

git-svn-id: http://svn.osgeo.org/qgis/trunk@15068 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
stopa85
stopa85 committed Jan 24, 2011
1 parent 864b1f0 commit 0a76ab4212ab5c5ef63c98f8a978034e2c0c42d2
Showing with 3,186 additions and 0 deletions.
  1. +1 −0 src/plugins/CMakeLists.txt
  2. +57 −0 src/plugins/roadgraph/CMakeLists.txt
  3. BIN src/plugins/roadgraph/about.png
  4. BIN src/plugins/roadgraph/coordinate_capture.png
  5. +112 −0 src/plugins/roadgraph/exportdlg.cpp
  6. +54 −0 src/plugins/roadgraph/exportdlg.h
  7. +69 −0 src/plugins/roadgraph/graphbuilder.h
  8. +53 −0 src/plugins/roadgraph/graphdirector.h
  9. +153 −0 src/plugins/roadgraph/linevectorlayerdirector.cpp
  10. +53 −0 src/plugins/roadgraph/linevectorlayerdirector.h
  11. +145 −0 src/plugins/roadgraph/linevectorlayersettings.cpp
  12. +110 −0 src/plugins/roadgraph/linevectorlayersettings.h
  13. +233 −0 src/plugins/roadgraph/linevectorlayerwidget.cpp
  14. +97 −0 src/plugins/roadgraph/linevectorlayerwidget.h
  15. BIN src/plugins/roadgraph/roadgraph.png
  16. +8 −0 src/plugins/roadgraph/roadgraph.qrc
  17. +359 −0 src/plugins/roadgraph/roadgraphplugin.cpp
  18. +160 −0 src/plugins/roadgraph/roadgraphplugin.h
  19. +59 −0 src/plugins/roadgraph/settings.h
  20. +119 −0 src/plugins/roadgraph/settingsdlg.cpp
  21. +79 −0 src/plugins/roadgraph/settingsdlg.h
  22. +334 −0 src/plugins/roadgraph/shortestpathwidget.cpp
  23. +179 −0 src/plugins/roadgraph/shortestpathwidget.h
  24. BIN src/plugins/roadgraph/showdirect.png
  25. +85 −0 src/plugins/roadgraph/showdirect.svg
  26. +119 −0 src/plugins/roadgraph/simplegraphbuilder.cpp
  27. +63 −0 src/plugins/roadgraph/simplegraphbuilder.h
  28. +93 −0 src/plugins/roadgraph/units.cpp
  29. +90 −0 src/plugins/roadgraph/units.h
  30. +166 −0 src/plugins/roadgraph/utils.cpp
  31. +136 −0 src/plugins/roadgraph/utils.h
@@ -14,6 +14,7 @@ SUBDIRS (copyright_label
point_displacement_renderer
spatialquery
sqlanywhere
roadgraph
)

IF (WITH_SPATIALITE)
@@ -0,0 +1,57 @@

########################################################
# Files

SET (VRP_SRCS
roadgraphplugin.cpp
settingsdlg.cpp
units.cpp
utils.cpp
shortestpathwidget.cpp
linevectorlayersettings.cpp
linevectorlayerwidget.cpp
linevectorlayerdirector.cpp
simplegraphbuilder.cpp
exportdlg.cpp
)

#SET ([pluginlcasename]_UIS [pluginlcasename]guibase.ui)

SET (VRP_MOC_HDRS
roadgraphplugin.h
settingsdlg.h
shortestpathwidget.h
linevectorlayerwidget.h
exportdlg.h
)
SET (VRP_RCCS roadgraph.qrc)

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
../../core
../../gui
..
)
########################################################
# Build

QT4_WRAP_CPP (VRP_MOC_SRCS ${VRP_MOC_HDRS})

QT4_ADD_RESOURCES(VRP_RCC_SRCS ${VRP_RCCS})

ADD_LIBRARY (roadgraphplugin MODULE ${VRP_SRCS} ${VRP_MOC_SRCS} ${VRP_RCC_SRCS})


TARGET_LINK_LIBRARIES(roadgraphplugin
qgis_core
qgis_gui
)


########################################################
# Install

INSTALL(TARGETS roadgraphplugin
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

Binary file not shown.
Binary file not shown.
@@ -0,0 +1,112 @@
/***************************************************************************
* Copyright (C) 2010 by Sergey Yakushev *
* yakushevs@list.ru *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "exportdlg.h"
#include <qgscontexthelp.h>

//qt includes
#include <qlabel.h>
#include <qcombobox.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <qdialogbuttonbox.h>
#include <qmessagebox.h>


// Qgis includes
#include <qgsvectorlayer.h>
#include <qgsmaplayerregistry.h>
#include <qgsproviderregistry.h>
#include <qgsvectordataprovider.h>

//standard includes

RgExportDlg::RgExportDlg( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
// create base widgets;
setWindowTitle( tr("Export feature") );
QVBoxLayout *v = new QVBoxLayout( this );

QHBoxLayout *h = new QHBoxLayout();
QLabel *l = new QLabel( tr("Select destination layer:"), this);
h->addWidget(l);
mcbLayers = new QComboBox( this );
h->addWidget(mcbLayers);
v->addLayout(h);

QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
connect(bb, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted()) );
connect(bb, SIGNAL(rejected()), this, SLOT(on_buttonBox_rejected()) );
v->addWidget(bb);

//fill list of layers
mcbLayers->insertItem( 0, tr("new temporary layer"), QVariant("-1") );

QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();

for ( ; layer_it != mapLayers.end(); ++layer_it )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer_it.value() );
if ( !vl )
continue;
if ( vl->geometryType() != QGis::Line )
continue;
mcbLayers->insertItem( 0, vl->name(), QVariant( vl->getLayerID() ) );
}

} // RgSettingsDlg::RgSettingsDlg()

RgExportDlg::~RgExportDlg()
{
}

QgsVectorLayer* RgExportDlg::mapLayer() const
{
QgsVectorLayer* myLayer = NULL;
QString layerId = mcbLayers->itemData( mcbLayers->currentIndex() ).toString();

if ( layerId == QString("-1") )
{
// create a temporary layer
myLayer = new QgsVectorLayer( "LineString", "shortest path", "memory" );

QgsVectorDataProvider *prov = myLayer->dataProvider();
if ( prov == NULL)
return NULL;

QList<QgsField> attrList;
attrList.append( QgsField("one", QVariant::Int) );
prov->addAttributes( attrList );
QgsMapLayerRegistry::instance()->addMapLayer( myLayer );

}else
{
// retrun selected layer
myLayer = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
}

return myLayer;
} // QgsVectorLayer* RgExportDlg::vectorLayer() const

void RgExportDlg::on_buttonBox_accepted()
{
accept();
} // void RgExportDlg::on_buttonBox_accepted()

void RgExportDlg::on_buttonBox_rejected()
{
reject();
}

void RgExportDlg::on_buttonBox_helpRequested()
{
QgsContextHelp::run( context_id );
}
@@ -0,0 +1,54 @@
/***************************************************************************
exportdlg.h
--------------------------------------
Date : 2010-11-29
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_EXPORTDLG_H
#define ROADGRAPH_EXPORTDLG_H

#include <QDialog>

// forward declaration QT-classes
class QComboBox;

// forward declaration Qgis-classes

//forward declaration RoadGraph plugins classes
class QgsVectorLayer;

/**
@author Sergey Yakushev
*/
/**
* \class RgSettingsDlg
* \brief implement of export dialog
*/
class RgExportDlg : public QDialog
{
Q_OBJECT
public:
RgExportDlg( QWidget* parent = 0, Qt::WFlags fl = 0 );
~RgExportDlg();
public:
QgsVectorLayer* mapLayer() const;
private:
static const int context_id = 0;

private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();

private:
QComboBox *mcbLayers;
};
#endif
@@ -0,0 +1,69 @@
/***************************************************************************
graphbuilder.h
--------------------------------------
Date : 2010-10-22
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_GRAPHBUILDER
#define ROADGRAPH_GRAPHBUILDER

#include "utils.h"

//QT4 includes

//QGIS includes
#include <qgspoint.h>
#include <qgscoordinatereferencesystem.h>

//forward declarations

/**
* \class RgGraphDirector
* \brief Determine making the graph
* contained the settings
*/
class RgGraphBuilder
{
public:
//! Destructor
virtual ~RgGraphBuilder()
{};
/**
* set source CRS
*/
virtual void setSourceCrs( const QgsCoordinateReferenceSystem& crs ) = 0;

/**
* set destionation CRS
*/
virtual void setDestinationCrs( const QgsCoordinateReferenceSystem& crs ) = 0;

/**
* add vertex
*/
virtual void addVertex( const QgsPoint& pt ) = 0;

/**
* add arc
*/
virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed ) = 0;

/**
* tie point
* @param pt maps point
* @param pt ok = false if tiePoint failed.
* @return Graph vertex corresponding pt.
* @note: graph can be modified
*/
virtual QgsPoint tiePoint( const QgsPoint &pt, bool &ok ) = 0;

};
#endif //GRAPHBUILDER
@@ -0,0 +1,53 @@
/***************************************************************************
graphdirector.h
--------------------------------------
Date : 2010-10-18
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_GRAPHDIRECTOR
#define ROADGRAPH_GRAPHDIRECTOR

//QT4 includes

//QGIS includes
#include <qgsrectangle.h>

//forward declarations
class RgSettings;
class RgGraphBuilder;

/**
* \class RgGraphDirector
* \brief Determine making the graph
* contained the settings
*/
class RgGraphDirector
{
public:
//! Destructor
virtual ~RgGraphDirector() { };

/**
* get adjacency matrix
*/
virtual void makeGraph( RgGraphBuilder * ) const = 0;

/**
* return pointer to my Settings
*/
virtual RgSettings* settings() = 0;

/**
* return Director name
*/
virtual QString name() const = 0;
};
#endif //GRAPHDIRECTOR

0 comments on commit 0a76ab4

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