Quantum GIS API Documentation  1.8
src/analysis/network/qgsgraph.h
Go to the documentation of this file.
00001 /***************************************************************************
00002   graph.h
00003   --------------------------------------
00004   Date                 : 2011-04-01
00005   Copyright            : (C) 2010 by Yakushev Sergey
00006   Email                : YakushevS <at> list.ru
00007 ****************************************************************************
00008 *                                                                          *
00009 *   This program is free software; you can redistribute it and/or modify   *
00010 *   it under the terms of the GNU General Public License as published by   *
00011 *   the Free Software Foundation; either version 2 of the License, or      *
00012 *   (at your option) any later version.                                    *
00013 *                                                                          *
00014 ***************************************************************************/
00015 
00016 /*
00017  * This file describes the built-in QGIS classes modeling a mathematical graph.
00018  * Vertex is identified by its geographic coordinates (but you can add two vertex
00019  * with unique coordinate), no additional properties it can not be assigned.
00020  * Count the number of properties not limited along the arc. Graph may
00021  * be have incidence arcs.
00022  *
00023  * \file qgsgraph.h
00024  */
00025 
00026 #ifndef QGSGRAPHH
00027 #define QGSGRAPHH
00028 
00029 // QT4 includes
00030 #include <QList>
00031 #include <QVector>
00032 #include <QVariant>
00033 
00034 // QGIS includes
00035 #include "qgspoint.h"
00036 
00037 class QgsGraphVertex;
00038 
00044 class ANALYSIS_EXPORT QgsGraphArc
00045 {
00046   public:
00047     QgsGraphArc();
00048 
00053     QVariant property( int propertyIndex ) const;
00054 
00058     QVector< QVariant > properties() const;
00059 
00063     int outVertex() const;
00064 
00068     int inVertex() const;
00069 
00070   private:
00071 
00072     QVector< QVariant > mProperties;
00073 
00074     int mOut;
00075     int mIn;
00076 
00077     friend class QgsGraph;
00078 };
00079 
00080 
00081 typedef QList< int > QgsGraphArcIdList;
00082 
00088 class ANALYSIS_EXPORT QgsGraphVertex
00089 {
00090   public:
00094     QgsGraphVertex() {}
00095 
00100     QgsGraphVertex( const QgsPoint& point );
00101 
00105     QgsGraphArcIdList outArc() const;
00106 
00110     QgsGraphArcIdList inArc() const;
00111 
00115     QgsPoint point() const;
00116 
00117   private:
00118     QgsPoint mCoordinate;
00119     QgsGraphArcIdList mOutArc;
00120     QgsGraphArcIdList mInArc;
00121 
00122     friend class QgsGraph;
00123 };
00124 
00131 class ANALYSIS_EXPORT QgsGraph
00132 {
00133   public:
00134     QgsGraph();
00135 
00136     ~QgsGraph();
00137 
00138     // begin graph constructing methods
00142     int addVertex( const QgsPoint& pt );
00143 
00147     int addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties );
00148 
00152     int vertexCount() const;
00153 
00157     const QgsGraphVertex& vertex( int idx ) const;
00158 
00162     int arcCount() const;
00163 
00167     const QgsGraphArc& arc( int idx ) const;
00168 
00173     int findVertex( const QgsPoint& pt ) const;
00174 
00175   private:
00176     QVector<QgsGraphVertex> mGraphVertexes;
00177 
00178     QVector<QgsGraphArc> mGraphArc;
00179 };
00180 
00181 #endif //QGSGRAPHH
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines