|
QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
|
A Widget which contains a scale 更多...
#include <qwt_scale_widget.h>
类 | |
| class | PrivateData |
Public 类型 | |
| enum | LayoutFlag { TitleInverted = 1 } |
| Layout flags of the title 更多... | |
| enum | BuiltinActions { ActionNone = 0x00 , ActionWheelZoom = 0x01 , ActionClickPan = 0x02 , ActionAll = 0xFF } |
| Built-in actions 更多... | |
信号 | |
| 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 成员函数 | |
| 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 QwtScaleDraw * | scaleDraw () const |
| Get the scale draw (const version) | |
| QwtScaleDraw * | scaleDraw () |
| 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 QwtColorMap * | colorMap () 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 成员函数 | |
| 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 | |
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 -│ │_________________________________
|
explicit |
Constructor
Create a scale with the position QwtScaleWidget::Left
| parent | Parent widget |
Constructor
| align | Alignment |
| parent | Parent widget |
| QwtScaleDraw::Alignment QwtScaleWidget::alignment | ( | ) | const |
| QwtAxisId QwtScaleWidget::axisID | ( | ) | const |
Get the axis ID for this scale widget
| QwtScaleWidget::BuiltinActionsFlags QwtScaleWidget::buildinActions | ( | ) | const |
Get the built-in actions flags
|
overrideprotectedvirtual |
Change Event handler
| event | Change event |
Invalidates internal caches if necessary
| QwtInterval QwtScaleWidget::colorBarInterval | ( | ) | const |
Get the value interval for the color bar
| QRectF QwtScaleWidget::colorBarRect | ( | const QRectF & | rect | ) | const |
Calculate the rectangle for the color bar
| rect | Bounding rectangle for all components of the scale |
| int QwtScaleWidget::colorBarWidth | ( | ) | const |
Get the width of the color bar
| const QwtColorMap * QwtScaleWidget::colorMap | ( | ) | const |
| int QwtScaleWidget::dimForLength | ( | int | length, |
| const QFont & | scaleFont | ||
| ) | const |
Find the minimum dimension for a given length
dim is the height, length the width seen in direction of the title.
| length | Width for horizontal, height for vertical scales |
| scaleFont | Font of the scale |
| void QwtScaleWidget::drawColorBar | ( | QPainter * | painter, |
| const QRectF & | rect | ||
| ) | const |
Draw the color bar
Draw the color bar of the scale widget
| painter | Painter |
| rect | Bounding rectangle for the color bar |
| 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
| painter | Painter |
| align | Alignment |
| rect | Bounding rectangle |
| int QwtScaleWidget::edgeMargin | ( | ) | const |
Get the edge margin
The edge margin is the offset between the axis and the plot canvas edge.
| int QwtScaleWidget::endBorderDist | ( | ) | const |
| int QwtScaleWidget::endMinBorderDist | ( | ) | const |
Get the minimum value for the distances of the scale's endpoints from the widget borders (right or bottom)
| 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.
| [out] | start | Border width at the beginning of the scale |
| [out] | end | Border width at the end of the scale |
| 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
| [out] | start | Border width at the beginning of the scale |
| [out] | end | Border width at the end of the scale |
| bool QwtScaleWidget::isColorBarEnabled | ( | ) | const |
Check if color bar is enabled
| 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"
| pos | Mouse position (relative to this QWidget's coordinates) |
| bool QwtScaleWidget::isSelected | ( | ) | const |
Check if the current axis is selected
| bool QwtScaleWidget::isXAxis | ( | ) | const |
Check if this is an X axis
| bool QwtScaleWidget::isYAxis | ( | ) | const |
Check if this is a Y axis
| void QwtScaleWidget::layoutScale | ( | bool | update_geometry = true | ) |
Layout the scale
Recalculate the scale's geometry and layout based on the current geometry and fonts
| update_geometry | Notify the layout system and call update to redraw the scale |
| int QwtScaleWidget::margin | ( | ) | const |
|
overridevirtual |
Get a minimum size hint
|
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.
| min | Minimum scale division requested |
| max | Maximum scale division requested |
|
overrideprotectedvirtual |
Event handler for resize events
| event | Resize event |
|
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.
| QColor QwtScaleWidget::scaleColor | ( | ) | const |
Get the color of the coordinate axis
| QwtScaleDraw * QwtScaleWidget::scaleDraw | ( | ) |
Get the scale draw
| const QwtScaleDraw * QwtScaleWidget::scaleDraw | ( | ) | const |
Get the scale draw (const version)
| QRect QwtScaleWidget::scaleRect | ( | ) | const |
Get the rectangle for drawing the scale (excluding colorBar, margin, edgeMargin, borderDist)
| qreal QwtScaleWidget::selectedPenWidthOffset | ( | ) | const |
Get the current pen width offset for the axis when it is in selected state
|
signal |
Signal emitted when the axis selection state changes
| selected | True if the axis is selected, false otherwise |
| QColor QwtScaleWidget::selectionColor | ( | ) | const |
Get the selection color
| void QwtScaleWidget::setAlignment | ( | QwtScaleDraw::Alignment | alignment | ) |
| 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.
| dist1 | Left or top distance |
| dist2 | Right or bottom distance |
| void QwtScaleWidget::setBuildinActions | ( | BuiltinActionsFlags | acts | ) |
Enable/disable built-in actions
Set the built-in actions
| actions | Built-in action flags |
| void QwtScaleWidget::setColorBarEnabled | ( | bool | on | ) |
Enable/disable the color bar
Enable/disable a color bar associated to the scale
| on | true to enable, false to disable |
| void QwtScaleWidget::setColorBarWidth | ( | int | width | ) |
Set the color bar width
Set the width of the color bar
| width | Width |
| 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
| interval | Value interval |
| colorMap | Color map |
| 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.
| offset | Edge margin offset |
| void QwtScaleWidget::setLabelAlignment | ( | Qt::Alignment | alignment | ) |
Set the label alignment
Change the alignment for the labels
| alignment | Alignment |
| void QwtScaleWidget::setLabelRotation | ( | double | rotation | ) |
Set the label rotation
Change the rotation for the labels
| rotation | Rotation angle in degrees |
| void QwtScaleWidget::setLayoutFlag | ( | LayoutFlag | flag, |
| bool | on | ||
| ) |
Set a layout flag
Toggle a layout flag
| flag | Layout flag |
| on | true/false |
| void QwtScaleWidget::setMargin | ( | int | margin | ) |
| 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.
| start | Minimum for the start border |
| end | Minimum for the end border |
| void QwtScaleWidget::setScaleColor | ( | const QColor & | c | ) |
Set the scale color (color of the coordinate axis)
Set the color of the coordinate axis
| c | Scale color |
| void QwtScaleWidget::setScaleDiv | ( | const QwtScaleDiv & | scaleDiv | ) |
Set the scale division
Assign a scale division
The scale division determines where to set the tick marks.
| scaleDiv | Scale Division |
| 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.
| scaleDraw | ScaleDraw object |
| 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.
| selected | true to select, false to deselect |
| 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.
| offset | The 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. |
| void QwtScaleWidget::setSelectionColor | ( | const QColor & | color | ) |
Set the selection color
| color | Selection color |
| void QwtScaleWidget::setSpacing | ( | int | spacing | ) |
Set the spacing
Specify the distance between color bar, scale and title
| spacing | Spacing |
| void QwtScaleWidget::setTextColor | ( | const QColor & | c | ) |
Set the text color (font color of the coordinate axis)
Set the font color of the coordinate axis
| c | Text color |
| void QwtScaleWidget::setTitle | ( | const QString & | title | ) |
| void QwtScaleWidget::setTitle | ( | const QwtText & | title | ) |
Set the title
Give title new text contents
| title | New title |
| void QwtScaleWidget::setTransformation | ( | QwtTransform * | transformation | ) |
Set the transformation
| transformation | Transformation |
| void QwtScaleWidget::setZoomFactor | ( | double | factor | ) |
Set the zoom factor (default 1.2)
| factor | Zoom factor (range 0.1 to 10.0) |
|
overridevirtual |
Get a size hint
| int QwtScaleWidget::spacing | ( | ) | const |
Get the distance between scale and title
| int QwtScaleWidget::startBorderDist | ( | ) | const |
| int QwtScaleWidget::startMinBorderDist | ( | ) | const |
Get the minimum value for the distances of the scale's endpoints from the widget borders (left or top)
| bool QwtScaleWidget::testBuildinActions | ( | QwtScaleWidget::BuiltinActions | ba | ) | const |
Test if a built-in action is active
| ba | Built-in action to test |
| bool QwtScaleWidget::testLayoutFlag | ( | LayoutFlag | flag | ) | const |
Test a layout flag
| flag | Layout flag |
| QColor QwtScaleWidget::textColor | ( | ) | const |
Get the font color of the coordinate axis
| QwtText QwtScaleWidget::title | ( | ) | const |
| int QwtScaleWidget::titleHeightForWidth | ( | int | width | ) | const |
Find the height of the title for a given width
| width | Width |
| double QwtScaleWidget::zoomFactor | ( | ) | const |
Get the zoom factor