Engauge Digitizer  2
Public Member Functions | List of all members
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. More...
 
virtual ~DigitizeStateAxis ()
 
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 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 14 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 }
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.

◆ ~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);
46 }
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
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
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.

◆ 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 48 of file DigitizeStateAxis.cpp.

50 {
51  return false;
52 }

◆ cursor()

QCursor DigitizeStateAxis::cursor ( CmdMediator cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 73 of file DigitizeStateAxis.cpp.

74 {
75  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::cursor";
76 
77  CursorFactory cursorFactory;
78  QCursor cursor = cursorFactory.generate (cmdMediator->document().modelDigitizeCurve());
79 
80  return cursor;
81 }
Create standard cross cursor, or custom cursor, according to settings.
Definition: CursorFactory.h:15
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Definition: Document.cpp:709
log4cpp::Category * mainCat
Definition: Logger.cpp:14
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
#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 83 of file DigitizeStateAxis.cpp.

84 {
85  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::end";
86 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ 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 88 of file DigitizeStateAxis.cpp.

90 {
91  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleContextMenuEventAxis "
92  << " point=" << pointIdentifier.toLatin1 ().data ();
93 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ 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 95 of file DigitizeStateAxis.cpp.

97 {
98  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleContextMenuEventGraph "
99  << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
100 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ 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 102 of file DigitizeStateAxis.cpp.

103 {
104  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleCurveChange";
105 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ 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 107 of file DigitizeStateAxis.cpp.

110 {
111  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleKeyPress"
112  << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
113 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ 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 115 of file DigitizeStateAxis.cpp.

117 {
118 // LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateAxis::handleMouseMove";
119 }

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 121 of file DigitizeStateAxis.cpp.

123 {
124  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleMousePress";
125 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 127 of file DigitizeStateAxis.cpp.

129 {
130  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::handleMouseRelease";
131 
132  if (context().mainWindow().transformIsDefined()) {
133 
134  QMessageBox::warning (nullptr,
135  QObject::tr ("Engauge Digitizer"),
136  QObject::tr ("Three axis points have been defined, and no more are needed or allowed."));
137 
138  } else {
139 
140  createTemporaryPoint (cmdMediator,
141  posScreen);
142 
143  // Ask user for coordinates
144  DlgEditPointAxis *dlg = new DlgEditPointAxis (context ().mainWindow (),
145  cmdMediator->document().modelCoords(),
146  cmdMediator->document().modelGeneral(),
149  cmdMediator->document().documentAxesPointsRequired());
150  int rtn = dlg->exec ();
151 
152  bool isXOnly;
153  QPointF posGraph = dlg->posGraph (isXOnly);
154  delete dlg;
155 
156  // Remove temporary point
158 
159  if (rtn == QDialog::Accepted) {
160 
161  // User wants to add this axis point, but let's perform sanity checks first
162 
163  bool isError;
164  QString errorMessage;
165  int nextOrdinal = cmdMediator->document().nextOrdinalForCurve(AXIS_CURVE_NAME);
166 
167  cmdMediator->document().checkAddPointAxis(posScreen,
168  posGraph,
169  isError,
170  errorMessage,
171  isXOnly);
172 
173  if (isError) {
174 
175  QMessageBox::warning (nullptr,
176  QObject::tr ("Engauge Digitizer"),
177  errorMessage);
178 
179  } else {
180 
181  // Create command to add point
182  Document &document = cmdMediator->document ();
183  QUndoCommand *cmd = new CmdAddPointAxis (context ().mainWindow(),
184  document,
185  posScreen,
186  posGraph,
187  nextOrdinal,
188  isXOnly);
189  context().appendNewCmd(cmdMediator,
190  cmd);
191  }
192  }
193  }
194 }
Dialog box for editing the information of one axis point, in a graph with two axes.
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
Definition: Document.cpp:765
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Definition: Document.cpp:723
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
Definition: Document.cpp:363
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
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:268
MainWindow & mainWindow()
Reference to the MainWindow, without const.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
Definition: Point.cpp:519
Transformation transformation() const
Return read-only copy of transformation.
QPointF posGraph(bool &isXOnly) const
Return the graph coordinates position specified by the user. Only applies if dialog was accepted...
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Command for adding one axis point.
Storage of one imported image and the data attached to that image.
Definition: Document.h:41
MainWindowModel modelMainWindow() const
Get method for main window model.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Definition: Document.cpp:695
const QString AXIS_CURVE_NAME

◆ state()

QString DigitizeStateAxis::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 196 of file DigitizeStateAxis.cpp.

197 {
198  return "DigitizeStateAxis";
199 }

◆ updateAfterPointAddition()

void DigitizeStateAxis::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 201 of file DigitizeStateAxis.cpp.

202 {
203  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::updateAfterPointAddition";
204 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 206 of file DigitizeStateAxis.cpp.

208 {
209  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::updateModelDigitizeCurve";
210 
211  setCursor(cmdMediator);
212 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
log4cpp::Category * mainCat
Definition: Logger.cpp:14

◆ updateModelSegments()

void DigitizeStateAxis::updateModelSegments ( const DocumentModelSegments modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 214 of file DigitizeStateAxis.cpp.

215 {
216  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateAxis::updateModelSegments";
217 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

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