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 bool guidelinesAreSelectable () const
 Enable/disable guidelines according to 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);
48
49 handleCurveChange(cmdMediator);
50}
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...
void handleGuidelinesActiveChange(bool active)
Handle Guidelines active status toggle.
#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 52 of file DigitizeStateSegment.cpp.

54{
55 return canPasteProtected (transformation,
56 viewSize);
57}
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 59 of file DigitizeStateSegment.cpp.

60{
61 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::cursor";
62
63 return QCursor (Qt::ArrowCursor);
64}
#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 66 of file DigitizeStateSegment.cpp.

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

◆ guidelinesAreSelectable()

bool DigitizeStateSegment::guidelinesAreSelectable ( ) const
virtual

Enable/disable guidelines according to state.

Implements DigitizeStateAbstractBase.

Definition at line 77 of file DigitizeStateSegment.cpp.

78{
79 return false;
80}

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

84{
85 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleContextMenuEventAxis "
86 << " point=" << pointIdentifier.toLatin1 ().data ();
87}

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

91{
92 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment ::handleContextMenuEventGraph "
93 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
94}

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

97{
98 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleCurveChange";
99
101
102 GraphicsScene &scene = context().mainWindow().scene();
103 SegmentFactory segmentFactory (dynamic_cast<QGraphicsScene &> (scene),
104 context().isGnuplot());
105
106 segmentFactory.clearSegments (m_segments);
107
108 // Create new segments
109 segmentFactory.makeSegments (img,
110 cmdMediator->document().modelSegments(),
111 m_segments);
112
113 // Connect signals of the new segments
114 QList<Segment*>::iterator itr;
115 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
116 Segment *segment = *itr;
117
118 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleCurveChange"
119 << " lines=" << segment->lineCount();
120
121 connect (segment, SIGNAL (signalMouseClickOnSegment (QPointF)), this, SLOT (slotMouseClickOnSegment (QPointF)));
122 }
123}
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:761
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 125 of file DigitizeStateSegment.cpp.

128{
129 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleKeyPress"
130 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
131}

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

135{
136// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::handleMouseMove";
137}

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 139 of file DigitizeStateSegment.cpp.

141{
142 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMousePress";
143}

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 145 of file DigitizeStateSegment.cpp.

147{
148 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMouseRelease";
149}

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

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

215{
216 return "DigitizeStateSegment";
217}

◆ updateAfterPointAddition()

void DigitizeStateSegment::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 219 of file DigitizeStateSegment.cpp.

220{
221 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateAfterPointAddition";
222}

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 224 of file DigitizeStateSegment.cpp.

226{
227 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelDigitizeCurve";
228}

◆ updateModelSegments()

void DigitizeStateSegment::updateModelSegments ( const DocumentModelSegments & modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 230 of file DigitizeStateSegment.cpp.

231{
232 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelSegments";
233
234 QList<Segment*>::const_iterator itr;
235 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
236 Segment *segment = *itr;
237
238 segment->updateModelSegment (modelSegments);
239 }
240}
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: