QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsmapcanvastracer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapcanvastracer.h
3  ---------------------
4  begin : January 2016
5  copyright : (C) 2016 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSMAPCANVASTRACER_H
16 #define QGSMAPCANVASTRACER_H
17 
18 #include "qgstracer.h"
19 #include "qgis_gui.h"
20 
21 class QAction;
22 class QgsMapCanvas;
23 class QgsMessageBar;
24 class QgsMessageBarItem;
25 
41 class GUI_EXPORT QgsMapCanvasTracer : public QgsTracer
42 {
43  Q_OBJECT
44 
45  public:
47  explicit QgsMapCanvasTracer( QgsMapCanvas *canvas, QgsMessageBar *messageBar = nullptr );
48  ~QgsMapCanvasTracer() override;
49 
51  QAction *actionEnableTracing() const { return mActionEnableTracing; }
52 
57  void setActionEnableTracing( QAction *action ) { mActionEnableTracing = action; }
58 
63  QAction *actionEnableSnapping() const { return mActionEnableSnapping; }
64 
70  void setActionEnableSnapping( QAction *action ) { mActionEnableSnapping = action; }
71 
77  static QgsMapCanvasTracer *tracerForCanvas( QgsMapCanvas *canvas );
78 
80  void reportError( PathError err, bool addingVertex );
81 
82  protected:
84  void configure() override;
85 
86  private slots:
87  void onCurrentLayerChanged();
88 
89  private:
90  QgsMapCanvas *mCanvas = nullptr;
91  QgsMessageBar *mMessageBar = nullptr;
92  QgsMessageBarItem *mLastMessage = nullptr;
93 
94  QAction *mActionEnableTracing = nullptr;
95  QAction *mActionEnableSnapping = nullptr;
96 };
97 
98 #endif // QGSMAPCANVASTRACER_H
QgsTracer
Definition: qgstracer.h:43
QgsMapCanvasTracer::setActionEnableTracing
void setActionEnableTracing(QAction *action)
Assign "enable tracing" checkable action to the tracer.
Definition: qgsmapcanvastracer.h:57
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsMapCanvasTracer::actionEnableTracing
QAction * actionEnableTracing() const
Access to action that user may use to toggle tracing on/off. May be nullptr if no action was associat...
Definition: qgsmapcanvastracer.h:51
QgsMessageBarItem
Definition: qgsmessagebaritem.h:38
QgsMapCanvasTracer
Definition: qgsmapcanvastracer.h:41
QgsMessageBar
Definition: qgsmessagebar.h:60
QgsMapCanvasTracer::actionEnableSnapping
QAction * actionEnableSnapping() const
Access to action that user may use to toggle snapping on/off.
Definition: qgsmapcanvastracer.h:63
QgsMapCanvasTracer::setActionEnableSnapping
void setActionEnableSnapping(QAction *action)
Assign "enable snapping" checkable action to the tracer.
Definition: qgsmapcanvastracer.h:70
QgsTracer::configure
virtual void configure()
Allows derived classes to setup the settings just before the tracer is initialized.
Definition: qgstracer.h:158
qgstracer.h