Tulip  5.7.4
Large graphs analysis and drawing
TulipMetaTypes.h
1 /*
2  *
3  * This file is part of Tulip (https://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/PropertiesCollection.h>
46 #include <tulip/StringCollection.h>
47 #include <tulip/TulipViewSettings.h>
48 
49 // Helper class for filesystem types handling
50 struct TulipFileDescriptor {
51  enum FileType { File, Directory };
52 
53  TulipFileDescriptor() {}
54  TulipFileDescriptor(const QString &absolutePath, FileType fileType, bool existing = true)
55  : absolutePath(absolutePath), type(fileType), mustExist(existing) {}
56  TulipFileDescriptor(const TulipFileDescriptor &d) {
57  absolutePath = d.absolutePath;
58  type = d.type;
59  mustExist = d.mustExist;
60  }
61  TulipFileDescriptor &operator=(const TulipFileDescriptor &) = default;
62  QString absolutePath;
63  FileType type;
64  // indicate if the file or dir must exist
65  bool mustExist;
66  QString fileFilterPattern;
67 };
68 
69 struct TextureFile {
70  QString texturePath;
71  TextureFile() {}
72  TextureFile(const QString &texturePath) : texturePath(texturePath) {}
73 };
74 
75 struct TulipFontIcon {
76 
77  TulipFontIcon() {}
78 
79  TulipFontIcon(const QString &iconName) : iconName(iconName) {}
80 
81  QString iconName;
82 };
83 
84 // Declare tulip type compatible with QVariant
85 Q_DECLARE_METATYPE(tlp::DataSet)
86 
87 Q_DECLARE_METATYPE(tlp::DoubleProperty *)
88 Q_DECLARE_METATYPE(tlp::DoubleVectorProperty *)
89 Q_DECLARE_METATYPE(std::vector<double>)
90 
91 Q_DECLARE_METATYPE(tlp::Color)
92 Q_DECLARE_METATYPE(tlp::ColorProperty *)
93 Q_DECLARE_METATYPE(tlp::ColorVectorProperty *)
94 Q_DECLARE_METATYPE(std::vector<tlp::Color>)
95 
96 Q_DECLARE_METATYPE(tlp::Size)
97 Q_DECLARE_METATYPE(tlp::SizeProperty *)
98 Q_DECLARE_METATYPE(tlp::SizeVectorProperty *)
99 Q_DECLARE_METATYPE(std::vector<tlp::Size>)
100 
101 Q_DECLARE_METATYPE(std::string)
102 Q_DECLARE_METATYPE(tlp::StringProperty *)
103 Q_DECLARE_METATYPE(tlp::StringVectorProperty *)
104 Q_DECLARE_METATYPE(std::vector<std::string>)
105 
106 // Q_DECLARE_METATYPE(tlp::Coord)
107 Q_DECLARE_METATYPE(tlp::LayoutProperty *)
108 Q_DECLARE_METATYPE(tlp::CoordVectorProperty *)
109 // Q_DECLARE_METATYPE(std::vector<tlp::Coord>)
110 
111 Q_DECLARE_METATYPE(tlp::Graph *)
112 Q_DECLARE_METATYPE(tlp::GraphProperty *)
113 
114 Q_DECLARE_METATYPE(tlp::IntegerProperty *)
115 Q_DECLARE_METATYPE(tlp::IntegerVectorProperty *)
116 Q_DECLARE_METATYPE(std::vector<int>)
117 
118 Q_DECLARE_METATYPE(tlp::BooleanProperty *)
119 Q_DECLARE_METATYPE(tlp::BooleanVectorProperty *)
120 // Q_DECLARE_METATYPE(std::vector<bool>)
121 Q_DECLARE_METATYPE(QVector<bool>)
122 
123 Q_DECLARE_METATYPE(tlp::node)
124 Q_DECLARE_METATYPE(tlp::edge)
125 Q_DECLARE_METATYPE(std::set<tlp::edge>)
126 
127 Q_DECLARE_METATYPE(tlp::NumericProperty *)
128 
129 Q_DECLARE_METATYPE(tlp::PropertyInterface *)
130 
131 Q_DECLARE_METATYPE(tlp::ColorScale)
132 
133 Q_DECLARE_METATYPE(tlp::StringCollection)
134 Q_DECLARE_METATYPE(tlp::PropertiesCollection)
135 
136 Q_DECLARE_METATYPE(TextureFile)
137 Q_DECLARE_METATYPE(TulipFileDescriptor)
138 Q_DECLARE_METATYPE(TulipFontIcon)
139 
140 Q_DECLARE_METATYPE(tlp::NodeShape::NodeShapes)
141 Q_DECLARE_METATYPE(tlp::EdgeShape::EdgeShapes)
142 Q_DECLARE_METATYPE(tlp::EdgeExtremityShape::EdgeExtremityShapes)
143 
144 Q_DECLARE_METATYPE(tlp::LabelPosition::LabelPositions)
145 Q_DECLARE_METATYPE(tlp::TulipFont)
146 
147 Q_DECLARE_METATYPE(QStringList)
148 
149 namespace tlp {
150 class TLP_QT_SCOPE TulipMetaTypes {
151  TulipMetaTypes() {}
152 
153  template <typename T>
154  inline static QVariant typedVariant(tlp::DataType *dm) {
155  T result;
156 
157  if (dm)
158  result = *(static_cast<T *>(dm->value));
159 
160  return QVariant::fromValue<T>(result);
161  }
162 
163 public:
164  static tlp::DataType *qVariantToDataType(const QVariant &);
165  static QVariant dataTypeToQvariant(tlp::DataType *, const std::string &paramName);
166 };
167 
168 class TLP_QT_SCOPE QStringListType : public TypeInterface<QStringList> {
169 public:
170  static void write(std::ostream &, const RealType &);
171  static bool read(std::istream &, RealType &);
172  FORWARD_STRING_METHODS(QStringListType)
173 };
174 
175 class TLP_QT_SCOPE QStringType : public TypeInterface<QString> {
176 public:
177  static void write(std::ostream &, const RealType &);
178  static bool read(std::istream &, RealType &);
179  static std::string toString(const RealType &);
180  static bool fromString(RealType &, const std::string &);
181 };
182 
183 extern void initQTypeSerializers();
184 } // namespace tlp
185 
186 #endif // TULIPMETATYPES_H
187 ///@endcond
A graph property that maps a Boolean value to graph elements.
A graph property that maps a std::vector<bool> value to graph elements.
A graph property that maps a tlp::Color value to graph elements.
Definition: ColorProperty.h:36
This class represents a color scale to perform color mapping. The color scale can be either a gradien...
Definition: ColorScale.h:62
A graph property that maps a std::vector<tlp::Color> value to graph elements.
Definition: ColorProperty.h:57
A graph property that maps a std::vector<tlp::Coord> value to graph elements.
A container that can store data from any type.
Definition: DataSet.h:195
A graph property that maps a double value to graph elements.
A graph property that maps a std::vector<double> 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 an integer value to graph elements.
A graph property that maps a std::vector<int> value to graph elements.
A graph property that maps a tlp::Coord value to graph nodes and std::vector<tlp::Coord> for edges.
Interface all numerical properties. Property values are always returned as double.
PropertyInterface describes the interface of a graph property.
A graph property that maps a tlp::Size value to graph elements.
Definition: SizeProperty.h:39
A graph property that maps a std::vector<tlp::Size> value to graph elements.
Definition: SizeProperty.h:81
A graph property that maps a std::string value to graph elements.
A graph property that maps a std::vector<std::string> value to graph elements.
Describes a value of any type.
Definition: DataSet.h:57
void * value
The actual pointer to the element's data.
Definition: DataSet.h:86
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