2016-06-26 20:54:16 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : main_window.cpp
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/06/26
|
|
|
|
* copyright : (c) 2016 Victor Zarubkin
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
|
|
|
* description : The file contains implementation of MainWindow for easy_profiler GUI.
|
|
|
|
* ----------------- :
|
2016-06-27 22:11:26 +03:00
|
|
|
* change log : * 2016/06/26 Victor Zarubkin: Initial commit.
|
2016-06-30 02:57:57 +03:00
|
|
|
* :
|
2016-06-27 22:11:26 +03:00
|
|
|
* : * 2016/06/27 Victor Zarubkin: Passing blocks number to ProfTreeWidget::setTree().
|
2016-06-30 02:57:57 +03:00
|
|
|
* :
|
|
|
|
* : * 2016/06/29 Victor Zarubkin: Added menu with tests.
|
|
|
|
* :
|
2016-06-26 20:54:16 +03:00
|
|
|
* : *
|
|
|
|
* ----------------- :
|
|
|
|
* license : TODO: add license text
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include "main_window.h"
|
|
|
|
#include "blocks_tree_widget.h"
|
|
|
|
#include "blocks_graphics_view.h"
|
2016-07-10 01:29:09 +03:00
|
|
|
//#include "graphics_scrollbar.h"
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
ProfMainWindow::ProfMainWindow() : QMainWindow(), m_treeWidget(nullptr), m_graphicsView(nullptr)
|
|
|
|
{
|
|
|
|
setObjectName("ProfilerGUI_MainWindow");
|
|
|
|
setWindowTitle("easy_profiler reader");
|
|
|
|
setDockNestingEnabled(true);
|
|
|
|
resize(800, 600);
|
|
|
|
|
|
|
|
setStatusBar(new QStatusBar());
|
|
|
|
|
2016-06-30 02:57:57 +03:00
|
|
|
auto graphicsView = new ProfGraphicsView(false);
|
2016-06-26 20:54:16 +03:00
|
|
|
m_graphicsView = new QDockWidget("Blocks diagram");
|
|
|
|
m_graphicsView->setMinimumHeight(50);
|
|
|
|
m_graphicsView->setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
|
|
m_graphicsView->setWidget(graphicsView);
|
|
|
|
|
|
|
|
auto treeWidget = new ProfTreeWidget();
|
|
|
|
m_treeWidget = new QDockWidget("Blocks hierarchy");
|
|
|
|
m_treeWidget->setMinimumHeight(50);
|
|
|
|
m_treeWidget->setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
|
|
m_treeWidget->setWidget(treeWidget);
|
|
|
|
|
2016-07-10 01:29:09 +03:00
|
|
|
//auto bar = new GraphicsHorizontalScrollbar();
|
|
|
|
//auto dock = new QDockWidget();
|
|
|
|
//dock->setMinimumHeight(20);
|
|
|
|
//dock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
|
|
//dock->setWidget(bar);
|
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
addDockWidget(Qt::TopDockWidgetArea, m_graphicsView);
|
2016-07-10 01:29:09 +03:00
|
|
|
//addDockWidget(Qt::TopDockWidgetArea, dock);
|
2016-06-26 20:54:16 +03:00
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, m_treeWidget);
|
|
|
|
|
|
|
|
auto actionOpen = new QAction("Open", nullptr);
|
2016-06-30 02:57:57 +03:00
|
|
|
connect(actionOpen, &QAction::triggered, this, &This::onOpenFileClicked);
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
auto actionReload = new QAction("Reload", nullptr);
|
2016-06-30 02:57:57 +03:00
|
|
|
connect(actionReload, &QAction::triggered, this, &This::onReloadFileClicked);
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
auto actionExit = new QAction("Exit", nullptr);
|
2016-06-30 02:57:57 +03:00
|
|
|
connect(actionExit, &QAction::triggered, this, &This::onExitClicked);
|
2016-06-26 20:54:16 +03:00
|
|
|
|
2016-06-30 02:57:57 +03:00
|
|
|
auto actionTestView = new QAction("Test viewport", nullptr);
|
|
|
|
connect(actionTestView, &QAction::triggered, this, &This::onTestViewportClicked);
|
2016-06-26 20:54:16 +03:00
|
|
|
|
2016-06-30 02:57:57 +03:00
|
|
|
auto menu = new QMenu("File");
|
|
|
|
menu->addAction(actionOpen);
|
|
|
|
menu->addAction(actionReload);
|
|
|
|
menu->addSeparator();
|
|
|
|
menu->addAction(actionExit);
|
|
|
|
menuBar()->addMenu(menu);
|
|
|
|
|
|
|
|
menu = new QMenu("Tests");
|
|
|
|
menu->addAction(actionTestView);
|
|
|
|
menuBar()->addMenu(menu);
|
2016-06-26 20:54:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
ProfMainWindow::~ProfMainWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ProfMainWindow::onOpenFileClicked(bool)
|
|
|
|
{
|
|
|
|
auto filename = QFileDialog::getOpenFileName(this, "Open profiler log", m_lastFile.c_str(), "Profiler Log File (*.prof);;All Files (*.*)");
|
|
|
|
auto stdfilename = filename.toStdString();
|
|
|
|
|
|
|
|
thread_blocks_tree_t prof_blocks;
|
|
|
|
auto nblocks = fillTreesFromFile(stdfilename.c_str(), prof_blocks, true);
|
|
|
|
|
2016-06-27 23:22:12 +03:00
|
|
|
if (nblocks != 0)
|
2016-06-26 20:54:16 +03:00
|
|
|
{
|
|
|
|
m_lastFile.swap(stdfilename);
|
|
|
|
m_currentProf.swap(prof_blocks);
|
2016-06-27 22:11:26 +03:00
|
|
|
static_cast<ProfTreeWidget*>(m_treeWidget->widget())->setTree(nblocks, m_currentProf);
|
2016-06-26 20:54:16 +03:00
|
|
|
static_cast<ProfGraphicsView*>(m_graphicsView->widget())->setTree(m_currentProf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ProfMainWindow::onReloadFileClicked(bool)
|
|
|
|
{
|
|
|
|
if (m_lastFile.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
thread_blocks_tree_t prof_blocks;
|
|
|
|
auto nblocks = fillTreesFromFile(m_lastFile.c_str(), prof_blocks, true);
|
|
|
|
|
2016-06-27 23:22:12 +03:00
|
|
|
if (nblocks != 0)
|
2016-06-26 20:54:16 +03:00
|
|
|
{
|
|
|
|
m_currentProf.swap(prof_blocks);
|
2016-06-27 22:11:26 +03:00
|
|
|
static_cast<ProfTreeWidget*>(m_treeWidget->widget())->setTree(nblocks, m_currentProf);
|
2016-06-26 20:54:16 +03:00
|
|
|
static_cast<ProfGraphicsView*>(m_graphicsView->widget())->setTree(m_currentProf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void ProfMainWindow::onExitClicked(bool)
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-30 02:57:57 +03:00
|
|
|
void ProfMainWindow::onTestViewportClicked(bool)
|
|
|
|
{
|
|
|
|
static_cast<ProfTreeWidget*>(m_treeWidget->widget())->clearSilent();
|
|
|
|
|
|
|
|
auto view = static_cast<ProfGraphicsView*>(m_graphicsView->widget());
|
|
|
|
view->clearSilent();
|
|
|
|
m_currentProf.clear();
|
|
|
|
|
|
|
|
view->test(18000, 40000000, 5);
|
|
|
|
//view->test(3, 300, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|