Go to the documentation of this file.
22 #include <QGraphicsLineItem>
23 #include <QMessageBox>
29 m_temporaryPoint0 (nullptr),
30 m_temporaryPoint1 (nullptr),
76 const QString &pointIdentifier)
79 <<
" point=" << pointIdentifier.toLatin1 ().data ();
83 const QStringList &pointIdentifiers)
86 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
99 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
105 if (m_temporaryPoint1 !=
nullptr) {
111 m_temporaryPoint1->
setPos (posScreen);
113 updateLineGeometry();
128 m_pointIdentifier1 = m_pointIdentifier0 +
"b";
132 NULL_GEOMETRY_WINDOW);
136 NULL_GEOMETRY_WINDOW);
150 m_line =
new QGraphicsLineItem;
152 m_line->setPen (QColor (Qt::red));
154 m_line->setVisible (
true);
156 updateLineGeometry ();
170 if (
context().mainWindow().transformIsDefined()) {
172 QMessageBox::warning (
nullptr,
173 QObject::tr (
"Engauge Digitizer"),
174 QObject::tr (
"The scale bar has been defined, and another is not needed or allowed."));
176 removeTemporaryPointsAndLine ();
185 int rtn = dlg->exec ();
188 QPointF posScreen0 = m_temporaryPoint0->
pos ();
189 QPointF posScreen1 = m_temporaryPoint1->
pos ();
192 removeTemporaryPointsAndLine ();
194 if (rtn == QDialog::Accepted) {
199 int nextOrdinal1 = nextOrdinal0 + 1;
216 void DigitizeStateScale::removeTemporaryPointsAndLine ()
222 m_temporaryPoint0 =
nullptr;
223 m_temporaryPoint1 =
nullptr;
229 return "DigitizeStateScale";
237 void DigitizeStateScale::updateLineGeometry ()
239 m_line->setLine (m_temporaryPoint0->
pos ().x (),
240 m_temporaryPoint0->
pos ().y (),
241 m_temporaryPoint1->
pos ().x (),
242 m_temporaryPoint1->
pos ().y ());
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
const QString AXIS_CURVE_NAME
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
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...
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
double scaleLength() const
Return the scale bar length specified by the user. Only applies if dialog was accepted.
Dialog box for editing the information of the map scale.
void setPassive()
Prevent automatic focus on point (=make it passive) for scale bar so drags can be made to work proper...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
Create standard cross cursor, or custom cursor, according to settings.
Storage of one imported image and the data attached to that image.
DigitizeStateScale(DigitizeStateContext &context)
Single constructor.
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...
MainWindowModel modelMainWindow() const
Get method for main window model.
static QString temporaryPointIdentifier()
Point identifier for temporary point that is used by DigitzeStateAxis.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
Container for one set of digitized Points.
DocumentModelDigitizeCurve modelDigitizeCurve() const
Get method for DocumentModelDigitizeCurve.
int nextOrdinalForCurve(const QString &curveName) const
Default next ordinal value for specified curve.
QCursor generate(const DocumentModelDigitizeCurve &modelDigitizeCurve) const
Factory method to generate standard or custom cursor.
void addTemporaryScaleBar(GraphicsPoint *point0, GraphicsPoint *point1, const QString &pointIdentifier0, const QString &pointIdentifier1)
Add temporary scale bar to scene.
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
DigitizeState
Set of possible states of Digitize toolbar.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
void setPos(const QPointF pos)
Update the position.
#define LOG4CPP_INFO_S(logger)
virtual ~DigitizeStateScale()
void removePoint(const QString &identifier)
Remove specified point. This aborts if the point does not exist.
Model for DlgSettingsSegments and CmdSettingsSegments.
QPointF pos() const
Proxy method for QGraphicsItem::pos.
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
PointStyle pointStyle() const
Get method for PointStyle.
log4cpp::Category * mainCat
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
Details for a specific Point.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
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 updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
#define LOG4CPP_DEBUG_S(logger)
Window that displays the geometry information, as a table, for the current curve.
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
Command for adding one scale point.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
CurveStyle curveStyle() const
Return the curve style.
QString QPointFToString(const QPointF &pos)
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
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 QString state() const
State name for debugging.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...