MCPcopy Create free account
hub / github.com/IENT/YUView / paintStatisticsData

Method paintStatisticsData

YUViewLib/src/statistics/StatisticsDataPainting.cpp:258–996  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256} // namespace
257
258void stats::paintStatisticsData(QPainter * painter,
259 stats::StatisticsData &statisticsData,
260 int frameIndex,
261 double zoomFactor)
262{
263 if (statisticsData.getFrameIndex() != frameIndex)
264 {
265 DEBUG_PAINT("StatisticsData::paintStatistics Frame index was not updated. Use setFrameIndex "
266 "first and load data.");
267 return;
268 }
269
270 // Save the state of the painter. This is restored when the function is done.
271 painter->save();
272 painter->setRenderHint(QPainter::Antialiasing, true);
273
274 QRect statRect;
275 auto frameSize = statisticsData.getFrameSize();
276 statRect.setSize(QSize(frameSize.width * zoomFactor, frameSize.height * zoomFactor));
277 statRect.moveCenter(QPoint(0, 0));
278
279 // Get the visible coordinates of the statistics
280 auto viewport = painter->viewport();
281 auto worldTransform = painter->worldTransform();
282 int xMin = statRect.width() / 2 - worldTransform.dx();
283 int yMin = statRect.height() / 2 - worldTransform.dy();
284 int xMax = statRect.width() / 2 - (worldTransform.dx() - viewport.width());
285 int yMax = statRect.height() / 2 - (worldTransform.dy() - viewport.height());
286
287 painter->translate(statRect.topLeft());
288
289 auto &statsTypes = statisticsData.getStatisticsTypes();
290
291 // First, get if more than one statistic that has block values is rendered.
292 bool moreThanOneBlockStatRendered = false;
293 bool oneBlockStatRendered = false;
294 for (const auto &type : statsTypes)
295 {
296 if (type.render && type.hasValueData)
297 {
298 if (oneBlockStatRendered)
299 {
300 moreThanOneBlockStatRendered = true;
301 break;
302 }
303 else
304 oneBlockStatRendered = true;
305 }
306 }
307
308 std::unique_lock<std::mutex> lock(statisticsData.accessMutex);
309
310 // Draw all the block types. Also, if the zoom factor is larger than STATISTICS_DRAW_VALUES_ZOOM,
311 // also save a list of all the values of the blocks and their position in order to draw the values
312 // in the next step.
313 QList<QPoint> drawStatPoints; // The positions of each value
314 QList<QStringList> drawStatTexts; // For each point: The values to draw
315 double maxLineWidth =

Callers

nothing calls this directly

Calls 15

styleToPenFunction · 0.85
convertToQPolygonFunction · 0.85
getPolygonCenterFunction · 0.85
clipFunction · 0.85
patternToQPenStyleFunction · 0.85
paintVectorFunction · 0.85
getFrameIndexMethod · 0.80
setSizeMethod · 0.80
hasDataForTypeIDMethod · 0.80
getColorMethod · 0.80
setAlphaMethod · 0.80
alphaMethod · 0.80

Tested by

no test coverage detected