Engauge Digitizer 2
Loading...
Searching...
No Matches
GuidelineStateHandleT.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)) << "GuidelineStateHandleT::begin"
29 << " identifier=" << context().guideline().identifier().toLatin1().data();
30
31 beginCommon ();
32}
33
35{
36 const double ARBITRARY_RANGE = 0; // Value that is legal in all cases (with log never applying)
37 QPointF posScreen;
38 context().transformation().transformRawGraphToScreen (QPointF (valueGraph,
39 ARBITRARY_RANGE),
40 posScreen);
41
42 LOG4CPP_DEBUG_S ((*mainCat)) << "GuidelineStateHandleT::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)) << "GuidelineStateHandleT::convertScreenPointToGraphCoordinate"
55 << " pos=(" << posGraph.x() << ", " << posGraph.y() << ")";
56
57 return posGraph.x();
58}
59
61{
62 LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateHandleT::end";
63}
64
73
74EllipseParameters GuidelineStateHandleT::pointToEllipse (const QPointF & /* posScreen */) const
75{
76 // pointToLine applies in this state
77 return EllipseParameters();
78}
79
80QLineF GuidelineStateHandleT::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_DISCARDED
@ GUIDELINE_STATE_DEPLOYED_CONSTANT_T_SELECT_EDIT
@ GUIDELINE_STATE_HANDLE_T
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 radial direction in graph coordinates to produce a curve along the constant...
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 void handleMouseRelease(const QPointF &posScene)
At the end of dragging, clone the Guideline that owns the state machine where these states live.
virtual EllipseParameters pointToEllipse(const QPointF &posScreen) const
Return ellipse representing constant range, that passes through the specified point.
virtual QString stateName() const
Name of state as a string for debugging only.
virtual QLineF pointToLine(const QPointF &posScreen) const
Return line parallel to an axis line, that passes through the specified point.
virtual void begin()
Transition into state.
virtual QPointF convertGraphCoordinateToScreenPoint(double valueGraph) const
Convert single graph coordinate into screen point pair.
virtual void end()
Transition out of state.
GuidelineStateHandleT(GuidelineStateContext &context)
Single constructor.
virtual double convertScreenPointToGraphCoordinate(const QPointF &posScreen) const
Convert screen point pair into single graph coordinate.
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