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

Digitizing state for digitizing one axis point at a time. More...

#include <DigitizeStateAxis.h>

Inheritance diagram for DigitizeStateAxis:
Inheritance graph
Collaboration diagram for DigitizeStateAxis:
Collaboration graph

Public Member Functions

 DigitizeStateAxis (DigitizeStateContext &context)
 Single constructor.
virtual ~DigitizeStateAxis ()
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 digitizing one axis point at a time.

Once three axis points are defined, those points define an affine transformation from pixel screen coordinates to graph coordinates.

Definition at line 16 of file DigitizeStateAxis.h.

Constructor & Destructor Documentation

◆ DigitizeStateAxis()

DigitizeStateAxis::DigitizeStateAxis ( DigitizeStateContext & context)

Single constructor.

Definition at line 24 of file DigitizeStateAxis.cpp.

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

◆ ~DigitizeStateAxis()

DigitizeStateAxis::~DigitizeStateAxis ( )
virtual

Definition at line 29 of file DigitizeStateAxis.cpp.

30{
31}

Member Function Documentation

◆ activeCurve()

QString DigitizeStateAxis::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 33 of file DigitizeStateAxis.cpp.

34{
35 return AXIS_CURVE_NAME;
36}
const QString AXIS_CURVE_NAME

◆ begin()

void DigitizeStateAxis::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 38 of file DigitizeStateAxis.cpp.

40{
41 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::begin";
42
43 setCursor(cmdMediator);
44 context().setDragMode(QGraphicsView::NoDrag);
47}
log4cpp::Category * mainCat
Definition Logger.cpp:14
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
MainWindow & mainWindow()
Reference to the MainWindow, without const.
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 DigitizeStateAxis::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 49 of file DigitizeStateAxis.cpp.

51{
52 return false;
53}

◆ cursor()

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

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 74 of file DigitizeStateAxis.cpp.

75{
76 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::cursor";
77
78 CursorFactory cursorFactory;
79 QCursor cursor = cursorFactory.generate (cmdMediator->document().modelDigitizeCurve());
80
81 return cursor;
82}
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 DigitizeStateAxis::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 84 of file DigitizeStateAxis.cpp.

85{
86 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::end";
87}

◆ guidelinesAreSelectable()

bool DigitizeStateAxis::guidelinesAreSelectable ( ) const
virtual

Enable/disable guidelines according to state.

Implements DigitizeStateAbstractBase.

Definition at line 89 of file DigitizeStateAxis.cpp.

90{
91 return false;
92}

◆ handleContextMenuEventAxis()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 94 of file DigitizeStateAxis.cpp.

96{
97 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleContextMenuEventAxis "
98 << " point=" << pointIdentifier.toLatin1 ().data ();
99}

◆ handleContextMenuEventGraph()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 101 of file DigitizeStateAxis.cpp.

103{
104 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleContextMenuEventGraph "
105 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
106}

◆ handleCurveChange()

void DigitizeStateAxis::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 108 of file DigitizeStateAxis.cpp.

109{
110 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleCurveChange";
111}

◆ handleKeyPress()

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

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 113 of file DigitizeStateAxis.cpp.

116{
117 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleKeyPress"
118 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
119
120 handleKeyPressArrow (cmdMediator,
121 key,
122 atLeastOneSelectedItem);
123}
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 DigitizeStateAxis::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 125 of file DigitizeStateAxis.cpp.

127{
128// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::handleMouseMove";
129}

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 131 of file DigitizeStateAxis.cpp.

133{
134 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleMousePress";
135}

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 137 of file DigitizeStateAxis.cpp.

139{
140 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleMouseRelease";
141
142 if (context().mainWindow().transformIsDefined()) {
143
144 QMessageBox::warning (nullptr,
145 QObject::tr ("Engauge Digitizer"),
146 QObject::tr ("Three axis points have been defined, and no more are needed or allowed."));
147
148 } else {
149
150 createTemporaryPoint (cmdMediator,
151 posScreen);
152
153 // Ask user for coordinates
154 DlgEditPointAxis *dlg = new DlgEditPointAxis (context ().mainWindow (),
155 cmdMediator->document().modelCoords(),
156 cmdMediator->document().modelGeneral(),
157 context().mainWindow().modelMainWindow(),
158 context().mainWindow().transformation(),
159 cmdMediator->document().documentAxesPointsRequired());
160 int rtn = dlg->exec ();
161
162 bool isXOnly;
163 QPointF posGraph = dlg->posGraph (isXOnly);
164 delete dlg;
165
166 // Remove temporary point
168
169 if (rtn == QDialog::Accepted) {
170
171 // User wants to add this axis point, but let's perform sanity checks first
172
173 bool isError;
174 QString errorMessage;
175 int nextOrdinal = cmdMediator->document().nextOrdinalForCurve(AXIS_CURVE_NAME);
176
177 cmdMediator->document().checkAddPointAxis(posScreen,
178 posGraph,
179 isError,
180 errorMessage,
181 isXOnly);
182
183 if (isError) {
184
185 QMessageBox::warning (nullptr,
186 QObject::tr ("Engauge Digitizer"),
187 errorMessage);
188
189 } else {
190
191 // Create command to add point
192 Document &document = cmdMediator->document ();
193 QUndoCommand *cmd = new CmdAddPointAxis (context ().mainWindow(),
194 document,
195 posScreen,
196 posGraph,
197 nextOrdinal,
198 isXOnly);
199 context().appendNewCmd(cmdMediator,
200 cmd);
201 }
202 }
203 }
204}
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
QPointF posGraph(bool &isXOnly) const
Return the graph coordinates position specified by the user. Only applies if dialog was accepted.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition Document.cpp:735
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
Definition Document.cpp:791
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:707
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition Document.cpp:369
void checkAddPointAxis(const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage, bool isXOnly)
Check before calling addPointAxis. Also returns the next available ordinal number (to prevent clashes...
Definition Document.cpp:274
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
Definition Point.cpp:519

◆ state()

QString DigitizeStateAxis::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 206 of file DigitizeStateAxis.cpp.

207{
208 return "DigitizeStateAxis";
209}

◆ updateAfterPointAddition()

void DigitizeStateAxis::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 211 of file DigitizeStateAxis.cpp.

212{
213 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::updateAfterPointAddition";
214}

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 216 of file DigitizeStateAxis.cpp.

218{
219 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::updateModelDigitizeCurve";
220
221 setCursor(cmdMediator);
222}

◆ updateModelSegments()

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

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 224 of file DigitizeStateAxis.cpp.

225{
226 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::updateModelSegments";
227}

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