26#include <QGraphicsItem>
54void DigitizeStateSelect::addHoverHighlighting()
59 QList<QGraphicsItem*>::iterator itr;
60 for (itr = items.begin (); itr != items.end (); itr++) {
62 QGraphicsItem *item = *itr;
65 item->setAcceptHoverEvents(
true);
78 addHoverHighlighting();
93 return QCursor (Qt::ArrowCursor);
100 removeHoverHighlighting();
109 const QString &pointIdentifier)
112 <<
" point=" << pointIdentifier.toLatin1 ().data ();
115 handleContextMenuEventAxis2 (cmdMediator);
117 handleContextMenuEventAxis34 (cmdMediator,
122void DigitizeStateSelect::handleContextMenuEventAxis2 (
CmdMediator *cmdMediator)
126 const bool IS_NOT_X_ONLY =
false;
130 QString pointIdentifier = scaleBarPointIdentifier (cmdMediator);
136 double scaleLength = scaleBarLength (cmdMediator);
140 context().mainWindow().modelMainWindow(),
142 int rtn = dlg->exec ();
147 if (rtn == QDialog::Accepted) {
152 QString errorMessage;
154 bool isXNonzero = (qAbs (posGraphBefore.x()) > 0);
155 QPointF posGraphAfter (isXNonzero ? scaleLength : 0,
156 isXNonzero ? 0 : scaleLength);
165 QMessageBox::warning (
nullptr,
172 CmdEditPointAxis *cmd =
new CmdEditPointAxis (
context().mainWindow(),
184void DigitizeStateSelect::handleContextMenuEventAxis34 (
CmdMediator *cmdMediator,
185 const QString &pointIdentifier)
194 double x = posGraphBefore.x();
195 double y = posGraphBefore.y();
197 DlgEditPointAxis *dlg =
new DlgEditPointAxis (
context().mainWindow(),
200 context().mainWindow().modelMainWindow(),
201 context().mainWindow().transformation(),
206 int rtn = dlg->exec ();
208 QPointF posGraphAfter = dlg->
posGraph (isXOnly);
211 if (rtn == QDialog::Accepted) {
216 QString errorMessage;
226 QMessageBox::warning (
nullptr,
233 CmdEditPointAxis *cmd =
new CmdEditPointAxis (
context().mainWindow(),
246 const QStringList &pointIdentifiers)
249 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
254 if (
context().mainWindow().transformation().transformIsDefined()) {
256 double *x =
nullptr, *y =
nullptr;
258 if (pointIdentifiers.count() == 1) {
265 QPointF posGraphBefore;
270 *x = posGraphBefore.x();
271 *y = posGraphBefore.y();
277 context().mainWindow().modelMainWindow(),
278 context().mainWindow().transformation(),
287 int rtn = dlg->exec ();
289 bool isXGiven, isYGiven;
290 double xGiven, yGiven;
291 dlg->
posGraph (isXGiven, xGiven, isYGiven, yGiven);
294 if (rtn == QDialog::Accepted) {
317 bool atLeastOneSelectedItem)
320 <<
" key=" << QKeySequence (key).toString ().toLatin1 ().data ();
322 if (atLeastOneSelectedItem) {
324 if (key == Qt::Key_Down ||
326 key == Qt::Key_Left ||
327 key == Qt::Key_Right) {
329 keyPressArrow (cmdMediator,
350 m_movingStart = posScreen;
359 QPointF deltaScreen = posScreen - m_movingStart;
362 bool positionHasChanged = (positionHasChangedIdentifers.count () > 0);
364 if (positionHasChanged && (
365 qAbs (deltaScreen.x ()) > 0 ||
366 qAbs (deltaScreen.y ()) > 0)) {
368 QString moveText = moveTextFromDeltaScreen (deltaScreen);
375 positionHasChangedIdentifers);
384 showCoordinatesIfSinglePointIsSelected ();
388void DigitizeStateSelect::keyPressArrow (
CmdMediator *cmdMediator,
395 deltaScreen = QPointF (0, zoomedToUnzoomedScreenY ());
400 deltaScreen = QPointF (-1 * zoomedToUnzoomedScreenX (), 0);
405 deltaScreen = QPointF (zoomedToUnzoomedScreenX (), 0);
410 deltaScreen = QPointF (0, -1 * zoomedToUnzoomedScreenY ());
419 GraphicsItemsExtractor graphicsItemsExtractor;
421 CmdMoveBy *cmd =
new CmdMoveBy (
context().mainWindow(),
430QString DigitizeStateSelect::moveTextFromDeltaScreen (
const QPointF &deltaScreen)
439 bool downOrRight = (deltaScreen.y () > -1.0 * deltaScreen.x ());
440 bool upOrRight = (deltaScreen.y () < deltaScreen.x ());
441 if (downOrRight && upOrRight) {
443 }
else if (downOrRight && !upOrRight) {
445 }
else if (!downOrRight && upOrRight) {
454void DigitizeStateSelect::removeHoverHighlighting()
459 QList<QGraphicsItem*>::iterator itr;
460 for (itr = items.begin (); itr != items.end (); itr++) {
462 QGraphicsItem *item = *itr;
465 item->setAcceptHoverEvents(
false);
470double DigitizeStateSelect::scaleBarLength (
CmdMediator *cmdMediator)
const
472 CallbackScaleBar ftor;
474 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
481QString DigitizeStateSelect::scaleBarPointIdentifier (
CmdMediator *cmdMediator)
const
483 CallbackScaleBar ftor;
485 Functor2wRet<const QString &, const Point&, CallbackSearchReturn> ftorWithCallback = functor_ret (ftor,
492void DigitizeStateSelect::setHoverHighlighting(
const MainWindowModel &modelMainWindow)
498 QList<QGraphicsItem*>::iterator itr;
499 for (itr = items.begin (); itr != items.end (); itr++) {
501 QGraphicsItem *item = *itr;
508void DigitizeStateSelect::showCoordinatesIfSinglePointIsSelected ()
512 if (items.size () == 1) {
515 QGraphicsItem *item = * (items.begin ());
520 QString coordsScreen, coordsGraph, resolutionGraph;
525 context().mainWindow().modeMap());
534 return "DigitizeStateSelect";
541 addHoverHighlighting ();
555double DigitizeStateSelect::zoomedToUnzoomedScreenX ()
const
561double DigitizeStateSelect::zoomedToUnzoomedScreenY ()
const
@ DATA_KEY_GRAPHICS_ITEM_TYPE
DigitizeState
Set of possible states of Digitize toolbar.
const QString MOVE_TEXT_UP(QObject::tr("Move up"))
const QString MOVE_TEXT_DOWN(QObject::tr("Move down"))
const QString MOVE_TEXT_LEFT(QObject::tr("Move left"))
const QString MOVE_TEXT_RIGHT(QObject::tr("Move right"))
@ DOCUMENT_AXES_POINTS_REQUIRED_2
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
@ GRAPHICS_ITEM_TYPE_GUIDELINE
@ GRAPHICS_ITEM_TYPE_POINT
log4cpp::Category * mainCat
QString QPointFToString(const QPointF &pos)
QString engaugeWindowTitle()
Text for title bars of dialogs.
QString scaleBarPointIdentifier() const
Identified axis point.
double scaleBarLength() const
Length of scale bar.
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Command for editing the graph coordinates of one or more graph points.
Command for moving all selected Points by a specified translation.
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 void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
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 updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
virtual ~DigitizeStateSelect()
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
Update the digitize curve settings.
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
virtual bool guidelinesAreSelectable() const
Enable/disable guidelines according to state.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release 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.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
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 handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
DigitizeStateSelect(DigitizeStateContext &context)
Single constructor.
virtual QString state() const
State name for debugging.
QPointF posGraph(bool &isXOnly) const
Return the graph coordinates position specified by the user. Only applies if dialog was accepted.
Dialog box for editing the information of one or more points.
void posGraph(bool &isX, double &x, bool &isY, double &y) const
Return one or both coordinates. Only applies if dialog was accepted.
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.
QPointF positionScreen(const QString &pointIdentifier) const
See Curve::positionScreen.
DocumentModelGeneral modelGeneral() const
Get method for DocumentModelGeneral.
QPointF positionGraph(const QString &pointIdentifier) const
See Curve::positionGraph.
bool isXOnly(const QString &pointIdentifier) const
See Curve::isXOnly.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
void checkEditPointAxis(const QString &pointIdentifier, const QPointF &posScreen, const QPointF &posGraph, bool &isError, QString &errorMessage)
Check before calling editPointAxis.
DocumentAxesPointsRequired documentAxesPointsRequired() const
Get method for DocumentAxesPointsRequired.
QStringList positionHasChangedPointIdentifiers() const
Return a list of identifiers for the points that have moved since the last call to resetPositionHasCh...
Model for DlgSettingsMainWindow.
double highlightOpacity() const
Get method for highlight opacity.
void showTemporaryMessage(const QString &temporaryMessage)
Show temporary message in status bar.
CmdMediator * cmdMediator()
Accessor for commands to process the Document.
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.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
void updateAfterMouseRelease()
Call MainWindow::updateControls (which is private) after the very specific case - a mouse press/relea...
Transformation transformation() const
Return read-only copy of transformation.
GraphicsView & view()
View for the QImage and QGraphicsItems, without const.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)