Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineProjectorAbstract.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2019 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
8#include <QPointF>
9#include <QRectF>
10#include "Transformation.h"
11
15
19
21 const QRectF &sceneRect,
22 QPointF &posGraphBL,
23 QPointF &posGraphTL,
24 QPointF &posGraphTR,
25 QPointF &posGraphBR) const
26{
27 double width = sceneRect.width();
28 double height = sceneRect.height();
29
30 // Convert sceneRect to graph coordinates
31 QPointF posScreenBL (0, 0), posScreenTL (0, height), posScreenTR (width, height), posScreenBR (width, 0);
32
33 transformation.transformScreenToRawGraph (posScreenBL, posGraphBL);
34 transformation.transformScreenToRawGraph (posScreenTL, posGraphTL);
35 transformation.transformScreenToRawGraph (posScreenTR, posGraphTR);
36 transformation.transformScreenToRawGraph (posScreenBR, posGraphBR);
37}
38
39bool GuidelineProjectorAbstract::isOutside (const QRectF &sceneRect,
40 const QPointF &posScreen) const
41{
42 double width = sceneRect.width();
43 double height = sceneRect.height();
44
45 QPointF posScreenBL (0, 0), posScreenTL (0, height), posScreenTR (width, height), posScreenBR (width, 0);
46
47 QPolygonF polygon;
48 polygon << posScreenBL << posScreenTL << posScreenTR << posScreenBR;
49
50 // Qt::OddEvenFill is faster and less accurate and Qt::WindingFill is slower and more accurate
51 return !polygon.containsPoint (posScreen,
52 Qt::WindingFill);
53}
bool isOutside(const QRectF &sceneRect, const QPointF &posScreen) const
Return true if point is outside of the scene.
void calculateCorners(const Transformation &transformation, const QRectF &sceneRect, QPointF &posGraphBL, QPointF &posGraphTL, QPointF &posGraphTR, QPointF &posGraphBR) const
Conpute four corners of scene in graph coordinates.
GuidelineProjectorAbstract()
Single constructor.
Affine transformation between screen and graph coordinates, based on digitized axis points.
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.