QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Abstract base class for all interactive plot tools. More...
#include <qgsplottool.h>
Signals | |
void | activated () |
Emitted when the tool is activated. | |
void | deactivated () |
Emitted when the tool is deactivated. | |
Public Member Functions | |
~QgsPlotTool () override | |
QAction * | action () |
Returns the action associated with the tool or nullptr if no action is associated. | |
virtual void | activate () |
Called when the tool is set as the currently active plot tool. | |
QgsPlotCanvas * | canvas () const |
Returns the tool's plot canvas. | |
virtual bool | canvasToolTipEvent (QHelpEvent *event) |
Tooltip event for overriding. | |
virtual void | deactivate () |
Called when the tool is being deactivated. | |
virtual Qgis::PlotToolFlags | flags () const |
Returns the flags for the plot tool. | |
virtual bool | gestureEvent (QGestureEvent *event) |
Gesture event for overriding. | |
bool | isActive () const |
Returns true if this tool is the current tool active on the plot canvas. | |
virtual void | keyPressEvent (QKeyEvent *event) |
Key press event for overriding. | |
virtual void | keyReleaseEvent (QKeyEvent *event) |
Key release event for overriding. | |
virtual void | plotDoubleClickEvent (QgsPlotMouseEvent *event) |
Mouse double-click event for overriding. | |
virtual void | plotMoveEvent (QgsPlotMouseEvent *event) |
Mouse move event for overriding. | |
virtual void | plotPressEvent (QgsPlotMouseEvent *event) |
Mouse press event for overriding. | |
virtual void | plotReleaseEvent (QgsPlotMouseEvent *event) |
Mouse release event for overriding. | |
virtual bool | populateContextMenuWithEvent (QMenu *menu, QgsPlotMouseEvent *event) |
Allows the tool to populate and customize the given menu, prior to showing it in response to a right-mouse button click. | |
void | setAction (QAction *action) |
Associates an action with this tool. | |
void | setCursor (const QCursor &cursor) |
Sets a user defined cursor for use when the tool is active. | |
QString | toolName () const |
Returns a user-visible, translated name for the tool. | |
virtual void | wheelEvent (QWheelEvent *event) |
Mouse wheel event for overriding. | |
Protected Member Functions | |
QgsPlotTool (QgsPlotCanvas *canvas, const QString &name) | |
Constructor takes a plot canvas as a parameter. | |
bool | isClickAndDrag (QPoint startViewPoint, QPoint endViewPoint) const |
Returns true if a mouse press/release operation which started at startViewPoint and ended at endViewPoint should be considered a "click and drag". | |
QgsPointXY | toCanvasCoordinates (const QgsPoint &point) const |
Converts a point in map coordinates to the associated canvas point. | |
QgsPoint | toMapCoordinates (const QgsPointXY &point) const |
Converts a point on the canvas to the associated map coordinate. | |
Static Protected Member Functions | |
static QPointF | constrainPointToRect (QPointF point, const QRectF &rect) |
Constrains a point to force it to fall within the specified rectangle. | |
Protected Attributes | |
QPointer< QAction > | mAction |
Optional action associated with tool. | |
QgsPlotCanvas * | mCanvas = nullptr |
The pointer to the canvas. | |
QCursor | mCursor = Qt::ArrowCursor |
Cursor used by tool. | |
QString | mToolName |
Translated name of the map tool. | |
Abstract base class for all interactive plot tools.
Plot tools are user tools for manipulating and interacting with a QgsPlotCanvas.
Definition at line 57 of file qgsplottool.h.
|
override |
Definition at line 69 of file qgsplottool.cpp.
|
protected |
Constructor takes a plot canvas as a parameter.
Definition at line 26 of file qgsplottool.cpp.
QAction * QgsPlotTool::action | ( | ) |
Returns the action associated with the tool or nullptr
if no action is associated.
Definition at line 158 of file qgsplottool.cpp.
|
virtual |
Called when the tool is set as the currently active plot tool.
Reimplemented in QgsPlotToolTemporaryKeyPan, QgsPlotToolTemporaryMousePan, and QgsPlotToolTemporaryKeyZoom.
Definition at line 80 of file qgsplottool.cpp.
|
signal |
Emitted when the tool is activated.
QgsPlotCanvas * QgsPlotTool::canvas | ( | ) | const |
Returns the tool's plot canvas.
Definition at line 148 of file qgsplottool.cpp.
|
virtual |
Tooltip event for overriding.
Returns true
if the event was handled by the tool and should not be propagated further.
Definition at line 143 of file qgsplottool.cpp.
|
staticprotected |
Constrains a point to force it to fall within the specified rectangle.
Definition at line 54 of file qgsplottool.cpp.
|
virtual |
Called when the tool is being deactivated.
Reimplemented in QgsPlotToolPan, and QgsPlotToolZoom.
Definition at line 90 of file qgsplottool.cpp.
|
signal |
Emitted when the tool is deactivated.
|
virtual |
Returns the flags for the plot tool.
Reimplemented in QgsPlotToolPan.
Definition at line 75 of file qgsplottool.cpp.
|
virtual |
Gesture event for overriding.
Returns true
if the event was handled by the tool and should not be propagated further.
Definition at line 138 of file qgsplottool.cpp.
bool QgsPlotTool::isActive | ( | ) | const |
Returns true
if this tool is the current tool active on the plot canvas.
Definition at line 98 of file qgsplottool.cpp.
|
protected |
Returns true
if a mouse press/release operation which started at startViewPoint and ended at endViewPoint should be considered a "click and drag".
If false
is returned, the operation should be instead treated as just a click on startViewPoint.
Definition at line 47 of file qgsplottool.cpp.
|
virtual |
Key press event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Reimplemented in QgsPlotToolZoom, and QgsPlotToolTemporaryKeyZoom.
Definition at line 128 of file qgsplottool.cpp.
|
virtual |
Key release event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Reimplemented in QgsPlotToolZoom, QgsPlotToolTemporaryKeyPan, and QgsPlotToolTemporaryKeyZoom.
Definition at line 133 of file qgsplottool.cpp.
|
virtual |
Mouse double-click event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Definition at line 108 of file qgsplottool.cpp.
|
virtual |
Mouse move event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Reimplemented in QgsPlotToolPan, QgsPlotToolZoom, QgsPlotToolTemporaryKeyPan, and QgsPlotToolTemporaryMousePan.
Definition at line 103 of file qgsplottool.cpp.
|
virtual |
Mouse press event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Reimplemented in QgsPlotToolPan, and QgsPlotToolZoom.
Definition at line 113 of file qgsplottool.cpp.
|
virtual |
Mouse release event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Reimplemented in QgsPlotToolPan, QgsPlotToolZoom, QgsPlotToolTemporaryMousePan, and QgsPlotToolTemporaryKeyZoom.
Definition at line 118 of file qgsplottool.cpp.
|
virtual |
Allows the tool to populate and customize the given menu, prior to showing it in response to a right-mouse button click.
menu will be initially populated with a set of default, generic actions. Any new actions added to the menu should be correctly parented to menu.
A pointer to the plot mouse event can be provided to allow particular behavior depending on the plot tool.
This method can return true
to inform the caller that the menu was effectively populated.
The default implementation does nothing and returns false
.
Definition at line 168 of file qgsplottool.cpp.
void QgsPlotTool::setAction | ( | QAction * | action | ) |
Associates an action with this tool.
When the setTool method of QgsPlotCanvas is called the action's state will be set to on. Usually this will cause a toolbutton to appear pressed in and the previously used toolbutton to pop out.
Definition at line 153 of file qgsplottool.cpp.
void QgsPlotTool::setCursor | ( | const QCursor & | cursor | ) |
Sets a user defined cursor for use when the tool is active.
Definition at line 163 of file qgsplottool.cpp.
|
protected |
Converts a point in map coordinates to the associated canvas point.
May return an empty point if the map point cannot be converted to a canvas point.
Definition at line 42 of file qgsplottool.cpp.
|
protected |
Converts a point on the canvas to the associated map coordinate.
May return an empty point if the canvas point cannot be converted to a map point.
Definition at line 37 of file qgsplottool.cpp.
|
inline |
Returns a user-visible, translated name for the tool.
Definition at line 87 of file qgsplottool.h.
|
virtual |
Mouse wheel event for overriding.
The default implementation does nothing. When subclasses implement this method and have acted on the event, they must explicitly call event->accept() to prevent the event from being passed on to other widgets.
Definition at line 123 of file qgsplottool.cpp.
|
protected |
Optional action associated with tool.
Definition at line 273 of file qgsplottool.h.
|
protected |
The pointer to the canvas.
Definition at line 267 of file qgsplottool.h.
|
protected |
Cursor used by tool.
Definition at line 276 of file qgsplottool.h.
|
protected |
Translated name of the map tool.
Definition at line 270 of file qgsplottool.h.