Engauge Digitizer  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 17 of file DigitizeStateSegment.h.

Constructor & Destructor Documentation

DigitizeStateSegment::DigitizeStateSegment ( DigitizeStateContext context)

Single constructor.

Definition at line 23 of file DigitizeStateSegment.cpp.

23  :
25 {
26 }
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
DigitizeStateSegment::~DigitizeStateSegment ( )
virtual

Definition at line 28 of file DigitizeStateSegment.cpp.

29 {
30 }

Member Function Documentation

QString DigitizeStateSegment::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 32 of file DigitizeStateSegment.cpp.

33 {
35 }
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
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 37 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);
49 }
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.
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
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.
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 51 of file DigitizeStateSegment.cpp.

53 {
54  return canPasteProtected (transformation,
55  viewSize);
56 }
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.
QCursor DigitizeStateSegment::cursor ( CmdMediator cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 58 of file DigitizeStateSegment.cpp.

59 {
60  LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::cursor";
61 
62  return QCursor (Qt::ArrowCursor);
63 }
log4cpp::Category * mainCat
Definition: Logger.cpp:14
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20
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 65 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);
74 }
#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.
Factory class for Segment objects.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:36
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 76 of file DigitizeStateSegment.cpp.

78 {
79  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleContextMenuEventAxis "
80  << " point=" << pointIdentifier.toLatin1 ().data ();
81 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 83 of file DigitizeStateSegment.cpp.

85 {
86  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment ::handleContextMenuEventGraph "
87  << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
88 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 90 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  }
117 }
int lineCount() const
Get method for number of lines.
Definition: Segment.cpp:380
#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...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
Factory class for Segment objects.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Selectable piecewise-defined line that follows a filtered line in the image.
Definition: Segment.h:21
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
Definition: MainWindow.cpp:844
void slotMouseClickOnSegment(QPointF)
Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be u...
log4cpp::Category * mainCat
Definition: Logger.cpp:14
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Definition: Document.cpp:751
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:36
void DigitizeStateSegment::handleKeyPress ( CmdMediator cmdMediator,
Qt::Key  key,
bool  atLeastOneSelectedItem 
)
virtual

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 119 of file DigitizeStateSegment.cpp.

122 {
123  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleKeyPress"
124  << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
125 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 127 of file DigitizeStateSegment.cpp.

129 {
130 // LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::handleMouseMove";
131 }
void DigitizeStateSegment::handleMousePress ( CmdMediator cmdMediator,
QPointF  pos 
)
virtual

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 133 of file DigitizeStateSegment.cpp.

135 {
136  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMousePress";
137 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void DigitizeStateSegment::handleMouseRelease ( CmdMediator cmdMediator,
QPointF  pos 
)
virtual

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 139 of file DigitizeStateSegment.cpp.

141 {
142  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMouseRelease";
143 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 165 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);
206 }
Transformation transformation() const
Return read-only copy of transformation.
#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...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
Factory class for Segment objects.
Affine transformation between screen and graph coordinates, based on digitized axis points...
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 or more graph points. This is for Segment Fill mode.
Storage of one imported image and the data attached to that image.
Definition: Document.h:41
Selectable piecewise-defined line that follows a filtered line in the image.
Definition: Segment.h:21
log4cpp::Category * mainCat
Definition: Logger.cpp:14
Utility class for generating ordinal numbers.
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Definition: Document.cpp:751
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Add point and line handling to generic QGraphicsScene.
Definition: GraphicsScene.h:36
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.
QString DigitizeStateSegment::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 208 of file DigitizeStateSegment.cpp.

209 {
210  return "DigitizeStateSegment";
211 }
void DigitizeStateSegment::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 213 of file DigitizeStateSegment.cpp.

214 {
215  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateAfterPointAddition";
216 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void DigitizeStateSegment::updateModelDigitizeCurve ( CmdMediator cmdMediator,
const DocumentModelDigitizeCurve modelDigitizeCurve 
)
virtual

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 218 of file DigitizeStateSegment.cpp.

220 {
221  LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelDigitizeCurve";
222 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void DigitizeStateSegment::updateModelSegments ( const DocumentModelSegments modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 224 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  }
234 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Selectable piecewise-defined line that follows a filtered line in the image.
Definition: Segment.h:21
log4cpp::Category * mainCat
Definition: Logger.cpp:14
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment given the new settings.
Definition: Segment.cpp:540

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