Tulip  4.0.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 1 and Inria Bordeaux - Sud Ouest
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 <QtCore/QFileInfo>
25 #include <QtCore/QVariant>
26 
27 #include <tulip/DataSet.h>
28 #include <tulip/Graph.h>
29 #include <tulip/DataSet.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 
46 #include <vector>
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):absolutePath(absolutePath),type(fileType) {}
54  TulipFileDescriptor(const TulipFileDescriptor& d) {
55  absolutePath = d.absolutePath;
56  type = d.type;
57  }
58  QString absolutePath;
59  FileType type;
60  QString fileFilterPattern;
61 };
62 
63 
64 struct NodeShape {
65  unsigned int nodeShapeId;
66  NodeShape(unsigned int nodeShapeId=0):nodeShapeId(nodeShapeId) {}
67  operator unsigned int() const {
68  return nodeShapeId;
69  }
70 };
71 
72 struct EdgeExtremityShape {
73  unsigned int edgeExtremityShapeId;
74  EdgeExtremityShape(unsigned int edgeExtremityShapeId=0):edgeExtremityShapeId(edgeExtremityShapeId) {}
75  operator unsigned int() const {
76  return edgeExtremityShapeId;
77  }
78 };
79 
80 //Declare tulip type compatible with QVariant
81 Q_DECLARE_METATYPE(tlp::DataSet)
82 
83 Q_DECLARE_METATYPE(tlp::DoubleProperty*)
84 Q_DECLARE_METATYPE(tlp::DoubleVectorProperty*)
85 Q_DECLARE_METATYPE(std::vector<double>)
86 
87 Q_DECLARE_METATYPE(tlp::ColorProperty*)
88 Q_DECLARE_METATYPE(tlp::ColorVectorProperty*)
89 Q_DECLARE_METATYPE(std::vector<tlp::Color>)
90 
91 Q_DECLARE_METATYPE(tlp::Size)
92 Q_DECLARE_METATYPE(tlp::SizeProperty*)
93 Q_DECLARE_METATYPE(tlp::SizeVectorProperty*)
94 Q_DECLARE_METATYPE(std::vector<tlp::Size>)
95 
96 Q_DECLARE_METATYPE(std::string)
97 Q_DECLARE_METATYPE(tlp::StringProperty*)
98 Q_DECLARE_METATYPE(tlp::StringVectorProperty*)
99 Q_DECLARE_METATYPE(std::vector<std::string>)
100 
101 //Q_DECLARE_METATYPE(tlp::Coord)
102 Q_DECLARE_METATYPE(tlp::LayoutProperty*)
103 Q_DECLARE_METATYPE(tlp::CoordVectorProperty*)
104 //Q_DECLARE_METATYPE(std::vector<tlp::Coord>)
105 
106 Q_DECLARE_METATYPE(tlp::Graph*)
107 Q_DECLARE_METATYPE(tlp::GraphProperty*)
108 
109 Q_DECLARE_METATYPE(tlp::IntegerProperty*)
110 Q_DECLARE_METATYPE(tlp::IntegerVectorProperty*)
111 Q_DECLARE_METATYPE(std::vector<int>)
112 
113 Q_DECLARE_METATYPE(tlp::BooleanProperty*)
114 Q_DECLARE_METATYPE(tlp::BooleanVectorProperty*)
115 Q_DECLARE_METATYPE(std::vector<bool>)
116 
117 Q_DECLARE_METATYPE(std::set<tlp::edge>)
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 
127 Q_DECLARE_METATYPE(NodeShape)
128 Q_DECLARE_METATYPE(tlp::EdgeShape)
129 Q_DECLARE_METATYPE(EdgeExtremityShape)
130 
131 Q_DECLARE_METATYPE(tlp::LabelPosition)
132 Q_DECLARE_METATYPE(tlp::TulipFont)
133 
134 
135 namespace tlp {
136 class TLP_QT_SCOPE TulipMetaTypes {
137  TulipMetaTypes() {}
138 
139  template<typename T>
140  inline static QVariant typedVariant(tlp::DataType *dm) {
141  T result;
142 
143  if (dm)
144  result = *((T*)dm->value);
145 
146  return QVariant::fromValue<T>(result);
147  }
148 
149 public:
150  static tlp::DataType *qVariantToDataType(const QVariant &);
151  static QVariant dataTypeToQvariant(tlp::DataType *,const std::string& paramName);
152 
153 };
154 }
155 
156 #endif // TULIPMETATYPES_H
157 ///@endcond