QWT API (中文) 7.3.0
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt3d_bar_p.h
1#ifndef QWT3D_BAR_P_H
2#define QWT3D_BAR_P_H
3
4#include "qwt3d_bar.h"
5#include "qwt3d_types.h"
6#include "qwt3d_color.h"
7
8#include <QOpenGLBuffer>
9#include <QOpenGLVertexArrayObject>
10#include <QOpenGLShaderProgram>
11#include <QVector3D>
12#include <QVector4D>
13
14#include <vector>
15#include <cfloat>
16
24{
25 QVector3D position;
26 QVector3D normal;
27 QVector4D color;
28};
29
37{
38 Triple center;
39 double halfWidth;
40 double halfDepth;
41 double baseZ;
42 double topZ;
43 double height;
44};
45
46class Qwt3DBar::PrivateData
47{
48 QWT_DECLARE_PUBLIC(Qwt3DBar)
49
50public:
51 explicit PrivateData(Qwt3DBar* q);
52 ~PrivateData();
53
54 // Bar specifications (filled by setSamples)
55 std::vector<Qwt3DBarSpec> m_bars;
56
57 // Bar geometry
58 double m_barWidth; // <= 0 means auto (80% of spacing)
59 double m_barDepth; // <= 0 means auto
60 double m_baseline;
61 double m_spacingX;
62 double m_spacingY;
63
64 // Plot style and color
65 Qwt3DBar::BarStyle m_barStyle;
66 Qwt3DColor* m_dataColor;
67 RGBA m_meshColor;
68 double m_meshLineWidth;
69 double m_polygonOffset;
70
71 // GL resources (created lazily in draw())
72 bool m_vboDirty;
73 bool m_shaderInitialized;
74 QOpenGLBuffer m_vertexBuffer;
75 QOpenGLBuffer m_indexBuffer;
76 QOpenGLVertexArrayObject m_vao;
77 QOpenGLShaderProgram m_shader;
78
79 // Index counts (tri indices first, then line indices in the same EBO)
80 int m_triIndexCount;
81 int m_lineIndexCount;
82 int m_vertexCount;
83
84 // Cached hull
85 ParallelEpiped m_hull;
86
87 // 2D grid metadata (set by setSamples(double**, ...) and setSamples(const Qwt3DFunctionData&))
88 bool m_isGridData = false;
89 int m_gridColumns = 0;
90 int m_gridRows = 0;
91 double m_gridMinX = 0.0;
92 double m_gridMaxX = 0.0;
93 double m_gridMinY = 0.0;
94 double m_gridMaxY = 0.0;
95 std::vector<std::vector<double>> m_gridZ;
96};
97
98inline Qwt3DBar::PrivateData::PrivateData(Qwt3DBar* q)
99 : q_ptr(q)
100 , m_barWidth(0.0)
101 , m_barDepth(0.0)
102 , m_baseline(0.0)
103 , m_spacingX(0.0)
104 , m_spacingY(0.0)
105 , m_barStyle(Qwt3DBar::FilledMesh)
106 , m_dataColor(nullptr)
107 , m_meshColor(RGBA(0.0, 0.0, 0.0, 1.0))
108 , m_meshLineWidth(1.0)
109 , m_polygonOffset(0.5)
110 , m_vboDirty(true)
111 , m_shaderInitialized(false)
112 , m_triIndexCount(0)
113 , m_lineIndexCount(0)
114 , m_vertexCount(0)
115 , m_hull(Triple(0, 0, 0), Triple(0, 0, 0))
116{
117 // QOpenGLBuffer with IndexBuffer target
118 m_indexBuffer = QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
119}
120
121inline Qwt3DBar::PrivateData::~PrivateData()
122{
123 // Destroy GL resources (safe to call even without current context)
124 m_vertexBuffer.destroy();
125 m_indexBuffer.destroy();
126 m_vao.destroy();
127
128 // Clean up color functor
129 if (m_dataColor)
130 m_dataColor->destroy();
131}
132
133#endif // QWT3D_BAR_P_H
3D bar chart item with VBO/VAO rendering
Definition qwt3d_bar.h:48
BarStyle
Bar rendering style
Definition qwt3d_bar.h:54
Abstract base class for color functors
Definition qwt3d_color.h:25
Vertex structure for VBO upload
Definition qwt3d_bar_p.h:24
Parallelepiped spanned by 2 Triples
Definition qwt3d_types.h:334
Specification of a single bar (axis-aligned cuboid)
Definition qwt3d_bar_p.h:37
double height
original z value, used to recompute baseZ/topZ when baseline changes
Definition qwt3d_bar_p.h:43
Red-Green-Blue-Alpha value
Definition qwt3d_types.h:395
Triple [x,y,z]
Definition qwt3d_types.h:201