diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2018-03-18 11:58:33 -0400 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2018-03-18 11:58:33 -0400 |
commit | 8b8ea9395bdda4bb1404497ff654b82098084822 (patch) | |
tree | c92d720990686acda5eeba18b028fe1e4b656a25 /src/tikzit.h | |
parent | 3cea1514203a451c0a8806d276807863b463a78f (diff) |
finally got bboxes working...i think
Diffstat (limited to 'src/tikzit.h')
-rw-r--r-- | src/tikzit.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/tikzit.h b/src/tikzit.h index 51aea20..5b23083 100644 --- a/src/tikzit.h +++ b/src/tikzit.h @@ -51,13 +51,25 @@ // divisible by 8 to avoid rounding errors with e.g. grid-snapping. #define GLOBAL_SCALE 80 #define GLOBAL_SCALEF 80.0f +#define GLOBAL_SCALEF_INV 0.0125f inline QPointF toScreen(QPointF src) { src.setY(-src.y()); src *= GLOBAL_SCALEF; return src; } inline QPointF fromScreen(QPointF src) -{ src.setY(-src.y()); src /= GLOBAL_SCALEF; return src; } - +{ src.setY(-src.y()); src *= GLOBAL_SCALEF_INV; return src; } + +inline QRectF rectToScreen(QRectF src) +{ return QRectF(src.x() * GLOBAL_SCALEF, + -(src.y()+src.height()) * GLOBAL_SCALEF, + src.width() * GLOBAL_SCALEF, + src.height() * GLOBAL_SCALEF); } + +inline QRectF rectFromScreen(QRectF src) +{ return QRectF(src.x() * GLOBAL_SCALEF_INV, + -(src.y()+src.height()) * GLOBAL_SCALEF_INV, + src.width() * GLOBAL_SCALEF_INV, + src.height() * GLOBAL_SCALEF_INV); } class Tikzit : public QObject { Q_OBJECT |