synfig-core
1.0.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
synfig
valuetransformation.h
Go to the documentation of this file.
1
2
/* === S Y N F I G ========================================================= */
22
/* ========================================================================= */
23
24
/* === S T A R T =========================================================== */
25
26
#ifndef __SYNFIG_VALUE_TRANSFORMATION_H
27
#define __SYNFIG_VALUE_TRANSFORMATION_H
28
29
/* === H E A D E R S ======================================================= */
30
31
#include "
value.h
"
32
#include "
transformation.h
"
33
34
/* === M A C R O S ========================================================= */
35
36
/* === T Y P E D E F S ===================================================== */
37
38
/* === C L A S S E S & S T R U C T S ======================================= */
39
40
namespace
synfig {
41
45
class
ValueTransformation
46
{
47
private
:
49
ValueTransformation() { }
50
51
public
:
52
static
bool
check_type
(
Type
&type) {
53
return
type ==
type_angle
54
|| type ==
type_bline_point
55
|| type ==
type_matrix
56
|| type ==
type_segment
57
|| type ==
type_transformation
58
|| type ==
type_vector
59
|| type ==
type_width_point
;
60
}
61
62
static
bool
check_type
(
const
ValueBase
&value)
63
{
return
check_type
(value.
get_type
()); }
64
65
static
ValueBase
transform
(
const
Transformation
&transformation,
const
ValueBase
&value) {
66
Type
&type(value.
get_type
());
67
if
(type ==
type_angle
)
68
return
value.
get
(
Angle
()) + transformation.
angle
;
69
else
70
if
(type ==
type_bline_point
)
71
{
72
BLinePoint
bp(value.
get
(
BLinePoint
()));
73
bp.
set_vertex
( transformation.
transform
(bp.get_vertex()) );
74
bp.set_tangent1( transformation.
transform
(bp.get_tangent1(),
false
) );
75
bp.set_tangent2( transformation.
transform
(bp.get_tangent2(),
false
) );
76
return
bp;
77
}
78
else
79
if
(type ==
type_matrix
)
80
return
transformation.
transform
(value.
get
(
Matrix
()));
81
else
82
if
(type ==
type_segment
)
83
{
84
Segment
s(value.
get
(
Segment
()));
85
s.
p1
= transformation.
transform
(s.p1);
86
s.t1 = transformation.
transform
(s.t1,
false
);
87
s.p2 = transformation.
transform
(s.p2);
88
s.t2 = transformation.
transform
(s.t2,
false
);
89
return
s;
90
}
91
else
92
if
(type ==
type_transformation
)
93
return
transformation.
transform
(value.
get
(
Transformation
()));
94
else
95
if
(type ==
type_vector
)
96
return
transformation.
transform
(value.
get
(
Vector
()));
97
else
98
if
(type ==
type_width_point
)
99
{
100
WidthPoint
wp(value.
get
(
WidthPoint
()));
101
wp.
set_width
( wp.get_width()*transformation.
scale
[1] );
102
return
wp;
103
}
104
105
return
value;
106
}
107
108
static
ValueBase
back_transform
(
const
Transformation
&transformation,
const
ValueBase
&value)
109
{
return
transform
(transformation.
get_back_transformation
(), value); }
110
};
111
112
};
// END of namespace synfig
113
114
/* === E N D =============================================================== */
115
116
#endif
Generated on Mon Nov 16 2015 15:34:00 for synfig-core by
1.8.1.2