QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QwtFigureWidgetOverlay Class Reference

An overlay widget for QwtFigure that provides interactive manipulation. More...

#include <qwt_figure_widget_overlay.h>

Inheritance diagram for QwtFigureWidgetOverlay:
QwtWidgetOverlay

Classes

class  PrivateData
 

Public Types

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...
 
- Public Types inherited from QwtWidgetOverlay
enum  MaskMode { NoMask , MaskHint , AlphaMask }
 Mask mode. More...
 
enum  RenderMode { AutoRenderMode , CopyAlphaMask , DrawOverlay }
 Render mode. More...
 

Public Slots

void setActiveWidget (QWidget *w)
 Changes the active widget.
 
- Public Slots inherited from QwtWidgetOverlay
void updateOverlay ()
 Recalculate the mask and repaint the overlay.
 

Signals

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.
 

Public Member Functions

 QwtFigureWidgetOverlay (QwtFigure *fig)
 Constructor, passing nullptr is not allowed.
 
QwtFigurefigure () const
 Returns the associated QwtFigure.
 
void setTransparentForMouseEvents (bool on)
 Sets whether the overlay is transparent for mouse events.
 
bool isTransparentForMouseEvents () const
 Checks if the overlay is transparent for mouse events.
 
void setBuiltInFunctionsEnable (BuiltInFunctionsFlag flag, bool on=true)
 Enables or disables built-in functions.
 
bool testBuiltInFunctions (BuiltInFunctionsFlag flag) const
 Tests if a built-in function is enabled.
 
bool hasActiveWidget () const
 Checks if there is an active widget.
 
bool isResizing () const
 Checks if currently resizing.
 
void setBorderPen (const QPen &p)
 Sets the border pen.
 
QPen borderPen () const
 Returns the border pen.
 
void setControlPointBrush (const QBrush &b)
 Sets the control point brush.
 
QBrush controlPointBrush () const
 Returns the control point brush.
 
void setControlPointSize (const QSize &c)
 Sets the control point size.
 
QSize controlPointSize () const
 Returns the control point size (default 8x8)
 
void selectNextWidget (bool forward=true)
 Selects the next widget as the active widget.
 
void selectNextPlot (bool forward=true)
 Selects the next plot as the active widget.
 
QWidget * currentActiveWidget () const
 Returns the current active widget.
 
QwtPlotcurrentActivePlot () const
 Returns the current active plot.
 
void showPercentText (bool on=true)
 Shows or hides percentage text.
 
virtual bool cancel ()
 Cancels the operation, emits finished(false) signal. Override should call this explicitly.
 
- Public Member Functions inherited from QwtWidgetOverlay
 QwtWidgetOverlay (QWidget *)
 Constructor.
 
void setMaskMode (MaskMode)
 Specify how to find the mask for the overlay.
 
MaskMode maskMode () const
 
void setRenderMode (RenderMode)
 Set the render mode.
 
RenderMode renderMode () const
 
virtual bool eventFilter (QObject *, QEvent *) override
 Event filter.
 

Static Public Member Functions

static Qt::CursorShape controlTypeToCursor (ControlType rr)
 Returns the cursor shape based on control type.
 
static ControlType getPositionControlType (const QPoint &pos, const QRect &region, int err=1)
 Determines control type based on point position relative to rectangle.
 
static bool isPointInRectEdget (const QPoint &pos, const QRect &region, int err=1)
 Checks if a point is on the edge of a rectangle.
 

Protected Member Functions

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
 
- Protected Member Functions inherited from QwtWidgetOverlay
virtual void paintEvent (QPaintEvent *) override
 Paint event.
 
virtual void resizeEvent (QResizeEvent *) override
 Resize event.
 

Detailed Description

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.

Member Enumeration Documentation

◆ BuiltInFunctionsFlag

Built-in functionality flags.

Enumerator
FunSelectCurrentPlot 

Enable changing the currently selected plot.

FunResizePlot 

Enable resizing plots.

Constructor & Destructor Documentation

◆ QwtFigureWidgetOverlay()

QwtFigureWidgetOverlay::QwtFigureWidgetOverlay ( QwtFigure fig)
explicit

Constructor, passing nullptr is not allowed.

Constructor.

Parameters
[in]figThe QwtFigure to attach to
Note
Passing nullptr is not allowed

Member Function Documentation

◆ activeWidgetChanged

void QwtFigureWidgetOverlay::activeWidgetChanged ( QWidget *  oldActive,
QWidget *  newActive 
)
signal

Signal emitted when the active widget changes.

Parameters
oldActiveThe previously active widget (may be nullptr if none)
newActiveThe 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(){
...
// Explicit call to trigger finished(true)
return true;
}
virtual bool cancel()
Cancels the operation, emits finished(false) signal. Override should call this explicitly.
Definition qwt_figure_widget_overlay.cpp:394

◆ 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()

Qt::CursorShape QwtFigureWidgetOverlay::controlTypeToCursor ( QwtFigureWidgetOverlay::ControlType  rr)
static

Returns the cursor shape based on control type.

Get cursor shape based on control type.

Parameters
rrThe control type
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
painter
activeW

◆ drawControlLine()

void QwtFigureWidgetOverlay::drawControlLine ( QPainter *  painter,
const QRect &  actualRect,
const QRectF &  normRect 
) const
protectedvirtual

Draws the control line.

Draw control lines.

Parameters
painter
actualRectActual size
normRectNormalized size

◆ drawOverlay()

void QwtFigureWidgetOverlay::drawOverlay ( QPainter *  painter) const
overrideprotectedvirtual

Draw the widget overlay.

Parameters
painterPainter

Implements QwtWidgetOverlay.

◆ 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
painter
willSetNormRect

◆ figure()

QwtFigure * QwtFigureWidgetOverlay::figure ( ) const

Returns the associated QwtFigure.

Returns
The parent QwtFigure

◆ finished

void QwtFigureWidgetOverlay::finished ( bool  isCancel)
signal

Signal emitted when the operation finishes.

Parameters
isCancelWhether the operation was cancelled

◆ getPositionControlType()

QwtFigureWidgetOverlay::ControlType QwtFigureWidgetOverlay::getPositionControlType ( const QPoint &  pos,
const QRect &  region,
int  err = 1 
)
static

Determines control type based on point position relative to rectangle.

Parameters
[in]posThe point position
[in]regionThe rectangle region
[in]errThe 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]posThe point position
[in]regionThe rectangle region
[in]errThe 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]forwardTrue for forward selection, false for backward

◆ selectNextWidget()

void QwtFigureWidgetOverlay::selectNextWidget ( bool  forward = true)

Selects the next widget as the active widget.

Parameters
[in]forwardTrue for forward selection, false for backward

◆ setActiveWidget

void QwtFigureWidgetOverlay::setActiveWidget ( QWidget *  w)
slot

Changes the active widget.

Sets the current active widget.

Parameters
[in]wThe 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
[in]pThe pen to set

◆ setBuiltInFunctionsEnable()

void QwtFigureWidgetOverlay::setBuiltInFunctionsEnable ( BuiltInFunctionsFlag  flag,
bool  on = true 
)

Enables or disables built-in functions.

Parameters
[in]flagThe function flag to set
[in]onTrue to enable, false to disable
See also
QwtFigureWidgetOverlay::BuiltInFunctionsFlag

◆ setControlPointBrush()

void QwtFigureWidgetOverlay::setControlPointBrush ( const QBrush &  b)

Sets the control point brush.

Parameters
[in]bThe brush to set

◆ setControlPointSize()

void QwtFigureWidgetOverlay::setControlPointSize ( const QSize &  c)

Sets the control point size.

Parameters
[in]cThe size to set

◆ setTransparentForMouseEvents()

void QwtFigureWidgetOverlay::setTransparentForMouseEvents ( bool  on)

Sets whether the overlay is transparent for mouse events.

Parameters
[in]onTrue to make transparent, false otherwise

◆ showPercentText()

void QwtFigureWidgetOverlay::showPercentText ( bool  on = true)

Shows or hides percentage text.

Parameters
[in]onTrue to show, false to hide

◆ startResize()

void QwtFigureWidgetOverlay::startResize ( QwtFigureWidgetOverlay::ControlType  controlType,
const QPoint &  pos 
)
protected

Helper function to mark the start of resizing.

Helper function to start resizing; records the initial resize state.

Parameters
controlType
pos

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()

bool QwtFigureWidgetOverlay::testBuiltInFunctions ( BuiltInFunctionsFlag  flag) const

Tests if a built-in function is enabled.

Parameters
[in]flagThe 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
wThe widget
oldNormGeoThe old normalized geometry
newNormGeoThe new normalized geometry

The documentation for this class was generated from the following files: