Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
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
50struct 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
69struct TextureFile {
70 QString texturePath;
71 TextureFile() {}
72 TextureFile(const QString &texturePath) : texturePath(texturePath) {}
73};
74
75struct 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
85Q_DECLARE_METATYPE(tlp::DataSet)
86
87Q_DECLARE_METATYPE(tlp::DoubleProperty *)
88Q_DECLARE_METATYPE(tlp::DoubleVectorProperty *)
89Q_DECLARE_METATYPE(std::vector<double>)
90
91Q_DECLARE_METATYPE(tlp::Color)
92Q_DECLARE_METATYPE(tlp::ColorProperty *)
93Q_DECLARE_METATYPE(tlp::ColorVectorProperty *)
94Q_DECLARE_METATYPE(std::vector<tlp::Color>)
95
96Q_DECLARE_METATYPE(tlp::Size)
97Q_DECLARE_METATYPE(tlp::SizeProperty *)
98Q_DECLARE_METATYPE(tlp::SizeVectorProperty *)
99Q_DECLARE_METATYPE(std::vector<tlp::Size>)
100
101Q_DECLARE_METATYPE(std::string)
102Q_DECLARE_METATYPE(tlp::StringProperty *)
103Q_DECLARE_METATYPE(tlp::StringVectorProperty *)
104Q_DECLARE_METATYPE(std::vector<std::string>)
105
106// Q_DECLARE_METATYPE(tlp::Coord)
107Q_DECLARE_METATYPE(tlp::LayoutProperty *)
108Q_DECLARE_METATYPE(tlp::CoordVectorProperty *)
109// Q_DECLARE_METATYPE(std::vector<tlp::Coord>)
110
111Q_DECLARE_METATYPE(tlp::Graph *)
112Q_DECLARE_METATYPE(tlp::GraphProperty *)
113
114Q_DECLARE_METATYPE(tlp::IntegerProperty *)
115Q_DECLARE_METATYPE(tlp::IntegerVectorProperty *)
116Q_DECLARE_METATYPE(std::vector<int>)
117
118Q_DECLARE_METATYPE(tlp::BooleanProperty *)
119Q_DECLARE_METATYPE(tlp::BooleanVectorProperty *)
120// Q_DECLARE_METATYPE(std::vector<bool>)
121Q_DECLARE_METATYPE(QVector<bool>)
122
123Q_DECLARE_METATYPE(tlp::node)
124Q_DECLARE_METATYPE(tlp::edge)
125Q_DECLARE_METATYPE(std::set<tlp::edge>)
126
127Q_DECLARE_METATYPE(tlp::NumericProperty *)
128
129Q_DECLARE_METATYPE(tlp::PropertyInterface *)
130
131Q_DECLARE_METATYPE(tlp::ColorScale)
132
133Q_DECLARE_METATYPE(tlp::StringCollection)
134Q_DECLARE_METATYPE(tlp::PropertiesCollection)
135
136Q_DECLARE_METATYPE(TextureFile)
137Q_DECLARE_METATYPE(TulipFileDescriptor)
138Q_DECLARE_METATYPE(TulipFontIcon)
139
140Q_DECLARE_METATYPE(tlp::NodeShape::NodeShapes)
141Q_DECLARE_METATYPE(tlp::EdgeShape::EdgeShapes)
142Q_DECLARE_METATYPE(tlp::EdgeExtremityShape::EdgeExtremityShapes)
143
144Q_DECLARE_METATYPE(tlp::LabelPosition::LabelPositions)
145Q_DECLARE_METATYPE(tlp::TulipFont)
146
147Q_DECLARE_METATYPE(QStringList)
148
149namespace tlp {
150class 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
163public:
164 static tlp::DataType *qVariantToDataType(const QVariant &);
165 static QVariant dataTypeToQvariant(tlp::DataType *, const std::string &paramName);
166};
167
168class TLP_QT_SCOPE QStringListType : public TypeInterface<QStringList> {
169public:
170 static void write(std::ostream &, const RealType &);
171 static bool read(std::istream &, RealType &);
172 FORWARD_STRING_METHODS(QStringListType)
173};
174
175class TLP_QT_SCOPE QStringType : public TypeInterface<QString> {
176public:
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
183extern 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:56
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:80
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