1 #include "CmdAddPointsGraph.h"
2 #include "DigitizeStateContext.h"
3 #include "DigitizeStateSegment.h"
4 #include "EngaugeAssert.h"
6 #include "MainWindow.h"
7 #include "OrdinalGenerator.h"
8 #include <QGraphicsPixmapItem>
9 #include <QGraphicsScene>
12 #include "SegmentFactory.h"
19 DigitizeStateSegment::~DigitizeStateSegment ()
30 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::begin";
41 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateSegment::cursor";
43 return QCursor (Qt::ArrowCursor);
48 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::end";
59 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleCurveChange";
71 context().cmdMediator().document().modelSegments(),
75 QList<Segment*>::iterator itr;
76 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
79 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleCurveChange"
82 connect (segment, SIGNAL (signalMouseClickOnSegment (QPointF)),
this, SLOT (
slotMouseClickOnSegment (QPointF)));
89 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleKeyPress"
90 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
100 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleMousePress";
105 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleMouseRelease";
108 Segment *DigitizeStateSegment::segmentFromSegmentStart (
const QPointF &posSegmentStart)
const
110 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::segmentFromSegmentStart"
111 <<
" segments=" << m_segments.count();
113 QList<Segment*>::const_iterator itr;
114 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
117 if (segment->
firstPoint() == posSegmentStart) {
123 LOG4CPP_ERROR_S ((*mainCat)) <<
"DigitizeStateSegment::segmentFromSegmentStart";
124 ENGAUGE_ASSERT (
false);
130 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::slotMouseClickOnSegment";
132 Segment *segment = segmentFromSegmentStart (posSegmentStart);
135 QList<Segment*> segments;
136 segments.push_back (segment);
143 QList<QPoint> points = segmentFactory.
fillPoints (
context().cmdMediator().document().modelSegments(),
150 QList<double> ordinals;
151 QList<QPoint>::iterator itr;
152 for (itr = points.begin(); itr != points.end(); itr++) {
164 context ().mainWindow().selectedGraphCurve(),
172 return "DigitizeStateSegment";
177 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateModelDigitizeCurve";
182 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateModelSegments";
184 QList<Segment*>::const_iterator itr;
185 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
void makeSegments(const QImage &imageFiltered, const DocumentModelSegments &modelSegments, QList< Segment * > &segments)
Main entry point for creating all Segments for the filtered image.
virtual QString state() const
State name for debugging.
virtual void handleCurveChange()
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
virtual void handleMouseRelease(QPointF posScreen)
Handle a mouse release that was intercepted earlier.
virtual void begin(DigitizeState previousState)
Method that is called at the exact moment a state is entered.
CmdMediator & cmdMediator()
Provide CmdMediator for indirect access to the Document.
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.
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.
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.
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 handleMousePress(QPointF posScreen)
Handle a mouse press that was intercepted earlier.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
virtual void handleMouseMove(QPointF posScreen)
Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mod...
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
void setCursor()
Update the cursor according to the current state.
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.
virtual void updateModelDigitizeCurve(const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
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.
void appendNewCmd(QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Utility class for generating ordinal numbers.
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.
virtual void handleKeyPress(Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
virtual QCursor cursor() const
Returns the state-specific cursor shape.
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.