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

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

#include <DigitizeStatePointMatch.h>

Inheritance diagram for DigitizeStatePointMatch:
Inheritance graph
Collaboration diagram for DigitizeStatePointMatch:
Collaboration graph

Public Member Functions

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

Definition at line 22 of file DigitizeStatePointMatch.h.

Constructor & Destructor Documentation

◆ DigitizeStatePointMatch()

DigitizeStatePointMatch::DigitizeStatePointMatch ( DigitizeStateContext & context)

Single constructor.

Definition at line 36 of file DigitizeStatePointMatch.cpp.

36 :
38 m_outline (nullptr),
39 m_candidatePoint (nullptr)
40{
41}
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...

◆ ~DigitizeStatePointMatch()

DigitizeStatePointMatch::~DigitizeStatePointMatch ( )
virtual

Definition at line 43 of file DigitizeStatePointMatch.cpp.

44{
45}

Member Function Documentation

◆ activeCurve()

QString DigitizeStatePointMatch::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 47 of file DigitizeStatePointMatch.cpp.

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

◆ begin()

void DigitizeStatePointMatch::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 52 of file DigitizeStatePointMatch.cpp.

54{
55 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::begin";
56
57 setCursor(cmdMediator);
58 context().setDragMode(QGraphicsView::NoDrag);
61
62 // Add outline that will move with the cursor
63 m_outline = new QGraphicsEllipseItem ();
64 context().mainWindow().scene().addItem (m_outline);
65 m_outline->setPen (QPen (Qt::black));
66 m_outline->setVisible (true);
67 m_outline->setZValue (Z_VALUE);
68}
const double Z_VALUE
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.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ canPaste()

bool DigitizeStatePointMatch::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 70 of file DigitizeStatePointMatch.cpp.

72{
73 return canPasteProtected (transformation,
74 viewSize);
75}
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 DigitizeStatePointMatch::cursor ( CmdMediator * cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 124 of file DigitizeStatePointMatch.cpp.

125{
126 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::cursor";
127
128 return QCursor (Qt::ArrowCursor);
129}
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ end()

void DigitizeStatePointMatch::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 131 of file DigitizeStatePointMatch.cpp.

132{
133 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::end";
134
135 // Remove candidate point which may or may not exist at this point
137
138 // Remove outline before leaving state
139 ENGAUGE_CHECK_PTR (m_outline);
140 context().mainWindow().scene().removeItem (m_outline);
141 m_outline = nullptr;
142}
#define ENGAUGE_CHECK_PTR(ptr)
Drop in replacement for Q_CHECK_PTR.
void removeTemporaryPointIfExists()
Remove temporary point if it exists.

◆ guidelinesAreSelectable()

bool DigitizeStatePointMatch::guidelinesAreSelectable ( ) const
virtual

Enable/disable guidelines according to state.

Implements DigitizeStateAbstractBase.

Definition at line 183 of file DigitizeStatePointMatch.cpp.

184{
185 return false;
186}

◆ handleContextMenuEventAxis()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 188 of file DigitizeStatePointMatch.cpp.

190{
191 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleContextMenuEventAxis "
192 << " point=" << pointIdentifier.toLatin1 ().data ();
193}

◆ handleContextMenuEventGraph()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 195 of file DigitizeStatePointMatch.cpp.

197{
198 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch ::handleContextMenuEventGraph "
199 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
200}

◆ handleCurveChange()

void DigitizeStatePointMatch::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 202 of file DigitizeStatePointMatch.cpp.

203{
204 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleCurveChange";
205}

◆ handleKeyPress()

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

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 207 of file DigitizeStatePointMatch.cpp.

210{
211 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleKeyPress"
212 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
213
214 // Qt::Key_Right is reserved by this state for adding points so we cannot also call
215 // handleKeyPressArrow (which also uses Qt::Key_Right for a different purpose). So
216 // moving point match points around with the direction arrows is not possible
217
218 // The selected key button has to be compatible with GraphicsView::keyPressEvent
219 if (key == Qt::Key_Right) {
220
221 promoteCandidatePointToPermanentPoint (cmdMediator); // This removes the current temporary point
222
223 popCandidatePoint(cmdMediator); // This creates a new temporary point
224
225 }
226}

◆ handleMouseMove()

void DigitizeStatePointMatch::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 228 of file DigitizeStatePointMatch.cpp.

230{
231// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::handleMouseMove";
232
233 const DocumentModelPointMatch &modelPointMatch = cmdMediator->document().modelPointMatch();
234
235 m_outline->setRect (posScreen.x() - modelPointMatch.maxPointSize() / 2.0,
236 posScreen.y() - modelPointMatch.maxPointSize() / 2.0,
237 modelPointMatch.maxPointSize(),
238 modelPointMatch.maxPointSize());
239
240 const QImage &img = context().mainWindow().imageFiltered();
241 int radiusLimit = cmdMediator->document().modelGeneral().cursorSize();
242 bool pixelShouldBeOn = pixelIsOnInImage (img,
243 qFloor (posScreen.x()),
244 qFloor (posScreen.y()),
245 radiusLimit);
246
247 QColor penColorIs = m_outline->pen().color();
248 bool pixelIsOn = (penColorIs.red () != penColorIs.green()); // Considered on if not gray scale
249 if (pixelShouldBeOn != pixelIsOn) {
250 QColor penColorShouldBe (pixelShouldBeOn ? Qt::green : Qt::black);
251 m_outline->setPen (QPen (penColorShouldBe));
252 }
253}
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
int cursorSize() const
Get method for effective cursor size.
double maxPointSize() const
Get method for max point size.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition Document.cpp:735
DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
Definition Document.cpp:770
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 255 of file DigitizeStatePointMatch.cpp.

257{
258 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleMousePress";
259}

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 261 of file DigitizeStatePointMatch.cpp.

263{
264 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleMouseRelease";
265
266 createPermanentPoint (cmdMediator,
267 posScreen);
268
269 findPointsAndShowFirstCandidate (cmdMediator,
270 posScreen);
271}

◆ state()

QString DigitizeStatePointMatch::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 372 of file DigitizeStatePointMatch.cpp.

373{
374 return "DigitizeStatePointMatch";
375}

◆ updateAfterPointAddition()

void DigitizeStatePointMatch::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 377 of file DigitizeStatePointMatch.cpp.

378{
379 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::updateAfterPointAddition";
380}

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 382 of file DigitizeStatePointMatch.cpp.

384{
385 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::updateModelDigitizeCurve";
386}

◆ updateModelSegments()

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

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 388 of file DigitizeStatePointMatch.cpp.

389{
390 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::updateModelSegments";
391}

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