Engauge Digitizer 2
Loading...
Searching...
No Matches
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.
 

Public Member Functions

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

Definition at line 17 of file DigitizeStateSegment.h.

Constructor & Destructor Documentation

◆ DigitizeStateSegment()

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.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...

◆ ~DigitizeStateSegment()

DigitizeStateSegment::~DigitizeStateSegment ( )
virtual

Definition at line 28 of file DigitizeStateSegment.cpp.

29{
30}

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 32 of file DigitizeStateSegment.cpp.

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

◆ 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 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}
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.
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
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 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}
const int INNER_RADIUS_MIN
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.

◆ cursor()

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}
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ 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 65 of file DigitizeStateSegment.cpp.

66{
67 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::end";
68
70 SegmentFactory segmentFactory (dynamic_cast<QGraphicsScene &> (scene),
71 context().isGnuplot());
72
73 segmentFactory.clearSegments(m_segments);
74}
Add point and line handling to generic QGraphicsScene.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Factory class for Segment objects.

◆ 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 76 of file DigitizeStateSegment.cpp.

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

◆ 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 83 of file DigitizeStateSegment.cpp.

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

◆ 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 90 of file DigitizeStateSegment.cpp.

91{
92 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleCurveChange";
93
95
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}
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
void slotMouseClickOnSegment(QPointF)
Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be u...
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Definition Document.cpp:751
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
Selectable piecewise-defined line that follows a filtered line in the image.
Definition Segment.h:22
int lineCount() const
Get method for number of lines.
Definition Segment.cpp:380

◆ 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 119 of file DigitizeStateSegment.cpp.

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

◆ 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 127 of file DigitizeStateSegment.cpp.

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

◆ handleMousePress()

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}

◆ handleMouseRelease()

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}

◆ 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 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
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
185 Document &document = m_cmdMediator->document ();
186 const Transformation &transformation = context ().mainWindow ().transformation();
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}
Command for adding one or more graph points. This is for Segment Fill mode.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Storage of one imported image and the data attached to that image.
Definition Document.h:42
Transformation transformation() const
Return read-only copy of transformation.
Utility class for generating ordinal numbers.
Affine transformation between screen and graph coordinates, based on digitized axis points.

◆ state()

QString DigitizeStateSegment::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 208 of file DigitizeStateSegment.cpp.

209{
210 return "DigitizeStateSegment";
211}

◆ updateAfterPointAddition()

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}

◆ updateModelDigitizeCurve()

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}

◆ updateModelSegments()

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}
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: