Go to the documentation of this file.
26 #include <QGraphicsItem>
28 #include <QMessageBox>
54 void DigitizeStateSelect::addHoverHighlighting()
59 QList<QGraphicsItem*>::iterator itr;
60 for (itr = items.begin (); itr != items.end (); itr++) {
62 QGraphicsItem *item = *itr;
64 item->setAcceptHoverEvents(
true);
77 addHoverHighlighting();
91 return QCursor (Qt::ArrowCursor);
98 removeHoverHighlighting();
102 const QString &pointIdentifier)
105 <<
" point=" << pointIdentifier.toLatin1 ().data ();
108 handleContextMenuEventAxis2 (cmdMediator);
110 handleContextMenuEventAxis34 (cmdMediator,
115 void DigitizeStateSelect::handleContextMenuEventAxis2 (
CmdMediator *cmdMediator)
119 const bool IS_NOT_X_ONLY =
false;
123 QString pointIdentifier = scaleBarPointIdentifier (cmdMediator);
129 double scaleLength = scaleBarLength (cmdMediator);
135 int rtn = dlg->exec ();
140 if (rtn == QDialog::Accepted) {
145 QString errorMessage;
147 bool isXNonzero = (qAbs (posGraphBefore.x()) > 0);
148 QPointF posGraphAfter (isXNonzero ? scaleLength : 0,
149 isXNonzero ? 0 : scaleLength);
158 QMessageBox::warning (
nullptr,
177 void DigitizeStateSelect::handleContextMenuEventAxis34 (
CmdMediator *cmdMediator,
178 const QString &pointIdentifier)
187 double x = posGraphBefore.x();
188 double y = posGraphBefore.y();
199 int rtn = dlg->exec ();
201 QPointF posGraphAfter = dlg->
posGraph (isXOnly);
204 if (rtn == QDialog::Accepted) {
209 QString errorMessage;
219 QMessageBox::warning (
nullptr,
239 const QStringList &pointIdentifiers)
242 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
247 if (
context().mainWindow().transformation().transformIsDefined()) {
249 double *x =
nullptr, *y =
nullptr;
251 if (pointIdentifiers.count() == 1) {
258 QPointF posGraphBefore;
263 *x = posGraphBefore.x();
264 *y = posGraphBefore.y();
280 int rtn = dlg->exec ();
282 bool isXGiven, isYGiven;
283 double xGiven, yGiven;
284 dlg->
posGraph (isXGiven, xGiven, isYGiven, yGiven);
287 if (rtn == QDialog::Accepted) {
310 bool atLeastOneSelectedItem)
313 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
315 if (atLeastOneSelectedItem) {
317 if (key == Qt::Key_Down ||
319 key == Qt::Key_Left ||
320 key == Qt::Key_Right) {
322 keyPressArrow (cmdMediator,
343 m_movingStart = posScreen;
352 QPointF deltaScreen = posScreen - m_movingStart;
355 bool positionHasChanged = (positionHasChangedIdentifers.count () > 0);
357 if (positionHasChanged && (
358 qAbs (deltaScreen.x ()) > 0 ||
359 qAbs (deltaScreen.y ()) > 0)) {
361 QString moveText = moveTextFromDeltaScreen (deltaScreen);
368 positionHasChangedIdentifers);
377 showCoordinatesIfSinglePointIsSelected ();
381 void DigitizeStateSelect::keyPressArrow (
CmdMediator *cmdMediator,
388 deltaScreen = QPointF (0, zoomedToUnzoomedScreenY ());
393 deltaScreen = QPointF (-1 * zoomedToUnzoomedScreenX (), 0);
398 deltaScreen = QPointF (zoomedToUnzoomedScreenX (), 0);
403 deltaScreen = QPointF (0, -1 * zoomedToUnzoomedScreenY ());
423 QString DigitizeStateSelect::moveTextFromDeltaScreen (
const QPointF &deltaScreen)
432 bool downOrRight = (deltaScreen.y () > -1.0 * deltaScreen.x ());
433 bool upOrRight = (deltaScreen.y () < deltaScreen.x ());
434 if (downOrRight && upOrRight) {
436 }
else if (downOrRight && !upOrRight) {
438 }
else if (!downOrRight && upOrRight) {
447 void DigitizeStateSelect::removeHoverHighlighting()
452 QList<QGraphicsItem*>::iterator itr;
453 for (itr = items.begin (); itr != items.end (); itr++) {
455 QGraphicsItem *item = *itr;
457 item->setAcceptHoverEvents(
false);
462 double DigitizeStateSelect::scaleBarLength (
CmdMediator *cmdMediator)
const
466 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
473 QString DigitizeStateSelect::scaleBarPointIdentifier (
CmdMediator *cmdMediator)
const
477 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
484 void DigitizeStateSelect::setHoverHighlighting(
const MainWindowModel &modelMainWindow)
490 QList<QGraphicsItem*>::iterator itr;
491 for (itr = items.begin (); itr != items.end (); itr++) {
493 QGraphicsItem *item = *itr;
500 void DigitizeStateSelect::showCoordinatesIfSinglePointIsSelected ()
504 if (items.size () == 1) {
507 QGraphicsItem *item = * (items.begin ());
512 QString coordsScreen, coordsGraph, resolutionGraph;
526 return "DigitizeStateSelect";
533 addHoverHighlighting ();
547 double DigitizeStateSelect::zoomedToUnzoomedScreenX ()
const
553 double DigitizeStateSelect::zoomedToUnzoomedScreenY ()
const
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
void updateAfterMouseRelease()
Call MainWindow::updateControls (which is private) after the very specific case - a mouse press/relea...
virtual ~DigitizeStateSelect()
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
const QString MOVE_TEXT_DOWN(QObject::tr("Move down"))
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
Command for moving all selected Points by a specified translation.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
Command for editing the graph coordinates one axis point.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
Unique identifier for QGraphicsItem object
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
DigitizeStateSelect(DigitizeStateContext &context)
Single constructor.
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.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
double highlightOpacity() const
Get method for highlight opacity.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
MainWindow & mainWindow()
Reference to the MainWindow, without const.
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
bool modeMap() const
True if document scale is set using a scale bar, otherwise using axis points.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
Dialog box for editing the information of one or more points.
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
MainWindowModel modelMainWindow() const
Get method for main window model.
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
const QString MOVE_TEXT_LEFT(QObject::tr("Move left"))
void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage)
Check before calling editPointAxis.
Callback for identifying, for the scale bar of a map, various quantities.
Model for DlgSettingsMainWindow.
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Dialog box for editing the information of one axis point, in a graph with two axes.
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.
const QString MOVE_TEXT_RIGHT(QObject::tr("Move right"))
DigitizeState
Set of possible states of Digitize toolbar.
#define LOG4CPP_INFO_S(logger)
Transformation transformation() const
Return read-only copy of transformation.
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
double scaleBarLength() const
Length of scale bar.
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
Model for DlgSettingsSegments and CmdSettingsSegments.
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
QString engaugeWindowTitle()
Text for title bars of dialogs.
log4cpp::Category * mainCat
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
bool isXOnly(const QString &pointIdentifier) const
See Curve::isXOnly.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
#define LOG4CPP_DEBUG_S(logger)
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
void showTemporaryMessage(const QString &temporaryMessage)
Show temporary message in status bar.
QString QPointFToString(const QPointF &pos)
const QString MOVE_TEXT_UP(QObject::tr("Move up"))
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...
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
void posGraph(bool &isX, double &x, bool &isY, double &y) const
Return one or both coordinates. Only applies if dialog was accepted.
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
QPointF posGraph(bool &isXOnly) const
Return the graph coordinates position specified by the user. Only applies if dialog was accepted.
QString scaleBarPointIdentifier() const
Identified axis point.
Command for editing the graph coordinates of one or more graph points.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...