/usr/include/tulip/LayoutProperty.h is in libtulip-dev 4.8.0dfsg-2+b7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | /*
*
* This file is part of Tulip (www.tulip-software.org)
*
* Authors: David Auber and the Tulip development Team
* from LaBRI, University of Bordeaux
*
* Tulip is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Tulip is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
*/
#ifndef TULIP_LAYOUT_H
#define TULIP_LAYOUT_H
#include <tulip/tuliphash.h>
#include <tulip/PropertyTypes.h>
#include <tulip/Observable.h>
#include <tulip/AbstractProperty.h>
#include <tulip/PropertyAlgorithm.h>
#include <tulip/minmaxproperty.h>
namespace tlp {
template <>
void tlp::MinMaxProperty<tlp::PointType, tlp::LineType>::updateEdgeValue(tlp::edge e, tlp::LineType::RealType newValue);
template <>
MINMAX_PAIR(tlp::PointType) tlp::MinMaxProperty<tlp::PointType, tlp::LineType>::computeMinMaxNode(Graph *sg);
class PropertyContext;
class Graph;
typedef AbstractProperty<tlp::PointType, tlp::LineType> AbstractLayoutProperty;
typedef MinMaxProperty<tlp::PointType, tlp::LineType> LayoutMinMaxProperty;
/**
* @ingroup Graph
* @brief A graph property that maps a tlp::Coord value to graph nodes and std::vector<tlp::Coord> for edges.
*/
class TLP_SCOPE LayoutProperty : public LayoutMinMaxProperty {
public:
LayoutProperty(Graph *graph, const std::string& name=""/*, bool updateOnEdgeReversal=true*/);
// override some PropertyInterface methods
PropertyInterface* clonePrototype(Graph *, const std::string& );
static const std::string propertyTypename;
const std::string& getTypename() const {
return propertyTypename;
}
//=======================================
//Methods for extra layout information
//=======================================
/**
* Returns the maximum coordinate of the layout, i.e. the top-right corner of the induced bounding box
*
* @param subgraph If not null, returns the maximum coordinate for a sub-graph layout
**/
Coord getMax(Graph *subgraph=NULL);
/**
* Returns the minimum coordinate of the layout, i.e. the bottom-left corner of the induced bounding box
*
* @param subgraph If not null, returns the minimum coordinate for a sub-graph layout
**/
Coord getMin(Graph *subgraph=NULL);
//============================================
//Functions for layout modification
//============================================
/**
* Translates the current layout according to a movement vector
*
* @param move a movement vector
* @param subgraph If not null, only translates the layout of that sub-graph
**/
void translate(const Vec3f &move, Graph *subgraph=NULL);
/**
* Translates the layout of a set of nodes and edges provided through iterators
* according to a movement vector
*
* @param move a movement vector
* @param itNodes an iterator on graph nodes
* @param itEdges an iterator on graph edges
*
* @warning The iterators are not deleted
**/
void translate(const Vec3f &move, Iterator<node> *itNodes, Iterator<edge> *itEdges);
/**
* Scales the current layout according to a vector of scale factors (sx, sy, sz).
*
* @param scaleFactors a vector of scale factors
* @param subgraph If not null, only scales the layout of that sub-graph
**/
void scale(const Vec3f &scaleFactors, Graph *subgraph=NULL);
/**
* Scales the layout of a set of nodes and edges provided through iterators
* according to a vector of scale factors (sx, sy, sz).
*
* @param scaleFactors a vector of scale factors
* @param itNodes an iterator on graph nodes
* @param itEdges an iterator on graph edges
*
* @warning The iterators are not deleted
**/
void scale(const Vec3f &scaleFactors, Iterator<node> *itNodes, Iterator<edge> *itEdges);
/**
* Rotates the layout around the X-axis according to an angle in degrees.
*
* @param alpha an angle in degrees
* @param subgraph If not null, only rotates the layout of that sub-graph
**/
void rotateX(const double &alpha, Graph *subgraph=NULL);
/**
* Rotates the layout around the Y-axis according to an angle in degrees.
*
* @param alpha an angle in degrees
* @param subgraph If not null, only rotates the layout of that sub-graph
**/
void rotateY(const double &alpha, Graph *subgraph=NULL);
/**
* Rotates the layout around the Z-axis according to an angle in degrees.
*
* @param alpha an angle in degrees
* @param subgraph If not null, only rotates the layout of that sub-graph
**/
void rotateZ(const double &alpha, Graph *subgraph=NULL);
/**
* Rotates the layout around the X-axis of the nodes and edges provided
* through iterators according to an angle in degrees.
*
* @param alpha an angle in degrees
* @param itNodes an iterator on graph nodes
* @param itEdges an iterator on graph edges
*
* @warning The iterators are not deleted
**/
void rotateX(const double &alpha, Iterator<node> *itNodes, Iterator<edge> *itEdges);
/**
* Rotates the layout around the Y-axis of the nodes and edges provided
* through iterators according to an angle in degrees.
*
* @param alpha an angle in degrees
* @param itNodes an iterator on graph nodes
* @param itEdges an iterator on graph edges
*
* @warning The iterators are not deleted
**/
void rotateY(const double &alpha, Iterator<node> *itNodes, Iterator<edge> *itEdges);
/**
* Rotates the layout around the Z-axis of the nodes and edges provided through
* iterators according to an angle in degrees.
*
* @param alpha an angle in degrees
* @param itNodes an iterator on graph nodes
* @param itEdges an iterator on graph edges
*
* @warning The iterators are not deleted
**/
void rotateZ(const double &alpha, Iterator<node> *itNodes, Iterator<edge> *itEdges);
/**
* Centers the layout, meaning translating it in order that
* the center of its bounding box is (0,0,0)
*
* @param subgraph If not null, only centers the layout of that sub-graph
**/
void center(Graph *subgraph=NULL);
/**
* Centers the layout to newCenter, meaning translating it in order that
* the center of its bounding box is equal to newCenter
*
* @param newCenter the coordinate of the new layout center
* @param subgraph If not null, only centers the layout of that sub-graph
**/
void center(const Vec3f &newCenter, Graph *subgraph=NULL);
/**
* Normalizes the layout, meaning dividing each nodes and edges coordinate by the maximum magnitude of the whole coordinates set
*
* @param subgraph If not null, only normalizes the layout of that sub-graph
**/
void normalize(Graph *subgraph=NULL);
/**
* Scales the layout in order to approach an aspect ratio (width / height) of 1.0 .
**/
void perfectAspectRatio();
//=======================================================================
// Set of function in order to measure the quality of the LayoutAlgorithm
//=======================================================================
/**
* Returns the length of an edge, the bends are taken into account.
* Thus, it measure the length of a polyline.
*
* @param e the graph edge on which to compute its length
*
* @warning this function only measure the length of the polyline between bends,
* when using curves like Bézier etc... the result will not be the length of the curve.
**/
double edgeLength(const edge e) const;
/**
* Returns the average edge length of the layout, the bends are taken into account
*
* @param subgraph If not null, only compute the average edge length for that sub-graph
**/
double averageEdgeLength(const Graph *subgraph=NULL) const;
/**
* Returns the average angular resolution of the layout.
* It is only defined for 2D drawing, meaning the third coordinate
* is omitted
*
* @param subgraph It not null, only computes the average angular resolution for that sub-graph
**/
double averageAngularResolution(const Graph *subgraph=NULL) const;
/**
* Returns the average angular resolution of a node.
* It is only defined for 2D drawing, meaning the third coordinate
* is omitted
*
* @param n the graph node on which to compute the angular resolution
* @param subgraph If not null, only computes the average angular resolution for the node in that sub-graph
**/
double averageAngularResolution(const node n, const Graph *subgraph=NULL) const;
/**
* Returns a vector of all angular resolution of a node.
* It is only defined for 2D drawing, meaning the third coordinate
* is omitted
*
* @param n the graph node on which to compute the angular resolution
* @param subgraph If not null, only computes the average angular resolution for the node in that sub-graph
**/
std::vector<double> angularResolutions(const node n, const Graph *subgraph=NULL) const;
/**
* Fixes embedding of the graph according to the layout
* ie. sort edges around nodes according to their neighbors/bends position in the layout/
* Only works in 2D, the third coordinate is not taken into account.
*
* @param subgraph It not null, only fixes embedding in that sub-graph
**/
void computeEmbedding(Graph *subgraph=NULL);
/**
* Fixes embedding of the node according to the layout
* ie. sort edges around the node according to its neighbors/bends position in the layout/
* Only work in 2D, the third coordinate is not taken into account.
*
* @param n the graph node on which to fix embedding
* @param subgraph If not null, only fixes the embedding of the node in that sub-graph
**/
void computeEmbedding(const node n, Graph *subgraph=NULL);
/**
* Returns the number of crossings in the layout
**/
//methods removed until we have a working implementation
//unsigned int crossingNumber() const;
// redefinition of some AbstractProperty methods
virtual void setNodeValue(const node, const Coord &v);
virtual void setEdgeValue(const edge, const std::vector<Coord> &v);
virtual void setAllNodeValue(const Coord &v);
virtual void setAllEdgeValue(const std::vector<Coord> &v);
protected:
virtual void clone_handler(AbstractProperty<tlp::PointType, tlp::LineType> &);
private:
void resetBoundingBox();
void rotate(const double& alpha, int rot, Iterator<node> *, Iterator<edge> *);
// override Observable::treatEvent
void treatEvent(const Event&);
public:
// the number of edges with bends
unsigned int nbBendedEdges;
};
/**
* @ingroup Graph
* @brief A graph property that maps a std::vector<tlp::Coord> value to graph elements.
*/
class TLP_SCOPE CoordVectorProperty:public AbstractVectorProperty<tlp::CoordVectorType, tlp::PointType> {
public :
CoordVectorProperty(Graph *g, const std::string& n=""):AbstractVectorProperty<CoordVectorType, tlp::PointType>(g, n) {}
// redefinition of some PropertyInterface methods
PropertyInterface* clonePrototype(Graph *, const std::string& );
static const std::string propertyTypename;
const std::string& getTypename() const {
return propertyTypename;
}
};
typedef CoordVectorProperty LayoutVectorProperty;
}
#endif
|