synfig-core
1.0.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
synfig
distance.h
Go to the documentation of this file.
1
/* === S Y N F I G ========================================================= */
21
/* ========================================================================= */
22
23
/* === S T A R T =========================================================== */
24
25
#ifndef __SYNFIG_DISTANCE_H
26
#define __SYNFIG_DISTANCE_H
27
28
/* === H E A D E R S ======================================================= */
29
30
#include "
real.h
"
31
#include "
string.h
"
32
33
/* === M A C R O S ========================================================= */
34
35
/* === T Y P E D E F S ===================================================== */
36
37
/* === C L A S S E S & S T R U C T S ======================================= */
38
39
namespace
synfig {
40
41
class
RendDesc;
42
43
class
Distance
44
{
45
public
:
46
typedef
Real
value_type
;
47
48
enum
System
49
{
50
SYSTEM_UNITS
,
51
SYSTEM_PIXELS
,
52
53
SYSTEM_POINTS
,
54
SYSTEM_INCHES
,
55
SYSTEM_METERS
,
56
SYSTEM_MILLIMETERS
,
57
SYSTEM_CENTIMETERS
,
58
59
SYSTEM_END
60
};
61
62
class
BadSystem
{ };
63
64
private
:
65
value_type
value_;
66
67
System
system_;
68
69
70
public
:
71
72
Distance
(): value_(), system_() { }
73
Distance
(
const
value_type
& value,
System
system):value_(value),system_(system) { }
74
explicit
Distance
(
const
synfig::String
&
string
);
75
76
operator
Real
()
const
{
return
value_; }
77
78
Distance
&
operator=
(
const
Real
& rhs) { value_=rhs;
return
*
this
; }
79
80
Distance
&
operator=
(
const
synfig::String
& rhs);
81
82
synfig::String
get_string
(
int
digits=4)
const
;
83
84
const
System
&
get_system
()
const
{
return
system_; }
85
86
const
Real
&
get
()
const
{
return
value_; }
87
88
Real
get
(
System
system,
const
RendDesc
& rend_desc)
const
;
89
90
void
convert
(
System
system,
const
RendDesc
& rend_desc);
91
92
Real
meters
()
const
;
93
Real
meters
(
const
RendDesc
& rend_desc)
const
;
94
Real
units
(
const
RendDesc
& rend_desc)
const
;
95
96
static
Real
meters_to_system
(
Real
x,
System
target_system);
97
static
System
ident_system
(
const
synfig::String
& str);
98
static
synfig::String
system_name
(
System
system);
99
static
synfig::String
system_local_name
(
System
system);
100
101
const
Distance
&
operator+=
(
const
Distance
&rhs) { value_+=
meters_to_system
(rhs.
meters
(),system_);
return
*
this
; }
102
const
Distance
&
operator-=
(
const
Distance
&rhs) { value_-=
meters_to_system
(rhs.
meters
(),system_);
return
*
this
; }
103
104
const
Distance
&
operator+=
(
const
float
&rhs) { value_+=rhs;
return
*
this
; }
105
const
Distance
&
operator-=
(
const
float
&rhs) { value_-=rhs;
return
*
this
; }
106
const
Distance
&
operator*=
(
const
float
&rhs) { value_*=rhs;
return
*
this
; }
107
const
Distance
&
operator/=
(
const
float
&rhs) { value_/=rhs;
return
*
this
; }
108
109
/*
110
template<typename U> const Time& operator+=(const U &rhs) { value_+=rhs; return *this; }
111
template<typename U> const Time& operator-=(const U &rhs) { value_-=rhs; return *this; }
112
template<typename U> const Time& operator*=(const U &rhs) { value_*=rhs; return *this; }
113
template<typename U> const Time& operator/=(const U &rhs) { value_/=rhs; return *this; }
114
115
template<typename U> Time operator+(const U &rhs)const { return value_+rhs; }
116
template<typename U> Time operator-(const U &rhs)const { return value_-rhs; }
117
template<typename U> Time operator*(const U &rhs)const { return value_*rhs; }
118
template<typename U> Time operator/(const U &rhs)const { return value_/rhs; }
119
120
Time operator-()const { return -value_; }
121
*/
122
};
// END of class Distance
123
124
};
// END of namespace synfig
125
126
/* === E N D =============================================================== */
127
128
#endif
Generated on Mon Nov 16 2015 15:33:39 for synfig-core by
1.8.1.2