MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / paint

Method paint

app/src/UI/Widgets/Plot3D.cpp:130–198  ·  view source on GitHub ↗

* @brief Renders the complete 3D plot scene, blending a red-cyan anaglyph when enabled. */

Source from the content-addressed store, hash-verified

128 * @brief Renders the complete 3D plot scene, blending a red-cyan anaglyph when enabled.
129 */
130void Widgets::Plot3D::paint(QPainter* painter)
131{
132 painter->setBackground(m_outerBackgroundColor);
133
134 if (m_dirtyGrid)
135 drawGrid();
136
137 if (m_dirtyData)
138 drawData();
139
140 if (m_dirtyCameraIndicator)
141 drawCameraIndicator();
142
143 if (m_dirtyBackground)
144 drawBackground();
145
146 QList<QImage*> images;
147 images.append(m_bgImg);
148
149 if (m_cameraAngleX <= 270 && m_cameraAngleX > 90.0) {
150 images.append(m_plotImg);
151 images.append(m_gridImg);
152 }
153
154 else {
155 images.append(m_gridImg);
156 images.append(m_plotImg);
157 }
158
159 images.append(m_cameraIndicatorImg);
160
161 if (anaglyphEnabled()) {
162 QImage left(widgetSize(), QImage::Format_ARGB32_Premultiplied);
163 left.setDevicePixelRatio(qApp->devicePixelRatio());
164 left.fill(Qt::transparent);
165
166 QImage right(widgetSize(), QImage::Format_ARGB32_Premultiplied);
167 right.setDevicePixelRatio(qApp->devicePixelRatio());
168 right.fill(Qt::transparent);
169
170 QPainter leftScene(&left);
171 for (const auto* p : images)
172 leftScene.drawImage(0, 0, p[0]);
173
174 QPainter rightScene(&right);
175 for (const auto* p : images)
176 rightScene.drawImage(0, 0, p[1]);
177
178 QImage finalImage(widgetSize(), QImage::Format_RGB32);
179 finalImage.setDevicePixelRatio(qApp->devicePixelRatio());
180 const int h = left.height();
181 const int w = left.width();
182 for (int y = 0; y < h; ++y) {
183 const auto* lLine = reinterpret_cast<const QRgb*>(left.constScanLine(y));
184 const auto* rLine = reinterpret_cast<const QRgb*>(right.constScanLine(y));
185 auto* oLine = reinterpret_cast<QRgb*>(finalImage.scanLine(y));
186
187 for (int x = 0; x < w; ++x)

Callers

nothing calls this directly

Calls 5

drawImageMethod · 0.80
heightMethod · 0.80
widthMethod · 0.80
appendMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected