From 8b8ea9395bdda4bb1404497ff654b82098084822 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sun, 18 Mar 2018 11:58:33 -0400 Subject: finally got bboxes working...i think --- src/tikzit.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/tikzit.h') 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 -- cgit v1.2.3