7 #include "CmdAddPointsGraph.h"
8 #include "DigitizeStateContext.h"
9 #include "DigitizeStateSegment.h"
10 #include "EngaugeAssert.h"
12 #include "MainWindow.h"
13 #include "OrdinalGenerator.h"
14 #include <QGraphicsPixmapItem>
15 #include <QGraphicsScene>
19 #include "SegmentFactory.h"
20 #include "Transformation.h"
27 DigitizeStateSegment::~DigitizeStateSegment ()
39 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::begin";
41 m_cmdMediator = cmdMediator;
51 const QSize &viewSize)
const
59 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateSegment::cursor";
61 return QCursor (Qt::ArrowCursor);
66 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::end";
76 const QString &pointIdentifier)
78 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleContextMenuEventAxis "
79 <<
" point=" << pointIdentifier.toLatin1 ().data ();
83 const QStringList &pointIdentifiers)
85 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment ::handleContextMenuEventGraph "
86 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
91 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleCurveChange";
107 QList<Segment*>::iterator itr;
108 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
111 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleCurveChange"
114 connect (segment, SIGNAL (signalMouseClickOnSegment (QPointF)),
this, SLOT (
slotMouseClickOnSegment (QPointF)));
122 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleKeyPress"
123 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
135 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleMousePress";
141 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleMouseRelease";
144 Segment *DigitizeStateSegment::segmentFromSegmentStart (
const QPointF &posSegmentStart)
const
146 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::segmentFromSegmentStart"
147 <<
" segments=" << m_segments.count();
149 QList<Segment*>::const_iterator itr;
150 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
153 if (segment->
firstPoint() == posSegmentStart) {
159 LOG4CPP_ERROR_S ((*mainCat)) <<
"DigitizeStateSegment::segmentFromSegmentStart";
160 ENGAUGE_ASSERT (
false);
166 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::slotMouseClickOnSegment";
168 Segment *segment = segmentFromSegmentStart (posSegmentStart);
171 QList<Segment*> segments;
172 segments.push_back (segment);
186 QList<double> ordinals;
187 QList<QPoint>::iterator itr;
188 for (itr = points.begin(); itr != points.end(); itr++) {
200 context ().mainWindow().selectedGraphCurve(),
209 return "DigitizeStateSegment";
214 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateAfterPointAddition";
220 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateModelDigitizeCurve";
225 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateModelSegments";
227 QList<Segment*>::const_iterator itr;
228 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity...
virtual QString state() const
State name for debugging.
Transformation transformation() const
Return read-only copy of transformation.
int lineCount() const
Get method for number of lines.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
QList< QPoint > fillPoints(const DocumentModelSegments &modelSegments, QList< Segment * > segments)
Return segment fill points for all segments, for previewing.
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
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 mod...
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
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 curre...
void clearSegments(QList< Segment * > &segments)
Remove the segments created by makeSegments.
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.
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
bool canPasteProtected(const Transformation &transformation, const QSize &viewSize) const
Protected version of canPaste method. Some, but not all, leaf classes use this method.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
Command for adding one or more graph points. This is for Segment Fill mode.
void makeSegments(const QImage &imageFiltered, const DocumentModelSegments &modelSegments, QList< Segment * > &segments, bool useDlg=true)
Main entry point for creating all Segments for the filtered image.
Storage of one imported image and the data attached to that image.
Selectable piecewise-defined line that follows a filtered line in the image.
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
void slotMouseClickOnSegment(QPointF)
Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be u...
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
Utility class for generating ordinal numbers.
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment given the new settings.
QPointF firstPoint() const
Coordinates of first point in Segment.
Model for DlgSettingsSegments and CmdSettingsSegments.
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
Add point and line handling to generic QGraphicsScene.
DigitizeStateSegment(DigitizeStateContext &context)
Single constructor.
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.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.