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

#0 [UI] refactoring

This commit is contained in:
Victor Zarubkin 2018-05-07 21:58:37 +03:00
parent 8c90ee7ef5
commit 91724bfe20
17 changed files with 206 additions and 199 deletions

View File

@ -25,25 +25,25 @@ if (Qt5Widgets_FOUND)
common_types.h common_types.h
descriptors_tree_widget.h descriptors_tree_widget.h
descriptors_tree_widget.cpp descriptors_tree_widget.cpp
easy_chronometer_item.h fps_widget.h
easy_chronometer_item.cpp fps_widget.cpp
easy_frame_rate_viewer.h
easy_frame_rate_viewer.cpp
easy_graphics_item.h
easy_graphics_item.cpp
easy_graphics_scrollbar.h
easy_graphics_scrollbar.cpp
easy_qtimer.h
easy_qtimer.cpp
globals.h globals.h
globals.cpp globals.cpp
globals_qobjects.cpp globals_qobjects.cpp
graphics_block_item.h
graphics_block_item.cpp
graphics_image_item.h graphics_image_item.h
graphics_image_item.cpp graphics_image_item.cpp
graphics_ruler_item.h
graphics_ruler_item.cpp
graphics_scrollbar.h
graphics_scrollbar.cpp
graphics_slider_area.h graphics_slider_area.h
graphics_slider_area.cpp graphics_slider_area.cpp
main_window.h main_window.h
main_window.cpp main_window.cpp
timer.h
timer.cpp
thread_pool.h thread_pool.h
thread_pool.cpp thread_pool.cpp
thread_pool_task.h thread_pool_task.h

View File

@ -78,7 +78,7 @@
#include <cmath> #include <cmath>
#include "arbitrary_value_inspector.h" #include "arbitrary_value_inspector.h"
#include "globals.h" #include "globals.h"
#include "easy_complexity_calculator.h" #include "complexity_calculator.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -19,7 +19,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 BlocksGraphicsItem and GraphicsRulerItem to separate files. * : * 2016/09/15 Victor Zarubkin: Moved sources of GraphicsBlockItem and GraphicsRulerItem to separate files.
* : * :
* : * * : *
* ----------------- : * ----------------- :
@ -79,9 +79,9 @@
#include <QGraphicsDropShadowEffect> #include <QGraphicsDropShadowEffect>
#include <QSettings> #include <QSettings>
#include "blocks_graphics_view.h" #include "blocks_graphics_view.h"
#include "easy_graphics_item.h" #include "graphics_block_item.h"
#include "easy_chronometer_item.h" #include "graphics_ruler_item.h"
#include "easy_graphics_scrollbar.h" #include "graphics_scrollbar.h"
#include "arbitrary_value_tooltip.h" #include "arbitrary_value_tooltip.h"
#include "globals.h" #include "globals.h"
@ -349,15 +349,16 @@ qreal BlocksGraphicsView::chronoTimeAux() const
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
GraphicsRulerItem* BlocksGraphicsView::createChronometer(bool _main) GraphicsRulerItem* BlocksGraphicsView::createRuler(bool _main)
{ {
auto chronoItem = new GraphicsRulerItem(_main); auto ruler = new GraphicsRulerItem(_main);
chronoItem->setColor(_main ? ::profiler_gui::CHRONOMETER_COLOR : ::profiler_gui::CHRONOMETER_COLOR2);
chronoItem->setBoundingRect(sceneRect());
chronoItem->hide();
scene()->addItem(chronoItem);
return chronoItem; ruler->setColor(_main ? ::profiler_gui::CHRONOMETER_COLOR : ::profiler_gui::CHRONOMETER_COLOR2);
ruler->setBoundingRect(sceneRect());
ruler->hide();
scene()->addItem(ruler);
return ruler;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -517,7 +518,7 @@ void BlocksGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocks
// Filling scene with items // Filling scene with items
m_items.reserve(_blocksTree.size()); m_items.reserve(_blocksTree.size());
qreal y = EASY_GLOBALS.size.timeline_height; qreal y = EASY_GLOBALS.size.timeline_height;
const BlocksGraphicsItem *longestItem = nullptr, *mainThreadItem = nullptr; const GraphicsBlockItem *longestItem = nullptr, *mainThreadItem = nullptr;
for (const ::profiler::BlocksTreeRoot& t : sorted_roots) for (const ::profiler::BlocksTreeRoot& t : sorted_roots)
{ {
if (m_items.size() == 0xff) if (m_items.size() == 0xff)
@ -534,7 +535,7 @@ void BlocksGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocks
else if (!t.sync.empty()) else if (!t.sync.empty())
x = time2position(easyBlocksTree(t.sync.front()).node->begin()); x = time2position(easyBlocksTree(t.sync.front()).node->begin());
auto item = new BlocksGraphicsItem(static_cast<uint8_t>(m_items.size()), t); auto item = new GraphicsBlockItem(static_cast<uint8_t>(m_items.size()), t);
if (t.depth) if (t.depth)
item->setLevels(t.depth); item->setLevels(t.depth);
item->setPos(0, y); item->setPos(0, y);
@ -580,8 +581,8 @@ void BlocksGraphicsView::setTree(const ::profiler::thread_blocks_tree_t& _blocks
// Create new chronometer item (previous item was destroyed by scene on scene()->clear()). // Create new chronometer item (previous item was destroyed by scene on scene()->clear()).
// It will be shown on mouse right button click. // It will be shown on mouse right button click.
m_rulerItem = createChronometer(false); m_rulerItem = createRuler(false);
m_selectionItem = createChronometer(true); m_selectionItem = createRuler(true);
bgItem->setBoundingRect(0, 0, m_sceneWidth, y); bgItem->setBoundingRect(0, 0, m_sceneWidth, y);
auto indicator = new TimelineIndicatorItem(); auto indicator = new TimelineIndicatorItem();
@ -634,7 +635,7 @@ bool BlocksGraphicsView::getSelectionRegionForSaving(profiler::timestamp_t& _beg
return true; return true;
} }
qreal BlocksGraphicsView::setTree(BlocksGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level) qreal BlocksGraphicsView::setTree(GraphicsBlockItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level)
{ {
if (_children.empty()) if (_children.empty())
{ {
@ -747,7 +748,7 @@ qreal BlocksGraphicsView::setTree(BlocksGraphicsItem* _item, const ::profiler::B
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void BlocksGraphicsView::setScrollbar(BlocksGraphicsScrollbar* _scrollbar) void BlocksGraphicsView::setScrollbar(GraphicsScrollbar* _scrollbar)
{ {
disconnect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::chartSliderChanged, this, &This::onGraphicsScrollbarValueChange); disconnect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::chartSliderChanged, this, &This::onGraphicsScrollbarValueChange);
disconnect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::chartWheeled, this, &This::onGraphicsScrollbarWheel); disconnect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::chartWheeled, this, &This::onGraphicsScrollbarWheel);
@ -885,7 +886,7 @@ void BlocksGraphicsView::onGraphicsScrollbarWheel(qreal _scenePos, int _wheelDel
onWheel(_scenePos, _wheelDelta); onWheel(_scenePos, _wheelDelta);
} }
void BlocksGraphicsView::scrollTo(const BlocksGraphicsItem* _item) void BlocksGraphicsView::scrollTo(const GraphicsBlockItem* _item)
{ {
m_bUpdatingRect = true; m_bUpdatingRect = true;
auto vbar = verticalScrollBar(); auto vbar = verticalScrollBar();
@ -2225,7 +2226,7 @@ void BlocksGraphicsView::onRefreshRequired()
DiagramWidget::DiagramWidget(QWidget* _parent) DiagramWidget::DiagramWidget(QWidget* _parent)
: QWidget(_parent) : QWidget(_parent)
, m_splitter(new QSplitter(Qt::Vertical, this)) , m_splitter(new QSplitter(Qt::Vertical, this))
, m_scrollbar(new BlocksGraphicsScrollbar(px(85) + 2 + (EASY_GLOBALS.size.font_height << 1), this)) , m_scrollbar(new GraphicsScrollbar(px(85) + 2 + (EASY_GLOBALS.size.font_height << 1), this))
, m_view(new BlocksGraphicsView(this)) , m_view(new BlocksGraphicsView(this))
, m_threadNamesWidget(new ThreadNamesWidget(m_view, m_scrollbar->height(), this)) , m_threadNamesWidget(new ThreadNamesWidget(m_view, m_scrollbar->height(), this))
{ {
@ -2545,7 +2546,7 @@ void ThreadNamesWidget::onIdleTimeout()
const auto overlap = EASY_GLOBALS.size.threads_row_spacing >> 1; const auto overlap = EASY_GLOBALS.size.threads_row_spacing >> 1;
BlocksGraphicsItem* intersectingItem = nullptr; GraphicsBlockItem* intersectingItem = nullptr;
for (auto item : items) for (auto item : items)
{ {
auto br = item->boundingRect(); auto br = item->boundingRect();

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 BlocksGraphicsItem and GraphicsRulerItem to separate files. * : * 2016/09/15 Victor Zarubkin: Moved sources of GraphicsBlockItem and GraphicsRulerItem to separate files.
* : * :
* : * * : *
* ----------------- : * ----------------- :
@ -82,8 +82,8 @@
class QGraphicsProxyWidget; class QGraphicsProxyWidget;
class BlocksGraphicsView; class BlocksGraphicsView;
class BlocksGraphicsItem; class GraphicsBlockItem;
class BlocksGraphicsScrollbar; class GraphicsScrollbar;
class GraphicsRulerItem; class GraphicsRulerItem;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -123,10 +123,10 @@ private:
using Parent = QGraphicsView; using Parent = QGraphicsView;
using This = BlocksGraphicsView; using This = BlocksGraphicsView;
using Items = ::std::vector<BlocksGraphicsItem*>; using Items = ::std::vector<GraphicsBlockItem*>;
//using Keys = ::std::unordered_set<int, ::estd::hash<int> >; //using Keys = ::std::unordered_set<int, ::estd::hash<int> >;
Items m_items; ///< Array of all BlocksGraphicsItem items Items m_items; ///< Array of all GraphicsBlockItem 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 (GraphicsRulerItem) ::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
@ -142,7 +142,7 @@ 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
BlocksGraphicsScrollbar* m_pScrollbar; ///< Pointer to the graphics scrollbar widget GraphicsScrollbar* m_pScrollbar; ///< Pointer to the graphics scrollbar 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. 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.
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. 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.
QWidget* m_popupWidget; ///< QWidget* m_popupWidget; ///<
@ -183,7 +183,7 @@ public:
qreal chronoTime() const; qreal chronoTime() const;
qreal chronoTimeAux() const; qreal chronoTimeAux() const;
void setScrollbar(BlocksGraphicsScrollbar* _scrollbar); void setScrollbar(GraphicsScrollbar* _scrollbar);
void clear(); void clear();
void setTree(const ::profiler::thread_blocks_tree_t& _blocksTree); void setTree(const ::profiler::thread_blocks_tree_t& _blocksTree);
@ -217,16 +217,16 @@ private:
void removePopup(); void removePopup();
bool needToIgnoreMouseEvent() const; bool needToIgnoreMouseEvent() const;
GraphicsRulerItem* createChronometer(bool _main = true); GraphicsRulerItem* createRuler(bool _main = true);
bool moveChrono(GraphicsRulerItem* _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 BlocksGraphicsItem* _item); void scrollTo(const GraphicsBlockItem* _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(BlocksGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level); qreal setTree(GraphicsBlockItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level);
void addSelectionToHierarchy(); void addSelectionToHierarchy();
@ -348,7 +348,7 @@ class DiagramWidget : public QWidget
private: private:
class QSplitter* m_splitter; class QSplitter* m_splitter;
BlocksGraphicsScrollbar* m_scrollbar; GraphicsScrollbar* m_scrollbar;
BlocksGraphicsView* m_view; BlocksGraphicsView* m_view;
ThreadNamesWidget* m_threadNamesWidget; ThreadNamesWidget* m_threadNamesWidget;

View File

@ -40,14 +40,14 @@ The Apache License, Version 2.0 (the "License");
**/ **/
#ifndef EASY_COMPLEXITY_CALCULATOR_H #ifndef COMPLEXITY_CALCULATOR_H
#define EASY_COMPLEXITY_CALCULATOR_H #define COMPLEXITY_CALCULATOR_H
#include <map>
#include <vector>
#include <functional>
#include <cmath> #include <cmath>
#include <functional>
#include <map>
#include <numeric> #include <numeric>
#include <vector>
enum class ComplexityType : uint8_t enum class ComplexityType : uint8_t
{ {
@ -63,64 +63,78 @@ enum class ComplexityType : uint8_t
}; };
template<class TValue> template<class TValue>
TValue getAverage(const std::vector<TValue>& derivatives) { TValue getAverage(const std::vector<TValue>& derivatives)
TValue result = std::accumulate(derivatives.begin(), derivatives.end(), TValue(0.0), [](TValue a, TValue b){ {
if(std::isnormal(b)) { TValue result = std::accumulate(derivatives.begin(), derivatives.end(), TValue(0.0), [](TValue a, TValue b)
{
if (std::isnormal(b))
return a + b; return a + b;
}
return a; return a;
}); });
return result / TValue(derivatives.size()); return result / TValue(derivatives.size());
} }
template<class TKey, class TValue> template<class TKey, class TValue>
std::vector<TValue> calculateDerivatives(const std::map<TKey, TValue>& input_array) { std::vector<TValue> calculateDerivatives(const std::map<TKey, TValue>& input_array)
{
std::vector<TValue> result; std::vector<TValue> result;
for(auto it = input_array.cbegin(), next_it = input_array.cbegin()++; next_it != input_array.cend();it = next_it, ++next_it) {
auto x0 = it->first;
auto x1 = next_it->first;
auto y0 = it->second; for (auto it = input_array.cbegin(), next_it = input_array.cbegin()++; next_it != input_array.cend(); it = next_it, ++next_it)
auto y1 = next_it->second; {
const auto x0 = it->first;
const auto x1 = next_it->first;
result.push_back((y1-y0)/(x1-x0)); const auto y0 = it->second;
const auto y1 = next_it->second;
result.push_back((y1 - y0) / (x1 - x0));
} }
return result; return result;
} }
template<class TKey, class TValue> template<class TKey, class TValue>
std::map<TValue, TValue> getLogarithmicChart(const std::map<TKey, std::vector<TValue> >& input) { std::map<TValue, TValue> getLogarithmicChart(const std::map<TKey, std::vector<TValue> >& input)
{
std::map<TValue, TValue> result; std::map<TValue, TValue> result;
for(auto it: input) {
for (auto it : input)
{
result[static_cast<TValue>(std::log2(it.first))] = std::log2(getAverage(it.second)); result[static_cast<TValue>(std::log2(it.first))] = std::log2(getAverage(it.second));
} }
return result; return result;
} }
template <class TKey, class TValue> template <class TKey, class TValue>
ComplexityType estimateComplexity(const std::map<TKey, std::vector<TValue> >& input) { ComplexityType estimateComplexity(const std::map<TKey, std::vector<TValue> >& input)
auto average = getAverage(calculateDerivatives(getLogarithmicChart(input))); {
const auto average = getAverage(calculateDerivatives(getLogarithmicChart(input)));
const double estimate_angle = std::atan(double(average)) * 57.3;
double estimate_angle = std::atan(double(average))*57.3; if (estimate_angle < 1)
if(estimate_angle < 1.0) {
return ComplexityType::Constant; return ComplexityType::Constant;
}else if (estimate_angle < 10.0) {
return ComplexityType::Logarithmic;
}else if (estimate_angle < 30.0) {
return ComplexityType::Linear;
}else if (estimate_angle < 50.0) {
return ComplexityType::Quasilinear;
}else if (estimate_angle < 65.0) {
return ComplexityType::Quadratic;
}else if (estimate_angle < 70.0) {
return ComplexityType::Cubic;
}else if (estimate_angle < 85.0) {
return ComplexityType::Exponential;
}else{
return ComplexityType::Factorial;
}
return ComplexityType::Unknown; if (estimate_angle < 10)
return ComplexityType::Logarithmic;
if (estimate_angle < 30)
return ComplexityType::Linear;
if (estimate_angle < 50)
return ComplexityType::Quasilinear;
if (estimate_angle < 65)
return ComplexityType::Quadratic;
if (estimate_angle < 70)
return ComplexityType::Cubic;
if (estimate_angle < 85)
return ComplexityType::Exponential;
return ComplexityType::Factorial;
} }
#endif #endif // COMPLEXITY_CALCULATOR_H

View File

@ -1,11 +1,11 @@
/************************************************************************ /************************************************************************
* file name : easy_frame_rate_viewer.cpp * file name : fps_widget.cpp
* ----------------- : * ----------------- :
* creation time : 2017/04/02 * creation time : 2017/04/02
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : This file contains implementation of FpsViewerWidget widget. * description : This file contains implementation of FpsWidget widget.
* ----------------- : * ----------------- :
* change log : * 2017/04/02 Victor Zarubkin: Initial commit. * change log : * 2017/04/02 Victor Zarubkin: Initial commit.
* : * :
@ -57,7 +57,7 @@
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
#include <QAction> #include <QAction>
#include "easy_frame_rate_viewer.h" #include "fps_widget.h"
#include "globals.h" #include "globals.h"
const int INTERVAL_WIDTH = 20; const int INTERVAL_WIDTH = 20;
@ -246,7 +246,7 @@ void FpsGraphicsItem::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
FpsViewerWidget::FpsViewerWidget(QWidget* _parent) : Parent(_parent), m_fpsItem(nullptr) FpsWidget::FpsWidget(QWidget* _parent) : Parent(_parent), m_fpsItem(nullptr)
{ {
setCacheMode(QGraphicsView::CacheNone); setCacheMode(QGraphicsView::CacheNone);
//setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); //setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
@ -277,24 +277,24 @@ FpsViewerWidget::FpsViewerWidget(QWidget* _parent) : Parent(_parent), m_fpsItem(
}); });
} }
FpsViewerWidget::~FpsViewerWidget() FpsWidget::~FpsWidget()
{ {
} }
void FpsViewerWidget::clear() void FpsWidget::clear()
{ {
m_fpsItem->clear(); m_fpsItem->clear();
scene()->update(); scene()->update();
} }
void FpsViewerWidget::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime) void FpsWidget::addPoint(uint32_t _maxFrameTime, uint32_t _avgFrameTime)
{ {
m_fpsItem->addPoint(_maxFrameTime, _avgFrameTime); m_fpsItem->addPoint(_maxFrameTime, _avgFrameTime);
scene()->update(); scene()->update();
} }
void FpsViewerWidget::resizeEvent(QResizeEvent* _event) void FpsWidget::resizeEvent(QResizeEvent* _event)
{ {
Parent::resizeEvent(_event); Parent::resizeEvent(_event);
@ -305,21 +305,21 @@ void FpsViewerWidget::resizeEvent(QResizeEvent* _event)
scene()->update(); scene()->update();
} }
void FpsViewerWidget::hideEvent(QHideEvent* _event) void FpsWidget::hideEvent(QHideEvent* _event)
{ {
Parent::hideEvent(_event); Parent::hideEvent(_event);
EASY_GLOBALS.fps_enabled = isVisible(); EASY_GLOBALS.fps_enabled = isVisible();
clear(); clear();
} }
void FpsViewerWidget::showEvent(QShowEvent* _event) void FpsWidget::showEvent(QShowEvent* _event)
{ {
Parent::showEvent(_event); Parent::showEvent(_event);
EASY_GLOBALS.fps_enabled = isVisible(); EASY_GLOBALS.fps_enabled = isVisible();
clear(); clear();
} }
void FpsViewerWidget::contextMenuEvent(QContextMenuEvent* _event) void FpsWidget::contextMenuEvent(QContextMenuEvent* _event)
{ {
QMenu menu; QMenu menu;
QAction* action = nullptr; QAction* action = nullptr;

View File

@ -1,11 +1,11 @@
/************************************************************************ /************************************************************************
* file name : easy_frame_rate_viewer.cpp * file name : fps_widget.cpp
* ----------------- : * ----------------- :
* creation time : 2017/04/02 * creation time : 2017/04/02
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : This file contains declaration of FpsViewerWidget widget. * description : This file contains declaration of FpsWidget widget.
* ----------------- : * ----------------- :
* change log : * 2017/04/02 Victor Zarubkin: Initial commit. * change log : * 2017/04/02 Victor Zarubkin: Initial commit.
* : * :
@ -52,16 +52,16 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#ifndef EASY__FRAME_RATE_VIEWER__H #ifndef FPS_WIDGET_H
#define EASY__FRAME_RATE_VIEWER__H #define FPS_WIDGET_H
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QTimer>
#include <vector>
#include <deque> #include <deque>
#include <utility> #include <utility>
#include <stdint.h> #include <stdint.h>
#include <vector>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QTimer>
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -93,21 +93,21 @@ public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class FpsViewerWidget : public QGraphicsView class FpsWidget : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
private: private:
using Parent = QGraphicsView; using Parent = QGraphicsView;
using This = FpsViewerWidget; using This = FpsWidget;
FpsGraphicsItem* m_fpsItem; FpsGraphicsItem* m_fpsItem;
public: public:
explicit FpsViewerWidget(QWidget* _parent = nullptr); explicit FpsWidget(QWidget* _parent = nullptr);
~FpsViewerWidget() override; ~FpsWidget() override;
void resizeEvent(QResizeEvent* _event) override; void resizeEvent(QResizeEvent* _event) override;
void hideEvent(QHideEvent* _event) override; void hideEvent(QHideEvent* _event) override;
@ -120,8 +120,8 @@ 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 FpsViewerWidget. }; // END of class FpsWidget.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#endif // EASY__FRAME_RATE_VIEWER__H #endif // FPS_WIDGET_H

View File

@ -1,15 +1,11 @@
/************************************************************************ /************************************************************************
* file name : easy_graphics_item.cpp * file name : graphics_block_item.cpp
* ----------------- : * ----------------- :
* creation time : 2016/09/15 * creation time : 2016/09/15
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains implementation of BlocksGraphicsItem. * description : The file contains implementation of GraphicsBlockItem.
* ----------------- :
* change log : * 2016/09/15 Victor Zarubkin: Moved sources from blocks_graphics_view.cpp
* :
* : *
* ----------------- : * ----------------- :
* license : Lightweight profiler library for c++ * license : Lightweight profiler library for c++
* : Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin * : Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin
@ -55,7 +51,7 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QDebug> #include <QDebug>
#include <algorithm> #include <algorithm>
#include "easy_graphics_item.h" #include "graphics_block_item.h"
#include "blocks_graphics_view.h" #include "blocks_graphics_view.h"
#include "globals.h" #include "globals.h"
@ -107,7 +103,7 @@ const QPen HIGHLIGHTER_PEN = ([]() -> QPen { QPen p(profiler::colors::Black); p.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
BlocksGraphicsItem::BlocksGraphicsItem(uint8_t _index, const profiler::BlocksTreeRoot& _root) GraphicsBlockItem::GraphicsBlockItem(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)
@ -115,23 +111,23 @@ BlocksGraphicsItem::BlocksGraphicsItem(uint8_t _index, const profiler::BlocksTre
{ {
} }
BlocksGraphicsItem::~BlocksGraphicsItem() GraphicsBlockItem::~GraphicsBlockItem()
{ {
} }
void BlocksGraphicsItem::validateName() void GraphicsBlockItem::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 BlocksGraphicsView* BlocksGraphicsItem::view() const const BlocksGraphicsView* GraphicsBlockItem::view() const
{ {
return static_cast<const BlocksGraphicsView*>(scene()->parent()); return static_cast<const BlocksGraphicsView*>(scene()->parent());
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
QRectF BlocksGraphicsItem::boundingRect() const QRectF GraphicsBlockItem::boundingRect() const
{ {
return m_boundingRect; return m_boundingRect;
} }
@ -176,7 +172,7 @@ struct EasyPainterInformation EASY_FINAL
}; };
#ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT #ifdef EASY_GRAPHICS_ITEM_RECURSIVE_PAINT
void BlocksGraphicsItem::paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber, void GraphicsBlockItem::paintChildren(const float _minWidth, const int _narrowSizeHalf, const uint8_t _levelsNumber,
QPainter* _painter, struct EasyPainterInformation& p, profiler_gui::EasyBlockItem& _item, QPainter* _painter, struct EasyPainterInformation& p, profiler_gui::EasyBlockItem& _item,
const profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level, const profiler_gui::EasyBlock& _itemBlock, RightBounds& _rightBounds, uint8_t _level,
int8_t _mode) int8_t _mode)
@ -454,7 +450,7 @@ void BlocksGraphicsItem::paintChildren(const float _minWidth, const int _narrowS
} }
#endif #endif
void BlocksGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*, QWidget*) void GraphicsBlockItem::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();
@ -1119,26 +1115,26 @@ void BlocksGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsIte
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
const ::profiler::BlocksTreeRoot* BlocksGraphicsItem::root() const const ::profiler::BlocksTreeRoot* GraphicsBlockItem::root() const
{ {
return m_pRoot; return m_pRoot;
} }
const QString& BlocksGraphicsItem::threadName() const const QString& GraphicsBlockItem::threadName() const
{ {
return m_threadName; return m_threadName;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
QRect BlocksGraphicsItem::getRect() const QRect GraphicsBlockItem::getRect() const
{ {
return view()->mapFromScene(m_boundingRect).boundingRect(); return view()->mapFromScene(m_boundingRect).boundingRect();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void BlocksGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::TreeBlocks& _blocks) const void GraphicsBlockItem::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();
@ -1183,7 +1179,7 @@ void BlocksGraphicsItem::getBlocks(qreal _left, qreal _right, ::profiler_gui::Tr
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersect(const QPointF& _pos, ::profiler::block_index_t& _blockIndex) const const ::profiler_gui::EasyBlock* GraphicsBlockItem::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())
{ {
@ -1356,7 +1352,7 @@ const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersect(const QPointF& _p
return nullptr; return nullptr;
} }
const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersectEvent(const QPointF& _pos) const const ::profiler_gui::EasyBlock* GraphicsBlockItem::intersectEvent(const QPointF& _pos) const
{ {
if (m_pRoot->sync.empty()) if (m_pRoot->sync.empty())
{ {
@ -1407,36 +1403,36 @@ const ::profiler_gui::EasyBlock* BlocksGraphicsItem::intersectEvent(const QPoint
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void BlocksGraphicsItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h) void GraphicsBlockItem::setBoundingRect(qreal x, qreal y, qreal w, qreal h)
{ {
m_boundingRect.setRect(x, y, w, h); m_boundingRect.setRect(x, y, w, h);
} }
void BlocksGraphicsItem::setBoundingRect(const QRectF& _rect) void GraphicsBlockItem::setBoundingRect(const QRectF& _rect)
{ {
m_boundingRect = _rect; m_boundingRect = _rect;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
::profiler::thread_id_t BlocksGraphicsItem::threadId() const ::profiler::thread_id_t GraphicsBlockItem::threadId() const
{ {
return m_pRoot->thread_id; return m_pRoot->thread_id;
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
uint8_t BlocksGraphicsItem::levels() const uint8_t GraphicsBlockItem::levels() const
{ {
return static_cast<uint8_t>(m_levels.size()); return static_cast<uint8_t>(m_levels.size());
} }
float BlocksGraphicsItem::levelY(uint8_t _level) const float GraphicsBlockItem::levelY(uint8_t _level) const
{ {
return static_cast<float>(y() + static_cast<int>(_level) * EASY_GLOBALS.size.graphics_row_full); return static_cast<float>(y() + static_cast<int>(_level) * EASY_GLOBALS.size.graphics_row_full);
} }
void BlocksGraphicsItem::setLevels(uint8_t _levels) void GraphicsBlockItem::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>();
@ -1446,29 +1442,29 @@ void BlocksGraphicsItem::setLevels(uint8_t _levels)
m_rightBounds.resize(_levels, -1e100); m_rightBounds.resize(_levels, -1e100);
} }
void BlocksGraphicsItem::reserve(uint8_t _level, unsigned int _items) void GraphicsBlockItem::reserve(uint8_t _level, unsigned int _items)
{ {
m_levels[_level].reserve(_items); m_levels[_level].reserve(_items);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
const BlocksGraphicsItem::Children& BlocksGraphicsItem::items(uint8_t _level) const const GraphicsBlockItem::Children& GraphicsBlockItem::items(uint8_t _level) const
{ {
return m_levels[_level]; return m_levels[_level];
} }
const ::profiler_gui::EasyBlockItem& BlocksGraphicsItem::getItem(uint8_t _level, unsigned int _index) const const ::profiler_gui::EasyBlockItem& GraphicsBlockItem::getItem(uint8_t _level, unsigned int _index) const
{ {
return m_levels[_level][_index]; return m_levels[_level][_index];
} }
::profiler_gui::EasyBlockItem& BlocksGraphicsItem::getItem(uint8_t _level, unsigned int _index) ::profiler_gui::EasyBlockItem& GraphicsBlockItem::getItem(uint8_t _level, unsigned int _index)
{ {
return m_levels[_level][_index]; return m_levels[_level][_index];
} }
unsigned int BlocksGraphicsItem::addItem(uint8_t _level) unsigned int GraphicsBlockItem::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

@ -1,17 +1,13 @@
/************************************************************************ /************************************************************************
* file name : easy_graphics_item.h * file name : graphics_block_item.h
* ----------------- : * ----------------- :
* creation time : 2016/09/15 * creation time : 2016/09/15
* author : Victor Zarubkin * author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com * email : v.s.zarubkin@gmail.com
* ----------------- : * ----------------- :
* description : The file contains declaration of BlocksGraphicsItem - an item * description : The file contains declaration of GraphicsBlockItem - 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
* :
* : *
* ----------------- :
* license : Lightweight profiler library for c++ * license : Lightweight profiler library for c++
* : Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin * : Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin
* : * :
@ -53,8 +49,8 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#ifndef EASY_GRAPHICS_ITEM_H #ifndef GRAPHICS_BLOCK_ITEM_H
#define EASY_GRAPHICS_ITEM_H #define GRAPHICS_BLOCK_ITEM_H
#include <stdlib.h> #include <stdlib.h>
@ -71,12 +67,12 @@
class BlocksGraphicsView; class BlocksGraphicsView;
class BlocksGraphicsItem : public QGraphicsItem class GraphicsBlockItem : public QGraphicsItem
{ {
typedef ::profiler_gui::EasyItems Children; using Children = profiler_gui::EasyItems;
typedef ::std::vector<uint32_t> DrawIndexes; using DrawIndexes = std::vector<uint32_t>;
typedef ::std::vector<qreal> RightBounds; using RightBounds = std::vector<qreal>;
typedef ::std::vector<Children> Sublevels; using Sublevels = std::vector<Children>;
DrawIndexes m_levelsIndexes; ///< Indexes of first item on each level from which we must start painting DrawIndexes m_levelsIndexes; ///< Indexes of first item on each level from which we must start painting
RightBounds m_rightBounds; ///< RightBounds m_rightBounds; ///<
@ -89,8 +85,8 @@ class BlocksGraphicsItem : public QGraphicsItem
public: public:
explicit BlocksGraphicsItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root); explicit GraphicsBlockItem(uint8_t _index, const::profiler::BlocksTreeRoot& _root);
virtual ~BlocksGraphicsItem(); virtual ~GraphicsBlockItem();
// Public virtual methods // Public virtual methods
@ -186,9 +182,9 @@ public:
return m_index; return m_index;
} }
}; // END of class BlocksGraphicsItem. }; // END of class GraphicsBlockItem.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#endif // EASY_GRAPHICS_ITEM_H #endif // GRAPHICS_BLOCK_ITEM_H

View File

@ -5,7 +5,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include <atomic> #include <atomic>
#include "easy_qtimer.h" #include "timer.h"
#include "thread_pool_task.h" #include "thread_pool_task.h"
class GraphicsImageItem : public QGraphicsItem class GraphicsImageItem : public QGraphicsItem

View File

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* file name : easy_chronometer_item.cpp * file name : graphics_ruler_item.cpp
* ----------------- : * ----------------- :
* creation time : 2016/09/15 * creation time : 2016/09/15
* author : Victor Zarubkin * author : Victor Zarubkin
@ -52,11 +52,11 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#include <math.h>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QFontMetricsF> #include <QFontMetricsF>
#include <math.h>
#include "blocks_graphics_view.h" #include "blocks_graphics_view.h"
#include "easy_chronometer_item.h" #include "graphics_ruler_item.h"
#include "globals.h" #include "globals.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* file name : easy_chronometer_item.h * file name : graphics_ruler_item.h
* ----------------- : * ----------------- :
* creation time : 2016/09/15 * creation time : 2016/09/15
* author : Victor Zarubkin * author : Victor Zarubkin
@ -53,8 +53,8 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#ifndef EASY_CHRONOMETER_ITEM_H #ifndef GRAPHICS_RULER_ITEM_H
#define EASY_CHRONOMETER_ITEM_H #define GRAPHICS_RULER_ITEM_H
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QRectF> #include <QRectF>
@ -168,4 +168,4 @@ private:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#endif // EASY_CHRONOMETER_ITEM_H #endif // GRAPHICS_RULER_ITEM_H

View File

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* file name : easy_graphics_scrollbar.cpp * file name : graphics_scrollbar.cpp
* ----------------- : * ----------------- :
* creation time : 2016/07/04 * creation time : 2016/07/04
* author : Victor Zarubkin * author : Victor Zarubkin
@ -58,7 +58,7 @@
#include <QMouseEvent> #include <QMouseEvent>
#include <QResizeEvent> #include <QResizeEvent>
#include <easy/utility.h> #include <easy/utility.h>
#include "easy_graphics_scrollbar.h" #include "graphics_scrollbar.h"
#include "globals.h" #include "globals.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -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 BlocksGraphicsScrollbar*>(scene()->parent()); const auto widget = static_cast<const GraphicsScrollbar*>(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 BlocksGraphicsScrollbar*>(scene()->parent()); const auto widget = static_cast<const GraphicsScrollbar*>(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();
@ -785,7 +785,7 @@ void GraphicsHistogramItem::onModeChanged()
if (!isImageUpdatePermitted()) if (!isImageUpdatePermitted())
return; return;
const auto widget = static_cast<const BlocksGraphicsScrollbar*>(scene()->parent()); const auto widget = static_cast<const GraphicsScrollbar*>(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;
@ -1141,7 +1141,7 @@ void GraphicsHistogramItem::updateImageAsync(QRectF _boundingRect, HistRegime _r
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
BlocksGraphicsScrollbar::BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent) GraphicsScrollbar::GraphicsScrollbar(int _initialHeight, QWidget* _parent)
: Parent(_parent) : Parent(_parent)
, m_histogramItem(nullptr) , m_histogramItem(nullptr)
{ {
@ -1171,14 +1171,14 @@ BlocksGraphicsScrollbar::BlocksGraphicsScrollbar(int _initialHeight, QWidget* _p
connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::allDataGoingToBeDeleted, this, &This::clear); connect(&EASY_GLOBALS.events, &profiler_gui::GlobalSignals::allDataGoingToBeDeleted, this, &This::clear);
} }
BlocksGraphicsScrollbar::~BlocksGraphicsScrollbar() GraphicsScrollbar::~GraphicsScrollbar()
{ {
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void BlocksGraphicsScrollbar::onThreadViewChanged() void GraphicsScrollbar::onThreadViewChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
{ {
@ -1187,7 +1187,7 @@ void BlocksGraphicsScrollbar::onThreadViewChanged()
} }
} }
void BlocksGraphicsScrollbar::onExpectedFrameTimeChanged() void GraphicsScrollbar::onExpectedFrameTimeChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
{ {
@ -1196,13 +1196,13 @@ void BlocksGraphicsScrollbar::onExpectedFrameTimeChanged()
} }
} }
void BlocksGraphicsScrollbar::onAutoAdjustHistogramChanged() void GraphicsScrollbar::onAutoAdjustHistogramChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
m_histogramItem->onModeChanged(); m_histogramItem->onModeChanged();
} }
void BlocksGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged() void GraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
{ {
if (m_histogramItem->isVisible()) if (m_histogramItem->isVisible())
m_histogramItem->rebuildSource(GraphicsHistogramItem::Hist_Id); m_histogramItem->rebuildSource(GraphicsHistogramItem::Hist_Id);
@ -1210,18 +1210,18 @@ void BlocksGraphicsScrollbar::onDisplayOnlyFramesOnHistogramChanged()
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void BlocksGraphicsScrollbar::clear() void GraphicsScrollbar::clear()
{ {
setHistogramSource(0, nullptr); setHistogramSource(0, nullptr);
Parent::clear(); Parent::clear();
} }
profiler::thread_id_t BlocksGraphicsScrollbar::hystThread() const profiler::thread_id_t GraphicsScrollbar::hystThread() const
{ {
return m_histogramItem->threadId(); return m_histogramItem->threadId();
} }
void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items) void GraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items)
{ {
if (m_bLocked) if (m_bLocked)
return; return;
@ -1230,7 +1230,7 @@ void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_i
scene()->update(); scene()->update();
} }
void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id) void GraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id)
{ {
if (m_bLocked) if (m_bLocked)
return; return;
@ -1239,7 +1239,7 @@ void BlocksGraphicsScrollbar::setHistogramSource(profiler::thread_id_t _thread_i
scene()->update(); scene()->update();
} }
void BlocksGraphicsScrollbar::mousePressEvent(QMouseEvent* _event) void GraphicsScrollbar::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

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* file name : easy_graphics_scrollbar.h * file name : graphics_scrollbar.h
* ----------------- : * ----------------- :
* creation time : 2016/07/04 * creation time : 2016/07/04
* author : Victor Zarubkin * author : Victor Zarubkin
@ -52,14 +52,14 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#ifndef EASY__GRAPHICS_SCROLLBAR__H #ifndef GRAPHICS_SCROLLBAR_H
#define EASY__GRAPHICS_SCROLLBAR__H #define GRAPHICS_SCROLLBAR_H
#include <stdlib.h> #include <stdlib.h>
#include <thread> #include <thread>
#include <atomic> #include <atomic>
#include <QImage> #include <QImage>
#include "easy_qtimer.h" #include "timer.h"
#include "graphics_slider_area.h" #include "graphics_slider_area.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -142,21 +142,21 @@ private:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
class BlocksGraphicsScrollbar : public GraphicsSliderArea class GraphicsScrollbar : public GraphicsSliderArea
{ {
Q_OBJECT Q_OBJECT
private: private:
using Parent = GraphicsSliderArea; using Parent = GraphicsSliderArea;
using This = BlocksGraphicsScrollbar; using This = GraphicsScrollbar;
GraphicsHistogramItem* m_histogramItem = nullptr; GraphicsHistogramItem* m_histogramItem = nullptr;
public: public:
explicit BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr); explicit GraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr);
~BlocksGraphicsScrollbar() override; ~GraphicsScrollbar() override;
void clear() override; void clear() override;
void mousePressEvent(QMouseEvent* _event) override; void mousePressEvent(QMouseEvent* _event) override;
@ -180,8 +180,8 @@ private slots:
void onAutoAdjustHistogramChanged(); void onAutoAdjustHistogramChanged();
void onDisplayOnlyFramesOnHistogramChanged(); void onDisplayOnlyFramesOnHistogramChanged();
}; // END of class BlocksGraphicsScrollbar. }; // END of class GraphicsScrollbar.
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#endif // EASY__GRAPHICS_SCROLLBAR__H #endif // GRAPHICS_SCROLLBAR_H

View File

@ -101,7 +101,7 @@
#include "blocks_tree_widget.h" #include "blocks_tree_widget.h"
#include "blocks_graphics_view.h" #include "blocks_graphics_view.h"
#include "descriptors_tree_widget.h" #include "descriptors_tree_widget.h"
#include "easy_frame_rate_viewer.h" #include "fps_widget.h"
#include "globals.h" #include "globals.h"
#include <easy/easy_net.h> #include <easy/easy_net.h>
@ -284,7 +284,7 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
m_fpsViewer = new DockWidget("FPS Monitor", this); m_fpsViewer = new DockWidget("FPS Monitor", this);
m_fpsViewer->setObjectName("ProfilerGUI_FPS"); m_fpsViewer->setObjectName("ProfilerGUI_FPS");
m_fpsViewer->setWidget(new FpsViewerWidget(this)); m_fpsViewer->setWidget(new FpsWidget(this));
m_fpsViewer->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); m_fpsViewer->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
addDockWidget(Qt::TopDockWidgetArea, m_graphicsView); addDockWidget(Qt::TopDockWidgetArea, m_graphicsView);
@ -1687,7 +1687,7 @@ void MainWindow::checkFrameTimeReady()
uint32_t maxTime = 0, avgTime = 0; uint32_t maxTime = 0, avgTime = 0;
if (m_listener.frameTime(maxTime, avgTime)) if (m_listener.frameTime(maxTime, avgTime))
{ {
static_cast<FpsViewerWidget*>(m_fpsViewer->widget())->addPoint(maxTime, avgTime); static_cast<FpsWidget*>(m_fpsViewer->widget())->addPoint(maxTime, avgTime);
} }
else if (m_fpsRequestTimer.isActive()) else if (m_fpsRequestTimer.isActive())
{ {
@ -2339,7 +2339,7 @@ void MainWindow::onConnectClicked(bool)
m_connectAction->setText(tr("Disconnect")); m_connectAction->setText(tr("Disconnect"));
if (m_fpsViewer->isVisible()) if (m_fpsViewer->isVisible())
static_cast<FpsViewerWidget*>(m_fpsViewer->widget())->clear(); static_cast<FpsWidget*>(m_fpsViewer->widget())->clear();
if (!m_fpsRequestTimer.isActive()) if (!m_fpsRequestTimer.isActive())
m_fpsRequestTimer.start(EASY_GLOBALS.fps_timer_interval); m_fpsRequestTimer.start(EASY_GLOBALS.fps_timer_interval);

View File

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* file name : easy_qtimer.h * file name : timer.cpp
* ----------------- : * ----------------- :
* creation time : 2016/12/05 * creation time : 2016/12/05
* author : Victor Zarubkin * author : Victor Zarubkin
@ -53,7 +53,7 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#include "easy_qtimer.h" #include "timer.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////

View File

@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* file name : easy_qtimer.h * file name : timer.h
* ----------------- : * ----------------- :
* creation time : 2016/12/05 * creation time : 2016/12/05
* author : Victor Zarubkin * author : Victor Zarubkin
@ -53,11 +53,11 @@
* : limitations under the License. * : limitations under the License.
************************************************************************/ ************************************************************************/
#ifndef EASY__QTIMER__H #ifndef TIMER_H
#define EASY__QTIMER__H #define TIMER_H
#include <QTimer>
#include <functional> #include <functional>
#include <QTimer>
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -95,4 +95,4 @@ private slots:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#endif // EASY__QTIMER__H #endif // TIMER_H