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