Tulip  4.8.0
Better Visualization Through Research
 All Classes Files Functions Variables Enumerations Enumerator Properties Groups Pages
TulipMetaTypes.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
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):absolutePath(absolutePath),type(fileType),mustExist(existing) {}
54  TulipFileDescriptor(const TulipFileDescriptor& d) {
55  absolutePath = d.absolutePath;
56  type = d.type;
57  mustExist = d.mustExist;
58  }
59  QString absolutePath;
60  FileType type;
61  // indicate if the file or dir must exist
62  bool mustExist;
63  QString fileFilterPattern;
64 };
65 
66 struct TulipFontAwesomeIcon {
67 
68  TulipFontAwesomeIcon() {}
69 
70  TulipFontAwesomeIcon(const QString &iconName) : iconName(iconName) {}
71 
72  QString iconName;
73 
74 };
75 
76 //Declare tulip type compatible with QVariant
77 Q_DECLARE_METATYPE(tlp::DataSet)
78 
79 Q_DECLARE_METATYPE(tlp::DoubleProperty*)
80 Q_DECLARE_METATYPE(tlp::DoubleVectorProperty*)
81 Q_DECLARE_METATYPE(std::vector<double>)
82 
83 Q_DECLARE_METATYPE(tlp::Color)
84 Q_DECLARE_METATYPE(tlp::ColorProperty*)
85 Q_DECLARE_METATYPE(tlp::ColorVectorProperty*)
86 Q_DECLARE_METATYPE(std::vector<tlp::Color>)
87 
88 Q_DECLARE_METATYPE(tlp::Size)
89 Q_DECLARE_METATYPE(tlp::SizeProperty*)
90 Q_DECLARE_METATYPE(tlp::SizeVectorProperty*)
91 Q_DECLARE_METATYPE(std::vector<tlp::Size>)
92 
93 Q_DECLARE_METATYPE(std::string)
94 Q_DECLARE_METATYPE(tlp::StringProperty*)
95 Q_DECLARE_METATYPE(tlp::StringVectorProperty*)
96 Q_DECLARE_METATYPE(std::vector<std::string>)
97 
98 //Q_DECLARE_METATYPE(tlp::Coord)
99 Q_DECLARE_METATYPE(tlp::LayoutProperty*)
100 Q_DECLARE_METATYPE(tlp::CoordVectorProperty*)
101 //Q_DECLARE_METATYPE(std::vector<tlp::Coord>)
102 
103 Q_DECLARE_METATYPE(tlp::Graph*)
104 Q_DECLARE_METATYPE(tlp::GraphProperty*)
105 
106 Q_DECLARE_METATYPE(tlp::IntegerProperty*)
107 Q_DECLARE_METATYPE(tlp::IntegerVectorProperty*)
108 Q_DECLARE_METATYPE(std::vector<int>)
109 
110 Q_DECLARE_METATYPE(tlp::BooleanProperty*)
111 Q_DECLARE_METATYPE(tlp::BooleanVectorProperty*)
112 //Q_DECLARE_METATYPE(std::vector<bool>)
113 Q_DECLARE_METATYPE(QVector<bool>)
114 
115 Q_DECLARE_METATYPE(std::set<tlp::edge>)
116 
117 Q_DECLARE_METATYPE(tlp::NumericProperty*)
118 
119 Q_DECLARE_METATYPE(tlp::PropertyInterface*)
120 
121 Q_DECLARE_METATYPE(tlp::ColorScale)
122 
123 Q_DECLARE_METATYPE(tlp::StringCollection)
124 
125 Q_DECLARE_METATYPE(TulipFileDescriptor)
126 Q_DECLARE_METATYPE(TulipFontAwesomeIcon)
127 
128 Q_DECLARE_METATYPE(tlp::NodeShape::NodeShapes)
129 Q_DECLARE_METATYPE(tlp::EdgeShape::EdgeShapes)
130 Q_DECLARE_METATYPE(tlp::EdgeExtremityShape::EdgeExtremityShapes)
131 
132 Q_DECLARE_METATYPE(tlp::LabelPosition::LabelPositions)
133 Q_DECLARE_METATYPE(tlp::TulipFont)
134 
135 Q_DECLARE_METATYPE(QStringList)
136 
137 namespace tlp {
138 class TLP_QT_SCOPE TulipMetaTypes {
139  TulipMetaTypes() {}
140 
141  template<typename T>
142  inline static QVariant typedVariant(tlp::DataType *dm) {
143  T result;
144 
145  if (dm)
146  result = *((T*)dm->value);
147 
148  return QVariant::fromValue<T>(result);
149  }
150 
151 public:
152  static tlp::DataType *qVariantToDataType(const QVariant &);
153  static QVariant dataTypeToQvariant(tlp::DataType *,const std::string& paramName);
154 };
155 
156 class TLP_QT_SCOPE QStringListType: public TypeInterface<QStringList> {
157 public:
158  static void write(std::ostream&, const RealType&);
159  static bool read(std::istream&, RealType&);
160  FORWARD_STRING_METHODS(QStringListType)
161 };
162 
163 class TLP_QT_SCOPE QStringType: public TypeInterface<QString> {
164 public:
165  static void write(std::ostream&, const RealType&);
166  static bool read(std::istream&, RealType&);
167  static std::string toString(const RealType &);
168  static bool fromString(RealType &, const std::string &);
169 };
170 
171 extern void initQTypeSerializers();
172 
173 }
174 
175 #endif // TULIPMETATYPES_H
176 ///@endcond
Describes a value of any type.
Definition: DataSet.h:57
A container that can store data from any type.
Definition: DataSet.h:172
void * value
The actual pointer to the element's data.
Definition: DataSet.h:74