aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcms <cms@beatworm.co.uk>2016-10-12 12:50:59 (GMT)
committercms <cms@beatworm.co.uk>2016-10-12 12:52:52 (GMT)
commitfa947622f4252559f737040e8fa3b3351ec1b34f (patch)
tree7cf04a2fea6605c134706c376387ab932b95bcc9
parent5838ec137b7641f5c682cd6a9a54ec600ad2f532 (diff)
downloadhydra-fa947622f4252559f737040e8fa3b3351ec1b34f.zip
hydra-fa947622f4252559f737040e8fa3b3351ec1b34f.tar.gz
hydra-fa947622f4252559f737040e8fa3b3351ec1b34f.tar.bz2
fixes base unit as explicitly points
adds constructors constructors expect points, and an optional dpi if there is no dpi provided, default to 72 (for now)
-rw-r--r--src/HydraUnit.cpp9
-rw-r--r--src/HydraUnit.h4
2 files changed, 9 insertions, 4 deletions
diff --git a/src/HydraUnit.cpp b/src/HydraUnit.cpp
index 8978038..6c487f1 100644
--- a/src/HydraUnit.cpp
+++ b/src/HydraUnit.cpp
@@ -2,9 +2,12 @@
namespace Hydra {
const double POINTS_PER_MM = 0.352777778 ;
-
- void Unit::mm(double mm_val) { _base = mm_to_points(mm_val); }
- double Unit::mm() { return points_to_mm(_base); }
+
+ Unit::Unit(double points) : _base_points(points), _dpi(72) {}
+ Unit::Unit(double points, int dpi) : _base_points(points), _dpi(dpi){}
+
+ void Unit::mm(double mm_val) { _base_points = mm_to_points(mm_val); }
+ double Unit::mm() { return points_to_mm(_base_points); }
double Unit::mm_to_points(double mm_val)
{
diff --git a/src/HydraUnit.h b/src/HydraUnit.h
index 659f98b..25b73be 100644
--- a/src/HydraUnit.h
+++ b/src/HydraUnit.h
@@ -2,6 +2,8 @@
namespace Hydra {
class Unit {
+ Unit(double points);
+ Unit(double points, int dpi);
double mm();
void mm(double);
@@ -12,7 +14,7 @@ namespace Hydra {
private:
double mm_to_points(double val);
double points_to_mm(double val);
- double _base;
+ double _base_points;
long _dpi ;
};
};