Engauge Digitizer 2
Loading...
Searching...
No Matches
DigitizeStateCurve.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 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 "CmdAddPointGraph.h"
8#include "CmdMediator.h"
9#include "CursorFactory.h"
11#include "DigitizeStateCurve.h"
12#include "Logger.h"
13#include "MainWindow.h"
14#include "OrdinalGenerator.h"
15#include <QCursor>
16#include <QGraphicsScene>
17#include <QImage>
18#include <QSize>
19#include "Transformation.h"
20
25
29
31{
33}
34
36 DigitizeState /* previousState */)
37{
38 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::begin";
39
40 setCursor(cmdMediator);
41 context().setDragMode(QGraphicsView::NoDrag);
44}
45
46bool DigitizeStateCurve::canPaste (const Transformation &transformation,
47 const QSize &size) const
48{
49 return canPasteProtected (transformation,
50 size);
51}
52
53QCursor DigitizeStateCurve::cursor(CmdMediator *cmdMediator) const
54{
55 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::cursor";
56
57 CursorFactory cursorFactory;
58 QCursor cursor = cursorFactory.generate (cmdMediator->document().modelDigitizeCurve());
59
60 return cursor;
61}
62
64{
65 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::end";
66}
67
69{
70 return false;
71}
72
74 const QString &pointIdentifier)
75{
76 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleContextMenuEventAxis "
77 << " point=" << pointIdentifier.toLatin1 ().data ();
78}
79
81 const QStringList &pointIdentifiers)
82{
83 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve ::handleContextMenuEventGraph "
84 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
85}
86
88{
89 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleCurveChange";
90}
91
93 Qt::Key key,
94 bool atLeastOneSelectedItem)
95{
96 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleKeyPress"
97 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
98
99 handleKeyPressArrow (cmdMediator,
100 key,
101 atLeastOneSelectedItem);
102}
103
105 QPointF /* posScreen */)
106{
107// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::handleMouseMove";
108}
109
111 QPointF /* posScreen */)
112{
113 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMousePress";
114}
115
117 QPointF posScreen)
118{
119 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMouseRelease";
120
121 // Create command to add point
122 OrdinalGenerator ordinalGenerator;
123 Document &document = cmdMediator->document ();
124 const Transformation &transformation = context ().mainWindow ().transformation();
125 QUndoCommand *cmd = new CmdAddPointGraph (context ().mainWindow(),
126 document,
127 context ().mainWindow().selectedGraphCurve(),
128 posScreen,
129 ordinalGenerator.generateCurvePointOrdinal(document,
130 transformation,
131 posScreen,
132 activeCurve ()));
133 context().appendNewCmd(cmdMediator,
134 cmd);
135}
136
138{
139 return "DigitizeStateCurve";
140}
141
143{
144 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateAfterPointAddition";
145}
146
148 const DocumentModelDigitizeCurve & /*modelDigitizeCurve */)
149{
150 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelDigitizeCurve";
151
152 setCursor(cmdMediator);
153}
154
156{
157 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelSegments";
158}
DigitizeState
Set of possible states of Digitize toolbar.
log4cpp::Category * mainCat
Definition Logger.cpp:14
Command for adding one graph point.
Command queue stack.
Definition CmdMediator.h:24
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Create standard cross cursor, or custom cursor, according to settings.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
virtual void handleKeyPressArrow(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
If the key is an arrow (left, right, up, down) then move currently selected items.
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
virtual bool canPaste(const Transformation &transformation, const QSize &viewSize) const
Return true if there is good data in the clipboard for pasting, and that is compatible with the curre...
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
virtual bool guidelinesAreSelectable() const
Enable/disable guidelines according to state.
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
virtual QString state() const
State name for debugging.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
DigitizeStateCurve(DigitizeStateContext &context)
Single constructor.
virtual void handleMouseMove(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mod...
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsSegments and CmdSettingsSegments.
Storage of one imported image and the data attached to that image.
Definition Document.h:44
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Definition Document.cpp:721
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
void handleGuidelinesActiveChange(bool active)
Handle Guidelines active status toggle.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
Transformation transformation() const
Return read-only copy of transformation.
Utility class for generating ordinal numbers.
double generateCurvePointOrdinal(const Document &document, const Transformation &transformation, const QPointF &posScreen, const QString &curveName)
Select ordinal so new point curve passes smoothly through existing points.
Affine transformation between screen and graph coordinates, based on digitized axis points.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20