From 26233f64797884f661cf9b5260fa1c315534bb1e Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Fri, 13 Apr 2018 22:03:42 +0300 Subject: [PATCH 1/2] #0 [UI] Added Crop button stub --- profiler_gui/blocks_graphics_view.cpp | 12 ++++++++++++ profiler_gui/blocks_graphics_view.h | 2 ++ profiler_gui/images/attribution.txt | 2 ++ profiler_gui/images/default/crop.svg | 15 +++++++++++++++ profiler_gui/main_window.cpp | 26 ++++++++++++++++++++++++++ profiler_gui/main_window.h | 1 + profiler_gui/resources.qrc | 1 + 7 files changed, 59 insertions(+) create mode 100644 profiler_gui/images/default/crop.svg diff --git a/profiler_gui/blocks_graphics_view.cpp b/profiler_gui/blocks_graphics_view.cpp index c89037fe..763b9900 100644 --- a/profiler_gui/blocks_graphics_view.cpp +++ b/profiler_gui/blocks_graphics_view.cpp @@ -614,6 +614,18 @@ const BlocksGraphicsView::Items &BlocksGraphicsView::getItems() const return m_items; } +void BlocksGraphicsView::saveSelectionToFile(const QString& _filename) const +{ + if (m_selectedBlocks.empty()) + return; + +// profiler::timestamp_t beginTime = ~0ULL; +// for (const auto& selection : m_selectedBlocks) +// { +// const auto& tree = easy +// } +} + qreal BlocksGraphicsView::setTree(BlocksGraphicsItem* _item, const ::profiler::BlocksTree::children_t& _children, qreal& _height, uint32_t& _maxDepthChild, qreal _y, short _level) { if (_children.empty()) diff --git a/profiler_gui/blocks_graphics_view.h b/profiler_gui/blocks_graphics_view.h index 5f440893..ce7b6e3b 100644 --- a/profiler_gui/blocks_graphics_view.h +++ b/profiler_gui/blocks_graphics_view.h @@ -190,6 +190,8 @@ class BlocksGraphicsView : public QGraphicsView const Items& getItems() const; + void saveSelectionToFile(const QString& _filename) const; + void inspectCurrentView(bool _strict) { onInspectCurrentView(_strict); } diff --git a/profiler_gui/images/attribution.txt b/profiler_gui/images/attribution.txt index 0d0a6cf1..e3ead568 100644 --- a/profiler_gui/images/attribution.txt +++ b/profiler_gui/images/attribution.txt @@ -29,6 +29,7 @@ default/binoculars.svg - Icon made by Gregor Cresnar from www.flaticon default/close-white.svg - Icon made by Cole Bemis from www.flaticon.com default/close-white-hover.svg - Icon made by Cole Bemis from www.flaticon.com default/close-white-pressed.svg - Icon made by Cole Bemis from www.flaticon.com +default/crop.svg - Icon made by Freepik from www.flaticon.com default/maximize-white.svg - Icon made by Freepik from www.flaticon.com default/maximize-white-hover.svg - Icon made by Freepik from www.flaticon.com default/maximize-white-pressed.svg - Icon made by Freepik from www.flaticon.com @@ -46,3 +47,4 @@ default/yx.svg - Icon made by Freepik from www.flaticon.com default/svg2.svg - Icon made by Freepik from www.flaticon.com default/svg3.svg - Icon made by Freepik from www.flaticon.com default/window.svg - Icon made by Freepik from www.flaticon.com + diff --git a/profiler_gui/images/default/crop.svg b/profiler_gui/images/default/crop.svg new file mode 100644 index 00000000..d4162e0d --- /dev/null +++ b/profiler_gui/images/default/crop.svg @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/profiler_gui/main_window.cpp b/profiler_gui/main_window.cpp index fd60508b..e8ec9e26 100644 --- a/profiler_gui/main_window.cpp +++ b/profiler_gui/main_window.cpp @@ -378,6 +378,10 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos static_cast(m_graphicsView->widget())->view()->inspectCurrentView(true); }); + action = toolbar->addAction(QIcon(imagePath("crop")), "Crop and save"); + action->setToolTip("Crop and save selected area\nas separate .prof file."); + connect(action, &QAction::triggered, this, &This::onCropAndSaveClicked); + toolbar->addSeparator(); auto menu = new QMenu("Settings", this); menu->setToolTipsVisible(true); @@ -2142,6 +2146,28 @@ void MainWindow::onFrameTimeChanged() ////////////////////////////////////////////////////////////////////////// +void MainWindow::onCropAndSaveClicked(bool) +{ + QString lastFile = m_lastFiles.empty() ? QString() : m_lastFiles.front(); + + const auto i = lastFile.lastIndexOf(QChar('/')); + const auto j = lastFile.lastIndexOf(QChar('\\')); + auto k = std::max(i, j); + + QString dir; + if (k > 0) + dir = lastFile.mid(0, ++k); + + auto filename = QFileDialog::getSaveFileName(this, "Save cropped area to EasyProfiler File", dir, + "EasyProfiler File (*.prof);;All Files (*.*)"); + if (filename.isEmpty()) + return; + + static_cast(m_graphicsView->widget())->view()->saveSelectionToFile(filename); +} + +////////////////////////////////////////////////////////////////////////// + void MainWindow::onConnectClicked(bool) { if (EASY_GLOBALS.connected) diff --git a/profiler_gui/main_window.h b/profiler_gui/main_window.h index bfeb21a0..94838336 100644 --- a/profiler_gui/main_window.h +++ b/profiler_gui/main_window.h @@ -326,6 +326,7 @@ protected slots: void onEventTracingEnableChange(bool _checked); void onFrameTimeEditFinish(); void onFrameTimeChanged(); + void onCropAndSaveClicked(bool); void onBlockStatusChange(profiler::block_id_t _id, profiler::EasyBlockStatus _status); diff --git a/profiler_gui/resources.qrc b/profiler_gui/resources.qrc index be736129..78b03c7f 100644 --- a/profiler_gui/resources.qrc +++ b/profiler_gui/resources.qrc @@ -7,6 +7,7 @@ images/default/binoculars.svg + images/default/crop.svg images/default/off.svg images/default/open-folder2.svg images/default/reload.svg From 3287d8aa5b49a7d0d7fd6f284d6a0dab4c9ca880 Mon Sep 17 00:00:00 2001 From: vladislav-horbatiuk Date: Mon, 16 Apr 2018 14:04:03 +0300 Subject: [PATCH 2/2] Build static/shared lib based on option value Actually build static/shared library version depending on "BUILD_SHARED_LIBS" option value. --- easy_profiler_core/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/easy_profiler_core/CMakeLists.txt b/easy_profiler_core/CMakeLists.txt index 1d1b08e7..ebacffe2 100644 --- a/easy_profiler_core/CMakeLists.txt +++ b/easy_profiler_core/CMakeLists.txt @@ -159,7 +159,12 @@ set(SOURCES ${INCLUDE_FILES} ) -add_library(easy_profiler ${SOURCES} resources.rc) +set(LIBRARY_TYPE SHARED) +if (NOT BUILD_SHARED_LIBS) + set(LIBRARY_TYPE STATIC) +endif () + +add_library(easy_profiler ${LIBRARY_TYPE} ${SOURCES} resources.rc) # End adding source files. #################################################