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