22#include <QGraphicsLineItem>
29 m_temporaryPoint0 (nullptr),
30 m_temporaryPoint1 (nullptr),
82 const QString &pointIdentifier)
85 <<
" point=" << pointIdentifier.toLatin1 ().data ();
89 const QStringList &pointIdentifiers)
92 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
105 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
111 if (m_temporaryPoint1 !=
nullptr) {
114 <<
" oldPos=" <<
QPointFToString (m_temporaryPoint1->pos ()).toLatin1().data()
117 m_temporaryPoint1->setPos (posScreen);
119 updateLineGeometry();
134 m_pointIdentifier1 = m_pointIdentifier0 +
"b";
138 NULL_GEOMETRY_WINDOW);
142 NULL_GEOMETRY_WINDOW);
149 m_temporaryPoint1->setPassive ();
156 m_line =
new QGraphicsLineItem;
158 m_line->setPen (QColor (Qt::red));
160 m_line->setVisible (
true);
162 updateLineGeometry ();
176 if (
context().mainWindow().transformIsDefined()) {
178 QMessageBox::warning (
nullptr,
179 QObject::tr (
"Engauge Digitizer"),
180 QObject::tr (
"The scale bar has been defined, and another is not needed or allowed."));
182 removeTemporaryPointsAndLine ();
190 context().mainWindow().modelMainWindow());
191 int rtn = dlg->exec ();
194 QPointF posScreen0 = m_temporaryPoint0->pos ();
195 QPointF posScreen1 = m_temporaryPoint1->pos ();
198 removeTemporaryPointsAndLine ();
200 if (rtn == QDialog::Accepted) {
205 int nextOrdinal1 = nextOrdinal0 + 1;
222void DigitizeStateScale::removeTemporaryPointsAndLine ()
228 m_temporaryPoint0 =
nullptr;
229 m_temporaryPoint1 =
nullptr;
235 return "DigitizeStateScale";
243void DigitizeStateScale::updateLineGeometry ()
245 m_line->setLine (m_temporaryPoint0->
pos ().x (),
246 m_temporaryPoint0->
pos ().y (),
247 m_temporaryPoint1->
pos ().x (),
248 m_temporaryPoint1->
pos ().y ());
const QString AXIS_CURVE_NAME
DigitizeState
Set of possible states of Digitize toolbar.
log4cpp::Category * mainCat
QString QPointFToString(const QPointF &pos)
Command for adding one scale point.
Create standard cross cursor, or custom cursor, according to settings.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
PointStyle pointStyle() const
Get method for PointStyle.
Container for one set of digitized Points.
CurveStyle curveStyle() const
Return the curve style.
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
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 bool guidelinesAreSelectable() const
Enable/disable guidelines according to state.
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
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...
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
virtual ~DigitizeStateScale()
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 QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
DigitizeStateScale(DigitizeStateContext &context)
Single constructor.
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 QString state() const
State name for debugging.
Dialog box for editing the information of the map scale.
double scaleLength() const
Return the scale bar length specified by the user. Only applies if dialog was accepted.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsSegments and CmdSettingsSegments.
Storage of one imported image and the data attached to that image.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
Window that displays the geometry information, as a table, for the current curve.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
void setPassive()
Prevent automatic focus on point (=make it passive) for scale bar so drags can be made to work proper...
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...
void addTemporaryScaleBar(GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1)
Add temporary scale bar to scene.
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
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.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
Details for a specific Point.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)