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

Digitizing state for creating Curve Points, one at a time. More...

#include <DigitizeStateCurve.h>

Inheritance diagram for DigitizeStateCurve:
Inheritance graph
Collaboration diagram for DigitizeStateCurve:
Collaboration graph

Public Member Functions

 DigitizeStateCurve (DigitizeStateContext &context)
 Single constructor.
virtual ~DigitizeStateCurve ()
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.
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 &modelDigitizeCurve)
 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 Curve Points, one at a time.

Definition at line 15 of file DigitizeStateCurve.h.

Constructor & Destructor Documentation

◆ DigitizeStateCurve()

DigitizeStateCurve::DigitizeStateCurve ( DigitizeStateContext & context)

Single constructor.

Definition at line 21 of file DigitizeStateCurve.cpp.

21 :
23{
24}
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...

◆ ~DigitizeStateCurve()

DigitizeStateCurve::~DigitizeStateCurve ( )
virtual

Definition at line 26 of file DigitizeStateCurve.cpp.

27{
28}

Member Function Documentation

◆ activeCurve()

QString DigitizeStateCurve::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 30 of file DigitizeStateCurve.cpp.

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

◆ begin()

void DigitizeStateCurve::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 35 of file DigitizeStateCurve.cpp.

37{
38 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::begin";
39
40 setCursor(cmdMediator);
41 context().setDragMode(QGraphicsView::NoDrag);
44}
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.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
void handleGuidelinesActiveChange(bool active)
Handle Guidelines active status toggle.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ canPaste()

bool DigitizeStateCurve::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 46 of file DigitizeStateCurve.cpp.

48{
49 return canPasteProtected (transformation,
50 size);
51}
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.

◆ cursor()

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

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 53 of file DigitizeStateCurve.cpp.

54{
55 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::cursor";
56
57 CursorFactory cursorFactory;
58 QCursor cursor = cursorFactory.generate (cmdMediator->document().modelDigitizeCurve());
59
60 return cursor;
61}
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Definition Document.cpp:721
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ end()

void DigitizeStateCurve::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 63 of file DigitizeStateCurve.cpp.

64{
65 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::end";
66}

◆ guidelinesAreSelectable()

bool DigitizeStateCurve::guidelinesAreSelectable ( ) const
virtual

Enable/disable guidelines according to state.

Implements DigitizeStateAbstractBase.

Definition at line 68 of file DigitizeStateCurve.cpp.

69{
70 return false;
71}

◆ handleContextMenuEventAxis()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 73 of file DigitizeStateCurve.cpp.

75{
76 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleContextMenuEventAxis "
77 << " point=" << pointIdentifier.toLatin1 ().data ();
78}

◆ handleContextMenuEventGraph()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 80 of file DigitizeStateCurve.cpp.

82{
83 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve ::handleContextMenuEventGraph "
84 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
85}

◆ handleCurveChange()

void DigitizeStateCurve::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 87 of file DigitizeStateCurve.cpp.

88{
89 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleCurveChange";
90}

◆ handleKeyPress()

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

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 92 of file DigitizeStateCurve.cpp.

95{
96 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleKeyPress"
97 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
98
99 handleKeyPressArrow (cmdMediator,
100 key,
101 atLeastOneSelectedItem);
102}
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.

◆ handleMouseMove()

void DigitizeStateCurve::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 104 of file DigitizeStateCurve.cpp.

106{
107// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::handleMouseMove";
108}

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 110 of file DigitizeStateCurve.cpp.

112{
113 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMousePress";
114}

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 116 of file DigitizeStateCurve.cpp.

118{
119 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMouseRelease";
120
121 // Create command to add point
122 OrdinalGenerator ordinalGenerator;
123 Document &document = cmdMediator->document ();
124 const Transformation &transformation = context ().mainWindow ().transformation();
125 QUndoCommand *cmd = new CmdAddPointGraph (context ().mainWindow(),
126 document,
127 context ().mainWindow().selectedGraphCurve(),
128 posScreen,
129 ordinalGenerator.generateCurvePointOrdinal(document,
130 transformation,
131 posScreen,
132 activeCurve ()));
133 context().appendNewCmd(cmdMediator,
134 cmd);
135}
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Transformation transformation() const
Return read-only copy of transformation.
double generateCurvePointOrdinal(const Document &document, const Transformation &transformation, const QPointF &posScreen, const QString &curveName)
Select ordinal so new point curve passes smoothly through existing points.

◆ state()

QString DigitizeStateCurve::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 137 of file DigitizeStateCurve.cpp.

138{
139 return "DigitizeStateCurve";
140}

◆ updateAfterPointAddition()

void DigitizeStateCurve::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 142 of file DigitizeStateCurve.cpp.

143{
144 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateAfterPointAddition";
145}

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 147 of file DigitizeStateCurve.cpp.

149{
150 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelDigitizeCurve";
151
152 setCursor(cmdMediator);
153}

◆ updateModelSegments()

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

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 155 of file DigitizeStateCurve.cpp.

156{
157 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelSegments";
158}

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