Engauge Digitizer
2
Loading...
Searching...
No Matches
Guideline
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
7
#include "
GuidelineProjectorAbstract.h
"
8
#include <QPointF>
9
#include <QRectF>
10
#include "
Transformation.h
"
11
12
GuidelineProjectorAbstract::GuidelineProjectorAbstract
()
13
{
14
}
15
16
GuidelineProjectorAbstract::~GuidelineProjectorAbstract
()
17
{
18
}
19
20
void
GuidelineProjectorAbstract::calculateCorners
(
const
Transformation
&transformation,
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
39
bool
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
}
GuidelineProjectorAbstract.h
Transformation.h
GuidelineProjectorAbstract::isOutside
bool isOutside(const QRectF &sceneRect, const QPointF &posScreen) const
Return true if point is outside of the scene.
Definition
GuidelineProjectorAbstract.cpp:39
GuidelineProjectorAbstract::~GuidelineProjectorAbstract
~GuidelineProjectorAbstract()
Definition
GuidelineProjectorAbstract.cpp:16
GuidelineProjectorAbstract::calculateCorners
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.
Definition
GuidelineProjectorAbstract.cpp:20
GuidelineProjectorAbstract::GuidelineProjectorAbstract
GuidelineProjectorAbstract()
Single constructor.
Definition
GuidelineProjectorAbstract.cpp:12
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition
Transformation.h:32
Transformation::transformScreenToRawGraph
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
Definition
Transformation.cpp:452
Generated on
for Engauge Digitizer by
1.14.0