2016-08-08 22:54:20 +03:00
/************************************************************************
* file name : globals . h
* - - - - - - - - - - - - - - - - - :
* creation time : 2016 / 08 / 03
* author : Victor Zarubkin
* email : v . s . zarubkin @ gmail . com
* - - - - - - - - - - - - - - - - - :
* description : The file contains declaration of global constants and variables for profiler gui .
* - - - - - - - - - - - - - - - - - :
* change log : * 2016 / 08 / 03 Victor Zarubkin : initial commit .
* :
* : *
* - - - - - - - - - - - - - - - - - :
2016-09-06 21:49:32 +03:00
* license : Lightweight profiler library for c + +
* : Copyright ( C ) 2016 Sergey Yagovtsev , Victor Zarubkin
* :
2016-11-13 16:39:59 +03:00
* :
* : Licensed under the Apache License , Version 2.0 ( the " License " ) ;
* : you may not use this file except in compliance with the License .
* : 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 .
* :
* :
* : GNU General Public License Usage
* : Alternatively , this file may be used under the terms of the GNU
* : General Public License as published by the Free Software Foundation ,
* : either version 3 of the License , or ( at your option ) any later version .
2016-09-06 21:49:32 +03:00
* :
* : This program is distributed in the hope that it will be useful ,
* : but WITHOUT ANY WARRANTY ; without even the implied warranty of
* : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* : GNU General Public License for more details .
* :
* : You should have received a copy of the GNU General Public License
* : along with this program . If not , see < http : //www.gnu.org/licenses/>.
2016-08-03 23:00:04 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# ifndef EASY_PROFILER__GUI_GLOBALS_H
# define EASY_PROFILER__GUI_GLOBALS_H
# include <string>
# include <QObject>
2016-08-06 14:50:31 +03:00
# include <QColor>
2016-08-09 00:45:45 +03:00
# include <QTextCodec>
2016-09-15 23:56:20 +03:00
# include <QSize>
2016-08-03 23:00:04 +03:00
# include "common_types.h"
2016-08-08 22:54:20 +03:00
# include "globals_qobjects.h"
2016-08-03 23:00:04 +03:00
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
namespace profiler_gui {
2016-09-06 22:23:55 +03:00
const QString ORGANAZATION_NAME = " EasyProfiler " ;
const QString APPLICATION_NAME = " Easy profiler gui application " ;
2016-08-04 23:12:41 +03:00
2016-09-09 00:07:27 +03:00
const QColor CHRONOMETER_COLOR = QColor : : fromRgba ( 0x40000000 | ( : : profiler : : colors : : RichBlue & 0x00ffffff ) ) ; // 0x402020c0);
2016-09-15 22:30:32 +03:00
const QColor CHRONOMETER_COLOR2 = QColor : : fromRgba ( 0x40000000 | ( : : profiler : : colors : : Dark & 0x00ffffff ) ) ; // 0x40408040);
2016-08-07 19:38:31 +03:00
const QRgb SELECTED_THREAD_BACKGROUND = 0x00e0e060 ;
2016-08-06 14:50:31 +03:00
const QRgb SELECTED_THREAD_FOREGROUND = 0x00ffffff - SELECTED_THREAD_BACKGROUND ;
2016-08-21 22:44:03 +03:00
const qreal SCALING_COEFFICIENT = 1.25 ;
const qreal SCALING_COEFFICIENT_INV = 1.0 / SCALING_COEFFICIENT ;
2016-09-15 22:30:32 +03:00
const uint16_t GRAPHICS_ROW_SIZE = 18 ;
const uint16_t GRAPHICS_ROW_SPACING = 2 ;
const uint16_t GRAPHICS_ROW_SIZE_FULL = GRAPHICS_ROW_SIZE + GRAPHICS_ROW_SPACING ;
const uint16_t THREADS_ROW_SPACING = 8 ;
# ifdef _WIN32
const qreal FONT_METRICS_FACTOR = 1.05 ;
# else
const qreal FONT_METRICS_FACTOR = 1. ;
# endif
2016-08-04 22:38:45 +03:00
//////////////////////////////////////////////////////////////////////////
2016-08-09 00:45:45 +03:00
template < class T >
2016-08-09 01:29:24 +03:00
inline auto toUnicode ( const T & _inputString ) - > decltype ( QTextCodec : : codecForLocale ( ) - > toUnicode ( _inputString ) )
2016-08-09 00:45:45 +03:00
{
return QTextCodec : : codecForLocale ( ) - > toUnicode ( _inputString ) ;
}
2016-08-04 22:38:45 +03:00
//////////////////////////////////////////////////////////////////////////
2016-11-30 21:59:40 +03:00
enum ChronometerTextPosition : int8_t
2016-08-24 01:00:24 +03:00
{
ChronoTextPosition_Center = 0 ,
ChronoTextPosition_Top ,
ChronoTextPosition_Bottom ,
} ; // END of enum ChronometerTextPosition.
//////////////////////////////////////////////////////////////////////////
2016-09-22 23:06:43 +03:00
struct EasyGlobals Q_DECL_FINAL
2016-08-03 23:00:04 +03:00
{
2016-08-18 23:26:41 +03:00
static EasyGlobals & instance ( ) ;
2016-08-03 23:00:04 +03:00
2016-08-18 23:26:41 +03:00
EasyGlobalSignals events ; ///< Global signals
2016-08-09 00:14:58 +03:00
: : profiler : : thread_blocks_tree_t profiler_blocks ; ///< Profiler blocks tree loaded from file
2016-08-28 18:19:12 +03:00
: : profiler : : descriptors_list_t descriptors ; ///< Profiler block descriptors list
2016-08-18 23:26:41 +03:00
EasyBlocks gui_blocks ; ///< Profiler graphics blocks builded by GUI
2016-12-04 16:51:27 +03:00
: : profiler : : timestamp_t begin_time ; ///<
2016-08-09 00:14:58 +03:00
: : profiler : : thread_id_t selected_thread ; ///< Current selected thread id
2016-09-17 11:10:45 +03:00
: : profiler : : block_index_t selected_block ; ///< Current selected profiler block index
2016-11-30 21:59:40 +03:00
: : profiler : : block_id_t selected_block_id ; ///< Current selected profiler block id
2016-11-13 22:02:47 +03:00
float frame_time ; ///< Value in microseconds to be displayed at minimap on graphics scrollbar
2016-11-19 04:52:45 +03:00
int blocks_spacing ; ///< Minimum blocks spacing on diagram
int blocks_size_min ; ///< Minimum blocks size on diagram
int blocks_narrow_size ; ///< Width indicating narrow blocks
2016-11-30 21:59:40 +03:00
ChronometerTextPosition chrono_text_position ; ///< Selected interval text position
TimeUnits time_units ; ///< Units type for time (milliseconds, microseconds, nanoseconds or auto-definition)
2016-09-25 11:49:49 +03:00
bool connected ; ///< Is connected to source (to be able to capture profiling information)
2016-09-23 23:50:43 +03:00
bool enable_event_indicators ; ///< Enable event indicators painting (These are narrow rectangles at the bottom of each thread)
2016-09-14 23:13:38 +03:00
bool enable_statistics ; ///< Enable gathering and using statistics (Disable if you want to consume less memory)
2016-11-23 22:54:59 +03:00
bool enable_zero_length ; ///< Enable zero length blocks (if true, then such blocks will have width == 1 pixel on each scale)
2016-11-26 18:08:02 +03:00
bool add_zero_blocks_to_hierarchy ; ///< Enable adding zero blocks into hierarchy tree
2016-08-09 00:14:58 +03:00
bool draw_graphics_items_borders ; ///< Draw borders for graphics blocks or not
2016-09-29 22:40:19 +03:00
bool hide_narrow_children ; ///< Hide children for narrow graphics blocks
2016-08-09 00:14:58 +03:00
bool display_only_relevant_stats ; ///< Display only relevant information in ProfTreeWidget (excludes min, max, average times if there are only 1 calls number)
2016-08-23 22:44:04 +03:00
bool collapse_items_on_tree_close ; ///< Collapse all items which were displayed in the hierarchy tree after tree close/reset
2016-08-23 23:50:30 +03:00
bool all_items_expanded_by_default ; ///< Expand all items after file is opened
2016-11-20 21:01:33 +03:00
bool only_current_thread_hierarchy ; ///< Build hierarchy tree for current thread only
2016-11-30 21:59:40 +03:00
bool highlight_blocks_with_same_id ; ///< Highlight all blocks with same id on diagram
2016-12-04 16:51:27 +03:00
bool selecting_block_changes_thread ; ///< If true then current selected thread will change every time you select block
2016-08-23 23:50:30 +03:00
bool bind_scene_and_tree_expand_status ; /** \brief If true then items on graphics scene and in the tree (blocks hierarchy) are binded on each other
so expanding / collapsing items on scene also expands / collapse items in the tree . */
2016-08-03 23:00:04 +03:00
private :
2016-08-18 23:26:41 +03:00
EasyGlobals ( ) ;
2016-08-24 01:00:24 +03:00
} ; // END of struct EasyGlobals.
2016-08-04 22:38:45 +03:00
//////////////////////////////////////////////////////////////////////////
2016-08-03 23:00:04 +03:00
} // END of namespace profiler_gui.
2016-08-30 22:51:18 +03:00
# ifndef IGNORE_GLOBALS_DECLARATION
static : : profiler_gui : : EasyGlobals & EASY_GLOBALS = : : profiler_gui : : EasyGlobals : : instance ( ) ;
inline : : profiler_gui : : EasyBlock & easyBlock ( : : profiler : : block_index_t i ) {
return EASY_GLOBALS . gui_blocks [ i ] ;
}
inline : : profiler : : SerializedBlockDescriptor & easyDescriptor ( : : profiler : : block_id_t i ) {
return * EASY_GLOBALS . descriptors [ i ] ;
}
inline : : profiler : : BlocksTree & blocksTree ( : : profiler : : block_index_t i ) {
return easyBlock ( i ) . tree ;
}
# endif
2016-09-15 23:56:20 +03:00
# define SET_ICON(objectName, iconName) { QIcon icon(iconName); if (!icon.isNull()) objectName->setIcon(icon); }
2016-08-03 23:00:04 +03:00
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
# endif // EASY_PROFILER__GUI_GLOBALS_H