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

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. More...
 

Detailed Description

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

Definition at line 21 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 }

◆ ~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 }

◆ 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);
60 
61  // Add outline that will move with the cursor
62  m_outline = new QGraphicsEllipseItem ();
63  context().mainWindow().scene().addItem (m_outline);
64  m_outline->setPen (QPen (Qt::black));
65  m_outline->setVisible (true);
66  m_outline->setZValue (Z_VALUE);
67 }

◆ 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 69 of file DigitizeStatePointMatch.cpp.

71 {
72  return canPasteProtected (transformation,
73  viewSize);
74 }

◆ cursor()

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

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 123 of file DigitizeStatePointMatch.cpp.

124 {
125  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::cursor";
126 
127  return QCursor (Qt::ArrowCursor);
128 }

◆ 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 130 of file DigitizeStatePointMatch.cpp.

131 {
132  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::end";
133 
134  // Remove candidate point which may or may not exist at this point
136 
137  // Remove outline before leaving state
138  ENGAUGE_CHECK_PTR (m_outline);
139  context().mainWindow().scene().removeItem (m_outline);
140  m_outline = nullptr;
141 }

◆ 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 182 of file DigitizeStatePointMatch.cpp.

184 {
185  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleContextMenuEventAxis "
186  << " point=" << pointIdentifier.toLatin1 ().data ();
187 }

◆ 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 189 of file DigitizeStatePointMatch.cpp.

191 {
192  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch ::handleContextMenuEventGraph "
193  << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
194 }

◆ 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 196 of file DigitizeStatePointMatch.cpp.

197 {
198  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleCurveChange";
199 }

◆ 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 201 of file DigitizeStatePointMatch.cpp.

204 {
205  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleKeyPress"
206  << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
207 
208  // The selected key button has to be compatible with GraphicsView::keyPressEvent
209  if (key == Qt::Key_Right) {
210 
211  promoteCandidatePointToPermanentPoint (cmdMediator); // This removes the current temporary point
212 
213  popCandidatePoint(cmdMediator); // This creates a new temporary point
214 
215  }
216 }

◆ 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 218 of file DigitizeStatePointMatch.cpp.

220 {
221 // LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::handleMouseMove";
222 
223  const DocumentModelPointMatch &modelPointMatch = cmdMediator->document().modelPointMatch();
224 
225  m_outline->setRect (posScreen.x() - modelPointMatch.maxPointSize() / 2.0,
226  posScreen.y() - modelPointMatch.maxPointSize() / 2.0,
227  modelPointMatch.maxPointSize(),
228  modelPointMatch.maxPointSize());
229 
230  const QImage &img = context().mainWindow().imageFiltered();
231  int radiusLimit = cmdMediator->document().modelGeneral().cursorSize();
232  bool pixelShouldBeOn = pixelIsOnInImage (img,
233  qFloor (posScreen.x()),
234  qFloor (posScreen.y()),
235  radiusLimit);
236 
237  QColor penColorIs = m_outline->pen().color();
238  bool pixelIsOn = (penColorIs.red () != penColorIs.green()); // Considered on if not gray scale
239  if (pixelShouldBeOn != pixelIsOn) {
240  QColor penColorShouldBe (pixelShouldBeOn ? Qt::green : Qt::black);
241  m_outline->setPen (QPen (penColorShouldBe));
242  }
243 }

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 245 of file DigitizeStatePointMatch.cpp.

247 {
248  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleMousePress";
249 }

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 251 of file DigitizeStatePointMatch.cpp.

253 {
254  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::handleMouseRelease";
255 
256  createPermanentPoint (cmdMediator,
257  posScreen);
258 
259  findPointsAndShowFirstCandidate (cmdMediator,
260  posScreen);
261 }

◆ state()

QString DigitizeStatePointMatch::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 362 of file DigitizeStatePointMatch.cpp.

363 {
364  return "DigitizeStatePointMatch";
365 }

◆ updateAfterPointAddition()

void DigitizeStatePointMatch::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 367 of file DigitizeStatePointMatch.cpp.

368 {
369  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::updateAfterPointAddition";
370 }

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 372 of file DigitizeStatePointMatch.cpp.

374 {
375  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::updateModelDigitizeCurve";
376 }

◆ updateModelSegments()

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

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 378 of file DigitizeStatePointMatch.cpp.

379 {
380  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStatePointMatch::updateModelSegments";
381 }

The documentation for this class was generated from the following files:
CmdMediator::document
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
DigitizeStateContext::setDragMode
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
Definition: DigitizeStateContext.cpp:211
Document::modelGeneral
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition: Document.cpp:723
GraphicsScene::removeTemporaryPointIfExists
void removeTemporaryPointIfExists()
Remove temporary point if it exists.
Definition: GraphicsScene.cpp:193
MainWindow::selectedGraphCurve
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
Definition: MainWindow.cpp:1479
DocumentModelGeneral::cursorSize
int cursorSize() const
Get method for effective cursor size.
Definition: DocumentModelGeneral.cpp:56
DocumentModelPointMatch::maxPointSize
double maxPointSize() const
Get method for max point size.
Definition: DocumentModelPointMatch.cpp:91
MainWindow::imageFiltered
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
Definition: MainWindow.cpp:844
ENGAUGE_CHECK_PTR
#define ENGAUGE_CHECK_PTR(ptr)
#endif
Definition: EngaugeAssert.h:27
Z_VALUE
const double Z_VALUE
Definition: DigitizeStatePointMatch.cpp:34
DigitizeStateContext::mainWindow
MainWindow & mainWindow()
Reference to the MainWindow, without const.
Definition: DigitizeStateContext.cpp:168
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
DigitizeStateAbstractBase::context
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
Definition: DigitizeStateAbstractBase.cpp:41
Document::modelPointMatch
DocumentModelPointMatch modelPointMatch() const
Get method for DocumentModelPointMatch.
Definition: Document.cpp:744
DigitizeStateAbstractBase::setCursor
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
Definition: DigitizeStateAbstractBase.cpp:51
mainCat
log4cpp::Category * mainCat
Definition: Logger.cpp:14
DigitizeStateAbstractBase::canPasteProtected
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.
Definition: DigitizeStateAbstractBase.cpp:32
DigitizeStatePointMatch::activeCurve
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Definition: DigitizeStatePointMatch.cpp:47
DocumentModelPointMatch
Model for DlgSettingsPointMatch and CmdSettingsPointMatch.
Definition: DocumentModelPointMatch.h:17
MainWindow::scene
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Definition: MainWindow.cpp:1459
LOG4CPP_DEBUG_S
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20
DigitizeStateAbstractBase
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
Definition: DigitizeStateAbstractBase.h:37
MainWindow::updateViewsOfSettings
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
Definition: MainWindow.cpp:3798