mirror of
https://github.com/yse/easy_profiler.git
synced 2025-01-14 00:27:55 +08:00
GUI: Added new settings into settings toolbar -> View. You can change blocks minimum size, spacing and narrow width value.
This commit is contained in:
parent
ed3e26a59c
commit
65be64fb51
@ -62,10 +62,7 @@ enum BlockItemState : int8_t
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const int MIN_ITEM_WIDTH = 3;
|
||||
const int MIN_ITEMS_SPACING = 2;
|
||||
const int MIN_SYNC_SPACING = 1;
|
||||
const int NARROW_ITEM_WIDTH = 20;
|
||||
const QRgb BORDERS_COLOR = ::profiler::colors::Grey700 & 0x00ffffff;// 0x00686868;
|
||||
|
||||
inline QRgb selectedItemBorderColor(::profiler::color_t _color) {
|
||||
@ -307,7 +304,7 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
if (x + w <= prevRight)
|
||||
{
|
||||
// This item is not visible
|
||||
if (!(EASY_GLOBALS.hide_narrow_children && w < NARROW_ITEM_WIDTH) && l > 0)
|
||||
if (!(EASY_GLOBALS.hide_narrow_children && w < EASY_GLOBALS.blocks_narrow_size) && l > 0)
|
||||
dont_skip_children(next_level, item.children_begin, BLOCK_ITEM_DO_PAINT_FIRST);
|
||||
//else
|
||||
// skip_children(next_level, item.children_begin);
|
||||
@ -323,7 +320,7 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
const auto& itemDesc = easyDescriptor(itemBlock.tree.node->id());
|
||||
|
||||
int h = 0, flags = 0;
|
||||
if ((EASY_GLOBALS.hide_narrow_children && w < NARROW_ITEM_WIDTH) || !itemBlock.expanded)
|
||||
if ((EASY_GLOBALS.hide_narrow_children && w < EASY_GLOBALS.blocks_narrow_size) || !itemBlock.expanded)
|
||||
{
|
||||
// Items which width is less than 20 will be painted as big rectangles which are hiding it's children
|
||||
|
||||
@ -354,16 +351,16 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
_painter->setPen(BORDERS_COLOR & inverseColor);// BORDERS_COLOR);
|
||||
}
|
||||
|
||||
if (w < MIN_ITEM_WIDTH)
|
||||
w = MIN_ITEM_WIDTH;
|
||||
if (w < EASY_GLOBALS.blocks_size_min)
|
||||
w = EASY_GLOBALS.blocks_size_min;
|
||||
|
||||
// Draw rectangle
|
||||
rect.setRect(x, top, w, h);
|
||||
_painter->drawRect(rect);
|
||||
|
||||
prevRight = rect.right() + MIN_ITEMS_SPACING;
|
||||
prevRight = rect.right() + EASY_GLOBALS.blocks_spacing;
|
||||
//skip_children(next_level, item.children_begin);
|
||||
if (w < NARROW_ITEM_WIDTH)
|
||||
if (w < EASY_GLOBALS.blocks_narrow_size)
|
||||
continue;
|
||||
|
||||
if (totalHeight > ::profiler_gui::GRAPHICS_ROW_SIZE)
|
||||
@ -401,14 +398,14 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
if (dh > 0)
|
||||
h -= dh;
|
||||
|
||||
if (w < MIN_ITEM_WIDTH)
|
||||
w = MIN_ITEM_WIDTH;
|
||||
if (w < EASY_GLOBALS.blocks_size_min)
|
||||
w = EASY_GLOBALS.blocks_size_min;
|
||||
|
||||
rect.setRect(x, top, w, h);
|
||||
_painter->drawRect(rect);
|
||||
|
||||
prevRight = rect.right() + MIN_ITEMS_SPACING;
|
||||
if (w < NARROW_ITEM_WIDTH)
|
||||
prevRight = rect.right() + EASY_GLOBALS.blocks_spacing;
|
||||
if (w < EASY_GLOBALS.blocks_narrow_size)
|
||||
{
|
||||
dont_skip_children(next_level, item.children_begin, BLOCK_ITEM_DO_PAINT_FIRST);
|
||||
continue;
|
||||
@ -473,7 +470,10 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
const auto& itemBlock = easyBlock(item.block);
|
||||
auto top = levelY(guiblock.graphics_item_level);
|
||||
auto w = ::std::max(item.width() * currentScale, 1.0);
|
||||
decltype(top) h = (!itemBlock.expanded || (w < NARROW_ITEM_WIDTH && EASY_GLOBALS.hide_narrow_children)) ? (itemBlock.tree.depth * ::profiler_gui::GRAPHICS_ROW_SIZE_FULL + ::profiler_gui::GRAPHICS_ROW_SIZE) : ::profiler_gui::GRAPHICS_ROW_SIZE;
|
||||
decltype(top) h = (!itemBlock.expanded ||
|
||||
(w < EASY_GLOBALS.blocks_narrow_size && EASY_GLOBALS.hide_narrow_children))
|
||||
? (itemBlock.tree.depth * ::profiler_gui::GRAPHICS_ROW_SIZE_FULL + ::profiler_gui::GRAPHICS_ROW_SIZE)
|
||||
: ::profiler_gui::GRAPHICS_ROW_SIZE;
|
||||
|
||||
auto dh = top + h - visibleBottom;
|
||||
if (dh < h)
|
||||
@ -503,7 +503,7 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
rect.setRect(x, top, w, h);
|
||||
_painter->drawRect(rect);
|
||||
|
||||
if (!selectedItemsWasPainted && w > NARROW_ITEM_WIDTH)
|
||||
if (!selectedItemsWasPainted && w > EASY_GLOBALS.blocks_narrow_size)
|
||||
{
|
||||
// Draw text-----------------------------------
|
||||
// calculating text coordinates
|
||||
@ -592,8 +592,8 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
|
||||
left = prevRight;
|
||||
}
|
||||
|
||||
if (width < MIN_ITEM_WIDTH)
|
||||
width = MIN_ITEM_WIDTH;
|
||||
if (width < EASY_GLOBALS.blocks_size_min)
|
||||
width = EASY_GLOBALS.blocks_size_min;
|
||||
|
||||
const bool self_thread = item.node->id() != 0 && EASY_GLOBALS.profiler_blocks.find(item.node->id()) != EASY_GLOBALS.profiler_blocks.end();
|
||||
::profiler::color_t color = 0;
|
||||
@ -825,7 +825,7 @@ const ::profiler_gui::EasyBlockItem* EasyGraphicsItem::intersect(const QPointF&
|
||||
}
|
||||
|
||||
const auto w = item.width() * currentScale;
|
||||
if (i == levelIndex || (w < NARROW_ITEM_WIDTH && EASY_GLOBALS.hide_narrow_children) || !easyBlock(item.block).expanded)
|
||||
if (i == levelIndex || (w < EASY_GLOBALS.blocks_narrow_size && EASY_GLOBALS.hide_narrow_children) || !easyBlock(item.block).expanded)
|
||||
{
|
||||
return &item;
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ namespace profiler_gui {
|
||||
, selected_block(::profiler_gui::numeric_max<decltype(selected_block)>())
|
||||
, chrono_text_position(ChronoTextPosition_Center)
|
||||
, frame_time(4e4f)
|
||||
, blocks_spacing(2)
|
||||
, blocks_size_min(3)
|
||||
, blocks_narrow_size(20)
|
||||
, connected(false)
|
||||
, enable_event_indicators(true)
|
||||
, enable_statistics(true)
|
||||
|
@ -112,6 +112,9 @@ namespace profiler_gui {
|
||||
::profiler::block_index_t selected_block; ///< Current selected profiler block index
|
||||
ChronometerTextPosition chrono_text_position; ///< Selected interval text position
|
||||
float frame_time; ///< Value in microseconds to be displayed at minimap on graphics scrollbar
|
||||
int blocks_spacing; ///< Minimum blocks spacing on diagram
|
||||
int blocks_size_min; ///< Minimum blocks size on diagram
|
||||
int blocks_narrow_size; ///< Width indicating narrow blocks
|
||||
bool connected; ///< Is connected to source (to be able to capture profiling information)
|
||||
bool enable_event_indicators; ///< Enable event indicators painting (These are narrow rectangles at the bottom of each thread)
|
||||
bool enable_statistics; ///< Enable gathering and using statistics (Disable if you want to consume less memory)
|
||||
|
@ -69,6 +69,7 @@
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QWidgetAction>
|
||||
#include <QSpinBox>
|
||||
#include <QMessageBox>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
@ -295,6 +296,52 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_lastAddress("127.0.0.1"), m_lastP
|
||||
submenu->addAction(action);
|
||||
connect(action, &QAction::triggered, this, &This::onChronoTextPosChanged);
|
||||
|
||||
submenu->addSeparator();
|
||||
auto w = new QWidget(submenu);
|
||||
auto l = new QHBoxLayout(w);
|
||||
l->setContentsMargins(33, 1, 1, 1);
|
||||
l->addWidget(new QLabel("Blocks spacing", w), 0, Qt::AlignLeft);
|
||||
auto spinbox = new QSpinBox(w);
|
||||
spinbox->setMinimum(0);
|
||||
spinbox->setValue(EASY_GLOBALS.blocks_spacing);
|
||||
spinbox->setFixedWidth(50);
|
||||
connect(spinbox, SIGNAL(valueChanged(int)), this, SLOT(onSpacingChange(int)));
|
||||
l->addWidget(spinbox);
|
||||
w->setLayout(l);
|
||||
auto waction = new QWidgetAction(submenu);
|
||||
waction->setDefaultWidget(w);
|
||||
submenu->addAction(waction);
|
||||
|
||||
w = new QWidget(submenu);
|
||||
l = new QHBoxLayout(w);
|
||||
l->setContentsMargins(33, 1, 1, 1);
|
||||
l->addWidget(new QLabel("Blocks size min", w), 0, Qt::AlignLeft);
|
||||
spinbox = new QSpinBox(w);
|
||||
spinbox->setMinimum(1);
|
||||
spinbox->setValue(EASY_GLOBALS.blocks_size_min);
|
||||
spinbox->setFixedWidth(50);
|
||||
connect(spinbox, SIGNAL(valueChanged(int)), this, SLOT(onMinSizeChange(int)));
|
||||
l->addWidget(spinbox);
|
||||
w->setLayout(l);
|
||||
waction = new QWidgetAction(submenu);
|
||||
waction->setDefaultWidget(w);
|
||||
submenu->addAction(waction);
|
||||
|
||||
w = new QWidget(submenu);
|
||||
l = new QHBoxLayout(w);
|
||||
l->setContentsMargins(33, 1, 1, 1);
|
||||
l->addWidget(new QLabel("Blocks narrow size", w), 0, Qt::AlignLeft);
|
||||
spinbox = new QSpinBox(w);
|
||||
spinbox->setMinimum(1);
|
||||
spinbox->setValue(EASY_GLOBALS.blocks_narrow_size);
|
||||
spinbox->setFixedWidth(50);
|
||||
connect(spinbox, SIGNAL(valueChanged(int)), this, SLOT(onNarrowSizeChange(int)));
|
||||
l->addWidget(spinbox);
|
||||
w->setLayout(l);
|
||||
waction = new QWidgetAction(submenu);
|
||||
waction->setDefaultWidget(w);
|
||||
submenu->addAction(waction);
|
||||
|
||||
|
||||
submenu = menu->addMenu("Remote");
|
||||
m_eventTracingEnableAction = submenu->addAction("Event tracing enabled");
|
||||
@ -638,6 +685,26 @@ void EasyMainWindow::onCollapseAllClicked(bool)
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EasyMainWindow::onSpacingChange(int _value)
|
||||
{
|
||||
EASY_GLOBALS.blocks_spacing = _value;
|
||||
static_cast<EasyGraphicsViewWidget*>(m_graphicsView->widget())->view()->scene()->update();
|
||||
}
|
||||
|
||||
void EasyMainWindow::onMinSizeChange(int _value)
|
||||
{
|
||||
EASY_GLOBALS.blocks_size_min = _value;
|
||||
static_cast<EasyGraphicsViewWidget*>(m_graphicsView->widget())->view()->scene()->update();
|
||||
}
|
||||
|
||||
void EasyMainWindow::onNarrowSizeChange(int _value)
|
||||
{
|
||||
EASY_GLOBALS.blocks_narrow_size = _value;
|
||||
static_cast<EasyGraphicsViewWidget*>(m_graphicsView->widget())->view()->scene()->update();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void EasyMainWindow::onEditBlocksClicked(bool)
|
||||
{
|
||||
if (m_descTreeDialog != nullptr)
|
||||
@ -713,6 +780,18 @@ void EasyMainWindow::loadSettings()
|
||||
if (!val.isNull())
|
||||
EASY_GLOBALS.frame_time = val.toFloat();
|
||||
|
||||
val = settings.value("blocks_spacing");
|
||||
if (!val.isNull())
|
||||
EASY_GLOBALS.blocks_spacing = val.toInt();
|
||||
|
||||
val = settings.value("blocks_size_min");
|
||||
if (!val.isNull())
|
||||
EASY_GLOBALS.blocks_size_min = val.toInt();
|
||||
|
||||
val = settings.value("blocks_narrow_size");
|
||||
if (!val.isNull())
|
||||
EASY_GLOBALS.blocks_narrow_size = val.toInt();
|
||||
|
||||
|
||||
auto flag = settings.value("draw_graphics_items_borders");
|
||||
if (!flag.isNull())
|
||||
@ -778,6 +857,9 @@ void EasyMainWindow::saveSettingsAndGeometry()
|
||||
settings.setValue("port", (quint32)m_lastPort);
|
||||
settings.setValue("chrono_text_position", static_cast<int>(EASY_GLOBALS.chrono_text_position));
|
||||
settings.setValue("frame_time", EASY_GLOBALS.frame_time);
|
||||
settings.setValue("blocks_spacing", EASY_GLOBALS.blocks_spacing);
|
||||
settings.setValue("blocks_size_min", EASY_GLOBALS.blocks_size_min);
|
||||
settings.setValue("blocks_narrow_size", EASY_GLOBALS.blocks_narrow_size);
|
||||
settings.setValue("draw_graphics_items_borders", EASY_GLOBALS.draw_graphics_items_borders);
|
||||
settings.setValue("hide_narrow_children", EASY_GLOBALS.hide_narrow_children);
|
||||
settings.setValue("collapse_items_on_tree_close", EASY_GLOBALS.collapse_items_on_tree_close);
|
||||
|
@ -235,6 +235,9 @@ protected slots:
|
||||
void onBindExpandStatusChange(bool);
|
||||
void onExpandAllClicked(bool);
|
||||
void onCollapseAllClicked(bool);
|
||||
void onSpacingChange(int _value);
|
||||
void onMinSizeChange(int _value);
|
||||
void onNarrowSizeChange(int _value);
|
||||
void onFileReaderTimeout();
|
||||
void onListenerTimerTimeout();
|
||||
void onFileReaderCancel();
|
||||
|
Loading…
x
Reference in New Issue
Block a user