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

A Widget which contains a scale. More...

#include <qwt_scale_widget.h>

Inheritance diagram for QwtScaleWidget:

Classes

class  PrivateData
 

Public Types

enum  LayoutFlag { TitleInverted = 1 }
 Layout flags of the title. More...
 
enum  BuiltinActions { ActionNone = 0x00 , ActionWheelZoom = 0x01 , ActionClickPan = 0x02 , ActionAll = 0xFF }
 Built-in actions. More...
 

Signals

void scaleDivChanged ()
 Signal emitted whenever the scale division changes.
 
void requestScaleRangeUpdate (double min, double max)
 Request to change the axis scale division.
 
void selectionChanged (bool selected)
 Signal emitted when the axis selection state changes.
 

Public Member Functions

 QwtScaleWidget (QWidget *parent=nullptr)
 Constructor.
 
 QwtScaleWidget (QwtScaleDraw::Alignment, QWidget *parent=nullptr)
 Constructor with alignment.
 
 ~QwtScaleWidget () override
 Destructor.
 
void setTitle (const QString &title)
 Set the title.
 
void setTitle (const QwtText &title)
 Set the title.
 
QwtText title () const
 Get the title.
 
void setLayoutFlag (LayoutFlag, bool on)
 Set a layout flag.
 
bool testLayoutFlag (LayoutFlag) const
 Test a layout flag.
 
void setBorderDist (int dist1, int dist2)
 Set the border distances.
 
int startBorderDist () const
 Get the start border distance.
 
int endBorderDist () const
 Get the end border distance.
 
void getBorderDistHint (int &start, int &end) const
 Get the border distance hint.
 
void getMinBorderDist (int &start, int &end) const
 Get the minimum border distances.
 
void setMinBorderDist (int start, int end)
 Set the minimum border distances.
 
int startMinBorderDist () const
 Get the minimum value for the distances of the scale's endpoints from the widget borders (left or top)
 
int endMinBorderDist () const
 Get the minimum value for the distances of the scale's endpoints from the widget borders (right or bottom)
 
void setMargin (int)
 Set the margin.
 
int margin () const
 Get the margin.
 
void setSpacing (int)
 Set the spacing.
 
int spacing () const
 Get the distance between scale and title.
 
void setEdgeMargin (int offset)
 Set the edge margin (offset between axis and plot canvas)
 
int edgeMargin () const
 Get the edge margin.
 
void setScaleDiv (const QwtScaleDiv &)
 Set the scale division.
 
void setTransformation (QwtTransform *)
 Set the transformation.
 
void setScaleDraw (QwtScaleDraw *)
 Set the scale draw.
 
const QwtScaleDrawscaleDraw () const
 Get the scale draw (const version)
 
QwtScaleDrawscaleDraw ()
 Get the scale draw.
 
void setLabelAlignment (Qt::Alignment)
 Set the label alignment.
 
void setLabelRotation (double rotation)
 Set the label rotation.
 
void setColorBarEnabled (bool)
 Enable/disable the color bar.
 
bool isColorBarEnabled () const
 Check if color bar is enabled.
 
void setColorBarWidth (int)
 Set the color bar width.
 
int colorBarWidth () const
 Get the width of the color bar.
 
void setColorMap (const QwtInterval &, QwtColorMap *)
 Set the color map.
 
QwtInterval colorBarInterval () const
 Get the value interval for the color bar.
 
const QwtColorMapcolorMap () const
 Get the color map.
 
virtual QSize sizeHint () const override
 Get a size hint.
 
virtual QSize minimumSizeHint () const override
 Get a minimum size hint.
 
int titleHeightForWidth (int width) const
 Find the height of the title for a given width.
 
int dimForLength (int length, const QFont &scaleFont) const
 Find the minimum dimension for a given length.
 
void drawColorBar (QPainter *, const QRectF &) const
 Draw the color bar.
 
void drawTitle (QPainter *, QwtScaleDraw::Alignment, const QRectF &rect) const
 Draw the title.
 
void setAlignment (QwtScaleDraw::Alignment)
 Set the alignment.
 
QwtScaleDraw::Alignment alignment () const
 Get the alignment.
 
QRectF colorBarRect (const QRectF &) const
 Calculate the rectangle for the color bar.
 
QRect scaleRect () const
 Get the rectangle for drawing the scale (excluding colorBar, margin, edgeMargin, borderDist)
 
void setTextColor (const QColor &c)
 Set the text color (font color of the coordinate axis)
 
QColor textColor () const
 Get the font color of the coordinate axis.
 
void setScaleColor (const QColor &c)
 Set the scale color (color of the coordinate axis)
 
QColor scaleColor () const
 Get the color of the coordinate axis.
 
void layoutScale (bool update_geometry=true)
 Layout the scale.
 
QwtAxisId axisID () const
 Get the axis ID for this scale widget.
 
bool isXAxis () const
 Check if this is an X axis.
 
bool isYAxis () const
 Check if this is a Y axis.
 
void setBuildinActions (BuiltinActionsFlags acts)
 Enable/disable built-in actions.
 
BuiltinActionsFlags buildinActions () const
 Get the built-in actions flags.
 
bool testBuildinActions (BuiltinActions ba) const
 Test if a built-in action is active.
 
void setSelected (bool selected)
 Set the selected state.
 
bool isSelected () const
 Check if the current axis is selected.
 
void setSelectionColor (const QColor &color)
 Set the selection color.
 
QColor selectionColor () const
 Get the selection color.
 
void setZoomFactor (double factor)
 Set the zoom factor (default 1.2)
 
double zoomFactor () const
 Get the zoom factor.
 
void setSelectedPenWidthOffset (qreal offset=1)
 Set the selected pen width offset.
 
qreal selectedPenWidthOffset () const
 Get the current pen width offset for the axis when it is in selected state.
 
bool isOnScale (const QPoint &pos) const
 Check if a point is on the scale area.
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *) override
 paintEvent
 
virtual void resizeEvent (QResizeEvent *) override
 Event handler for resize events.
 
virtual void changeEvent (QEvent *) override
 Change Event handler.
 
void draw (QPainter *) const
 draw the scale
 
void scaleChange ()
 Notify a change of the scale.
 

Detailed Description

A Widget which contains a scale.

This Widget can be used to decorate composite widgets with a scale.

Layout diagram: │<--------------------------— plot yleft edge │ │ │ │tick ┌ ┌--------------------------------— │ │ │ │label│ │ │edge │YLeft │space │ 6 -│margin │ │margin│Title │ │ │ │ │ │ │ │ 5 -│ │ │ │ │ │ │ │ │ │ │ │ 4 -│ │ plot cavans │ │ │ │ │ │ │ │ │ │ 3 -│ │ │ │ │ │ │ │ │ │ │ │ 2 -│ │ │ │ │ │ │ │ │ │ │ │ 1 -│ │_________________________________

Member Enumeration Documentation

◆ BuiltinActions

Built-in actions.

Enumerator
ActionNone 

No action.

ActionWheelZoom 

Mouse wheel zoom (after clicking to activate the axis, scrolling the wheel zooms the current axis)

ActionClickPan 

Mouse click and drag (after clicking to activate the axis, dragging moves the axis left/right)

ActionAll 

All actions.

◆ LayoutFlag

Layout flags of the title.

Enumerator
TitleInverted 

The title of vertical scales is painted from top to bottom. Otherwise it is painted from bottom to top.

Constructor & Destructor Documentation

◆ QwtScaleWidget()

QwtScaleWidget::QwtScaleWidget ( QWidget *  parent = nullptr)
explicit

Constructor.

Create a scale with the position QwtScaleWidget::Left.

Parameters
parentParent widget

Constructor

Parameters
alignAlignment
parentParent widget

Member Function Documentation

◆ alignment()

QwtScaleDraw::Alignment QwtScaleWidget::alignment ( ) const

Get the alignment.

Returns
the alignment
Alignment of the scale
See also
setAlignment()

◆ axisID()

QwtAxisId QwtScaleWidget::axisID ( ) const

Get the axis ID for this scale widget.

Returns
the axis ID for this scale widget
Note
This function converts based on QwtScaleDraw alignment. If alignment is not set, returns QwtAxis::AxisPositions.
Returns
Axis ID

◆ buildinActions()

QwtScaleWidget::BuiltinActionsFlags QwtScaleWidget::buildinActions ( ) const

Get the built-in actions flags.

Returns
the built-in actions flags
Built-in action flags

◆ changeEvent()

void QwtScaleWidget::changeEvent ( QEvent *  event)
overrideprotectedvirtual

Change Event handler.

Parameters
eventChange event

Invalidates internal caches if necessary

◆ colorBarInterval()

QwtInterval QwtScaleWidget::colorBarInterval ( ) const

Get the value interval for the color bar.

Returns
the color bar interval
Value interval for the color bar
See also
setColorMap(), colorMap()

◆ colorBarRect()

QRectF QwtScaleWidget::colorBarRect ( const QRectF &  rect) const

Calculate the rectangle for the color bar.

Returns
the rectangle for the color bar
Parameters
rectBounding rectangle for all components of the scale
Returns
Rectangle for the color bar

◆ colorBarWidth()

int QwtScaleWidget::colorBarWidth ( ) const

Get the width of the color bar.

Returns
the color bar width
Width of the color bar
See also
setColorBarEnabled(), setColorBarWidth()

◆ colorMap()

const QwtColorMap * QwtScaleWidget::colorMap ( ) const

Get the color map.

Returns
the color map
Color map
See also
setColorMap(), colorBarInterval()

◆ dimForLength()

int QwtScaleWidget::dimForLength ( int  length,
const QFont &  scaleFont 
) const

Find the minimum dimension for a given length.

Returns
the dimension required for a given length

dim is the height, length the width seen in direction of the title.

Parameters
lengthWidth for horizontal, height for vertical scales
scaleFontFont of the scale
Returns
Height for horizontal, width for vertical scales

◆ drawColorBar()

void QwtScaleWidget::drawColorBar ( QPainter *  painter,
const QRectF &  rect 
) const

Draw the color bar.

Draw the color bar of the scale widget.

Parameters
painterPainter
rectBounding rectangle for the color bar
See also
setColorBarEnabled()

◆ drawTitle()

void QwtScaleWidget::drawTitle ( QPainter *  painter,
QwtScaleDraw::Alignment  align,
const QRectF &  rect 
) const

Draw the title.

Rotate and paint a title according to its position into a given rectangle.

Parameters
painterPainter
alignAlignment
rectBounding rectangle

◆ edgeMargin()

int QwtScaleWidget::edgeMargin ( ) const

Get the edge margin.

Returns
the edge margin

The edge margin is the offset between the axis and the plot canvas edge.

Returns
Edge margin value

◆ endBorderDist()

int QwtScaleWidget::endBorderDist ( ) const

Get the end border distance.

Returns
the end border distance
End border distance
See also
setBorderDist()

◆ endMinBorderDist()

int QwtScaleWidget::endMinBorderDist ( ) const

Get the minimum value for the distances of the scale's endpoints from the widget borders (right or bottom)

Returns
the end minimum border distance
End minimum border distance
See also
getMinBorderDist(), getBorderDistHint()

◆ getBorderDistHint()

void QwtScaleWidget::getBorderDistHint ( int &  start,
int &  end 
) const

Get the border distance hint.

Calculate a hint for the border distances.

This member function calculates the distance of the scale's endpoints from the widget borders which is required for the mark labels to fit into the widget. The maximum of this distance and the minimum border distance is returned.

Parameters
[out]startBorder width at the beginning of the scale
[out]endBorder width at the end of the scale
Warning
The minimum border distance depends on the font.
See also
setMinBorderDist(), getMinBorderDist(), setBorderDist()

◆ getMinBorderDist()

void QwtScaleWidget::getMinBorderDist ( int &  start,
int &  end 
) const

Get the minimum border distances.

Get the minimum value for the distances of the scale's endpoints from the widget borders.

Parameters
[out]startBorder width at the beginning of the scale
[out]endBorder width at the end of the scale
See also
setMinBorderDist(), getBorderDistHint()

◆ isColorBarEnabled()

bool QwtScaleWidget::isColorBarEnabled ( ) const

Check if color bar is enabled.

Returns
true if color bar is enabled
true when the color bar is enabled
See also
setColorBarEnabled(), setColorBarWidth()

◆ isOnScale()

bool QwtScaleWidget::isOnScale ( const QPoint &  pos) const

Check if a point is on the scale area.

Check if a mouse position falls on the "pure scale area".

Parameters
posMouse position (relative to this QWidget's coordinates)
Returns
true if on the scale area, false if on margin, edgeMargin, title, colorBar, etc.

◆ isSelected()

bool QwtScaleWidget::isSelected ( ) const

Check if the current axis is selected.

Returns
true if selected
true if selected, false otherwise

◆ isXAxis()

bool QwtScaleWidget::isXAxis ( ) const

Check if this is an X axis.

Returns
true if this is an X axis

◆ isYAxis()

bool QwtScaleWidget::isYAxis ( ) const

Check if this is a Y axis.

Returns
true if this is a Y axis

◆ layoutScale()

void QwtScaleWidget::layoutScale ( bool  update_geometry = true)

Layout the scale.

Recalculate the scale's geometry and layout based on the current geometry and fonts.

Parameters
update_geometryNotify the layout system and call update to redraw the scale

◆ margin()

int QwtScaleWidget::margin ( ) const

Get the margin.

Returns
the margin
Margin value
See also
setMargin()

◆ minimumSizeHint()

QSize QwtScaleWidget::minimumSizeHint ( ) const
overridevirtual

Get a minimum size hint.

Returns
Minimum size hint

◆ requestScaleRangeUpdate

void QwtScaleWidget::requestScaleRangeUpdate ( double  min,
double  max 
)
signal

Request to change the axis scale division.

Emitted when built-in actions (zoom/pan) need to alter the scale. Unlike normal QwtPlot updates, here the axis drives the change: QwtPlot receives this signal and adjusts item bounds accordingly.

Parameters
minMinimum scale division requested
maxMaximum scale division requested

◆ resizeEvent()

void QwtScaleWidget::resizeEvent ( QResizeEvent *  event)
overrideprotectedvirtual

Event handler for resize events.

Parameters
eventResize event

◆ scaleChange()

void QwtScaleWidget::scaleChange ( )
protected

Notify a change of the scale.

This virtual function can be overloaded by derived classes. The default implementation updates the geometry and repaints the widget.

◆ scaleColor()

QColor QwtScaleWidget::scaleColor ( ) const

Get the color of the coordinate axis.

Returns
the scale color
Scale color

◆ scaleDraw() [1/2]

QwtScaleDraw * QwtScaleWidget::scaleDraw ( )

Get the scale draw.

Returns
the scale draw
scaleDraw of this scale
See also
QwtScaleDraw::setScaleDraw()

◆ scaleDraw() [2/2]

const QwtScaleDraw * QwtScaleWidget::scaleDraw ( ) const

Get the scale draw (const version)

Returns
the scale draw (const version)
scaleDraw of this scale
See also
setScaleDraw(), QwtScaleDraw::setScaleDraw()

◆ scaleRect()

QRect QwtScaleWidget::scaleRect ( ) const

Get the rectangle for drawing the scale (excluding colorBar, margin, edgeMargin, borderDist)

Returns
the scale rectangle (excluding color bar, margin, edge margin, border distances)
Rectangle used for drawing the scale

◆ selectedPenWidthOffset()

qreal QwtScaleWidget::selectedPenWidthOffset ( ) const

Get the current pen width offset for the axis when it is in selected state.

Returns
the selected pen width offset
The current width offset value
See also
QwtScaleWidget::setSelectedPenWidthOffset, QwtAbstractScaleDraw::selectedPenWidthOffset

◆ selectionChanged

void QwtScaleWidget::selectionChanged ( bool  selected)
signal

Signal emitted when the axis selection state changes.

Parameters
selectedTrue if the axis is selected, false otherwise

◆ selectionColor()

QColor QwtScaleWidget::selectionColor ( ) const

Get the selection color.

Returns
the selection color
Selection color

◆ setAlignment()

void QwtScaleWidget::setAlignment ( QwtScaleDraw::Alignment  alignment)

Set the alignment.

Change the alignment.

Parameters
alignmentNew alignment
See also
alignment()

◆ setBorderDist()

void QwtScaleWidget::setBorderDist ( int  dist1,
int  dist2 
)

Set the border distances.

Specify distances of the scale's endpoints from the widget's borders.

The actual borders will never be less than minimum border distance.

Parameters
dist1Left or top distance
dist2Right or bottom distance
See also
startBorderDist(), endBorderDist()

◆ setBuildinActions()

void QwtScaleWidget::setBuildinActions ( BuiltinActionsFlags  acts)

Enable/disable built-in actions.

Set the built-in actions.

Parameters
actionsBuilt-in action flags
See also
BuiltinActions

◆ setColorBarEnabled()

void QwtScaleWidget::setColorBarEnabled ( bool  on)

Enable/disable the color bar.

Enable/disable a color bar associated to the scale.

Parameters
ontrue to enable, false to disable
See also
isColorBarEnabled(), setColorBarWidth()

◆ setColorBarWidth()

void QwtScaleWidget::setColorBarWidth ( int  width)

Set the color bar width.

Set the width of the color bar.

Parameters
widthWidth
See also
colorBarWidth(), setColorBarEnabled()

◆ setColorMap()

void QwtScaleWidget::setColorMap ( const QwtInterval interval,
QwtColorMap colorMap 
)

Set the color map.

Set the color map and value interval used for displaying the color bar.

Parameters
intervalValue interval
colorMapColor map
See also
colorMap(), colorBarInterval()

◆ setEdgeMargin()

void QwtScaleWidget::setEdgeMargin ( int  offset)

Set the edge margin (offset between axis and plot canvas)

Set the edge margin (offset between axis and plot canvas edge)

edgeMargin and margin are opposite: margin is the offset from the plot, edgeMargin is the offset from the plot canvas edge.

Parameters
offsetEdge margin offset

◆ setLabelAlignment()

void QwtScaleWidget::setLabelAlignment ( Qt::Alignment  alignment)

Set the label alignment.

Change the alignment for the labels.

Parameters
alignmentAlignment
See also
QwtScaleDraw::setLabelAlignment(), setLabelRotation()

◆ setLabelRotation()

void QwtScaleWidget::setLabelRotation ( double  rotation)

Set the label rotation.

Change the rotation for the labels.

Parameters
rotationRotation angle in degrees
See also
QwtScaleDraw::setLabelRotation(), setLabelAlignment()

◆ setLayoutFlag()

void QwtScaleWidget::setLayoutFlag ( LayoutFlag  flag,
bool  on 
)

Set a layout flag.

Toggle a layout flag.

Parameters
flagLayout flag
ontrue/false
See also
testLayoutFlag(), LayoutFlag

◆ setMargin()

void QwtScaleWidget::setMargin ( int  margin)

Set the margin.

Specify the margin to the colorBar/base line.

Parameters
marginMargin
See also
margin()

◆ setMinBorderDist()

void QwtScaleWidget::setMinBorderDist ( int  start,
int  end 
)

Set the minimum border distances.

Set a minimum value for the distances of the scale's endpoints from the widget borders.

This is useful to avoid that the scales are "jumping" when the tick labels or their positions change often.

Parameters
startMinimum for the start border
endMinimum for the end border
See also
getMinBorderDist(), getBorderDistHint(), startMinBorderDist(), endMinBorderDist()

◆ setScaleColor()

void QwtScaleWidget::setScaleColor ( const QColor &  c)

Set the scale color (color of the coordinate axis)

Set the color of the coordinate axis.

Parameters
cScale color

◆ setScaleDiv()

void QwtScaleWidget::setScaleDiv ( const QwtScaleDiv scaleDiv)

Set the scale division.

Assign a scale division.

The scale division determines where to set the tick marks.

Parameters
scaleDivScale Division
See also
For more information about scale divisions, see QwtScaleDiv.

◆ setScaleDraw()

void QwtScaleWidget::setScaleDraw ( QwtScaleDraw scaleDraw)

Set the scale draw.

Set a scale draw.

scaleDraw has to be created with new and will be deleted in ~QwtScaleWidget() or the next call of setScaleDraw(). scaleDraw will be initialized with the attributes of the previous scaleDraw object.

Parameters
scaleDrawScaleDraw object
See also
scaleDraw()

◆ setSelected()

void QwtScaleWidget::setSelected ( bool  selected)

Set the selected state.

This function triggers the selectionChanged signal. Setting the same state repeatedly will not trigger the signal again.

Parameters
selectedtrue to select, false to deselect

◆ setSelectedPenWidthOffset()

void QwtScaleWidget::setSelectedPenWidthOffset ( qreal  offset = 1)

Set the selected pen width offset.

Set the pen width offset for the axis when it is in selected state.

When an axis (e.g., X-axis or Y-axis) is selected by the user, the pen width used for drawing will be increased by this offset value, achieving a visual highlighting effect.

Parameters
offsetThe additional width value to be added when selected (unit: pixels). This value should be non-negative. If it is 0, the line width in selected state will be the same as in normal state.
See also
QwtScaleWidget::selectedPenWidthOffset, QwtAbstractScaleDraw::setSelectedPenWidthOffset

◆ setSelectionColor()

void QwtScaleWidget::setSelectionColor ( const QColor &  color)

Set the selection color.

Parameters
colorSelection color

◆ setSpacing()

void QwtScaleWidget::setSpacing ( int  spacing)

Set the spacing.

Specify the distance between color bar, scale and title.

Parameters
spacingSpacing
See also
spacing()

◆ setTextColor()

void QwtScaleWidget::setTextColor ( const QColor &  c)

Set the text color (font color of the coordinate axis)

Set the font color of the coordinate axis.

Parameters
cText color

◆ setTitle() [1/2]

void QwtScaleWidget::setTitle ( const QString &  title)

Set the title.

Give title new text contents.

Parameters
titleNew title
See also
title(), setTitle(const QwtText&)

◆ setTitle() [2/2]

void QwtScaleWidget::setTitle ( const QwtText title)

Set the title.

Give title new text contents.

Parameters
titleNew title
See also
title()
Warning
The title flags are interpreted in direction of the label, AlignTop, AlignBottom can't be set as the title will always be aligned to the scale.

◆ setTransformation()

void QwtScaleWidget::setTransformation ( QwtTransform transformation)

Set the transformation.

Parameters
transformationTransformation
See also
QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap

◆ setZoomFactor()

void QwtScaleWidget::setZoomFactor ( double  factor)

Set the zoom factor (default 1.2)

Parameters
factorZoom factor (range 0.1 to 10.0)

◆ sizeHint()

QSize QwtScaleWidget::sizeHint ( ) const
overridevirtual

Get a size hint.

Returns
Size hint

◆ spacing()

int QwtScaleWidget::spacing ( ) const

Get the distance between scale and title.

Returns
the spacing
Distance between scale and title
See also
setSpacing()

◆ startBorderDist()

int QwtScaleWidget::startBorderDist ( ) const

Get the start border distance.

Returns
the start border distance
Start border distance
See also
setBorderDist()

◆ startMinBorderDist()

int QwtScaleWidget::startMinBorderDist ( ) const

Get the minimum value for the distances of the scale's endpoints from the widget borders (left or top)

Returns
the start minimum border distance
Start minimum border distance
See also
getMinBorderDist(), getBorderDistHint()

◆ testBuildinActions()

bool QwtScaleWidget::testBuildinActions ( QwtScaleWidget::BuiltinActions  ba) const

Test if a built-in action is active.

Returns
true if a built-in action is active
Parameters
baBuilt-in action to test
Returns
true if the action is active

◆ testLayoutFlag()

bool QwtScaleWidget::testLayoutFlag ( LayoutFlag  flag) const

Test a layout flag.

Returns
true if a layout flag is set
Parameters
flagLayout flag
Returns
true/false
See also
setLayoutFlag(), LayoutFlag

◆ textColor()

QColor QwtScaleWidget::textColor ( ) const

Get the font color of the coordinate axis.

Returns
the text color
Text color

◆ title()

QwtText QwtScaleWidget::title ( ) const

Get the title.

Returns
the title
Title text
See also
setTitle()

◆ titleHeightForWidth()

int QwtScaleWidget::titleHeightForWidth ( int  width) const

Find the height of the title for a given width.

Returns
the height required for the title for a given width
Parameters
widthWidth
Returns
Height

◆ zoomFactor()

double QwtScaleWidget::zoomFactor ( ) const

Get the zoom factor.

Returns
the zoom factor
Zoom factor

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