An overlay widget for QwtFigure that provides interactive manipulation.
More...
#include <qwt_figure_widget_overlay.h>
|
| enum | ControlType {
ControlLineTop
, ControlLineBottom
, ControlLineLeft
, ControlLineRight
,
ControlPointTopLeft
, ControlPointTopRight
, ControlPointBottomLeft
, ControlPointBottomRight
,
Inner
, OutSide
} |
| | Enum for marking rectangular control regions.
|
| |
| enum | BuiltInFunctionsFlag { FunSelectCurrentPlot = 1
, FunResizePlot = 2
} |
| | Built-in functionality flags. More...
|
| |
| enum | MaskMode { NoMask
, MaskHint
, AlphaMask
} |
| | Mask mode. More...
|
| |
| enum | RenderMode { AutoRenderMode
, CopyAlphaMask
, DrawOverlay
} |
| | Render mode. More...
|
| |
|
| void | setActiveWidget (QWidget *w) |
| | Changes the active widget.
|
| |
|
void | updateOverlay () |
| | Recalculate the mask and repaint the overlay.
|
| |
|
| void | widgetNormGeometryChanged (QWidget *w, const QRectF &oldNormGeo, const QRectF &newNormGeo) |
| | Signal emitted when widget normalized geometry changes.
|
| |
| void | activeWidgetChanged (QWidget *oldActive, QWidget *newActive) |
| | Signal emitted when the active widget changes.
|
| |
| void | finished (bool isCancel) |
| | Signal emitted when the operation finishes.
|
| |
|
| virtual void | drawOverlay (QPainter *p) const override |
| | Draw the widget overlay.
|
| |
| virtual QRegion | maskHint () const override |
| | Calculate an approximation for the mask.
|
| |
| virtual void | drawActiveWidget (QPainter *painter, QWidget *activeW) const |
| | Draws the active widget.
|
| |
| virtual void | drawResizeingControlLine (QPainter *painter, const QRectF &willSetNormRect) const |
| | Draws the resizing rubber-band control line.
|
| |
| virtual void | drawControlLine (QPainter *painter, const QRect &actualRect, const QRectF &normRect) const |
| | Draws the control line.
|
| |
| void | startResize (ControlType controlType, const QPoint &pos) |
| | Helper function to mark the start of resizing.
|
| |
|
void | mouseMoveEvent (QMouseEvent *me) override |
| |
| void | mouseReleaseEvent (QMouseEvent *me) override |
| |
|
void | mousePressEvent (QMouseEvent *me) override |
| |
|
void | keyPressEvent (QKeyEvent *ke) override |
| |
| virtual void | paintEvent (QPaintEvent *) override |
| | Paint event.
|
| |
| virtual void | resizeEvent (QResizeEvent *) override |
| | Resize event.
|
| |
An overlay widget for QwtFigure that provides interactive manipulation.
This class provides functionality for resizing child widgets within a figure window and changing the currently active plot. You can extend this class to implement additional operations.
- Note
- QwtFigureWidgetOverlay does not directly modify sizes. Size changes are performed in the managing window, allowing greater flexibility such as implementing undo/redo functionality.
◆ BuiltInFunctionsFlag
Built-in functionality flags.
| Enumerator |
|---|
| FunSelectCurrentPlot | Enable changing the currently selected plot.
|
| FunResizePlot | Enable resizing plots.
|
◆ QwtFigureWidgetOverlay()
| QwtFigureWidgetOverlay::QwtFigureWidgetOverlay |
( |
QwtFigure * |
fig | ) |
|
|
explicit |
Constructor, passing nullptr is not allowed.
Constructor.
- Parameters
-
- Note
- Passing nullptr is not allowed
◆ activeWidgetChanged
| void QwtFigureWidgetOverlay::activeWidgetChanged |
( |
QWidget * |
oldActive, |
|
|
QWidget * |
newActive |
|
) |
| |
|
signal |
Signal emitted when the active widget changes.
- Parameters
-
| oldActive | The previously active widget (may be nullptr if none) |
| newActive | The newly active widget (may be nullptr if none) |
◆ borderPen()
| QPen QwtFigureWidgetOverlay::borderPen |
( |
| ) |
const |
Returns the border pen.
- Returns
- The current border pen
◆ cancel()
| bool QwtFigureWidgetOverlay::cancel |
( |
| ) |
|
|
virtual |
Cancels the operation, emits finished(false) signal. Override should call this explicitly.
Cancels the operation.
- Returns
- True on success
- Note
- This function emits finished(true) signal. Override should call this explicitly.
bool MyFigureWidgetOverlay::cancel(){
...
return true;
}
◆ controlPointBrush()
| QBrush QwtFigureWidgetOverlay::controlPointBrush |
( |
| ) |
const |
Returns the control point brush.
- Returns
- The current control point brush
◆ controlPointSize()
| QSize QwtFigureWidgetOverlay::controlPointSize |
( |
| ) |
const |
Returns the control point size (default 8x8)
Returns the control point size.
- Returns
- The current control point size (default 8x8)
◆ controlTypeToCursor()
Returns the cursor shape based on control type.
Get cursor shape based on control type.
- Parameters
-
- Returns
- The cursor shape
◆ currentActivePlot()
| QwtPlot * QwtFigureWidgetOverlay::currentActivePlot |
( |
| ) |
const |
Returns the current active plot.
- Returns
- The current active plot, nullptr if none or not a plot
◆ currentActiveWidget()
| QWidget * QwtFigureWidgetOverlay::currentActiveWidget |
( |
| ) |
const |
Returns the current active widget.
- Returns
- The current active widget, nullptr if none
◆ drawActiveWidget()
| void QwtFigureWidgetOverlay::drawActiveWidget |
( |
QPainter * |
painter, |
|
|
QWidget * |
activeW |
|
) |
| const |
|
protectedvirtual |
Draws the active widget.
Draw the active widget.
Override this function to change the drawing style. Default drawing calls drawControlLine.
- Parameters
-
◆ drawControlLine()
| void QwtFigureWidgetOverlay::drawControlLine |
( |
QPainter * |
painter, |
|
|
const QRect & |
actualRect, |
|
|
const QRectF & |
normRect |
|
) |
| const |
|
protectedvirtual |
Draws the control line.
Draw control lines.
- Parameters
-
| painter | |
| actualRect | Actual size |
| normRect | Normalized size |
◆ drawOverlay()
| void QwtFigureWidgetOverlay::drawOverlay |
( |
QPainter * |
painter | ) |
const |
|
overrideprotectedvirtual |
◆ drawResizeingControlLine()
| void QwtFigureWidgetOverlay::drawResizeingControlLine |
( |
QPainter * |
painter, |
|
|
const QRectF & |
willSetNormRect |
|
) |
| const |
|
protectedvirtual |
Draws the resizing rubber-band control line.
Draw the rubber-band control lines during resize.
Override this function to change the drawing style. Default drawing calls drawControlLine.
- Parameters
-
◆ figure()
| QwtFigure * QwtFigureWidgetOverlay::figure |
( |
| ) |
const |
◆ finished
| void QwtFigureWidgetOverlay::finished |
( |
bool |
isCancel | ) |
|
|
signal |
Signal emitted when the operation finishes.
- Parameters
-
| isCancel | Whether the operation was cancelled |
◆ getPositionControlType()
Determines control type based on point position relative to rectangle.
- Parameters
-
| [in] | pos | The point position |
| [in] | region | The rectangle region |
| [in] | err | The error tolerance |
- Returns
- The control type at the given position
◆ hasActiveWidget()
| bool QwtFigureWidgetOverlay::hasActiveWidget |
( |
| ) |
const |
Checks if there is an active widget.
- Returns
- True if there is an active widget, false otherwise
◆ isPointInRectEdget()
| bool QwtFigureWidgetOverlay::isPointInRectEdget |
( |
const QPoint & |
pos, |
|
|
const QRect & |
region, |
|
|
int |
err = 1 |
|
) |
| |
|
static |
Checks if a point is on the edge of a rectangle.
- Parameters
-
| [in] | pos | The point position |
| [in] | region | The rectangle region |
| [in] | err | The error tolerance |
- Returns
- True if the point is on the edge
◆ isResizing()
| bool QwtFigureWidgetOverlay::isResizing |
( |
| ) |
const |
Checks if currently resizing.
- Returns
- True if resizing, false otherwise
◆ isTransparentForMouseEvents()
| bool QwtFigureWidgetOverlay::isTransparentForMouseEvents |
( |
| ) |
const |
Checks if the overlay is transparent for mouse events.
- Returns
- True if transparent, false otherwise
◆ maskHint()
| QRegion QwtFigureWidgetOverlay::maskHint |
( |
| ) |
const |
|
overrideprotectedvirtual |
Calculate an approximation for the mask.
- MaskHint The hint is used as mask.
- AlphaMask The hint is used to speed up the algorithm for calculating a mask from non transparent pixels
- NoMask The hint is unused.
The default implementation returns an invalid region indicating no hint.
- Returns
- Hint for the mask
Reimplemented from QwtWidgetOverlay.
◆ mouseReleaseEvent()
| void QwtFigureWidgetOverlay::mouseReleaseEvent |
( |
QMouseEvent * |
me | ) |
|
|
overrideprotected |
Must release mouse since it was captured in startResize
◆ selectNextPlot()
| void QwtFigureWidgetOverlay::selectNextPlot |
( |
bool |
forward = true | ) |
|
Selects the next plot as the active widget.
- Parameters
-
| [in] | forward | True for forward selection, false for backward |
◆ selectNextWidget()
| void QwtFigureWidgetOverlay::selectNextWidget |
( |
bool |
forward = true | ) |
|
Selects the next widget as the active widget.
- Parameters
-
| [in] | forward | True for forward selection, false for backward |
◆ setActiveWidget
| void QwtFigureWidgetOverlay::setActiveWidget |
( |
QWidget * |
w | ) |
|
|
slot |
Changes the active widget.
Sets the current active widget.
- Parameters
-
| [in] | w | The widget to set as active |
- Note
- If w is the same as current active widget, no action is taken
-
This function emits activeWidgetChanged signal
- See also
- activeWidgetChanged
◆ setBorderPen()
| void QwtFigureWidgetOverlay::setBorderPen |
( |
const QPen & |
p | ) |
|
Sets the border pen.
- Parameters
-
◆ setBuiltInFunctionsEnable()
| void QwtFigureWidgetOverlay::setBuiltInFunctionsEnable |
( |
BuiltInFunctionsFlag |
flag, |
|
|
bool |
on = true |
|
) |
| |
◆ setControlPointBrush()
| void QwtFigureWidgetOverlay::setControlPointBrush |
( |
const QBrush & |
b | ) |
|
Sets the control point brush.
- Parameters
-
◆ setControlPointSize()
| void QwtFigureWidgetOverlay::setControlPointSize |
( |
const QSize & |
c | ) |
|
Sets the control point size.
- Parameters
-
◆ setTransparentForMouseEvents()
| void QwtFigureWidgetOverlay::setTransparentForMouseEvents |
( |
bool |
on | ) |
|
Sets whether the overlay is transparent for mouse events.
- Parameters
-
| [in] | on | True to make transparent, false otherwise |
◆ showPercentText()
| void QwtFigureWidgetOverlay::showPercentText |
( |
bool |
on = true | ) |
|
Shows or hides percentage text.
- Parameters
-
| [in] | on | True to show, false to hide |
◆ startResize()
Helper function to mark the start of resizing.
Helper function to start resizing; records the initial resize state.
- Parameters
-
Capture the mouse to ensure all mouse events are sent to this widget. This is critical to prevent mouse events from being captured by other widgets during mouse movement, which would cause the release event to be missed. grabMouse will:
- Force all mouse events (move, click, release, etc.) to be sent to this widget
- Ignore the actual mouse position, even if the mouse moves to other widgets or screen edges
- Ensure the integrity of the mouse event chain This MUST be paired with releaseMouse (called in mouseReleaseEvent).
Without this function, if the mouse moves over underlying plot widgets or other child widgets, mouse events may be intercepted by those widgets, causing QwtFigureWidgetOverlay to miss mouseReleaseEvent and leaving the state stuck in "resizing".
◆ testBuiltInFunctions()
Tests if a built-in function is enabled.
- Parameters
-
| [in] | flag | The function flag to test |
- Returns
- True if enabled, false otherwise
◆ widgetNormGeometryChanged
| void QwtFigureWidgetOverlay::widgetNormGeometryChanged |
( |
QWidget * |
w, |
|
|
const QRectF & |
oldNormGeo, |
|
|
const QRectF & |
newNormGeo |
|
) |
| |
|
signal |
Signal emitted when widget normalized geometry changes.
- Parameters
-
| w | The widget |
| oldNormGeo | The old normalized geometry |
| newNormGeo | The new normalized geometry |
The documentation for this class was generated from the following files: