Tulip  5.2.1
Large graphs analysis and drawing
TulipMetaTypes.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 ///@cond DOXYGEN_HIDDEN
20 
21 #ifndef TULIPMETATYPES_H
22 #define TULIPMETATYPES_H
23 
24 #include <QVector>
25 #include <QStringList>
26 #include <QVariant>
27 
28 #include <tulip/DataSet.h>
29 #include <tulip/Graph.h>
30 #include <tulip/Color.h>
31 #include <tulip/Coord.h>
32 #include <tulip/Size.h>
33 #include <tulip/BooleanProperty.h>
34 #include <tulip/DoubleProperty.h>
35 #include <tulip/ColorProperty.h>
36 #include <tulip/SizeProperty.h>
37 #include <tulip/StringProperty.h>
38 #include <tulip/LayoutProperty.h>
39 #include <tulip/GraphProperty.h>
40 #include <tulip/IntegerProperty.h>
41 #include <tulip/ColorScale.h>
42 #include <tulip/GlGraphStaticData.h>
43 #include <tulip/GlLabel.h>
44 #include <tulip/TulipFont.h>
45 #include <tulip/StringCollection.h>
46 #include <tulip/TulipViewSettings.h>
47 
48 // Helper class for filesystem types handling
49 struct TulipFileDescriptor {
50  enum FileType { File, Directory };
51 
52  TulipFileDescriptor() {}
53  TulipFileDescriptor(const QString &absolutePath, FileType fileType, bool existing = true)
54  : absolutePath(absolutePath), type(fileType), mustExist(existing) {}
55  TulipFileDescriptor(const TulipFileDescriptor &d) {
56  absolutePath = d.absolutePath;
57  type = d.type;
58  mustExist = d.mustExist;
59  }
60  QString absolutePath;
61  FileType type;
62  // indicate if the file or dir must exist
63  bool mustExist;
64  QString fileFilterPattern;
65 };
66 
67 struct TextureFile {
68  QString texturePath;
69  TextureFile() {}
70  TextureFile(const QString &texturePath) : texturePath(texturePath) {}
71 };
72 
73 struct TulipFontIcon {
74 
75  TulipFontIcon() {}
76 
77  TulipFontIcon(const QString &iconName) : iconName(iconName) {}
78 
79  QString iconName;
80 };
81 
82 // Declare tulip type compatible with QVariant
83 Q_DECLARE_METATYPE(tlp::DataSet)
84 
85 Q_DECLARE_METATYPE(tlp::DoubleProperty *)
86 Q_DECLARE_METATYPE(tlp::DoubleVectorProperty *)
87 Q_DECLARE_METATYPE(std::vector<double>)
88 
89 Q_DECLARE_METATYPE(tlp::Color)
90 Q_DECLARE_METATYPE(tlp::ColorProperty *)
91 Q_DECLARE_METATYPE(tlp::ColorVectorProperty *)
92 Q_DECLARE_METATYPE(std::vector<tlp::Color>)
93 
94 Q_DECLARE_METATYPE(tlp::Size)
95 Q_DECLARE_METATYPE(tlp::SizeProperty *)
96 Q_DECLARE_METATYPE(tlp::SizeVectorProperty *)
97 Q_DECLARE_METATYPE(std::vector<tlp::Size>)
98 
99 Q_DECLARE_METATYPE(std::string)
100 Q_DECLARE_METATYPE(tlp::StringProperty *)
101 Q_DECLARE_METATYPE(tlp::StringVectorProperty *)
102 Q_DECLARE_METATYPE(std::vector<std::string>)
103 
104 // Q_DECLARE_METATYPE(tlp::Coord)
105 Q_DECLARE_METATYPE(tlp::LayoutProperty *)
106 Q_DECLARE_METATYPE(tlp::CoordVectorProperty *)
107 // Q_DECLARE_METATYPE(std::vector<tlp::Coord>)
108 
109 Q_DECLARE_METATYPE(tlp::Graph *)
110 Q_DECLARE_METATYPE(tlp::GraphProperty *)
111 
112 Q_DECLARE_METATYPE(tlp::IntegerProperty *)
113 Q_DECLARE_METATYPE(tlp::IntegerVectorProperty *)
114 Q_DECLARE_METATYPE(std::vector<int>)
115 
116 Q_DECLARE_METATYPE(tlp::BooleanProperty *)
117 Q_DECLARE_METATYPE(tlp::BooleanVectorProperty *)
118 // Q_DECLARE_METATYPE(std::vector<bool>)
119 Q_DECLARE_METATYPE(QVector<bool>)
120 
121 Q_DECLARE_METATYPE(tlp::node)
122 Q_DECLARE_METATYPE(tlp::edge)
123 Q_DECLARE_METATYPE(std::set<tlp::edge>)
124 
125 Q_DECLARE_METATYPE(tlp::NumericProperty *)
126 
127 Q_DECLARE_METATYPE(tlp::PropertyInterface *)
128 
129 Q_DECLARE_METATYPE(tlp::ColorScale)
130 
131 Q_DECLARE_METATYPE(tlp::StringCollection)
132 
133 Q_DECLARE_METATYPE(TextureFile)
134 Q_DECLARE_METATYPE(TulipFileDescriptor)
135 Q_DECLARE_METATYPE(TulipFontIcon)
136 
137 Q_DECLARE_METATYPE(tlp::NodeShape::NodeShapes)
138 Q_DECLARE_METATYPE(tlp::EdgeShape::EdgeShapes)
139 Q_DECLARE_METATYPE(tlp::EdgeExtremityShape::EdgeExtremityShapes)
140 
141 Q_DECLARE_METATYPE(tlp::LabelPosition::LabelPositions)
142 Q_DECLARE_METATYPE(tlp::TulipFont)
143 
144 Q_DECLARE_METATYPE(QStringList)
145 
146 namespace tlp {
147 class TLP_QT_SCOPE TulipMetaTypes {
148  TulipMetaTypes() {}
149 
150  template <typename T>
151  inline static QVariant typedVariant(tlp::DataType *dm) {
152  T result;
153 
154  if (dm)
155  result = *(static_cast<T *>(dm->value));
156 
157  return QVariant::fromValue<T>(result);
158  }
159 
160 public:
161  static tlp::DataType *qVariantToDataType(const QVariant &);
162  static QVariant dataTypeToQvariant(tlp::DataType *, const std::string &paramName);
163 };
164 
165 class TLP_QT_SCOPE QStringListType : public TypeInterface<QStringList> {
166 public:
167  static void write(std::ostream &, const RealType &);
168  static bool read(std::istream &, RealType &);
169  FORWARD_STRING_METHODS(QStringListType)
170 };
171 
172 class TLP_QT_SCOPE QStringType : public TypeInterface<QString> {
173 public:
174  static void write(std::ostream &, const RealType &);
175  static bool read(std::istream &, RealType &);
176  static std::string toString(const RealType &);
177  static bool fromString(RealType &, const std::string &);
178 };
179 
180 extern void initQTypeSerializers();
181 } // namespace tlp
182 
183 #endif // TULIPMETATYPES_H
184 ///@endcond
A graph property that maps a std::vector<tlp::Color> value to graph elements.
Definition: ColorProperty.h:54
A graph property that maps a std::vector<tlp::Coord> value to graph elements.
A graph property that maps a boolean value to graph elements.
PropertyInterface describes the interface of a graph property.
Describes a value of any type.
Definition: DataSet.h:57
A container that can store data from any type.
Definition: DataSet.h:189
A graph property that maps a std::vector<std::string> value to graph elements.
This class represents a color scale to perform color mapping. The color scale can be either a gradien...
Definition: ColorScale.h:62
The edge struct represents an edge in a Graph object.
Definition: Edge.h:40
The node struct represents a node in a Graph object.
Definition: Node.h:40
A graph property that maps a std::string value to graph elements.
A graph property that maps a std::vector<int> value to graph elements.
A graph property that maps a tlp::Graph* value to graph elements.
Definition: GraphProperty.h:42
A graph property that maps a tlp::Size value to graph elements.
Definition: SizeProperty.h:38
A graph property that maps a double value to graph elements.
Interface all numerical properties. Property values are always returned as double.
void * value
The actual pointer to the element&#39;s data.
Definition: DataSet.h:86
A graph property that maps a std::vector<bool> value to graph elements.
A graph property that maps a std::vector<tlp::Size> value to graph elements.
Definition: SizeProperty.h:79
A graph property that maps a std::vector<double> value to graph elements.
A graph property that maps a tlp::Color value to graph elements.
Definition: ColorProperty.h:36
A graph property that maps an integer value to graph elements.
A graph property that maps a tlp::Coord value to graph nodes and std::vector<tlp::Coord> for edges...