libdcp
src
text.cc
Go to the documentation of this file.
1
/*
2
Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
3
4
This file is part of libdcp.
5
6
libdcp is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
11
libdcp is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with libdcp. If not, see <http://www.gnu.org/licenses/>.
18
19
In addition, as a special exception, the copyright holders give
20
permission to link the code of portions of this program with the
21
OpenSSL library under certain conditions as described in each
22
individual source file, and distribute linked combinations
23
including the two.
24
25
You must obey the GNU General Public License in all respects
26
for all of the code used other than OpenSSL. If you modify
27
file(s) with this exception, you may extend this exception to your
28
version of the file(s), but you are not obligated to do so. If you
29
do not wish to do so, delete this exception statement from your
30
version. If you delete this exception statement from all source
31
files in the program, then also delete it here.
32
*/
33
34
40
#include "compose.hpp"
41
#include "
dcp_time.h
"
42
#include "
equality_options.h
"
43
#include "
text.h
"
44
45
46
using
std::shared_ptr;
47
using namespace
dcp
;
48
49
51
Text::Text
(
52
Time
in,
53
Time
out,
54
float
h_position,
55
HAlign
h_align,
56
float
v_position,
57
VAlign
v_align,
58
float
z_position,
59
Time
fade_up_time,
60
Time
fade_down_time
61
)
62
: _in (in)
63
, _out (out)
64
, _h_position (h_position)
65
, _h_align (h_align)
66
, _v_position (v_position)
67
, _v_align (v_align)
68
, _z_position(z_position)
69
, _fade_up_time (fade_up_time)
70
, _fade_down_time (fade_down_time)
71
{
72
73
}
74
75
76
bool
77
Text::equals(shared_ptr<const Text> other,
EqualityOptions
const
& options, NoteHandler note)
const
78
{
79
bool
same =
true
;
80
81
if
(
in
() != other->in()) {
82
note(NoteType::ERROR,
"text in times differ"
);
83
same =
false
;
84
}
85
86
if
(
out
() != other->out()) {
87
note(NoteType::ERROR,
"text out times differ"
);
88
same =
false
;
89
}
90
91
if
(h_position() != other->h_position()) {
92
note(NoteType::ERROR,
"text horizontal positions differ"
);
93
same =
false
;
94
}
95
96
if
(h_align() != other->h_align()) {
97
note(NoteType::ERROR,
"text horizontal alignments differ"
);
98
same =
false
;
99
}
100
101
auto
const
vpos = std::abs(
v_position
() - other->v_position());
102
if
(vpos > options.
max_text_vertical_position_error
) {
103
note(
104
NoteType::ERROR,
105
String::compose(
"text vertical positions differ by %1 (more than the allowed difference of %2)"
, vpos, options.
max_text_vertical_position_error
)
106
);
107
same =
false
;
108
}
109
110
if
(v_align() != other->v_align()) {
111
note(NoteType::ERROR,
"text vertical alignments differ"
);
112
same =
false
;
113
}
114
115
if
(z_position() != other->z_position()) {
116
note(NoteType::ERROR,
"text Z positions differ"
);
117
same =
false
;
118
}
119
120
if
(fade_up_time() != other->fade_up_time()) {
121
note(NoteType::ERROR,
"text fade-up times differ"
);
122
same =
false
;
123
}
124
125
if
(fade_down_time() != other->fade_down_time()) {
126
note(NoteType::ERROR,
"text fade-down times differ"
);
127
same =
false
;
128
}
129
130
return
same;
131
}
dcp::EqualityOptions
A class to describe what "equality" means for a particular test.
Definition:
equality_options.h:56
dcp::EqualityOptions::max_text_vertical_position_error
float max_text_vertical_position_error
Definition:
equality_options.h:83
dcp::Text::Text
Text(Time in, Time out, float h_position, HAlign h_align, float v_position, VAlign v_align, float z_position, Time fade_up_time, Time fade_down_time)
Definition:
text.cc:51
dcp::Text::in
Time in() const
Definition:
text.h:61
dcp::Text::out
Time out() const
Definition:
text.h:66
dcp::Text::v_position
float v_position() const
Definition:
text.h:82
dcp::Time
A representation of time within a DCP.
Definition:
dcp_time.h:73
dcp_time.h
Time class.
equality_options.h
Class to describe what equality means when calling Asset::equals().
dcp
Namespace for everything in libdcp.
Definition:
array_data.h:50
dcp::HAlign
HAlign
Definition:
h_align.h:46
dcp::VAlign
VAlign
Definition:
v_align.h:46
text.h
Text class.
Generated on Tue Dec 24 2024 22:10:58 for libdcp by
1.9.1