0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

#0 [Gui] Large portion of refactoring; Replaced bunch of threads with thread pool; Small fixes for arbitrary values viewer

This commit is contained in:
Victor Zarubkin 2018-01-28 20:52:17 +03:00
parent 1f6d3c2a7d
commit 1a333e4f01
42 changed files with 1356 additions and 1067 deletions

View File

@ -42,6 +42,10 @@ if (Qt5Widgets_FOUND)
graphics_slider_area.cpp graphics_slider_area.cpp
main_window.h main_window.h
main_window.cpp main_window.cpp
thread_pool.h
thread_pool.cpp
thread_pool_task.h
thread_pool_task.cpp
tree_widget_item.h tree_widget_item.h
tree_widget_item.cpp tree_widget_item.cpp
tree_widget_loader.h tree_widget_loader.h

View File

@ -71,6 +71,9 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EASY_CONSTEXPR int ChartBound = 2; ///< Top and bottom bounds for chart
EASY_CONSTEXPR int ChartBounds = ChartBound << 1;
void getChartPoints(const ArbitraryValuesCollection& _collection, Points& _points, qreal& _minValue, qreal& _maxValue) void getChartPoints(const ArbitraryValuesCollection& _collection, Points& _points, qreal& _minValue, qreal& _maxValue)
{ {
_minValue = 1e300; _minValue = 1e300;
@ -151,7 +154,7 @@ ArbitraryValuesCollection::ArbitraryValuesCollection()
ArbitraryValuesCollection::~ArbitraryValuesCollection() ArbitraryValuesCollection::~ArbitraryValuesCollection()
{ {
join();
} }
const ArbitraryValuesMap& ArbitraryValuesCollection::valuesMap() const const ArbitraryValuesMap& ArbitraryValuesCollection::valuesMap() const
@ -196,9 +199,13 @@ void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, p
m_jobType = ValuesJob; m_jobType = ValuesJob;
if (_valueId == 0) if (_valueId == 0)
m_collectorThread = std::thread(&This::collectByName, this, _threadId, _valueName); {
m_worker.enqueue([this, _threadId, _valueName] { collectByName(_threadId, _valueName); }, m_bInterrupt);
}
else else
m_collectorThread = std::thread(&This::collectById, this, _threadId, _valueId); {
m_worker.enqueue([this, _threadId, _valueId] { collectById(_threadId, _valueId); }, m_bInterrupt);
}
} }
void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, profiler::vin_t _valueId, const char* _valueName, profiler::timestamp_t _beginTime) void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, profiler::vin_t _valueId, const char* _valueName, profiler::timestamp_t _beginTime)
@ -213,9 +220,13 @@ void ArbitraryValuesCollection::collectValues(profiler::thread_id_t _threadId, p
m_jobType = ValuesJob | PointsJob; m_jobType = ValuesJob | PointsJob;
if (_valueId == 0) if (_valueId == 0)
m_collectorThread = std::thread(&This::collectByName, this, _threadId, _valueName); {
m_worker.enqueue([this, _threadId, _valueName] { collectByName(_threadId, _valueName); }, m_bInterrupt);
}
else else
m_collectorThread = std::thread(&This::collectById, this, _threadId, _valueId); {
m_worker.enqueue([this, _threadId, _valueId] { collectById(_threadId, _valueId); }, m_bInterrupt);
}
} }
bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime) bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime)
@ -223,8 +234,7 @@ bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime
if (status() != Ready || m_values.empty()) if (status() != Ready || m_values.empty())
return false; return false;
if (m_collectorThread.joinable()) m_worker.dequeue();
m_collectorThread.join();
setStatus(InProgress); setStatus(InProgress);
m_points.clear(); m_points.clear();
@ -233,38 +243,22 @@ bool ArbitraryValuesCollection::calculatePoints(profiler::timestamp_t _beginTime
m_maxValue = -1e300; m_maxValue = -1e300;
m_jobType = PointsJob; m_jobType = PointsJob;
m_collectorThread = std::thread([this] m_worker.enqueue([this]
{ {
getChartPoints(*this, m_points, m_minValue, m_maxValue); getChartPoints(*this, m_points, m_minValue, m_maxValue);
setStatus(Ready); setStatus(Ready);
}); }, m_bInterrupt);
return true; return true;
} }
void ArbitraryValuesCollection::interrupt() void ArbitraryValuesCollection::interrupt()
{ {
if (m_collectorThread.joinable()) m_worker.dequeue();
{
m_bInterrupt.store(true, std::memory_order_release);
m_collectorThread.join();
m_bInterrupt.store(false, std::memory_order_release);
setStatus(Idle); setStatus(Idle);
m_jobType = None; m_jobType = None;
m_values.clear(); m_values.clear();
} }
}
void ArbitraryValuesCollection::join()
{
if (m_collectorThread.joinable())
{
m_bInterrupt.store(true, std::memory_order_release);
m_collectorThread.join();
m_bInterrupt.store(false, std::memory_order_release);
}
}
void ArbitraryValuesCollection::setStatus(JobStatus _status) void ArbitraryValuesCollection::setStatus(JobStatus _status)
{ {
@ -438,8 +432,8 @@ void ArbitraryValuesChartItem::paint(QPainter* _painter, const QStyleOptionGraph
if (!EASY_GLOBALS.scene.empty) if (!EASY_GLOBALS.scene.empty)
{ {
const auto range = bindMode ? widget->sliderWidth() : widget->range(); const auto range = bindMode ? widget->sliderWidth() : widget->range();
paintMouseIndicator(_painter, m_boundingRect.top(), bottom, width, m_boundingRect.height(), font_h, paintMouseIndicator(_painter, m_boundingRect.top(), bottom, width,
widget->value(), range); m_boundingRect.height(), font_h, widget->value(), range);
} }
_painter->setPen(Qt::darkGray); _painter->setPen(Qt::darkGray);
@ -456,21 +450,25 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
return; return;
const auto x = m_mousePos.x(); const auto x = m_mousePos.x();
const auto y = m_mousePos.y(); auto y = m_mousePos.y();
// Horizontal // Horizontal
const bool visibleY = (_top < y && y < _bottom); const bool visibleY = (_top < y && y < _bottom);
if (visibleY) y = estd::clamp(_top, y, _bottom);
//if (visibleY)
{ {
_height -= ChartBounds;
const int half_font_h = _font_h >> 1; const int half_font_h = _font_h >> 1;
const auto value = m_minValue + ((_bottom - 2 - y) / (_height - 4)) * (m_maxValue - m_minValue); const auto yvalue = estd::clamp(_top + ChartBound, y, _bottom - ChartBound);
const auto value = m_minValue + ((_bottom - ChartBound - yvalue) / _height) * (m_maxValue - m_minValue);
const auto mouseStr = QString::number(value, 'f', 3); const auto mouseStr = QString::number(value, 'f', 3);
const int textWidth = _painter->fontMetrics().width(mouseStr) + 3; const int textWidth = _painter->fontMetrics().width(mouseStr) + 3;
const QRectF rect(0, y - _font_h - 2, _width, 4 + (_font_h << 1)); const QRectF rect(0, y - _font_h - 2, _width - 3, 4 + (_font_h << 1));
_painter->setPen(Qt::blue); _painter->setPen(Qt::blue);
qreal left = 0, right = _width; qreal left = 0, right = _width - 3;
const Qt::AlignmentFlag alignment = x < textWidth ? Qt::AlignRight : Qt::AlignLeft; const Qt::AlignmentFlag alignment = x < textWidth ? Qt::AlignRight : Qt::AlignLeft;
if (y > _bottom - half_font_h) if (y > _bottom - half_font_h)
@ -485,11 +483,12 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
{ {
_painter->drawText(rect, alignment | Qt::AlignVCenter, mouseStr); _painter->drawText(rect, alignment | Qt::AlignVCenter, mouseStr);
if (x < textWidth) if (x < textWidth)
right = _width - textWidth; right = _width - textWidth - 3;
else else
left = textWidth; left = textWidth;
} }
if (visibleY)
_painter->drawLine(QLineF(left, y, right, y)); _painter->drawLine(QLineF(left, y, right, y));
} }
@ -507,8 +506,8 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
else if (x > (_width - textWidthHalf)) else if (x > (_width - textWidthHalf))
left = _width - textWidth; left = _width - textWidth;
if (!visibleY) //if (!visibleY)
_painter->setPen(Qt::blue); // _painter->setPen(Qt::blue);
const QRectF rect(left, _bottom + 2, textWidth, _font_h); const QRectF rect(left, _bottom + 2, textWidth, _font_h);
_painter->drawText(rect, Qt::AlignCenter, mouseStr); _painter->drawText(rect, Qt::AlignCenter, mouseStr);
@ -526,9 +525,21 @@ bool ArbitraryValuesChartItem::updateImage()
m_imageScaleUpdate = widget->range() / widget->sliderWidth(); m_imageScaleUpdate = widget->range() / widget->sliderWidth();
m_imageOriginUpdate = widget->bindMode() ? (widget->value() - widget->sliderWidth() * 3) : widget->minimum(); m_imageOriginUpdate = widget->bindMode() ? (widget->value() - widget->sliderWidth() * 3) : widget->minimum();
m_workerThread = std::thread(&This::updateImageAsync, this, m_boundingRect, widget->getWindowScale(), // Ugly, but doen't use exceeded count of threads
widget->minimum(), widget->maximum(), widget->range(), widget->value(), widget->sliderWidth(), const auto rect = m_boundingRect;
widget->bindMode(), EASY_GLOBALS.begin_time, EASY_GLOBALS.auto_adjust_chart_height); const auto scale = widget->getWindowScale();
const auto left = widget->minimum();
const auto right = widget->maximum();
const auto value = widget->value();
const auto window = widget->sliderWidth();
const auto bindMode = widget->bindMode();
const auto beginTime = EASY_GLOBALS.begin_time;
const auto autoHeight = EASY_GLOBALS.auto_adjust_chart_height;
m_worker.enqueue([this, rect, scale, left, right, value, window, bindMode, beginTime, autoHeight]
{
updateImageAsync(rect, scale, left, right, right - left, value, window, bindMode,
beginTime, autoHeight);
}, m_bReady);
return true; return true;
} }
@ -708,8 +719,8 @@ void ArbitraryValuesChartItem::updateImageAsync(QRectF _boundingRect, qreal _cur
{ {
y = maxValue - y; y = maxValue - y;
y /= height; y /= height;
y *= _boundingRect.height() - 4; y *= _boundingRect.height() - ChartBounds;
y += 2; y += ChartBound;
} }
return y; return y;
@ -878,7 +889,7 @@ GraphicsChart::GraphicsChart(QWidget* _parent)
m_chartItem->setPos(0, 0); m_chartItem->setPos(0, 0);
m_chartItem->setBoundingRect(0, rect.top() + margin(), scene()->width(), rect.height() - margins() - 1); m_chartItem->setBoundingRect(0, rect.top() + margin(), scene()->width(), rect.height() - margins() - 1);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::autoAdjustChartChanged, this, &This::onAutoAdjustChartChanged); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::autoAdjustChartChanged, this, &This::onAutoAdjustChartChanged);
m_chartItem->updateImage(); m_chartItem->updateImage();
} }
@ -1040,7 +1051,7 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(QWidget* _parent)
//m_treeWidget->setSortingEnabled(false); //m_treeWidget->setSortingEnabled(false);
m_treeWidget->setColumnCount(int_cast(ArbitraryColumns::Count)); m_treeWidget->setColumnCount(int_cast(ArbitraryColumns::Count));
m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows); m_treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
m_treeWidget->setItemDelegateForColumn(0, new EasyTreeViewFirstColumnItemDelegate(this)); m_treeWidget->setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(this));
auto headerItem = new QTreeWidgetItem(); auto headerItem = new QTreeWidgetItem();
headerItem->setText(int_cast(ArbitraryColumns::Type), "Type"); headerItem->setText(int_cast(ArbitraryColumns::Type), "Type");
@ -1056,9 +1067,9 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(QWidget* _parent)
connect(m_treeWidget, &QTreeWidget::currentItemChanged, this, &This::onCurrentItemChanged); connect(m_treeWidget, &QTreeWidget::currentItemChanged, this, &This::onCurrentItemChanged);
auto globalEvents = &EASY_GLOBALS.events; auto globalEvents = &EASY_GLOBALS.events;
connect(globalEvents, &profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChanged); connect(globalEvents, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::selectedBlockIdChanged, this, &This::onSelectedBlockIdChanged); connect(globalEvents, &profiler_gui::GlobalSignals::selectedBlockIdChanged, this, &This::onSelectedBlockIdChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::fileOpened, this, &This::rebuild); connect(globalEvents, &profiler_gui::GlobalSignals::fileOpened, this, &This::rebuild);
loadSettings(); loadSettings();
@ -1182,7 +1193,6 @@ void ArbitraryValuesWidget::onCollectionsTimeout()
{ {
if (item->collection()->status() != ArbitraryValuesCollection::InProgress) if (item->collection()->status() != ArbitraryValuesCollection::InProgress)
{ {
item->collection()->join();
collections.push_back(CollectionPaintData {item->collection(), item->color(), collections.push_back(CollectionPaintData {item->collection(), item->color(),
ChartType::Line, item == m_treeWidget->currentItem()}); ChartType::Line, item == m_treeWidget->currentItem()});
} }

View File

@ -67,10 +67,10 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <string> #include <string>
#include <thread>
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include "graphics_slider_area.h" #include "graphics_slider_area.h"
#include "thread_pool_task.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -91,7 +91,7 @@ private:
ArbitraryValuesMap m_values; ArbitraryValuesMap m_values;
Points m_points; Points m_points;
std::thread m_collectorThread; ThreadPoolTask m_worker;
profiler::timestamp_t m_beginTime; profiler::timestamp_t m_beginTime;
qreal m_minValue; qreal m_minValue;
qreal m_maxValue; qreal m_maxValue;
@ -116,7 +116,6 @@ public:
void collectValues(profiler::thread_id_t _threadId, profiler::vin_t _valueId, const char* _valueName, profiler::timestamp_t _beginTime); void collectValues(profiler::thread_id_t _threadId, profiler::vin_t _valueId, const char* _valueName, profiler::timestamp_t _beginTime);
bool calculatePoints(profiler::timestamp_t _beginTime); bool calculatePoints(profiler::timestamp_t _beginTime);
void interrupt(); void interrupt();
void join();
private: private:

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
* : * :
* : * 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.
* : * :
* : * 2016/09/15 Victor Zarubkin: Moved sources of EasyGraphicsItem and EasyChronometerItem to separate files. * : * 2016/09/15 Victor Zarubkin: Moved sources of BlocksGraphicsItem and GraphicsRulerItem to separate files.
* : * :
* : * * : *
* ----------------- : * ----------------- :
@ -81,10 +81,10 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class QGraphicsProxyWidget; class QGraphicsProxyWidget;
class EasyGraphicsView; class BlocksGraphicsView;
class EasyGraphicsItem; class BlocksGraphicsItem;
class EasyGraphicsScrollbar; class BlocksGraphicsScrollbar;
class EasyChronometerItem; class GraphicsRulerItem;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -100,35 +100,35 @@ public: \
void setBoundingRect(const QRectF& _rect) { m_boundingRect = _rect; } \ void setBoundingRect(const QRectF& _rect) { m_boundingRect = _rect; } \
} }
EASY_QGRAPHICSITEM(EasyBackgroundItem); EASY_QGRAPHICSITEM(BackgroundItem);
EASY_QGRAPHICSITEM(EasyTimelineIndicatorItem); EASY_QGRAPHICSITEM(TimelineIndicatorItem);
EASY_QGRAPHICSITEM(EasyThreadNameItem); EASY_QGRAPHICSITEM(ThreadNameItem);
#undef EASY_QGRAPHICSITEM #undef EASY_QGRAPHICSITEM
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
struct EasyBoldLabel : public QLabel { struct BoldLabel : public QLabel {
EasyBoldLabel(const QString& _text, QWidget* _parent = nullptr); BoldLabel(const QString& _text, QWidget* _parent = nullptr);
virtual ~EasyBoldLabel(); ~BoldLabel() override;
}; };
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyGraphicsView : public QGraphicsView class BlocksGraphicsView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
private: private:
using Parent = QGraphicsView; using Parent = QGraphicsView;
using This = EasyGraphicsView; using This = BlocksGraphicsView;
using Items = ::std::vector<EasyGraphicsItem*>; using Items = ::std::vector<BlocksGraphicsItem*>;
//using Keys = ::std::unordered_set<int, ::estd::hash<int> >; //using Keys = ::std::unordered_set<int, ::estd::hash<int> >;
Items m_items; ///< Array of all EasyGraphicsItem items Items m_items; ///< Array of all BlocksGraphicsItem items
//Keys m_keys; ///< Pressed keyboard keys //Keys m_keys; ///< Pressed keyboard keys
::profiler_gui::TreeBlocks m_selectedBlocks; ///< Array of items which were selected by selection zone (EasyChronometerItem) ::profiler_gui::TreeBlocks m_selectedBlocks; ///< Array of items which were selected by selection zone (GraphicsRulerItem)
QTimer m_flickerTimer; ///< Timer for flicking behavior QTimer m_flickerTimer; ///< Timer for flicking behavior
QTimer m_idleTimer; ///< QTimer m_idleTimer; ///<
QRectF m_visibleSceneRect; ///< Visible scene rectangle QRectF m_visibleSceneRect; ///< Visible scene rectangle
@ -142,9 +142,9 @@ private:
QPoint m_mousePressPos; ///< Last mouse global position (used by mousePressEvent and mouseMoveEvent) QPoint m_mousePressPos; ///< Last mouse global position (used by mousePressEvent and mouseMoveEvent)
QPoint m_mouseMovePath; ///< Mouse move path between press and release of any button QPoint m_mouseMovePath; ///< Mouse move path between press and release of any button
Qt::MouseButtons m_mouseButtons; ///< Pressed mouse buttons Qt::MouseButtons m_mouseButtons; ///< Pressed mouse buttons
EasyGraphicsScrollbar* m_pScrollbar; ///< Pointer to the graphics scrollbar widget BlocksGraphicsScrollbar* m_pScrollbar; ///< Pointer to the graphics scrollbar widget
EasyChronometerItem* m_chronometerItem; ///< Pointer to the EasyChronometerItem which is displayed when you press right mouse button and move mouse left or right. This item is used to select blocks to display in tree widget. GraphicsRulerItem* m_selectionItem; ///< Pointer to the GraphicsRulerItem which is displayed when you press right mouse button and move mouse left or right. This item is used to select blocks to display in tree widget.
EasyChronometerItem* m_chronometerItemAux; ///< Pointer to the EasyChronometerItem which is displayed when you double click left mouse button and move mouse left or right. This item is used only to measure time. GraphicsRulerItem* m_rulerItem; ///< Pointer to the GraphicsRulerItem which is displayed when you double click left mouse button and move mouse left or right. This item is used only to measure time.
QGraphicsProxyWidget* m_popupWidget; ///< QGraphicsProxyWidget* m_popupWidget; ///<
int m_flickerSpeedX; ///< Current flicking speed x int m_flickerSpeedX; ///< Current flicking speed x
int m_flickerSpeedY; ///< Current flicking speed y int m_flickerSpeedY; ///< Current flicking speed y
@ -156,8 +156,8 @@ private:
public: public:
explicit EasyGraphicsView(QWidget* _parent = nullptr); explicit BlocksGraphicsView(QWidget* _parent = nullptr);
~EasyGraphicsView() override; ~BlocksGraphicsView() override;
// Public virtual methods // Public virtual methods
@ -180,7 +180,7 @@ public:
qreal chronoTime() const; qreal chronoTime() const;
qreal chronoTimeAux() const; qreal chronoTimeAux() const;
void setScrollbar(EasyGraphicsScrollbar* _scrollbar); void setScrollbar(BlocksGraphicsScrollbar* _scrollbar);
void clear(); void clear();
void setTree(const ::profiler::thread_blocks_tree_t& _blocksTree); void setTree(const ::profiler::thread_blocks_tree_t& _blocksTree);
@ -207,16 +207,16 @@ private:
void removePopup(bool _removeFromScene = false); void removePopup(bool _removeFromScene = false);
EasyChronometerItem* createChronometer(bool _main = true); GraphicsRulerItem* createChronometer(bool _main = true);
bool moveChrono(EasyChronometerItem* _chronometerItem, qreal _mouseX); bool moveChrono(GraphicsRulerItem* _chronometerItem, qreal _mouseX);
void initMode(); void initMode();
int updateVisibleSceneRect(); int updateVisibleSceneRect();
void updateTimelineStep(qreal _windowWidth); void updateTimelineStep(qreal _windowWidth);
void scaleTo(qreal _scale); void scaleTo(qreal _scale);
void scrollTo(const EasyGraphicsItem* _item); void scrollTo(const BlocksGraphicsItem* _item);
qreal mapToDiagram(qreal x) const; qreal mapToDiagram(qreal x) const;
void onWheel(qreal _scenePos, int _wheelDelta); void onWheel(qreal _scenePos, int _wheelDelta);
qreal setTree(EasyGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level); qreal setTree(BlocksGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level);
private slots: private slots:
@ -270,30 +270,30 @@ public:
//return PROF_FROM_MILLISECONDS(_pos); //return PROF_FROM_MILLISECONDS(_pos);
} }
}; // END of class EasyGraphicsView. }; // END of class BlocksGraphicsView.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyThreadNamesWidget : public QGraphicsView class ThreadNamesWidget : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
private: private:
using Parent = QGraphicsView; using Parent = QGraphicsView;
using This = EasyThreadNamesWidget; using This = ThreadNamesWidget;
QTimer m_idleTimer; ///< QTimer m_idleTimer; ///<
uint64_t m_idleTime; ///< uint64_t m_idleTime; ///<
EasyGraphicsView* m_view; ///< BlocksGraphicsView* m_view; ///<
QGraphicsProxyWidget* m_popupWidget; ///< QGraphicsProxyWidget* m_popupWidget; ///<
int m_maxLength; ///< int m_maxLength; ///<
const int m_additionalHeight; ///< const int m_additionalHeight; ///<
public: public:
explicit EasyThreadNamesWidget(EasyGraphicsView* _view, int _additionalHeight, QWidget* _parent = nullptr); explicit ThreadNamesWidget(BlocksGraphicsView* _view, int _additionalHeight, QWidget* _parent = nullptr);
~EasyThreadNamesWidget() override; ~ThreadNamesWidget() override;
void mousePressEvent(QMouseEvent* _event) override; void mousePressEvent(QMouseEvent* _event) override;
void mouseDoubleClickEvent(QMouseEvent* _event) override; void mouseDoubleClickEvent(QMouseEvent* _event) override;
@ -307,7 +307,7 @@ public:
void clear(); void clear();
const EasyGraphicsView* view() const const BlocksGraphicsView* view() const
{ {
return m_view; return m_view;
} }
@ -323,27 +323,27 @@ private slots:
void onIdleTimeout(); void onIdleTimeout();
void repaintScene(); void repaintScene();
}; // END of class EasyThreadNamesWidget. }; // END of class ThreadNamesWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyGraphicsViewWidget : public QWidget class DiagramWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
private: private:
class QSplitter* m_splitter; class QSplitter* m_splitter;
EasyGraphicsScrollbar* m_scrollbar; BlocksGraphicsScrollbar* m_scrollbar;
EasyGraphicsView* m_view; BlocksGraphicsView* m_view;
EasyThreadNamesWidget* m_threadNamesWidget; ThreadNamesWidget* m_threadNamesWidget;
public: public:
explicit EasyGraphicsViewWidget(QWidget* _parent = nullptr); explicit DiagramWidget(QWidget* _parent = nullptr);
~EasyGraphicsViewWidget() override; ~DiagramWidget() override;
EasyGraphicsView* view(); BlocksGraphicsView* view();
void clear(); void clear();
void save(class QSettings& settings); void save(class QSettings& settings);
@ -353,7 +353,7 @@ private:
void initWidget(); void initWidget();
}; // END of class EasyGraphicsViewWidget. }; // END of class DiagramWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyTreeWidget and it's auxiliary classes * description : The file contains implementation of BlocksTreeWidget and it's auxiliary classes
* : for displyaing easy_profiler blocks tree. * : for displyaing easy_profiler blocks tree.
* ----------------- : * ----------------- :
* change log : * 2016/06/26 Victor Zarubkin: Moved sources from tree_view.h * change log : * 2016/06/26 Victor Zarubkin: Moved sources from tree_view.h
@ -79,6 +79,7 @@
#include <QByteArray> #include <QByteArray>
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <thread>
#include "blocks_tree_widget.h" #include "blocks_tree_widget.h"
#include "globals.h" #include "globals.h"
@ -136,13 +137,13 @@ const bool SIMPLIFIED_REGIME_COLUMNS[COL_COLUMNS_NUMBER] = {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyTreeWidget::EasyTreeWidget(QWidget* _parent) BlocksTreeWidget::BlocksTreeWidget(QWidget* _parent)
: Parent(_parent) : Parent(_parent)
, m_beginTime(::std::numeric_limits<decltype(m_beginTime)>::max()) , m_beginTime(::std::numeric_limits<decltype(m_beginTime)>::max())
, m_lastFound(nullptr) , m_lastFound(nullptr)
, m_progress(nullptr) , m_progress(nullptr)
, m_hintLabel(nullptr) , m_hintLabel(nullptr)
, m_mode(EasyTreeMode_Plain) , m_mode(TreeMode::Plain)
, m_bLocked(false) , m_bLocked(false)
, m_bSilentExpandCollapse(false) , m_bSilentExpandCollapse(false)
{ {
@ -159,7 +160,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
auto header_item = new QTreeWidgetItem(); auto header_item = new QTreeWidgetItem();
auto f = header()->font(); auto f = header()->font();
f.setBold(true); f.setBold(true);
header()->setFont(f);// ::profiler_gui::EFont("Helvetica", 9, QFont::Bold)); header()->setFont(f);// profiler_gui::EFont("Helvetica", 9, QFont::Bold));
header_item->setText(COL_NAME, "Name"); header_item->setText(COL_NAME, "Name");
@ -199,7 +200,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
header_item->setText(COL_ACTIVE_TIME, "Active time"); header_item->setText(COL_ACTIVE_TIME, "Active time");
header_item->setText(COL_ACTIVE_PERCENT, "Active %"); header_item->setText(COL_ACTIVE_PERCENT, "Active %");
auto color = QColor::fromRgb(::profiler::colors::DeepOrange900); auto color = QColor::fromRgb(profiler::colors::DeepOrange900);
header_item->setForeground(COL_MIN_PER_THREAD, color); header_item->setForeground(COL_MIN_PER_THREAD, color);
header_item->setForeground(COL_MAX_PER_THREAD, color); header_item->setForeground(COL_MAX_PER_THREAD, color);
header_item->setForeground(COL_AVERAGE_PER_THREAD, color); header_item->setForeground(COL_AVERAGE_PER_THREAD, color);
@ -207,7 +208,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
header_item->setForeground(COL_PERCENT_SUM_PER_THREAD, color); header_item->setForeground(COL_PERCENT_SUM_PER_THREAD, color);
header_item->setForeground(COL_DURATION_SUM_PER_THREAD, color); header_item->setForeground(COL_DURATION_SUM_PER_THREAD, color);
color = QColor::fromRgb(::profiler::colors::Blue900); color = QColor::fromRgb(profiler::colors::Blue900);
header_item->setForeground(COL_MIN_PER_FRAME, color); header_item->setForeground(COL_MIN_PER_FRAME, color);
header_item->setForeground(COL_MAX_PER_FRAME, color); header_item->setForeground(COL_MAX_PER_FRAME, color);
header_item->setForeground(COL_AVERAGE_PER_FRAME, color); header_item->setForeground(COL_AVERAGE_PER_FRAME, color);
@ -216,7 +217,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
header_item->setForeground(COL_DURATION_SUM_PER_FRAME, color); header_item->setForeground(COL_DURATION_SUM_PER_FRAME, color);
header_item->setForeground(COL_PERCENT_PER_FRAME, color); header_item->setForeground(COL_PERCENT_PER_FRAME, color);
color = QColor::fromRgb(::profiler::colors::Teal900); color = QColor::fromRgb(profiler::colors::Teal900);
header_item->setForeground(COL_MIN_PER_PARENT, color); header_item->setForeground(COL_MIN_PER_PARENT, color);
header_item->setForeground(COL_MAX_PER_PARENT, color); header_item->setForeground(COL_MAX_PER_PARENT, color);
header_item->setForeground(COL_AVERAGE_PER_PARENT, color); header_item->setForeground(COL_AVERAGE_PER_PARENT, color);
@ -227,8 +228,8 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
setHeaderItem(header_item); setHeaderItem(header_item);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedThreadChanged, this, &This::onSelectedThreadChange, Qt::QueuedConnection); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedThreadChanged, this, &This::onSelectedThreadChange, Qt::QueuedConnection);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange, Qt::QueuedConnection); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange, Qt::QueuedConnection);
connect(&m_fillTimer, &QTimer::timeout, this, &This::onFillTimerTimeout); connect(&m_fillTimer, &QTimer::timeout, this, &This::onFillTimerTimeout);
loadSettings(); loadSettings();
@ -236,7 +237,7 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
m_columnsHiddenStatus[0] = 0; m_columnsHiddenStatus[0] = 0;
setColumnHidden(0, false); setColumnHidden(0, false);
if (m_mode == EasyTreeMode_Full) if (m_mode == TreeMode::Full)
{ {
for (int i = 1; i < COL_COLUMNS_NUMBER; ++i) for (int i = 1; i < COL_COLUMNS_NUMBER; ++i)
m_columnsHiddenStatus[i] = isColumnHidden(i) ? 1 : 0; m_columnsHiddenStatus[i] = isColumnHidden(i) ? 1 : 0;
@ -266,14 +267,14 @@ EasyTreeWidget::EasyTreeWidget(QWidget* _parent)
setItemDelegateForColumn(0, new EasyItemDelegate(this)); setItemDelegateForColumn(0, new EasyItemDelegate(this));
} }
EasyTreeWidget::~EasyTreeWidget() BlocksTreeWidget::~BlocksTreeWidget()
{ {
saveSettings(); saveSettings();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onFillTimerTimeout() void BlocksTreeWidget::onFillTimerTimeout()
{ {
if (m_hierarchyBuilder.done()) if (m_hierarchyBuilder.done())
{ {
@ -300,7 +301,7 @@ void EasyTreeWidget::onFillTimerTimeout()
setSortingEnabled(true); setSortingEnabled(true);
sortByColumn(COL_BEGIN, Qt::AscendingOrder); // sort by begin time sortByColumn(COL_BEGIN, Qt::AscendingOrder); // sort by begin time
if (m_mode == EasyTreeMode_Plain) // and after that, sort by frame % if (m_mode == TreeMode::Plain) // and after that, sort by frame %
sortByColumn(COL_PERCENT_PER_FRAME, Qt::DescendingOrder); sortByColumn(COL_PERCENT_PER_FRAME, Qt::DescendingOrder);
//resizeColumnToContents(COL_NAME); //resizeColumnToContents(COL_NAME);
@ -318,7 +319,7 @@ void EasyTreeWidget::onFillTimerTimeout()
} }
} }
void EasyTreeWidget::setTree(const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree) void BlocksTreeWidget::setTree(const unsigned int _blocksNumber, const profiler::thread_blocks_tree_t& _blocksTree)
{ {
clearSilent(); clearSilent();
@ -346,7 +347,7 @@ void EasyTreeWidget::setTree(const unsigned int _blocksNumber, const ::profiler:
//} //}
} }
void EasyTreeWidget::setTreeBlocks(const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _session_begin_time, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict) void BlocksTreeWidget::setTreeBlocks(const profiler_gui::TreeBlocks& _blocks, profiler::timestamp_t _session_begin_time, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict)
{ {
clearSilent(); clearSilent();
@ -389,7 +390,7 @@ void EasyTreeWidget::setTreeBlocks(const ::profiler_gui::TreeBlocks& _blocks, ::
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::clearSilent(bool _global) void BlocksTreeWidget::clearSilent(bool _global)
{ {
const QSignalBlocker b(this); const QSignalBlocker b(this);
@ -419,7 +420,7 @@ void EasyTreeWidget::clearSilent(bool _global)
#ifdef EASY_TREE_WIDGET__USE_VECTOR #ifdef EASY_TREE_WIDGET__USE_VECTOR
auto& gui_block = item->guiBlock(); auto& gui_block = item->guiBlock();
gui_block.expanded = false; gui_block.expanded = false;
::profiler_gui::set_max(gui_block.tree_item); profiler_gui::set_max(gui_block.tree_item);
#else #else
item.second->guiBlock().expanded = false; item.second->guiBlock().expanded = false;
#endif #endif
@ -427,7 +428,7 @@ void EasyTreeWidget::clearSilent(bool _global)
#ifdef EASY_TREE_WIDGET__USE_VECTOR #ifdef EASY_TREE_WIDGET__USE_VECTOR
else for (auto item : m_items) else for (auto item : m_items)
{ {
::profiler_gui::set_max(item->guiBlock().tree_item); profiler_gui::set_max(item->guiBlock().tree_item);
} }
#endif #endif
} }
@ -461,7 +462,7 @@ void EasyTreeWidget::clearSilent(bool _global)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int EasyTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags) int BlocksTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
{ {
if (m_bLocked || _str.isEmpty()) if (m_bLocked || _str.isEmpty())
return 0; return 0;
@ -511,7 +512,7 @@ int EasyTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
return itemsList.size(); return itemsList.size();
} }
int EasyTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags) int BlocksTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
{ {
if (m_bLocked || _str.isEmpty()) if (m_bLocked || _str.isEmpty())
return 0; return 0;
@ -559,7 +560,7 @@ int EasyTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event) void BlocksTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
if (m_bLocked) if (m_bLocked)
{ {
@ -568,7 +569,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
} }
const auto col = currentColumn(); const auto col = currentColumn();
auto item = static_cast<EasyTreeWidgetItem*>(currentItem()); auto item = static_cast<TreeWidgetItem*>(currentItem());
QMenu menu; QMenu menu;
menu.setToolTipsVisible(true); menu.setToolTipsVisible(true);
QAction* action = nullptr; QAction* action = nullptr;
@ -604,16 +605,16 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
auto actionHierarchy = new QAction("Hierarchy mode", actionGroup); auto actionHierarchy = new QAction("Hierarchy mode", actionGroup);
actionHierarchy->setCheckable(true); actionHierarchy->setCheckable(true);
actionHierarchy->setChecked(m_mode == EasyTreeMode_Full); actionHierarchy->setChecked(m_mode == TreeMode::Full);
actionHierarchy->setToolTip("Display full blocks hierarchy"); actionHierarchy->setToolTip("Display full blocks hierarchy");
actionHierarchy->setData((quint32)EasyTreeMode_Full); actionHierarchy->setData((quint32)TreeMode::Full);
menu.addAction(actionHierarchy); menu.addAction(actionHierarchy);
auto actionPlain = new QAction("Plain mode", actionGroup); auto actionPlain = new QAction("Plain mode", actionGroup);
actionPlain->setCheckable(true); actionPlain->setCheckable(true);
actionPlain->setChecked(m_mode == EasyTreeMode_Plain); actionPlain->setChecked(m_mode == TreeMode::Plain);
actionPlain->setToolTip("Display plain list of blocks per frame.\nSome columns are disabled with this mode."); actionPlain->setToolTip("Display plain list of blocks per frame.\nSome columns are disabled with this mode.");
actionPlain->setData((quint32)EasyTreeMode_Plain); actionPlain->setData((quint32)TreeMode::Plain);
menu.addAction(actionPlain); menu.addAction(actionPlain);
connect(actionHierarchy, &QAction::triggered, this, &This::onModeChange); connect(actionHierarchy, &QAction::triggered, this, &This::onModeChange);
@ -635,7 +636,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
case COL_MAX_PER_FRAME: case COL_MAX_PER_FRAME:
{ {
auto& block = item->block(); auto& block = item->block();
auto i = ::profiler_gui::numeric_max<uint32_t>(); auto i = profiler_gui::numeric_max<uint32_t>();
switch (col) switch (col)
{ {
case COL_MIN_PER_THREAD: i = block.per_thread_stats->min_duration_block; break; case COL_MIN_PER_THREAD: i = block.per_thread_stats->min_duration_block; break;
@ -646,7 +647,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
case COL_MAX_PER_FRAME: i = block.per_frame_stats->max_duration_block; break; case COL_MAX_PER_FRAME: i = block.per_frame_stats->max_duration_block; break;
} }
if (i != ::profiler_gui::numeric_max(i)) if (i != profiler_gui::numeric_max(i))
{ {
menu.addSeparator(); menu.addSeparator();
auto itemAction = new QAction("Jump to such item", nullptr); auto itemAction = new QAction("Jump to such item", nullptr);
@ -676,12 +677,12 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
action->setToolTip(ToolTipValue);\ action->setToolTip(ToolTipValue);\
connect(action, &QAction::triggered, this, &This::onBlockStatusChangeClicked) connect(action, &QAction::triggered, this, &This::onBlockStatusChangeClicked)
ADD_STATUS_ACTION("Off", ::profiler::OFF, "Do not profile this block."); ADD_STATUS_ACTION("Off", profiler::OFF, "Do not profile this block.");
ADD_STATUS_ACTION("On", ::profiler::ON, "Profile this block\nif parent enabled children."); ADD_STATUS_ACTION("On", profiler::ON, "Profile this block\nif parent enabled children.");
ADD_STATUS_ACTION("Force-On", ::profiler::FORCE_ON, "Always profile this block even\nif it's parent disabled children."); ADD_STATUS_ACTION("Force-On", profiler::FORCE_ON, "Always profile this block even\nif it's parent disabled children.");
ADD_STATUS_ACTION("Off-recursive", ::profiler::OFF_RECURSIVE, "Do not profile neither this block\nnor it's children."); ADD_STATUS_ACTION("Off-recursive", profiler::OFF_RECURSIVE, "Do not profile neither this block\nnor it's children.");
ADD_STATUS_ACTION("On-without-children", ::profiler::ON_WITHOUT_CHILDREN, "Profile this block, but\ndo not profile it's children."); ADD_STATUS_ACTION("On-without-children", profiler::ON_WITHOUT_CHILDREN, "Profile this block, but\ndo not profile it's children.");
ADD_STATUS_ACTION("Force-On-without-children", ::profiler::FORCE_ON_WITHOUT_CHILDREN, "Always profile this block, but\ndo not profile it's children."); ADD_STATUS_ACTION("Force-On-without-children", profiler::FORCE_ON_WITHOUT_CHILDREN, "Always profile this block, but\ndo not profile it's children.");
#undef ADD_STATUS_ACTION #undef ADD_STATUS_ACTION
submenu->setEnabled(EASY_GLOBALS.connected); submenu->setEnabled(EASY_GLOBALS.connected);
@ -698,7 +699,7 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
columnAction->setData(i); columnAction->setData(i);
columnAction->setCheckable(true); columnAction->setCheckable(true);
columnAction->setChecked(m_columnsHiddenStatus[i] == 0); columnAction->setChecked(m_columnsHiddenStatus[i] == 0);
if ((m_mode == EasyTreeMode_Full || SIMPLIFIED_REGIME_COLUMNS[i])) if ((m_mode == TreeMode::Full || SIMPLIFIED_REGIME_COLUMNS[i]))
connect(columnAction, &QAction::triggered, this, &This::onHideShowColumn); connect(columnAction, &QAction::triggered, this, &This::onHideShowColumn);
else else
columnAction->setEnabled(false); columnAction->setEnabled(false);
@ -712,19 +713,19 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::resizeEvent(QResizeEvent* _event) void BlocksTreeWidget::resizeEvent(QResizeEvent* _event)
{ {
Parent::resizeEvent(_event); Parent::resizeEvent(_event);
alignProgressBar(); alignProgressBar();
} }
void EasyTreeWidget::moveEvent(QMoveEvent* _event) void BlocksTreeWidget::moveEvent(QMoveEvent* _event)
{ {
Parent::moveEvent(_event); Parent::moveEvent(_event);
alignProgressBar(); alignProgressBar();
} }
void EasyTreeWidget::alignProgressBar() void BlocksTreeWidget::alignProgressBar()
{ {
auto center = rect().center(); auto center = rect().center();
auto pos = mapToGlobal(center); auto pos = mapToGlobal(center);
@ -735,7 +736,7 @@ void EasyTreeWidget::alignProgressBar()
m_hintLabel->move(center.x() - (m_hintLabel->width() >> 1), std::max(center.y() - (m_hintLabel->height() >> 1), header()->height())); m_hintLabel->move(center.x() - (m_hintLabel->width() >> 1), std::max(center.y() - (m_hintLabel->height() >> 1), header()->height()));
} }
void EasyTreeWidget::destroyProgressDialog() void BlocksTreeWidget::destroyProgressDialog()
{ {
if (m_progress != nullptr) if (m_progress != nullptr)
{ {
@ -745,7 +746,7 @@ void EasyTreeWidget::destroyProgressDialog()
} }
} }
void EasyTreeWidget::createProgressDialog() void BlocksTreeWidget::createProgressDialog()
{ {
destroyProgressDialog(); destroyProgressDialog();
@ -760,7 +761,7 @@ void EasyTreeWidget::createProgressDialog()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onJumpToItemClicked(bool) void BlocksTreeWidget::onJumpToItemClicked(bool)
{ {
auto action = qobject_cast<QAction*>(sender()); auto action = qobject_cast<QAction*>(sender());
if (action == nullptr) if (action == nullptr)
@ -771,11 +772,11 @@ void EasyTreeWidget::onJumpToItemClicked(bool)
if (block_index < EASY_GLOBALS.gui_blocks.size()) if (block_index < EASY_GLOBALS.gui_blocks.size())
EASY_GLOBALS.selected_block_id = easyBlock(block_index).tree.node->id(); EASY_GLOBALS.selected_block_id = easyBlock(block_index).tree.node->id();
else else
::profiler_gui::set_max(EASY_GLOBALS.selected_block_id); profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
emit EASY_GLOBALS.events.selectedBlockChanged(block_index); emit EASY_GLOBALS.events.selectedBlockChanged(block_index);
} }
void EasyTreeWidget::onCollapseAllClicked(bool) void BlocksTreeWidget::onCollapseAllClicked(bool)
{ {
const QSignalBlocker b(this); const QSignalBlocker b(this);
@ -796,7 +797,7 @@ void EasyTreeWidget::onCollapseAllClicked(bool)
} }
} }
void EasyTreeWidget::onExpandAllClicked(bool) void BlocksTreeWidget::onExpandAllClicked(bool)
{ {
const QSignalBlocker blocker(this); const QSignalBlocker blocker(this);
@ -821,9 +822,9 @@ void EasyTreeWidget::onExpandAllClicked(bool)
} }
} }
void EasyTreeWidget::onCollapseAllChildrenClicked(bool) void BlocksTreeWidget::onCollapseAllChildrenClicked(bool)
{ {
auto current = static_cast<EasyTreeWidgetItem*>(currentItem()); auto current = static_cast<TreeWidgetItem*>(currentItem());
if (current != nullptr) if (current != nullptr)
{ {
const QSignalBlocker b(this); const QSignalBlocker b(this);
@ -836,9 +837,9 @@ void EasyTreeWidget::onCollapseAllChildrenClicked(bool)
} }
} }
void EasyTreeWidget::onExpandAllChildrenClicked(bool) void BlocksTreeWidget::onExpandAllChildrenClicked(bool)
{ {
auto current = static_cast<EasyTreeWidgetItem*>(currentItem()); auto current = static_cast<TreeWidgetItem*>(currentItem());
if (current != nullptr) if (current != nullptr)
{ {
const QSignalBlocker b(this); const QSignalBlocker b(this);
@ -854,12 +855,12 @@ void EasyTreeWidget::onExpandAllChildrenClicked(bool)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onBlockStatusChangeClicked(bool _checked) void BlocksTreeWidget::onBlockStatusChangeClicked(bool _checked)
{ {
if (!_checked) if (!_checked)
return; return;
auto item = static_cast<EasyTreeWidgetItem*>(currentItem()); auto item = static_cast<TreeWidgetItem*>(currentItem());
if (item == nullptr) if (item == nullptr)
return; return;
@ -867,14 +868,14 @@ void EasyTreeWidget::onBlockStatusChangeClicked(bool _checked)
if (action != nullptr) if (action != nullptr)
{ {
auto& desc = easyDescriptor(item->block().node->id()); auto& desc = easyDescriptor(item->block().node->id());
desc.setStatus(static_cast<::profiler::EasyBlockStatus>(action->data().toUInt())); desc.setStatus(static_cast<profiler::EasyBlockStatus>(action->data().toUInt()));
emit EASY_GLOBALS.events.blockStatusChanged(desc.id(), desc.status()); emit EASY_GLOBALS.events.blockStatusChanged(desc.id(), desc.status());
} }
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onItemExpand(QTreeWidgetItem* _item) void BlocksTreeWidget::onItemExpand(QTreeWidgetItem* _item)
{ {
if (!EASY_GLOBALS.bind_scene_and_tree_expand_status || _item->parent() == nullptr) if (!EASY_GLOBALS.bind_scene_and_tree_expand_status || _item->parent() == nullptr)
{ {
@ -882,7 +883,7 @@ void EasyTreeWidget::onItemExpand(QTreeWidgetItem* _item)
return; return;
} }
static_cast<EasyTreeWidgetItem*>(_item)->guiBlock().expanded = true; static_cast<TreeWidgetItem*>(_item)->guiBlock().expanded = true;
if (!m_bSilentExpandCollapse) if (!m_bSilentExpandCollapse)
{ {
@ -891,12 +892,12 @@ void EasyTreeWidget::onItemExpand(QTreeWidgetItem* _item)
} }
} }
void EasyTreeWidget::onItemCollapse(QTreeWidgetItem* _item) void BlocksTreeWidget::onItemCollapse(QTreeWidgetItem* _item)
{ {
if (!EASY_GLOBALS.bind_scene_and_tree_expand_status || _item->parent() == nullptr) if (!EASY_GLOBALS.bind_scene_and_tree_expand_status || _item->parent() == nullptr)
return; return;
static_cast<EasyTreeWidgetItem*>(_item)->guiBlock().expanded = false; static_cast<TreeWidgetItem*>(_item)->guiBlock().expanded = false;
if (!m_bSilentExpandCollapse) if (!m_bSilentExpandCollapse)
emit EASY_GLOBALS.events.itemsExpandStateChanged(); emit EASY_GLOBALS.events.itemsExpandStateChanged();
@ -904,36 +905,36 @@ void EasyTreeWidget::onItemCollapse(QTreeWidgetItem* _item)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _previous) void BlocksTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _previous)
{ {
if (_previous != nullptr) if (_previous != nullptr)
static_cast<EasyTreeWidgetItem*>(_previous)->setBold(false); static_cast<TreeWidgetItem*>(_previous)->setBold(false);
if (_item == nullptr) if (_item == nullptr)
{ {
::profiler_gui::set_max(EASY_GLOBALS.selected_block); profiler_gui::set_max(EASY_GLOBALS.selected_block);
::profiler_gui::set_max(EASY_GLOBALS.selected_block_id); profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
} }
else else
{ {
auto item = static_cast<EasyTreeWidgetItem*>(_item); auto item = static_cast<TreeWidgetItem*>(_item);
item->setBold(true); item->setBold(true);
EASY_GLOBALS.selected_block = item->block_index(); EASY_GLOBALS.selected_block = item->block_index();
if (EASY_GLOBALS.selected_block < EASY_GLOBALS.gui_blocks.size()) if (EASY_GLOBALS.selected_block < EASY_GLOBALS.gui_blocks.size())
EASY_GLOBALS.selected_block_id = easyBlock(EASY_GLOBALS.selected_block).tree.node->id(); EASY_GLOBALS.selected_block_id = easyBlock(EASY_GLOBALS.selected_block).tree.node->id();
else else
::profiler_gui::set_max(EASY_GLOBALS.selected_block_id); profiler_gui::set_max(EASY_GLOBALS.selected_block_id);
} }
disconnect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange); disconnect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
emit EASY_GLOBALS.events.selectedBlockChanged(EASY_GLOBALS.selected_block); emit EASY_GLOBALS.events.selectedBlockChanged(EASY_GLOBALS.selected_block);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onSelectedThreadChange(::profiler::thread_id_t _id) void BlocksTreeWidget::onSelectedThreadChange(profiler::thread_id_t _id)
{ {
for (auto& it : m_roots) for (auto& it : m_roots)
{ {
@ -950,11 +951,11 @@ void EasyTreeWidget::onSelectedThreadChange(::profiler::thread_id_t _id)
f->setFocus(); f->setFocus();
} }
void EasyTreeWidget::onSelectedBlockChange(uint32_t _block_index) void BlocksTreeWidget::onSelectedBlockChange(uint32_t _block_index)
{ {
disconnect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange); disconnect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange);
EasyTreeWidgetItem* item = nullptr; TreeWidgetItem* item = nullptr;
if (_block_index < EASY_GLOBALS.gui_blocks.size()) if (_block_index < EASY_GLOBALS.gui_blocks.size())
{ {
@ -969,7 +970,7 @@ void EasyTreeWidget::onSelectedBlockChange(uint32_t _block_index)
#endif #endif
} }
auto previous = static_cast<EasyTreeWidgetItem*>(currentItem()); auto previous = static_cast<TreeWidgetItem*>(currentItem());
if (previous != nullptr) if (previous != nullptr)
previous->setBold(false); previous->setBold(false);
@ -1012,7 +1013,7 @@ void EasyTreeWidget::onSelectedBlockChange(uint32_t _block_index)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::resizeColumnsToContents() void BlocksTreeWidget::resizeColumnsToContents()
{ {
for (int i = 0; i < COL_COLUMNS_NUMBER; ++i) for (int i = 0; i < COL_COLUMNS_NUMBER; ++i)
{ {
@ -1022,7 +1023,7 @@ void EasyTreeWidget::resizeColumnsToContents()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::onHideShowColumn(bool) void BlocksTreeWidget::onHideShowColumn(bool)
{ {
auto action = qobject_cast<QAction*>(sender()); auto action = qobject_cast<QAction*>(sender());
if (action == nullptr) if (action == nullptr)
@ -1034,19 +1035,19 @@ void EasyTreeWidget::onHideShowColumn(bool)
m_columnsHiddenStatus[col] = hideCol ? 1 : 0; m_columnsHiddenStatus[col] = hideCol ? 1 : 0;
} }
void EasyTreeWidget::onModeChange(bool) void BlocksTreeWidget::onModeChange(bool)
{ {
auto action = qobject_cast<QAction*>(sender()); auto action = qobject_cast<QAction*>(sender());
if (action == nullptr) if (action == nullptr)
return; return;
const auto prev = m_mode; const auto prev = m_mode;
m_mode = static_cast<EasyTreeMode>(action->data().toUInt()); m_mode = static_cast<TreeMode>(action->data().toUInt());
if (m_mode == prev) if (m_mode == prev)
return; return;
if (m_mode == EasyTreeMode_Full) if (m_mode == TreeMode::Full)
{ {
for (int i = 1; i < COL_COLUMNS_NUMBER; ++i) for (int i = 1; i < COL_COLUMNS_NUMBER; ++i)
setColumnHidden(i, m_columnsHiddenStatus[i] != 0); setColumnHidden(i, m_columnsHiddenStatus[i] != 0);
@ -1062,14 +1063,14 @@ void EasyTreeWidget::onModeChange(bool)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidget::loadSettings() void BlocksTreeWidget::loadSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget"); settings.beginGroup("tree_widget");
auto val = settings.value("regime"); auto val = settings.value("regime");
if (!val.isNull()) if (!val.isNull())
m_mode = static_cast<EasyTreeMode>(val.toUInt()); m_mode = static_cast<TreeMode>(val.toUInt());
val = settings.value("columns"); val = settings.value("columns");
if (!val.isNull()) if (!val.isNull())
@ -1085,9 +1086,9 @@ void EasyTreeWidget::loadSettings()
settings.endGroup(); settings.endGroup();
} }
void EasyTreeWidget::saveSettings() void BlocksTreeWidget::saveSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("tree_widget"); settings.beginGroup("tree_widget");
settings.setValue("regime", static_cast<uint8_t>(m_mode)); settings.setValue("regime", static_cast<uint8_t>(m_mode));
settings.setValue("columns", QByteArray(m_columnsHiddenStatus, COL_COLUMNS_NUMBER)); settings.setValue("columns", QByteArray(m_columnsHiddenStatus, COL_COLUMNS_NUMBER));
@ -1098,8 +1099,8 @@ void EasyTreeWidget::saveSettings()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent) HierarchyWidget::HierarchyWidget(QWidget* _parent) : Parent(_parent)
, m_tree(new EasyTreeWidget(this)) , m_tree(new BlocksTreeWidget(this))
, m_searchBox(new QLineEdit(this)) , m_searchBox(new QLineEdit(this))
, m_foundNumber(new QLabel("Found 0 matches", this)) , m_foundNumber(new QLabel("Found 0 matches", this))
, m_searchButton(nullptr) , m_searchButton(nullptr)
@ -1138,7 +1139,7 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
menu->addAction(a); menu->addAction(a);
auto tb = new QToolBar(this); auto tb = new QToolBar(this);
tb->setIconSize(::profiler_gui::ICONS_SIZE); tb->setIconSize(profiler_gui::ICONS_SIZE);
tb->setContentsMargins(0, 0, 0, 0); tb->setContentsMargins(0, 0, 0, 0);
tb->addAction(m_searchButton); tb->addAction(m_searchButton);
tb->addWidget(m_searchBox); tb->addWidget(m_searchBox);
@ -1157,15 +1158,15 @@ EasyHierarchyWidget::EasyHierarchyWidget(QWidget* _parent) : Parent(_parent)
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed); connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
} }
EasyHierarchyWidget::~EasyHierarchyWidget() HierarchyWidget::~HierarchyWidget()
{ {
saveSettings(); saveSettings();
} }
void EasyHierarchyWidget::loadSettings() void HierarchyWidget::loadSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyHierarchyWidget"); settings.beginGroup("HierarchyWidget");
auto val = settings.value("case_sensitive"); auto val = settings.value("case_sensitive");
if (!val.isNull()) if (!val.isNull())
@ -1174,15 +1175,15 @@ void EasyHierarchyWidget::loadSettings()
settings.endGroup(); settings.endGroup();
} }
void EasyHierarchyWidget::saveSettings() void HierarchyWidget::saveSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(profiler_gui::ORGANAZATION_NAME, profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyHierarchyWidget"); settings.beginGroup("HierarchyWidget");
settings.setValue("case_sensitive", m_bCaseSensitiveSearch); settings.setValue("case_sensitive", m_bCaseSensitiveSearch);
settings.endGroup(); settings.endGroup();
} }
void EasyHierarchyWidget::keyPressEvent(QKeyEvent* _event) void HierarchyWidget::keyPressEvent(QKeyEvent* _event)
{ {
if (_event->key() == Qt::Key_F3) if (_event->key() == Qt::Key_F3)
{ {
@ -1197,25 +1198,25 @@ void EasyHierarchyWidget::keyPressEvent(QKeyEvent* _event)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void EasyHierarchyWidget::contextMenuEvent(QContextMenuEvent* _event) void HierarchyWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
m_tree->contextMenuEvent(_event); m_tree->contextMenuEvent(_event);
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EasyTreeWidget* EasyHierarchyWidget::tree() BlocksTreeWidget* HierarchyWidget::tree()
{ {
return m_tree; return m_tree;
} }
void EasyHierarchyWidget::clear(bool _global) void HierarchyWidget::clear(bool _global)
{ {
m_tree->clearSilent(_global); m_tree->clearSilent(_global);
m_foundNumber->setText(QString("Found 0 matches")); m_foundNumber->setText(QString("Found 0 matches"));
} }
void EasyHierarchyWidget::onSeachBoxReturnPressed() void HierarchyWidget::onSeachBoxReturnPressed()
{ {
if (m_searchButton->data().toBool() == true) if (m_searchButton->data().toBool() == true)
findNext(true); findNext(true);
@ -1223,7 +1224,7 @@ void EasyHierarchyWidget::onSeachBoxReturnPressed()
findPrev(true); findPrev(true);
} }
void EasyHierarchyWidget::findNext(bool) void HierarchyWidget::findNext(bool)
{ {
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags()); auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -1233,7 +1234,7 @@ void EasyHierarchyWidget::findNext(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches)); m_foundNumber->setText(QString("Found %1 matches").arg(matches));
} }
void EasyHierarchyWidget::findPrev(bool) void HierarchyWidget::findPrev(bool)
{ {
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags()); auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -1243,7 +1244,7 @@ void EasyHierarchyWidget::findPrev(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches)); m_foundNumber->setText(QString("Found %1 matches").arg(matches));
} }
void EasyHierarchyWidget::findNextFromMenu(bool _checked) void HierarchyWidget::findNextFromMenu(bool _checked)
{ {
if (!_checked) if (!_checked)
return; return;
@ -1260,7 +1261,7 @@ void EasyHierarchyWidget::findNextFromMenu(bool _checked)
findNext(true); findNext(true);
} }
void EasyHierarchyWidget::findPrevFromMenu(bool _checked) void HierarchyWidget::findPrevFromMenu(bool _checked)
{ {
if (!_checked) if (!_checked)
return; return;

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyTreeWidget and it's auxiliary classes * description : The file contains declaration of BlocksTreeWidget and it's auxiliary classes
* : for displyaing EasyProfiler blocks tree. * : for displyaing EasyProfiler blocks tree.
* ----------------- : * ----------------- :
* change log : * 2016/06/26 Victor Zarubkin: moved sources from tree_view.h * change log : * 2016/06/26 Victor Zarubkin: moved sources from tree_view.h
@ -73,16 +73,16 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyTreeWidget : public QTreeWidget class BlocksTreeWidget : public QTreeWidget
{ {
Q_OBJECT Q_OBJECT
using Parent = QTreeWidget; using Parent = QTreeWidget;
using This = EasyTreeWidget; using This = BlocksTreeWidget;
protected: protected:
EasyTreeWidgetLoader m_hierarchyBuilder; TreeWidgetLoader m_hierarchyBuilder;
Items m_items; Items m_items;
RootsMap m_roots; RootsMap m_roots;
::profiler_gui::TreeBlocks m_inputBlocks; ::profiler_gui::TreeBlocks m_inputBlocks;
@ -92,15 +92,15 @@ protected:
::profiler::timestamp_t m_beginTime; ::profiler::timestamp_t m_beginTime;
class QProgressDialog* m_progress; class QProgressDialog* m_progress;
class QLabel* m_hintLabel; class QLabel* m_hintLabel;
EasyTreeMode m_mode; TreeMode m_mode;
bool m_bLocked; bool m_bLocked;
bool m_bSilentExpandCollapse; bool m_bSilentExpandCollapse;
char m_columnsHiddenStatus[COL_COLUMNS_NUMBER]; char m_columnsHiddenStatus[COL_COLUMNS_NUMBER];
public: public:
explicit EasyTreeWidget(QWidget* _parent = nullptr); explicit BlocksTreeWidget(QWidget* _parent = nullptr);
~EasyTreeWidget() override; ~BlocksTreeWidget() override;
void contextMenuEvent(QContextMenuEvent* _event) override; void contextMenuEvent(QContextMenuEvent* _event) override;
void dragEnterEvent(QDragEnterEvent*) override {} void dragEnterEvent(QDragEnterEvent*) override {}
@ -160,20 +160,20 @@ private:
void destroyProgressDialog(); void destroyProgressDialog();
void createProgressDialog(); void createProgressDialog();
}; // END of class EasyTreeWidget. }; // END of class BlocksTreeWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyHierarchyWidget : public QWidget class HierarchyWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
using Parent = QWidget; using Parent = QWidget;
using This = EasyHierarchyWidget; using This = HierarchyWidget;
private: private:
EasyTreeWidget* m_tree; BlocksTreeWidget* m_tree;
class QLineEdit* m_searchBox; class QLineEdit* m_searchBox;
class QLabel* m_foundNumber; class QLabel* m_foundNumber;
class QAction* m_searchButton; class QAction* m_searchButton;
@ -183,8 +183,8 @@ public:
// Public virtual methods // Public virtual methods
explicit EasyHierarchyWidget(QWidget* _parent = nullptr); explicit HierarchyWidget(QWidget* _parent = nullptr);
~EasyHierarchyWidget() override; ~HierarchyWidget() override;
void keyPressEvent(QKeyEvent* _event) override; void keyPressEvent(QKeyEvent* _event) override;
void contextMenuEvent(QContextMenuEvent* _event) override; void contextMenuEvent(QContextMenuEvent* _event) override;
@ -194,7 +194,7 @@ public:
// Public non-virtual methods // Public non-virtual methods
EasyTreeWidget* tree(); BlocksTreeWidget* tree();
void clear(bool _global = false); void clear(bool _global = false);
private slots: private slots:
@ -214,7 +214,7 @@ private:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
}; // END of class EasyHierarchyWidget. }; // END of class HierarchyWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyDescTreeWidget and it's auxiliary classes * description : The file contains implementation of DescriptorsTreeWidget and it's auxiliary classes
* : for displyaing EasyProfiler blocks descriptors tree. * : for displyaing EasyProfiler blocks descriptors tree.
* ----------------- : * ----------------- :
* change log : * 2016/09/17 Victor Zarubkin: initial commit. * change log : * 2016/09/17 Victor Zarubkin: initial commit.
@ -187,20 +187,20 @@ const char* statusText(::profiler::EasyBlockStatus _status)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyDescWidgetItem::EasyDescWidgetItem(::profiler::block_id_t _desc, Parent* _parent) DescriptorsTreeItem::DescriptorsTreeItem(::profiler::block_id_t _desc, Parent* _parent)
: Parent(_parent, QTreeWidgetItem::UserType) : Parent(_parent, QTreeWidgetItem::UserType)
, m_desc(_desc) , m_desc(_desc)
, m_type(EasyDescWidgetItem::Type::File) , m_type(DescriptorsTreeItem::Type::File)
{ {
} }
EasyDescWidgetItem::~EasyDescWidgetItem() DescriptorsTreeItem::~DescriptorsTreeItem()
{ {
} }
bool EasyDescWidgetItem::operator < (const Parent& _other) const bool DescriptorsTreeItem::operator < (const Parent& _other) const
{ {
const auto col = treeWidget()->sortColumn(); const auto col = treeWidget()->sortColumn();
@ -216,7 +216,7 @@ bool EasyDescWidgetItem::operator < (const Parent& _other) const
return Parent::operator < (_other); return Parent::operator < (_other);
} }
QVariant EasyDescWidgetItem::data(int _column, int _role) const QVariant DescriptorsTreeItem::data(int _column, int _role) const
{ {
if (_column == DESC_COL_TYPE) if (_column == DESC_COL_TYPE)
{ {
@ -247,7 +247,7 @@ QVariant EasyDescWidgetItem::data(int _column, int _role) const
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyDescTreeWidget::EasyDescTreeWidget(QWidget* _parent) DescriptorsTreeWidget::DescriptorsTreeWidget(QWidget* _parent)
: Parent(_parent) : Parent(_parent)
, m_lastFound(nullptr) , m_lastFound(nullptr)
, m_lastSearchColumn(-1) , m_lastSearchColumn(-1)
@ -269,18 +269,18 @@ EasyDescTreeWidget::EasyDescTreeWidget(QWidget* _parent)
header_item->setText(DESC_COL_STATUS, "Status"); header_item->setText(DESC_COL_STATUS, "Status");
setHeaderItem(header_item); setHeaderItem(header_item);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange); connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::selectedBlockChanged, this, &This::onSelectedBlockChange);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::blockStatusChanged, this, &This::onBlockStatusChange); connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::blockStatusChanged, this, &This::onBlockStatusChange);
connect(this, &Parent::itemExpanded, this, &This::onItemExpand); connect(this, &Parent::itemExpanded, this, &This::onItemExpand);
connect(this, &Parent::itemDoubleClicked, this, &This::onDoubleClick); connect(this, &Parent::itemDoubleClicked, this, &This::onDoubleClick);
connect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange); connect(this, &Parent::currentItemChanged, this, &This::onCurrentItemChange);
loadSettings(); loadSettings();
setItemDelegateForColumn(0, new EasyTreeViewFirstColumnItemDelegate(this)); setItemDelegateForColumn(0, new TreeViewFirstColumnItemDelegate(this));
} }
EasyDescTreeWidget::~EasyDescTreeWidget() DescriptorsTreeWidget::~DescriptorsTreeWidget()
{ {
if (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && !::profiler_gui::is_max(EASY_GLOBALS.selected_block_id)) if (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && !::profiler_gui::is_max(EASY_GLOBALS.selected_block_id))
{ {
@ -293,19 +293,19 @@ EasyDescTreeWidget::~EasyDescTreeWidget()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::setSearchColumn(int column) void DescriptorsTreeWidget::setSearchColumn(int column)
{ {
m_searchColumn = column; m_searchColumn = column;
} }
int EasyDescTreeWidget::searchColumn() const int DescriptorsTreeWidget::searchColumn() const
{ {
return m_searchColumn; return m_searchColumn;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event) void DescriptorsTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
_event->accept(); _event->accept();
@ -322,7 +322,7 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
auto item = currentItem(); auto item = currentItem();
if (item != nullptr && item->parent() != nullptr && currentColumn() >= DESC_COL_TYPE) if (item != nullptr && item->parent() != nullptr && currentColumn() >= DESC_COL_TYPE)
{ {
const auto& desc = easyDescriptor(static_cast<EasyDescWidgetItem*>(item)->desc()); const auto& desc = easyDescriptor(static_cast<DescriptorsTreeItem*>(item)->desc());
menu.addSeparator(); menu.addSeparator();
auto submenu = menu.addMenu("Change status"); auto submenu = menu.addMenu("Change status");
@ -354,7 +354,7 @@ void EasyDescTreeWidget::contextMenuEvent(QContextMenuEvent* _event)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::clearSilent(bool _global) void DescriptorsTreeWidget::clearSilent(bool _global)
{ {
const QSignalBlocker b(this); const QSignalBlocker b(this);
@ -396,12 +396,12 @@ void EasyDescTreeWidget::clearSilent(bool _global)
struct FileItems struct FileItems
{ {
using Items = ::std::unordered_map<int, EasyDescWidgetItem*, ::estd::hash<int> >; using Items = ::std::unordered_map<int, DescriptorsTreeItem*, ::estd::hash<int> >;
Items children; Items children;
QTreeWidgetItem* item = nullptr; QTreeWidgetItem* item = nullptr;
}; };
void EasyDescTreeWidget::build() void DescriptorsTreeWidget::build()
{ {
auto f = font(); auto f = font();
f.setBold(true); f.setBold(true);
@ -421,16 +421,16 @@ void EasyDescTreeWidget::build()
auto& p = fileItems[desc->file()]; auto& p = fileItems[desc->file()];
if (p.item == nullptr) if (p.item == nullptr)
{ {
auto item = new EasyDescWidgetItem(0); auto item = new DescriptorsTreeItem(0);
item->setText(DESC_COL_FILE_LINE, QString(desc->file()).remove(QRegExp("^(\\.{2}\\\\+|\\/+)+"))); item->setText(DESC_COL_FILE_LINE, QString(desc->file()).remove(QRegExp("^(\\.{2}\\\\+|\\/+)+")));
item->setType(EasyDescWidgetItem::Type::File); item->setType(DescriptorsTreeItem::Type::File);
p.item = item; p.item = item;
} }
auto it = p.children.find(desc->line()); auto it = p.children.find(desc->line());
if (it == p.children.end()) if (it == p.children.end())
{ {
auto item = new EasyDescWidgetItem(desc->id(), p.item); auto item = new DescriptorsTreeItem(desc->id(), p.item);
item->setText(DESC_COL_FILE_LINE, QString::number(desc->line())); item->setText(DESC_COL_FILE_LINE, QString::number(desc->line()));
item->setData(DESC_COL_FILE_LINE, Qt::UserRole, desc->line()); item->setData(DESC_COL_FILE_LINE, Qt::UserRole, desc->line());
item->setText(DESC_COL_NAME, desc->name()); item->setText(DESC_COL_NAME, desc->name());
@ -438,15 +438,15 @@ void EasyDescTreeWidget::build()
switch (desc->type()) switch (desc->type())
{ {
case ::profiler::BlockType::Block: case ::profiler::BlockType::Block:
item->setType(EasyDescWidgetItem::Type::Block); item->setType(DescriptorsTreeItem::Type::Block);
break; break;
case ::profiler::BlockType::Event: case ::profiler::BlockType::Event:
item->setType(EasyDescWidgetItem::Type::Event); item->setType(DescriptorsTreeItem::Type::Event);
break; break;
case ::profiler::BlockType::Value: case ::profiler::BlockType::Value:
item->setType(EasyDescWidgetItem::Type::Value); item->setType(DescriptorsTreeItem::Type::Value);
break; break;
} }
@ -482,21 +482,21 @@ void EasyDescTreeWidget::build()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onItemExpand(QTreeWidgetItem*) void DescriptorsTreeWidget::onItemExpand(QTreeWidgetItem*)
{ {
resizeColumnsToContents(); resizeColumnsToContents();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onDoubleClick(QTreeWidgetItem* _item, int _column) void DescriptorsTreeWidget::onDoubleClick(QTreeWidgetItem* _item, int _column)
{ {
if (!EASY_GLOBALS.connected) if (!EASY_GLOBALS.connected)
return; return;
if (_column >= DESC_COL_TYPE && _item->parent() != nullptr) if (_column >= DESC_COL_TYPE && _item->parent() != nullptr)
{ {
auto item = static_cast<EasyDescWidgetItem*>(_item); auto item = static_cast<DescriptorsTreeItem*>(_item);
auto& desc = easyDescriptor(item->desc()); auto& desc = easyDescriptor(item->desc());
desc.setStatus(nextStatus(desc.status())); desc.setStatus(nextStatus(desc.status()));
@ -511,7 +511,7 @@ void EasyDescTreeWidget::onDoubleClick(QTreeWidgetItem* _item, int _column)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev) void DescriptorsTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidgetItem* _prev)
{ {
if (_prev != nullptr) if (_prev != nullptr)
{ {
@ -529,7 +529,7 @@ void EasyDescTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidget
if (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && _item->parent() != nullptr) if (::profiler_gui::is_max(EASY_GLOBALS.selected_block) && _item->parent() != nullptr)
{ {
const auto id = static_cast<EasyDescWidgetItem*>(_item)->desc(); const auto id = static_cast<DescriptorsTreeItem*>(_item)->desc();
if (EASY_GLOBALS.selected_block_id != id) if (EASY_GLOBALS.selected_block_id != id)
{ {
EASY_GLOBALS.selected_block_id = id; EASY_GLOBALS.selected_block_id = id;
@ -546,7 +546,7 @@ void EasyDescTreeWidget::onCurrentItemChange(QTreeWidgetItem* _item, QTreeWidget
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onBlockStatusChangeClicked(bool _checked) void DescriptorsTreeWidget::onBlockStatusChangeClicked(bool _checked)
{ {
if (!_checked || !EASY_GLOBALS.connected) if (!_checked || !EASY_GLOBALS.connected)
return; return;
@ -558,7 +558,7 @@ void EasyDescTreeWidget::onBlockStatusChangeClicked(bool _checked)
auto action = qobject_cast<QAction*>(sender()); auto action = qobject_cast<QAction*>(sender());
if (action != nullptr) if (action != nullptr)
{ {
auto& desc = easyDescriptor(static_cast<EasyDescWidgetItem*>(item)->desc()); auto& desc = easyDescriptor(static_cast<DescriptorsTreeItem*>(item)->desc());
desc.setStatus(static_cast<::profiler::EasyBlockStatus>(action->data().toUInt())); desc.setStatus(static_cast<::profiler::EasyBlockStatus>(action->data().toUInt()));
item->setText(DESC_COL_STATUS, statusText(desc.status())); item->setText(DESC_COL_STATUS, statusText(desc.status()));
item->setForeground(DESC_COL_STATUS, QColor::fromRgba(statusColor(desc.status()))); item->setForeground(DESC_COL_STATUS, QColor::fromRgba(statusColor(desc.status())));
@ -569,7 +569,7 @@ void EasyDescTreeWidget::onBlockStatusChangeClicked(bool _checked)
} }
} }
void EasyDescTreeWidget::onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status) void DescriptorsTreeWidget::onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status)
{ {
if (m_bLocked) if (m_bLocked)
return; return;
@ -585,7 +585,7 @@ void EasyDescTreeWidget::onBlockStatusChange(::profiler::block_id_t _id, ::profi
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::resizeColumnsToContents() void DescriptorsTreeWidget::resizeColumnsToContents()
{ {
for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i) for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i)
resizeColumnToContents(i); resizeColumnToContents(i);
@ -593,7 +593,7 @@ void EasyDescTreeWidget::resizeColumnsToContents()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::onSelectedBlockChange(uint32_t _block_index) void DescriptorsTreeWidget::onSelectedBlockChange(uint32_t _block_index)
{ {
if (::profiler_gui::is_max(_block_index)) if (::profiler_gui::is_max(_block_index))
{ {
@ -611,7 +611,7 @@ void EasyDescTreeWidget::onSelectedBlockChange(uint32_t _block_index)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyDescTreeWidget::resetHighlight() void DescriptorsTreeWidget::resetHighlight()
{ {
for (auto item : m_highlightItems) { for (auto item : m_highlightItems) {
for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i) for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i)
@ -620,7 +620,7 @@ void EasyDescTreeWidget::resetHighlight()
m_highlightItems.clear(); m_highlightItems.clear();
} }
void EasyDescTreeWidget::loadSettings() void DescriptorsTreeWidget::loadSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("desc_tree_widget"); settings.beginGroup("desc_tree_widget");
@ -632,7 +632,7 @@ void EasyDescTreeWidget::loadSettings()
settings.endGroup(); settings.endGroup();
} }
void EasyDescTreeWidget::saveSettings() void DescriptorsTreeWidget::saveSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("desc_tree_widget"); settings.beginGroup("desc_tree_widget");
@ -644,7 +644,7 @@ void EasyDescTreeWidget::saveSettings()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
int EasyDescTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags) int DescriptorsTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
{ {
if (_str.isEmpty()) if (_str.isEmpty())
{ {
@ -705,7 +705,7 @@ int EasyDescTreeWidget::findNext(const QString& _str, Qt::MatchFlags _flags)
return itemsList.size(); return itemsList.size();
} }
int EasyDescTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags) int DescriptorsTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
{ {
if (_str.isEmpty()) if (_str.isEmpty())
{ {
@ -765,9 +765,9 @@ int EasyDescTreeWidget::findPrev(const QString& _str, Qt::MatchFlags _flags)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent) BlockDescriptorsWidget::BlockDescriptorsWidget(QWidget* _parent) : Parent(_parent)
, m_splitter(new QSplitter(Qt::Vertical, this)) , m_splitter(new QSplitter(Qt::Vertical, this))
, m_tree(new EasyDescTreeWidget(this)) , m_tree(new DescriptorsTreeWidget(this))
, m_values(new ArbitraryValuesWidget(this)) , m_values(new ArbitraryValuesWidget(this))
, m_searchBox(new QLineEdit(this)) , m_searchBox(new QLineEdit(this))
, m_foundNumber(new QLabel("Found 0 matches", this)) , m_foundNumber(new QLabel("Found 0 matches", this))
@ -789,7 +789,7 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
auto refreshButton = tb->addAction(QIcon(imagePath("reload")), tr("Refresh blocks list")); auto refreshButton = tb->addAction(QIcon(imagePath("reload")), tr("Refresh blocks list"));
refreshButton->setEnabled(EASY_GLOBALS.connected); refreshButton->setEnabled(EASY_GLOBALS.connected);
refreshButton->setToolTip(tr("Refresh blocks list.\nConnection needed.")); refreshButton->setToolTip(tr("Refresh blocks list.\nConnection needed."));
connect(refreshButton, &QAction::triggered, &EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::blocksRefreshRequired); connect(refreshButton, &QAction::triggered, &EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::blocksRefreshRequired);
@ -856,21 +856,21 @@ EasyDescWidget::EasyDescWidget(QWidget* _parent) : Parent(_parent)
lay->addWidget(m_splitter); lay->addWidget(m_splitter);
connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed); connect(m_searchBox, &QLineEdit::returnPressed, this, &This::onSeachBoxReturnPressed);
connect(&EASY_GLOBALS.events, &::profiler_gui::EasyGlobalSignals::connectionChanged, refreshButton, &QAction::setEnabled); connect(&EASY_GLOBALS.events, &::profiler_gui::GlobalSignals::connectionChanged, refreshButton, &QAction::setEnabled);
loadSettings(); loadSettings();
caseSensitiveSwitch->setChecked(m_bCaseSensitiveSearch); caseSensitiveSwitch->setChecked(m_bCaseSensitiveSearch);
} }
EasyDescWidget::~EasyDescWidget() BlockDescriptorsWidget::~BlockDescriptorsWidget()
{ {
saveSettings(); saveSettings();
} }
void EasyDescWidget::loadSettings() void BlockDescriptorsWidget::loadSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyDescWidget"); settings.beginGroup("BlockDescriptorsWidget");
auto val = settings.value("case_sensitive"); auto val = settings.value("case_sensitive");
if (!val.isNull()) if (!val.isNull())
@ -887,17 +887,17 @@ void EasyDescWidget::loadSettings()
settings.endGroup(); settings.endGroup();
} }
void EasyDescWidget::saveSettings() void BlockDescriptorsWidget::saveSettings()
{ {
QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME); QSettings settings(::profiler_gui::ORGANAZATION_NAME, ::profiler_gui::APPLICATION_NAME);
settings.beginGroup("EasyDescWidget"); settings.beginGroup("BlockDescriptorsWidget");
settings.setValue("case_sensitive", m_bCaseSensitiveSearch); settings.setValue("case_sensitive", m_bCaseSensitiveSearch);
settings.setValue("vsplitter/geometry", m_splitter->saveGeometry()); settings.setValue("vsplitter/geometry", m_splitter->saveGeometry());
settings.setValue("vsplitter/state", m_splitter->saveState()); settings.setValue("vsplitter/state", m_splitter->saveState());
settings.endGroup(); settings.endGroup();
} }
void EasyDescWidget::keyPressEvent(QKeyEvent* _event) void BlockDescriptorsWidget::keyPressEvent(QKeyEvent* _event)
{ {
if (_event->key() == Qt::Key_F3) if (_event->key() == Qt::Key_F3)
{ {
@ -910,12 +910,12 @@ void EasyDescWidget::keyPressEvent(QKeyEvent* _event)
_event->accept(); _event->accept();
} }
void EasyDescWidget::contextMenuEvent(QContextMenuEvent* _event) void BlockDescriptorsWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
m_tree->contextMenuEvent(_event); m_tree->contextMenuEvent(_event);
} }
void EasyDescWidget::build() void BlockDescriptorsWidget::build()
{ {
m_tree->clearSilent(false); m_tree->clearSilent(false);
m_foundNumber->setText(QString("Found 0 matches")); m_foundNumber->setText(QString("Found 0 matches"));
@ -923,14 +923,14 @@ void EasyDescWidget::build()
m_values->rebuild(); m_values->rebuild();
} }
void EasyDescWidget::clear() void BlockDescriptorsWidget::clear()
{ {
m_tree->clearSilent(true); m_tree->clearSilent(true);
m_foundNumber->setText(QString("Found 0 matches")); m_foundNumber->setText(QString("Found 0 matches"));
m_values->clear(); m_values->clear();
} }
void EasyDescWidget::onSeachBoxReturnPressed() void BlockDescriptorsWidget::onSeachBoxReturnPressed()
{ {
if (m_searchButton->data().toBool() == true) if (m_searchButton->data().toBool() == true)
findNext(true); findNext(true);
@ -938,14 +938,14 @@ void EasyDescWidget::onSeachBoxReturnPressed()
findPrev(true); findPrev(true);
} }
void EasyDescWidget::onSearchColumnChange(bool) void BlockDescriptorsWidget::onSearchColumnChange(bool)
{ {
auto action = qobject_cast<QAction*>(sender()); auto action = qobject_cast<QAction*>(sender());
if (action != nullptr) if (action != nullptr)
m_tree->setSearchColumn(action->data().toInt()); m_tree->setSearchColumn(action->data().toInt());
} }
void EasyDescWidget::findNext(bool) void BlockDescriptorsWidget::findNext(bool)
{ {
auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags()); auto matches = m_tree->findNext(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -955,7 +955,7 @@ void EasyDescWidget::findNext(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches)); m_foundNumber->setText(QString("Found %1 matches").arg(matches));
} }
void EasyDescWidget::findPrev(bool) void BlockDescriptorsWidget::findPrev(bool)
{ {
auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags()); auto matches = m_tree->findPrev(m_searchBox->text(), m_bCaseSensitiveSearch ? Qt::MatchCaseSensitive : Qt::MatchFlags());
@ -965,7 +965,7 @@ void EasyDescWidget::findPrev(bool)
m_foundNumber->setText(QString("Found %1 matches").arg(matches)); m_foundNumber->setText(QString("Found %1 matches").arg(matches));
} }
void EasyDescWidget::findNextFromMenu(bool _checked) void BlockDescriptorsWidget::findNextFromMenu(bool _checked)
{ {
if (!_checked) if (!_checked)
return; return;
@ -982,7 +982,7 @@ void EasyDescWidget::findNextFromMenu(bool _checked)
findNext(true); findNext(true);
} }
void EasyDescWidget::findPrevFromMenu(bool _checked) void BlockDescriptorsWidget::findPrevFromMenu(bool _checked)
{ {
if (!_checked) if (!_checked)
return; return;

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyDescTreeWidget and it's auxiliary classes * description : The file contains declaration of DescriptorsTreeWidget and it's auxiliary classes
* : for displyaing EasyProfiler blocks descriptors tree. * : for displyaing EasyProfiler blocks descriptors tree.
* ----------------- : * ----------------- :
* change log : * 2016/09/17 Victor Zarubkin: initial commit. * change log : * 2016/09/17 Victor Zarubkin: initial commit.
@ -67,10 +67,10 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyDescWidgetItem : public QTreeWidgetItem class DescriptorsTreeItem : public QTreeWidgetItem
{ {
using Parent = QTreeWidgetItem; using Parent = QTreeWidgetItem;
using This = EasyDescWidgetItem; using This = DescriptorsTreeItem;
public: public:
@ -89,8 +89,8 @@ private:
public: public:
explicit EasyDescWidgetItem(::profiler::block_id_t _desc, Parent* _parent = nullptr); explicit DescriptorsTreeItem(::profiler::block_id_t _desc, Parent* _parent = nullptr);
~EasyDescWidgetItem() override; ~DescriptorsTreeItem() override;
bool operator < (const Parent& _other) const override; bool operator < (const Parent& _other) const override;
QVariant data(int _column, int _role) const override; QVariant data(int _column, int _role) const override;
@ -109,18 +109,18 @@ public:
m_type = _type; m_type = _type;
} }
}; // END of class EasyDescWidgetItem. }; // END of class DescriptorsTreeItem.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyDescTreeWidget : public QTreeWidget class DescriptorsTreeWidget : public QTreeWidget
{ {
Q_OBJECT Q_OBJECT
using Parent = QTreeWidget; using Parent = QTreeWidget;
using This = EasyDescTreeWidget; using This = DescriptorsTreeWidget;
using Items = ::std::vector<EasyDescWidgetItem*>; using Items = ::std::vector<DescriptorsTreeItem*>;
using TreeItems = ::std::vector<QTreeWidgetItem*>; using TreeItems = ::std::vector<QTreeWidgetItem*>;
using ExpandedFiles = ::std::unordered_set<::std::string>; using ExpandedFiles = ::std::unordered_set<::std::string>;
@ -139,8 +139,8 @@ public:
// Public virtual methods // Public virtual methods
explicit EasyDescTreeWidget(QWidget* _parent = nullptr); explicit DescriptorsTreeWidget(QWidget* _parent = nullptr);
~EasyDescTreeWidget() override; ~DescriptorsTreeWidget() override;
void contextMenuEvent(QContextMenuEvent* _event) override; void contextMenuEvent(QContextMenuEvent* _event) override;
public: public:
@ -175,21 +175,21 @@ private:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
}; // END of class EasyDescTreeWidget. }; // END of class DescriptorsTreeWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyDescWidget : public QWidget class BlockDescriptorsWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
using Parent = QWidget; using Parent = QWidget;
using This = EasyDescWidget; using This = BlockDescriptorsWidget;
private: private:
class QSplitter* m_splitter; class QSplitter* m_splitter;
EasyDescTreeWidget* m_tree; DescriptorsTreeWidget* m_tree;
class ArbitraryValuesWidget* m_values; class ArbitraryValuesWidget* m_values;
class QLineEdit* m_searchBox; class QLineEdit* m_searchBox;
class QLabel* m_foundNumber; class QLabel* m_foundNumber;
@ -200,8 +200,8 @@ public:
// Public virtual methods // Public virtual methods
explicit EasyDescWidget(QWidget* _parent = nullptr); explicit BlockDescriptorsWidget(QWidget* _parent = nullptr);
~EasyDescWidget() override; ~BlockDescriptorsWidget() override;
void keyPressEvent(QKeyEvent* _event) override; void keyPressEvent(QKeyEvent* _event) override;
void contextMenuEvent(QContextMenuEvent* _event) override; void contextMenuEvent(QContextMenuEvent* _event) override;
@ -228,7 +228,7 @@ private:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();
}; // END of class EasyDescWidget. }; // END of class BlockDescriptorsWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyChronometerItem. * description : The file contains implementation of GraphicsRulerItem.
* ----------------- : * ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.cpp * change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.cpp
* : * :
@ -72,7 +72,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyChronometerItem::EasyChronometerItem(bool _main) GraphicsRulerItem::GraphicsRulerItem(bool _main)
: Parent() : Parent()
, m_color(::profiler_gui::CHRONOMETER_COLOR) , m_color(::profiler_gui::CHRONOMETER_COLOR)
, m_left(0) , m_left(0)
@ -86,16 +86,16 @@ EasyChronometerItem::EasyChronometerItem(bool _main)
m_indicator.reserve(3); m_indicator.reserve(3);
} }
EasyChronometerItem::~EasyChronometerItem() GraphicsRulerItem::~GraphicsRulerItem()
{ {
} }
QRectF EasyChronometerItem::boundingRect() const QRectF GraphicsRulerItem::boundingRect() const
{ {
return m_boundingRect; return m_boundingRect;
} }
void EasyChronometerItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*) void GraphicsRulerItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
{ {
auto const sceneView = view(); auto const sceneView = view();
const auto currentScale = sceneView->scale(); const auto currentScale = sceneView->scale();
@ -290,7 +290,7 @@ void EasyChronometerItem::paint(QPainter* _painter, const QStyleOptionGraphicsIt
// END Paint!~~~~~~~~~~~~~~~~~~~~~~ // END Paint!~~~~~~~~~~~~~~~~~~~~~~
} }
void EasyChronometerItem::hide() void GraphicsRulerItem::hide()
{ {
m_bHoverIndicator = false; m_bHoverIndicator = false;
m_bHoverLeftBorder = false; m_bHoverLeftBorder = false;
@ -299,7 +299,7 @@ void EasyChronometerItem::hide()
Parent::hide(); Parent::hide();
} }
bool EasyChronometerItem::indicatorContains(const QPointF& _pos) const bool GraphicsRulerItem::indicatorContains(const QPointF& _pos) const
{ {
if (m_indicator.empty()) if (m_indicator.empty())
return false; return false;
@ -308,56 +308,56 @@ bool EasyChronometerItem::indicatorContains(const QPointF& _pos) const
return m_indicator.containsPoint(QPointF(itemX, _pos.y()), Qt::OddEvenFill); return m_indicator.containsPoint(QPointF(itemX, _pos.y()), Qt::OddEvenFill);
} }
void EasyChronometerItem::setHoverLeft(bool _hover) void GraphicsRulerItem::setHoverLeft(bool _hover)
{ {
m_bHoverLeftBorder = _hover; m_bHoverLeftBorder = _hover;
} }
void EasyChronometerItem::setHoverRight(bool _hover) void GraphicsRulerItem::setHoverRight(bool _hover)
{ {
m_bHoverRightBorder = _hover; m_bHoverRightBorder = _hover;
} }
bool EasyChronometerItem::hoverLeft(qreal _x) const bool GraphicsRulerItem::hoverLeft(qreal _x) const
{ {
const auto dx = fabs(_x - m_left) * view()->scale(); const auto dx = fabs(_x - m_left) * view()->scale();
return dx < 4; return dx < 4;
} }
bool EasyChronometerItem::hoverRight(qreal _x) const bool GraphicsRulerItem::hoverRight(qreal _x) const
{ {
const auto dx = fabs(_x - m_right) * view()->scale(); const auto dx = fabs(_x - m_right) * view()->scale();
return dx < 4; return dx < 4;
} }
QPointF EasyChronometerItem::toItem(const QPointF& _pos) const QPointF GraphicsRulerItem::toItem(const QPointF& _pos) const
{ {
const auto sceneView = view(); const auto sceneView = view();
return QPointF((_pos.x() - sceneView->offset()) * sceneView->scale() - x(), _pos.y()); return QPointF((_pos.x() - sceneView->offset()) * sceneView->scale() - x(), _pos.y());
} }
qreal EasyChronometerItem::toItem(qreal _x) const qreal GraphicsRulerItem::toItem(qreal _x) const
{ {
const auto sceneView = view(); const auto sceneView = view();
return (_x - sceneView->offset()) * sceneView->scale() - x(); return (_x - sceneView->offset()) * sceneView->scale() - x();
} }
void EasyChronometerItem::setColor(const QColor& _color) void GraphicsRulerItem::setColor(const QColor& _color)
{ {
m_color = _color; m_color = _color;
} }
void EasyChronometerItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h) void GraphicsRulerItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{ {
m_boundingRect.setRect(x, y, w, h); m_boundingRect.setRect(x, y, w, h);
} }
void EasyChronometerItem::setBoundingRect(const QRectF& _rect) void GraphicsRulerItem::setBoundingRect(const QRectF& _rect)
{ {
m_boundingRect = _rect; m_boundingRect = _rect;
} }
void EasyChronometerItem::setLeftRight(qreal _left, qreal _right) void GraphicsRulerItem::setLeftRight(qreal _left, qreal _right)
{ {
if (_left < _right) if (_left < _right)
{ {
@ -371,24 +371,24 @@ void EasyChronometerItem::setLeftRight(qreal _left, qreal _right)
} }
} }
void EasyChronometerItem::setReverse(bool _reverse) void GraphicsRulerItem::setReverse(bool _reverse)
{ {
m_bReverse = _reverse; m_bReverse = _reverse;
} }
void EasyChronometerItem::setHoverIndicator(bool _hover) void GraphicsRulerItem::setHoverIndicator(bool _hover)
{ {
m_bHoverIndicator = _hover; m_bHoverIndicator = _hover;
} }
const EasyGraphicsView* EasyChronometerItem::view() const const BlocksGraphicsView* GraphicsRulerItem::view() const
{ {
return static_cast<const EasyGraphicsView*>(scene()->parent()); return static_cast<const BlocksGraphicsView*>(scene()->parent());
} }
EasyGraphicsView* EasyChronometerItem::view() BlocksGraphicsView* GraphicsRulerItem::view()
{ {
return static_cast<EasyGraphicsView*>(scene()->parent()); return static_cast<BlocksGraphicsView*>(scene()->parent());
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyChronometerItem - an item * description : The file contains declaration of GraphicsRulerItem - an item
* : used to display selected interval on graphics scene. * : used to display selected interval on graphics scene.
* ----------------- : * ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.h * change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.h
@ -67,12 +67,12 @@
class QWidget; class QWidget;
class QPainter; class QPainter;
class QStyleOptionGraphicsItem; class QStyleOptionGraphicsItem;
class EasyGraphicsView; class BlocksGraphicsView;
class EasyChronometerItem : public QGraphicsItem class GraphicsRulerItem : public QGraphicsItem
{ {
typedef QGraphicsItem Parent; typedef QGraphicsItem Parent;
typedef EasyChronometerItem This; typedef GraphicsRulerItem This;
QPolygonF m_indicator; ///< Indicator displayed when this chrono item is out of screen (displaying only for main item) QPolygonF m_indicator; ///< Indicator displayed when this chrono item is out of screen (displaying only for main item)
QRectF m_boundingRect; ///< boundingRect (see QGraphicsItem) QRectF m_boundingRect; ///< boundingRect (see QGraphicsItem)
@ -86,8 +86,8 @@ class EasyChronometerItem : public QGraphicsItem
public: public:
explicit EasyChronometerItem(bool _main = true); explicit GraphicsRulerItem(bool _main = true);
virtual ~EasyChronometerItem(); virtual ~GraphicsRulerItem();
// Public virtual methods // Public virtual methods
@ -159,11 +159,11 @@ public:
private: private:
///< Returns pointer to the EasyGraphicsView widget. ///< Returns pointer to the BlocksGraphicsView widget.
const EasyGraphicsView* view() const; const BlocksGraphicsView* view() const;
EasyGraphicsView* view(); BlocksGraphicsView* view();
}; // END of class EasyChronometerItem. }; // END of class GraphicsRulerItem.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : This file contains implementation of EasyFrameRateViewer widget. * description : This file contains implementation of FpsViewerWidget widget.
* ----------------- : * ----------------- :
* change log : * 2017/04/02 Victor Zarubkin: Initial commit. * change log : * 2017/04/02 Victor Zarubkin: Initial commit.
* : * :
@ -64,36 +64,36 @@ const int INTERVAL_WIDTH = 20;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyFPSGraphicsItem::EasyFPSGraphicsItem() : Parent(nullptr) FpsGraphicsItem::FpsGraphicsItem() : Parent(nullptr)
{ {
} }
EasyFPSGraphicsItem::~EasyFPSGraphicsItem() FpsGraphicsItem::~FpsGraphicsItem()
{ {
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
QRectF EasyFPSGraphicsItem::boundingRect() const QRectF FpsGraphicsItem::boundingRect() const
{ {
return m_boundingRect; return m_boundingRect;
} }
void EasyFPSGraphicsItem::setBoundingRect(const QRectF& _boundingRect) void FpsGraphicsItem::setBoundingRect(const QRectF& _boundingRect)
{ {
m_boundingRect = _boundingRect; m_boundingRect = _boundingRect;
} }
void EasyFPSGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h) void FpsGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{ {
m_boundingRect.setRect(x, y, w, h); m_boundingRect.setRect(x, y, w, h);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyFPSGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*) void FpsGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
{ {
if (m_frames.empty()) if (m_frames.empty())
return; return;
@ -232,12 +232,12 @@ void EasyFPSGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsIt
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyFPSGraphicsItem::clear() void FpsGraphicsItem::clear()
{ {
m_frames.clear(); m_frames.clear();
} }
void EasyFPSGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime) void FpsGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
{ {
m_frames.emplace_back(_maxFrameTime, _avgFrameTime); m_frames.emplace_back(_maxFrameTime, _avgFrameTime);
if (static_cast<int>(m_frames.size()) > EASY_GLOBALS.max_fps_history) if (static_cast<int>(m_frames.size()) > EASY_GLOBALS.max_fps_history)
@ -246,7 +246,7 @@ void EasyFPSGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTim
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyFrameRateViewer::EasyFrameRateViewer(QWidget* _parent) : Parent(_parent), m_fpsItem(nullptr) FpsViewerWidget::FpsViewerWidget(QWidget* _parent) : Parent(_parent), m_fpsItem(nullptr)
{ {
setCacheMode(QGraphicsView::CacheNone); setCacheMode(QGraphicsView::CacheNone);
//setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
@ -260,7 +260,7 @@ EasyFrameRateViewer::EasyFrameRateViewer(QWidget* _parent) : Parent(_parent), m_
setScene(new QGraphicsScene(this)); setScene(new QGraphicsScene(this));
scene()->setSceneRect(0, 0, 50, 50); scene()->setSceneRect(0, 0, 50, 50);
m_fpsItem = new EasyFPSGraphicsItem(); m_fpsItem = new FpsGraphicsItem();
m_fpsItem->setPos(0, 0); m_fpsItem->setPos(0, 0);
m_fpsItem->setBoundingRect(0, 0, 50, 50); m_fpsItem->setBoundingRect(0, 0, 50, 50);
scene()->addItem(m_fpsItem); scene()->addItem(m_fpsItem);
@ -277,24 +277,24 @@ EasyFrameRateViewer::EasyFrameRateViewer(QWidget* _parent) : Parent(_parent), m_
}); });
} }
EasyFrameRateViewer::~EasyFrameRateViewer() FpsViewerWidget::~FpsViewerWidget()
{ {
} }
void EasyFrameRateViewer::clear() void FpsViewerWidget::clear()
{ {
m_fpsItem->clear(); m_fpsItem->clear();
scene()->update(); scene()->update();
} }
void EasyFrameRateViewer::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime) void FpsViewerWidget::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
{ {
m_fpsItem->addPoint(_maxFrameTime, _avgFrameTime); m_fpsItem->addPoint(_maxFrameTime, _avgFrameTime);
scene()->update(); scene()->update();
} }
void EasyFrameRateViewer::resizeEvent(QResizeEvent* _event) void FpsViewerWidget::resizeEvent(QResizeEvent* _event)
{ {
Parent::resizeEvent(_event); Parent::resizeEvent(_event);
@ -305,21 +305,21 @@ void EasyFrameRateViewer::resizeEvent(QResizeEvent* _event)
scene()->update(); scene()->update();
} }
void EasyFrameRateViewer::hideEvent(QHideEvent* _event) void FpsViewerWidget::hideEvent(QHideEvent* _event)
{ {
Parent::hideEvent(_event); Parent::hideEvent(_event);
EASY_GLOBALS.fps_enabled = isVisible(); EASY_GLOBALS.fps_enabled = isVisible();
clear(); clear();
} }
void EasyFrameRateViewer::showEvent(QShowEvent* _event) void FpsViewerWidget::showEvent(QShowEvent* _event)
{ {
Parent::showEvent(_event); Parent::showEvent(_event);
EASY_GLOBALS.fps_enabled = isVisible(); EASY_GLOBALS.fps_enabled = isVisible();
clear(); clear();
} }
void EasyFrameRateViewer::contextMenuEvent(QContextMenuEvent* _event) void FpsViewerWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
QMenu menu; QMenu menu;
QAction* action = nullptr; QAction* action = nullptr;

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : This file contains declaration of EasyFrameRateViewer widget. * description : This file contains declaration of FpsViewerWidget widget.
* ----------------- : * ----------------- :
* change log : * 2017/04/02 Victor Zarubkin: Initial commit. * change log : * 2017/04/02 Victor Zarubkin: Initial commit.
* : * :
@ -65,10 +65,10 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyFPSGraphicsItem : public QGraphicsItem class FpsGraphicsItem : public QGraphicsItem
{ {
using Parent = QGraphicsItem; using Parent = QGraphicsItem;
using This = EasyFPSGraphicsItem; using This = FpsGraphicsItem;
using FrameTimes = std::deque<std::pair<uint32_t, uint32_t> >; using FrameTimes = std::deque<std::pair<uint32_t, uint32_t> >;
std::vector<QPointF> m_points1, m_points2; std::vector<QPointF> m_points1, m_points2;
@ -77,8 +77,8 @@ class EasyFPSGraphicsItem : public QGraphicsItem
public: public:
explicit EasyFPSGraphicsItem(); explicit FpsGraphicsItem();
~EasyFPSGraphicsItem() override; ~FpsGraphicsItem() override;
QRectF boundingRect() const override; QRectF boundingRect() const override;
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget) override; void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget) override;
@ -89,25 +89,25 @@ public:
void clear(); void clear();
void addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime); void addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime);
}; // END of class EasyFPSGraphicsItem. }; // END of class FpsGraphicsItem.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyFrameRateViewer : public QGraphicsView class FpsViewerWidget : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
private: private:
using Parent = QGraphicsView; using Parent = QGraphicsView;
using This = EasyFrameRateViewer; using This = FpsViewerWidget;
EasyFPSGraphicsItem* m_fpsItem; FpsGraphicsItem* m_fpsItem;
public: public:
explicit EasyFrameRateViewer(QWidget* _parent = nullptr); explicit FpsViewerWidget(QWidget* _parent = nullptr);
~EasyFrameRateViewer() override; ~FpsViewerWidget() override;
void resizeEvent(QResizeEvent* _event) override; void resizeEvent(QResizeEvent* _event) override;
void hideEvent(QHideEvent* _event) override; void hideEvent(QHideEvent* _event) override;
@ -120,7 +120,7 @@ public slots:
void clear(); void clear();
void addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime); void addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime);
}; // END of class EasyFrameRateViewer. }; // END of class FpsViewerWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyGraphicsItem. * description : The file contains implementation of BlocksGraphicsItem.
* ----------------- : * ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: Moved sources from blocks_graphics_view.cpp * change log : * 2016/09/15 Victor Zarubkin: Moved sources from blocks_graphics_view.cpp
* : * :
@ -93,7 +93,7 @@ const QPen HIGHLIGHTER_PEN = ([]() -> QPen { QPen p(::profiler::colors::Black);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyGraphicsItem::EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root) BlocksGraphicsItem::BlocksGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root)
: QGraphicsItem(nullptr) : QGraphicsItem(nullptr)
, m_threadName(::profiler_gui::decoratedThreadName(EASY_GLOBALS.use_decorated_thread_name, _root, EASY_GLOBALS.hex_thread_id)) , m_threadName(::profiler_gui::decoratedThreadName(EASY_GLOBALS.use_decorated_thread_name, _root, EASY_GLOBALS.hex_thread_id))
, m_pRoot(&_root) , m_pRoot(&_root)
@ -101,23 +101,23 @@ EasyGraphicsItem::EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRo
{ {
} }
EasyGraphicsItem::~EasyGraphicsItem() BlocksGraphicsItem::~BlocksGraphicsItem()
{ {
} }
void EasyGraphicsItem::validateName() void BlocksGraphicsItem::validateName()
{ {
m_threadName = ::profiler_gui::decoratedThreadName(EASY_GLOBALS.use_decorated_thread_name, *m_pRoot, EASY_GLOBALS.hex_thread_id); m_threadName = ::profiler_gui::decoratedThreadName(EASY_GLOBALS.use_decorated_thread_name, *m_pRoot, EASY_GLOBALS.hex_thread_id);
} }
const EasyGraphicsView* EasyGraphicsItem::view() const const BlocksGraphicsView* BlocksGraphicsItem::view() const
{ {
return static_cast<const EasyGraphicsView*>(scene()->parent()); return static_cast<const BlocksGraphicsView*>(scene()->parent());
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
QRectF EasyGraphicsItem::boundingRect() const QRectF BlocksGraphicsItem::boundingRect() const
{ {
return m_boundingRect; return m_boundingRect;
} }
@ -141,7 +141,7 @@ struct EasyPainterInformation EASY_FINAL
bool is_light; bool is_light;
bool selectedItemsWasPainted; bool selectedItemsWasPainted;
explicit EasyPainterInformation(const EasyGraphicsView* sceneView) explicit EasyPainterInformation(const BlocksGraphicsView* sceneView)
: visibleSceneRect(sceneView->visibleSceneRect()) : visibleSceneRect(sceneView->visibleSceneRect())
, visibleBottom(visibleSceneRect.bottom() - 1) , visibleBottom(visibleSceneRect.bottom() - 1)
, currentScale(sceneView->scale()) , currentScale(sceneView->scale())
@ -162,7 +162,7 @@ struct EasyPainterInformation EASY_FINAL
}; };
#ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT #ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT
void EasyGraphicsItem::paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode) void BlocksGraphicsItem::paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode)
{ {
if (_level >= _levelsNumber || _itemBlock.tree.children.empty()) if (_level >= _levelsNumber || _itemBlock.tree.children.empty())
return; return;
@ -436,7 +436,7 @@ void EasyGraphicsItem::paintChildren(const float _minWidth, const int _narrowSiz
} }
#endif #endif
void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*) void BlocksGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*)
{ {
const bool gotItems = !m_levels.empty() && !m_levels.front().empty(); const bool gotItems = !m_levels.empty() && !m_levels.front().empty();
const bool gotSync = !m_pRoot->sync.empty(); const bool gotSync = !m_pRoot->sync.empty();
@ -1100,26 +1100,26 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
const ::profiler::BlocksTreeRoot* EasyGraphicsItem::root() const const ::profiler::BlocksTreeRoot* BlocksGraphicsItem::root() const
{ {
return m_pRoot; return m_pRoot;
} }
const QString& EasyGraphicsItem::threadName() const const QString& BlocksGraphicsItem::threadName() const
{ {
return m_threadName; return m_threadName;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
QRect EasyGraphicsItem::getRect() const QRect BlocksGraphicsItem::getRect() const
{ {
return view()->mapFromScene(m_boundingRect).boundingRect(); return view()->mapFromScene(m_boundingRect).boundingRect();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const void BlocksGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const
{ {
// Search for first visible top-level item // Search for first visible top-level item
auto& level0 = m_levels.front(); auto& level0 = m_levels.front();
@ -1164,7 +1164,7 @@ void EasyGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::Tree
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersect(const QPointF& _pos, ::profiler::block_index_t& _blockIndex) const const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersect(const QPointF& _pos, ::profiler::block_index_t& _blockIndex) const
{ {
if (m_levels.empty() || m_levels.front().empty()) if (m_levels.empty() || m_levels.front().empty())
{ {
@ -1337,7 +1337,7 @@ const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersect(const QPointF& _pos
return nullptr; return nullptr;
} }
const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersectEvent(const QPointF& _pos) const const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersectEvent(const QPointF& _pos) const
{ {
if (m_pRoot->sync.empty()) if (m_pRoot->sync.empty())
{ {
@ -1388,36 +1388,36 @@ const ::profiler_gui::EasyBlock* EasyGraphicsItem::intersectEvent(const QPointF&
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h) void BlocksGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{ {
m_boundingRect.setRect(x, y, w, h); m_boundingRect.setRect(x, y, w, h);
} }
void EasyGraphicsItem::setBoundingRect(const QRectF& _rect) void BlocksGraphicsItem::setBoundingRect(const QRectF& _rect)
{ {
m_boundingRect = _rect; m_boundingRect = _rect;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
::profiler::thread_id_t EasyGraphicsItem::threadId() const ::profiler::thread_id_t BlocksGraphicsItem::threadId() const
{ {
return m_pRoot->thread_id; return m_pRoot->thread_id;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
uint8_t EasyGraphicsItem::levels() const uint8_t BlocksGraphicsItem::levels() const
{ {
return static_cast<uint8_t>(m_levels.size()); return static_cast<uint8_t>(m_levels.size());
} }
float EasyGraphicsItem::levelY(uint8_t _level) const float BlocksGraphicsItem::levelY(uint8_t _level) const
{ {
return y() + static_cast<int>(_level) * static_cast<int>(::profiler_gui::GRAPHICS_ROW_SIZE_FULL); return y() + static_cast<int>(_level) * static_cast<int>(::profiler_gui::GRAPHICS_ROW_SIZE_FULL);
} }
void EasyGraphicsItem::setLevels(uint8_t _levels) void BlocksGraphicsItem::setLevels(uint8_t _levels)
{ {
typedef decltype(m_levelsIndexes) IndexesT; typedef decltype(m_levelsIndexes) IndexesT;
static const auto MAX_CHILD_INDEX = ::profiler_gui::numeric_max<IndexesT::value_type>(); static const auto MAX_CHILD_INDEX = ::profiler_gui::numeric_max<IndexesT::value_type>();
@ -1427,29 +1427,29 @@ void EasyGraphicsItem::setLevels(uint8_t _levels)
m_rightBounds.resize(_levels, -1e100); m_rightBounds.resize(_levels, -1e100);
} }
void EasyGraphicsItem::reserve(uint8_t _level, unsigned int _items) void BlocksGraphicsItem::reserve(uint8_t _level, unsigned int _items)
{ {
m_levels[_level].reserve(_items); m_levels[_level].reserve(_items);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
const EasyGraphicsItem::Children& EasyGraphicsItem::items(uint8_t _level) const const BlocksGraphicsItem::Children& BlocksGraphicsItem::items(uint8_t _level) const
{ {
return m_levels[_level]; return m_levels[_level];
} }
const ::profiler_gui::EasyBlockItem& EasyGraphicsItem::getItem(uint8_t _level, unsigned int _index) const const ::profiler_gui::EasyBlockItem& BlocksGraphicsItem::getItem(uint8_t _level, unsigned int _index) const
{ {
return m_levels[_level][_index]; return m_levels[_level][_index];
} }
::profiler_gui::EasyBlockItem& EasyGraphicsItem::getItem(uint8_t _level, unsigned int _index) ::profiler_gui::EasyBlockItem& BlocksGraphicsItem::getItem(uint8_t _level, unsigned int _index)
{ {
return m_levels[_level][_index]; return m_levels[_level][_index];
} }
unsigned int EasyGraphicsItem::addItem(uint8_t _level) unsigned int BlocksGraphicsItem::addItem(uint8_t _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);

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyGraphicsItem - an item * description : The file contains declaration of BlocksGraphicsItem - an item
* : used to draw profiler blocks on graphics scene. * : used to draw profiler blocks on graphics scene.
* ----------------- : * ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.h/.cpp * change log : * 2016/09/15 Victor Zarubkin: moved sources from blocks_graphics_view.h/.cpp
@ -69,9 +69,9 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyGraphicsView; class BlocksGraphicsView;
class EasyGraphicsItem : public QGraphicsItem class BlocksGraphicsItem : public QGraphicsItem
{ {
typedef ::profiler_gui::EasyItems Children; typedef ::profiler_gui::EasyItems Children;
typedef ::std::vector<uint32_t> DrawIndexes; typedef ::std::vector<uint32_t> DrawIndexes;
@ -85,12 +85,12 @@ class EasyGraphicsItem : public QGraphicsItem
QRectF m_boundingRect; ///< boundingRect (see QGraphicsItem) QRectF m_boundingRect; ///< boundingRect (see QGraphicsItem)
QString m_threadName; ///< QString m_threadName; ///<
const ::profiler::BlocksTreeRoot* m_pRoot; ///< Pointer to the root profiler block (thread block). Used by ProfTreeWidget to restore hierarchy. const ::profiler::BlocksTreeRoot* m_pRoot; ///< Pointer to the root profiler block (thread block). Used by ProfTreeWidget to restore hierarchy.
uint8_t m_index; ///< This item's index in the list of items of EasyGraphicsView uint8_t m_index; ///< This item's index in the list of items of BlocksGraphicsView
public: public:
explicit EasyGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root); explicit BlocksGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root);
virtual ~EasyGraphicsItem(); virtual ~BlocksGraphicsItem();
// Public virtual methods // Public virtual methods
@ -170,8 +170,8 @@ public:
private: private:
///< Returns pointer to the EasyGraphicsView widget. ///< Returns pointer to the BlocksGraphicsView widget.
const EasyGraphicsView* view() const; const BlocksGraphicsView* view() const;
#ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT #ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT
void paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode); void paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, QPainter* _painter, struct EasyPainterInformation& p, ::profiler_gui::EasyBlockItem& _item, const ::profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, int8_t _mode);
@ -181,13 +181,12 @@ public:
// Public inline methods // Public inline methods
///< Returns this item's index in the list of graphics items of EasyGraphicsView ///< Returns this item's index in the list of graphics items of BlocksGraphicsView
inline uint8_t index() const uint8_t index() const {
{
return m_index; return m_index;
} }
}; // END of class EasyGraphicsItem. }; // END of class BlocksGraphicsItem.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -148,7 +148,7 @@ void GraphicsHistogramItem::paintMouseIndicator(QPainter* _painter, qreal _top,
void GraphicsHistogramItem::paintByPtr(QPainter* _painter) void GraphicsHistogramItem::paintByPtr(QPainter* _painter)
{ {
const auto widget = static_cast<const EasyGraphicsScrollbar*>(scene()->parent()); const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent());
const bool bindMode = widget->bindMode(); const bool bindMode = widget->bindMode();
const auto currentScale = widget->getWindowScale(); const auto currentScale = widget->getWindowScale();
const auto bottom = m_boundingRect.bottom(); const auto bottom = m_boundingRect.bottom();
@ -239,7 +239,7 @@ void GraphicsHistogramItem::paintByPtr(QPainter* _painter)
void GraphicsHistogramItem::paintById(QPainter* _painter) void GraphicsHistogramItem::paintById(QPainter* _painter)
{ {
const auto widget = static_cast<const EasyGraphicsScrollbar*>(scene()->parent()); const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent());
const bool bindMode = widget->bindMode(); const bool bindMode = widget->bindMode();
const auto currentScale = widget->getWindowScale(); const auto currentScale = widget->getWindowScale();
const auto bottom = m_boundingRect.bottom(); const auto bottom = m_boundingRect.bottom();
@ -410,13 +410,15 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, const pr
m_timeUnits = EASY_GLOBALS.time_units; m_timeUnits = EASY_GLOBALS.time_units;
setReady(false); setReady(false);
m_workerThread = std::thread([this](const profiler_gui::EasyItems* _source)
auto source = m_pSource;
m_worker.enqueue([this, source]
{ {
m_maxValue = 0; m_maxValue = 0;
m_minValue = 1e30; m_minValue = 1e30;
bool empty = true; bool empty = true;
for (const auto& item : *_source) for (const auto& item : *source)
{ {
if (isReady()) if (isReady())
return; return;
@ -464,7 +466,7 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, const pr
setReady(true); setReady(true);
}, m_pSource); }, m_bReady);
startTimer(); startTimer();
show(); show();
@ -536,10 +538,16 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, profiler
m_threadWaitTime = root.wait_time; m_threadWaitTime = root.wait_time;
setReady(false); setReady(false);
m_workerThread = std::thread([this](decltype(root) profiler_thread, profiler::block_index_t selected_block, bool _showOnlyTopLevelBlocks)
const auto selected_thread = std::ref(root);
const auto selected_block = EASY_GLOBALS.selected_block;
const bool showOnlyTopLevelBlocks = EASY_GLOBALS.display_only_frames_on_histogram;
m_worker.enqueue([this, selected_thread, selected_block, showOnlyTopLevelBlocks]
{ {
using Stack = std::vector<std::pair<profiler::block_index_t, profiler::block_index_t> >; using Stack = std::vector<std::pair<profiler::block_index_t, profiler::block_index_t> >;
const auto& profiler_thread = selected_thread.get();
m_maxValue = 0; m_maxValue = 0;
m_minValue = 1e30; m_minValue = 1e30;
//const auto& profiler_thread = EASY_GLOBALS.profiler_blocks[m_threadId]; //const auto& profiler_thread = EASY_GLOBALS.profiler_blocks[m_threadId];
@ -565,7 +573,7 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, profiler
m_blockTotalDuraion += w; m_blockTotalDuraion += w;
} }
if (_showOnlyTopLevelBlocks) if (showOnlyTopLevelBlocks)
continue; continue;
stack.emplace_back(frame, 0U); stack.emplace_back(frame, 0U);
@ -652,7 +660,7 @@ void GraphicsHistogramItem::setSource(profiler::thread_id_t _thread_id, profiler
setReady(true); setReady(true);
}, std::ref(root), EASY_GLOBALS.selected_block, EASY_GLOBALS.display_only_frames_on_histogram); }, m_bReady);
startTimer(); startTimer();
} }
@ -777,7 +785,7 @@ void GraphicsHistogramItem::onModeChanged()
if (!isImageUpdatePermitted()) if (!isImageUpdatePermitted())
return; return;
const auto widget = static_cast<const EasyGraphicsScrollbar*>(scene()->parent()); const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent());
if (!widget->bindMode() && EASY_GLOBALS.auto_adjust_histogram_height) if (!widget->bindMode() && EASY_GLOBALS.auto_adjust_histogram_height)
{ {
m_topValue = m_maxValue; m_topValue = m_maxValue;
@ -800,10 +808,25 @@ bool GraphicsHistogramItem::updateImage()
m_imageScaleUpdate = widget->range() / widget->sliderWidth(); m_imageScaleUpdate = widget->range() / widget->sliderWidth();
m_imageOriginUpdate = widget->bindMode() ? (widget->value() - widget->sliderWidth() * 3) : widget->minimum(); m_imageOriginUpdate = widget->bindMode() ? (widget->value() - widget->sliderWidth() * 3) : widget->minimum();
m_workerThread = std::thread(&This::updateImageAsync, this, m_boundingRect, m_regime, widget->getWindowScale(), // Ugly, but doesn't use exceeded count of threads
widget->minimum(), widget->maximum(), widget->range(), widget->value(), widget->sliderWidth(), const auto rect = m_boundingRect;
m_topValue, m_bottomValue, widget->bindMode(), EASY_GLOBALS.frame_time, EASY_GLOBALS.begin_time, const auto regime = m_regime;
EASY_GLOBALS.auto_adjust_histogram_height); const auto scale = widget->getWindowScale();
const auto left = widget->minimum();
const auto right = widget->maximum();
const auto value = widget->value();
const auto window = widget->sliderWidth();
const auto top = m_topValue;
const auto bottom = m_bottomValue;
const auto bindMode = widget->bindMode();
const auto frameTime = EASY_GLOBALS.frame_time;
const auto beginTime = EASY_GLOBALS.begin_time;
const auto autoHeight = EASY_GLOBALS.auto_adjust_histogram_height;
m_worker.enqueue([this, rect, regime, scale, left, right, value, window, top, bottom, bindMode, frameTime, beginTime, autoHeight]
{
updateImageAsync(rect, regime, scale, left, right, right - left, value, window, top, bottom, bindMode,
frameTime, beginTime, autoHeight);
}, m_bReady);
return true; return true;
} }
@ -1119,7 +1142,7 @@ void GraphicsHistogramItem::updateImageAsync(QRectF _boundingRect, HistRegime _r
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyGraphicsScrollbar::EasyGraphicsScrollbar(int _initialHeight, QWidget* _parent) BlocksGraphicsScrollbar::BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent)
: Parent(_parent) : Parent(_parent)
, m_histogramItem(nullptr) , m_histogramItem(nullptr)
{ {
@ -1134,27 +1157,27 @@ EasyGraphicsScrollbar::EasyGraphicsScrollbar(int _initialHeight, QWidget* _paren
m_histogramItem->setBoundingRect(0, scene()->sceneRect().top() + margin(), scene()->width(), sceneHeight - margins() - 1); m_histogramItem->setBoundingRect(0, scene()->sceneRect().top() + margin(), scene()->width(), sceneHeight - margins() - 1);
m_histogramItem->hide(); m_histogramItem->hide();
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::expectedFrameTimeChanged, connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::expectedFrameTimeChanged,
this, &This::onExpectedFrameTimeChanged); this, &This::onExpectedFrameTimeChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::autoAdjustHistogramChanged, connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::autoAdjustHistogramChanged,
this, &This::onAutoAdjustHistogramChanged); this, &This::onAutoAdjustHistogramChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::displayOnlyFramesOnHistogramChanged, connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::displayOnlyFramesOnHistogramChanged,
this, &This::onDisplayOnlyFramesOnHistogramChanged); this, &This::onDisplayOnlyFramesOnHistogramChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::threadNameDecorationChanged, this, &This::onThreadViewChanged); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::threadNameDecorationChanged, this, &This::onThreadViewChanged);
connect(&EASY_GLOBALS.events, &profiler_gui::EasyGlobalSignals::hexThreadIdChanged, this, &This::onThreadViewChanged); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::hexThreadIdChanged, this, &This::onThreadViewChanged);
} }
EasyGraphicsScrollbar::~EasyGraphicsScrollbar() BlocksGraphicsScrollbar::~BlocksGraphicsScrollbar()
{ {
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyGraphicsScrollbar::onThreadViewChanged() void BlocksGraphicsScrollbar::onThreadViewChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
{ {
@ -1163,7 +1186,7 @@ void EasyGraphicsScrollbar::onThreadViewChanged()
} }
} }
void EasyGraphicsScrollbar::onExpectedFrameTimeChanged() void BlocksGraphicsScrollbar::onExpectedFrameTimeChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
{ {
@ -1172,13 +1195,13 @@ void EasyGraphicsScrollbar::onExpectedFrameTimeChanged()
} }
} }
void EasyGraphicsScrollbar::onAutoAdjustHistogramChanged() void BlocksGraphicsScrollbar::onAutoAdjustHistogramChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
m_histogramItem->onModeChanged(); m_histogramItem->onModeChanged();
} }
void EasyGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged() void BlocksGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
m_histogramItem->rebuildSource(GraphicsHistogramItem::Hist_Id); m_histogramItem->rebuildSource(GraphicsHistogramItem::Hist_Id);
@ -1186,18 +1209,18 @@ void EasyGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyGraphicsScrollbar::clear() void BlocksGraphicsScrollbar::clear()
{ {
setHistogramSource(0, nullptr); setHistogramSource(0, nullptr);
Parent::clear(); Parent::clear();
} }
profiler::thread_id_t EasyGraphicsScrollbar::hystThread() const profiler::thread_id_t BlocksGraphicsScrollbar::hystThread() const
{ {
return m_histogramItem->threadId(); return m_histogramItem->threadId();
} }
void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items) void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items)
{ {
if (m_bLocked) if (m_bLocked)
return; return;
@ -1206,7 +1229,7 @@ void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id,
scene()->update(); scene()->update();
} }
void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id) void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id)
{ {
if (m_bLocked) if (m_bLocked)
return; return;
@ -1215,7 +1238,7 @@ void EasyGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id,
scene()->update(); scene()->update();
} }
void EasyGraphicsScrollbar::mousePressEvent(QMouseEvent* _event) void BlocksGraphicsScrollbar::mousePressEvent(QMouseEvent* _event)
{ {
Parent::mousePressEvent(_event); Parent::mousePressEvent(_event);
if ((m_mouseButtons & Qt::RightButton) && _event->modifiers()) if ((m_mouseButtons & Qt::RightButton) && _event->modifiers())

View File

@ -142,21 +142,21 @@ private:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyGraphicsScrollbar : public GraphicsSliderArea class BlocksGraphicsScrollbar : public GraphicsSliderArea
{ {
Q_OBJECT Q_OBJECT
private: private:
using Parent = GraphicsSliderArea; using Parent = GraphicsSliderArea;
using This = EasyGraphicsScrollbar; using This = BlocksGraphicsScrollbar;
GraphicsHistogramItem* m_histogramItem = nullptr; GraphicsHistogramItem* m_histogramItem = nullptr;
public: public:
explicit EasyGraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr); explicit BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr);
~EasyGraphicsScrollbar() override; ~BlocksGraphicsScrollbar() override;
void clear() override; void clear() override;
void mousePressEvent(QMouseEvent* _event) override; void mousePressEvent(QMouseEvent* _event) override;
@ -180,7 +180,7 @@ private slots:
void onAutoAdjustHistogramChanged(); void onAutoAdjustHistogramChanged();
void onDisplayOnlyFramesOnHistogramChanged(); void onDisplayOnlyFramesOnHistogramChanged();
}; // END of class EasyGraphicsScrollbar. }; // END of class BlocksGraphicsScrollbar.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : This file contains implementation of EasyQTimer class used to * description : This file contains implementation of Timer class used to
* : connect QTimer to non-QObject classes. * : connect QTimer to non-QObject classes.
* ----------------- : * ----------------- :
* change log : * 2016/12/05 Victor Zarubkin: Initial commit. * change log : * 2016/12/05 Victor Zarubkin: Initial commit.
@ -57,69 +57,69 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyQTimer::EasyQTimer() Timer::Timer()
: QObject() : QObject()
{ {
connect(&m_timer, &QTimer::timeout, this, &EasyQTimer::onTimeout); connect(&m_timer, &QTimer::timeout, this, &Timer::onTimeout);
} }
EasyQTimer::EasyQTimer(::std::function<void()>&& handler, bool signleShot) Timer::Timer(std::function<void()>&& handler, bool signleShot)
: QObject() : QObject()
, m_handler(::std::forward<::std::function<void()>&&>(handler)) , m_handler(std::forward<std::function<void()>&&>(handler))
{ {
m_timer.setSingleShot(signleShot); m_timer.setSingleShot(signleShot);
connect(&m_timer, &QTimer::timeout, this, &EasyQTimer::onTimeout); connect(&m_timer, &QTimer::timeout, this, &Timer::onTimeout);
} }
EasyQTimer::~EasyQTimer() Timer::~Timer()
{ {
} }
void EasyQTimer::onTimeout() void Timer::onTimeout()
{ {
m_handler(); m_handler();
} }
void EasyQTimer::setHandler(::std::function<void()>&& handler) void Timer::setHandler(std::function<void()>&& handler)
{ {
m_handler = handler; m_handler = handler;
} }
void EasyQTimer::setSignleShot(bool singleShot) void Timer::setSignleShot(bool singleShot)
{ {
m_timer.setSingleShot(singleShot); m_timer.setSingleShot(singleShot);
} }
bool EasyQTimer::isSingleShot() const bool Timer::isSingleShot() const
{ {
return m_timer.isSingleShot(); return m_timer.isSingleShot();
} }
void EasyQTimer::setInterval(int msec) void Timer::setInterval(int msec)
{ {
m_timer.setInterval(msec); m_timer.setInterval(msec);
} }
void EasyQTimer::start(int msec) void Timer::start(int msec)
{ {
stop(); stop();
m_timer.start(msec); m_timer.start(msec);
} }
void EasyQTimer::start() void Timer::start()
{ {
stop(); stop();
m_timer.start(); m_timer.start();
} }
void EasyQTimer::stop() void Timer::stop()
{ {
if (m_timer.isActive()) if (m_timer.isActive())
m_timer.stop(); m_timer.stop();
} }
bool EasyQTimer::isActive() const bool Timer::isActive() const
{ {
return m_timer.isActive(); return m_timer.isActive();
} }

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : This file contains declaration of EasyQTimer class used to * description : This file contains declaration of Timer class used to
* : connect QTimer to non-QObject classes. * : connect QTimer to non-QObject classes.
* ----------------- : * ----------------- :
* change log : * 2016/12/05 Victor Zarubkin: Initial commit. * change log : * 2016/12/05 Victor Zarubkin: Initial commit.
@ -61,7 +61,7 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyQTimer : public QObject class Timer : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -72,11 +72,11 @@ private:
public: public:
explicit EasyQTimer(); explicit Timer();
explicit EasyQTimer(::std::function<void()>&& handler, bool signleShot = false); explicit Timer(std::function<void()>&& handler, bool signleShot = false);
~EasyQTimer() override; ~Timer() override;
void setHandler(::std::function<void()>&& _handler); void setHandler(std::function<void()>&& handler);
void setSignleShot(bool singleShot); void setSignleShot(bool singleShot);
bool isSingleShot() const; bool isSingleShot() const;
@ -91,7 +91,7 @@ private slots:
void onTimeout(); void onTimeout();
}; // END of class EasyQTimer. }; // END of class Timer.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -61,15 +61,15 @@
namespace profiler_gui { namespace profiler_gui {
EasyGlobals& EasyGlobals::instance() Globals& Globals::instance()
{ {
// It's okay even without C++11 "magic statics" feature because first call happens // It's okay even without C++11 "magic statics" feature because first call happens
// on application initialization - there is only one thread and no data races occur. // on application initialization - there is only one thread and no data races occur.
static EasyGlobals globals; static Globals globals;
return globals; return globals;
} }
EasyGlobals::EasyGlobals() Globals::Globals()
: theme("default") : theme("default")
, bg_font(::profiler_gui::EFont("DejaVu Sans", 10, QFont::Bold)) , bg_font(::profiler_gui::EFont("DejaVu Sans", 10, QFont::Bold))
, chronometer_font(::profiler_gui::EFont("DejaVu Sans", 16, QFont::Bold)) , chronometer_font(::profiler_gui::EFont("DejaVu Sans", 16, QFont::Bold))

View File

@ -171,11 +171,11 @@ namespace profiler_gui {
bool empty = true; bool empty = true;
}; };
struct EasyGlobals Q_DECL_FINAL struct Globals Q_DECL_FINAL
{ {
static EasyGlobals& instance(); static Globals& instance();
EasyGlobalSignals events; ///< Global signals GlobalSignals events; ///< Global signals
::profiler::thread_blocks_tree_t profiler_blocks; ///< Profiler blocks tree loaded from file ::profiler::thread_blocks_tree_t profiler_blocks; ///< Profiler blocks tree loaded from file
::profiler::descriptors_list_t descriptors; ///< Profiler block descriptors list ::profiler::descriptors_list_t descriptors; ///< Profiler block descriptors list
EasyBlocks gui_blocks; ///< Profiler graphics blocks builded by GUI EasyBlocks gui_blocks; ///< Profiler graphics blocks builded by GUI
@ -226,16 +226,16 @@ namespace profiler_gui {
private: private:
EasyGlobals(); Globals();
}; // END of struct EasyGlobals. }; // END of struct Globals.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
} // END of namespace profiler_gui. } // END of namespace profiler_gui.
#ifndef IGNORE_GLOBALS_DECLARATION #ifndef IGNORE_GLOBALS_DECLARATION
#define EASY_GLOBALS ::profiler_gui::EasyGlobals::instance() #define EASY_GLOBALS ::profiler_gui::Globals::instance()
inline ::profiler_gui::EasyBlock& easyBlock(::profiler::block_index_t i) { inline ::profiler_gui::EasyBlock& easyBlock(::profiler::block_index_t i) {
return EASY_GLOBALS.gui_blocks[i]; return EASY_GLOBALS.gui_blocks[i];

View File

@ -5,7 +5,7 @@
* authors : Victor Zarubkin, Sergey Yagovtsev * authors : Victor Zarubkin, Sergey Yagovtsev
* email : v.s.zarubkin@gmail.com, yse.sey@gmail.com * email : v.s.zarubkin@gmail.com, yse.sey@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyGlobalSignals QObject class. * description : The file contains implementation of GlobalSignals QObject class.
* ----------------- : * ----------------- :
* change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.cpp * change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.cpp
* : * :
@ -59,11 +59,11 @@
namespace profiler_gui { namespace profiler_gui {
EasyGlobalSignals::EasyGlobalSignals() : QObject() GlobalSignals::GlobalSignals() : QObject()
{ {
} }
EasyGlobalSignals::~EasyGlobalSignals() GlobalSignals::~GlobalSignals()
{ {
} }

View File

@ -5,7 +5,7 @@
* authors : Victor Zarubkin, Sergey Yagovtsev * authors : Victor Zarubkin, Sergey Yagovtsev
* email : v.s.zarubkin@gmail.com, yse.sey@gmail.com * email : v.s.zarubkin@gmail.com, yse.sey@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyGlobalSignals QObject class. * description : The file contains declaration of GlobalSignals QObject class.
* ----------------- : * ----------------- :
* change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.h * change log : * 2016/08/08 Sergey Yagovtsev: moved sources from globals.h
* : * :
@ -60,14 +60,14 @@
namespace profiler_gui { namespace profiler_gui {
class EasyGlobalSignals Q_DECL_FINAL : public QObject class GlobalSignals Q_DECL_FINAL : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
EasyGlobalSignals(); GlobalSignals();
~EasyGlobalSignals() Q_DECL_OVERRIDE; ~GlobalSignals() Q_DECL_OVERRIDE;
signals: signals:
@ -100,7 +100,7 @@ namespace profiler_gui {
void chartWheeled(qreal pos, int delta); void chartWheeled(qreal pos, int delta);
void chartSliderChanged(qreal pos); void chartSliderChanged(qreal pos);
}; // END of class EasyGlobalSignals. }; // END of class GlobalSignals.
} // END of namespace profiler_gui. } // END of namespace profiler_gui.

View File

@ -258,9 +258,6 @@ void GraphicsImageItem::onTimeout()
{ {
// Image updated // Image updated
if (m_workerThread.joinable())
m_workerThread.join();
m_workerImage->swap(m_image); m_workerImage->swap(m_image);
delete m_workerImage; delete m_workerImage;
m_workerImage = nullptr; m_workerImage = nullptr;
@ -286,18 +283,15 @@ bool GraphicsImageItem::isImageUpdatePermitted() const
void GraphicsImageItem::cancelAnyJob() void GraphicsImageItem::cancelAnyJob()
{ {
setReady(true); stopTimer();
if (m_workerThread.joinable())
m_workerThread.join(); m_worker.dequeue();
//setReady(false);
delete m_workerImage; delete m_workerImage;
m_workerImage = nullptr; m_workerImage = nullptr;
m_imageOriginUpdate = m_imageOrigin; m_imageOriginUpdate = m_imageOrigin;
m_imageScaleUpdate = m_imageScale; m_imageScaleUpdate = m_imageScale;
stopTimer();
} }
void GraphicsImageItem::resetTopBottomValues() void GraphicsImageItem::resetTopBottomValues()

View File

@ -4,9 +4,9 @@
#define EASY_PROFILER_GRAPHICS_IMAGE_ITEM_H #define EASY_PROFILER_GRAPHICS_IMAGE_ITEM_H
#include <QGraphicsItem> #include <QGraphicsItem>
#include <thread>
#include <atomic> #include <atomic>
#include "easy_qtimer.h" #include "easy_qtimer.h"
#include "thread_pool_task.h"
class GraphicsImageItem : public QGraphicsItem class GraphicsImageItem : public QGraphicsItem
{ {
@ -17,8 +17,8 @@ protected:
QRectF m_boundingRect; QRectF m_boundingRect;
QImage m_image; QImage m_image;
EasyQTimer m_boundaryTimer; Timer m_boundaryTimer;
std::thread m_workerThread; ThreadPoolTask m_worker;
QPointF m_mousePos; QPointF m_mousePos;
QImage* m_workerImage; QImage* m_workerImage;
qreal m_imageOrigin; qreal m_imageOrigin;
@ -31,11 +31,11 @@ protected:
qreal m_bottomValue; qreal m_bottomValue;
qreal m_maxValue; qreal m_maxValue;
qreal m_minValue; qreal m_minValue;
std::atomic_bool m_bReady;
private: private:
EasyQTimer m_timer; Timer m_timer;
std::atomic_bool m_bReady;
bool m_bPermitImageUpdate; ///< Is false when m_workerThread is parsing input dataset (when setSource(_block_id) is called) bool m_bPermitImageUpdate; ///< Is false when m_workerThread is parsing input dataset (when setSource(_block_id) is called)
public: public:

View File

@ -218,13 +218,13 @@ GraphicsSliderArea::GraphicsSliderArea(QWidget* _parent)
centerOn(0, 0); centerOn(0, 0);
auto globalEvents = &EASY_GLOBALS.events; auto globalEvents = &EASY_GLOBALS.events;
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneCleared, this, &This::clear); connect(globalEvents, &profiler_gui::GlobalSignals::sceneCleared, this, &This::clear);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneVisibleRegionSizeChanged, this, &This::setSliderWidth); connect(globalEvents, &profiler_gui::GlobalSignals::sceneVisibleRegionSizeChanged, this, &This::setSliderWidth);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneVisibleRegionPosChanged, this, &This::setValue); connect(globalEvents, &profiler_gui::GlobalSignals::sceneVisibleRegionPosChanged, this, &This::setValue);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::chartSliderChanged, this, &This::onExternalChartSliderChanged); connect(globalEvents, &profiler_gui::GlobalSignals::chartSliderChanged, this, &This::onExternalChartSliderChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::sceneSizeChanged, this, &This::onSceneSizeChanged); connect(globalEvents, &profiler_gui::GlobalSignals::sceneSizeChanged, this, &This::onSceneSizeChanged);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::lockCharts, this, &This::lock); connect(globalEvents, &profiler_gui::GlobalSignals::lockCharts, this, &This::lock);
connect(globalEvents, &profiler_gui::EasyGlobalSignals::unlockCharts, this, &This::unlock); connect(globalEvents, &profiler_gui::GlobalSignals::unlockCharts, this, &This::unlock);
} }
GraphicsSliderArea::~GraphicsSliderArea() GraphicsSliderArea::~GraphicsSliderArea()

View File

@ -52,6 +52,7 @@
#include <QApplication> #include <QApplication>
#include "main_window.h" #include "main_window.h"
#include "globals.h" #include "globals.h"
#include "thread_pool.h"
#if defined(_WIN32) && defined (_BUILD_RELEASE_) #if defined(_WIN32) && defined (_BUILD_RELEASE_)
#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
@ -62,12 +63,15 @@ int main(int argc, char **argv)
auto now = ::std::chrono::duration_cast<std::chrono::seconds>(::std::chrono::system_clock::now().time_since_epoch()).count() >> 1; auto now = ::std::chrono::duration_cast<std::chrono::seconds>(::std::chrono::system_clock::now().time_since_epoch()).count() >> 1;
srand((unsigned int)now); srand((unsigned int)now);
// Instanciate thread pool to avoid data races for compilers without C++11 thread-safe statics
ThreadPool::instance();
QApplication app(argc, argv); QApplication app(argc, argv);
// Instanciate easy globals after QApplication to allow creation of global fonts, and on the main thread to avoid data races // Instanciate easy globals after QApplication to allow creation of global fonts, and on the main thread to avoid data races
profiler_gui::EasyGlobals::instance(); profiler_gui::Globals::instance();
EasyMainWindow window; MainWindow window;
window.show(); window.show();
return app.exec(); return app.exec();

File diff suppressed because it is too large Load Diff

View File

@ -83,28 +83,28 @@ namespace profiler { namespace net { struct EasyProfilerStatus; } }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyFileReader Q_DECL_FINAL class FileReader Q_DECL_FINAL
{ {
::profiler::SerializedData m_serializedBlocks; ///< profiler::SerializedData m_serializedBlocks; ///<
::profiler::SerializedData m_serializedDescriptors; ///< profiler::SerializedData m_serializedDescriptors; ///<
::profiler::descriptors_list_t m_descriptors; ///< profiler::descriptors_list_t m_descriptors; ///<
::profiler::blocks_t m_blocks; ///< profiler::blocks_t m_blocks; ///<
::profiler::thread_blocks_tree_t m_blocksTree; ///< profiler::thread_blocks_tree_t m_blocksTree; ///<
::std::stringstream m_stream; ///< std::stringstream m_stream; ///<
::std::stringstream m_errorMessage; ///< std::stringstream m_errorMessage; ///<
QString m_filename; ///< QString m_filename; ///<
uint32_t m_descriptorsNumberInFile = 0; ///< uint32_t m_descriptorsNumberInFile = 0; ///<
uint32_t m_version = 0; ///< uint32_t m_version = 0; ///<
::std::thread m_thread; ///< std::thread m_thread; ///<
::std::atomic_bool m_bDone; ///< std::atomic_bool m_bDone; ///<
::std::atomic<int> m_progress; ///< std::atomic<int> m_progress; ///<
::std::atomic<unsigned int> m_size; ///< std::atomic<unsigned int> m_size; ///<
bool m_isFile = false; ///< bool m_isFile = false; ///<
public: public:
EasyFileReader(); FileReader();
~EasyFileReader(); ~FileReader();
const bool isFile() const; const bool isFile() const;
bool done() const; bool done() const;
@ -113,44 +113,44 @@ public:
const QString& filename() const; const QString& filename() const;
void load(const QString& _filename); void load(const QString& _filename);
void load(::std::stringstream& _stream); void load(std::stringstream& _stream);
void interrupt(); void interrupt();
void get(::profiler::SerializedData& _serializedBlocks, ::profiler::SerializedData& _serializedDescriptors, void get(profiler::SerializedData& _serializedBlocks, profiler::SerializedData& _serializedDescriptors,
::profiler::descriptors_list_t& _descriptors, ::profiler::blocks_t& _blocks, ::profiler::thread_blocks_tree_t& _tree, profiler::descriptors_list_t& _descriptors, profiler::blocks_t& _blocks, profiler::thread_blocks_tree_t& _tree,
uint32_t& _descriptorsNumberInFile, uint32_t& _version, QString& _filename); uint32_t& _descriptorsNumberInFile, uint32_t& _version, QString& _filename);
void join(); void join();
QString getError(); QString getError();
}; // END of class EasyFileReader. }; // END of class FileReader.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
enum EasyListenerRegime : uint8_t enum class ListenerRegime : uint8_t
{ {
LISTENER_IDLE = 0, Idle = 0,
LISTENER_CAPTURE, Capture,
LISTENER_CAPTURE_RECEIVE, Capture_Receive,
LISTENER_DESCRIBE Descriptors
}; };
class EasySocketListener Q_DECL_FINAL class EasySocketListener Q_DECL_FINAL
{ {
EasySocket m_easySocket; ///< EasySocket m_easySocket; ///<
::std::string m_address; ///< std::string m_address; ///<
::std::stringstream m_receivedData; ///< std::stringstream m_receivedData; ///<
::std::thread m_thread; ///< std::thread m_thread; ///<
uint64_t m_receivedSize; ///< uint64_t m_receivedSize; ///<
uint16_t m_port; ///< uint16_t m_port; ///<
::std::atomic<uint32_t> m_frameMax; ///< std::atomic<uint32_t> m_frameMax; ///<
::std::atomic<uint32_t> m_frameAvg; ///< std::atomic<uint32_t> m_frameAvg; ///<
::std::atomic_bool m_bInterrupt; ///< std::atomic_bool m_bInterrupt; ///<
::std::atomic_bool m_bConnected; ///< std::atomic_bool m_bConnected; ///<
::std::atomic_bool m_bStopReceive; ///< std::atomic_bool m_bStopReceive; ///<
::std::atomic_bool m_bCaptureReady; ///< std::atomic_bool m_bCaptureReady; ///<
::std::atomic_bool m_bFrameTimeReady; ///< std::atomic_bool m_bFrameTimeReady; ///<
EasyListenerRegime m_regime; ///< ListenerRegime m_regime; ///<
public: public:
@ -159,18 +159,18 @@ public:
bool connected() const; bool connected() const;
bool captured() const; bool captured() const;
EasyListenerRegime regime() const; ListenerRegime regime() const;
uint64_t size() const; uint64_t size() const;
const ::std::string& address() const; const std::string& address() const;
uint16_t port() const; uint16_t port() const;
::std::stringstream& data(); std::stringstream& data();
void clearData(); void clearData();
void disconnect(); void disconnect();
void closeSocket(); void closeSocket();
bool connect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst = false); bool connect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply, bool _disconnectFirst = false);
bool reconnect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply); bool reconnect(const char* _ipaddress, uint16_t _port, profiler::net::EasyProfilerStatus& _reply);
bool startCapture(); bool startCapture();
void stopCapture(); void stopCapture();
@ -181,8 +181,7 @@ public:
bool requestFrameTime(); bool requestFrameTime();
template <class T> template <class T>
inline void send(const T& _message) void send(const T& _message) {
{
m_easySocket.send(&_message, sizeof(T)); m_easySocket.send(&_message, sizeof(T));
} }
@ -214,13 +213,13 @@ struct DialogWithGeometry EASY_FINAL
void restoreGeometry(); void restoreGeometry();
}; };
class EasyMainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
protected: protected:
using This = EasyMainWindow; using This = MainWindow;
using Parent = QMainWindow; using Parent = QMainWindow;
DialogWithGeometry m_descTreeDialog; DialogWithGeometry m_descTreeDialog;
@ -237,14 +236,14 @@ protected:
#endif #endif
class QProgressDialog* m_progress = nullptr; class QProgressDialog* m_progress = nullptr;
class EasyDescWidget* m_dialogDescTree = nullptr; class BlockDescriptorsWidget* m_dialogDescTree = nullptr;
class QMessageBox* m_listenerDialog = nullptr; class QMessageBox* m_listenerDialog = nullptr;
QTimer m_readerTimer; QTimer m_readerTimer;
QTimer m_listenerTimer; QTimer m_listenerTimer;
QTimer m_fpsRequestTimer; QTimer m_fpsRequestTimer;
::profiler::SerializedData m_serializedBlocks; profiler::SerializedData m_serializedBlocks;
::profiler::SerializedData m_serializedDescriptors; profiler::SerializedData m_serializedDescriptors;
EasyFileReader m_reader; FileReader m_reader;
EasySocketListener m_listener; EasySocketListener m_listener;
class QLineEdit* m_addressEdit = nullptr; class QLineEdit* m_addressEdit = nullptr;
@ -267,8 +266,8 @@ protected:
public: public:
explicit EasyMainWindow(); explicit MainWindow();
~EasyMainWindow() override; ~MainWindow() override;
// Public virtual methods // Public virtual methods
@ -316,7 +315,7 @@ protected slots:
void onFrameTimeEditFinish(); void onFrameTimeEditFinish();
void onFrameTimeChanged(); void onFrameTimeChanged();
void onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status); void onBlockStatusChange(profiler::block_id_t _id, profiler::EasyBlockStatus _status);
void checkFrameTimeReady(); void checkFrameTimeReady();
@ -330,7 +329,7 @@ private:
void addFileToList(const QString& filename); void addFileToList(const QString& filename);
void loadFile(const QString& filename); void loadFile(const QString& filename);
void readStream(::std::stringstream& data); void readStream(std::stringstream& data);
void loadSettings(); void loadSettings();
void loadGeometry(); void loadGeometry();
@ -341,7 +340,7 @@ private:
void destroyProgressDialog(); void destroyProgressDialog();
void createProgressDialog(const QString& text); void createProgressDialog(const QString& text);
}; // END of class EasyMainWindow. }; // END of class MainWindow.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -20,7 +20,7 @@
*:disabled { *:disabled {
color: #a08888; } color: #a08888; }
EasyMainWindow, QToolBar, QDialog { MainWindow, QToolBar, QDialog {
background-color: #f8f2f2; } background-color: #f8f2f2; }
QToolTip { QToolTip {

View File

@ -42,7 +42,7 @@ $SpinBoxArrowSize: 8px;
color: $DisabledTextColor; color: $DisabledTextColor;
} }
EasyMainWindow, QToolBar, QDialog { MainWindow, QToolBar, QDialog {
background-color: #f8f2f2; background-color: #f8f2f2;
} }

View File

@ -0,0 +1,77 @@
/*
* */
#include "thread_pool.h"
#include <algorithm>
ThreadPool& ThreadPool::instance()
{
static ThreadPool pool;
return pool;
}
ThreadPool::ThreadPool()
{
const auto threadsCount = std::max(std::thread::hardware_concurrency(), 2U);
m_threads.reserve(threadsCount);
std::generate_n(std::back_inserter(m_threads), threadsCount, [this] {
return std::thread(&ThreadPool::work, this);
});
}
ThreadPool::~ThreadPool()
{
m_interrupt.store(true, std::memory_order_release);
m_cv.notify_all();
for (auto& thread : m_threads)
thread.join();
}
void ThreadPool::enqueue(ThreadPoolTask& task)
{
m_mutex.lock();
m_tasks.emplace_back(task);
m_mutex.unlock();
m_cv.notify_one();
}
void ThreadPool::dequeue(ThreadPoolTask& task)
{
const std::lock_guard<std::mutex> lock(m_mutex);
if (task.status() != TaskStatus::Enqueued)
return;
for (auto it = m_tasks.begin(); it != m_tasks.end(); ++it)
{
if (&it->get() == &task)
{
m_tasks.erase(it);
break;
}
}
}
void ThreadPool::work()
{
while (true)
{
std::unique_lock<std::mutex> lock(m_mutex);
m_cv.wait(lock, [this] { return !m_tasks.empty() || m_interrupt.load(std::memory_order_acquire); });
if (m_interrupt.load(std::memory_order_acquire))
break;
if (m_tasks.empty())
continue;
auto& task = m_tasks.front().get();
task.setStatus(TaskStatus::Processing);
m_tasks.pop_front();
lock.unlock();
task.execute();
}
}

View File

@ -0,0 +1,39 @@
/**
* */
#ifndef EASY_PROFILER_THREAD_POOL_H
#define EASY_PROFILER_THREAD_POOL_H
#include "thread_pool_task.h"
#include <vector>
#include <deque>
#include <condition_variable>
#include <thread>
class ThreadPool EASY_FINAL
{
friend ThreadPoolTask;
std::vector<std::thread> m_threads;
std::deque<std::reference_wrapper<ThreadPoolTask> > m_tasks;
std::mutex m_mutex;
std::condition_variable m_cv;
std::atomic_bool m_interrupt;
ThreadPool();
public:
~ThreadPool();
static ThreadPool& instance();
private:
void enqueue(ThreadPoolTask& task);
void dequeue(ThreadPoolTask& task);
void work();
}; // end of class ThreadPool.
#endif //EASY_PROFILER_THREAD_POOL_H

View File

@ -0,0 +1,65 @@
/**
* */
#include "thread_pool_task.h"
#include "thread_pool.h"
ThreadPoolTask::ThreadPoolTask() : m_func([]{}), m_interrupt(nullptr)
{
m_status = ATOMIC_VAR_INIT(static_cast<int8_t>(TaskStatus::Finished));
}
ThreadPoolTask::~ThreadPoolTask()
{
dequeue();
}
void ThreadPoolTask::enqueue(std::function<void()>&& func, std::atomic_bool& interruptFlag)
{
dequeue();
m_interrupt = & interruptFlag;
m_interrupt->store(false, std::memory_order_release);
m_func = std::move(func);
setStatus(TaskStatus::Enqueued);
ThreadPool::instance().enqueue(*this);
}
void ThreadPoolTask::dequeue()
{
if (m_interrupt == nullptr)
return;
m_interrupt->store(true, std::memory_order_release);
ThreadPool::instance().dequeue(*this);
// wait for finish
m_mutex.lock();
setStatus(TaskStatus::Finished);
m_mutex.unlock();
m_interrupt->store(false, std::memory_order_release);
}
TaskStatus ThreadPoolTask::status() const
{
return static_cast<TaskStatus>(m_status.load(std::memory_order_acquire));
}
void ThreadPoolTask::execute()
{
const std::lock_guard<std::mutex> guard(m_mutex);
if (status() == TaskStatus::Finished || m_interrupt->load(std::memory_order_acquire))
return;
m_func();
setStatus(TaskStatus::Finished);
}
void ThreadPoolTask::setStatus(TaskStatus status)
{
m_status.store(static_cast<int8_t>(status), std::memory_order_release);
}

View File

@ -0,0 +1,47 @@
/*
* */
#ifndef EASY_PROFILER_THREAD_POOL_TASK_H
#define EASY_PROFILER_THREAD_POOL_TASK_H
#include <easy/details/easy_compiler_support.h>
#include <functional>
#include <atomic>
#include <mutex>
enum class TaskStatus : int8_t
{
Enqueued,
Processing,
Finished,
};
class ThreadPoolTask EASY_FINAL
{
friend class ThreadPool;
std::function<void()> m_func;
std::mutex m_mutex;
std::atomic<int8_t> m_status;
std::atomic_bool* m_interrupt;
public:
ThreadPoolTask(const ThreadPoolTask&) = delete;
ThreadPoolTask(ThreadPoolTask&&) = delete;
ThreadPoolTask();
~ThreadPoolTask();
void enqueue(std::function<void()>&& func, std::atomic_bool& interruptFlag);
void dequeue();
private:
void execute();
TaskStatus status() const;
void setStatus(TaskStatus status);
};
#endif //EASY_PROFILER_THREAD_POOL_TASK_H

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyTreeWidgetItem. * description : The file contains implementation of TreeWidgetItem.
* ----------------- : * ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: Moved sources from blocks_tree_widget.cpp * change log : * 2016/08/18 Victor Zarubkin: Moved sources from blocks_tree_widget.cpp
* : and renamed classes from Prof* to Easy*. * : and renamed classes from Prof* to Easy*.
@ -109,7 +109,7 @@ EASY_CONSTEXPR int ColumnBit[COL_COLUMNS_NUMBER] = {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyTreeWidgetItem::EasyTreeWidgetItem(const ::profiler::block_index_t _treeBlock, Parent* _parent) TreeWidgetItem::TreeWidgetItem(const profiler::block_index_t _treeBlock, Parent* _parent)
: Parent(_parent, QTreeWidgetItem::UserType) : Parent(_parent, QTreeWidgetItem::UserType)
, m_block(_treeBlock) , m_block(_treeBlock)
, m_customBGColor(0) , m_customBGColor(0)
@ -118,11 +118,11 @@ EasyTreeWidgetItem::EasyTreeWidgetItem(const ::profiler::block_index_t _treeBloc
} }
EasyTreeWidgetItem::~EasyTreeWidgetItem() TreeWidgetItem::~TreeWidgetItem()
{ {
} }
bool EasyTreeWidgetItem::operator < (const Parent& _other) const bool TreeWidgetItem::operator < (const Parent& _other) const
{ {
const auto col = treeWidget()->sortColumn(); const auto col = treeWidget()->sortColumn();
@ -166,20 +166,20 @@ bool EasyTreeWidgetItem::operator < (const Parent& _other) const
} }
} }
bool EasyTreeWidgetItem::hasToolTip(int _column) const bool TreeWidgetItem::hasToolTip(int _column) const
{ {
const int bit = ColumnBit[_column]; const int bit = ColumnBit[_column];
return bit < 0 ? false : m_bHasToolTip.test(static_cast<size_t>(bit)); return bit < 0 ? false : m_bHasToolTip.test(static_cast<size_t>(bit));
} }
void EasyTreeWidgetItem::setHasToolTip(int _column) void TreeWidgetItem::setHasToolTip(int _column)
{ {
const int bit = ColumnBit[_column]; const int bit = ColumnBit[_column];
if (bit >= 0) if (bit >= 0)
m_bHasToolTip.set(static_cast<size_t>(bit), true); m_bHasToolTip.set(static_cast<size_t>(bit), true);
} }
QVariant EasyTreeWidgetItem::data(int _column, int _role) const QVariant TreeWidgetItem::data(int _column, int _role) const
{ {
if (_column == COL_NAME) if (_column == COL_NAME)
{ {
@ -207,7 +207,7 @@ QVariant EasyTreeWidgetItem::data(int _column, int _role) const
return m_font; return m_font;
case Qt::ForegroundRole: case Qt::ForegroundRole:
return m_bMain ? QVariant::fromValue(QColor::fromRgb(::profiler_gui::SELECTED_THREAD_FOREGROUND)) : QVariant(); return m_bMain ? QVariant::fromValue(QColor::fromRgb(profiler_gui::SELECTED_THREAD_FOREGROUND)) : QVariant();
case Qt::ToolTipRole: case Qt::ToolTipRole:
return hasToolTip(_column) ? return hasToolTip(_column) ?
@ -219,40 +219,40 @@ QVariant EasyTreeWidgetItem::data(int _column, int _role) const
} }
} }
::profiler::block_index_t EasyTreeWidgetItem::block_index() const profiler::block_index_t TreeWidgetItem::block_index() const
{ {
return m_block; return m_block;
} }
::profiler_gui::EasyBlock& EasyTreeWidgetItem::guiBlock() profiler_gui::EasyBlock& TreeWidgetItem::guiBlock()
{ {
return easyBlock(m_block); return easyBlock(m_block);
} }
const ::profiler::BlocksTree& EasyTreeWidgetItem::block() const const profiler::BlocksTree& TreeWidgetItem::block() const
{ {
return easyBlocksTree(m_block); return easyBlocksTree(m_block);
} }
::profiler::timestamp_t EasyTreeWidgetItem::duration() const profiler::timestamp_t TreeWidgetItem::duration() const
{ {
if (parent() != nullptr) if (parent() != nullptr)
return block().node->duration(); return block().node->duration();
return data(COL_DURATION, Qt::UserRole).toULongLong(); return data(COL_DURATION, Qt::UserRole).toULongLong();
} }
::profiler::timestamp_t EasyTreeWidgetItem::selfDuration() const profiler::timestamp_t TreeWidgetItem::selfDuration() const
{ {
return data(COL_SELF_DURATION, Qt::UserRole).toULongLong(); return data(COL_SELF_DURATION, Qt::UserRole).toULongLong();
} }
void EasyTreeWidgetItem::setTimeSmart(int _column, ::profiler_gui::TimeUnits _units, const ::profiler::timestamp_t& _time, const QString& _prefix) void TreeWidgetItem::setTimeSmart(int _column, profiler_gui::TimeUnits _units, const profiler::timestamp_t& _time, const QString& _prefix)
{ {
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time); const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime); setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column); setHasToolTip(_column);
setText(_column, QString("%1%2").arg(_prefix).arg(::profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3))); setText(_column, QString("%1%2").arg(_prefix).arg(profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3)));
// if (_time < 1e3) // if (_time < 1e3)
// { // {
@ -272,46 +272,46 @@ void EasyTreeWidgetItem::setTimeSmart(int _column, ::profiler_gui::TimeUnits _un
// } // }
} }
void EasyTreeWidgetItem::setTimeSmart(int _column, ::profiler_gui::TimeUnits _units, const ::profiler::timestamp_t& _time) void TreeWidgetItem::setTimeSmart(int _column, profiler_gui::TimeUnits _units, const profiler::timestamp_t& _time)
{ {
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time); const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime); setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column); setHasToolTip(_column);
setText(_column, ::profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3)); setText(_column, profiler_gui::timeStringRealNs(_units, nanosecondsTime, 3));
} }
void EasyTreeWidgetItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time) void TreeWidgetItem::setTimeMs(int _column, const profiler::timestamp_t& _time)
{ {
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time); const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime); setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column); setHasToolTip(_column);
setText(_column, QString::number(double(nanosecondsTime) * 1e-6, 'g', 9)); setText(_column, QString::number(double(nanosecondsTime) * 1e-6, 'g', 9));
} }
void EasyTreeWidgetItem::setTimeMs(int _column, const ::profiler::timestamp_t& _time, const QString& _prefix) void TreeWidgetItem::setTimeMs(int _column, const profiler::timestamp_t& _time, const QString& _prefix)
{ {
const ::profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time); const profiler::timestamp_t nanosecondsTime = PROF_NANOSECONDS(_time);
setData(_column, Qt::UserRole, (quint64)nanosecondsTime); setData(_column, Qt::UserRole, (quint64)nanosecondsTime);
setHasToolTip(_column); setHasToolTip(_column);
setText(_column, QString("%1%2").arg(_prefix).arg(double(nanosecondsTime) * 1e-6, 0, 'g', 9)); setText(_column, QString("%1%2").arg(_prefix).arg(double(nanosecondsTime) * 1e-6, 0, 'g', 9));
} }
void EasyTreeWidgetItem::setBackgroundColor(QRgb _color) void TreeWidgetItem::setBackgroundColor(QRgb _color)
{ {
m_customBGColor = _color; m_customBGColor = _color;
} }
void EasyTreeWidgetItem::setMain(bool _main) void TreeWidgetItem::setMain(bool _main)
{ {
m_bMain = _main; m_bMain = _main;
} }
void EasyTreeWidgetItem::collapseAll() void TreeWidgetItem::collapseAll()
{ {
for (int i = 0, childrenNumber = childCount(); i < childrenNumber; ++i) for (int i = 0, childrenNumber = childCount(); i < childrenNumber; ++i)
{ {
static_cast<EasyTreeWidgetItem*>(child(i))->collapseAll(); static_cast<TreeWidgetItem*>(child(i))->collapseAll();
} }
setExpanded(false); setExpanded(false);
@ -319,11 +319,11 @@ void EasyTreeWidgetItem::collapseAll()
guiBlock().expanded = false; guiBlock().expanded = false;
} }
void EasyTreeWidgetItem::expandAll() void TreeWidgetItem::expandAll()
{ {
for (int i = 0, childrenNumber = childCount(); i < childrenNumber; ++i) for (int i = 0, childrenNumber = childCount(); i < childrenNumber; ++i)
{ {
static_cast<EasyTreeWidgetItem*>(child(i))->expandAll(); static_cast<TreeWidgetItem*>(child(i))->expandAll();
} }
setExpanded(true); setExpanded(true);
@ -331,7 +331,7 @@ void EasyTreeWidgetItem::expandAll()
guiBlock().expanded = true; guiBlock().expanded = true;
} }
void EasyTreeWidgetItem::setBold(bool _bold) void TreeWidgetItem::setBold(bool _bold)
{ {
m_font.setBold(_bold); m_font.setBold(_bold);
} }
@ -375,7 +375,7 @@ void EasyItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti
{ {
painter->save(); painter->save();
painter->setBrush(Qt::NoBrush); painter->setBrush(Qt::NoBrush);
painter->setPen(::profiler_gui::SYSTEM_BORDER_COLOR); painter->setPen(profiler_gui::SYSTEM_BORDER_COLOR);
painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft); painter->drawLine(QPoint(0, bottomLeft.y()), bottomLeft);
painter->restore(); painter->restore();
} }
@ -414,7 +414,7 @@ void EasyItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& opti
// Draw color marker with block color // Draw color marker with block color
const auto brush = m_treeWidget->model()->data(index, Qt::UserRole + 1).value<QBrush>(); const auto brush = m_treeWidget->model()->data(index, Qt::UserRole + 1).value<QBrush>();
painter->setBrush(brush); painter->setBrush(brush);
painter->setPen(::profiler_gui::SYSTEM_BORDER_COLOR); painter->setPen(profiler_gui::SYSTEM_BORDER_COLOR);
painter->drawRect(QRect(option.rect.left(), option.rect.top() + 5, 16, option.rect.height() - 10)); painter->drawRect(QRect(option.rect.left(), option.rect.top() + 5, 16, option.rect.height() - 10));
// Draw line under tree indicator // Draw line under tree indicator

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyTreeWidgetItem * description : The file contains declaration of TreeWidgetItem
* : for displyaing EasyProfiler blocks tree. * : for displyaing EasyProfiler blocks tree.
* ----------------- : * ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h * change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h
@ -113,10 +113,10 @@ enum EasyColumnsIndexes
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyTreeWidgetItem : public QTreeWidgetItem class TreeWidgetItem : public QTreeWidgetItem
{ {
using Parent = QTreeWidgetItem; using Parent = QTreeWidgetItem;
using This = EasyTreeWidgetItem; using This = TreeWidgetItem;
QFont m_font; QFont m_font;
const ::profiler::block_index_t m_block; const ::profiler::block_index_t m_block;
@ -126,8 +126,8 @@ class EasyTreeWidgetItem : public QTreeWidgetItem
public: public:
explicit EasyTreeWidgetItem(const ::profiler::block_index_t _treeBlock = ::profiler_gui::numeric_max<decltype(m_block)>(), Parent* _parent = nullptr); explicit TreeWidgetItem(const ::profiler::block_index_t _treeBlock = ::profiler_gui::numeric_max<decltype(m_block)>(), Parent* _parent = nullptr);
virtual ~EasyTreeWidgetItem(); virtual ~TreeWidgetItem();
bool operator < (const Parent& _other) const override; bool operator < (const Parent& _other) const override;
QVariant data(int _column, int _role) const override; QVariant data(int _column, int _role) const override;
@ -162,7 +162,7 @@ private:
bool hasToolTip(int _column) const; bool hasToolTip(int _column) const;
void setHasToolTip(int _column); void setHasToolTip(int _column);
}; // END of class EasyTreeWidgetItem. }; // END of class TreeWidgetItem.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of EasyTreeWidgetLoader which aim is * description : The file contains implementation of TreeWidgetLoader which aim is
* : to load EasyProfiler blocks hierarchy in separate thread. * : to load EasyProfiler blocks hierarchy in separate thread.
* ----------------- : * ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h/.cpp * change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h/.cpp
@ -57,6 +57,7 @@
#include "tree_widget_loader.h" #include "tree_widget_loader.h"
#include "tree_widget_item.h" #include "tree_widget_item.h"
#include "globals.h" #include "globals.h"
#include <thread>
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
@ -77,46 +78,46 @@
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
EasyTreeWidgetLoader::EasyTreeWidgetLoader() TreeWidgetLoader::TreeWidgetLoader()
: m_bDone(ATOMIC_VAR_INIT(false)) : m_bDone(ATOMIC_VAR_INIT(false))
, m_bInterrupt(ATOMIC_VAR_INIT(false)) , m_bInterrupt(ATOMIC_VAR_INIT(false))
, m_progress(ATOMIC_VAR_INIT(0)) , m_progress(ATOMIC_VAR_INIT(0))
, m_mode(EasyTreeMode_Full) , m_mode(TreeMode::Full)
{ {
} }
EasyTreeWidgetLoader::~EasyTreeWidgetLoader() TreeWidgetLoader::~TreeWidgetLoader()
{ {
interrupt(true); interrupt(true);
} }
bool EasyTreeWidgetLoader::done() const bool TreeWidgetLoader::done() const
{ {
return m_bDone.load(); return m_bDone.load(std::memory_order_acquire);
} }
void EasyTreeWidgetLoader::setDone() void TreeWidgetLoader::setDone()
{ {
m_bDone.store(true); m_bDone.store(true, std::memory_order_release);
//m_progress.store(100); //m_progress.store(100);
} }
void EasyTreeWidgetLoader::setProgress(int _progress) void TreeWidgetLoader::setProgress(int _progress)
{ {
m_progress.store(_progress); m_progress.store(_progress, std::memory_order_release);
} }
bool EasyTreeWidgetLoader::interrupted() const bool TreeWidgetLoader::interrupted() const
{ {
return m_bInterrupt.load(); return m_bInterrupt.load(std::memory_order_acquire);
} }
int EasyTreeWidgetLoader::progress() const int TreeWidgetLoader::progress() const
{ {
return m_progress.load(); return m_progress.load(std::memory_order_acquire);
} }
void EasyTreeWidgetLoader::takeTopLevelItems(ThreadedItems& _output) void TreeWidgetLoader::takeTopLevelItems(ThreadedItems& _output)
{ {
if (done()) if (done())
{ {
@ -125,7 +126,7 @@ void EasyTreeWidgetLoader::takeTopLevelItems(ThreadedItems& _output)
} }
} }
void EasyTreeWidgetLoader::takeItems(Items& _output) void TreeWidgetLoader::takeItems(Items& _output)
{ {
if (done()) if (done())
{ {
@ -134,15 +135,11 @@ void EasyTreeWidgetLoader::takeItems(Items& _output)
} }
} }
void EasyTreeWidgetLoader::interrupt(bool _wait) void TreeWidgetLoader::interrupt(bool _wait)
{ {
m_bInterrupt.store(true); m_worker.dequeue();
if (m_thread.joinable()) m_bDone.store(false, std::memory_order_release);
m_thread.join(); m_progress.store(0, std::memory_order_release);
m_bInterrupt.store(false);
m_bDone.store(false);
m_progress.store(0);
if (!_wait) if (!_wait)
{ {
@ -170,27 +167,39 @@ void EasyTreeWidgetLoader::interrupt(bool _wait)
m_iditems.clear(); m_iditems.clear();
} }
void EasyTreeWidgetLoader::fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, EasyTreeMode _mode) void TreeWidgetLoader::fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, TreeMode _mode)
{ {
interrupt(); interrupt();
m_mode = _mode; m_mode = _mode;
m_thread = ::std::thread(&EasyTreeWidgetLoader::setTreeInternal1, this,
::std::ref(_beginTime), _blocksNumber, ::std::ref(_blocksTree), EASY_GLOBALS.add_zero_blocks_to_hierarchy, const auto zeroBlocks = EASY_GLOBALS.add_zero_blocks_to_hierarchy;
EASY_GLOBALS.use_decorated_thread_name, EASY_GLOBALS.hex_thread_id, EASY_GLOBALS.time_units); const auto decoratedNames = EASY_GLOBALS.use_decorated_thread_name;
const auto hexThreadIds = EASY_GLOBALS.hex_thread_id;
const auto timeUnits = EASY_GLOBALS.time_units;
m_worker.enqueue([this, &_beginTime, _blocksNumber, &_blocksTree, zeroBlocks, decoratedNames, hexThreadIds, timeUnits]
{
setTreeInternal1(_beginTime, _blocksNumber, _blocksTree, zeroBlocks, decoratedNames, hexThreadIds, timeUnits);
}, m_bInterrupt);
} }
void EasyTreeWidgetLoader::fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, EasyTreeMode _mode) void TreeWidgetLoader::fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, TreeMode _mode)
{ {
interrupt(); interrupt();
m_mode = _mode; m_mode = _mode;
m_thread = ::std::thread(&EasyTreeWidgetLoader::setTreeInternal2, this,
_beginTime, ::std::ref(_blocks), _left, _right, _strict, EASY_GLOBALS.add_zero_blocks_to_hierarchy, const auto zeroBlocks = EASY_GLOBALS.add_zero_blocks_to_hierarchy;
EASY_GLOBALS.use_decorated_thread_name, EASY_GLOBALS.hex_thread_id, EASY_GLOBALS.time_units); const auto decoratedNames = EASY_GLOBALS.use_decorated_thread_name;
const auto hexThreadIds = EASY_GLOBALS.hex_thread_id;
const auto timeUnits = EASY_GLOBALS.time_units;
m_worker.enqueue([this, _beginTime, &_blocks, _left, _right, _strict, zeroBlocks, decoratedNames, hexThreadIds, timeUnits]
{
setTreeInternal2(_beginTime, _blocks, _left, _right, _strict, zeroBlocks, decoratedNames, hexThreadIds, timeUnits);
}, m_bInterrupt);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void EasyTreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units) void TreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units)
{ {
m_items.reserve(_blocksNumber + _blocksTree.size()); // _blocksNumber does not include Thread root blocks m_items.reserve(_blocksNumber + _blocksTree.size()); // _blocksNumber does not include Thread root blocks
@ -218,7 +227,7 @@ void EasyTreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime,
break; break;
const auto& root = threadTree.second; const auto& root = threadTree.second;
auto item = new EasyTreeWidgetItem(); auto item = new TreeWidgetItem();
item->setText(COL_NAME, ::profiler_gui::decoratedThreadName(_decoratedThreadNames, root, u_thread, _hexThreadId)); item->setText(COL_NAME, ::profiler_gui::decoratedThreadName(_decoratedThreadNames, root, u_thread, _hexThreadId));
::profiler::timestamp_t duration = 0; ::profiler::timestamp_t duration = 0;
@ -270,7 +279,7 @@ void EasyTreeWidgetLoader::setTreeInternal1(::profiler::timestamp_t& _beginTime,
using BeginEndIndicesMap = ::std::unordered_map<::profiler::thread_id_t, ::profiler::block_index_t, using BeginEndIndicesMap = ::std::unordered_map<::profiler::thread_id_t, ::profiler::block_index_t,
::estd::hash<::profiler::thread_id_t> >; ::estd::hash<::profiler::thread_id_t> >;
void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _beginTime, void TreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _beginTime,
const ::profiler_gui::TreeBlocks& _blocks, const ::profiler_gui::TreeBlocks& _blocks,
::profiler::timestamp_t _left, ::profiler::timestamp_t _left,
::profiler::timestamp_t _right, ::profiler::timestamp_t _right,
@ -289,7 +298,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
BeginEndIndicesMap beginEndMap; BeginEndIndicesMap beginEndMap;
RootsMap threadsMap; RootsMap threadsMap;
auto const setTree = (m_mode == EasyTreeMode_Full) ? &EasyTreeWidgetLoader::setTreeInternal : &EasyTreeWidgetLoader::setTreeInternalPlain; auto const setTree = (m_mode == TreeMode::Full) ? &TreeWidgetLoader::setTreeInternal : &TreeWidgetLoader::setTreeInternalPlain;
const auto u_thread = ::profiler_gui::toUnicode("thread"); const auto u_thread = ::profiler_gui::toUnicode("thread");
int i = 0, total = static_cast<int>(_blocks.size()); int i = 0, total = static_cast<int>(_blocks.size());
@ -309,7 +318,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
} }
::profiler::timestamp_t duration = 0; ::profiler::timestamp_t duration = 0;
EasyTreeWidgetItem* thread_item = nullptr; TreeWidgetItem* thread_item = nullptr;
::profiler::block_index_t& firstCswitch = beginEndMap[block.root->thread_id]; ::profiler::block_index_t& firstCswitch = beginEndMap[block.root->thread_id];
auto thread_item_it = threadsMap.find(block.root->thread_id); auto thread_item_it = threadsMap.find(block.root->thread_id);
if (thread_item_it != threadsMap.end()) if (thread_item_it != threadsMap.end())
@ -318,7 +327,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
} }
else else
{ {
thread_item = new EasyTreeWidgetItem(); thread_item = new TreeWidgetItem();
thread_item->setText(COL_NAME, ::profiler_gui::decoratedThreadName(_decoratedThreadNames, *block.root, u_thread, _hexThreadId)); thread_item->setText(COL_NAME, ::profiler_gui::decoratedThreadName(_decoratedThreadNames, *block.root, u_thread, _hexThreadId));
if (!block.root->children.empty()) if (!block.root->children.empty())
@ -376,7 +385,7 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
} }
} }
auto item = new EasyTreeWidgetItem(block.tree, thread_item); auto item = new TreeWidgetItem(block.tree, thread_item);
duration = endTime - startTime; duration = endTime - startTime;
auto name = *gui_block.tree.node->name() != 0 ? gui_block.tree.node->name() : easyDescriptor(gui_block.tree.node->id()).name(); auto name = *gui_block.tree.node->name() != 0 ? gui_block.tree.node->name() : easyDescriptor(gui_block.tree.node->id()).name();
@ -538,12 +547,12 @@ void EasyTreeWidgetLoader::setTreeInternal2(const ::profiler::timestamp_t& _begi
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _threadRoot, size_t TreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _threadRoot,
::profiler::block_index_t _firstCswitch, ::profiler::block_index_t _firstCswitch,
const ::profiler::timestamp_t& _beginTime, const ::profiler::timestamp_t& _beginTime,
const ::profiler::BlocksTree::children_t& _children, const ::profiler::BlocksTree::children_t& _children,
EasyTreeWidgetItem* _parent, TreeWidgetItem* _parent,
EasyTreeWidgetItem* _frame, TreeWidgetItem* _frame,
::profiler::timestamp_t _left, ::profiler::timestamp_t _left,
::profiler::timestamp_t _right, ::profiler::timestamp_t _right,
bool _strict, bool _strict,
@ -551,7 +560,7 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
bool _addZeroBlocks, bool _addZeroBlocks,
::profiler_gui::TimeUnits _units) ::profiler_gui::TimeUnits _units)
{ {
auto const setTree = m_mode == EasyTreeMode_Full ? &EasyTreeWidgetLoader::setTreeInternal : &EasyTreeWidgetLoader::setTreeInternalPlain; auto const setTree = m_mode == TreeMode::Full ? &TreeWidgetLoader::setTreeInternal : &TreeWidgetLoader::setTreeInternalPlain;
size_t total_items = 0; size_t total_items = 0;
for (auto child_index : _children) for (auto child_index : _children)
@ -599,7 +608,7 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
} }
} }
auto item = new EasyTreeWidgetItem(child_index, _parent); auto item = new TreeWidgetItem(child_index, _parent);
auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name(); auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name();
item->setText(COL_NAME, ::profiler_gui::toUnicode(name)); item->setText(COL_NAME, ::profiler_gui::toUnicode(name));
@ -771,7 +780,7 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
::profiler::timestamp_t EasyTreeWidgetLoader::calculateChildrenDurationRecursive(const ::profiler::BlocksTree::children_t& _children, ::profiler::block_id_t _id) ::profiler::timestamp_t TreeWidgetLoader::calculateChildrenDurationRecursive(const ::profiler::BlocksTree::children_t& _children, ::profiler::block_id_t _id)
{ {
::profiler::timestamp_t total_duration = 0; ::profiler::timestamp_t total_duration = 0;
@ -789,12 +798,12 @@ size_t EasyTreeWidgetLoader::setTreeInternal(const ::profiler::BlocksTreeRoot& _
return total_duration; return total_duration;
} }
size_t EasyTreeWidgetLoader::setTreeInternalPlain(const ::profiler::BlocksTreeRoot& _threadRoot, size_t TreeWidgetLoader::setTreeInternalPlain(const ::profiler::BlocksTreeRoot& _threadRoot,
::profiler::block_index_t _firstCswitch, ::profiler::block_index_t _firstCswitch,
const ::profiler::timestamp_t& _beginTime, const ::profiler::timestamp_t& _beginTime,
const ::profiler::BlocksTree::children_t& _children, const ::profiler::BlocksTree::children_t& _children,
EasyTreeWidgetItem*, TreeWidgetItem*,
EasyTreeWidgetItem* _frame, TreeWidgetItem* _frame,
::profiler::timestamp_t _left, ::profiler::timestamp_t _left,
::profiler::timestamp_t _right, ::profiler::timestamp_t _right,
bool _strict, bool _strict,
@ -915,7 +924,7 @@ size_t EasyTreeWidgetLoader::setTreeInternalPlain(const ::profiler::BlocksTreeRo
} }
} }
auto item = new EasyTreeWidgetItem(child_index, _frame); auto item = new TreeWidgetItem(child_index, _frame);
auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name(); auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name();
item->setText(COL_NAME, ::profiler_gui::toUnicode(name)); item->setText(COL_NAME, ::profiler_gui::toUnicode(name));

View File

@ -5,7 +5,7 @@
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of EasyTreeWidgetLoader which aim is * description : The file contains declaration of TreeWidgetLoader which aim is
* : to load EasyProfiler blocks hierarchy in separate thread. * : to load EasyProfiler blocks hierarchy in separate thread.
* ----------------- : * ----------------- :
* change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h/.cpp * change log : * 2016/08/18 Victor Zarubkin: moved sources from blocks_tree_widget.h/.cpp
@ -59,50 +59,50 @@
#include <stdlib.h> #include <stdlib.h>
#include <vector> #include <vector>
#include <thread>
#include <atomic> #include <atomic>
#include <easy/reader.h> #include <easy/reader.h>
#include "common_types.h" #include "common_types.h"
#include "thread_pool_task.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyTreeWidgetItem; class TreeWidgetItem;
#ifndef EASY_TREE_WIDGET__USE_VECTOR #ifndef EASY_TREE_WIDGET__USE_VECTOR
using Items = ::std::unordered_map<::profiler::block_index_t, EasyTreeWidgetItem*, ::estd::hash<::profiler::block_index_t> >; using Items = ::std::unordered_map<profiler::block_index_t, TreeWidgetItem*, ::estd::hash<profiler::block_index_t> >;
#else #else
using Items = ::std::vector<EasyTreeWidgetItem*>; using Items = ::std::vector<TreeWidgetItem*>;
#endif #endif
using ThreadedItems = ::std::vector<::std::pair<::profiler::thread_id_t, EasyTreeWidgetItem*> >; using ThreadedItems = ::std::vector<::std::pair<profiler::thread_id_t, TreeWidgetItem*> >;
using RootsMap = ::std::unordered_map<::profiler::thread_id_t, EasyTreeWidgetItem*, ::estd::hash<::profiler::thread_id_t> >; using RootsMap = ::std::unordered_map<profiler::thread_id_t, TreeWidgetItem*, ::estd::hash<profiler::thread_id_t> >;
using IdItems = ::std::unordered_map<::profiler::block_id_t, EasyTreeWidgetItem*, ::estd::hash<::profiler::block_index_t> >; using IdItems = ::std::unordered_map<profiler::block_id_t, TreeWidgetItem*, ::estd::hash<profiler::block_index_t> >;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
enum EasyTreeMode : uint8_t enum class TreeMode : uint8_t
{ {
EasyTreeMode_Full, Full,
EasyTreeMode_Plain Plain
}; };
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class EasyTreeWidgetLoader Q_DECL_FINAL class TreeWidgetLoader Q_DECL_FINAL
{ {
ThreadedItems m_topLevelItems; ///< ThreadedItems m_topLevelItems; ///<
Items m_items; ///< Items m_items; ///<
IdItems m_iditems; ///< IdItems m_iditems; ///<
::std::thread m_thread; ///< ThreadPoolTask m_worker; ///<
::std::atomic_bool m_bDone; ///< std::atomic_bool m_bDone; ///<
::std::atomic_bool m_bInterrupt; ///< std::atomic_bool m_bInterrupt; ///<
::std::atomic<int> m_progress; ///< std::atomic<int> m_progress; ///<
EasyTreeMode m_mode; ///< TreeMode m_mode; ///<
public: public:
EasyTreeWidgetLoader(); TreeWidgetLoader();
~EasyTreeWidgetLoader(); ~TreeWidgetLoader();
int progress() const; int progress() const;
bool done() const; bool done() const;
@ -111,8 +111,8 @@ public:
void takeItems(Items& _output); void takeItems(Items& _output);
void interrupt(bool _wait = false); void interrupt(bool _wait = false);
void fillTree(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, EasyTreeMode _mode); void fillTree(profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const profiler::thread_blocks_tree_t& _blocksTree, TreeMode _mode);
void fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _beginTime, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, EasyTreeMode _mode); void fillTreeBlocks(const::profiler_gui::TreeBlocks& _blocks, profiler::timestamp_t _beginTime, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, TreeMode _mode);
private: private:
@ -120,14 +120,14 @@ private:
void setDone(); void setDone();
void setProgress(int _progress); void setProgress(int _progress);
void setTreeInternal1(::profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const ::profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units); void setTreeInternal1(profiler::timestamp_t& _beginTime, const unsigned int _blocksNumber, const profiler::thread_blocks_tree_t& _blocksTree, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units);
void setTreeInternal2(const ::profiler::timestamp_t& _beginTime, const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units); void setTreeInternal2(const profiler::timestamp_t& _beginTime, const ::profiler_gui::TreeBlocks& _blocks, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, bool _addZeroBlocks, bool _decoratedThreadNames, bool _hexThreadId, ::profiler_gui::TimeUnits _units);
size_t setTreeInternal(const ::profiler::BlocksTreeRoot& _threadRoot, ::profiler::block_index_t _firstCswitch, const ::profiler::timestamp_t& _beginTime, const ::profiler::BlocksTree::children_t& _children, EasyTreeWidgetItem* _parent, EasyTreeWidgetItem* _frame, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, ::profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units); size_t setTreeInternal(const profiler::BlocksTreeRoot& _threadRoot, profiler::block_index_t _firstCswitch, const profiler::timestamp_t& _beginTime, const profiler::BlocksTree::children_t& _children, TreeWidgetItem* _parent, TreeWidgetItem* _frame, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units);
size_t setTreeInternalPlain(const ::profiler::BlocksTreeRoot& _threadRoot, ::profiler::block_index_t _firstCswitch, const ::profiler::timestamp_t& _beginTime, const ::profiler::BlocksTree::children_t& _children, EasyTreeWidgetItem* _parent, EasyTreeWidgetItem* _frame, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, ::profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units); size_t setTreeInternalPlain(const profiler::BlocksTreeRoot& _threadRoot, profiler::block_index_t _firstCswitch, const profiler::timestamp_t& _beginTime, const profiler::BlocksTree::children_t& _children, TreeWidgetItem* _parent, TreeWidgetItem* _frame, profiler::timestamp_t _left, profiler::timestamp_t _right, bool _strict, profiler::timestamp_t& _duration, bool _addZeroBlocks, ::profiler_gui::TimeUnits _units);
::profiler::timestamp_t calculateChildrenDurationRecursive(const ::profiler::BlocksTree::children_t& _children, ::profiler::block_id_t _id); profiler::timestamp_t calculateChildrenDurationRecursive(const profiler::BlocksTree::children_t& _children, profiler::block_id_t _id);
}; // END of class EasyTreeWidgetLoader. }; // END of class TreeWidgetLoader.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -5,17 +5,17 @@
#include "treeview_first_column_delegate.h" #include "treeview_first_column_delegate.h"
#include "globals.h" #include "globals.h"
EasyTreeViewFirstColumnItemDelegate::EasyTreeViewFirstColumnItemDelegate(QObject* parent) : QStyledItemDelegate(parent) TreeViewFirstColumnItemDelegate::TreeViewFirstColumnItemDelegate(QObject* parent) : QStyledItemDelegate(parent)
{ {
} }
EasyTreeViewFirstColumnItemDelegate::~EasyTreeViewFirstColumnItemDelegate() TreeViewFirstColumnItemDelegate::~TreeViewFirstColumnItemDelegate()
{ {
} }
void EasyTreeViewFirstColumnItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const void TreeViewFirstColumnItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{ {
// Draw item as usual // Draw item as usual
QStyledItemDelegate::paint(painter, option, index); QStyledItemDelegate::paint(painter, option, index);

View File

@ -8,16 +8,16 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
class EasyTreeViewFirstColumnItemDelegate : public QStyledItemDelegate class TreeViewFirstColumnItemDelegate : public QStyledItemDelegate
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EasyTreeViewFirstColumnItemDelegate(QObject* parent = nullptr); explicit TreeViewFirstColumnItemDelegate(QObject* parent = nullptr);
~EasyTreeViewFirstColumnItemDelegate() override; ~TreeViewFirstColumnItemDelegate() override;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
}; // END of class EasyTreeViewFirstColumnItemDelegate. }; // END of class TreeViewFirstColumnItemDelegate.
#endif // EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H #endif // EASY_PROFILER_GUI_TREEVIEW_FIRST_COLUMN_DELEGATE_H

View File

@ -175,7 +175,7 @@ void modellingThread(){
localSleep(1200000); localSleep(1200000);
++step; ++step;
EASY_VALUE("step", step, profiler::colors::Gold); EASY_VALUE("step", sin((double)step), profiler::colors::Gold, EASY_VIN(step));
if (step > 10000000) if (step > 10000000)
step = 0; step = 0;