|
QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
|
Pure rendering window for 3D plots. More...
#include <qwt3d_plot.h>
Classes | |
| class | PrivateData |
Public Slots | |
| void | setRotation (double xVal, double yVal, double zVal) |
| void | setShift (double xVal, double yVal, double zVal) |
| void | setViewportShift (double xVal, double yVal) |
| void | setScale (double xVal, double yVal, double zVal) |
| void | setZoom (double) |
| void | setOrtho (bool) |
| Sets up orthogonal or perspective mode and updates widget. | |
| void | setAspectRatioMode (ASPECTRATIOMODE mode) |
| Sets the aspect ratio mode for the 3D coordinate box. | |
| void | enableMouse (bool val=true) |
| void | disableMouse (bool val=true) |
| void | enableKeyboard (bool val=true) |
| void | disableKeyboard (bool val=true) |
| void | enableLighting (bool val=true) |
| Enable or disable lighting. | |
| void | disableLighting (bool val=true) |
| void | setLightRotation (double xVal, double yVal, double zVal, unsigned int idx=0) |
| Set the rotation angle of the light source. | |
| void | setLightShift (double xVal, double yVal, double zVal, unsigned int idx=0) |
| Set the shift in light source (world) coordinates. | |
| virtual bool | savePixmap (QString const &fileName, QString const &format) |
| Saves the framebuffer to an image file. | |
| virtual bool | saveVector (QString const &fileName, QString const &format, Qwt3DVectorWriter::TEXTMODE text, Qwt3DVectorWriter::SORTMODE sortmode) |
| Writes vector data supported by gl2ps. | |
| virtual bool | save (QString const &fileName, QString const &format) |
| Saves content in one of the registered output formats. | |
Signals | |
| void | rotationChanged (double xAngle, double yAngle, double zAngle) |
| Signal emitted when the rotation is changed. | |
| void | shiftChanged (double xShift, double yShift, double zShift) |
| Signal emitted when the shift is changed. | |
| void | vieportShiftChanged (double xShift, double yShift) |
| Signal emitted when the viewport shift is changed. | |
| void | scaleChanged (double xScale, double yScale, double zScale) |
| Signal emitted when the scaling is changed. | |
| void | zoomChanged (double) |
| Signal emitted when the zoom is changed. | |
| void | projectionChanged (bool) |
| Signal emitted when the projection mode is changed. | |
| void | aspectRatioModeChanged (ASPECTRATIOMODE mode) |
| Signal emitted when the aspect ratio mode is changed. | |
Public Member Functions | |
| Qwt3DPlot (QWidget *parent=nullptr) | |
| Constructs a Qwt3DPlot widget. | |
| QPixmap | renderPixmap (int w=0, int h=0, bool useContext=false) |
| Renders the plot to a pixmap. | |
| void | createCoordinateSystem (Triple beg, Triple end) |
| Creates a coordinate system with generating corners beg and end. | |
| Qwt3DCoordinateSystem * | coordinates () |
| Qwt3DColorLegend * | legend () |
| double | xRotation () const |
| double | yRotation () const |
| double | zRotation () const |
| double | xShift () const |
| double | yShift () const |
| double | zShift () const |
| double | xViewportShift () const |
| double | yViewportShift () const |
| double | xScale () const |
| double | yScale () const |
| double | zScale () const |
| double | zoom () const |
| bool | ortho () const |
| ASPECTRATIOMODE | aspectRatioMode () const |
| void | setBackgroundColor (RGBA rgba) |
| Sets the background color. | |
| RGBA | backgroundRGBAColor () const |
| ParallelEpiped | hull () const |
| void | showColorLegend (bool) |
| Shows or hides the color legend. | |
| bool | isColorLegendShown () const |
| 返回颜色图例是否显示 | |
| void | setLegendPosition (Qwt3DColorLegend::Position pos) |
| void | setLegendAbsolutePosition (const QRectF &pixelRect) |
| void | setTitlePosition (double rely, double relx=0.5, ANCHOR=TopCenter) |
| Sets relative caption position. | |
| void | setTitleFont (const QString &family, int pointSize, int weight=QFont::Normal, bool italic=false) |
| Sets the caption font. | |
| void | setTitleColor (RGBA col) |
| void | setTitle (const QString &title) |
| QString | title () const |
| 返回标题文本 | |
| void | setTheme (const Qwt3DTheme &theme) |
| Qwt3DTheme | theme () const |
| void | applyTheme (Qwt3DTheme::Preset preset) |
| void | applyTheme (const QString &presetName) |
| void | assignMouse (Qwt3DMouseState xrot, Qwt3DMouseState yrot, Qwt3DMouseState zrot, Qwt3DMouseState xscale, Qwt3DMouseState yscale, Qwt3DMouseState zscale, Qwt3DMouseState zoom, Qwt3DMouseState xshift, Qwt3DMouseState yshift) |
| bool | mouseEnabled () const |
| void | assignKeyboard (Qwt3DKeyboardState xrot_n, Qwt3DKeyboardState xrot_p, Qwt3DKeyboardState yrot_n, Qwt3DKeyboardState yrot_p, Qwt3DKeyboardState zrot_n, Qwt3DKeyboardState zrot_p, Qwt3DKeyboardState xscale_n, Qwt3DKeyboardState xscale_p, Qwt3DKeyboardState yscale_n, Qwt3DKeyboardState yscale_p, Qwt3DKeyboardState zscale_n, Qwt3DKeyboardState zscale_p, Qwt3DKeyboardState zoom_n, Qwt3DKeyboardState zoom_p, Qwt3DKeyboardState xshift_n, Qwt3DKeyboardState xshift_p, Qwt3DKeyboardState yshift_n, Qwt3DKeyboardState yshift_p) |
| bool | keyboardEnabled () const |
| void | setKeySpeed (double rot, double scale, double shift) |
| void | keySpeed (double &rot, double &scale, double &shift) const |
| bool | lightingEnabled () const |
| void | illuminate (unsigned light=0) |
| void | blowout (unsigned light=0) |
| void | setMaterialComponent (unsigned int property, double r, double g, double b, double a=1.0) |
| Sets material component (RGBA) | |
| void | setMaterialComponent (unsigned int property, double intensity) |
| Sets material component (intensity) | |
| void | setShininess (double exponent) |
| Sets shininess exponent. | |
| void | setLightComponent (unsigned int property, double r, double g, double b, double a=1.0, unsigned light=0) |
| Sets light component (RGBA) | |
| void | setLightComponent (unsigned int property, double intensity, unsigned light=0) |
| Sets light component (intensity) | |
| double | xLightRotation (unsigned idx=0) const |
| double | yLightRotation (unsigned idx=0) const |
| double | zLightRotation (unsigned idx=0) const |
| double | xLightShift (unsigned idx=0) const |
| double | yLightShift (unsigned idx=0) const |
| double | zLightShift (unsigned idx=0) const |
| bool | hasItems () const |
| virtual void | attach (Qwt3DPlotItem *item) |
| Attach a plot item to this plot. | |
| virtual void | detach (Qwt3DPlotItem *item) |
| Detach a plot item from this plot. | |
| const QList< Qwt3DPlotItem * > & | itemList () const |
| Returns the list of attached items (sorted by z-order) | |
| void | itemChanged (Qwt3DPlotItem *item) |
| Called by Qwt3DPlotItem when its data or properties change. | |
| bool | initializedGL () const |
| QMatrix4x4 | modelViewMatrix () const |
| Returns the current model-view matrix. | |
| QMatrix4x4 | projectionMatrix () const |
| Returns the current projection matrix. | |
| QPointF | worldToScreen (const Triple &world) const |
| Converts a world coordinate to screen (viewport) coordinates. | |
| Triple | screenToWorld (const QPointF &screen) const |
| Converts screen (viewport) coordinates to a world coordinate. | |
| QSize | viewportSize () const |
| Returns the viewport size in pixels. | |
| QOpenGLShaderProgram * | lineShader () const |
| Returns the shared line shader program. | |
| QOpenGLShaderProgram * | pointShader () const |
| Returns the shared point shader program. | |
| QOpenGLShaderProgram * | polygonShader () const |
| Returns the shared polygon shader program. | |
| QOpenGLShaderProgram * | textShader () const |
| Returns the shared text shader program. | |
Protected Member Functions | |
| void | initializeGL () override |
| Sets up the OpenGL rendering state. | |
| void | paintGL () override |
| Paints the widget's content. | |
| void | resizeGL (int w, int h) override |
| Sets up the OpenGL view port. | |
| void | mousePressEvent (QMouseEvent *e) override |
| void | mouseReleaseEvent (QMouseEvent *e) override |
| void | mouseMoveEvent (QMouseEvent *e) override |
| void | wheelEvent (QWheelEvent *e) override |
| void | keyPressEvent (QKeyEvent *e) override |
Pure rendering window for 3D plots.
Qwt3DPlot is the central rendering window (a QOpenGLWidget subclass). It manages GL context, view transformation, lighting, coordinate system, legend, title, and mouse/keyboard interaction. It does NOT hold any plotting data — data is managed by Qwt3DPlotItem subclasses that are attached via attach().
The rendering pipeline in paintGL():
| Qwt3DPlot::Qwt3DPlot | ( | QWidget * | parent = nullptr | ) |
|
signal |
Signal emitted when the aspect ratio mode is changed.
| mode | The new aspect ratio mode (AUTOFILL or DATARATIO) |
| void Qwt3DPlot::assignKeyboard | ( | Qwt3DKeyboardState | xrot_n, |
| Qwt3DKeyboardState | xrot_p, | ||
| Qwt3DKeyboardState | yrot_n, | ||
| Qwt3DKeyboardState | yrot_p, | ||
| Qwt3DKeyboardState | zrot_n, | ||
| Qwt3DKeyboardState | zrot_p, | ||
| Qwt3DKeyboardState | xscale_n, | ||
| Qwt3DKeyboardState | xscale_p, | ||
| Qwt3DKeyboardState | yscale_n, | ||
| Qwt3DKeyboardState | yscale_p, | ||
| Qwt3DKeyboardState | zscale_n, | ||
| Qwt3DKeyboardState | zscale_p, | ||
| Qwt3DKeyboardState | zoom_n, | ||
| Qwt3DKeyboardState | zoom_p, | ||
| Qwt3DKeyboardState | xshift_n, | ||
| Qwt3DKeyboardState | xshift_p, | ||
| Qwt3DKeyboardState | yshift_n, | ||
| Qwt3DKeyboardState | yshift_p | ||
| ) |
Sets the keybutton combination for data/coordinatesystem moves inside the widget
default behaviour:
rotate around x axis: [Key_Down, Key_Up] rotate around y axis: SHIFT+[Key_Right, Key_Left] rotate around z axis: [Key_Right, Key_Left] scale x: ALT+[Key_Right, Key_Left] scale y: ALT+[Key_Up, Key_Down] scale z: ALT+SHIFT[Key_Down, Key_Up] zoom: ALT+CTRL+[Key_Down, Key_Up] shifting along x: CTRL+[Key_Right, Key_Left] shifting along z: CTRL+[Key_Down, Key_Up]
| void Qwt3DPlot::assignMouse | ( | Qwt3DMouseState | xrot, |
| Qwt3DMouseState | yrot, | ||
| Qwt3DMouseState | zrot, | ||
| Qwt3DMouseState | xscale, | ||
| Qwt3DMouseState | yscale, | ||
| Qwt3DMouseState | zscale, | ||
| Qwt3DMouseState | zoom, | ||
| Qwt3DMouseState | xshift, | ||
| Qwt3DMouseState | yshift | ||
| ) |
Sets the key/mousebutton combination for data/coordinatesystem moves inside the widget\n\n default behaviour:\n @verbatim rotate around x axis: Qt::LeftButton rotate around y axis: Qt::LeftButton | Qt::ShiftButton rotate around z axis: Qt::LeftButton scale x: Qt::LeftButton | Qt::AltButton scale y: Qt::LeftButton | Qt::AltButton scale z: Qt::LeftButton | Qt::AltButton | Qt::ShiftButton zoom: Qt::LeftButton | Qt::AltButton | Qt::ControlButton shifting along x: Qt::LeftButton | Qt::ControlButton shifting along y: Qt::LeftButton | Qt::ControlButton @endverbatim mouseMoveEvent() evaluates this function - if overridden, their usefulness becomes somehow
limited
|
virtual |
Attach a plot item to this plot.
| item | Pointer to the item to attach |
Inserts the item into the internal list and sorts by z-order. If the item is already attached, it is not duplicated.
| void Qwt3DPlot::blowout | ( | unsigned | light = 0 | ) |
| light | light number [0..7] |
Creates a coordinate system with generating corners beg and end.
| beg | Minimum vertex of the coordinate system |
| end | Maximum vertex of the coordinate system |
|
virtual |
Detach a plot item from this plot.
| item | Pointer to the item to detach |
Removes the item from the internal list. Does not delete the item.
|
slot |
|
slot |
|
slot |
The function has no effect if you derive from Qwt3DPlot and overrides the keyboard Functions too careless. In this case check first against keyboardEnabled() in your version of keyPressEvent() A more fine grained input control can be achieved by combining assignKeyboard() with enableKeyboard().
|
slot |
Enable or disable lighting.
| val | True to enable, false to disable |
Lighting parameters are stored on CPU only. No GL_LIGHTING glEnable/glDisable calls are made. Shader-based lighting will use these stored parameters as uniform values.
|
slot |
The function has no effect if you derive from Qwt3DPlot and overrides the mouse Function too careless. In this case check first against mouseEnabled() in your version of mouseMoveEvent() and wheelEvent(). A more fine grained input control can be achieved by combining assignMouse() with enableMouse().
| void Qwt3DPlot::illuminate | ( | unsigned | light = 0 | ) |
| light | light number [0..7] |
|
overrideprotected |
Sets up the OpenGL rendering state.
Compiles shared GLSL shaders (line, point, polygon, text) for use by drawables and items. Enables blend and depth test.
| bool Qwt3DPlot::isColorLegendShown | ( | ) | const |
返回颜色图例是否显示
返回 d->m_displayLegend。showColorLegend(bool) 通过 d->m_displayLegend = show 设置,此处返回该值。
| void Qwt3DPlot::itemChanged | ( | Qwt3DPlotItem * | item | ) |
Called by Qwt3DPlotItem when its data or properties change.
| item | The item that changed |
Re-sorts the item list by z-order, recalculates the plot hull as the union of all items' hulls, updates the coordinate system, and triggers a repaint.
| QMatrix4x4 Qwt3DPlot::modelViewMatrix | ( | ) | const |
Returns the current model-view matrix.
Items use this matrix in their shader uniforms to transform vertex positions from model space to view space.
|
overrideprotected |
Standard mouse button Function
|
overrideprotected |
Standard mouse button Function. Prepares the call to mouseMoveEvent
|
overrideprotected |
Standard mouse button Function. Completes the call to mouseMoveEvent
|
overrideprotected |
Paints the widget's content.
Uses CPU-side QMatrix4x4 for view/projection calculation. All rendering uses VBO/VAO + GLSL shaders.
|
signal |
Signal emitted when the projection mode is changed.
| ortho | True for orthogonal, false for perspective |
| QMatrix4x4 Qwt3DPlot::projectionMatrix | ( | ) | const |
Returns the current projection matrix.
Items use this matrix in their shader uniforms to transform vertex positions from view space to clip space.
| QPixmap Qwt3DPlot::renderPixmap | ( | int | w = 0, |
| int | h = 0, |
||
| bool | useContext = false |
||
| ) |
Renders the plot to a pixmap.
| w | Width (0 for default) |
| h | Height (0 for default) |
| useContext | Whether to use existing GL context |
|
overrideprotected |
Sets up the OpenGL view port.
| w | New width |
| h | New height |
|
signal |
Signal emitted when the rotation is changed.
| xAngle | X axis rotation angle |
| yAngle | Y axis rotation angle |
| zAngle | Z axis rotation angle |
|
virtualslot |
Saves content in one of the registered output formats.
| fileName | Output file name |
| format | Output format string |
To modify the behaviour for more complex output handling use Qwt3DIO::outputHandler.
|
virtualslot |
Saves the framebuffer to an image file.
| fileName | Output file name |
| format | Image file format supported by Qt |
|
virtualslot |
Writes vector data supported by gl2ps.
| fileName | Output file name |
| format | Output format ("EPS", "PS", "PDF", "SVG", or "PGF") |
| text | Text handling mode |
| sortmode | Sort mode for polygon ordering |
If zlib has been configured, format types will be extended by "EPS_GZ" and "PS_GZ". Beware: BSPSORT turns out to behave very slowly and memory consuming, especially in cases where many polygons appear. It is still more exact than SIMPLESORT.
|
signal |
Signal emitted when the scaling is changed.
| xScale | X axis scale factor |
| yScale | Y axis scale factor |
| zScale | Z axis scale factor |
| Triple Qwt3DPlot::screenToWorld | ( | const QPointF & | screen | ) | const |
Converts screen (viewport) coordinates to a world coordinate.
| screen | Screen-space point (pixel coordinates) |
Uses the inverse of the CPU-side modelView and projection matrices to unproject screen coordinates. The z-component is determined by the near plane (z=0 in NDC). Replaces the legacy gluUnProject call.
|
slot |
Sets the aspect ratio mode for the 3D coordinate box.
| mode | AUTOFILL to independently scale each axis to fill the viewport, DATARATIO to preserve original data proportions |
In AUTOFILL mode (default), each axis is normalized to the same visual length so the coordinate box appears as a cube, making the plot fill the viewport. In DATARATIO mode, the original data proportions are preserved (equal aspect ratio), similar to matplotlib's plt.axis('equal').
| void Qwt3DPlot::setBackgroundColor | ( | RGBA | rgba | ) |
Sets the background color.
| rgba | Background color as RGBA value |
| void Qwt3DPlot::setKeySpeed | ( | double | rot, |
| double | scale, | ||
| double | shift | ||
| ) |
Values < 0 are ignored. Default is (3,5,5)
| void Qwt3DPlot::setLightComponent | ( | unsigned int | property, |
| double | intensity, | ||
| unsigned | light = 0 |
||
| ) |
Sets light component (intensity)
Convenience function: sets r=g=b=intensity, a=1.0
| void Qwt3DPlot::setLightComponent | ( | unsigned int | property, |
| double | r, | ||
| double | g, | ||
| double | b, | ||
| double | a = 1.0, |
||
| unsigned | light = 0 |
||
| ) |
Sets light component (RGBA)
Parameters are stored on CPU for future shader uniform upload. No glLightfv calls are made.
|
slot |
Set the rotation angle of the light source.
| xVal | angle in degree to rotate around the X axis |
| yVal | angle in degree to rotate around the Y axis |
| zVal | angle in degree to rotate around the Z axis |
| light | light number |
|
slot |
Set the shift in light source (world) coordinates.
| xVal | shift along (world) X axis |
| yVal | shift along (world) Y axis |
| zVal | shift along (world) Z axis |
| light | light number |
| void Qwt3DPlot::setMaterialComponent | ( | unsigned int | property, |
| double | intensity | ||
| ) |
Sets material component (intensity)
Convenience function: sets r=g=b=intensity, a=1.0
| void Qwt3DPlot::setMaterialComponent | ( | unsigned int | property, |
| double | r, | ||
| double | g, | ||
| double | b, | ||
| double | a = 1.0 |
||
| ) |
Sets material component (RGBA)
Parameters are stored on CPU for future shader uniform upload. No glMaterialfv calls are made.
|
slot |
Sets up orthogonal or perspective mode and updates widget.
| val | True for orthogonal projection, false for perspective |
|
slot |
Set the rotation angle of the object. If you look along the respective axis towards ascending values, the rotation is performed in mathematical negative sense
| xVal | angle in degree to rotate around the X axis |
| yVal | angle in degree to rotate around the Y axis |
| zVal | angle in degree to rotate around the Z axis |
|
slot |
Set the scale in object (world) coordinates.
| xVal | scaling for X values |
| yVal | scaling for Y values |
| zVal | scaling for Z values |
A respective value of 1 represents no scaling;
|
slot |
Set the shift in object (world) coordinates.
| xVal | shift along (world) X axis |
| yVal | shift along (world) Y axis |
| zVal | shift along (world) Z axis |
| void Qwt3DPlot::setShininess | ( | double | exponent | ) |
Sets shininess exponent.
Parameter is stored on CPU for future shader uniform upload. No glMaterialf calls are made.
| void Qwt3DPlot::setTitleFont | ( | const QString & | family, |
| int | pointSize, | ||
| int | weight = QFont::Normal, |
||
| bool | italic = false |
||
| ) |
Sets the caption font.
| family | Font family name |
| pointSize | Font point size |
| weight | Font weight |
| italic | Whether font is italic |
| void Qwt3DPlot::setTitlePosition | ( | double | rely, |
| double | relx = 0.5, |
||
| ANCHOR | anchor = TopCenter |
||
| ) |
Sets relative caption position.
| rely | Relative Y position (0-1). (0.5,0.5) means the anchor point lies in the center of the screen. |
| relx | Relative X position (0-1) |
| anchor | Anchor type for title alignment |
|
slot |
Performs shifting along screen axes. The shift moves points inside a sphere, which encloses the unscaled and unzoomed data by multiples of the spheres diameter
| xVal | shift along (view) X axis |
| yVal | shift along (view) Y axis |
|
slot |
Set the (zoom in addition to scale).
| val | zoom value (value == 1 indicates no zooming) |
|
signal |
Signal emitted when the shift is changed.
| xShift | X axis shift value |
| yShift | Y axis shift value |
| zShift | Z axis shift value |
| void Qwt3DPlot::showColorLegend | ( | bool | show | ) |
Shows or hides the color legend.
| show | True to show, false to hide |
The color legend colors are populated from attached items' dataColor functors during paintGL.
| QString Qwt3DPlot::title | ( | ) | const |
返回标题文本
委托到内部 Qwt3DLabel 的 string() getter。 setTitle() 通过 d->m_title.setString(title) 设置,此处返回 d->m_title.string()。
|
signal |
Signal emitted when the viewport shift is changed.
| xShift | X viewport shift value |
| yShift | Y viewport shift value |
|
overrideprotected |
Standard wheel Function - zoom (wheel only) or z-scale (shift+wheel)
| QPointF Qwt3DPlot::worldToScreen | ( | const Triple & | world | ) | const |
Converts a world coordinate to screen (viewport) coordinates.
| world | World-space triple |
Uses the CPU-side modelView and projection matrices to transform world coordinates to normalized device coordinates, then maps to viewport pixels. Replaces the legacy gluProject call.
|
signal |
Signal emitted when the zoom is changed.
| zoom | Zoom factor |