A Graph contains vectorial data representing areas, roads, rivers. More...
#include <Graph.h>
Classes | |
struct | Changes |
A set of changes that occured to a Graph. More... | |
struct | Cmp |
Less method for mapping ordering. More... | |
class | GraphIterator |
An abstract iterator to iterate over the elements of a Graph. More... | |
Public Member Functions | |
Graph () | |
Creates a new Graph. | |
virtual | ~Graph () |
Deletes this Graph. | |
virtual void | print (bool detailed=true) |
Displays the graph's content. | |
virtual void | clear ()=0 |
Deletes all items when deleting the graph. | |
Graph * | getAncestor () |
Returns the ancestor Graph (Furthest parent). | |
virtual void | setParent (Graph *p) |
Sets the parent graph of this graph. | |
Graph * | getParent () const |
Returns the parent Graph of this graph. | |
virtual int | getNodeCount () const =0 |
Returns the number of nodes in this graph. | |
virtual int | getCurveCount () const =0 |
Returns the number of curves in this graph. | |
virtual int | getAreaCount () const =0 |
Returns the number of areas in this graph. | |
virtual Node * | findNode (vec2d &pos) const |
Seaches in mapping if given coordinates correspond to a point. | |
virtual NodePtr | getNode (NodeId id)=0 |
Returns a node. | |
virtual CurvePtr | getCurve (CurveId id)=0 |
Returns a curve. | |
virtual AreaPtr | getArea (AreaId id)=0 |
Returns an area. | |
virtual ptr< CurveIterator > | getChildCurves (CurveId parentId)=0 |
Returns the child curves of a given curve of the parent graph. | |
virtual AreaPtr | getChildArea (AreaId parentId)=0 |
Returns the child area of a given area of the parent graph. | |
virtual ptr< NodeIterator > | getNodes ()=0 |
Returns an iterator containing the entire list of nodes in this graph. | |
virtual ptr< CurveIterator > | getCurves ()=0 |
Returns an iterator containing the entire list of curves in this graph. | |
virtual ptr< AreaIterator > | getAreas ()=0 |
Returns an iterator containing the entire list of areas in this graph. | |
void | getAreasFromCurves (const set< CurveId > &curves, set< AreaId > &areas) |
Gets the list of areas containing the specified curves. | |
void | getPointsFromCurves (vector< CurveId > &curves, map< CurveId, int > orientations, vector< Vertex > &points) |
Gets the list of points contained in the given curves. | |
virtual void | load (const string &file, bool loadSubgraphs=true)=0 |
Loads a graph. | |
virtual void | load (FileReader *fileReader, bool loadSubgraphs=true)=0 |
Loads a graph from a basic file. | |
virtual void | checkParams (int nodes, int curves, int areas, int curveExtremities, int curvePoints, int areaCurves, int subgraphs) |
Checks if the provided params count are correct for this graph. | |
virtual void | checkDefaultParams (int nodes, int curves, int areas, int curveExtremities, int curvePoints, int areaCurves, int subgraphs) |
Asserts that the provided params count are the default Graph parameter counts. | |
virtual void | save (const string &file, bool saveAreas=true, bool isBinary=true, bool isIndexed=false) |
Saves this graph. | |
virtual void | save (FileWriter *fileWriter, bool saveAreas=true) |
Saves this graph from a basic file. | |
virtual void | indexedSave (FileWriter *fileWriter, bool saveAreas=true) |
Saves this graph from an indexed file. | |
void | flatten (float squareFlatness) |
Subdivides the curves of this graph where necessary to satisfy the given maximum error bound. | |
void | flattenUpdate (const Changes &changes, float squareFlatness) |
Subdivides the given curves where necessary to satisfy the given maximum error bound. | |
virtual Graph * | clip (const box2d &clip, Margin *margin) |
Clips this graph with the given clip region. | |
void | clipUpdate (const Changes &srcChanges, const box2d &clip, Margin *margin, Graph &result, Changes &dstChanges) |
Updates a clipped graph based on a set of changed curves and areas. | |
virtual CurvePtr | addCurvePart (CurvePart &cp, set< CurveId > *addedCurves, bool setParent=true) |
Adds a Curve, copy of a given CurvePart, into this graph. | |
void | addCurvePart (CurvePart &cp, set< CurveId > *addedCurves, set< CurveId > &visited, AreaPtr a) |
Adds a Curve, copy of a given CurvePart, into a given area of this graph. | |
void | buildCurves (bool useType, GraphPtr result) |
Computes the maximal curves of this graph. | |
bool | buildArea (CurvePtr begin, set< CurveId > &excluded, vector< CurveId > &used, map< CurveId, int > &orientations, int orientation) |
Builds an area, starting from a given Curve, and a given Node in it. | |
void | buildAreas () |
Computes the areas of this graph. | |
void | decimateCurves (float minDistance) |
Merge connected nodes below a minimum distance. | |
void | buildSubgraphs (const Graph &subgraphs) |
Adds the connected components of the given graph as subgraphs of this graph. | |
void | build (bool useType, GraphPtr result) |
Build the maximal curves and the areas of this graph. | |
virtual void | movePoint (CurvePtr c, int i, const vec2d &p) |
Moves a control point or a node on a given curve. | |
void | moveNode (NodePtr n, const vec2d &p) |
Moves a node. | |
virtual void | movePoint (CurvePtr c, int i, const vec2d &p, set< CurveId > &changedCurves) |
Moves a control point or a node on a given curve and returns the list of changed Curves. | |
virtual NodePtr | addNode (CurvePtr c, int i, Graph::Changes &changed) |
Splits a curve by changing a Vertex into a Node. | |
virtual CurvePtr | removeNode (CurvePtr first, CurvePtr second, const vec2d &p, Graph::Changes &changed, int &selectedPoint) |
Merges two curves by changing a Node into a Vertex. | |
virtual CurvePtr | addCurve (vec2d start, vec2d end, Graph::Changes &changed) |
Adds a curve from 2 new Points. | |
virtual CurvePtr | addCurve (NodeId start, vec2d end, Graph::Changes &changed) |
Adds a curve from 1 existing Node & 1 new Point. | |
virtual CurvePtr | addCurve (NodeId start, NodeId end, Graph::Changes &changed) |
Adds a curve from 2 existing Nodes. | |
virtual void | removeVertex (CurvePtr &curve, int &selectedSegment, int &selectedPoint, Graph::Changes &changed) |
Removes a Vertex from a curve. | |
virtual void | removeCurve (CurveId id, Graph::Changes &changed) |
Removes a Curve. | |
bool | equals (Graph *g) |
Check if this contains the same data as another graph. | |
void | addListener (GraphListener *p) |
Adds a listener to this graph. | |
void | removeListener (GraphListener *p) |
Removes a listener from this graph. | |
int | getListenerCount () |
Returns the number of GraphListeners for this graph. | |
void | notifyListeners () |
Calls the GraphListener::GraphChanged() method for each listener on this graph. | |
virtual NodePtr | newNode (const vec2d &p)=0 |
Adds a node to this graph. | |
virtual CurvePtr | newCurve (CurvePtr parent, bool setParent)=0 |
Adds a curve to this graph. | |
virtual CurvePtr | newCurve (CurvePtr model, NodePtr start, NodePtr end)=0 |
Adds a curve to this graph. | |
virtual AreaPtr | newArea (AreaPtr parent, bool setParent)=0 |
Adds an area to this graph. | |
virtual CurvePart * | createCurvePart (CurvePtr p, int orientation, int start, int end) |
Returns a new CurvePart whose type depends on the current Graph's type. | |
virtual Graph * | createChild () |
Returns a new BasicGraph. | |
Static Public Member Functions | |
static Graph::Changes | merge (Graph::Changes old, Graph::Changes c) |
Static method to merge 2 successive changes. | |
static void | fitCubicCurve (vector< vec2d > points, vector< vec2d > &output, float error) |
Returns the Bezier polygon that fits to a given set of digitized points. | |
static bool | hasOppositeControlPoint (CurvePtr p, int i, int di, vec2d &q, CurveId &id, int &j) |
Checks if a moved point from a curve has an opposite ControlPoint. | |
Public Attributes | |
Changes | changes |
Contains all changes on this graph which will be spread amongst child graphs. | |
unsigned int | version |
Graph's Version. | |
Protected Member Functions | |
virtual void | removeNode (NodeId id)=0 |
Removes a Node from this graph. | |
virtual void | removeCurve (CurveId id)=0 |
Removes a Curve from this graph. | |
void | mergeNodes (NodeId ida, NodeId idb) |
Merges two nodes. | |
virtual void | removeArea (AreaId id)=0 |
Removes an Area from this graph. | |
Protected Attributes | |
int | nParamsNodes |
Amount of parameters for each Node in the file from which it is loaded. | |
int | nParamsCurves |
Amount of parameters for each Curve in the file from which it is loaded. | |
int | nParamsAreas |
Amount of parameters for each Area in the file from which it is loaded. | |
int | nParamsCurveExtremities |
Amount of parameters for each Curve's Node in the file from which it is loaded. | |
int | nParamsCurvePoints |
Amount of parameters for each Curve's Vertex in the file from which it is loaded. | |
int | nParamsAreaCurves |
Amount of parameters for each Area's Curve in the file from which it is loaded. | |
int | nParamsSubgraphs |
Amount of parameters for each Subgraph in the file from which it is loaded. | |
Private Member Functions | |
int | enlarge (box2d &area, CurvePtr p, int i, int di) |
Enlarges a box to make it contain a given Curve. | |
virtual void | clean ()=0 |
Clean method to erase the changes in the graph. | |
Static Private Member Functions | |
static bool | isOpposite (const vec2d &p, const vec2d &q, const vec2d &r) |
Checks if two points are symmetric with respect to another point. | |
static void | followHalfCurve (NodePtr prev, NodePtr cur, vector< NodePtr > &result, set< CurvePtr > &visited, bool invert, bool useType, float *width) |
Scans the list of nodes in order to find a loop. | |
static void | followCurve (CurvePtr c, bool useType, set< CurvePtr > &visited, float *width, int *type, vector< NodePtr > &result) |
Follows a given curve in order to find an area. | |
Private Attributes | |
map< vec2d, Node *, Cmp > * | mapping |
A map of nodes. | |
Graph * | parent |
Parent graph. | |
box2d | bounds |
This graph's bounds. | |
vector< GraphListener * > | listeners |
List of listeners on this graph. |
A Graph contains vectorial data representing areas, roads, rivers.
.. It handles creation, modification, and deletion of each element. There are two types of graphs : Basic & Lazy. See each one for further desc. Vectorial Data consists of nodes (points), curves (how points are linked to each other), and areas (groups of curves).
proland::Graph::Graph | ( | ) |
Creates a new Graph.
virtual proland::Graph::~Graph | ( | ) | [virtual] |
Deletes this Graph.
virtual CurvePtr proland::Graph::addCurve | ( | NodeId | start, | |
NodeId | end, | |||
Graph::Changes & | changed | |||
) | [virtual] |
Adds a curve from 2 existing Nodes.
start | first point. | |
end | second point. | |
changed | the list of changed areas & curves. |
virtual CurvePtr proland::Graph::addCurve | ( | NodeId | start, | |
vec2d | end, | |||
Graph::Changes & | changed | |||
) | [virtual] |
virtual CurvePtr proland::Graph::addCurve | ( | vec2d | start, | |
vec2d | end, | |||
Graph::Changes & | changed | |||
) | [virtual] |
Adds a curve from 2 new Points.
start | first point. | |
end | second point. | |
changed | the list of changed areas & curves. |
void proland::Graph::addCurvePart | ( | CurvePart & | cp, | |
set< CurveId > * | addedCurves, | |||
set< CurveId > & | visited, | |||
AreaPtr | a | |||
) |
void proland::Graph::addListener | ( | GraphListener * | p | ) |
Adds a listener to this graph.
Listeners are used to update resources using graphs when a modification occured on it (Example : GraphProducers).
p | a GraphListener based object. |
virtual NodePtr proland::Graph::addNode | ( | CurvePtr | c, | |
int | i, | |||
Graph::Changes & | changed | |||
) | [virtual] |
void proland::Graph::build | ( | bool | useType, | |
GraphPtr | result | |||
) |
Build the maximal curves and the areas of this graph.
The result is added to the given graph.
useType | see buildCurves. | |
result | the graph to which the maximal curves and the areas must be added. |
bool proland::Graph::buildArea | ( | CurvePtr | begin, | |
set< CurveId > & | excluded, | |||
vector< CurveId > & | used, | |||
map< CurveId, int > & | orientations, | |||
int | orientation | |||
) |
Builds an area, starting from a given Curve, and a given Node in it.
The result is a list of curves and their orientations.
begin | the starting curve. | |
excluded | the list of excluded curves (for example the ones that are not in a loop). | |
used | After function call, it will contain the list of curves for the new area. Empty if no area found. | |
orientations | After function call, it will contain correspondence betwenn each curve and its orientation in the area. Empty if no area found. | |
orientation | If 0, will start the search from the begin->getStart(). Otherwise, from begin->getEnd(). |
void proland::Graph::buildAreas | ( | ) |
Computes the areas of this graph.
This method follows each curve in both directions and calls Area::build for each, in order to find all the areas of the graph.
void proland::Graph::buildCurves | ( | bool | useType, | |
GraphPtr | result | |||
) |
Computes the maximal curves of this graph.
This method removes all nodes that connect exactly two curves, and merges the two curves into a single one. In fact the graph is not modified, but a copy with these maximal curves is created in the given graph.
useType | true if curves of different types must not be merged. | |
result | the graph to which the maximal curves must be added. |
void proland::Graph::buildSubgraphs | ( | const Graph & | subgraphs | ) |
Adds the connected components of the given graph as subgraphs of this graph.
Each connected component of the given graph is associated with the area of this graph that contains its interior points. The bounding box of this area is then added to the connected component. The exterior points of the connected component (i.e., those connected to only one curve) are then moved on this bounding box, and finally this completed connected component is build (see build).
subgraph | the graph whose connex components must be added as subgraphs of this graph. |
virtual void proland::Graph::checkDefaultParams | ( | int | nodes, | |
int | curves, | |||
int | areas, | |||
int | curveExtremities, | |||
int | curvePoints, | |||
int | areaCurves, | |||
int | subgraphs | |||
) | [virtual] |
Asserts that the provided params count are the default Graph parameter counts.
Prevents from loading unsuitable graphs in a subclass of Graph. A correct amount of parameters may depend on the graph it is used by. For Graph, the amounts must be respectively 2, 3, 3, 1, 3, 2, 0. Should be overwritten for graphs containing more data.
virtual void proland::Graph::checkParams | ( | int | nodes, | |
int | curves, | |||
int | areas, | |||
int | curveExtremities, | |||
int | curvePoints, | |||
int | areaCurves, | |||
int | subgraphs | |||
) | [virtual] |
Checks if the provided params count are correct for this graph.
A correct amount of parameters may depend on the graph it is used by. For Graph, the amounts must be respectively at least 2, 3, 3, 1, 3, 2, 0. Should be overwritten for graphs containing more data.
virtual void proland::Graph::clean | ( | ) | [private, pure virtual] |
Clean method to erase the changes in the graph.
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual void proland::Graph::clear | ( | ) | [pure virtual] |
Deletes all items when deleting the graph.
Implemented in proland::BasicGraph, and proland::LazyGraph.
Clips this graph with the given clip region.
A specific margin is added to the clip region for each curve and area that will be clipped.
clip | the clip region. | |
margin | the object to be used to compute the specific margins for each curve and area. |
void proland::Graph::clipUpdate | ( | const Changes & | srcChanges, | |
const box2d & | clip, | |||
Margin * | margin, | |||
Graph & | result, | |||
Changes & | dstChanges | |||
) |
Updates a clipped graph based on a set of changed curves and areas.
The old clipped curves and areas corresponding to the changed curves and areas are removed from the clipped graph, and the changed curves and areas are then clipped again and added to the clipped graph.
changedCurves | a list of changed curves. | |
clip | the clip region that was used to compute the original clipped graph. | |
margin | the object that was used to compute the original clipped graph (see clip()). | |
result | the clipped graph that must be updated. |
virtual Graph* proland::Graph::createChild | ( | ) | [virtual] |
Returns a new BasicGraph.
Should be overrided for different graph types.
virtual CurvePart* proland::Graph::createCurvePart | ( | CurvePtr | p, | |
int | orientation, | |||
int | start, | |||
int | end | |||
) | [virtual] |
Returns a new CurvePart whose type depends on the current Graph's type.
Default is BasicCurvePart. A new type should be used for curves with more data than normal curves.
p | the whole curve. | |
orientation | the curve part orientation (see CurvePart::orientation). | |
start | start of the interval in p to which this part corresponds. | |
end | end of the interval in p to which this part corresponds. |
void proland::Graph::decimateCurves | ( | float | minDistance | ) |
Merge connected nodes below a minimum distance.
Slow, intended for preprocessing. COMPLETELY BROKEN DO NOT USE Merge vertex in Curves which are longer than minDistance.
int proland::Graph::enlarge | ( | box2d & | area, | |
CurvePtr | p, | |||
int | i, | |||
int | di | |||
) | [private] |
Enlarges a box to make it contain a given Curve.
The function can take each di point.
area | the box2d to enlarge. | |
p | the Curve that will be used to enlarge the box. | |
i | the rank of the first point we want to be contained in the box. | |
di | the increment of i. For example, to use only a point every two points, put 2 (to avoid non-controlPoints points). |
bool proland::Graph::equals | ( | Graph * | g | ) |
Check if this contains the same data as another graph.
g | A graph to compare. |
virtual Node* proland::Graph::findNode | ( | vec2d & | pos | ) | const [virtual] |
Seaches in mapping if given coordinates correspond to a point.
If they do, it returns the node, NULL otherwise.
pos | the node's position. |
static void proland::Graph::fitCubicCurve | ( | vector< vec2d > | points, | |
vector< vec2d > & | output, | |||
float | error | |||
) | [static] |
Returns the Bezier polygon that fits to a given set of digitized points.
points | digitized points. | |
[out] | output | the Bezier polygon. |
error | the maximum reconstruction error allowed. |
void proland::Graph::flatten | ( | float | squareFlatness | ) |
Subdivides the curves of this graph where necessary to satisfy the given maximum error bound.
See Curve::flatten().
squareFlatness | square of the maximum allowed distance between a limit curve and its polyline approximation. |
void proland::Graph::flattenUpdate | ( | const Changes & | changes, | |
float | squareFlatness | |||
) |
Subdivides the given curves where necessary to satisfy the given maximum error bound.
See Curve::flatten().
changedCurves | a list of curves that have changed. | |
squareFlatness | square of the maximum allowed distance between a limit curve and its polyline approximation. |
static void proland::Graph::followCurve | ( | CurvePtr | c, | |
bool | useType, | |||
set< CurvePtr > & | visited, | |||
float * | width, | |||
int * | type, | |||
vector< NodePtr > & | result | |||
) | [static, private] |
Follows a given curve in order to find an area.
path | the first curve to follow. | |
useType | If true, will only search in curves with type == 0. | |
visited | list of visited curves, that will be excluded from the search. | |
width | After function call, will contain the max curve's width. | |
type | After function call, will contain the max curve's width. |
static void proland::Graph::followHalfCurve | ( | NodePtr | prev, | |
NodePtr | cur, | |||
vector< NodePtr > & | result, | |||
set< CurvePtr > & | visited, | |||
bool | invert, | |||
bool | useType, | |||
float * | width | |||
) | [static, private] |
Scans the list of nodes in order to find a loop.
prev | the previously found node. | |
cur | the current node. | |
result | list of nodes that forms an area. | |
visited | list of visited nodes, that will be excluded from the search. | |
invert | If true, search backwards. | |
useType | If true, will only search in curves with type == 0. | |
width | After function call, will contain the max curve's width. |
Graph* proland::Graph::getAncestor | ( | ) | [inline] |
Returns the ancestor Graph (Furthest parent).
See getParent().
virtual AreaPtr proland::Graph::getArea | ( | AreaId | id | ) | [pure virtual] |
Returns an area.
id | the id of the area to be returned. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual int proland::Graph::getAreaCount | ( | ) | const [pure virtual] |
Returns the number of areas in this graph.
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual ptr<AreaIterator> proland::Graph::getAreas | ( | ) | [pure virtual] |
Returns an iterator containing the entire list of areas in this graph.
See GraphIterator.
Implemented in proland::BasicGraph, and proland::LazyGraph.
Gets the list of areas containing the specified curves.
curves | the set of curves to search. | |
areas | the set of areas linked to the specified curves. |
virtual AreaPtr proland::Graph::getChildArea | ( | AreaId | parentId | ) | [pure virtual] |
Returns the child area of a given area of the parent graph.
A child area of an area A of the parent graph is an area that was created by the clipping of A, during the creation of this graph. The clipping of an area can result in only one clipped area.
parentId | the id of an area of the parent graph of this graph. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual ptr<CurveIterator> proland::Graph::getChildCurves | ( | CurveId | parentId | ) | [pure virtual] |
Returns the child curves of a given curve of the parent graph.
A child curve of a curve C of the parent graph is a curve that was created by the clipping of C, during the creation of this graph. The clipping of a curve can result in several clipped curves, hence a curve can have several child curves.
parentId | the id of a curve of the parent graph of this graph. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual CurvePtr proland::Graph::getCurve | ( | CurveId | id | ) | [pure virtual] |
Returns a curve.
id | the id of the curve to be returned. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual int proland::Graph::getCurveCount | ( | ) | const [pure virtual] |
Returns the number of curves in this graph.
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual ptr<CurveIterator> proland::Graph::getCurves | ( | ) | [pure virtual] |
Returns an iterator containing the entire list of curves in this graph.
See GraphIterator.
Implemented in proland::BasicGraph, and proland::LazyGraph.
int proland::Graph::getListenerCount | ( | ) |
Returns the number of GraphListeners for this graph.
virtual NodePtr proland::Graph::getNode | ( | NodeId | id | ) | [pure virtual] |
Returns a node.
id | the id of the node to be returned. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual int proland::Graph::getNodeCount | ( | ) | const [pure virtual] |
Returns the number of nodes in this graph.
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual ptr<NodeIterator> proland::Graph::getNodes | ( | ) | [pure virtual] |
Returns an iterator containing the entire list of nodes in this graph.
See GraphIterator.
Implemented in proland::BasicGraph, and proland::LazyGraph.
Graph* proland::Graph::getParent | ( | ) | const [inline] |
Returns the parent Graph of this graph.
See setParent().
void proland::Graph::getPointsFromCurves | ( | vector< CurveId > & | curves, | |
map< CurveId, int > | orientations, | |||
vector< Vertex > & | points | |||
) |
Gets the list of points contained in the given curves.
curves | the set of curves to search. | |
orientations | the orientations of each curves. Determines the final result. | |
points | the resulting vector of points. |
static bool proland::Graph::hasOppositeControlPoint | ( | CurvePtr | p, | |
int | i, | |||
int | di, | |||
vec2d & | q, | |||
CurveId & | id, | |||
int & | j | |||
) | [static] |
Checks if a moved point from a curve has an opposite ControlPoint.
A ControlPoint should be moved if its opposite is moved, in order to keep the continuity of the Curve.
p | the Curve to which the point belongs. | |
i | rank of the point to move. | |
di | degree of the Curve. Determines which points will be checked. | |
q | coordinates of the point that should move too (opposite) if any. | |
id | CurveId of the Curve to which q belongs to (if any). | |
j | rank of the opposite ControlPoint on its Curve. |
virtual void proland::Graph::indexedSave | ( | FileWriter * | fileWriter, | |
bool | saveAreas = true | |||
) | [virtual] |
Saves this graph from an indexed file.
Indexed files are used to load LazyGraphs faster. It contains the indexes of each element in the file.
fileWriter | the FileWriter used to save the file | |
saveAreas | if true, will save the subgraphs |
static bool proland::Graph::isOpposite | ( | const vec2d & | p, | |
const vec2d & | q, | |||
const vec2d & | r | |||
) | [static, private] |
Checks if two points are symmetric with respect to another point.
p | first point. | |
q | point supposed to be the center point. | |
r | second point. |
virtual void proland::Graph::load | ( | FileReader * | fileReader, | |
bool | loadSubgraphs = true | |||
) | [pure virtual] |
Loads a graph from a basic file.
the | stream to read the data from. | |
loadSubgraphs | if true, will load the subgraphs. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual void proland::Graph::load | ( | const string & | file, | |
bool | loadSubgraphs = true | |||
) | [pure virtual] |
Loads a graph.
This method determines whether to call load() or loadIndexed() method.
file | the file to load from. | |
loadSubgraphs | if true, will load the subgraphs. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
static Graph::Changes proland::Graph::merge | ( | Graph::Changes | old, | |
Graph::Changes | c | |||
) | [static] |
Static method to merge 2 successive changes.
For example, if a curve was first changed and then deleted, it will just be deleted.
old | the first Graph::Changes. | |
c | the second Graph::Changes. |
void proland::Graph::moveNode | ( | NodePtr | n, | |
const vec2d & | p | |||
) |
Moves a node.
n | the node to move. | |
p | the place to go. |
virtual void proland::Graph::movePoint | ( | CurvePtr | c, | |
int | i, | |||
const vec2d & | p, | |||
set< CurveId > & | changedCurves | |||
) | [virtual] |
Moves a control point or a node on a given curve and returns the list of changed Curves.
c | the curve to edit. | |
i | the index of the control point (or node, if i is 0 or c->getSize()-1) to move on c. | |
p | the new control point or node position. | |
changedCurves | List of changed curves. |
virtual void proland::Graph::movePoint | ( | CurvePtr | c, | |
int | i, | |||
const vec2d & | p | |||
) | [virtual] |
Moves a control point or a node on a given curve.
c | the curve to edit. | |
i | the index of the control point (or node, if i is 0 or c->getSize()-1) to move on c. | |
p | the new control point or node position. |
Reimplemented in proland::LazyGraph.
virtual AreaPtr proland::Graph::newArea | ( | AreaPtr | parent, | |
bool | setParent | |||
) | [pure virtual] |
Adds an area to this graph.
parent | the parent area (NULL if none). | |
setParent | if true, the new area's parent will be s et to the 'parent' parameter. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual CurvePtr proland::Graph::newCurve | ( | CurvePtr | model, | |
NodePtr | start, | |||
NodePtr | end | |||
) | [pure virtual] |
Adds a curve to this graph.
model | a model curve : the new curve will have the same vertices. | |
start | the start node. | |
end | the end node. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual CurvePtr proland::Graph::newCurve | ( | CurvePtr | parent, | |
bool | setParent | |||
) | [pure virtual] |
Adds a curve to this graph.
parent | the parent curve (NULL if none). | |
setParent | if true, the new curve's parent will be set to the 'parent' parameter. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual NodePtr proland::Graph::newNode | ( | const vec2d & | p | ) | [pure virtual] |
Adds a node to this graph.
p | a vector containing the coordinates of the new node. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
void proland::Graph::notifyListeners | ( | ) |
Calls the GraphListener::GraphChanged() method for each listener on this graph.
virtual void proland::Graph::print | ( | bool | detailed = true |
) | [virtual] |
Displays the graph's content.
Debug only.
detailed | if true, will show info about every item in graph. If false, only displays elements count. |
virtual void proland::Graph::removeArea | ( | AreaId | id | ) | [protected, pure virtual] |
Removes an Area from this graph.
This method is called when editing the Graph.
id | the id of an Area that is currently being deleted. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual void proland::Graph::removeCurve | ( | CurveId | id | ) | [protected, pure virtual] |
Removes a Curve from this graph.
This method is called when editing the Graph.
id | the id of a Curve that is currently being deleted. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual void proland::Graph::removeCurve | ( | CurveId | id, | |
Graph::Changes & | changed | |||
) | [virtual] |
Removes a Curve.
id | the id of the curve to remove. | |
changed | the list of changed areas & curves. |
void proland::Graph::removeListener | ( | GraphListener * | p | ) |
Removes a listener from this graph.
p | a GraphListener. |
virtual void proland::Graph::removeNode | ( | NodeId | id | ) | [protected, pure virtual] |
Removes a Node from this graph.
This method is called when editing the Graph.
id | the id of a Node that is currently being deleted. |
Implemented in proland::BasicGraph, and proland::LazyGraph.
virtual CurvePtr proland::Graph::removeNode | ( | CurvePtr | first, | |
CurvePtr | second, | |||
const vec2d & | p, | |||
Graph::Changes & | changed, | |||
int & | selectedPoint | |||
) | [virtual] |
Merges two curves by changing a Node into a Vertex.
first | the first curve to merge. | |
second | the second curve. | |
p | the XY coords of the node to remove. | |
changed | the list of changed areas & curves. | |
selectedPoint | After function call, will contain the rank of the selectedPoint into selectedCurve. Used for editGraphOrthoLayer. |
virtual void proland::Graph::removeVertex | ( | CurvePtr & | curve, | |
int & | selectedSegment, | |||
int & | selectedPoint, | |||
Graph::Changes & | changed | |||
) | [virtual] |
Removes a Vertex from a curve.
inout] | curve the Curve from which to remove the point. After function call, will contain the selected Curve. Used for editGraphOrthoLayer. | |
[out] | selectedSegment | After function call, will contain the selected segment in selectedCurve. |
inout] | selectedPoint the vertex to remove from in::curve. After function call, will be -1. | |
[out] | changed | the list of changed areas & curves. |
virtual void proland::Graph::save | ( | FileWriter * | fileWriter, | |
bool | saveAreas = true | |||
) | [virtual] |
Saves this graph from a basic file.
fileWriter | the FileWriter used to save the file. | |
saveAreas | if true, will save the subgraphs. |
virtual void proland::Graph::save | ( | const string & | file, | |
bool | saveAreas = true , |
|||
bool | isBinary = true , |
|||
bool | isIndexed = false | |||
) | [virtual] |
Saves this graph.
This method determines whether to call save() or indexed save() method.
file | the file to save into. | |
saveAreas | if true, will save the subgraphs. | |
isBinary | if true, will save in binary mode. | |
isIndexed | if true, will save in indexed mode, used to accelerate LazyGraph loading. |
virtual void proland::Graph::setParent | ( | Graph * | p | ) | [virtual] |
Sets the parent graph of this graph.
The parent graph is the graph from which this graph was created by clipping, or NULL is this graph was not created by clipping (e.g. the root graph tile in a GraphProducer).
p | the parent graph of this graph. |
box2d proland::Graph::bounds [private] |
This graph's bounds.
Only computed in getBounds().
Contains all changes on this graph which will be spread amongst child graphs.
Added & removed areas. Added & removed curves.
vector<GraphListener *> proland::Graph::listeners [private] |
List of listeners on this graph.
GraphListeners are used to monitor changes on a Graph.
map<vec2d, Node*, Cmp>* proland::Graph::mapping [private] |
A map of nodes.
Maps the coordinates of the nodes to their pointer.
int proland::Graph::nParamsAreaCurves [protected] |
Amount of parameters for each Area's Curve in the file from which it is loaded.
Default is 2.
int proland::Graph::nParamsAreas [protected] |
Amount of parameters for each Area in the file from which it is loaded.
Default is 2.
int proland::Graph::nParamsCurveExtremities [protected] |
Amount of parameters for each Curve's Node in the file from which it is loaded.
Default is 2.
int proland::Graph::nParamsCurvePoints [protected] |
Amount of parameters for each Curve's Vertex in the file from which it is loaded.
Default is 2.
int proland::Graph::nParamsCurves [protected] |
Amount of parameters for each Curve in the file from which it is loaded.
Default is 2.
int proland::Graph::nParamsNodes [protected] |
Amount of parameters for each Node in the file from which it is loaded.
Default is 2.
int proland::Graph::nParamsSubgraphs [protected] |
Amount of parameters for each Subgraph in the file from which it is loaded.
Default is 2.
Graph* proland::Graph::parent [private] |
Parent graph.
See getParent().
unsigned int proland::Graph::version |
Graph's Version.
Allows to know if the Graph needs an update.