2016-07-10 01:29:09 +03:00
|
|
|
/************************************************************************
|
2016-09-15 22:30:32 +03:00
|
|
|
* file name : easy_graphics_scrollbar.h
|
2016-07-10 01:29:09 +03:00
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/07/04
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
2016-09-06 21:49:32 +03:00
|
|
|
* description : This file contains declaration of
|
2016-07-10 01:29:09 +03:00
|
|
|
* ----------------- :
|
|
|
|
* change log : * 2016/07/04 Victor Zarubkin: Initial commit.
|
|
|
|
* :
|
|
|
|
* : *
|
|
|
|
* ----------------- :
|
2016-09-06 21:49:32 +03:00
|
|
|
* license : Lightweight profiler library for c++
|
2018-01-29 23:29:43 +03:00
|
|
|
* : Copyright(C) 2016-2018 Sergey Yagovtsev, Victor Zarubkin
|
2017-03-30 06:14:23 +03:00
|
|
|
* :
|
|
|
|
* : Licensed under either of
|
|
|
|
* : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT)
|
|
|
|
* : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
* : at your option.
|
|
|
|
* :
|
|
|
|
* : The MIT License
|
|
|
|
* :
|
|
|
|
* : Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* : of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* : in the Software without restriction, including without limitation the rights
|
|
|
|
* : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* : of the Software, and to permit persons to whom the Software is furnished
|
|
|
|
* : to do so, subject to the following conditions:
|
|
|
|
* :
|
|
|
|
* : The above copyright notice and this permission notice shall be included in all
|
|
|
|
* : copies or substantial portions of the Software.
|
|
|
|
* :
|
|
|
|
* : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
|
|
* : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
|
|
* : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
* : USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
* :
|
|
|
|
* : The Apache License, Version 2.0 (the "License")
|
|
|
|
* :
|
|
|
|
* : You may not use this file except in compliance with the License.
|
2016-11-13 16:39:59 +03:00
|
|
|
* : You may obtain a copy of the License at
|
|
|
|
* :
|
|
|
|
* : http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
* :
|
|
|
|
* : Unless required by applicable law or agreed to in writing, software
|
|
|
|
* : distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* : See the License for the specific language governing permissions and
|
|
|
|
* : limitations under the License.
|
2016-07-10 01:29:09 +03:00
|
|
|
************************************************************************/
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
#ifndef EASY__GRAPHICS_SCROLLBAR__H
|
|
|
|
#define EASY__GRAPHICS_SCROLLBAR__H
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2016-12-04 16:51:27 +03:00
|
|
|
#include <thread>
|
|
|
|
#include <atomic>
|
|
|
|
#include <QImage>
|
|
|
|
#include "easy_qtimer.h"
|
2018-01-20 15:23:28 +03:00
|
|
|
#include "graphics_slider_area.h"
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
class GraphicsHistogramItem : public GraphicsImageItem
|
2016-07-10 01:29:09 +03:00
|
|
|
{
|
2018-01-20 15:23:28 +03:00
|
|
|
using Parent = GraphicsImageItem;
|
|
|
|
using This = GraphicsHistogramItem;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
enum HistRegime : uint8_t { Hist_Pointer, Hist_Id };
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
private:
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
qreal m_workerTopDuration;
|
|
|
|
qreal m_workerBottomDuration;
|
|
|
|
profiler::timestamp_t m_blockTotalDuraion;
|
|
|
|
QString m_topDurationStr;
|
|
|
|
QString m_bottomDurationStr;
|
|
|
|
QString m_threadName;
|
|
|
|
QString m_blockName;
|
|
|
|
profiler::BlocksTree::children_t m_selectedBlocks;
|
|
|
|
profiler::timestamp_t m_threadDuration;
|
|
|
|
profiler::timestamp_t m_threadProfiledTime;
|
|
|
|
profiler::timestamp_t m_threadWaitTime;
|
|
|
|
const profiler_gui::EasyItems* m_pSource;
|
|
|
|
const profiler::BlocksTreeRoot* m_pProfilerThread;
|
|
|
|
profiler::thread_id_t m_threadId;
|
|
|
|
profiler::block_index_t m_blockId;
|
|
|
|
profiler_gui::TimeUnits m_timeUnits;
|
|
|
|
HistRegime m_regime;
|
2016-12-04 16:51:27 +03:00
|
|
|
|
2017-06-07 02:08:53 +03:00
|
|
|
public:
|
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
explicit GraphicsHistogramItem();
|
|
|
|
~GraphicsHistogramItem() override;
|
2017-06-07 02:08:53 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
void paint(QPainter* _painter, const QStyleOptionGraphicsItem* _option, QWidget* _widget) override;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
bool updateImage() override;
|
|
|
|
void onImageUpdated() override;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
bool pickTopValue() override;
|
|
|
|
bool increaseTopValue() override;
|
|
|
|
bool decreaseTopValue() override;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
bool pickBottomValue() override;
|
|
|
|
bool increaseBottomValue() override;
|
|
|
|
bool decreaseBottomValue() override;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
void onModeChanged() override;
|
2016-08-03 00:06:36 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Public non-virtual methods
|
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
profiler::thread_id_t threadId() const;
|
2016-08-03 23:00:04 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
void setSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items);
|
|
|
|
void setSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id);
|
2017-06-07 02:08:53 +03:00
|
|
|
void rebuildSource(HistRegime _regime);
|
|
|
|
void rebuildSource();
|
2016-12-14 21:47:33 +03:00
|
|
|
void validateName();
|
2017-03-07 00:29:34 +03:00
|
|
|
|
2017-03-07 01:09:27 +03:00
|
|
|
void pickFrameTime(qreal _y) const;
|
2017-03-07 00:29:34 +03:00
|
|
|
|
2016-12-04 16:51:27 +03:00
|
|
|
private:
|
|
|
|
|
2017-03-07 00:29:34 +03:00
|
|
|
void paintMouseIndicator(QPainter* _painter, qreal _top, qreal _bottom, qreal _width, qreal _height, qreal _top_width, qreal _mouse_y, qreal _delta_time, int _font_h);
|
2016-12-04 16:51:27 +03:00
|
|
|
void paintByPtr(QPainter* _painter);
|
|
|
|
void paintById(QPainter* _painter);
|
2016-08-03 23:00:04 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
void updateImageAsync(QRectF _boundingRect, HistRegime _regime, qreal _current_scale,
|
|
|
|
qreal _minimum, qreal _maximum, qreal _range,
|
|
|
|
qreal _value, qreal _width, qreal _top_duration, qreal _bottom_duration, bool _bindMode,
|
|
|
|
float _frame_time, profiler::timestamp_t _begin_time, bool _autoAdjustHist);
|
|
|
|
|
|
|
|
}; // END of class GraphicsHistogramItem.
|
2016-08-03 23:00:04 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-01-28 20:52:17 +03:00
|
|
|
class BlocksGraphicsScrollbar : public GraphicsSliderArea
|
2016-07-10 01:29:09 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
using Parent = GraphicsSliderArea;
|
2018-01-28 20:52:17 +03:00
|
|
|
using This = BlocksGraphicsScrollbar;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
GraphicsHistogramItem* m_histogramItem = nullptr;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
public:
|
2016-08-03 23:00:04 +03:00
|
|
|
|
2018-01-28 20:52:17 +03:00
|
|
|
explicit BlocksGraphicsScrollbar(int _initialHeight, QWidget* _parent = nullptr);
|
|
|
|
~BlocksGraphicsScrollbar() override;
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
void clear() override;
|
2016-07-31 13:13:48 +03:00
|
|
|
void mousePressEvent(QMouseEvent* _event) override;
|
2016-11-19 05:39:41 +03:00
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
// Public non-virtual methods
|
2016-07-31 13:13:48 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
profiler::thread_id_t hystThread() const;
|
2016-07-31 13:13:48 +03:00
|
|
|
|
2018-01-20 15:23:28 +03:00
|
|
|
void setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems* _items);
|
|
|
|
void setHistogramSource(profiler::thread_id_t _thread_id, profiler::block_id_t _block_id);
|
|
|
|
void setHistogramSource(profiler::thread_id_t _thread_id, const profiler_gui::EasyItems& _items) {
|
2017-03-07 19:59:57 +03:00
|
|
|
setHistogramSource(_thread_id, &_items);
|
2016-12-04 16:51:27 +03:00
|
|
|
}
|
|
|
|
|
2016-08-03 23:00:04 +03:00
|
|
|
private slots:
|
2016-07-31 13:13:48 +03:00
|
|
|
|
2017-06-05 21:26:10 +03:00
|
|
|
void onThreadViewChanged();
|
2018-01-28 02:01:49 +03:00
|
|
|
void onExpectedFrameTimeChanged();
|
|
|
|
void onAutoAdjustHistogramChanged();
|
|
|
|
void onDisplayOnlyFramesOnHistogramChanged();
|
2016-07-10 01:29:09 +03:00
|
|
|
|
2018-01-28 20:52:17 +03:00
|
|
|
}; // END of class BlocksGraphicsScrollbar.
|
2016-07-10 01:29:09 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
#endif // EASY__GRAPHICS_SCROLLBAR__H
|