Engauge Digitizer 2
Loading...
Searching...
No Matches
DigitizeStateGuideline Class Reference

Digitizing state for creating, moving and removing guidelines. More...

#include <DigitizeStateGuideline.h>

Inheritance diagram for DigitizeStateGuideline:
Inheritance graph
Collaboration diagram for DigitizeStateGuideline:
Collaboration graph

Public Member Functions

 DigitizeStateGuideline (DigitizeStateContext &context)
 Single constructor.
virtual ~DigitizeStateGuideline ()
virtual QString activeCurve () const
 Name of the active Curve. This can include AXIS_CURVE_NAME.
virtual void begin (CmdMediator *cmdMediator, DigitizeState previousState)
 Method that is called at the exact moment a state is entered.
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 current state.
void createGuidelineCommand (bool selectedXT, double valueSelected)
 Create command to add Guideline for CentipedeStateContext.
virtual QCursor cursor (CmdMediator *cmdMediator) const
 Returns the state-specific cursor shape.
virtual void end ()
 Method that is called at the exact moment a state is exited. Typically called just before begin for the next state.
virtual bool guidelinesAreSelectable () const
 Enable/disable guidelines according to state.
virtual void handleContextMenuEventAxis (CmdMediator *cmdMediator, const QString &pointIdentifier)
 Handle a right click, on an axis point, 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 handleCurveChange (CmdMediator *cmdMediator)
 Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Segments.
virtual void handleKeyPress (CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
 Handle a key press that was intercepted earlier.
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 mode is worthwhile.
virtual void handleMousePress (CmdMediator *cmdMediator, QPointF posScreen)
 Handle a mouse press that was intercepted earlier.
virtual void handleMouseRelease (CmdMediator *cmdMediator, QPointF posScreen)
 Handle a mouse release that was intercepted earlier.
virtual QString state () const
 State name for debugging.
virtual void updateAfterPointAddition ()
 Update graphics attributes after possible new points. This is useful for highlight opacity.
virtual void updateModelDigitizeCurve (CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &curve)
 Update the digitize curve settings.
virtual void updateModelSegments (const DocumentModelSegments &modelSegments)
 Update the segments given the new settings.
Public Member Functions inherited from DigitizeStateAbstractBase
 DigitizeStateAbstractBase (DigitizeStateContext &context)
 Single constructor.
virtual ~DigitizeStateAbstractBase ()
DigitizeStateContextcontext ()
 Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses, without const.
const DigitizeStateContextcontext () const
 Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses, without const.
void setCursor (CmdMediator *cmdMediator)
 Update the cursor according to the current state.

Additional Inherited Members

Protected Member Functions inherited from DigitizeStateAbstractBase
bool canPasteProtected (const Transformation &transformation, const QSize &viewSize) const
 Protected version of canPaste method. Some, but not all, leaf classes use this method.
virtual void handleKeyPressArrow (CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
 If the key is an arrow (left, right, up, down) then move currently selected items.
QString moveTextDown () const
 Display text for down arrow.
QString moveTextLeft () const
 Display text for left arrow.
QString moveTextRight () const
 Display text for right arrow.
QString moveTextUp () const
 Display text for up arrow.

Detailed Description

Digitizing state for creating, moving and removing guidelines.

A challenge for creating guidelines was reconciling the multistep nature of creating a guideline (click, move, move, ..., move done) with control-z. Initially the control-z was grabbed by the command stack which would remove the previous command while leaving the partially-complete guideline. Very confusing. Three options were studied for reconciling the command stack and the guideline steps:

  • Create a new command for each operation (mouse press, mouse move, and key press to catch Escape key). Then use QUndoGroup to lump multiple commands into one big command. This added multiple command and much complexity
  • Use QUndoStack's beginMacro and endMacro which had same issues as first option
  • Turn off QUndoStack and just have single stack command when finished. This option was selected since the complexity is kept within DigitizeStateGuideline. This calls QUndoStack::setActive to enable/disable the command stack

Definition at line 34 of file DigitizeStateGuideline.h.

Constructor & Destructor Documentation

◆ DigitizeStateGuideline()

DigitizeStateGuideline::DigitizeStateGuideline ( DigitizeStateContext & context)

Single constructor.

Definition at line 37 of file DigitizeStateGuideline.cpp.

37 :
39 m_context (new CentipedeStateContext (*this))
40{
41}
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...

◆ ~DigitizeStateGuideline()

DigitizeStateGuideline::~DigitizeStateGuideline ( )
virtual

Definition at line 43 of file DigitizeStateGuideline.cpp.

44{
45 delete m_context;
46}

Member Function Documentation

◆ activeCurve()

QString DigitizeStateGuideline::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 48 of file DigitizeStateGuideline.cpp.

49{
51}
MainWindow & mainWindow()
Reference to the MainWindow, without const.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.

◆ begin()

void DigitizeStateGuideline::begin ( CmdMediator * cmdMediator,
DigitizeState previousState )
virtual

Method that is called at the exact moment a state is entered.

Typically called just after end for the previous state. The previousState value is used by DigitizeStateColorPicker to return to the previous state

Implements DigitizeStateAbstractBase.

Definition at line 53 of file DigitizeStateGuideline.cpp.

55{
56 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateGuideline::beginn";
57
58 setCursor(cmdMediator);
59 context().setDragMode(QGraphicsView::NoDrag);
60 lockNonGuidelinesAndUnlockGuidelines (true);
61}
log4cpp::Category * mainCat
Definition Logger.cpp:14
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ canPaste()

bool DigitizeStateGuideline::canPaste ( const Transformation & transformation,
const QSize & viewSize ) const
virtual

Return true if there is good data in the clipboard for pasting, and that is compatible with the current state.

Implements DigitizeStateAbstractBase.

Definition at line 63 of file DigitizeStateGuideline.cpp.

65{
66 return false;
67}

◆ createGuidelineCommand()

void DigitizeStateGuideline::createGuidelineCommand ( bool selectedXT,
double valueSelected )

Create command to add Guideline for CentipedeStateContext.

Definition at line 69 of file DigitizeStateGuideline.cpp.

71{
72 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateGuideline::createGuidelineCommand";
73
74 CmdAbstract *cmd = nullptr;
75 if (selectedXT) {
76 cmd = new CmdGuidelineAddXT (context().mainWindow(),
77 context().mainWindow().cmdMediator()->document(),
78 valueSelected);
79 } else {
80 cmd = new CmdGuidelineAddYR (context().mainWindow(),
81 context().mainWindow().cmdMediator()->document(),
82 valueSelected);
83 }
84
85 context().appendNewCmd (context().mainWindow().cmdMediator(),
86 cmd);
87}
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ cursor()

QCursor DigitizeStateGuideline::cursor ( CmdMediator * cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 89 of file DigitizeStateGuideline.cpp.

90{
91 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateGuideline::cursor";
92
93 return QCursor (Qt::ArrowCursor);
94}

◆ end()

void DigitizeStateGuideline::end ( )
virtual

Method that is called at the exact moment a state is exited. Typically called just before begin for the next state.

Implements DigitizeStateAbstractBase.

Definition at line 96 of file DigitizeStateGuideline.cpp.

97{
98 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateGuideline::end";
99
100 lockNonGuidelinesAndUnlockGuidelines (false);
101}

◆ guidelinesAreSelectable()

bool DigitizeStateGuideline::guidelinesAreSelectable ( ) const
virtual

Enable/disable guidelines according to state.

Implements DigitizeStateAbstractBase.

Definition at line 103 of file DigitizeStateGuideline.cpp.

104{
105 return false;
106}

◆ handleContextMenuEventAxis()

void DigitizeStateGuideline::handleContextMenuEventAxis ( CmdMediator * cmdMediator,
const QString & pointIdentifier )
virtual

Handle a right click, on an axis point, that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 108 of file DigitizeStateGuideline.cpp.

110{
111 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateGuideline::handleContextMenuEventAxis "
112 << " point=" << pointIdentifier.toLatin1 ().data ();
113}

◆ handleContextMenuEventGraph()

void DigitizeStateGuideline::handleContextMenuEventGraph ( CmdMediator * cmdMediator,
const QStringList & pointIdentifiers )
virtual

Handle a right click, on a graph point, that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 115 of file DigitizeStateGuideline.cpp.

117{
118 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateGuideline ::handleContextMenuEventGraph "
119 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
120}

◆ handleCurveChange()

void DigitizeStateGuideline::handleCurveChange ( CmdMediator * cmdMediator)
virtual

Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Segments.

Implements DigitizeStateAbstractBase.

Definition at line 122 of file DigitizeStateGuideline.cpp.

123{
124}

◆ handleKeyPress()

void DigitizeStateGuideline::handleKeyPress ( CmdMediator * cmdMediator,
Qt::Key key,
bool atLeastOneSelectedItem )
virtual

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 126 of file DigitizeStateGuideline.cpp.

129{
130 m_context->handleKeyPress (key,
131 atLeastOneSelectedItem);
132}

◆ handleMouseMove()

void DigitizeStateGuideline::handleMouseMove ( CmdMediator * cmdMediator,
QPointF posScreen )
virtual

Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mode is worthwhile.

Implements DigitizeStateAbstractBase.

Definition at line 134 of file DigitizeStateGuideline.cpp.

136{
137 m_context->handleMouseMove (posScreen);
138}

◆ handleMousePress()

void DigitizeStateGuideline::handleMousePress ( CmdMediator * cmdMediator,
QPointF pos )
virtual

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 140 of file DigitizeStateGuideline.cpp.

142{
143 m_context->handleMousePress (&context().mainWindow ().scene (),
144 context().mainWindow ().transformation (),
145 cmdMediator->document ().modelGuideline (),
146 cmdMediator->document ().modelCoords (),
147 posScreen,
148 hitTestForGraphics (posScreen));
149}
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
DocumentModelGuideline modelGuideline() const
Get method for DocumentModelGuideline.
Definition Document.cpp:756
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:707

◆ handleMouseRelease()

void DigitizeStateGuideline::handleMouseRelease ( CmdMediator * cmdMediator,
QPointF pos )
virtual

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 151 of file DigitizeStateGuideline.cpp.

153{
154 m_context->handleMouseRelease (posScreen);
155}

◆ state()

QString DigitizeStateGuideline::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 224 of file DigitizeStateGuideline.cpp.

225{
226 return "DigitizeStateGuideline";
227}

◆ updateAfterPointAddition()

void DigitizeStateGuideline::updateAfterPointAddition ( )
virtual

Update graphics attributes after possible new points. This is useful for highlight opacity.

Implements DigitizeStateAbstractBase.

Definition at line 229 of file DigitizeStateGuideline.cpp.

230{
231}

◆ updateModelDigitizeCurve()

void DigitizeStateGuideline::updateModelDigitizeCurve ( CmdMediator * cmdMediator,
const DocumentModelDigitizeCurve & modelDigitizeCurve )
virtual

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 233 of file DigitizeStateGuideline.cpp.

235{
236}

◆ updateModelSegments()

void DigitizeStateGuideline::updateModelSegments ( const DocumentModelSegments & modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 238 of file DigitizeStateGuideline.cpp.

239{
240}

The documentation for this class was generated from the following files: