Engauge Digitizer  2
Public Slots | Public Member Functions | List of all members
DigitizeStateSegment Class Reference

Digitizing state for creating multiple Points along a highlighted segment. More...

#include <DigitizeStateSegment.h>

Inheritance diagram for DigitizeStateSegment:
Inheritance graph
Collaboration diagram for DigitizeStateSegment:
Collaboration graph

Public Slots

void slotMouseClickOnSegment (QPointF)
 Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be used. More...
 

Public Member Functions

 DigitizeStateSegment (DigitizeStateContext &context)
 Single constructor. More...
 
virtual ~DigitizeStateSegment ()
 
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 multiple Points along a highlighted segment.

Definition at line 16 of file DigitizeStateSegment.h.

Constructor & Destructor Documentation

◆ DigitizeStateSegment()

DigitizeStateSegment::DigitizeStateSegment ( DigitizeStateContext context)

Single constructor.

Definition at line 22 of file DigitizeStateSegment.cpp.

23  :
25 {

◆ ~DigitizeStateSegment()

DigitizeStateSegment::~DigitizeStateSegment ( )
virtual

Definition at line 27 of file DigitizeStateSegment.cpp.

29 {

Member Function Documentation

◆ activeCurve()

QString DigitizeStateSegment::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 31 of file DigitizeStateSegment.cpp.

33 {

◆ begin()

void DigitizeStateSegment::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 36 of file DigitizeStateSegment.cpp.

39 {
40  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::begin";
41 
42  m_cmdMediator = cmdMediator; // Save for slotMouseClickOnSegment
43 
44  setCursor(cmdMediator);
45  context().setDragMode(QGraphicsView::NoDrag);
47 
48  handleCurveChange(cmdMediator);

◆ canPaste()

bool DigitizeStateSegment::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 50 of file DigitizeStateSegment.cpp.

53 {
54  return canPasteProtected (transformation,
55  viewSize);

◆ cursor()

QCursor DigitizeStateSegment::cursor ( CmdMediator cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 57 of file DigitizeStateSegment.cpp.

59 {
60  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::cursor";
61 
62  return QCursor (Qt::ArrowCursor);

◆ end()

void DigitizeStateSegment::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 64 of file DigitizeStateSegment.cpp.

66 {
67  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::end";
68 
69  GraphicsScene &scene = context().mainWindow().scene();
70  SegmentFactory segmentFactory (dynamic_cast<QGraphicsScene &> (scene),
71  context().isGnuplot());
72 
73  segmentFactory.clearSegments(m_segments);

◆ handleContextMenuEventAxis()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 75 of file DigitizeStateSegment.cpp.

78 {
79  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleContextMenuEventAxis "
80  << " point=" << pointIdentifier.toLatin1 ().data ();

◆ handleContextMenuEventGraph()

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

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

Implements DigitizeStateAbstractBase.

Definition at line 82 of file DigitizeStateSegment.cpp.

85 {
86  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment ::handleContextMenuEventGraph "
87  << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();

◆ handleCurveChange()

void DigitizeStateSegment::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 89 of file DigitizeStateSegment.cpp.

91 {
92  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleCurveChange";
93 
94  QImage img = context().mainWindow().imageFiltered();
95 
96  GraphicsScene &scene = context().mainWindow().scene();
97  SegmentFactory segmentFactory (dynamic_cast<QGraphicsScene &> (scene),
98  context().isGnuplot());
99 
100  segmentFactory.clearSegments (m_segments);
101 
102  // Create new segments
103  segmentFactory.makeSegments (img,
104  cmdMediator->document().modelSegments(),
105  m_segments);
106 
107  // Connect signals of the new segments
108  QList<Segment*>::iterator itr;
109  for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
110  Segment *segment = *itr;
111 
112  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleCurveChange"
113  << " lines=" << segment->lineCount();
114 
115  connect (segment, SIGNAL (signalMouseClickOnSegment (QPointF)), this, SLOT (slotMouseClickOnSegment (QPointF)));
116  }

◆ handleKeyPress()

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

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 118 of file DigitizeStateSegment.cpp.

122 {
123  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleKeyPress"
124  << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();

◆ handleMouseMove()

void DigitizeStateSegment::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 126 of file DigitizeStateSegment.cpp.

129 {
130 // LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::handleMouseMove";

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 132 of file DigitizeStateSegment.cpp.

135 {
136  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMousePress";

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 138 of file DigitizeStateSegment.cpp.

141 {
142  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMouseRelease";

◆ slotMouseClickOnSegment

void DigitizeStateSegment::slotMouseClickOnSegment ( QPointF  posSegmentStart)
slot

Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be used.

Definition at line 164 of file DigitizeStateSegment.cpp.

166 {
167  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::slotMouseClickOnSegment";
168 
169  Segment *segment = segmentFromSegmentStart (posSegmentStart);
170 
171  // Create single-entry list that is expected by SegmentFactory
172  QList<Segment*> segments;
173  segments.push_back (segment);
174 
175  // Generate point coordinates. Nothing is created in the GraphicsScene at this point
176  GraphicsScene &scene = context().mainWindow().scene();
177  SegmentFactory segmentFactory (dynamic_cast<QGraphicsScene &> (scene),
178  context().isGnuplot());
179 
180  QList<QPoint> points = segmentFactory.fillPoints (m_cmdMediator->document().modelSegments(),
181  segments);
182 
183  // Create one ordinal for each point
184  OrdinalGenerator ordinalGenerator;
185  Document &document = m_cmdMediator->document ();
186  const Transformation &transformation = context ().mainWindow ().transformation();
187  QList<double> ordinals;
188  QList<QPoint>::iterator itr;
189  for (itr = points.begin(); itr != points.end(); itr++) {
190 
191  QPoint point = *itr;
192  ordinals << ordinalGenerator.generateCurvePointOrdinal(document,
193  transformation,
194  point,
195  activeCurve ());
196  }
197 
198  // Create command to add points
199  QUndoCommand *cmd = new CmdAddPointsGraph (context ().mainWindow(),
200  document,
201  context ().mainWindow().selectedGraphCurve(),
202  points,
203  ordinals);
204  context().appendNewCmd(m_cmdMediator,
205  cmd);

◆ state()

QString DigitizeStateSegment::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 207 of file DigitizeStateSegment.cpp.

209 {
210  return "DigitizeStateSegment";

◆ updateAfterPointAddition()

void DigitizeStateSegment::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 212 of file DigitizeStateSegment.cpp.

214 {
215  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateAfterPointAddition";

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 217 of file DigitizeStateSegment.cpp.

220 {
221  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelDigitizeCurve";

◆ updateModelSegments()

void DigitizeStateSegment::updateModelSegments ( const DocumentModelSegments modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 223 of file DigitizeStateSegment.cpp.

225 {
226  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelSegments";
227 
228  QList<Segment*>::const_iterator itr;
229  for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
230  Segment *segment = *itr;
231 
232  segment->updateModelSegment (modelSegments);
233  }

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
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
Document::modelSegments
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Definition: Document.cpp:751
Segment
Selectable piecewise-defined line that follows a filtered line in the image.
Definition: Segment.h:20
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:843
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
CmdAddPointsGraph
Command for adding one or more graph points. This is for Segment Fill mode.
Definition: CmdAddPointsGraph.h:18
Segment::lineCount
int lineCount() const
Get method for number of lines.
Definition: Segment.cpp:380
CmdMediator::document
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
DigitizeStateSegment::slotMouseClickOnSegment
void slotMouseClickOnSegment(QPointF)
Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be u...
Definition: DigitizeStateSegment.cpp:164
Segment::updateModelSegment
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment given the new settings.
Definition: Segment.cpp:540
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
GraphicsScene
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:35
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
MainWindow::scene
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Definition: MainWindow.cpp:1458
DigitizeStateSegment::activeCurve
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Definition: DigitizeStateSegment.cpp:31
LOG4CPP_DEBUG_S
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20
DigitizeStateSegment::handleCurveChange
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
Definition: DigitizeStateSegment.cpp:89
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
SegmentFactory
Factory class for Segment objects.
Definition: SegmentFactory.h:26
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