Engauge Digitizer 2
|
This class is a special case of the standard QGraphicsLineItem for guidelines, and serves as the base class for the guideline state classes. More...
#include <GuidelineAbstract.h>
Public Slots | |
void | slotHandleMoved (QPointF posScreen) |
Slot for signal from cloned deployed Guideline from handle Guideline. |
Signals | |
void | signalGuidelineDragged (QString, double, bool, GuidelineState) |
Signal indicating end of Guideline drag. | |
void | signalHandleMoved (QPointF) |
Signal for cloned deployed Guideline from handle Guideline. |
Public Member Functions | |
GuidelineAbstract (QGraphicsScene &scene) | |
Single constructor. | |
~GuidelineAbstract () | |
void | bindGuidelineVisibleToInvisible (GuidelineAbstract *guidelineVisible) |
Bind a newly-created visible Guideline to this Guideline, and make this one invisible. | |
virtual bool | getGraphicsItemAcceptHover () const =0 |
Return true if accepting hover events. | |
virtual bool | getGraphicsItemSelected () const =0 |
Wrapper for QGraphicsItem::isSelected. | |
virtual QGraphicsItem::GraphicsItemFlags | graphicsItemFlags () const =0 |
Wraps QGraphicsItem::flags. | |
void | handleActiveChange (bool active) |
DigitizeState change so active status may (or may not) be toggled. | |
void | handleGuidelineMode (bool visible, bool locked) |
User toggled Guideline visibility and/or locked mode. | |
void | handleHoverEnterEvent () |
Highlight this Guideline upon hover enter. | |
void | handleHoverLeaveEvent () |
Unset highlighting triggered by hover enter. | |
void | handleMouseMoveEvent (const QPointF &posScene) |
Forward movements to visible Guideline. | |
void | handleMousePressEvent (const QPointF &posScene) |
Forward press event to state machine. | |
void | handleMouseReleaseEvent (const QPointF &posScene) |
Cleanup after being dragged. | |
virtual QString | identifier () const =0 |
Unique identifier from QGraphicsItem. | |
QPointF | posCursorGraph () const |
Get position in graph coordinates. | |
virtual void | removeFromScene (QGraphicsScene *scene)=0 |
Make graphics item remove itself from the scene. | |
void | sacrificeHandleAndVisibleGuidelines (const QPointF &posScene, GuidelineState guidelineStateForReplacement) |
Replace visible and handle Guidelines after click and drag. | |
QGraphicsScene & | scene () |
GraphicsScene that owns this class. | |
virtual void | setGraphicsItemAcceptHoverEvents (bool accept)=0 |
Wrapper for QGraphicsItem::setAcceptHoverEvents. | |
virtual void | setGraphicsItemFlags (QGraphicsItem::GraphicsItemFlags flags)=0 |
Wrapper for QGraphicsItem::setFlags. | |
virtual void | setGraphicsItemLine (const QLineF &line)=0 |
Wrapper for QGraphicsLineItem::setLine. | |
virtual void | setGraphicsItemPen (const QColor &color, double lineWidth)=0 |
Wrapper for QGraphicsItem::setPen. | |
virtual void | setGraphicsItemVisible (bool visible)=0 |
Wrapper for QGraphicsItem::setVisible. | |
virtual void | setGraphicsItemZValue (double z)=0 |
Wrapper for QGraphicsItem::setZValue. | |
QString | stateDump () const |
Dump of state as a string for debugging only. Context like the QGraphicsItem flags is included. | |
QString | stateName () const |
Current state name for debugging and unit test only. | |
void | updateActive (bool active) |
Update active versus inactive state. | |
virtual void | updateColor ()=0 |
Force a color update. | |
virtual void | updateGeometry (double valueGraph)=0 |
Update the geometry so it passes through the specified coordinate value in graph coordinates. | |
virtual void | updateGeometry (const QPointF &posScreen)=0 |
Update the geometry so it passes through the specified point in screen coordinates. | |
void | updateWithLatestTransformation () |
Update given Transformation in GuidelineStateContext. This is called after a command has been executed. |
Protected Member Functions | |
GuidelineStateContext * | context () |
State machine context owned by this class. | |
const GuidelineStateContext * | context () const |
State machine context owned by this class as a const. | |
void | setContext (GuidelineStateContext *context) |
Create state machine after virtual methods of child classes have been defined. |
This class is a special case of the standard QGraphicsLineItem for guidelines, and serves as the base class for the guideline state classes.
This class has a state machine to handle state-specific behavior for hovering, dragging, and formatting.
General strategy: When a deployed Guideline is dragged, the following process occurs 1) The dragged Guideline becomes invisible, and its state changes to Handle 2) A new deployed Guideline is generated where the dragged Guideline was located 3) Dragging the Handle causes the same movements in the new deployed Guideline 4) The new deployed Guideline is continually resized to just fit the scene, and in the case of polar coordinates resized to go between origin and scene edge (theta) or curved elliptically (range) 5) At the end of the drag, the Handle and Visible Guidelines are sacrificed (=discarded) and a new Deployed Guideline is created. Since the new Deployed Guideline is off the stack, the new CmdGuidelineMove can work on it safely State transitions are diagrammed in the GuidelineStateContext class
This strategy works with the following constraints 1) Since it is not the dragged object that we modify in 3d above, we can resize and adjust the curvature of the visible new deployed Guideline as necessary 2) When a Guideline is clicked on, that is the one that is active during the cursor drag. It is not possible to move the focus to another QGraphicsItem 3) At the end of the drag, a new CmdGuidelineMove is created and its redo method is run before the Handle Guideline is off the stack. This would corrupt the movement if that CmdGuidelineMove tried to move the (on the stack) Handle, so we do not transition the Handle state back to the Deployed state. Instead, a third Guideline is created as the target of the new CmdGuidelineMove. The Handle and Visible Guidelines are sacrificed (=moved to Discard state or deleted).j
State names are defined as:
Guideline along the same drag trajectory
There are two derived classes:
An attempt to draw lines with just QGraphicsEllipseItem, for simplicity, failed with the result having sinusoidally changing line width.
Definition at line 68 of file GuidelineAbstract.h.
GuidelineAbstract::GuidelineAbstract | ( | QGraphicsScene & | scene | ) |
Single constructor.
Definition at line 28 of file GuidelineAbstract.cpp.
GuidelineAbstract::~GuidelineAbstract | ( | ) |
Definition at line 35 of file GuidelineAbstract.cpp.
void GuidelineAbstract::bindGuidelineVisibleToInvisible | ( | GuidelineAbstract * | guidelineVisible | ) |
Bind a newly-created visible Guideline to this Guideline, and make this one invisible.
Definition at line 40 of file GuidelineAbstract.cpp.
|
protected |
State machine context owned by this class.
Definition at line 50 of file GuidelineAbstract.cpp.
|
protected |
State machine context owned by this class as a const.
Definition at line 55 of file GuidelineAbstract.cpp.
|
pure virtual |
Return true if accepting hover events.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wrapper for QGraphicsItem::isSelected.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wraps QGraphicsItem::flags.
Implemented in GuidelineEllipse, and GuidelineLine.
void GuidelineAbstract::handleActiveChange | ( | bool | active | ) |
DigitizeState change so active status may (or may not) be toggled.
Definition at line 60 of file GuidelineAbstract.cpp.
void GuidelineAbstract::handleGuidelineMode | ( | bool | visible, |
bool | locked ) |
User toggled Guideline visibility and/or locked mode.
Definition at line 65 of file GuidelineAbstract.cpp.
void GuidelineAbstract::handleHoverEnterEvent | ( | ) |
Highlight this Guideline upon hover enter.
Definition at line 72 of file GuidelineAbstract.cpp.
void GuidelineAbstract::handleHoverLeaveEvent | ( | ) |
Unset highlighting triggered by hover enter.
Definition at line 77 of file GuidelineAbstract.cpp.
void GuidelineAbstract::handleMouseMoveEvent | ( | const QPointF & | posScene | ) |
Forward movements to visible Guideline.
Definition at line 82 of file GuidelineAbstract.cpp.
void GuidelineAbstract::handleMousePressEvent | ( | const QPointF & | posScene | ) |
Forward press event to state machine.
Definition at line 94 of file GuidelineAbstract.cpp.
void GuidelineAbstract::handleMouseReleaseEvent | ( | const QPointF & | posScene | ) |
Cleanup after being dragged.
Definition at line 101 of file GuidelineAbstract.cpp.
|
pure virtual |
Unique identifier from QGraphicsItem.
Implemented in GuidelineEllipse, and GuidelineLine.
QPointF GuidelineAbstract::posCursorGraph | ( | ) | const |
Get position in graph coordinates.
Definition at line 144 of file GuidelineAbstract.cpp.
|
pure virtual |
Make graphics item remove itself from the scene.
Implemented in GuidelineEllipse, and GuidelineLine.
void GuidelineAbstract::sacrificeHandleAndVisibleGuidelines | ( | const QPointF & | posScene, |
GuidelineState | guidelineStateForReplacement ) |
Replace visible and handle Guidelines after click and drag.
Definition at line 108 of file GuidelineAbstract.cpp.
QGraphicsScene & GuidelineAbstract::scene | ( | ) |
GraphicsScene that owns this class.
Definition at line 139 of file GuidelineAbstract.cpp.
|
protected |
Create state machine after virtual methods of child classes have been defined.
Definition at line 149 of file GuidelineAbstract.cpp.
|
pure virtual |
Wrapper for QGraphicsItem::setAcceptHoverEvents.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wrapper for QGraphicsItem::setFlags.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wrapper for QGraphicsLineItem::setLine.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wrapper for QGraphicsItem::setPen.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wrapper for QGraphicsItem::setVisible.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Wrapper for QGraphicsItem::setZValue.
Implemented in GuidelineEllipse, and GuidelineLine.
|
signal |
Signal indicating end of Guideline drag.
|
signal |
Signal for cloned deployed Guideline from handle Guideline.
|
slot |
Slot for signal from cloned deployed Guideline from handle Guideline.
Definition at line 154 of file GuidelineAbstract.cpp.
QString GuidelineAbstract::stateDump | ( | ) | const |
Dump of state as a string for debugging only. Context like the QGraphicsItem flags is included.
Definition at line 160 of file GuidelineAbstract.cpp.
QString GuidelineAbstract::stateName | ( | ) | const |
Current state name for debugging and unit test only.
Definition at line 178 of file GuidelineAbstract.cpp.
void GuidelineAbstract::updateActive | ( | bool | active | ) |
Update active versus inactive state.
Inactive state applies when DigitizeState is not DigitizeStateSelect, since the Guidelines can help with moving points around. This method is called on DigitizeState transitions. Active is not the same as visibility. When inactive, guidelines ignore hover and click events
|
pure virtual |
Force a color update.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Update the geometry so it passes through the specified point in screen coordinates.
Implemented in GuidelineEllipse, and GuidelineLine.
|
pure virtual |
Update the geometry so it passes through the specified coordinate value in graph coordinates.
Implemented in GuidelineEllipse, and GuidelineLine.
void GuidelineAbstract::updateWithLatestTransformation | ( | ) |
Update given Transformation in GuidelineStateContext. This is called after a command has been executed.
Definition at line 183 of file GuidelineAbstract.cpp.