Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineStateDeployedConstantXAbstract.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 "EngaugeAssert.h"
8#include "GuidelineLine.h"
12#include "Logger.h"
13#include "Transformation.h"
14
19
23
25{
26 const double ARBITRARY_Y = 1.0; // Value that is legal in all cases, including log scaling
27 QPointF posScreen;
28 context().transformation().transformRawGraphToScreen (QPointF (valueGraph,
29 ARBITRARY_Y),
30 posScreen);
31
32 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateDeployedConstantXAbstract::convertGraphCoordinateToScreenPoint"
33 << " pos=(" << posScreen.x() << ", " << posScreen.y() << ")";
34
35 return posScreen;
36}
37
39{
40 QPointF posGraph;
42 posGraph);
43
44 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateDeployedConstantXAbstract::convertScreenPointToGraphCoordinate"
45 << " pos=(" << posGraph.x() << ", " << posGraph.y() << ")";
46
47 return posGraph.x();
48}
49
51{
52 // pointToLine applies in this state
53 return EllipseParameters();
54}
55
56QLineF GuidelineStateDeployedConstantXAbstract::pointToLine (const QPointF &posScreen) const
57{
59
60 return projector.fromPosScreen (context().transformation(),
61 sceneRect (),
62 posScreen);
63}
64
66{
67 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateDeployedConstantXAbstract::updateWithLatestTransformation";
68
69 if (!context().transformation().transformIsDefined()) {
70 // Discard this Guideline immediately if the transformation transitions to undefined
72 } else {
73
75
76 GuidelineLine *line = dynamic_cast<GuidelineLine*> (&context().guideline());
77 line->setLine (projector.fromCoordinateX (context().transformation(),
78 sceneRect (),
79 context().posCursorGraph ().x()));
80 }
81}
@ GUIDELINE_STATE_DISCARDED
log4cpp::Category * mainCat
Definition Logger.cpp:14
Parameters that define an ellipse about the specified center, at the specified angle from alignment w...
Line version of GuidelineAbstract.
Project a point along the vertical direction in graph coordinates to produce a line segment along the...
QLineF fromCoordinateX(const Transformation &transformation, const QRectF &sceneRect, double xGraph)
Return line through x in graph coordinates.
QLineF fromPosScreen(const Transformation &transformation, const QRectF &sceneRect, const QPointF &posScreen)
Return line through point in screen coordinates.
QRectF sceneRect() const
Scene rectangle in screen coordinates (=pixels)
GuidelineStateContext & context() const
Context in charge of the state classes.
Context class for state machine that belongs to the Guideline class.
Transformation transformation() const
Return copy of transformation owned by MainWindow.
GuidelineAbstract & guideline()
Guideline that owns this context class.
void requestStateTransition(GuidelineState guidelineState)
Request a state transition.
GuidelineStateDeployedAbstract(GuidelineStateContext &context)
Single constructor.
virtual void updateWithLatestTransformation()
Update given Transformation in GuidelineStateContext.
virtual double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
GuidelineStateDeployedConstantXAbstract(GuidelineStateContext &context)
Single constructor.
virtual QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
virtual QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const
Convert single graph coordinate into screen point pair.
virtual EllipseParameters pointToEllipse(const QPointF &posScreen) const
Return ellipse representing constant range, that passes through the specified point.
void transformRawGraphToScreen(const QPointF &pointRaw, QPointF &pointScreen) const
Transform from raw graph coordinates to linear cartesian graph coordinates, then to screen coordinate...
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20