From d8d9a2fd32f1e4b6f2ab2ef016607bd224c1d221 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Tue, 6 Sep 2016 00:23:46 +0300 Subject: [PATCH] (EasyGraphicsView) Painting context switches with outlined rectangles --- profiler_gui/blocks_graphics_view.cpp | 57 ++++++++++++++++----------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/profiler_gui/blocks_graphics_view.cpp b/profiler_gui/blocks_graphics_view.cpp index f781eeb..04bc07e 100644 --- a/profiler_gui/blocks_graphics_view.cpp +++ b/profiler_gui/blocks_graphics_view.cpp @@ -514,37 +514,46 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem* #ifdef EASY_STORE_CSWITCH_SEPARATELY if (!m_pRoot->sync.empty()) { - _painter->setBrush(Qt::NoBrush); - QPen pen(QColor::fromRgba(0xe0f08040)); - pen.setWidth(3); - _painter->setPen(pen); + _painter->setBrush(QColor::fromRgba(0xfff08040)); + _painter->setPen(QColor::fromRgb(0x00505050)); - qreal prevRight = -1e100, top = y() - 1; - for (auto it = firstSync, end = m_pRoot->sync.end(); it != end; ++it) + qreal prevRight = -1e100, top = y() - 4, h = 3; + if (top + h < visibleBottom) { - const auto& item = easyBlock(*it).tree; - auto begin = sceneView->time2position(item.node->begin()); + for (auto it = firstSync, end = m_pRoot->sync.end(); it != end; ++it) + { + const auto& item = easyBlock(*it).tree; + auto begin = sceneView->time2position(item.node->begin()); - if (begin > sceneRight) - break; // This is first totally invisible item. No need to check other items. + if (begin > sceneRight) + break; // This is first totally invisible item. No need to check other items. - decltype(begin) width = sceneView->time2position(item.node->end()) - begin; - auto r = begin + width; - if (r < sceneLeft) // This item is not visible - continue; + decltype(begin) width = sceneView->time2position(item.node->end()) - begin; + auto r = begin + width; + if (r < sceneLeft) // This item is not visible + continue; - begin *= currentScale; - begin -= dx; - width *= currentScale; -// r = begin + width; -// if (r <= prevRight) // This item is not visible -// continue; + begin *= currentScale; + begin -= dx; + width *= currentScale; + r = begin + width; + if (r <= prevRight) // This item is not visible + continue; - if (width < 1) - width = 1; + if (begin < prevRight) + { + width -= prevRight - begin; + begin = prevRight; + } - _painter->drawLine(QLineF(begin, top, begin + width, top)); - prevRight = begin + width; + if (width < 2) + width = 2; + + //_painter->drawLine(QLineF(::std::max(begin, prevRight), top, begin + width, top)); + rect.setRect(begin, top, width, h); + _painter->drawRect(rect); + prevRight = begin + width; + } } } #endif