MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / drawBackground

Method drawBackground

QtNodeEditor/src/FlowView.cpp:343–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341
342
343void
344FlowView::
345drawBackground(QPainter* painter, const QRectF& r)
346{
347 QGraphicsView::drawBackground(painter, r);
348
349 auto drawGrid =
350 [&](double gridStep)
351 {
352 gridStep = 1;
353 QRect windowRect = rect();
354 QPointF tl = mapToScene(windowRect.topLeft());
355 QPointF br = mapToScene(windowRect.bottomRight());
356
357 double left = std::floor(tl.x() / gridStep - 0.5);
358 double right = std::floor(br.x() / gridStep + 1.0);
359 double bottom = std::floor(tl.y() / gridStep - 0.5);
360 double top = std::floor (br.y() / gridStep + 1.0);
361
362 // vertical lines
363 // for (int xi = int(left); xi <= int(right); ++xi)
364 {
365 int xi = 0;
366 QLineF line(xi * gridStep, bottom * gridStep,
367 xi * gridStep, top * gridStep);
368
369 painter->drawLine(line);
370 }
371
372 // horizontal lines
373 //for (int yi = int(bottom); yi <= int(top); ++yi)
374 {
375 int yi = 0;
376 QLineF line(left * gridStep, yi * gridStep,
377 right * gridStep, yi * gridStep );
378 painter->drawLine(line);
379 }
380 };
381
382 auto const &flowViewStyle = StyleCollection::flowViewStyle();
383
384 QBrush bBrush = backgroundBrush();
385
386 QPen pfine(flowViewStyle.FineGridColor, 1.0);
387
388 painter->setPen(pfine);
389 drawGrid(20);
390
391 QPen p(Qt::white, 2.0);
392
393 painter->setPen(p);
394 //drawGrid(150);
395}
396
397
398void

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected