MyBooks
cutereport_functions.h
Go to the documentation of this file.
1 /***************************************************************************
2  * This file is part of the CuteReport project *
3  * Copyright (C) 2012-2017 by Alexander Mikhalov *
4  * alexander.mikhalov@gmail.com *
5  * *
6  ** GNU General Public License Usage **
7  * *
8  * This library is free software: you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation, either version 3 of the License, or *
11  * (at your option) any later version. *
12  * You should have received a copy of the GNU General Public License *
13  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
14  * *
15  ** GNU Lesser General Public License **
16  * *
17  * This library is free software: you can redistribute it and/or modify *
18  * it under the terms of the GNU Lesser General Public License as *
19  * published by the Free Software Foundation, either version 3 of the *
20  * License, or (at your option) any later version. *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library. *
23  * If not, see <http://www.gnu.org/licenses/>. *
24  * *
25  * This library is distributed in the hope that it will be useful, *
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
28  * GNU General Public License for more details. *
29  ****************************************************************************/
30 #ifndef FUNCTIONS_H
31 #define FUNCTIONS_H
32 
33 #include "cutereport_types.h"
34 #include "cutereport_globals.h"
35 
36 namespace CuteReport
37 {
38 
39 inline qreal mm2pixel(qreal mm, qreal dpi) { return ((mm * dpi) / 25.4); }
40 inline qreal pixel2mm(qreal pixels, qreal dpi) { return (pixels * 25.4) / dpi; }
41 inline qreal inch2pixel(qreal inches, qreal dpi) { return (inches * dpi);}
42 inline qreal pixel2inch(qreal pixels, qreal dpi) { return pixels/dpi; }
43 
44 inline qreal mm2pixel_trunc(qreal mm, qreal dpi) { return (int)((mm * dpi) / 25.4); }
45 inline qreal mm2pixel_ceil(qreal mm, qreal dpi) { return ceil((mm * dpi) / 25.4); }
46 //inline qreal mm2pixel_round(qreal mm, qreal dpi) { return round((mm * dpi) / 25.4); }
47 
48 inline qreal mm2inch(qreal mm) { return mm/25.4; }
49 inline qreal inch2mm(qreal inch) { return inch * 25.4; }
50 
51 CUTEREPORT_EXPORTS QRectF convertUnit(const QRectF & rect, Unit unitIn, Unit unitOut, int dpi, bool roundPixels = true);
52 CUTEREPORT_EXPORTS QPointF convertUnit(const QPointF & point, Unit unitIn, Unit unitOut, int dpi, bool roundPixels = true);
53 CUTEREPORT_EXPORTS QSizeF convertUnit(const QSizeF & size, Unit unitIn, Unit unitOut, int dpi, bool roundPixels = true);
54 CUTEREPORT_EXPORTS qreal convertUnit(const qreal & value, Unit unitIn, Unit unitOut, int dpi, bool roundPixels = true);
55 
56 //CUTEREPORT_EXPORTS QRectF convertUnit2(const QRectF & rect, Unit unitIn, Unit unitOut, int dpi);
57 //CUTEREPORT_EXPORTS QPointF convertUnit2(const QPointF & point, Unit unitIn, Unit unitOut, int dpi);
58 
62 
63 CUTEREPORT_EXPORTS bool typeIsNumber(QVariant::Type type);
64 
65 //CUTEREPORT_EXPORTS QSet<QString> findVariables(const QString & str);
66 //CUTEREPORT_EXPORTS QString setVariablesValue(const QString & str, const QVariantHash & values);
67 //CUTEREPORT_EXPORTS bool isStringValued(const QString & str, const QVariantHash & values, QStringList * missedVariables = 0);
68 
69 } //namespace
70 #endif // FUNCTIONS_H
qreal mm2pixel_trunc(qreal mm, qreal dpi)
Definition: cutereport_functions.h:44
qreal pixel2mm(qreal pixels, qreal dpi)
Definition: cutereport_functions.h:40
Definition: abstractpainterdelegate.h:42
qreal mm2pixel(qreal mm, qreal dpi)
Definition: cutereport_functions.h:39
CUTEREPORT_EXPORTS bool typeIsNumber(QVariant::Type type)
CUTEREPORT_EXPORTS QString unitToFullString(CuteReport::Unit unit)
CUTEREPORT_EXPORTS QString unitToShortString(CuteReport::Unit unit)
CUTEREPORT_EXPORTS QRectF convertUnit(const QRectF &rect, Unit unitIn, Unit unitOut, int dpi, bool roundPixels=true)
qreal mm2inch(qreal mm)
Definition: cutereport_functions.h:48
qreal mm2pixel_ceil(qreal mm, qreal dpi)
Definition: cutereport_functions.h:45
qreal pixel2inch(qreal pixels, qreal dpi)
Definition: cutereport_functions.h:42
CUTEREPORT_EXPORTS CuteReport::Unit unitFromString(const QString &str)
#define CUTEREPORT_EXPORTS
Definition: cutereport_globals.h:47
qreal inch2mm(qreal inch)
Definition: cutereport_functions.h:49
Unit
Definition: cutereport_types.h:95
qreal inch2pixel(qreal inches, qreal dpi)
Definition: cutereport_functions.h:41