Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Centipede
CentipedePairPolar.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2020 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 "
CentipedePairPolar.h
"
8
#include "
CentipedeSegmentAbstract.h
"
9
#include "
CentipedeSegmentConstantREllipse.h
"
10
#include "
CentipedeSegmentConstantTRadial.h
"
11
#include "
CentipedeSegmentConstantXLine.h
"
12
#include "
CentipedeSegmentConstantYLine.h
"
13
#include "
DocumentModelCoords.h
"
14
#include "
DocumentModelGuideline.h
"
15
#include "
GraphicsScene.h
"
16
#include "
mmsubs.h
"
17
#include "
Transformation.h
"
18
19
CentipedePairPolar::CentipedePairPolar
(
GraphicsScene
&scene,
20
const
Transformation
&transformation,
21
const
DocumentModelGuideline
&modelGuideline,
22
const
DocumentModelCoords
&modelCoords,
23
const
QPointF &posScreen) :
24
m_modelGuideline (modelGuideline),
25
m_centipedeXT (nullptr),
26
m_centipedeYR (nullptr),
27
m_posScreenStart (posScreen),
28
m_selectedXTFinal (true),
29
m_valueFinal (0)
30
{
31
// Create visible Centipede items
32
m_centipedeXT =
new
CentipedeSegmentConstantTRadial
(scene,
33
modelCoords,
34
modelGuideline,
35
transformation,
36
posScreen);
37
m_centipedeYR =
new
CentipedeSegmentConstantREllipse
(scene,
38
modelCoords,
39
modelGuideline,
40
transformation,
41
posScreen);
42
43
// Save starting graph position
44
transformation.
transformScreenToRawGraph
(posScreen,
45
m_posGraphStart);
46
}
47
48
CentipedePairPolar::~CentipedePairPolar
()
49
{
50
delete
m_centipedeXT;
51
delete
m_centipedeYR;
52
}
53
54
bool
CentipedePairPolar::done
(
const
QPointF &posScreen)
55
{
56
QPointF delta = posScreen - m_posScreenStart;
57
double
distanceFromCenter =
magnitude
(delta);
58
59
return
(distanceFromCenter > m_modelGuideline.creationCircleRadius ());
60
}
61
62
void
CentipedePairPolar::move
(
const
QPointF &posScreen)
63
{
64
QPointF delta = posScreen - m_posScreenStart;
65
double
distanceFromCenter =
magnitude
(delta);
66
67
if
(updateFinalValues (posScreen)) {
68
m_centipedeXT->updateRadius (m_modelGuideline.creationCircleRadius () + distanceFromCenter);
69
m_centipedeYR->updateRadius (m_modelGuideline.creationCircleRadius () - distanceFromCenter);
70
}
else
{
71
m_centipedeXT->updateRadius (m_modelGuideline.creationCircleRadius () - distanceFromCenter);
72
m_centipedeYR->updateRadius (m_modelGuideline.creationCircleRadius () + distanceFromCenter);
73
}
74
}
75
76
bool
CentipedePairPolar::selectedXTFinal
()
const
77
{
78
return
m_selectedXTFinal;
79
}
80
81
bool
CentipedePairPolar::updateFinalValues (
const
QPointF &posScreen)
82
{
83
// Update selection
84
double
distXT = m_centipedeXT->
distanceToClosestEndpoint
(posScreen);
85
double
distYR = m_centipedeYR->
distanceToClosestEndpoint
(posScreen);
86
m_selectedXTFinal = (distXT < distYR);
87
88
// Update value
89
if
(m_selectedXTFinal) {
90
m_valueFinal = m_posGraphStart.x();
91
}
else
{
92
m_valueFinal = m_posGraphStart.y();
93
}
94
95
return
m_selectedXTFinal;
96
}
97
98
double
CentipedePairPolar::valueFinal
()
const
99
{
100
return
m_valueFinal;
101
}
CentipedePairPolar.h
CentipedeSegmentAbstract.h
CentipedeSegmentConstantREllipse.h
CentipedeSegmentConstantTRadial.h
CentipedeSegmentConstantXLine.h
CentipedeSegmentConstantYLine.h
DocumentModelCoords.h
DocumentModelGuideline.h
GraphicsScene.h
Transformation.h
CentipedePairPolar::move
void move(const QPointF &posScreen)
Follow cursor move.
Definition
CentipedePairPolar.cpp:62
CentipedePairPolar::CentipedePairPolar
CentipedePairPolar(GraphicsScene &scene, const Transformation &transformation, const DocumentModelGuideline &modelGuideline, const DocumentModelCoords &modelCoords, const QPointF &posScreen)
Constructor with individual coordinates.
Definition
CentipedePairPolar.cpp:19
CentipedePairPolar::selectedXTFinal
bool selectedXTFinal() const
True if XT is final selection, otherwise false if YR is final selection.
Definition
CentipedePairPolar.cpp:76
CentipedePairPolar::valueFinal
double valueFinal() const
Final XT or YT (depending on selectedXTFinal) value.
Definition
CentipedePairPolar.cpp:98
CentipedePairPolar::done
bool done(const QPointF &posScreen)
True if cursor has moved far enough that the CentipedePairPolar has finished and should be removed.
Definition
CentipedePairPolar.cpp:54
CentipedePairPolar::~CentipedePairPolar
virtual ~CentipedePairPolar()
Definition
CentipedePairPolar.cpp:48
CentipedeSegmentAbstract::distanceToClosestEndpoint
virtual double distanceToClosestEndpoint(const QPointF &posScreen) const =0
Return distance to closest endpoint.
CentipedeSegmentConstantREllipse
Centipede for constant R.
Definition
CentipedeSegmentConstantREllipse.h:20
CentipedeSegmentConstantTRadial
Centipede for constant T radial using QGraphicsLineItem.
Definition
CentipedeSegmentConstantTRadial.h:19
DocumentModelCoords
Model for DlgSettingsCoords and CmdSettingsCoords.
Definition
DocumentModelCoords.h:21
DocumentModelGuideline
Model for managing the coordinate values corresponding Guidelines.
Definition
DocumentModelGuideline.h:22
GraphicsScene
Add point and line handling to generic QGraphicsScene.
Definition
GraphicsScene.h:37
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:465
magnitude
double magnitude(const QPointF &vec)
Norm of vector.
Definition
mmsubs.cpp:193
mmsubs.h
Generated on
for Engauge Digitizer by
1.17.0