Engauge Digitizer  2
DigitizeStateSelect.h
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 #ifndef DIGITIZE_STATE_SELECT_H
8 #define DIGITIZE_STATE_SELECT_H
9 
11 
20 {
21 public:
24  virtual ~DigitizeStateSelect();
25 
26  virtual QString activeCurve () const;
27  virtual void begin(CmdMediator *cmdMediator,
28  DigitizeState previousState);
29  virtual bool canPaste (const Transformation &transformation,
30  const QSize &viewSize) const;
31  virtual QCursor cursor (CmdMediator *cmdMediator) const;
32  virtual void end();
33  virtual void handleContextMenuEventAxis (CmdMediator *cmdMediator,
34  const QString &pointIdentifier);
35  virtual void handleContextMenuEventGraph (CmdMediator *cmdMediator,
36  const QStringList &pointIdentifiers);
37  virtual void handleCurveChange(CmdMediator *cmdMediator);
38  virtual void handleKeyPress (CmdMediator *cmdMediator,
39  Qt::Key key,
40  bool atLeastOneSelectedItem);
41  virtual void handleMouseMove (CmdMediator *cmdMediator,
42  QPointF posScreen);
43  virtual void handleMousePress (CmdMediator *cmdMediator,
44  QPointF posScreen);
45  virtual void handleMouseRelease (CmdMediator *cmdMediator,
46  QPointF posScreen);
47  virtual QString state() const;
48  virtual void updateAfterPointAddition ();
49  virtual void updateModelDigitizeCurve (CmdMediator *cmdMediator,
50  const DocumentModelDigitizeCurve &modelDigitizeCurve);
51  virtual void updateModelSegments(const DocumentModelSegments &modelSegments);
52 
53 private:
55 
56  void addHoverHighlighting();
57  void handleContextMenuEventAxis2 (CmdMediator *cmdMediator);
58  void handleContextMenuEventAxis34 (CmdMediator *cmdMediator,
59  const QString &pointIdentifier);
60  void keyPressArrow (CmdMediator *cmdMediator,
61  Qt::Key key);
62  QString moveTextFromDeltaScreen (const QPointF &deltaScreen);
63  void removeHoverHighlighting();
64  double scaleBarLength (CmdMediator *cmdMediator) const;
65  QString scaleBarPointIdentifier (CmdMediator *cmdMediator) const;
66  void setHoverHighlighting(const MainWindowModel &modelMainWindow);
67  void showCoordinatesIfSinglePointIsSelected ();
68  double zoomedToUnzoomedScreenX () const;
69  double zoomedToUnzoomedScreenY () const;
70 
71  // Click and drag cases are:
72  // 1) rubber band selection
73  // Result = selection of any items inside the rubber band but no movement
74  // 2) selection and moving with no initially selected items.
75  // Result = selection and movement of item under cursor
76  // 3) selection and moving with only item under cursor initially selected
77  // Result = same result as case #2
78  // 4) selection and moving with item under cursor not initially selected but other item(s) selected
79  // Result = other items get unselected so the result is the same as case #2 but with some items now unselected
80  // 5) selection and moving with item under cursor initially selected along with other selected items
81  // Result = all selected items get moved
82  // Originally, determining if any object was under the cursor during mousePressEvent was done with various hit tests, but
83  // none were 100% consistent with the internal hit test done by the QGraphicsView. The solution was to simply:
84  // 1) Mark all items as unmoved when the mousePressEvent occurs
85  // 2) Mark items that undergo QGraphicsItem::ItemScaleHasChanged as having moved
86  // 3) Harvest the results when the mouseReleaseEvent occurs
87  // All moved items then have the currentCursorPosition - m_movingStart translation applied to them
88  QPointF m_movingStart;
89 };
90 
91 #endif // DIGITIZE_STATE_SELECT_H
DigitizeStateSelect::~DigitizeStateSelect
virtual ~DigitizeStateSelect()
Definition: DigitizeStateSelect.cpp:44
DigitizeStateContext
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
Definition: DigitizeStateContext.h:26
DigitizeStateAbstractBase::context
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
Definition: DigitizeStateAbstractBase.cpp:41
DigitizeStateSelect::end
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
Definition: DigitizeStateSelect.cpp:93
DigitizeStateSelect::handleMouseRelease
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
Definition: DigitizeStateSelect.cpp:345
DigitizeStateSelect::begin
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
Definition: DigitizeStateSelect.cpp:68
DigitizeStateSelect::handleContextMenuEventGraph
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
Definition: DigitizeStateSelect.cpp:237
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition: Transformation.h:30
DigitizeStateSelect::handleContextMenuEventAxis
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
Definition: DigitizeStateSelect.cpp:100
DigitizeStateSelect::handleMousePress
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
Definition: DigitizeStateSelect.cpp:334
DigitizeStateSelect::handleCurveChange
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
Definition: DigitizeStateSelect.cpp:302
DigitizeStateSelect::updateAfterPointAddition
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
Definition: DigitizeStateSelect.cpp:528
DigitizeStateAbstractBase.h
MainWindowModel
Model for DlgSettingsMainWindow.
Definition: MainWindowModel.h:29
DigitizeStateSelect::cursor
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
Definition: DigitizeStateSelect.cpp:86
DigitizeStateSelect::canPaste
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...
Definition: DigitizeStateSelect.cpp:80
DigitizeStateSelect
Digitizing state for selecting one or more Points in the Document.
Definition: DigitizeStateSelect.h:18
DigitizeStateSelect::state
virtual QString state() const
State name for debugging.
Definition: DigitizeStateSelect.cpp:523
DigitizeState
DigitizeState
Set of possible states of Digitize toolbar.
Definition: DigitizeStateAbstractBase.h:23
DigitizeStateSelect::handleKeyPress
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
Definition: DigitizeStateSelect.cpp:307
DigitizeStateSelect::updateModelSegments
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
Definition: DigitizeStateSelect.cpp:541
DocumentModelSegments
Model for DlgSettingsSegments and CmdSettingsSegments.
Definition: DocumentModelSegments.h:16
DocumentModelDigitizeCurve
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Definition: DocumentModelDigitizeCurve.h:17
DigitizeStateSelect::updateModelDigitizeCurve
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
Definition: DigitizeStateSelect.cpp:535
CmdMediator
Command queue stack.
Definition: CmdMediator.h:22
DigitizeStateSelect::activeCurve
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Definition: DigitizeStateSelect.cpp:48
DigitizeStateSelect::handleMouseMove
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...
Definition: DigitizeStateSelect.cpp:328
DigitizeStateAbstractBase
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
Definition: DigitizeStateAbstractBase.h:36