scantools 1.0.8
Graphics manipulation with a view towards scanned documents
paperSize.h
1/*
2 * Copyright © 2017-2020 Stefan Kebekus <stefan.kebekus@math.uni-freiburg.de>
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation, either version 3 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19#ifndef PAPERSIZE
20#define PAPERSIZE
21
22#include "length.h"
23
24
30
32{
33 public:
42
44 paperSize() : _width(), _height() {
45 }
46
53 paperSize(length width, length height) : _width(width), _height(height) {
54 }
55
60 // cppcheck-suppress noExplicitConstructor
62 setSize(f);
63 }
64
74 paperSize(QString formatString, bool *ok=0) {
75 bool myOk = setSize(formatString);
76 if (ok)
77 *ok = myOk;
78 }
79
84 bool isEmpty() const {
85 return (_width.isNonPositive() || _height.isNonPositive());
86 }
87
93 _height = height;
94 return;
95 }
96
102 _width = width;
103 return;
104 }
105
110 length height() const {
111 return _height;
112 }
113
118 length width() const {
119 return _width;
120 }
121
127
135 bool setSize(QString formatString);
136
137 private:
138 length _width;
139 length _height;
140};
141
142#endif
The length stores a length and converts between units.
Definition length.h:38
void setHeight(length height)
Sets paper height.
Definition paperSize.h:92
void setSize(format f)
Sets paperSize to a given standard format.
paperSize(format f)
Constructs paperSize for given standard format.
Definition paperSize.h:61
bool isEmpty() const
Checks for empty paper size.
Definition paperSize.h:84
paperSize()
Constructs empty paperSize.
Definition paperSize.h:44
bool setSize(QString formatString)
Reads paperSize from a string.
paperSize(QString formatString, bool *ok=0)
Constructs paperSize from a string.
Definition paperSize.h:74
format
List of supported standard sizes.
Definition paperSize.h:35
@ A4
DIN A4.
Definition paperSize.h:36
@ A5
DIN A5.
Definition paperSize.h:37
@ Legal
US Legal.
Definition paperSize.h:40
@ Letter
US Standard Letter.
Definition paperSize.h:39
@ empty
0x0mm
Definition paperSize.h:38
length width() const
Width of the paper.
Definition paperSize.h:118
paperSize(length width, length height)
Constructs paperSize of given width and height.
Definition paperSize.h:53
length height() const
Height of the paper.
Definition paperSize.h:110
void setWidth(length width)
Sets paper width.
Definition paperSize.h:101