|
QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
|
3D surface plot item with VBO/VAO rendering More...
#include <qwt3d_surface.h>
Classes | |
| class | PrivateData |
Public Member Functions | |
| Qwt3DSurface () | |
| Constructs an empty surface item. | |
| ~Qwt3DSurface () override | |
| Destructor — releases GL resources and data. | |
| void | loadFromData (Triple **data, unsigned int columns, unsigned int rows, bool uperiodic=false, bool vperiodic=false) |
| Load grid data from Triple array (x, y, z per vertex) | |
| void | loadFromData (double **data, unsigned int columns, unsigned int rows, double minx, double maxx, double miny, double maxy) |
| Load grid data from z-value matrix with explicit x/y domain. | |
| void | loadFromData (const Qwt3DFunctionData &data) |
| Load grid data from a Qwt3DFunctionData result (modern vector API) | |
| void | loadFromData (const Qwt3DParametricData &data) |
| Load grid data from a Qwt3DParametricData result (modern vector API) | |
| void | loadFromData (TripleField const &nodes, CellField const &poly) |
| Load cell (polygon) data from node coordinates and cell indices. | |
| int | resolution () const |
| Returns data resolution (1 = all data, higher = coarser) | |
| FLOORSTYLE | floorStyle () const |
| Returns the current floor projection style. | |
| void | setFloorStyle (FLOORSTYLE style) |
| Sets the floor projection style. | |
| bool | normals () const |
| Returns true if normal vectors are drawn. | |
| void | showNormals (bool b) |
| Show or hide normal vectors at each vertex. | |
| double | normalLength () const |
| Returns the relative length of drawn normals (0..1) | |
| void | setNormalLength (double val) |
| Sets the relative length of drawn normals. | |
| int | normalQuality () const |
| Returns the quality of normal arrow rendering. | |
| void | setNormalQuality (int val) |
| Sets the quality of normal arrow rendering (minimum 3) | |
| std::pair< int, int > | facets () const |
| Returns the number of mesh cells in the original data. | |
| void | updateNormals () |
| Recalculates surface normals from current data. | |
| PLOTSTYLE | plotStyle () const |
| Returns the current plotting style. | |
| void | setPlotStyle (PLOTSTYLE style) |
| Sets the plotting style. | |
| void | setDataColor (Qwt3DColor *color) |
| Sets the data color functor (takes ownership) | |
| const Qwt3DColor * | dataColor () const |
| Returns the data color functor. | |
| void | invalidateColors () |
| Marks per-vertex colors as stale, triggering a VBO rebuild on the next draw. | |
| RGBA | meshColor () const |
| Returns the mesh line color. | |
| void | setMeshColor (RGBA color) |
| Sets the mesh line color. | |
| double | meshLineWidth () const |
| Returns the mesh line width. | |
| void | setMeshLineWidth (double width) |
| Sets the mesh line width. | |
| int | isolines () const |
| Returns the number of isolines. | |
| void | setIsolines (int n) |
| Sets the number of isolines. | |
| bool | smoothMesh () const |
| Returns true if smooth mesh lines are enabled. | |
| void | setSmoothMesh (bool smooth) |
| Enables or disables smooth mesh lines. | |
| double | polygonOffset () const |
| Returns the polygon offset for filled rendering. | |
| void | setPolygonOffset (double offset) |
| Sets the polygon offset for filled rendering. | |
| SHADINGSTYLE | shading () const |
| Returns the shading style. | |
| void | setShading (SHADINGSTYLE style) |
| Sets the shading style. | |
| Qwt3DEnrichment * | addEnrichment (Qwt3DEnrichment const &enrichment) |
| Adds an enrichment to the surface (clones the argument) | |
| bool | degrade (Qwt3DEnrichment *enrichment) |
| Removes an enrichment from the surface. | |
| int | rtti () const override |
| 运行时类型信息 | |
| void | draw () override |
| Draws the surface using VBO/VAO and GLSL shaders. | |
| ParallelEpiped | hull () const override |
| Returns the bounding hull of the surface in 3D space. | |
| void | populateLegendColors (ColorVector &colors) const override |
| Populate the legend color vector from the item's color functor. | |
| Qwt3DGridData * | gridData () const |
| Returns the grid data pointer (nullptr if cell data) | |
| Qwt3DCellData * | cellData () const |
| Returns the cell data pointer (nullptr if grid data) | |
| bool | isGridData () const |
| Returns true if the current data is grid-based. | |
| void | setResolution (int res) |
| Sets the data resolution (1 = full, higher = coarser) | |
Public Member Functions inherited from Qwt3DPlotItem | |
| Qwt3DPlotItem () | |
| Default constructor. | |
| virtual | ~Qwt3DPlotItem () |
| Destructor — detaches from any plot. | |
| void | attach (Qwt3DPlot *plot) |
| Attach the item to a plot. | |
| void | detach () |
| Detach the item from its plot. | |
| Qwt3DPlot * | plot () const |
| Get the plot this item is attached to. | |
| void | setTitle (const QString &title) |
| Set the item title. | |
| QString | title () const |
| Get the item title. | |
| void | setZ (double z) |
| Set the z-order value (controls draw sequence) | |
| double | z () const |
| Get the z-order value. | |
| void | setVisible (bool on) |
| Set item visibility. | |
| bool | isVisible () const |
| Check if the item is visible. | |
| virtual void | itemChanged () |
| Notify the plot that the item has changed. | |
3D surface plot item with VBO/VAO rendering
Qwt3DSurface is a Qwt3DPlotItem that renders 3D surface data using modern OpenGL (VBO/VAO + GLSL shaders). It supports both grid-based (regular mesh) and cell-based (polygon mesh) data, with multiple rendering styles (filled, wireframe, hiddenline, points).
The item manages its own data storage, color mapping, and GL resources (VBO, VAO, EBO, shader program). Data is uploaded to GPU memory when dirty and reused across frames until the data changes.
| Qwt3DSurface::Qwt3DSurface | ( | ) |
Constructs an empty surface item.
Constructs an empty Qwt3DSurface item.
Initializes data storage (empty grid and cell data) and GL resource placeholders. VBO/VAO/shader are created lazily in draw().
Destructor
GL resources (VBO, EBO, VAO) are cleaned up in PrivateData destructor. Data pointers and color functor are also deleted there.
Load grid data from Triple array
| data | 2D array of Triple values [columns][rows] |
| columns | Number of columns in the grid |
| rows | Number of rows in the grid |
| uperiodic | Whether the u-direction is periodic |
| vperiodic | Whether the v-direction is periodic |
Reads vertex positions, computes normals, and marks the VBO for rebuild.
| Qwt3DEnrichment * Qwt3DSurface::addEnrichment | ( | Qwt3DEnrichment const & | enrichment | ) |
Adds an enrichment to the surface (clones the argument)
Adds an enrichment to the surface.
| enrichment | The enrichment to add (will be cloned) |
The enrichment is cloned and assigned to the current plot. TODO: Enrichment rendering with VBO will be implemented in a future plan.
| Qwt3DCellData * Qwt3DSurface::cellData | ( | ) | const |
Returns the cell data pointer (nullptr if grid data)
Returns the cell data pointer.
| bool Qwt3DSurface::degrade | ( | Qwt3DEnrichment * | enrichment | ) |
Removes an enrichment from the surface.
| enrichment | Pointer to the enrichment to remove |
|
overridevirtual |
Draws the surface using VBO/VAO and GLSL shaders.
Called by Qwt3DPlot::paintGL() for each visible item. The GL context is guaranteed to be current.
Rendering strategy by plot style:
Implements Qwt3DPlotItem.
| std::pair< int, int > Qwt3DSurface::facets | ( | ) | const |
Returns the number of mesh cells in the original data.
| FLOORSTYLE Qwt3DSurface::floorStyle | ( | ) | const |
Returns the current floor projection style.
Returns the floor projection style.
| Qwt3DGridData * Qwt3DSurface::gridData | ( | ) | const |
Returns the grid data pointer (nullptr if cell data)
Returns the grid data pointer.
|
overridevirtual |
Returns the bounding hull of the surface in 3D space.
Implements Qwt3DPlotItem.
| void Qwt3DSurface::invalidateColors | ( | ) |
Marks per-vertex colors as stale, triggering a VBO rebuild on the next draw.
Marks per-vertex colors as stale.
Per-vertex colors are baked into the VBO during buildVBO(). Mutating the color functor in place (e.g. setColorMap, setAlpha) does not automatically trigger a rebuild. Call this method afterwards so that draw() re-runs the color functor and re-uploads the vertex buffer.
| void Qwt3DSurface::loadFromData | ( | const Qwt3DFunctionData & | data | ) |
Load grid data from a Qwt3DFunctionData result (modern vector API)
Load grid data from a Qwt3DFunctionData result.
| data | Result of Qwt3DFunction::create() containing z-values and domain |
Converts the vector-based data to the internal grid format and delegates to the pointer-based overload. Memory-safe: the vector data is read-only; a temporary pointer array is created for the legacy API.
| void Qwt3DSurface::loadFromData | ( | const Qwt3DParametricData & | data | ) |
Load grid data from a Qwt3DParametricData result (modern vector API)
Load grid data from a Qwt3DParametricData result.
| data | Result of Qwt3DParametricSurface::create() containing xyz triples |
Converts the vector-based data to the internal grid format and delegates to the pointer-based overload. Memory-safe: the vector data is read-only; a temporary pointer array is created for the legacy API.
| void Qwt3DSurface::loadFromData | ( | double ** | data, |
| unsigned int | columns, | ||
| unsigned int | rows, | ||
| double | minx, | ||
| double | maxx, | ||
| double | miny, | ||
| double | maxy | ||
| ) |
Load grid data from z-value matrix with explicit x/y domain.
Load grid data from z-value matrix.
| data | 2D array of z-values [columns][rows] |
| columns | Number of columns in the grid |
| rows | Number of rows in the grid |
| minx | Minimum x coordinate |
| maxx | Maximum x coordinate |
| miny | Minimum y coordinate |
| maxy | Maximum y coordinate |
Generates x/y coordinates from the domain, reads z-values, computes normals, and marks the VBO for rebuild.
| void Qwt3DSurface::loadFromData | ( | TripleField const & | nodes, |
| CellField const & | poly | ||
| ) |
Load cell (polygon) data from node coordinates and cell indices.
| nodes | Vector of 3D node coordinates |
| poly | Vector of cells (each cell is a vector of node indices) |
Stores node positions and cell topology, computes per-vertex normals and bounding hull, and marks the VBO for rebuild.
|
overridevirtual |
Populate the legend color vector from the item's color functor.
Reimplemented from Qwt3DPlotItem.
| int Qwt3DSurface::resolution | ( | ) | const |
Returns data resolution (1 = all data, higher = coarser)
Returns the current data resolution.
|
overridevirtual |
| void Qwt3DSurface::setDataColor | ( | Qwt3DColor * | color | ) |
Sets the data color functor (takes ownership)
Sets the data color functor.
| color | Pointer to a Qwt3DColor subclass (item takes ownership) |
The color functor is called per-vertex during VBO build to compute vertex colors. If nullptr, a default Qwt3DStandardColor is created lazily when the item is attached to a plot.
| void Qwt3DSurface::setFloorStyle | ( | FLOORSTYLE | style | ) |
Sets the floor projection style.
| style | Floor projection style |
TODO: Floor projection rendering will be implemented as a separate Qwt3DFloorProjection item in a future plan.
| void Qwt3DSurface::setNormalLength | ( | double | val | ) |
Sets the relative length of drawn normals.
| val | Relative length (0..1, relative to hull diagonal) |
| void Qwt3DSurface::setNormalQuality | ( | int | val | ) |
Sets the quality of normal arrow rendering (minimum 3)
Sets the quality of normal arrow rendering.
| val | Quality value (minimum 3) |
| void Qwt3DSurface::setPlotStyle | ( | PLOTSTYLE | style | ) |
Sets the plotting style.
| style | One of NOPLOT, WIREFRAME, HIDDENLINE, FILLED, FILLEDMESH, QWT3D_POINTS |
| void Qwt3DSurface::setResolution | ( | int | res | ) |
Sets the data resolution (1 = full, higher = coarser)
Sets the data resolution.
| res | Resolution value (1 = full data, higher = coarser) |
Resolution controls index buffer stepping: higher values skip vertices in the index buffer, reducing rendered detail without rebuilding the VBO. A value of 1 renders all data.
| void Qwt3DSurface::setShading | ( | SHADINGSTYLE | style | ) |
Sets the shading style.
| style | One of GOURAUD, FLAT, or SMOOTH |
The shading style controls per-fragment lighting interpolation. Currently stored for shader uniform use; full implementation requires shader-level branching.
| void Qwt3DSurface::updateNormals | ( | ) |
Recalculates surface normals from current data.
For grid data, recalculates normals using 4-neighbor cross products. For cell data, recalculates normals from cell topology. Marks the VBO for rebuild.