Introducing vRound function.
Shortcut to round double to X points decimal. --HG-- branch : develop
This commit is contained in:
parent
0c0207aa6f
commit
9e25e6de24
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "vabstractlayoutdialog.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../vmisc/vmath.h"
|
||||
|
||||
//must be the same order as PaperSizeTemplate constants
|
||||
const VAbstractLayoutDialog::FormatsVector VAbstractLayoutDialog::pageFormatNames
|
||||
|
@ -172,12 +173,12 @@ QSizeF VAbstractLayoutDialog::RoundTemplateSize(qreal width, qreal height, Unit
|
|||
case Unit::Cm:
|
||||
case Unit::Mm:
|
||||
case Unit::Px:
|
||||
w = qRound(width * 100.0) / 100.0;
|
||||
h = qRound(height * 100.0) / 100.0;
|
||||
w = vRound(width, 2);
|
||||
h = vRound(height, 2);
|
||||
return QSizeF(w, h);
|
||||
case Unit::Inch:
|
||||
w = qRound(width * 100000.0) / 100000.0;
|
||||
h = qRound(height * 100000.0) / 100000.0;
|
||||
w = vRound(width, 5);
|
||||
h = vRound(height, 5);
|
||||
return QSizeF(w, h);
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -51,5 +51,9 @@
|
|||
#define M_EULER (0.57721566490153286060)
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
Q_DECL_CONSTEXPR inline T vRound(T d, int p)
|
||||
{ return p > 0 ? qRound(d * (p * 10.0)) / (p * 10.0) : qRound(d); }
|
||||
|
||||
#endif // VMATH_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user