-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapper.h
157 lines (130 loc) · 3.49 KB
/
Mapper.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
/*
* Mapper.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 MAPPER_H_
#define MAPPER_H_
#include <QtGlobal>
#if __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#include <tr1/memory>
#include <stdlib.h>
#include <stdio.h>
#include "Shape.h"
#include "Paint.h"
#include "Mapping.h"
#include "Util.h"
#include "qtpropertymanager.h"
#include "qtvariantproperty.h"
#include "qttreepropertybrowser.h"
#include "qtbuttonpropertybrowser.h"
#include "qtgroupboxpropertybrowser.h"
/**
* A way to draw on some kind of shape.
*
* This is an abstract class for specific ways to draw
* a given paint of a shape.
*
* Each shape x paint combination that is possible in
* this software are implemented using a child of this
* class.
*/
class Mapper : public QObject
{
Q_OBJECT
protected:
Mapping::ptr _mapping;
public:
typedef std::tr1::shared_ptr<Mapper> ptr;
Mapper(Mapping::ptr mapping) : _mapping(mapping) {}
virtual ~Mapper() {}
virtual QWidget* getPropertiesEditor() = 0;
virtual void draw() = 0;
public slots:
virtual void updateShape(Shape* shape)
{
Q_UNUSED(shape);
}
};
//class ShapeDrawer
//{
//protected:
// std:tr1::shared_ptr<Shape> _shape;
//
//public:
// ShapeDrawer(const std:tr1::shared_ptr<Shape>& shape) : _shape(shape) {}
// virtual ~ShapeDrawer() {}
//
// virtual void draw() = 0;
//};
//
//class QuadDrawer
//{
//public:
// QuadDrawer(const std:tr1::shared_ptr<Quad>& quad) : ShapeDrawer(quad) {}
//
// virtual void draw() {
// std::tr1::shared_ptr<Quad> quad = std::tr1::static_pointer_cast<Quad>(_shape);
// wxASSERT(quad != NULL);
//
// glColor4f (1, 1, 1, 1);
//
// // Source quad.
// glLineWidth(5);
// glBegin (GL_LINE_STRIP);
// {
// for (int i=0; i<5; i++) {
// glVertex3f(quad->getVertex(i % 4).x / (GLfloat)texture->getWidth(),
// quad->getVertex(i % 4).y / (GLfloat)texture->getHeight(),
// 0);
// }
// }
// glEnd ();
// }
//};
/**
* Draws a texture.
*/
class TextureMapper : public Mapper
{
Q_OBJECT
public:
TextureMapper(std::tr1::shared_ptr<TextureMapping> mapping);
virtual ~TextureMapper() {}
virtual QWidget* getPropertiesEditor();
virtual void draw();
signals:
void valueChanged();
public slots:
void setValue(QtProperty* property, const QVariant& value);
void updateShape(Shape* shape);
private:
QtAbstractPropertyBrowser* _propertyBrowser;
QtVariantEditorFactory* _variantFactory;
QtVariantPropertyManager* _variantManager;
QtProperty* _topItem;
QtProperty* _inputItem;
QtProperty* _outputItem;
std::map<QtProperty*, std::pair<Shape*, int> > _propertyToVertex;
void _buildShapeProperty(QtProperty* shapeItem, Shape* shape);
void _updateShapeProperty(QtProperty* shapeItem, Shape* shape);
};
#endif /* MAPPER_H_ */