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>
18#include "SegmentFactory.h"
25DigitizeStateSegment::~DigitizeStateSegment ()
37 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::begin";
39 m_cmdMediator = cmdMediator;
50 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateSegment::cursor";
52 return QCursor (Qt::ArrowCursor);
57 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::end";
68 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleCurveChange";
84 QList<Segment*>::iterator itr;
85 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
88 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleCurveChange"
91 connect (segment, SIGNAL (signalMouseClickOnSegment (QPointF)),
this, SLOT (
slotMouseClickOnSegment (QPointF)));
99 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleKeyPress"
100 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
112 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleMousePress";
118 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::handleMouseRelease";
121Segment *DigitizeStateSegment::segmentFromSegmentStart (
const QPointF &posSegmentStart)
const
123 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::segmentFromSegmentStart"
124 <<
" segments=" << m_segments.count();
126 QList<Segment*>::const_iterator itr;
127 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
130 if (segment->
firstPoint() == posSegmentStart) {
136 LOG4CPP_ERROR_S ((*mainCat)) <<
"DigitizeStateSegment::segmentFromSegmentStart";
137 ENGAUGE_ASSERT (
false);
143 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::slotMouseClickOnSegment";
145 Segment *segment = segmentFromSegmentStart (posSegmentStart);
148 QList<Segment*> segments;
149 segments.push_back (segment);
163 QList<double> ordinals;
164 QList<QPoint>::iterator itr;
165 for (itr = points.begin(); itr != points.end(); itr++) {
177 context ().mainWindow().selectedGraphCurve(),
186 return "DigitizeStateSegment";
192 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateModelDigitizeCurve";
197 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateSegment::updateModelSegments";
199 QList<Segment*>::const_iterator itr;
200 for (itr = m_segments.begin(); itr != m_segments.end(); itr++) {
Command for adding one or more graph points. This is for Segment Fill mode.
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,...
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 setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
virtual QString state() const
State name for debugging.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
void slotMouseClickOnSegment(QPointF)
Receive signal from Segment that has been clicked on. The CmdMediator from the begin method will be u...
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
DigitizeStateSegment(DigitizeStateContext &context)
Single constructor.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
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 handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsSegments and CmdSettingsSegments.
Storage of one imported image and the data attached to that image.
DocumentModelSegments modelSegments() const
Get method for DocumentModelSegments.
Add point and line handling to generic QGraphicsScene.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
QImage imageFiltered() const
Background image that has been filtered for the current curve. This asserts if a curve-specific image...
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Transformation transformation() const
Return read-only copy of transformation.
Utility class for generating ordinal numbers.
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.
Factory class for Segment objects.
QList< QPoint > fillPoints(const DocumentModelSegments &modelSegments, QList< Segment * > segments)
Return segment fill points for all segments, for previewing.
void clearSegments(QList< Segment * > &segments)
Remove the segments created by makeSegments.
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.
Selectable piecewise-defined line that follows a filtered line in the image.
int lineCount() const
Get method for number of lines.
void updateModelSegment(const DocumentModelSegments &modelSegments)
Update this segment given the new settings.
QPointF firstPoint() const
Coordinates of first point in Segment.