7 #include "CmdAddScale.h" 8 #include "CmdMediator.h" 9 #include "CursorFactory.h" 10 #include "DigitizeStateScale.h" 11 #include "DigitizeStateContext.h" 12 #include "DlgEditScale.h" 14 #include "EngaugeAssert.h" 15 #include "GraphicsPoint.h" 16 #include "GraphicsScene.h" 17 #include "GraphicsView.h" 19 #include "MainWindow.h" 20 #include "PointStyle.h" 22 #include <QGraphicsLineItem> 23 #include <QMessageBox> 24 #include "QtToString.h" 29 m_temporaryPoint0 (0),
30 m_temporaryPoint1 (0),
35 DigitizeStateScale::~DigitizeStateScale ()
41 return AXIS_CURVE_NAME;
47 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::begin";
56 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateScale::cursor";
66 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::end";
70 const QString &pointIdentifier)
72 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::handleContextMenuEventAxis " 73 <<
" point=" << pointIdentifier.toLatin1 ().data ();
77 const QStringList &pointIdentifiers)
79 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::handleContextMenuEventGraph " 80 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
85 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::handleCurveChange";
92 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::handleKeyPress" 93 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
99 if (m_temporaryPoint1 != 0) {
101 LOG4CPP_DEBUG_S ((*mainCat)) <<
"DigitizeStateScale::handleMouseMove" 102 <<
" oldPos=" << QPointFToString (m_temporaryPoint1->
pos ()).toLatin1().data()
103 <<
" newPos=" << QPointFToString (posScreen).toLatin1().data();
105 m_temporaryPoint1->
setPos (posScreen);
107 updateLineGeometry();
114 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::handleMousePress";
122 m_pointIdentifier1 = m_pointIdentifier0 +
"b";
126 NULL_GEOMETRY_WINDOW);
130 NULL_GEOMETRY_WINDOW);
144 m_line =
new QGraphicsLineItem;
146 m_line->setPen (QColor (Qt::red));
147 m_line->setZValue (Z_VALUE_CURVE);
148 m_line->setVisible (
true);
150 updateLineGeometry ();
162 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::handleMouseRelease";
164 if (
context().mainWindow().transformIsDefined()) {
166 QMessageBox::warning (0,
167 QObject::tr (
"Engauge Digitizer"),
168 QObject::tr (
"The scale bar has been defined, and another is not needed or allowed."));
170 removeTemporaryPointsAndLine ();
179 int rtn = dlg->exec ();
182 QPointF posScreen0 = m_temporaryPoint0->
pos ();
183 QPointF posScreen1 = m_temporaryPoint1->
pos ();
186 removeTemporaryPointsAndLine ();
188 if (rtn == QDialog::Accepted) {
193 int nextOrdinal1 = nextOrdinal0 + 1;
210 void DigitizeStateScale::removeTemporaryPointsAndLine ()
216 m_temporaryPoint0 = 0;
217 m_temporaryPoint1 = 0;
223 return "DigitizeStateScale";
228 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::updateAfterPointAddition";
231 void DigitizeStateScale::updateLineGeometry ()
233 m_line->setLine (m_temporaryPoint0->
pos ().x (),
234 m_temporaryPoint0->
pos ().y (),
235 m_temporaryPoint1->
pos ().x (),
236 m_temporaryPoint1->
pos ().y ());
242 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::updateModelDigitizeCurve";
249 LOG4CPP_INFO_S ((*mainCat)) <<
"DigitizeStateScale::updateModelSegments";
void setPassive()
Prevent automatic focus on point (=make it passive) for scale bar so drags can be made to work proper...
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
Create standard cross cursor, or custom cursor, according to settings.
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
Dialog box for editing the information of the map scale.
PointStyle pointStyle() const
Get method for PointStyle.
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
void addTemporaryScaleBar(GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1)
Add temporary scale bar to scene.
Window that displays the geometry information, as a table, for the current curve. ...
void setPos(const QPointF pos)
Update the position.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
virtual QString state() const
State name for debugging.
GraphicsPoint * createPoint(const QString &identifier, const PointStyle &pointStyle, const QPointF &posScreen, GeometryWindow *geometryWindow)
Create one QGraphicsItem-based object that represents one Point. It is NOT added to m_graphicsLinesFo...
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Details for a specific Point.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
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 updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity...
Storage of one imported image and the data attached to that image.
Container for one set of digitized Points.
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
MainWindowModel modelMainWindow() const
Get method for main window model.
Command for adding one scale point.
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
Model for DlgSettingsSegments and CmdSettingsSegments.
CurveStyle curveStyle() const
Return the curve style.
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
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 end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
DigitizeStateScale(DigitizeStateContext &context)
Single constructor.
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
double scaleLength() const
Return the scale bar length specified by the user. Only applies if dialog was accepted.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.