mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
Merge commit
This commit is contained in:
commit
b257ef2c1d
@ -255,14 +255,6 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
// _painter->setBrush(brush);
|
// _painter->setBrush(brush);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (previousColor != item.color)
|
|
||||||
{
|
|
||||||
// Set background color brush for rectangle
|
|
||||||
previousColor = item.color;
|
|
||||||
brush.setColor(previousColor);
|
|
||||||
_painter->setBrush(brush);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool changepen = false;
|
bool changepen = false;
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -271,23 +263,38 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
pen.setColor(Qt::red);
|
pen.setColor(Qt::red);
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
_painter->setPen(pen);
|
_painter->setPen(pen);
|
||||||
|
|
||||||
|
previousColor = SELECTED_ITEM_COLOR;
|
||||||
|
brush.setColor(previousColor);
|
||||||
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
else if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders)
|
else
|
||||||
{
|
{
|
||||||
if (w < 3)
|
if (previousColor != item.color)
|
||||||
{
|
{
|
||||||
// Do not paint borders for very narrow items
|
// Set background color brush for rectangle
|
||||||
if (previousPenStyle != Qt::NoPen)
|
previousColor = item.color;
|
||||||
{
|
brush.setColor(previousColor);
|
||||||
previousPenStyle = Qt::NoPen;
|
_painter->setBrush(brush);
|
||||||
_painter->setPen(Qt::NoPen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (previousPenStyle != Qt::SolidLine)
|
|
||||||
|
if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders)
|
||||||
{
|
{
|
||||||
// Restore pen for item which is wide enough to paint borders
|
if (w < 3)
|
||||||
previousPenStyle = Qt::SolidLine;
|
{
|
||||||
_painter->setPen(BORDERS_COLOR);
|
// Do not paint borders for very narrow items
|
||||||
|
if (previousPenStyle != Qt::NoPen)
|
||||||
|
{
|
||||||
|
previousPenStyle = Qt::NoPen;
|
||||||
|
_painter->setPen(Qt::NoPen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (previousPenStyle != Qt::SolidLine)
|
||||||
|
{
|
||||||
|
// Restore pen for item which is wide enough to paint borders
|
||||||
|
previousPenStyle = Qt::SolidLine;
|
||||||
|
_painter->setPen(BORDERS_COLOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,13 +344,6 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
// brush = QBrush(previousColor);
|
// brush = QBrush(previousColor);
|
||||||
// _painter->setBrush(brush);
|
// _painter->setBrush(brush);
|
||||||
//} else
|
//} else
|
||||||
if (previousColor != item.color)
|
|
||||||
{
|
|
||||||
// Set background color brush for rectangle
|
|
||||||
previousColor = item.color;
|
|
||||||
brush.setColor(previousColor);
|
|
||||||
_painter->setBrush(brush);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -351,12 +351,27 @@ void ProfGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
|||||||
pen.setColor(Qt::red);
|
pen.setColor(Qt::red);
|
||||||
pen.setWidth(2);
|
pen.setWidth(2);
|
||||||
_painter->setPen(pen);
|
_painter->setPen(pen);
|
||||||
|
|
||||||
|
previousColor = SELECTED_ITEM_COLOR;
|
||||||
|
brush.setColor(previousColor);
|
||||||
|
_painter->setBrush(brush);
|
||||||
}
|
}
|
||||||
else if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders && previousPenStyle != Qt::SolidLine)
|
else
|
||||||
{
|
{
|
||||||
// Restore pen for item which is wide enough to paint borders
|
if (previousColor != item.color)
|
||||||
previousPenStyle = Qt::SolidLine;
|
{
|
||||||
_painter->setPen(BORDERS_COLOR);
|
// Set background color brush for rectangle
|
||||||
|
previousColor = item.color;
|
||||||
|
brush.setColor(previousColor);
|
||||||
|
_painter->setBrush(brush);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (::profiler_gui::EASY_GLOBALS.draw_graphics_items_borders && previousPenStyle != Qt::SolidLine)
|
||||||
|
{
|
||||||
|
// Restore pen for item which is wide enough to paint borders
|
||||||
|
previousPenStyle = Qt::SolidLine;
|
||||||
|
_painter->setPen(BORDERS_COLOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw rectangle
|
// Draw rectangle
|
||||||
|
@ -1,85 +1,86 @@
|
|||||||
/************************************************************************
|
/************************************************************************
|
||||||
* 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
|
||||||
#define EASY_PROFILER__GUI_GLOBALS_H
|
#define EASY_PROFILER__GUI_GLOBALS_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
#include "globals_qobjects.h"
|
#include "globals_qobjects.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class ProfGraphicsItem;
|
class ProfGraphicsItem;
|
||||||
class ProfTreeWidgetItem;
|
class ProfTreeWidgetItem;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
const unsigned int NEGATIVE_ONE = std::numeric_limits<unsigned int>::max();
|
||||||
|
|
||||||
const unsigned int NEGATIVE_ONE = std::numeric_limits<unsigned int>::max();
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace profiler_gui {
|
namespace profiler_gui {
|
||||||
|
|
||||||
const QString ORGANAZATION_NAME = "EasyProfiler";
|
const QString ORGANAZATION_NAME = "EasyProfiler";
|
||||||
const QString APPLICATION_NAME = "Easy profiler gui application";
|
const QString APPLICATION_NAME = "Easy profiler gui application";
|
||||||
|
|
||||||
const QColor CHRONOMETER_COLOR = QColor::fromRgba(0x202020c0);
|
const QColor CHRONOMETER_COLOR = QColor::fromRgba(0x202020c0);
|
||||||
const QRgb SELECTED_THREAD_BACKGROUND = 0x00e0e060;
|
const QRgb SELECTED_THREAD_BACKGROUND = 0x00e0e060;
|
||||||
const QRgb SELECTED_THREAD_FOREGROUND = 0x00ffffff - SELECTED_THREAD_BACKGROUND;
|
const QRgb SELECTED_THREAD_FOREGROUND = 0x00ffffff - SELECTED_THREAD_BACKGROUND;
|
||||||
|
const QRgb SELECTED_ITEM_COLOR = 0x000050a0;
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
struct ProfBlock final
|
|
||||||
{
|
struct ProfBlock final
|
||||||
ProfGraphicsItem* graphics_item;
|
{
|
||||||
ProfTreeWidgetItem* tree_item;
|
ProfGraphicsItem* graphics_item;
|
||||||
unsigned short graphics_item_level;
|
ProfTreeWidgetItem* tree_item;
|
||||||
unsigned int graphics_item_index;
|
unsigned short graphics_item_level;
|
||||||
};
|
unsigned int graphics_item_index;
|
||||||
|
};
|
||||||
typedef ::std::vector<ProfBlock> ProfBlocks;
|
|
||||||
|
typedef ::std::vector<ProfBlock> ProfBlocks;
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
struct ProfGlobals final
|
|
||||||
{
|
struct ProfGlobals final
|
||||||
static ProfGlobals& instance();
|
{
|
||||||
|
static ProfGlobals& instance();
|
||||||
ProfGlobalSignals events;
|
|
||||||
::profiler::thread_blocks_tree_t profiler_blocks;
|
ProfGlobalSignals events;
|
||||||
ProfBlocks gui_blocks;
|
::profiler::thread_blocks_tree_t profiler_blocks;
|
||||||
::profiler::thread_id_t selected_thread;
|
ProfBlocks gui_blocks;
|
||||||
unsigned int selected_block;
|
::profiler::thread_id_t selected_thread;
|
||||||
bool draw_graphics_items_borders;
|
unsigned int selected_block;
|
||||||
|
bool draw_graphics_items_borders;
|
||||||
private:
|
|
||||||
|
private:
|
||||||
ProfGlobals();
|
|
||||||
};
|
ProfGlobals();
|
||||||
#ifndef IGNORE_GLOBALS_DECLARATION
|
};
|
||||||
static ProfGlobals& EASY_GLOBALS = ProfGlobals::instance();
|
#ifndef IGNORE_GLOBALS_DECLARATION
|
||||||
#endif
|
static ProfGlobals& EASY_GLOBALS = ProfGlobals::instance();
|
||||||
//////////////////////////////////////////////////////////////////////////
|
#endif
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
} // END of namespace profiler_gui.
|
|
||||||
|
} // END of namespace profiler_gui.
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
#endif // EASY_PROFILER__GUI_GLOBALS_H
|
|
||||||
|
#endif // EASY_PROFILER__GUI_GLOBALS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user