Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineStateHandleY.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 "GraphicsScene.h"
9#include "GuidelineAbstract.h"
11#include "GuidelineState.h"
14#include "Logger.h"
15#include "Transformation.h"
16
21
25
27{
28 LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateHandleY::begin"
29 << " identifier=" << context().guideline().identifier().toLatin1().data();
30
31 beginCommon ();
32}
33
35{
36 const double ARBITRARY_X = 1; // Value that is legal in all cases including log
37 QPointF posScreen;
38 context().transformation().transformRawGraphToScreen (QPointF (ARBITRARY_X,
39 valueGraph),
40 posScreen);
41
42 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateHandleY::convertGraphCoordinateToScreenPoint"
43 << " pos=(" << posScreen.x() << ", " << posScreen.y() << ")";
44
45 return posScreen;
46}
47
49{
50 QPointF posGraph;
52 posGraph);
53
54 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateHandleY::convertScreenPointToGraphCoordinate"
55 << " pos=(" << posGraph.x() << ", " << posGraph.y() << ")";
56
57 return posGraph.y();
58}
59
61{
62 LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateHandleY::end";
63}
64
73
74EllipseParameters GuidelineStateHandleY::pointToEllipse (const QPointF & /* posScreen */) const
75{
76 // pointToLine applies in this state
77 return EllipseParameters();
78}
79
80QLineF GuidelineStateHandleY::pointToLine (const QPointF &posScreen) const
81{
83
84 return projector.fromPosScreen (context().transformation(),
85 sceneRect (),
86 posScreen);
87}
88
QString guidelineStateAsString(GuidelineState state)
@ GUIDELINE_STATE_HANDLE_Y
@ GUIDELINE_STATE_DISCARDED
@ GUIDELINE_STATE_DEPLOYED_CONSTANT_Y_SELECT_EDIT
log4cpp::Category * mainCat
Definition Logger.cpp:14
Parameters that define an ellipse about the specified center, at the specified angle from alignment w...
void sacrificeHandleAndVisibleGuidelines(const QPointF &posScene, GuidelineState guidelineStateForReplacement)
Replace visible and handle Guidelines after click and drag.
virtual QString identifier() const =0
Unique identifier from QGraphicsItem.
Project a point along the horizontal direction in graph coordinates to produce a line segment along t...
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.
GuidelineStateHandleAbstract(GuidelineStateContext &context)
Single constructor.
virtual EllipseParameters pointToEllipse(const QPointF &posScreen) const
Return ellipse representing constant range, that passes through the specified point.
virtual double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
virtual QString stateName() const
Name of state as a string for debugging only.
virtual void end()
Transition out of state.
virtual void handleMouseRelease(const QPointF &posScene)
At the end of dragging, clone the Guideline that owns the state machine where these states live.
virtual void begin()
Transition into state.
virtual QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const
Convert single graph coordinate into screen point pair.
virtual QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
GuidelineStateHandleY(GuidelineStateContext &context)
Single constructor.
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_INFO_S(logger)
Definition convenience.h:18
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20