-
Notifications
You must be signed in to change notification settings - Fork 1
/
MappingGui.h
231 lines (174 loc) · 5.57 KB
/
MappingGui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
* MappingGui.h
*
* (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
* (c) 2013 Alexandre Quessy -- alexandre(@)quessy(.)net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAPPING_GUI_
#define MAPPING_GUI_
#include <QtGlobal>
#if __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "Shape.h"
#include "Paint.h"
#include "Mapping.h"
#include "MapperGLCanvas.h"
#include "ShapeGraphicsItem.h"
#include "ShapeControlPainter.h"
#include "Util.h"
#include "qtpropertymanager.h"
#include "qtvariantproperty.h"
#include "qttreepropertybrowser.h"
#include "qtbuttonpropertybrowser.h"
#include "qtgroupboxpropertybrowser.h"
#include "variantmanager.h"
#include "variantfactory.h"
namespace mmp {
/**
* This is the "view" side of the Mapping class (model). It contains the graphic items for
* both input and output as well as the properties editor.
*/
class MappingGui : public QObject
{
Q_OBJECT
public:
typedef QSharedPointer<MappingGui> ptr;
protected:
/// Constructor. A mapper applies to a mapping.
MappingGui(Mapping::ptr mapping);
public:
virtual ~MappingGui() {}
public:
/// Returns a pointer to the properties editor for that mapper.
virtual QWidget* getPropertiesEditor() { return _propertyBrowser.data(); }
/// Returns the output/destination ShapeGraphicsItem.
virtual QSharedPointer<ShapeGraphicsItem> getGraphicsItem() const { return _graphicsItem; }
/// Returns the input/source ShapeGraphicsItem.
virtual QSharedPointer<ShapeGraphicsItem> getInputGraphicsItem() { return _inputGraphicsItem; }
public slots:
virtual void setValue(QtProperty* property, const QVariant& value);
virtual void setValue(QString propertyName, QVariant value);
virtual void updateShape(MShape* shape);
signals:
void valueChanged();
protected:
Mapping::ptr _mapping;
QSharedPointer<QtTreePropertyBrowser> _propertyBrowser;
QtVariantEditorFactory* _variantFactory;
QtVariantPropertyManager* _variantManager;
QtProperty* _topItem;
QtVariantProperty* _opacityItem;
QtProperty* _outputItem;
std::map<QtProperty*, std::pair<MShape*, int> > _propertyToVertex;
QSharedPointer<ShapeGraphicsItem> _graphicsItem;
QSharedPointer<ShapeGraphicsItem> _inputGraphicsItem;
// FIXME: use typedefs, member of the class for type names that are too long to type:
MShape::ptr outputShape;
virtual void _buildShapeProperty(QtProperty* shapeItem, MShape* shape);
virtual void _updateShapeProperty(QtProperty* shapeItem, MShape* shape);
};
/// Parent class for color -> color mappings.
class ColorMappingGui : public MappingGui
{
Q_OBJECT
protected:
ColorMappingGui(Mapping::ptr mapping);
virtual ~ColorMappingGui() {}
protected:
QSharedPointer<Color> color;
};
class PolygonColorMappingGui : public ColorMappingGui
{
Q_OBJECT
public:
PolygonColorMappingGui(Mapping::ptr mapping);
virtual ~PolygonColorMappingGui() {}
};
class MeshColorMappingGui : public PolygonColorMappingGui
{
Q_OBJECT
public:
MeshColorMappingGui(Mapping::ptr mapping);
virtual ~MeshColorMappingGui() {}
public slots:
virtual void setValue(QtProperty* property, const QVariant& value);
private:
QtVariantProperty* _meshItem;
};
class EllipseColorMappingGui : public ColorMappingGui
{
Q_OBJECT
public:
EllipseColorMappingGui(Mapping::ptr mapping);
virtual ~EllipseColorMappingGui() {}
};
/// Parent class for texture -> texture mapping.
class TextureMappingGui : public MappingGui
{
Q_OBJECT
public:
TextureMappingGui(QSharedPointer<TextureMapping> mapping);
virtual ~TextureMappingGui() {}
public slots:
virtual void updateShape(MShape* shape);
protected:
QtProperty* _inputItem;
QtVariantProperty* _meshItem;
// FIXME: use typedefs, member of the class for type names that are too long to type:
QWeakPointer<TextureMapping> textureMapping;
QWeakPointer<Texture> texture;
QWeakPointer<MShape> inputShape;
};
class PolygonTextureMappingGui : public TextureMappingGui
{
Q_OBJECT
public:
PolygonTextureMappingGui(QSharedPointer<TextureMapping> mapping) : TextureMappingGui(mapping) {}
virtual ~PolygonTextureMappingGui() {}
};
class TriangleTextureMappingGui : public PolygonTextureMappingGui
{
Q_OBJECT
public:
TriangleTextureMappingGui(QSharedPointer<TextureMapping> mapping);
virtual ~TriangleTextureMappingGui() {}
};
class MeshTextureMappingGui : public PolygonTextureMappingGui
{
Q_OBJECT
public:
MeshTextureMappingGui(QSharedPointer<TextureMapping> mapping);
virtual ~MeshTextureMappingGui() {}
public slots:
virtual void setValue(QtProperty* property, const QVariant& value);
private:
QtVariantProperty* _meshItem;
};
class EllipseTextureMappingGui : public PolygonTextureMappingGui {
Q_OBJECT
public:
EllipseTextureMappingGui(QSharedPointer<TextureMapping> mapping);
virtual ~EllipseTextureMappingGui() {}
protected:
static void _setPointOfEllipseAtAngle(QPointF& point, const QPointF& center, float hRadius, float vRadius, float rotation, float circularAngle);
};
}
#endif /* MAPPER_H_ */