Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DigitizeStateSelect Class Reference

Digitizing state for selecting one or more Points in the Document. More...

#include <DigitizeStateSelect.h>

Inheritance diagram for DigitizeStateSelect:
Inheritance graph
Collaboration diagram for DigitizeStateSelect:
Collaboration graph

Public Member Functions

 DigitizeStateSelect (DigitizeStateContext &context)
 Single constructor.
 
virtual ~DigitizeStateSelect ()
 
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 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.
 

Detailed Description

Digitizing state for selecting one or more Points in the Document.

Originally this class set the cursor for each QGraphicsItem at the beginning of the state, but that triggered Qt bug 4190 which has the description 'If you have set the cursor for some QGraphicsItems you can no longer change the cursor for the view in for example a mouseReleaseEvent'. In turn, that lead to Engauge issue #155. Unfortunately, this means the user no longer has need feedback that suggests the user can do something with the QGraphicsItems.

Definition at line 19 of file DigitizeStateSelect.h.

Constructor & Destructor Documentation

◆ DigitizeStateSelect()

DigitizeStateSelect::DigitizeStateSelect ( DigitizeStateContext & context)

Single constructor.

Definition at line 40 of file DigitizeStateSelect.cpp.

40 :
42{
43}
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...

◆ ~DigitizeStateSelect()

DigitizeStateSelect::~DigitizeStateSelect ( )
virtual

Definition at line 45 of file DigitizeStateSelect.cpp.

46{
47}

Member Function Documentation

◆ activeCurve()

QString DigitizeStateSelect::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 49 of file DigitizeStateSelect.cpp.

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

◆ begin()

void DigitizeStateSelect::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 69 of file DigitizeStateSelect.cpp.

71{
72 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::begin";
73
74 setCursor(cmdMediator);
75 context().setDragMode(QGraphicsView::RubberBandDrag);
76
77 addHoverHighlighting();
79}
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...
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ canPaste()

bool DigitizeStateSelect::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 81 of file DigitizeStateSelect.cpp.

83{
84 return false;
85}

◆ cursor()

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

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 87 of file DigitizeStateSelect.cpp.

88{
89 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSelect::cursor";
90
91 return QCursor (Qt::ArrowCursor);
92}
const int INNER_RADIUS_MIN
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ end()

void DigitizeStateSelect::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 94 of file DigitizeStateSelect.cpp.

95{
96 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::end";
97
98 removeHoverHighlighting();
99}

◆ handleContextMenuEventAxis()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 101 of file DigitizeStateSelect.cpp.

103{
104 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::handleContextMenuEventAxis "
105 << " point=" << pointIdentifier.toLatin1 ().data ();
106
108 handleContextMenuEventAxis2 (cmdMediator);
109 } else {
110 handleContextMenuEventAxis34 (cmdMediator,
112 }
113}
@ DOCUMENT_AXES_POINTS_REQUIRED_2
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition Document.cpp:363

◆ handleContextMenuEventGraph()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 238 of file DigitizeStateSelect.cpp.

240{
241 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::handleContextMenuEventGraph "
242 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
243
244 // Editing graph coordinates before the axes are defined is not useful because:
245 // 1) That functionality is for fine tuning point placement based on defined axes
246 // 2) The transformation from screen to graph coordinates below will crash
247 if (context().mainWindow().transformation().transformIsDefined()) {
248
249 double *x = nullptr, *y = nullptr;
250
251 if (pointIdentifiers.count() == 1) {
252
253 // There is exactly one point so pass its coordinates to the dialog
254 x = new double;
255 y = new double;
256
261
262 // Ask user for coordinates
263 *x = posGraphBefore.x();
264 *y = posGraphBefore.y();
265 }
266
267 DlgEditPointGraph *dlg = new DlgEditPointGraph (context().mainWindow(),
268 cmdMediator->document().modelCoords(),
269 cmdMediator->document().modelGeneral(),
270 context().mainWindow().modelMainWindow(),
271 context().mainWindow().transformation(),
272 x,
273 y);
274 delete x;
275 delete y;
276
277 x = nullptr;
278 y = nullptr;
279
280 int rtn = dlg->exec ();
281
282 bool isXGiven, isYGiven;
283 double xGiven, yGiven;
284 dlg->posGraph (isXGiven, xGiven, isYGiven, yGiven); // One or both coordinates are returned
285 delete dlg;
286
287 if (rtn == QDialog::Accepted) {
288
289 // Create a command to edit the point
290 CmdEditPointGraph *cmd = new CmdEditPointGraph (context().mainWindow(),
291 cmdMediator->document(),
293 isXGiven,
294 isYGiven,
295 xGiven,
296 yGiven);
297 context().appendNewCmd(cmdMediator,
298 cmd);
299 }
300 }
301}
Command for editing the graph coordinates of one or more graph points.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Dialog box for editing the information of one or more points.
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
Definition Document.cpp:827
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition Document.cpp:723
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition Document.cpp:695
Transformation transformation() const
Return read-only copy of transformation.
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.

◆ handleCurveChange()

void DigitizeStateSelect::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 303 of file DigitizeStateSelect.cpp.

304{
305 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::handleCurveChange";
306}

◆ handleKeyPress()

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

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 308 of file DigitizeStateSelect.cpp.

311{
312 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::handleKeyPress"
313 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
314
316
317 if (key == Qt::Key_Down ||
318 key == Qt::Key_Up ||
319 key == Qt::Key_Left ||
320 key == Qt::Key_Right) {
321
322 keyPressArrow (cmdMediator,
323 key);
324
325 }
326 }
327}

◆ handleMouseMove()

void DigitizeStateSelect::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 329 of file DigitizeStateSelect.cpp.

331{
332// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSelect::handleMouseMove";
333}

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 335 of file DigitizeStateSelect.cpp.

337{
338 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::handleMousePress"
339 << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ();
340
341 // Note that GraphicsView has already called GraphicsPointAbstract::resetPositionHasChanged on all items
342
343 m_movingStart = posScreen;
344}
QString QPointFToString(const QPointF &pos)

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 346 of file DigitizeStateSelect.cpp.

348{
349 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::handleMouseRelease"
350 << " posScreen=" << QPointFToString (posScreen).toLatin1 ().data ();
351
352 QPointF deltaScreen = posScreen - m_movingStart;
354
356
357 if (positionHasChanged && (
358 qAbs (deltaScreen.x ()) > 0 ||
359 qAbs (deltaScreen.y ()) > 0)) {
360
361 QString moveText = moveTextFromDeltaScreen (deltaScreen);
362
363 // Create command to move points
364 CmdMoveBy *cmd = new CmdMoveBy (context().mainWindow(),
365 cmdMediator->document(),
367 moveText,
369 context().appendNewCmd (cmdMediator,
370 cmd);
371
372 } else {
373
374 // Selection probably changed so update the MainWindow controls (especially Cut)
376
377 showCoordinatesIfSinglePointIsSelected ();
378 }
379}
Command for moving all selected Points by a specified translation.
Definition CmdMoveBy.h:19
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
void updateAfterMouseRelease()
Call MainWindow::updateControls (which is private) after the very specific case - a mouse press/relea...

◆ state()

QString DigitizeStateSelect::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 524 of file DigitizeStateSelect.cpp.

525{
526 return "DigitizeStateSelect";
527}

◆ updateAfterPointAddition()

void DigitizeStateSelect::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 529 of file DigitizeStateSelect.cpp.

530{
531 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::updateAfterPointAddition";
532
533 addHoverHighlighting ();
534}

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 536 of file DigitizeStateSelect.cpp.

538{
539 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::updateModelDigitizeCurve";
540}

◆ updateModelSegments()

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

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 542 of file DigitizeStateSelect.cpp.

543{
544 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSelect::updateModelSegments";
545}

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