Engauge Digitizer  2
Public Member Functions | List of all members
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. More...
 
virtual ~DigitizeStateCurve ()
 
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 ()
 
DigitizeStateContextcontext ()
 Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses, without const. More...
 
const DigitizeStateContextcontext () 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 creating Curve Points, one at a time.

Definition at line 12 of file DigitizeStateCurve.h.

Constructor & Destructor Documentation

◆ DigitizeStateCurve()

DigitizeStateCurve::DigitizeStateCurve ( DigitizeStateContext context)

Single constructor.

Definition at line 20 of file DigitizeStateCurve.cpp.

21  :
23 {

◆ ~DigitizeStateCurve()

DigitizeStateCurve::~DigitizeStateCurve ( )
virtual

Definition at line 25 of file DigitizeStateCurve.cpp.

27 {

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 29 of file DigitizeStateCurve.cpp.

31 {

◆ 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 34 of file DigitizeStateCurve.cpp.

37 {
38  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::begin";
39 
40  setCursor(cmdMediator);
41  context().setDragMode(QGraphicsView::NoDrag);

◆ 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 44 of file DigitizeStateCurve.cpp.

47 {
48  return canPasteProtected (transformation,
49  size);

◆ cursor()

QCursor DigitizeStateCurve::cursor ( CmdMediator cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 51 of file DigitizeStateCurve.cpp.

53 {
54  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::cursor";
55 
56  CursorFactory cursorFactory;
57  QCursor cursor = cursorFactory.generate (cmdMediator->document().modelDigitizeCurve());
58 
59  return cursor;

◆ 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 61 of file DigitizeStateCurve.cpp.

63 {
64  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::end";

◆ 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 66 of file DigitizeStateCurve.cpp.

69 {
70  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleContextMenuEventAxis "
71  << " point=" << pointIdentifier.toLatin1 ().data ();

◆ 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 73 of file DigitizeStateCurve.cpp.

76 {
77  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve ::handleContextMenuEventGraph "
78  << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();

◆ 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 80 of file DigitizeStateCurve.cpp.

82 {
83  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleCurveChange";

◆ 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 85 of file DigitizeStateCurve.cpp.

89 {
90  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleKeyPress"
91  << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();

◆ 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 93 of file DigitizeStateCurve.cpp.

96 {
97 // LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateCurve::handleMouseMove";

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 99 of file DigitizeStateCurve.cpp.

102 {
103  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMousePress";

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 105 of file DigitizeStateCurve.cpp.

108 {
109  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::handleMouseRelease";
110 
111  // Create command to add point
112  OrdinalGenerator ordinalGenerator;
113  Document &document = cmdMediator->document ();
114  const Transformation &transformation = context ().mainWindow ().transformation();
115  QUndoCommand *cmd = new CmdAddPointGraph (context ().mainWindow(),
116  document,
117  context ().mainWindow().selectedGraphCurve(),
118  posScreen,
119  ordinalGenerator.generateCurvePointOrdinal(document,
120  transformation,
121  posScreen,
122  activeCurve ()));
123  context().appendNewCmd(cmdMediator,
124  cmd);

◆ state()

QString DigitizeStateCurve::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 126 of file DigitizeStateCurve.cpp.

128 {
129  return "DigitizeStateCurve";

◆ updateAfterPointAddition()

void DigitizeStateCurve::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 131 of file DigitizeStateCurve.cpp.

133 {
134  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateAfterPointAddition";

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 136 of file DigitizeStateCurve.cpp.

139 {
140  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelDigitizeCurve";
141 
142  setCursor(cmdMediator);

◆ updateModelSegments()

void DigitizeStateCurve::updateModelSegments ( const DocumentModelSegments modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 144 of file DigitizeStateCurve.cpp.

146 {
147  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateCurve::updateModelSegments";

The documentation for this class was generated from the following files:
DigitizeStateContext::setDragMode
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
Definition: DigitizeStateContext.cpp:211
DigitizeStateAbstractBase::context
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
Definition: DigitizeStateAbstractBase.cpp:41
DigitizeStateContext::mainWindow
MainWindow & mainWindow()
Reference to the MainWindow, without const.
Definition: DigitizeStateContext.cpp:168
MainWindow::selectedGraphCurve
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
Definition: MainWindow.cpp:1478
CursorFactory
Create standard cross cursor, or custom cursor, according to settings.
Definition: CursorFactory.h:14
Document
Storage of one imported image and the data attached to that image.
Definition: Document.h:40
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition: Transformation.h:30
CmdAddPointGraph
Command for adding one graph point.
Definition: CmdAddPointGraph.h:16
Document::modelDigitizeCurve
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Definition: Document.cpp:709
CursorFactory::generate
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
Definition: CursorFactory.cpp:18
DigitizeStateContext::appendNewCmd
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Definition: DigitizeStateContext.cpp:64
CmdMediator::document
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
DigitizeStateCurve::activeCurve
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Definition: DigitizeStateCurve.cpp:29
LOG4CPP_INFO_S
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
OrdinalGenerator::generateCurvePointOrdinal
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.
Definition: OrdinalGenerator.cpp:34
MainWindow::transformation
Transformation transformation() const
Return read-only copy of transformation.
Definition: MainWindow.cpp:3230
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
DigitizeStateCurve::cursor
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
Definition: DigitizeStateCurve.cpp:51
LOG4CPP_DEBUG_S
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20
OrdinalGenerator
Utility class for generating ordinal numbers.
Definition: OrdinalGenerator.h:17
DigitizeStateAbstractBase
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
Definition: DigitizeStateAbstractBase.h:36
MainWindow::updateViewsOfSettings
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
Definition: MainWindow.cpp:3797