-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapping.h
104 lines (86 loc) · 2.38 KB
/
Mapping.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
/*
* Mapping.h
*
* (c) 2013 Sofian Audry -- info(@)sofianaudry(.)com
*
* 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_H_
#define MAPPING_H_
#include <QtGlobal>
#include <tr1/memory>
#include "Shape.h"
#include "Paint.h"
#include "Layer.h"
class Layer;
/**
* One object in the scene that is a shape with some paint on it.
*
* A Mapping is an area of the rendering window that is drawn with
* either some texture, or any special effect that might animate a
* polygon or a line.
*/
class Mapping : public QObject
{
Q_OBJECT
Q_PROPERTY(uint _id READ getId)
protected:
Paint::ptr _paint;
Shape::ptr _shape;
Layer* _layer;
private:
uint _id;
public:
typedef std::tr1::shared_ptr<Mapping> ptr;
Mapping(Paint::ptr paint, Shape::ptr shape)
: _paint(paint), _shape(shape), _layer(0)
{
static uint id = 0;
_id = id++;
}
virtual ~Mapping() {}
virtual void build() {
_paint->build();
_shape->build();
}
public:
Paint::ptr getPaint() const { return _paint; }
Shape::ptr getShape() const { return _shape; }
uint getId() const { return _id; }
Layer* getLayer() const { return _layer; }
void setLayer(Layer* layer) { _layer = layer; }
};
/**
* Object whose paint is an image texture. In the case of a texture mapping we require
* an additional input shape to specify the area on the image where we pick the pixels.
*/
class TextureMapping : public Mapping
{
private:
Shape::ptr _inputShape;
public:
TextureMapping(Paint::ptr paint,
Shape::ptr shape,
Shape::ptr inputShape)
: Mapping(paint, shape),
_inputShape(inputShape)
{}
virtual void build() {
Mapping::build();
_inputShape->build();
}
public:
Shape::ptr getInputShape() const { return _inputShape; }
};
#endif /* MAPPING_H_ */