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 
14 {
15 public:
18  virtual ~DigitizeStateSelect();
19 
20  virtual QString activeCurve () const;
21  virtual void begin(CmdMediator *cmdMediator,
22  DigitizeState previousState);
23  virtual QCursor cursor (CmdMediator *cmdMediator) const;
24  virtual void end();
25  virtual void handleCurveChange(CmdMediator *cmdMediator);
26  virtual void handleKeyPress (CmdMediator *cmdMediator,
27  Qt::Key key,
28  bool atLeastOneSelectedItem);
29  virtual void handleMouseMove (CmdMediator *cmdMediator,
30  QPointF posScreen);
31  virtual void handleMousePress (CmdMediator *cmdMediator,
32  QPointF posScreen);
33  virtual void handleMouseRelease (CmdMediator *cmdMediator,
34  QPointF posScreen);
35  virtual QString state() const;
36  virtual void updateModelDigitizeCurve (CmdMediator *cmdMediator,
37  const DocumentModelDigitizeCurve &modelDigitizeCurve);
38  virtual void updateModelSegments(const DocumentModelSegments &modelSegments);
39 
40 private:
42 
43  void keyPressArrow (CmdMediator *cmdMediator,
44  Qt::Key key);
45  QString moveTextFromDeltaScreen (const QPointF &deltaScreen);
46  void setCursorForPoints();
47  void unsetCursorForPoints();
48  double zoomedToUnzoomedScreenX () const;
49  double zoomedToUnzoomedScreenY () const;
50 
51  // Click and drag cases are:
52  // 1) rubber band selection
53  // Result = selection of any items inside the rubber band but no movement
54  // 2) selection and moving with no initially selected items.
55  // Result = selection and movement of item under cursor
56  // 3) selection and moving with only item under cursor initially selected
57  // Result = same result as case #2
58  // 4) selection and moving with item under cursor not initially selected but other item(s) selected
59  // Result = other items get unselected so the result is the same as case #2 but with some items now unselected
60  // 5) selection and moving with item under cursor initially selected along with other selected items
61  // Result = all selected items get moved
62  // Originally, determining if any object was under the cursor during mousePressEvent was done with various hit tests, but
63  // none were 100% consistent with the internal hit test done by the QGraphicsView. The solution was to simply:
64  // 1) Mark all items as unmoved when the mousePressEvent occurs
65  // 2) Mark items that undergo QGraphicsItem::ItemScaleHasChanged as having moved
66  // 3) Harvest the results when the mouseReleaseEvent occurs
67  // All moved items then have the currentCursorPosition - m_movingStart translation applied to them
68  QPointF m_movingStart;
69 };
70 
71 #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 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 handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
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...
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
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...
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 QString state() const
State name for debugging.
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.