QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
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 68 of file qgsplottool.cpp.
|
protected |
Constructor takes a plot canvas as a parameter.
Definition at line 25 of file qgsplottool.cpp.
QAction * QgsPlotTool::action | ( | ) |
Returns the action associated with the tool or nullptr
if no action is associated.
Definition at line 157 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 79 of file qgsplottool.cpp.
|
signal |
Emitted when the tool is activated.
QgsPlotCanvas * QgsPlotTool::canvas | ( | ) | const |
Returns the tool's plot canvas.
Definition at line 147 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 142 of file qgsplottool.cpp.
|
staticprotected |
Constrains a point to force it to fall within the specified rectangle.
Definition at line 53 of file qgsplottool.cpp.
|
virtual |
Called when the tool is being deactivated.
Reimplemented in QgsPlotToolPan, and QgsPlotToolZoom.
Definition at line 89 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 74 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 137 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 97 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 46 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 127 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 132 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 107 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 102 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 112 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 117 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 167 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 152 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 162 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 41 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 36 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 122 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.