Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
DigitizeStateCurve.cpp
1 #include "CmdAddPointGraph.h"
2 #include "CmdMediator.h"
3 #include "CursorFactory.h"
4 #include "DigitizeStateContext.h"
5 #include "DigitizeStateCurve.h"
6 #include "Logger.h"
7 #include "MainWindow.h"
8 #include "OrdinalGenerator.h"
9 #include <QCursor>
10 #include <QGraphicsScene>
11 #include <QImage>
12 
15 {
16 }
17 
18 DigitizeStateCurve::~DigitizeStateCurve ()
19 {
20 }
21 
23 {
25 }
26 
27 void DigitizeStateCurve::begin (DigitizeState /* previousState */)
28 {
29  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::begin";
30 
31  setCursor();
32  context().setDragMode(QGraphicsView::NoDrag);
34 }
35 
37 {
38  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::cursor";
39 
40  CursorFactory cursorFactory;
41  QCursor cursor = cursorFactory.generate (context().cmdMediator().document().modelDigitizeCurve());
42 
43  return cursor;
44 }
45 
47 {
48  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::end";
49 }
50 
52 {
53  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleCurveChange";
54 }
55 
57  bool /* atLeastOneSelectedItem */)
58 {
59  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleKeyPress"
60  << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
61 }
62 
63 void DigitizeStateCurve::handleMouseMove (QPointF /* posScreen */)
64 {
65 // LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::handleMouseMove";
66 }
67 
68 void DigitizeStateCurve::handleMousePress (QPointF /* posScreen */)
69 {
70  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMousePress";
71 }
72 
74 {
75  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMouseRelease";
76 
77  // Create command to add point
78  OrdinalGenerator ordinalGenerator;
79  Document &document = context ().cmdMediator ().document ();
80  const Transformation &transformation = context ().mainWindow ().transformation();
81  QUndoCommand *cmd = new CmdAddPointGraph (context ().mainWindow(),
82  document,
83  context ().mainWindow().selectedGraphCurve(),
84  posScreen,
85  ordinalGenerator.generateCurvePointOrdinal(document,
86  transformation,
87  posScreen,
88  activeCurve ()));
89  context().appendNewCmd(cmd);
90 }
91 
93 {
94  return "DigitizeStateCurve";
95 }
96 
98 {
99  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelDigitizeCurve";
100 
101  setCursor();
102 }
103 
105 {
106  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelSegments";
107 }
virtual void handleMousePress(QPointF posScreen)
Handle a mouse press that was intercepted earlier.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
virtual void handleMouseRelease(QPointF posScreen)
Handle a mouse release that was intercepted earlier.
virtual void handleMouseMove(QPointF posScreen)
Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mod...
CmdMediator & cmdMediator()
Provide CmdMediator for indirect access to the Document.
Transformation transformation() const
Return read-only copy of transformation.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
Create standard cross cursor, or custom cursor, according to settings.
Definition: CursorFactory.h:9
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
virtual void updateModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:61
DigitizeStateCurve(DigitizeStateContext &context)
Single constructor.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
virtual QString state() const
State name for debugging.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Affine transformation between screen and graph coordinates, based on digitized axis points...
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
void setCursor()
Update the cursor according to the current state.
Command for adding one graph point.
Storage of one imported image and the data attached to that image.
Definition: Document.h:29
virtual QCursor cursor() const
Returns the state-specific cursor shape.
virtual void handleCurveChange()
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
void appendNewCmd(QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Utility class for generating ordinal numbers.
Model for DlgSettingsSegments and CmdSettingsSegments.
virtual void handleKeyPress(Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
virtual void begin(DigitizeState previousState)
Method that is called at the exact moment a state is entered.
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.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.