Tulip  4.3.0
Better Visualization Through Research
 All Classes Namespaces 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 <tulip/DataSet.h>
25 #include <tulip/Graph.h>
26 #include <tulip/Color.h>
27 #include <tulip/Coord.h>
28 #include <tulip/Size.h>
29 #include <tulip/BooleanProperty.h>
30 #include <tulip/DoubleProperty.h>
31 #include <tulip/ColorProperty.h>
32 #include <tulip/SizeProperty.h>
33 #include <tulip/StringProperty.h>
34 #include <tulip/LayoutProperty.h>
35 #include <tulip/GraphProperty.h>
36 #include <tulip/IntegerProperty.h>
37 #include <tulip/ColorScale.h>
38 #include <tulip/GlGraphStaticData.h>
39 #include <tulip/GlLabel.h>
40 #include <tulip/TulipFont.h>
41 #include <tulip/StringCollection.h>
42 
43 // Helper class for filesystem types handling
44 struct TulipFileDescriptor {
45  enum FileType {File,Directory};
46 
47  TulipFileDescriptor() {}
48  TulipFileDescriptor(const QString& absolutePath,FileType fileType):absolutePath(absolutePath),type(fileType) {}
49  TulipFileDescriptor(const TulipFileDescriptor& d) {
50  absolutePath = d.absolutePath;
51  type = d.type;
52  }
53  QString absolutePath;
54  FileType type;
55  QString fileFilterPattern;
56 };
57 
58 
59 struct NodeShape {
60  unsigned int nodeShapeId;
61  NodeShape(unsigned int nodeShapeId=0):nodeShapeId(nodeShapeId) {}
62  operator unsigned int() const {
63  return nodeShapeId;
64  }
65 };
66 
67 struct EdgeExtremityShape {
68  unsigned int edgeExtremityShapeId;
69  EdgeExtremityShape(unsigned int edgeExtremityShapeId=0):edgeExtremityShapeId(edgeExtremityShapeId) {}
70  operator unsigned int() const {
71  return edgeExtremityShapeId;
72  }
73 };
74 
75 //Declare tulip type compatible with QVariant
76 Q_DECLARE_METATYPE(tlp::DataSet)
77 
78 Q_DECLARE_METATYPE(tlp::DoubleProperty*)
79 Q_DECLARE_METATYPE(tlp::DoubleVectorProperty*)
80 Q_DECLARE_METATYPE(std::vector<double>)
81 
82 Q_DECLARE_METATYPE(tlp::Color)
83 Q_DECLARE_METATYPE(tlp::ColorProperty*)
84 Q_DECLARE_METATYPE(tlp::ColorVectorProperty*)
85 Q_DECLARE_METATYPE(std::vector<tlp::Color>)
86 
87 Q_DECLARE_METATYPE(tlp::Size)
88 Q_DECLARE_METATYPE(tlp::SizeProperty*)
89 Q_DECLARE_METATYPE(tlp::SizeVectorProperty*)
90 Q_DECLARE_METATYPE(std::vector<tlp::Size>)
91 
92 Q_DECLARE_METATYPE(std::string)
93 Q_DECLARE_METATYPE(tlp::StringProperty*)
94 Q_DECLARE_METATYPE(tlp::StringVectorProperty*)
95 Q_DECLARE_METATYPE(std::vector<std::string>)
96 
97 //Q_DECLARE_METATYPE(tlp::Coord)
98 Q_DECLARE_METATYPE(tlp::LayoutProperty*)
99 Q_DECLARE_METATYPE(tlp::CoordVectorProperty*)
100 //Q_DECLARE_METATYPE(std::vector<tlp::Coord>)
101 
102 Q_DECLARE_METATYPE(tlp::Graph*)
103 Q_DECLARE_METATYPE(tlp::GraphProperty*)
104 
105 Q_DECLARE_METATYPE(tlp::IntegerProperty*)
106 Q_DECLARE_METATYPE(tlp::IntegerVectorProperty*)
107 Q_DECLARE_METATYPE(std::vector<int>)
108 
109 Q_DECLARE_METATYPE(tlp::BooleanProperty*)
110 Q_DECLARE_METATYPE(tlp::BooleanVectorProperty*)
111 Q_DECLARE_METATYPE(std::vector<bool>)
112 
113 Q_DECLARE_METATYPE(std::set<tlp::edge>)
114 
115 Q_DECLARE_METATYPE(tlp::NumericProperty*)
116 
117 Q_DECLARE_METATYPE(tlp::PropertyInterface*)
118 
119 Q_DECLARE_METATYPE(tlp::ColorScale)
120 
121 Q_DECLARE_METATYPE(tlp::StringCollection)
122 
123 Q_DECLARE_METATYPE(TulipFileDescriptor)
124 
125 Q_DECLARE_METATYPE(NodeShape)
126 Q_DECLARE_METATYPE(tlp::EdgeShape)
127 Q_DECLARE_METATYPE(EdgeExtremityShape)
128 
129 Q_DECLARE_METATYPE(tlp::LabelPosition)
130 Q_DECLARE_METATYPE(tlp::TulipFont)
131 
132 Q_DECLARE_METATYPE(QStringList)
133 
134 namespace tlp {
135 class TLP_QT_SCOPE TulipMetaTypes {
136  TulipMetaTypes() {}
137 
138  template<typename T>
139  inline static QVariant typedVariant(tlp::DataType *dm) {
140  T result;
141 
142  if (dm)
143  result = *((T*)dm->value);
144 
145  return QVariant::fromValue<T>(result);
146  }
147 
148 public:
149  static tlp::DataType *qVariantToDataType(const QVariant &);
150  static QVariant dataTypeToQvariant(tlp::DataType *,const std::string& paramName);
151 };
152 
153 class TLP_QT_SCOPE QStringListType: public TypeInterface<QStringList> {
154 public:
155  static void write(std::ostream&, const RealType&);
156  static bool read(std::istream&, RealType&);
157  FORWARD_STRING_METHODS(QStringListType)
158 };
159 
160 class TLP_QT_SCOPE QStringType: public TypeInterface<QString> {
161 public:
162  static void write(std::ostream&, const RealType&);
163  static bool read(std::istream&, RealType&);
164  static std::string toString(const RealType &);
165  static bool fromString(RealType &, const std::string &);
166 };
167 
168 extern void initQTypeSerializers();
169 
170 }
171 
172 #endif // TULIPMETATYPES_H
173 ///@endcond