QWT API (English) 7.0.1
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 . More...
 
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 }
 

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.
 
virtual ~QwtWidgetOverlay ()
 Destructor .
 
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.

Member Enumeration Documentation

◆ BuiltInFunctionsFlag

Built-in functionality flags .

Enumerator
FunSelectCurrentPlot 

Enable changing the currently selected plot.

FunResizePlot 

Enable resizing plots.

◆ ControlType

Enum for marking rectangular control regions .

Constructor & Destructor Documentation

◆ QwtFigureWidgetOverlay()

QwtFigureWidgetOverlay::QwtFigureWidgetOverlay ( QwtFigure fig)
explicit

Constructor, passing nullptr is not allowed.

Constructor.

Member Function Documentation

◆ activeWidgetChanged

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

Signal emitted when the active widget changes.

◆ borderPen()

QPen QwtFigureWidgetOverlay::borderPen ( ) const

Returns the border pen.

◆ cancel()

bool QwtFigureWidgetOverlay::cancel ( )
virtual

Cancels the operation, emits finished(false) signal. Override should call this explicitly.

Cancels the operation.

◆ controlPointBrush()

QBrush QwtFigureWidgetOverlay::controlPointBrush ( ) const

Returns the control point brush.

◆ controlPointSize()

QSize QwtFigureWidgetOverlay::controlPointSize ( ) const

Returns the control point size (default 8x8)

Returns the control point size.

◆ controlTypeToCursor()

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

Returns the cursor shape based on control type.

根据范围获取鼠标图标

Parameters
rr
Returns
鼠标图标

◆ currentActivePlot()

QwtPlot * QwtFigureWidgetOverlay::currentActivePlot ( ) const

Returns the current active plot.

◆ currentActiveWidget()

QWidget * QwtFigureWidgetOverlay::currentActiveWidget ( ) const

Returns the current active widget.

◆ drawActiveWidget()

void QwtFigureWidgetOverlay::drawActiveWidget ( QPainter *  painter,
QWidget *  activeW 
) const
protectedvirtual

Draws the active widget.

绘制激活的窗口

通过继承此函数可改变绘制的方式,默认绘制会调用drawControlLine 函数

Parameters
painter
activeW

◆ drawControlLine()

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

Draws the control line.

绘制控制线

Parameters
painter
actualRect真实尺寸
normRect归一化尺寸

◆ 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.

绘制resize变换的橡皮筋控制线

通过继承此函数可改变绘制的方式,默认绘制会调用drawControlLine 函数

Parameters
painter
willSetNormRect

◆ figure()

QwtFigure * QwtFigureWidgetOverlay::figure ( ) const

Returns the associated QwtFigure.

◆ finished

void QwtFigureWidgetOverlay::finished ( bool  isCancel)
signal

Signal emitted when the operation finishes.

◆ 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.

◆ hasActiveWidget()

bool QwtFigureWidgetOverlay::hasActiveWidget ( ) const

Checks if there is an active widget.

◆ 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.

◆ isResizing()

bool QwtFigureWidgetOverlay::isResizing ( ) const

Checks if currently resizing.

◆ isTransparentForMouseEvents()

bool QwtFigureWidgetOverlay::isTransparentForMouseEvents ( ) const

Checks if the overlay is transparent for mouse events.

◆ 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

由于在startResize时捕获了鼠标,因此,这里必须释放鼠标

◆ selectNextPlot()

void QwtFigureWidgetOverlay::selectNextPlot ( bool  forward = true)

Selects the next plot as the active widget.

◆ selectNextWidget()

void QwtFigureWidgetOverlay::selectNextWidget ( bool  forward = true)

Selects the next widget as the active widget.

◆ setActiveWidget

void QwtFigureWidgetOverlay::setActiveWidget ( QWidget *  w)
slot

Changes the active widget.

Sets the current active widget.

◆ setBorderPen()

void QwtFigureWidgetOverlay::setBorderPen ( const QPen &  p)

Sets the border pen.

◆ setBuiltInFunctionsEnable()

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

Enables or disables built-in functions.

◆ setControlPointBrush()

void QwtFigureWidgetOverlay::setControlPointBrush ( const QBrush &  b)

Sets the control point brush.

◆ setControlPointSize()

void QwtFigureWidgetOverlay::setControlPointSize ( const QSize &  c)

Sets the control point size.

◆ setTransparentForMouseEvents()

void QwtFigureWidgetOverlay::setTransparentForMouseEvents ( bool  on)

Sets whether the overlay is transparent for mouse events.

◆ showPercentText()

void QwtFigureWidgetOverlay::showPercentText ( bool  on = true)

Shows or hides percentage text.

◆ startResize()

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

Helper function to mark the start of resizing.

开始变换的辅助函数,此函数会记录开始变换的状态

Parameters
controlType
pos

捕获鼠标,确保所有鼠标事件都发送到这个窗口 这个函数是关键,避免鼠标移动的时候被别的窗口捕获掉鼠标,导致无法接收到release事件 grabMouse可以:

  • 强制所有鼠标事件(移动、点击、释放等)都发送到调用该函数的窗口部件
  • 忽略鼠标的实际位置,即使鼠标移到了其他窗口或屏幕边缘
  • 确保鼠标事件链的完整性 此函数一定要releaseMouse,(releaseMouse在mouseReleaseEvent执行)

如果没有这个函数,鼠标移动到了底层绘图窗口或其他子窗口上,鼠标事件可能被这些窗口截获 QwtFigureWidgetOverlay收不到 mouseReleaseEvent,导致状态卡在"调整中"

◆ testBuiltInFunctions()

bool QwtFigureWidgetOverlay::testBuiltInFunctions ( BuiltInFunctionsFlag  flag) const

Tests if a built-in function is enabled.

◆ widgetNormGeometryChanged

void QwtFigureWidgetOverlay::widgetNormGeometryChanged ( QWidget *  w,
const QRectF &  oldNormGeo,
const QRectF &  newNormGeo 
)
signal

Signal emitted when widget normalized geometry changes.


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