Engauge Digitizer 2
Loading...
Searching...
No Matches
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.
virtual void handleKeyPressArrow (CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
 If the key is an arrow (left, right, up, down) then move currently selected items.
QString moveTextDown () const
 Display text for down arrow.
QString moveTextLeft () const
 Display text for left arrow.
QString moveTextRight () const
 Display text for right arrow.
QString moveTextUp () const
 Display text for up arrow.

Detailed Description

Digitizing state for creating multiple Points along a highlighted segment.

Definition at line 18 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}
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
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}
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
70 GraphicsScene &scene = context().mainWindow().scene();
71 SegmentFactory segmentFactory (dynamic_cast<QGraphicsScene &> (scene),
72 context().isGnuplot());
73
74 segmentFactory.clearSegments(m_segments);
75}
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.

◆ 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
100 QImage img = context().mainWindow().imageFiltered();
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:777
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
int lineCount() const
Get method for number of lines.
Definition Segment.cpp:381

◆ 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
132 handleKeyPressArrow (cmdMediator,
133 key,
134 atLeastOneSelectedItem);
135}
virtual void handleKeyPressArrow(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
If the key is an arrow (left, right, up, down) then move currently selected items.

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

139{
140// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateSegment::handleMouseMove";
141}

◆ handleMousePress()

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

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 143 of file DigitizeStateSegment.cpp.

145{
146 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMousePress";
147}

◆ handleMouseRelease()

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

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 149 of file DigitizeStateSegment.cpp.

151{
152 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::handleMouseRelease";
153}

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

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

◆ state()

QString DigitizeStateSegment::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 218 of file DigitizeStateSegment.cpp.

219{
220 return "DigitizeStateSegment";
221}

◆ updateAfterPointAddition()

void DigitizeStateSegment::updateAfterPointAddition ( )
virtual

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

Implements DigitizeStateAbstractBase.

Definition at line 223 of file DigitizeStateSegment.cpp.

224{
225 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateAfterPointAddition";
226}

◆ updateModelDigitizeCurve()

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

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 228 of file DigitizeStateSegment.cpp.

230{
231 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelDigitizeCurve";
232}

◆ updateModelSegments()

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

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 234 of file DigitizeStateSegment.cpp.

235{
236 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateSegment::updateModelSegments";
237
238 QList<Segment*>::const_iterator itr;
239 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
240 Segment *segment = *itr;
241
242 segment->updateModelSegment (modelSegments);
243 }
244}
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment given the new settings.
Definition Segment.cpp:551

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