MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Misc.hpp
Go to the documentation of this file.
1 #ifndef MISC_H
2 #define MISC_H
3 
8 #include <Config.hpp>
9 #include <GL.hpp>
10 
11 #include <Color.hpp>
12 #include <EdgeData.hpp>
13 #include <MGXViewer/qglviewer.h>
14 #include <Vector.hpp>
15 #include <VertexData.hpp>
16 #include <VVGraph.hpp>
17 
18 #include <QDir>
19 #include <QList>
20 #include <QtGui>
21 
22 namespace mgx {
23 
24 static const QString UM(QString::fromWCharArray(L"\xb5m")); // um
25 static const QString UM2(QString::fromWCharArray(L"\xb5m\xb2")); // um^2
26 static const QString UM3(QString::fromWCharArray(L"\xb5m\xb3")); // um^3
27 static const QString UM_1(QString::fromWCharArray(L"\xb5m\x207B\xb9")); // um^-1
28 static const QString UM_2(QString::fromWCharArray(L"\xb5m\x207B\xb2")); // um^-2
29 
30 #ifdef _MSC_VER
31 template class mgx_EXPORT graph::Vertex<VertexData>;
32 template class mgx_EXPORT graph::Edge<EdgeData>;
33 template class mgx_EXPORT graph::VVGraph<VertexData, EdgeData>;
34 #endif
35 
36 // Type of the VV graph
37 typedef graph::VVGraph<VertexData, EdgeData> vvgraph;
38 
39 // Type of a vertex
40 typedef vvgraph::vertex_t vertex;
41 
42 // Type of an edge
43 typedef vvgraph::edge_t edge;
44 
46 typedef util::Vector<2, int> Point2i;
47 typedef util::Vector<3, GLuint> Point3GLui;
48 typedef util::Vector<4, GLuint> Point4GLui;
49 typedef util::Vector<3, GLubyte> Point3GLub;
50 typedef util::Vector<4, GLubyte> Point4GLub;
51 typedef util::Color<float> Colorf;
52 typedef util::Vector<3, float> Point3f;
53 
54 namespace util {
56 mgx_EXPORT QDir resourcesDir();
58 mgx_EXPORT QDir userProcessesDir();
60 mgx_EXPORT QList<QDir> processesDirs();
62 mgx_EXPORT QDir libsDir();
64 mgx_EXPORT QDir includesDir();
66 mgx_EXPORT QDir docsDir();
67 
69 inline Point3GLub vMapColor(uint u)
70 {
71  u++;
72  return (Point3GLub(u / (256 * 256), u / 256 % 256, u % 256));
73 }
74 
76 inline uint vMapColor(Point3GLub& p) {
77  return ((int(p.x()) * 256 * 256 + int(p.y()) * 256 + int(p.z())) - 1);
78 }
79 
81 inline QString shield(QString s)
82 {
83  s.replace("\\", "\\\\");
84  s.replace(" ", "\\s");
85  s.replace("\n", "\\n");
86  s.replace("\t", "\\t");
87  s.replace("\"", "\\\"");
88  s.replace("\'", "\\\'");
89  return s;
90 }
91 
93 inline QString unshield(QString s)
94 {
95  s.replace("\\\'", "\'");
96  s.replace("\\\"", "\"");
97  s.replace("\\s", " ");
98  s.replace("\\n", "\n");
99  s.replace("\\t", "\t");
100  s.replace("\\\\", "\\");
101  return s;
102 }
103 
105 inline QString shield_python(QString s)
106 {
107  s.replace("\\", "\\\\");
108  s.replace("\n", "\\n");
109  s.replace("\t", "\\t");
110  s.replace("\"", "\\\"");
111  s.replace("\'", "\\\'");
112  return s;
113 }
114 
116 inline QString unshield_python(QString s)
117 {
118  s.replace("\\\'", "\'");
119  s.replace("\\\"", "\"");
120  s.replace("\\n", "\n");
121  s.replace("\\t", "\t");
122  s.replace("\\\\", "\\");
123  return s;
124 }
125 
126 } // namespace util
127 } // namespace mgx
128 #endif
fromWCharArray(const wchar_t *string, int size=-1)
This file contains the definition of a vertex.
replace(int position, int n, const QString &after)
graph::VVGraph< VertexData, EdgeData > vvgraph
Type of the VV graph holding the actual mesh.
Definition: Mesh.hpp:36
This file contains the definition of an edge data.
vvgraph::vertex_t vertex
Type of a vertex.
Definition: Mesh.hpp:39
Edge< EdgeData > edge_t
Weak pointer on an edge.
Definition: VVGraph.hpp:81
Contain the definition of the VVGraph template class.
Defines the Color class template.
vvgraph::edge_t edge
Type of an edge.
Definition: Mesh.hpp:42
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can't...