mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 08:37:55 +08:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
c6fb0bfeb9
@ -17,6 +17,7 @@ add_executable(${PROJECT_NAME}
|
|||||||
blocks_tree_widget.cpp
|
blocks_tree_widget.cpp
|
||||||
globals.h
|
globals.h
|
||||||
globals.cpp
|
globals.cpp
|
||||||
|
globals_qobjects.cpp
|
||||||
graphics_scrollbar.h
|
graphics_scrollbar.h
|
||||||
graphics_scrollbar.cpp
|
graphics_scrollbar.cpp
|
||||||
main_window.h
|
main_window.h
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
/************************************************************************
|
/************************************************************************
|
||||||
* file name : blocks_graphics_view.cpp
|
* file name : blocks_graphics_view.cpp
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* creation time : 2016/06/26
|
* creation time : 2016/06/26
|
||||||
* copyright : (c) 2016 Victor Zarubkin
|
* copyright : (c) 2016 Victor Zarubkin
|
||||||
* author : Victor Zarubkin
|
* author : Victor Zarubkin
|
||||||
* email : v.s.zarubkin@gmail.com
|
* email : v.s.zarubkin@gmail.com
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* description : The file contains implementation of GraphicsScene and GraphicsView and
|
* description : The file contains implementation of GraphicsScene and GraphicsView and
|
||||||
* : it's auxiliary classes for displyaing easy_profiler blocks tree.
|
* : it's auxiliary classes for displyaing easy_profiler blocks tree.
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* change log : * 2016/06/26 Victor Zarubkin: Moved sources from graphics_view.h
|
* change log : * 2016/06/26 Victor Zarubkin: Moved sources from graphics_view.h
|
||||||
* : and renamed classes from My* to Prof*.
|
* : and renamed classes from My* to Prof*.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/27 Victor Zarubkin: Added text shifting relatively to it's parent item.
|
* : * 2016/06/27 Victor Zarubkin: Added text shifting relatively to it's parent item.
|
||||||
* : Disabled border lines painting because of vertical lines painting bug.
|
* : Disabled border lines painting because of vertical lines painting bug.
|
||||||
* : Changed height of blocks. Variable thread-block height.
|
* : Changed height of blocks. Variable thread-block height.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/29 Victor Zarubkin: Highly optimized painting performance and memory consumption.
|
* : * 2016/06/29 Victor Zarubkin: Highly optimized painting performance and memory consumption.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/30 Victor Zarubkin: Replaced doubles with floats (in ProfBlockItem) for less memory consumption.
|
* : * 2016/06/30 Victor Zarubkin: Replaced doubles with floats (in ProfBlockItem) for less memory consumption.
|
||||||
* :
|
* :
|
||||||
* : *
|
* : *
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* license : TODO: add license text
|
* license : TODO: add license text
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
@ -34,6 +34,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "blocks_graphics_view.h"
|
#include "blocks_graphics_view.h"
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
using namespace profiler_gui;
|
using namespace profiler_gui;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -110,9 +112,9 @@ ProfGraphicsItem::~ProfGraphicsItem()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProfGraphicsView* ProfGraphicsItem::view() const
|
const ProfGraphicsView* ProfGraphicsItem::view() const
|
||||||
{
|
{
|
||||||
return static_cast<const ProfGraphicsView*>(scene()->parent());
|
return static_cast<const ProfGraphicsView*>(scene()->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -243,15 +245,15 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto x = item.left() * currentScale - dx;
|
const auto x = item.left() * currentScale - dx;
|
||||||
//if (previousColor != item.color)
|
//if (previousColor != item.color)
|
||||||
//{
|
//{
|
||||||
// changebrush = true;
|
// changebrush = true;
|
||||||
// previousColor = item.color;
|
// previousColor = item.color;
|
||||||
// QLinearGradient gradient(x - dx, item.top(), x - dx, item.top() + item.totalHeight);
|
// QLinearGradient gradient(x - dx, item.top(), x - dx, item.top() + item.totalHeight);
|
||||||
// gradient.setColorAt(0, item.color);
|
// gradient.setColorAt(0, item.color);
|
||||||
// gradient.setColorAt(1, 0x00ffffff);
|
// gradient.setColorAt(1, 0x00ffffff);
|
||||||
// brush = QBrush(gradient);
|
// brush = QBrush(gradient);
|
||||||
// _painter->setBrush(brush);
|
// _painter->setBrush(brush);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
bool changepen = false;
|
bool changepen = false;
|
||||||
@ -264,18 +266,18 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
_painter->setPen(pen);
|
_painter->setPen(pen);
|
||||||
|
|
||||||
previousColor = SELECTED_ITEM_COLOR;
|
previousColor = SELECTED_ITEM_COLOR;
|
||||||
brush.setColor(previousColor);
|
brush.setColor(previousColor);
|
||||||
_painter->setBrush(brush);
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (previousColor != item.color)
|
if (previousColor != item.color)
|
||||||
{
|
{
|
||||||
// Set background color brush for rectangle
|
// Set background color brush for rectangle
|
||||||
previousColor = item.color;
|
previousColor = item.color;
|
||||||
brush.setColor(previousColor);
|
brush.setColor(previousColor);
|
||||||
_painter->setBrush(brush);
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders)
|
if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders)
|
||||||
@ -304,24 +306,24 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
|
|
||||||
if (changepen)
|
if (changepen)
|
||||||
{
|
{
|
||||||
if (previousPenStyle == Qt::NoPen)
|
if (previousPenStyle == Qt::NoPen)
|
||||||
_painter->setPen(Qt::NoPen);
|
_painter->setPen(Qt::NoPen);
|
||||||
else
|
else
|
||||||
_painter->setPen(BORDERS_COLOR); // restore pen for rectangle painting
|
_painter->setPen(BORDERS_COLOR); // restore pen for rectangle painting
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next_level < levelsNumber && item.children_begin != -1)
|
if (next_level < levelsNumber && item.children_begin != NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
// Mark that we would not paint children of current item
|
// Mark that we would not paint children of current item
|
||||||
m_levels[next_level][item.children_begin].state = -1;
|
m_levels[next_level][item.children_begin].state = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next_level < levelsNumber && item.children_begin != -1)
|
if (next_level < levelsNumber && item.children_begin != NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
if (m_levelsIndexes[next_level] == -1)
|
if (m_levelsIndexes[next_level] == NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
// Mark first potentially visible child item on next sublevel
|
// Mark first potentially visible child item on next sublevel
|
||||||
m_levelsIndexes[next_level] = item.children_begin;
|
m_levelsIndexes[next_level] = item.children_begin;
|
||||||
@ -340,11 +342,11 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
//if (changebrush)
|
//if (changebrush)
|
||||||
//{
|
//{
|
||||||
// changebrush = false;
|
// changebrush = false;
|
||||||
// previousColor = item.color;
|
// previousColor = item.color;
|
||||||
// brush = QBrush(previousColor);
|
// brush = QBrush(previousColor);
|
||||||
// _painter->setBrush(brush);
|
// _painter->setBrush(brush);
|
||||||
//} else
|
//} else
|
||||||
|
|
||||||
if (!m_bTest && item.block->block_index == ::profiler_gui::EASY_GLOBALS.selected_block)
|
if (!m_bTest && item.block->block_index == ::profiler_gui::EASY_GLOBALS.selected_block)
|
||||||
{
|
{
|
||||||
selectedItemsWasPainted = true;
|
selectedItemsWasPainted = true;
|
||||||
@ -353,18 +355,18 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
_painter->setPen(pen);
|
_painter->setPen(pen);
|
||||||
|
|
||||||
previousColor = SELECTED_ITEM_COLOR;
|
previousColor = SELECTED_ITEM_COLOR;
|
||||||
brush.setColor(previousColor);
|
brush.setColor(previousColor);
|
||||||
_painter->setBrush(brush);
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (previousColor != item.color)
|
if (previousColor != item.color)
|
||||||
{
|
{
|
||||||
// Set background color brush for rectangle
|
// Set background color brush for rectangle
|
||||||
previousColor = item.color;
|
previousColor = item.color;
|
||||||
brush.setColor(previousColor);
|
brush.setColor(previousColor);
|
||||||
_painter->setBrush(brush);
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders && previousPenStyle != Qt::SolidLine)
|
if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders && previousPenStyle != Qt::SolidLine)
|
||||||
@ -372,16 +374,16 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
// Restore pen for item which is wide enough to paint borders
|
// Restore pen for item which is wide enough to paint borders
|
||||||
previousPenStyle = Qt::SolidLine;
|
previousPenStyle = Qt::SolidLine;
|
||||||
_painter->setPen(BORDERS_COLOR);
|
_painter->setPen(BORDERS_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw rectangle
|
// Draw rectangle
|
||||||
const auto x = item.left() * currentScale - dx;
|
const auto x = item.left() * currentScale - dx;
|
||||||
rect.setRect(x, item.top(), w, item.height());
|
rect.setRect(x, item.top(), w, item.height());
|
||||||
_painter->drawRect(rect);
|
_painter->drawRect(rect);
|
||||||
|
|
||||||
// Draw text-----------------------------------
|
// Draw text-----------------------------------
|
||||||
// calculating text coordinates
|
// calculating text coordinates
|
||||||
auto xtext = x;
|
auto xtext = x;
|
||||||
if (item.left() < sceneLeft)
|
if (item.left() < sceneLeft)
|
||||||
{
|
{
|
||||||
@ -391,31 +393,31 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
xtext = sceneLeft * currentScale - dx;
|
xtext = sceneLeft * currentScale - dx;
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.setRect(xtext + 1, item.top(), w - 1, item.height());
|
rect.setRect(xtext + 1, item.top(), w - 1, item.height());
|
||||||
|
|
||||||
// text will be painted with inverse color
|
// text will be painted with inverse color
|
||||||
auto textColor = 0x00ffffff - previousColor;
|
auto textColor = 0x00ffffff - previousColor;
|
||||||
if (textColor == previousColor) textColor = 0;
|
if (textColor == previousColor) textColor = 0;
|
||||||
_painter->setPen(textColor);
|
_painter->setPen(textColor);
|
||||||
|
|
||||||
// drawing text
|
// drawing text
|
||||||
if (m_bTest)
|
if (m_bTest)
|
||||||
{
|
{
|
||||||
char text[128] = {0};
|
char text[128] = {0};
|
||||||
sprintf(text, "ITEM_%u", i);
|
sprintf(text, "ITEM_%u", i);
|
||||||
_painter->drawText(rect, 0, text);
|
_painter->drawText(rect, 0, text);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_painter->drawText(rect, 0, item.block->node->getBlockName());
|
_painter->drawText(rect, 0, item.block->node->getBlockName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore previous pen color
|
// restore previous pen color
|
||||||
if (previousPenStyle == Qt::NoPen)
|
if (previousPenStyle == Qt::NoPen)
|
||||||
_painter->setPen(Qt::NoPen);
|
_painter->setPen(Qt::NoPen);
|
||||||
else
|
else
|
||||||
_painter->setPen(BORDERS_COLOR); // restore pen for rectangle painting
|
_painter->setPen(BORDERS_COLOR); // restore pen for rectangle painting
|
||||||
// END Draw text~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// END Draw text~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,10 +450,10 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
|
|
||||||
void ProfGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const
|
void ProfGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const
|
||||||
{
|
{
|
||||||
//if (m_bTest)
|
//if (m_bTest)
|
||||||
//{
|
//{
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Search for first visible top-level item
|
// Search for first visible top-level item
|
||||||
auto& level0 = m_levels.front();
|
auto& level0 = m_levels.front();
|
||||||
@ -568,7 +570,7 @@ const ::profiler_gui::ProfBlockItem* ProfGraphicsItem::intersect(const QPointF&
|
|||||||
return &item;
|
return &item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.children_begin == -1)
|
if (item.children_begin == NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
if (itemIndex != 0)
|
if (itemIndex != 0)
|
||||||
{
|
{
|
||||||
@ -578,7 +580,7 @@ const ::profiler_gui::ProfBlockItem* ProfGraphicsItem::intersect(const QPointF&
|
|||||||
|
|
||||||
--j;
|
--j;
|
||||||
const auto& item2 = level[j];
|
const auto& item2 = level[j];
|
||||||
if (item2.children_begin != -1)
|
if (item2.children_begin != NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
firstItem = item2.children_begin;
|
firstItem = item2.children_begin;
|
||||||
break;
|
break;
|
||||||
@ -600,7 +602,7 @@ const ::profiler_gui::ProfBlockItem* ProfGraphicsItem::intersect(const QPointF&
|
|||||||
for (auto j = itemIndex + 1; j < size; ++j)
|
for (auto j = itemIndex + 1; j < size; ++j)
|
||||||
{
|
{
|
||||||
const auto& item2 = level[j];
|
const auto& item2 = level[j];
|
||||||
if (item2.children_begin != -1)
|
if (item2.children_begin != NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
lastItem = item2.children_begin;
|
lastItem = item2.children_begin;
|
||||||
break;
|
break;
|
||||||
@ -649,40 +651,40 @@ unsigned short ProfGraphicsItem::levels() const
|
|||||||
return static_cast<unsigned short>(m_levels.size());
|
return static_cast<unsigned short>(m_levels.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfGraphicsItem::setLevels(unsigned short _levels)
|
void ProfGraphicsItem::setLevels(unsigned short _levels)
|
||||||
{
|
{
|
||||||
m_levels.resize(_levels);
|
m_levels.resize(_levels);
|
||||||
m_levelsIndexes.resize(_levels, -1);
|
m_levelsIndexes.resize(_levels, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfGraphicsItem::reserve(unsigned short _level, unsigned int _items)
|
void ProfGraphicsItem::reserve(unsigned short _level, unsigned int _items)
|
||||||
{
|
{
|
||||||
m_levels[_level].reserve(_items);
|
m_levels[_level].reserve(_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
const ProfGraphicsItem::Children& ProfGraphicsItem::items(unsigned short _level) const
|
const ProfGraphicsItem::Children& ProfGraphicsItem::items(unsigned short _level) const
|
||||||
{
|
{
|
||||||
return m_levels[_level];
|
return m_levels[_level];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ::profiler_gui::ProfBlockItem& ProfGraphicsItem::getItem(unsigned short _level, unsigned int _index) const
|
const ::profiler_gui::ProfBlockItem& ProfGraphicsItem::getItem(unsigned short _level, unsigned int _index) const
|
||||||
{
|
{
|
||||||
return m_levels[_level][_index];
|
return m_levels[_level][_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
::profiler_gui::ProfBlockItem& ProfGraphicsItem::getItem(unsigned short _level, unsigned int _index)
|
::profiler_gui::ProfBlockItem& ProfGraphicsItem::getItem(unsigned short _level, unsigned int _index)
|
||||||
{
|
{
|
||||||
return m_levels[_level][_index];
|
return m_levels[_level][_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ProfGraphicsItem::addItem(unsigned short _level)
|
unsigned int ProfGraphicsItem::addItem(unsigned short _level)
|
||||||
{
|
{
|
||||||
m_levels[_level].emplace_back();
|
m_levels[_level].emplace_back();
|
||||||
return static_cast<unsigned int>(m_levels[_level].size() - 1);
|
return static_cast<unsigned int>(m_levels[_level].size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ProfChronometerItem::ProfChronometerItem(bool _main) : QGraphicsItem(), m_font(QFont("CourierNew", 16, 2)), m_color(CHRONOMETER_COLOR), m_left(0), m_right(0), m_bMain(_main), m_bReverse(false), m_bHover(false)
|
ProfChronometerItem::ProfChronometerItem(bool _main) : QGraphicsItem(), m_font(QFont("CourierNew", 16, 2)), m_color(CHRONOMETER_COLOR), m_left(0), m_right(0), m_bMain(_main), m_bReverse(false), m_bHover(false)
|
||||||
@ -1131,13 +1133,13 @@ void ProfGraphicsView::clearSilent()
|
|||||||
void ProfGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocksTree)
|
void ProfGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocksTree)
|
||||||
{
|
{
|
||||||
// clear scene
|
// clear scene
|
||||||
clearSilent();
|
clearSilent();
|
||||||
|
|
||||||
if (_blocksTree.empty())
|
if (_blocksTree.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set new blocks tree
|
// set new blocks tree
|
||||||
// calculate scene size and fill it with items
|
// calculate scene size and fill it with items
|
||||||
|
|
||||||
@ -1201,7 +1203,7 @@ void ProfGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocksTr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Center view on the beginning of the scene
|
// Center view on the beginning of the scene
|
||||||
updateVisibleSceneRect();
|
updateVisibleSceneRect();
|
||||||
setScrollbar(m_pScrollbar);
|
setScrollbar(m_pScrollbar);
|
||||||
|
|
||||||
if (longestItem != nullptr)
|
if (longestItem != nullptr)
|
||||||
@ -1407,19 +1409,19 @@ void ProfGraphicsView::mousePressEvent(QMouseEvent* _event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mouseButtons = _event->buttons();
|
m_mouseButtons = _event->buttons();
|
||||||
m_mousePressPos = _event->pos();
|
m_mousePressPos = _event->pos();
|
||||||
|
|
||||||
if (m_mouseButtons & Qt::RightButton)
|
if (m_mouseButtons & Qt::RightButton)
|
||||||
{
|
{
|
||||||
const auto mouseX = m_offset + mapToScene(m_mousePressPos).x() / m_scale;
|
const auto mouseX = m_offset + mapToScene(m_mousePressPos).x() / m_scale;
|
||||||
m_chronometerItem->setLeftRight(mouseX, mouseX);
|
m_chronometerItem->setLeftRight(mouseX, mouseX);
|
||||||
m_chronometerItem->setReverse(false);
|
m_chronometerItem->setReverse(false);
|
||||||
m_chronometerItem->hide();
|
m_chronometerItem->hide();
|
||||||
m_pScrollbar->hideChrono();
|
m_pScrollbar->hideChrono();
|
||||||
}
|
}
|
||||||
|
|
||||||
_event->accept();
|
_event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfGraphicsView::mouseDoubleClickEvent(QMouseEvent* _event)
|
void ProfGraphicsView::mouseDoubleClickEvent(QMouseEvent* _event)
|
||||||
@ -1434,12 +1436,12 @@ void ProfGraphicsView::mouseDoubleClickEvent(QMouseEvent* _event)
|
|||||||
m_mousePressPos = _event->pos();
|
m_mousePressPos = _event->pos();
|
||||||
m_bDoubleClick = true;
|
m_bDoubleClick = true;
|
||||||
|
|
||||||
if (m_mouseButtons & Qt::LeftButton)
|
if (m_mouseButtons & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
const auto mouseX = m_offset + mapToScene(m_mousePressPos).x() / m_scale;
|
const auto mouseX = m_offset + mapToScene(m_mousePressPos).x() / m_scale;
|
||||||
m_chronometerItemAux->setLeftRight(mouseX, mouseX);
|
m_chronometerItemAux->setLeftRight(mouseX, mouseX);
|
||||||
m_chronometerItemAux->setReverse(false);
|
m_chronometerItemAux->setReverse(false);
|
||||||
m_chronometerItemAux->hide();
|
m_chronometerItemAux->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
_event->accept();
|
_event->accept();
|
||||||
@ -1454,130 +1456,130 @@ void ProfGraphicsView::mouseReleaseEvent(QMouseEvent* _event)
|
|||||||
_event->accept();
|
_event->accept();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changedSelection = false, clicked = false, changedSelectedItem = false;
|
bool changedSelection = false, clicked = false, changedSelectedItem = false;
|
||||||
if (m_mouseButtons & Qt::RightButton)
|
if (m_mouseButtons & Qt::RightButton)
|
||||||
{
|
{
|
||||||
if (m_chronometerItem->isVisible() && m_chronometerItem->width() < 1e-6)
|
if (m_chronometerItem->isVisible() && m_chronometerItem->width() < 1e-6)
|
||||||
{
|
{
|
||||||
m_chronometerItem->hide();
|
m_chronometerItem->hide();
|
||||||
m_chronometerItem->setHover(false);
|
m_chronometerItem->setHover(false);
|
||||||
m_pScrollbar->hideChrono();
|
m_pScrollbar->hideChrono();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_selectedBlocks.empty())
|
if (!m_selectedBlocks.empty())
|
||||||
{
|
{
|
||||||
changedSelection = true;
|
changedSelection = true;
|
||||||
m_selectedBlocks.clear();
|
m_selectedBlocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_bTest && m_chronometerItem->isVisible())
|
if (!m_bTest && m_chronometerItem->isVisible())
|
||||||
{
|
{
|
||||||
//printf("INTERVAL: {%lf, %lf} ms\n", m_chronometerItem->left(), m_chronometerItem->right());
|
//printf("INTERVAL: {%lf, %lf} ms\n", m_chronometerItem->left(), m_chronometerItem->right());
|
||||||
|
|
||||||
for (auto item : m_items)
|
for (auto item : m_items)
|
||||||
{
|
{
|
||||||
item->getBlocks(m_chronometerItem->left(), m_chronometerItem->right(), m_selectedBlocks);
|
item->getBlocks(m_chronometerItem->left(), m_chronometerItem->right(), m_selectedBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_selectedBlocks.empty())
|
if (!m_selectedBlocks.empty())
|
||||||
{
|
{
|
||||||
changedSelection = true;
|
changedSelection = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_mouseButtons & Qt::LeftButton)
|
if (m_mouseButtons & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
if (m_chronometerItemAux->isVisible() && m_chronometerItemAux->width() < 1e-6)
|
if (m_chronometerItemAux->isVisible() && m_chronometerItemAux->width() < 1e-6)
|
||||||
{
|
{
|
||||||
m_chronometerItemAux->hide();
|
m_chronometerItemAux->hide();
|
||||||
}
|
}
|
||||||
else if (m_chronometerItem->isVisible() && m_chronometerItem->hover())
|
else if (m_chronometerItem->isVisible() && m_chronometerItem->hover())
|
||||||
{
|
{
|
||||||
// Jump to selected zone
|
// Jump to selected zone
|
||||||
clicked = true;
|
clicked = true;
|
||||||
m_flickerSpeedX = m_flickerSpeedY = 0;
|
m_flickerSpeedX = m_flickerSpeedY = 0;
|
||||||
m_pScrollbar->setValue(m_chronometerItem->left() + m_chronometerItem->width() * 0.5 - m_pScrollbar->sliderHalfWidth());
|
m_pScrollbar->setValue(m_chronometerItem->left() + m_chronometerItem->width() * 0.5 - m_pScrollbar->sliderHalfWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clicked && m_mouseMovePath.manhattanLength() < 5 && !m_bTest)
|
if (!clicked && m_mouseMovePath.manhattanLength() < 5 && !m_bTest)
|
||||||
{
|
{
|
||||||
// Handle Click
|
// Handle Click
|
||||||
|
|
||||||
clicked = true;
|
clicked = true;
|
||||||
auto mouseClickPos = mapToScene(m_mousePressPos);
|
auto mouseClickPos = mapToScene(m_mousePressPos);
|
||||||
mouseClickPos.setX(m_offset + mouseClickPos.x() / m_scale);
|
mouseClickPos.setX(m_offset + mouseClickPos.x() / m_scale);
|
||||||
|
|
||||||
// Try to select one of item blocks
|
// Try to select one of item blocks
|
||||||
for (auto item : m_items)
|
for (auto item : m_items)
|
||||||
{
|
{
|
||||||
auto block = item->intersect(mouseClickPos);
|
auto block = item->intersect(mouseClickPos);
|
||||||
if (block)
|
if (block)
|
||||||
{
|
{
|
||||||
changedSelectedItem = true;
|
changedSelectedItem = true;
|
||||||
::profiler_gui::EASY_GLOBALS.selected_block = block->block->block_index;
|
::profiler_gui::EASY_GLOBALS.selected_block = block->block->block_index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bDoubleClick = false;
|
m_bDoubleClick = false;
|
||||||
m_mouseButtons = _event->buttons();
|
m_mouseButtons = _event->buttons();
|
||||||
m_mouseMovePath = QPoint();
|
m_mouseMovePath = QPoint();
|
||||||
_event->accept();
|
_event->accept();
|
||||||
|
|
||||||
if (changedSelection)
|
if (changedSelection)
|
||||||
{
|
{
|
||||||
emit intervalChanged(m_selectedBlocks, m_beginTime, position2time(m_chronometerItem->left()), position2time(m_chronometerItem->right()), m_chronometerItem->reverse());
|
emit intervalChanged(m_selectedBlocks, m_beginTime, position2time(m_chronometerItem->left()), position2time(m_chronometerItem->right()), m_chronometerItem->reverse());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_chronometerItem->setReverse(false);
|
m_chronometerItem->setReverse(false);
|
||||||
|
|
||||||
if (changedSelectedItem)
|
if (changedSelectedItem)
|
||||||
{
|
{
|
||||||
m_bUpdatingRect = true;
|
m_bUpdatingRect = true;
|
||||||
emit ::profiler_gui::EASY_GLOBALS.events.selectedBlockChanged(::profiler_gui::EASY_GLOBALS.selected_block);
|
emit ::profiler_gui::EASY_GLOBALS.events.selectedBlockChanged(::profiler_gui::EASY_GLOBALS.selected_block);
|
||||||
m_bUpdatingRect = false;
|
m_bUpdatingRect = false;
|
||||||
|
|
||||||
updateScene();
|
updateScene();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool ProfGraphicsView::moveChrono(ProfChronometerItem* _chronometerItem, qreal _mouseX)
|
bool ProfGraphicsView::moveChrono(ProfChronometerItem* _chronometerItem, qreal _mouseX)
|
||||||
{
|
{
|
||||||
if (_chronometerItem->reverse())
|
if (_chronometerItem->reverse())
|
||||||
{
|
{
|
||||||
if (_mouseX > _chronometerItem->right())
|
if (_mouseX > _chronometerItem->right())
|
||||||
{
|
{
|
||||||
_chronometerItem->setReverse(false);
|
_chronometerItem->setReverse(false);
|
||||||
_chronometerItem->setLeftRight(_chronometerItem->right(), _mouseX);
|
_chronometerItem->setLeftRight(_chronometerItem->right(), _mouseX);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_chronometerItem->setLeftRight(_mouseX, _chronometerItem->right());
|
_chronometerItem->setLeftRight(_mouseX, _chronometerItem->right());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_mouseX < _chronometerItem->left())
|
if (_mouseX < _chronometerItem->left())
|
||||||
{
|
{
|
||||||
_chronometerItem->setReverse(true);
|
_chronometerItem->setReverse(true);
|
||||||
_chronometerItem->setLeftRight(_mouseX, _chronometerItem->left());
|
_chronometerItem->setLeftRight(_mouseX, _chronometerItem->left());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_chronometerItem->setLeftRight(_chronometerItem->left(), _mouseX);
|
_chronometerItem->setLeftRight(_chronometerItem->left(), _mouseX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_chronometerItem->isVisible() && _chronometerItem->width() > 1e-6)
|
if (!_chronometerItem->isVisible() && _chronometerItem->width() > 1e-6)
|
||||||
{
|
{
|
||||||
_chronometerItem->show();
|
_chronometerItem->show();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -1592,8 +1594,8 @@ void ProfGraphicsView::mouseMoveEvent(QMouseEvent* _event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool needUpdate = false;
|
bool needUpdate = false;
|
||||||
const auto pos = _event->pos();
|
const auto pos = _event->pos();
|
||||||
const auto delta = pos - m_mousePressPos;
|
const auto delta = pos - m_mousePressPos;
|
||||||
m_mousePressPos = pos;
|
m_mousePressPos = pos;
|
||||||
|
|
||||||
if (m_mouseButtons != 0)
|
if (m_mouseButtons != 0)
|
||||||
@ -1602,66 +1604,67 @@ void ProfGraphicsView::mouseMoveEvent(QMouseEvent* _event)
|
|||||||
m_mouseMovePath.setY(m_mouseMovePath.y() + ::std::abs(delta.y()));
|
m_mouseMovePath.setY(m_mouseMovePath.y() + ::std::abs(delta.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mouseScenePos = mapToScene(m_mousePressPos);
|
auto mouseScenePos = mapToScene(m_mousePressPos);
|
||||||
mouseScenePos.setX(m_offset + mouseScenePos.x() / m_scale);
|
mouseScenePos.setX(m_offset + mouseScenePos.x() / m_scale);
|
||||||
|
|
||||||
if (m_mouseButtons & Qt::RightButton)
|
if (m_mouseButtons & Qt::RightButton)
|
||||||
{
|
{
|
||||||
bool showItem = moveChrono(m_chronometerItem, mouseScenePos.x());
|
bool showItem = moveChrono(m_chronometerItem, mouseScenePos.x());
|
||||||
m_pScrollbar->setChronoPos(m_chronometerItem->left(), m_chronometerItem->right());
|
m_pScrollbar->setChronoPos(m_chronometerItem->left(), m_chronometerItem->right());
|
||||||
|
|
||||||
if (showItem)
|
if (showItem)
|
||||||
{
|
{
|
||||||
m_pScrollbar->showChrono();
|
m_pScrollbar->showChrono();
|
||||||
}
|
}
|
||||||
|
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_mouseButtons & Qt::LeftButton)
|
if (m_mouseButtons & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
if (m_bDoubleClick)
|
if (m_bDoubleClick)
|
||||||
{
|
{
|
||||||
moveChrono(m_chronometerItemAux, mouseScenePos.x());
|
moveChrono(m_chronometerItemAux, mouseScenePos.x());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto vbar = verticalScrollBar();
|
auto vbar = verticalScrollBar();
|
||||||
|
|
||||||
m_bUpdatingRect = true; // Block scrollbars from updating scene rect to make it possible to do it only once
|
m_bUpdatingRect = true; // Block scrollbars from updating scene rect to make it possible to do it only once
|
||||||
vbar->setValue(vbar->value() - delta.y());
m_pScrollbar->setValue(m_pScrollbar->value() - delta.x() / m_scale);
|
vbar->setValue(vbar->value() - delta.y());
|
||||||
m_bUpdatingRect = false;
|
m_pScrollbar->setValue(m_pScrollbar->value() - delta.x() / m_scale);
|
||||||
// Seems like an ugly stub, but QSignalBlocker is also a bad decision
|
m_bUpdatingRect = false;
|
||||||
// because if scrollbar does not emit valueChanged signal then viewport does not move
|
// Seems like an ugly stub, but QSignalBlocker is also a bad decision
|
||||||
|
// because if scrollbar does not emit valueChanged signal then viewport does not move
|
||||||
updateVisibleSceneRect(); // Update scene visible rect only once
|
|
||||||
|
updateVisibleSceneRect(); // Update scene visible rect only once
|
||||||
// Update flicker speed
|
|
||||||
m_flickerSpeedX += delta.x() >> 1;
|
// Update flicker speed
|
||||||
m_flickerSpeedY += delta.y() >> 1;
|
m_flickerSpeedX += delta.x() >> 1;
|
||||||
if (!m_flickerTimer.isActive())
|
m_flickerSpeedY += delta.y() >> 1;
|
||||||
{
|
if (!m_flickerTimer.isActive())
|
||||||
// If flicker timer is not started, then start it
|
{
|
||||||
m_flickerTimer.start(FLICKER_INTERVAL);
|
// If flicker timer is not started, then start it
|
||||||
}
|
m_flickerTimer.start(FLICKER_INTERVAL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
needUpdate = true;
|
|
||||||
}
|
needUpdate = true;
|
||||||
|
}
|
||||||
if (m_chronometerItem->isVisible())
|
|
||||||
{
|
if (m_chronometerItem->isVisible())
|
||||||
auto prevValue = m_chronometerItem->hover();
|
{
|
||||||
m_chronometerItem->setHover(m_chronometerItem->contains(mouseScenePos));
|
auto prevValue = m_chronometerItem->hover();
|
||||||
needUpdate = needUpdate || (prevValue != m_chronometerItem->hover());
|
m_chronometerItem->setHover(m_chronometerItem->contains(mouseScenePos));
|
||||||
}
|
needUpdate = needUpdate || (prevValue != m_chronometerItem->hover());
|
||||||
|
}
|
||||||
if (needUpdate)
|
|
||||||
{
|
if (needUpdate)
|
||||||
updateScene(); // repaint scene
|
{
|
||||||
}
|
updateScene(); // repaint scene
|
||||||
|
}
|
||||||
_event->accept();
|
|
||||||
|
_event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -1729,13 +1732,13 @@ void ProfGraphicsView::onFlickerTimeout()
|
|||||||
|
|
||||||
auto vbar = verticalScrollBar();
|
auto vbar = verticalScrollBar();
|
||||||
|
|
||||||
m_bUpdatingRect = true; // Block scrollbars from updating scene rect to make it possible to do it only once
|
m_bUpdatingRect = true; // Block scrollbars from updating scene rect to make it possible to do it only once
|
||||||
m_pScrollbar->setValue(m_pScrollbar->value() - m_flickerSpeedX / m_scale);
|
m_pScrollbar->setValue(m_pScrollbar->value() - m_flickerSpeedX / m_scale);
|
||||||
vbar->setValue(vbar->value() - m_flickerSpeedY);
|
vbar->setValue(vbar->value() - m_flickerSpeedY);
|
||||||
m_bUpdatingRect = false;
|
m_bUpdatingRect = false;
|
||||||
// Seems like an ugly stub, but QSignalBlocker is also a bad decision
|
// Seems like an ugly stub, but QSignalBlocker is also a bad decision
|
||||||
// because if scrollbar does not emit valueChanged signal then viewport does not move
|
// because if scrollbar does not emit valueChanged signal then viewport does not move
|
||||||
|
|
||||||
updateVisibleSceneRect(); // Update scene visible rect only once
|
updateVisibleSceneRect(); // Update scene visible rect only once
|
||||||
updateScene(); // repaint scene
|
updateScene(); // repaint scene
|
||||||
|
|
||||||
@ -1792,7 +1795,7 @@ void ProfGraphicsView::onSelectedBlockChange(unsigned int _block_index)
|
|||||||
const auto& guiblock = ::profiler_gui::EASY_GLOBALS.gui_blocks[_block_index];
|
const auto& guiblock = ::profiler_gui::EASY_GLOBALS.gui_blocks[_block_index];
|
||||||
const auto& item = guiblock.graphics_item->items(guiblock.graphics_item_level)[guiblock.graphics_item_index];
|
const auto& item = guiblock.graphics_item->items(guiblock.graphics_item_level)[guiblock.graphics_item_index];
|
||||||
|
|
||||||
m_flickerSpeedX = m_flickerSpeedY = 0;
|
m_flickerSpeedX = m_flickerSpeedY = 0;
|
||||||
m_pScrollbar->setValue(item.left() + item.width() * 0.5 - m_pScrollbar->sliderHalfWidth());
|
m_pScrollbar->setValue(item.left() + item.width() * 0.5 - m_pScrollbar->sliderHalfWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/************************************************************************
|
/************************************************************************
|
||||||
* file name : blocks_graphics_view.h
|
* file name : blocks_graphics_view.h
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* creation time : 2016/06/26
|
* creation time : 2016/06/26
|
||||||
* copyright : (c) 2016 Victor Zarubkin
|
* copyright : (c) 2016 Victor Zarubkin
|
||||||
* author : Victor Zarubkin
|
* author : Victor Zarubkin
|
||||||
* email : v.s.zarubkin@gmail.com
|
* email : v.s.zarubkin@gmail.com
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* description : The file contains declaration of GraphicsScene and GraphicsView and
|
* description : The file contains declaration of GraphicsScene and GraphicsView and
|
||||||
* : it's auxiliary classes for displyaing easy_profiler blocks tree.
|
* : it's auxiliary classes for displyaing easy_profiler blocks tree.
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* change log : * 2016/06/26 Victor Zarubkin: moved sources from graphics_view.h
|
* change log : * 2016/06/26 Victor Zarubkin: moved sources from graphics_view.h
|
||||||
* : and renamed classes from My* to Prof*.
|
* : and renamed classes from My* to Prof*.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/29 Victor Zarubkin: Highly optimized painting performance and memory consumption.
|
* : * 2016/06/29 Victor Zarubkin: Highly optimized painting performance and memory consumption.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/30 Victor Zarubkin: Replaced doubles with floats (in ProfBlockItem) for less memory consumption.
|
* : * 2016/06/30 Victor Zarubkin: Replaced doubles with floats (in ProfBlockItem) for less memory consumption.
|
||||||
* :
|
* :
|
||||||
* : *
|
* : *
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* license : TODO: add license text
|
* license : TODO: add license text
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#ifndef MY____GRAPHICS___VIEW_H
|
#ifndef MY____GRAPHICS___VIEW_H
|
||||||
@ -34,7 +34,6 @@
|
|||||||
#include "graphics_scrollbar.h"
|
#include "graphics_scrollbar.h"
|
||||||
#include "profiler/reader.h"
|
#include "profiler/reader.h"
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "globals.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -86,53 +85,53 @@ public:
|
|||||||
\note Must be set before doing anything else.
|
\note Must be set before doing anything else.
|
||||||
|
|
||||||
\param _levels Desired number of levels */
|
\param _levels Desired number of levels */
|
||||||
void setLevels(unsigned short _levels);
|
void setLevels(unsigned short _levels);
|
||||||
|
|
||||||
/** \brief Reserves memory for desired number of items on specified level.
|
/** \brief Reserves memory for desired number of items on specified level.
|
||||||
|
|
||||||
\param _level Index of the level
|
\param _level Index of the level
|
||||||
\param _items Desired number of items on this level */
|
\param _items Desired number of items on this level */
|
||||||
void reserve(unsigned short _level, unsigned int _items);
|
void reserve(unsigned short _level, unsigned int _items);
|
||||||
|
|
||||||
/**\brief Returns reference to the array of items of specified level.
|
/**\brief Returns reference to the array of items of specified level.
|
||||||
|
|
||||||
\param _level Index of the level */
|
\param _level Index of the level */
|
||||||
const Children& items(unsigned short _level) const;
|
const Children& items(unsigned short _level) const;
|
||||||
|
|
||||||
/**\brief Returns reference to the item with required index on specified level.
|
/**\brief Returns reference to the item with required index on specified level.
|
||||||
|
|
||||||
\param _level Index of the level
|
\param _level Index of the level
|
||||||
\param _index Index of required item */
|
\param _index Index of required item */
|
||||||
const ::profiler_gui::ProfBlockItem& getItem(unsigned short _level, unsigned int _index) const;
|
const ::profiler_gui::ProfBlockItem& getItem(unsigned short _level, unsigned int _index) const;
|
||||||
|
|
||||||
/**\brief Returns reference to the item with required index on specified level.
|
/**\brief Returns reference to the item with required index on specified level.
|
||||||
|
|
||||||
\param _level Index of the level
|
\param _level Index of the level
|
||||||
\param _index Index of required item */
|
\param _index Index of required item */
|
||||||
::profiler_gui::ProfBlockItem& getItem(unsigned short _level, unsigned int _index);
|
::profiler_gui::ProfBlockItem& getItem(unsigned short _level, unsigned int _index);
|
||||||
|
|
||||||
/** \brief Adds new item to required level.
|
/** \brief Adds new item to required level.
|
||||||
|
|
||||||
\param _level Index of the level
|
\param _level Index of the level
|
||||||
|
|
||||||
\retval Index of the new created item */
|
\retval Index of the new created item */
|
||||||
unsigned int addItem(unsigned short _level);
|
unsigned int addItem(unsigned short _level);
|
||||||
|
|
||||||
/** \brief Finds top-level blocks which are intersects with required selection zone.
|
/** \brief Finds top-level blocks which are intersects with required selection zone.
|
||||||
|
|
||||||
\note Found blocks will be added into the array of selected blocks.
|
\note Found blocks will be added into the array of selected blocks.
|
||||||
|
|
||||||
\param _left Left bound of the selection zone
|
\param _left Left bound of the selection zone
|
||||||
\param _right Right bound of the selection zone
|
\param _right Right bound of the selection zone
|
||||||
\param _blocks Reference to the array of selected blocks */
|
\param _blocks Reference to the array of selected blocks */
|
||||||
void getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const;
|
void getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const;
|
||||||
|
|
||||||
const ::profiler_gui::ProfBlockItem* intersect(const QPointF& _pos) const;
|
const ::profiler_gui::ProfBlockItem* intersect(const QPointF& _pos) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
///< Returns pointer to the ProfGraphicsView widget.
|
///< Returns pointer to the ProfGraphicsView widget.
|
||||||
const ProfGraphicsView* view() const;
|
const ProfGraphicsView* view() const;
|
||||||
|
|
||||||
}; // END of class ProfGraphicsItem.
|
}; // END of class ProfGraphicsItem.
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include "blocks_tree_widget.h"
|
#include "blocks_tree_widget.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -834,7 +835,7 @@ void ProfTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
|||||||
case COL_MAX_PER_PARENT:
|
case COL_MAX_PER_PARENT:
|
||||||
case COL_MAX_PER_FRAME:
|
case COL_MAX_PER_FRAME:
|
||||||
{
|
{
|
||||||
unsigned int i = -1;
|
unsigned int i = NEGATIVE_ONE;
|
||||||
switch (col)
|
switch (col)
|
||||||
{
|
{
|
||||||
case COL_MIN_PER_THREAD: i = item->block()->per_thread_stats->min_duration_block; break;
|
case COL_MIN_PER_THREAD: i = item->block()->per_thread_stats->min_duration_block; break;
|
||||||
@ -845,7 +846,7 @@ void ProfTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
|
|||||||
case COL_MAX_PER_FRAME: i = item->block()->per_frame_stats->max_duration_block; break;
|
case COL_MAX_PER_FRAME: i = item->block()->per_frame_stats->max_duration_block; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != -1)
|
if (i != NEGATIVE_ONE)
|
||||||
{
|
{
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
itemAction = new ProfItemAction("Jump to such item", i);
|
itemAction = new ProfItemAction("Jump to such item", i);
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "profiler/reader.h"
|
#include "profiler/reader.h"
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "globals.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -1,35 +1,29 @@
|
|||||||
/************************************************************************
|
/************************************************************************
|
||||||
* file name : globals.cpp
|
* file name : globals.cpp
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* creation time : 2016/08/03
|
* creation time : 2016/08/03
|
||||||
* copyright : (c) 2016 Victor Zarubkin
|
* copyright : (c) 2016 Victor Zarubkin
|
||||||
* author : Victor Zarubkin
|
* author : Victor Zarubkin
|
||||||
* email : v.s.zarubkin@gmail.com
|
* email : v.s.zarubkin@gmail.com
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* description : The file contains implementation of global constants and variables for profiler gui.
|
* description : The file contains implementation of global constants and variables for profiler gui.
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* change log : * 2016/08/03 Victor Zarubkin: initial commit.
|
* change log : * 2016/08/03 Victor Zarubkin: initial commit.
|
||||||
* :
|
* :
|
||||||
* : *
|
* : *
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* license : TODO: add license text
|
* license : TODO: add license text
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
#define IGNORE_GLOBALS_DECLARATION
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#undef IGNORE_GLOBALS_DECLARATION
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace profiler_gui {
|
namespace profiler_gui {
|
||||||
|
|
||||||
ProfGlobalSignals::ProfGlobalSignals() : QObject()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfGlobalSignals::~ProfGlobalSignals()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfGlobals& ProfGlobals::instance()
|
ProfGlobals& ProfGlobals::instance()
|
||||||
{
|
{
|
||||||
static ProfGlobals globals;
|
static ProfGlobals globals;
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/************************************************************************
|
/************************************************************************
|
||||||
* file name : globals.h
|
* file name : globals.h
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* creation time : 2016/08/03
|
* creation time : 2016/08/03
|
||||||
* copyright : (c) 2016 Victor Zarubkin
|
* copyright : (c) 2016 Victor Zarubkin
|
||||||
* author : Victor Zarubkin
|
* author : Victor Zarubkin
|
||||||
* email : v.s.zarubkin@gmail.com
|
* email : v.s.zarubkin@gmail.com
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* description : The file contains declaration of global constants and variables for profiler gui.
|
* description : The file contains declaration of global constants and variables for profiler gui.
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* change log : * 2016/08/03 Victor Zarubkin: initial commit.
|
* change log : * 2016/08/03 Victor Zarubkin: initial commit.
|
||||||
* :
|
* :
|
||||||
* : *
|
* : *
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* license : TODO: add license text
|
* license : TODO: add license text
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#ifndef EASY_PROFILER__GUI_GLOBALS_H
|
#ifndef EASY_PROFILER__GUI_GLOBALS_H
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
|
#include "globals_qobjects.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -29,6 +30,8 @@
|
|||||||
class ProfGraphicsItem;
|
class ProfGraphicsItem;
|
||||||
class ProfTreeWidgetItem;
|
class ProfTreeWidgetItem;
|
||||||
|
|
||||||
|
const unsigned int NEGATIVE_ONE = std::numeric_limits<unsigned int>::max();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace profiler_gui {
|
namespace profiler_gui {
|
||||||
@ -43,23 +46,6 @@ namespace profiler_gui {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class ProfGlobalSignals final : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ProfGlobalSignals();
|
|
||||||
virtual ~ProfGlobalSignals();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void selectedThreadChanged(::profiler::thread_id_t _id);
|
|
||||||
void selectedBlockChanged(unsigned int _block_index);
|
|
||||||
};
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
struct ProfBlock final
|
struct ProfBlock final
|
||||||
{
|
{
|
||||||
ProfGraphicsItem* graphics_item;
|
ProfGraphicsItem* graphics_item;
|
||||||
@ -87,9 +73,9 @@ namespace profiler_gui {
|
|||||||
|
|
||||||
ProfGlobals();
|
ProfGlobals();
|
||||||
};
|
};
|
||||||
|
#ifndef IGNORE_GLOBALS_DECLARATION
|
||||||
static ProfGlobals& EASY_GLOBALS = ProfGlobals::instance();
|
static ProfGlobals& EASY_GLOBALS = ProfGlobals::instance();
|
||||||
|
#endif
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
} // END of namespace profiler_gui.
|
} // END of namespace profiler_gui.
|
||||||
|
35
profiler_gui/globals_qobjects.cpp
Normal file
35
profiler_gui/globals_qobjects.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/************************************************************************
|
||||||
|
* file name : globals_qobjects.cpp
|
||||||
|
* ----------------- :
|
||||||
|
* creation time : 2016/08/08
|
||||||
|
* copyright : (c) 2016 Victor Zarubkin, Sergey Yagovtsev
|
||||||
|
* author : Victor Zarubkin
|
||||||
|
* email : v.s.zarubkin@gmail.com
|
||||||
|
* ----------------- :
|
||||||
|
* description : The file contains implementation of ProfGlobalSignals QObject class.
|
||||||
|
* ----------------- :
|
||||||
|
* change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.cpp
|
||||||
|
* :
|
||||||
|
* : *
|
||||||
|
* ----------------- :
|
||||||
|
* license : TODO: add license text
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#include "globals_qobjects.h"
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace profiler_gui {
|
||||||
|
|
||||||
|
ProfGlobalSignals::ProfGlobalSignals() : QObject()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfGlobalSignals::~ProfGlobalSignals()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} // END of namespace profiler_gui.
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
25
profiler_gui/globals_qobjects.h
Normal file
25
profiler_gui/globals_qobjects.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef GLOBALS_QOBJECTS_H
|
||||||
|
#define GLOBALS_QOBJECTS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "profiler/profiler.h"
|
||||||
|
|
||||||
|
namespace profiler_gui {
|
||||||
|
class ProfGlobalSignals final : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ProfGlobalSignals();
|
||||||
|
virtual ~ProfGlobalSignals();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void selectedThreadChanged(::profiler::thread_id_t _id);
|
||||||
|
void selectedBlockChanged(unsigned int _block_index);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GLOBALS_QOBJECTS_H
|
@ -22,6 +22,7 @@
|
|||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "graphics_scrollbar.h"
|
#include "graphics_scrollbar.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -170,12 +171,12 @@ void ProfMinimapItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
//const auto color = ::profiler_gui::toRgb(col * 255, (1.0 - col) * 255, 0); // item.color;
|
//const auto color = ::profiler_gui::toRgb(col * 255, (1.0 - col) * 255, 0); // item.color;
|
||||||
const auto color = 0x00ffffff & QColor::fromHsvF((1.0 - col) * 0.35, 0.85, 0.85).rgb();
|
const auto color = 0x00ffffff & QColor::fromHsvF((1.0 - col) * 0.35, 0.85, 0.85).rgb();
|
||||||
|
|
||||||
if (previousColor != color)
|
if (previousColor != color)
|
||||||
{
|
{
|
||||||
// Set background color brush for rectangle
|
// Set background color brush for rectangle
|
||||||
previousColor = color;
|
previousColor = color;
|
||||||
brush.setColor(QColor::fromRgba(0xc0000000 | color));
|
brush.setColor(QColor::fromRgba(0xc0000000 | color));
|
||||||
_painter->setBrush(brush);
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
|
|
||||||
rect.setRect(item.left() * currentScale, bottom - h, ::std::max(item.width() * currentScale, 1.0), h);
|
rect.setRect(item.left() * currentScale, bottom - h, ::std::max(item.width() * currentScale, 1.0), h);
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <QGraphicsRectItem>
|
#include <QGraphicsRectItem>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "globals.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/************************************************************************
|
/************************************************************************
|
||||||
* file name : main_window.cpp
|
* file name : main_window.cpp
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* creation time : 2016/06/26
|
* creation time : 2016/06/26
|
||||||
* copyright : (c) 2016 Victor Zarubkin
|
* copyright : (c) 2016 Victor Zarubkin
|
||||||
* author : Victor Zarubkin
|
* author : Victor Zarubkin
|
||||||
* email : v.s.zarubkin@gmail.com
|
* email : v.s.zarubkin@gmail.com
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* description : The file contains implementation of MainWindow for easy_profiler GUI.
|
* description : The file contains implementation of MainWindow for easy_profiler GUI.
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* change log : * 2016/06/26 Victor Zarubkin: Initial commit.
|
* change log : * 2016/06/26 Victor Zarubkin: Initial commit.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/27 Victor Zarubkin: Passing blocks number to ProfTreeWidget::setTree().
|
* : * 2016/06/27 Victor Zarubkin: Passing blocks number to ProfTreeWidget::setTree().
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/29 Victor Zarubkin: Added menu with tests.
|
* : * 2016/06/29 Victor Zarubkin: Added menu with tests.
|
||||||
* :
|
* :
|
||||||
* : * 2016/06/30 Sergey Yagovtsev: Open file by command line argument
|
* : * 2016/06/30 Sergey Yagovtsev: Open file by command line argument
|
||||||
* :
|
* :
|
||||||
* : *
|
* : *
|
||||||
* ----------------- :
|
* ----------------- :
|
||||||
* license : TODO: add license text
|
* license : TODO: add license text
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
@ -27,12 +27,13 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
#include "blocks_tree_widget.h"
|
#include "blocks_tree_widget.h"
|
||||||
#include "blocks_graphics_view.h"
|
#include "blocks_graphics_view.h"
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -82,17 +83,17 @@ ProfMainWindow::ProfMainWindow() : QMainWindow(), m_treeWidget(nullptr), m_graph
|
|||||||
menu = new QMenu("Tests");
|
menu = new QMenu("Tests");
|
||||||
menu->addAction(actionTestView);
|
menu->addAction(actionTestView);
|
||||||
menuBar()->addMenu(menu);
|
menuBar()->addMenu(menu);
|
||||||
|
|
||||||
connect(graphicsView->view(), &ProfGraphicsView::intervalChanged, treeWidget, &ProfTreeWidget::setTreeBlocks);
|
connect(graphicsView->view(), &ProfGraphicsView::intervalChanged, treeWidget, &ProfTreeWidget::setTreeBlocks);
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
if(QCoreApplication::arguments().size() > 1)
|
if(QCoreApplication::arguments().size() > 1)
|
||||||
{
|
{
|
||||||
auto opened_filename = QCoreApplication::arguments().at(1).toStdString();
|
auto opened_filename = QCoreApplication::arguments().at(1).toStdString();
|
||||||
loadFile(opened_filename);
|
loadFile(opened_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfMainWindow::~ProfMainWindow()
|
ProfMainWindow::~ProfMainWindow()
|
||||||
{
|
{
|
||||||
@ -103,13 +104,13 @@ ProfMainWindow::~ProfMainWindow()
|
|||||||
void ProfMainWindow::onOpenFileClicked(bool)
|
void ProfMainWindow::onOpenFileClicked(bool)
|
||||||
{
|
{
|
||||||
auto filename = QFileDialog::getOpenFileName(this, "Open profiler log", m_lastFile.c_str(), "Profiler Log File (*.prof);;All Files (*.*)");
|
auto filename = QFileDialog::getOpenFileName(this, "Open profiler log", m_lastFile.c_str(), "Profiler Log File (*.prof);;All Files (*.*)");
|
||||||
loadFile(filename.toStdString());
|
loadFile(filename.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void ProfMainWindow::loadFile(const std::string& stdfilename)
|
void ProfMainWindow::loadFile(const std::string& stdfilename)
|
||||||
{
|
{
|
||||||
::profiler::thread_blocks_tree_t prof_blocks;
|
::profiler::thread_blocks_tree_t prof_blocks;
|
||||||
auto nblocks = fillTreesFromFile(stdfilename.c_str(), prof_blocks, true);
|
auto nblocks = fillTreesFromFile(stdfilename.c_str(), prof_blocks, true);
|
||||||
|
|
||||||
@ -117,8 +118,8 @@ void ProfMainWindow::loadFile(const std::string& stdfilename)
|
|||||||
{
|
{
|
||||||
static_cast<ProfTreeWidget*>(m_treeWidget->widget())->clearSilent(true);
|
static_cast<ProfTreeWidget*>(m_treeWidget->widget())->clearSilent(true);
|
||||||
|
|
||||||
m_lastFile = stdfilename;
|
m_lastFile = stdfilename;
|
||||||
::profiler_gui::EASY_GLOBALS.selected_thread = 0;
|
::profiler_gui::EASY_GLOBALS.selected_thread = 0;
|
||||||
::profiler_gui::EASY_GLOBALS.profiler_blocks.swap(prof_blocks);
|
::profiler_gui::EASY_GLOBALS.profiler_blocks.swap(prof_blocks);
|
||||||
::profiler_gui::EASY_GLOBALS.gui_blocks.resize(nblocks);
|
::profiler_gui::EASY_GLOBALS.gui_blocks.resize(nblocks);
|
||||||
memset(::profiler_gui::EASY_GLOBALS.gui_blocks.data(), 0, sizeof(::profiler_gui::ProfBlock) * nblocks);
|
memset(::profiler_gui::EASY_GLOBALS.gui_blocks.data(), 0, sizeof(::profiler_gui::ProfBlock) * nblocks);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user