2016-06-30 21:39:04 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : main_window.h
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/06/26
|
|
|
|
* author : Victor Zarubkin
|
|
|
|
* email : v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
|
|
|
* description : The file contains declaration of MainWindow for easy_profiler GUI.
|
|
|
|
* ----------------- :
|
|
|
|
* change log : * 2016/06/26 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-06-26 20:54:16 +03:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef EASY_PROFILER_GUI__MAIN_WINDOW__H
|
|
|
|
#define EASY_PROFILER_GUI__MAIN_WINDOW__H
|
|
|
|
|
|
|
|
#include <string>
|
2016-08-18 23:26:41 +03:00
|
|
|
#include <thread>
|
|
|
|
#include <atomic>
|
2016-09-18 20:20:37 +03:00
|
|
|
#include <sstream>
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QTimer>
|
2016-12-11 03:27:42 +03:00
|
|
|
#include <QStringList>
|
2016-09-18 20:20:37 +03:00
|
|
|
|
2017-03-05 23:50:38 +03:00
|
|
|
#include <easy/easy_socket.h>
|
|
|
|
#include <easy/reader.h>
|
2016-09-18 20:20:37 +03:00
|
|
|
|
|
|
|
#ifdef max
|
2016-09-16 02:11:11 +03:00
|
|
|
#undef max
|
2016-09-18 20:20:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef min
|
2016-09-16 02:11:11 +03:00
|
|
|
#undef min
|
2016-09-18 20:20:37 +03:00
|
|
|
#endif
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-09-17 18:43:06 +03:00
|
|
|
#define EASY_GUI_USE_DESCRIPTORS_DOCK_WINDOW 0
|
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
class QDockWidget;
|
|
|
|
|
2016-09-28 00:37:20 +03:00
|
|
|
namespace profiler { namespace net { struct EasyProfilerStatus; } }
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-09-22 23:06:43 +03:00
|
|
|
class EasyFileReader Q_DECL_FINAL
|
2016-08-18 23:26:41 +03:00
|
|
|
{
|
2016-08-28 18:19:12 +03:00
|
|
|
::profiler::SerializedData m_serializedBlocks; ///<
|
|
|
|
::profiler::SerializedData m_serializedDescriptors; ///<
|
|
|
|
::profiler::descriptors_list_t m_descriptors; ///<
|
2016-08-30 22:51:18 +03:00
|
|
|
::profiler::blocks_t m_blocks; ///<
|
2016-08-28 18:19:12 +03:00
|
|
|
::profiler::thread_blocks_tree_t m_blocksTree; ///<
|
2016-09-25 11:49:49 +03:00
|
|
|
::std::stringstream m_stream; ///<
|
2016-09-27 22:28:04 +03:00
|
|
|
::std::stringstream m_errorMessage; ///<
|
2016-08-28 18:19:12 +03:00
|
|
|
QString m_filename; ///<
|
2016-10-02 12:13:12 +03:00
|
|
|
uint32_t m_descriptorsNumberInFile = 0; ///<
|
2016-08-28 18:19:12 +03:00
|
|
|
::std::thread m_thread; ///<
|
|
|
|
::std::atomic_bool m_bDone; ///<
|
|
|
|
::std::atomic<int> m_progress; ///<
|
|
|
|
::std::atomic<unsigned int> m_size; ///<
|
2016-09-25 11:49:49 +03:00
|
|
|
bool m_isFile = false; ///<
|
2016-08-18 23:26:41 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
EasyFileReader();
|
|
|
|
~EasyFileReader();
|
|
|
|
|
2016-09-25 11:49:49 +03:00
|
|
|
const bool isFile() const;
|
2016-08-18 23:26:41 +03:00
|
|
|
bool done() const;
|
|
|
|
int progress() const;
|
|
|
|
unsigned int size() const;
|
2016-08-23 22:44:04 +03:00
|
|
|
const QString& filename() const;
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2016-08-23 22:44:04 +03:00
|
|
|
void load(const QString& _filename);
|
2016-09-25 11:49:49 +03:00
|
|
|
void load(::std::stringstream& _stream);
|
2016-08-18 23:26:41 +03:00
|
|
|
void interrupt();
|
2016-08-28 18:19:12 +03:00
|
|
|
void get(::profiler::SerializedData& _serializedBlocks, ::profiler::SerializedData& _serializedDescriptors,
|
2016-08-30 22:51:18 +03:00
|
|
|
::profiler::descriptors_list_t& _descriptors, ::profiler::blocks_t& _blocks, ::profiler::thread_blocks_tree_t& _tree,
|
2016-10-02 12:13:12 +03:00
|
|
|
uint32_t& _descriptorsNumberInFile, QString& _filename);
|
2016-08-18 23:26:41 +03:00
|
|
|
|
2016-09-27 22:28:04 +03:00
|
|
|
QString getError();
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
}; // END of class EasyFileReader.
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-09-25 11:49:49 +03:00
|
|
|
enum EasyListenerRegime : uint8_t
|
|
|
|
{
|
|
|
|
LISTENER_IDLE = 0,
|
|
|
|
LISTENER_CAPTURE,
|
|
|
|
LISTENER_DESCRIBE
|
|
|
|
};
|
|
|
|
|
|
|
|
class EasySocketListener Q_DECL_FINAL
|
|
|
|
{
|
|
|
|
EasySocket m_easySocket; ///<
|
2016-12-08 22:22:09 +03:00
|
|
|
::std::string m_address; ///<
|
2016-09-25 11:49:49 +03:00
|
|
|
::std::stringstream m_receivedData; ///<
|
2016-09-29 23:29:57 +03:00
|
|
|
::std::thread m_thread; ///<
|
|
|
|
uint64_t m_receivedSize; ///<
|
2016-12-08 22:22:09 +03:00
|
|
|
uint16_t m_port; ///<
|
2016-09-25 11:49:49 +03:00
|
|
|
::std::atomic_bool m_bInterrupt; ///<
|
|
|
|
::std::atomic_bool m_bConnected; ///<
|
2016-12-18 18:27:19 +03:00
|
|
|
::std::atomic_bool m_bStopReceive; ///<
|
2016-09-25 11:49:49 +03:00
|
|
|
EasyListenerRegime m_regime; ///<
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
EasySocketListener();
|
|
|
|
~EasySocketListener();
|
|
|
|
|
|
|
|
bool connected() const;
|
|
|
|
EasyListenerRegime regime() const;
|
|
|
|
uint64_t size() const;
|
2016-12-08 22:22:09 +03:00
|
|
|
const ::std::string& address() const;
|
|
|
|
uint16_t port() const;
|
2016-09-25 11:49:49 +03:00
|
|
|
|
|
|
|
::std::stringstream& data();
|
|
|
|
void clearData();
|
|
|
|
|
2016-09-28 00:37:20 +03:00
|
|
|
bool connect(const char* _ipaddress, uint16_t _port, ::profiler::net::EasyProfilerStatus& _reply);
|
2016-09-25 11:49:49 +03:00
|
|
|
|
2016-12-18 18:27:19 +03:00
|
|
|
bool startCapture();
|
2016-09-25 11:49:49 +03:00
|
|
|
void stopCapture();
|
|
|
|
void requestBlocksDescription();
|
|
|
|
|
2016-09-28 00:37:20 +03:00
|
|
|
template <class T>
|
|
|
|
inline void send(const T& _message) {
|
|
|
|
m_easySocket.send(&_message, sizeof(T));
|
|
|
|
}
|
2016-09-25 11:49:49 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void listenCapture();
|
|
|
|
void listenDescription();
|
|
|
|
|
|
|
|
}; // END of class EasySocketListener.
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
class EasyMainWindow : public QMainWindow
|
2016-06-26 20:54:16 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
typedef EasyMainWindow This;
|
|
|
|
typedef QMainWindow Parent;
|
2016-06-30 02:57:57 +03:00
|
|
|
|
2016-12-11 03:27:42 +03:00
|
|
|
QStringList m_lastFiles;
|
2016-09-27 21:57:46 +03:00
|
|
|
QString m_lastAddress;
|
2016-09-18 20:20:37 +03:00
|
|
|
QDockWidget* m_treeWidget = nullptr;
|
|
|
|
QDockWidget* m_graphicsView = nullptr;
|
2016-09-17 18:43:06 +03:00
|
|
|
|
|
|
|
#if EASY_GUI_USE_DESCRIPTORS_DOCK_WINDOW != 0
|
2016-09-18 20:20:37 +03:00
|
|
|
QDockWidget* m_descTreeWidget = nullptr;
|
2016-09-17 18:43:06 +03:00
|
|
|
#endif
|
|
|
|
|
2016-09-18 20:20:37 +03:00
|
|
|
class QProgressDialog* m_progress = nullptr;
|
|
|
|
class QDialog* m_descTreeDialog = nullptr;
|
|
|
|
class EasyDescWidget* m_dialogDescTree = nullptr;
|
2016-09-25 11:49:49 +03:00
|
|
|
class QMessageBox* m_listenerDialog = nullptr;
|
2016-08-28 18:19:12 +03:00
|
|
|
QTimer m_readerTimer;
|
2016-09-25 11:49:49 +03:00
|
|
|
QTimer m_listenerTimer;
|
2016-08-28 18:19:12 +03:00
|
|
|
::profiler::SerializedData m_serializedBlocks;
|
|
|
|
::profiler::SerializedData m_serializedDescriptors;
|
|
|
|
EasyFileReader m_reader;
|
2016-09-25 11:49:49 +03:00
|
|
|
EasySocketListener m_listener;
|
2016-09-13 21:42:38 +03:00
|
|
|
|
2016-12-11 03:27:42 +03:00
|
|
|
class QLineEdit* m_addressEdit = nullptr;
|
2016-09-18 20:20:37 +03:00
|
|
|
class QLineEdit* m_portEdit = nullptr;
|
2016-11-13 22:02:47 +03:00
|
|
|
class QLineEdit* m_frameTimeEdit = nullptr;
|
2016-09-18 20:20:37 +03:00
|
|
|
|
2016-12-11 03:27:42 +03:00
|
|
|
class QMenu* m_loadActionMenu = nullptr;
|
2016-09-29 22:40:19 +03:00
|
|
|
class QAction* m_saveAction = nullptr;
|
|
|
|
class QAction* m_deleteAction = nullptr;
|
|
|
|
|
2016-09-18 20:20:37 +03:00
|
|
|
class QAction* m_captureAction = nullptr;
|
|
|
|
class QAction* m_connectAction = nullptr;
|
2016-09-28 00:37:20 +03:00
|
|
|
class QAction* m_eventTracingEnableAction = nullptr;
|
|
|
|
class QAction* m_eventTracingPriorityAction = nullptr;
|
2016-09-18 18:08:47 +03:00
|
|
|
|
2016-10-02 12:13:12 +03:00
|
|
|
uint32_t m_descriptorsNumberInFile = 0;
|
2016-09-27 21:57:46 +03:00
|
|
|
uint16_t m_lastPort = 0;
|
2016-10-02 12:13:12 +03:00
|
|
|
bool m_bNetworkFileRegime = false;
|
2016-09-27 21:57:46 +03:00
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
public:
|
|
|
|
|
2016-09-17 15:39:31 +03:00
|
|
|
explicit EasyMainWindow();
|
2016-08-18 23:26:41 +03:00
|
|
|
virtual ~EasyMainWindow();
|
2016-06-26 20:54:16 +03:00
|
|
|
|
2016-08-04 23:46:04 +03:00
|
|
|
// Public virtual methods
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent* close_event) override;
|
2016-11-19 05:39:41 +03:00
|
|
|
void dragEnterEvent(QDragEnterEvent* drag_event) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent* drag_event) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent* drag_event) override;
|
|
|
|
void dropEvent(QDropEvent* drop_event) override;
|
2016-08-04 23:46:04 +03:00
|
|
|
|
2016-06-26 20:54:16 +03:00
|
|
|
protected slots:
|
|
|
|
|
|
|
|
void onOpenFileClicked(bool);
|
2016-09-29 22:40:19 +03:00
|
|
|
void onSaveFileClicked(bool);
|
2016-09-21 22:09:04 +03:00
|
|
|
void onDeleteClicked(bool);
|
2016-06-26 20:54:16 +03:00
|
|
|
void onExitClicked(bool);
|
2016-08-09 00:45:45 +03:00
|
|
|
void onEncodingChanged(bool);
|
2016-08-24 01:00:24 +03:00
|
|
|
void onChronoTextPosChanged(bool);
|
2016-11-30 21:59:40 +03:00
|
|
|
void onUnitsChanged(bool);
|
2016-09-23 23:50:43 +03:00
|
|
|
void onEventIndicatorsChange(bool);
|
2016-09-14 23:13:38 +03:00
|
|
|
void onEnableDisableStatistics(bool);
|
2016-08-23 22:44:04 +03:00
|
|
|
void onCollapseItemsAfterCloseChanged(bool);
|
|
|
|
void onAllItemsExpandedByDefaultChange(bool);
|
2016-08-23 23:50:30 +03:00
|
|
|
void onBindExpandStatusChange(bool);
|
2016-11-20 21:01:33 +03:00
|
|
|
void onHierarchyFlagChange(bool);
|
2016-08-21 22:44:03 +03:00
|
|
|
void onExpandAllClicked(bool);
|
|
|
|
void onCollapseAllClicked(bool);
|
2016-11-19 04:52:45 +03:00
|
|
|
void onSpacingChange(int _value);
|
|
|
|
void onMinSizeChange(int _value);
|
|
|
|
void onNarrowSizeChange(int _value);
|
2016-08-18 23:26:41 +03:00
|
|
|
void onFileReaderTimeout();
|
2016-09-25 11:49:49 +03:00
|
|
|
void onListenerTimerTimeout();
|
2016-08-18 23:26:41 +03:00
|
|
|
void onFileReaderCancel();
|
2016-09-17 15:39:31 +03:00
|
|
|
void onEditBlocksClicked(bool);
|
2016-09-17 18:43:06 +03:00
|
|
|
void onDescTreeDialogClose(int);
|
2016-09-25 11:49:49 +03:00
|
|
|
void onListenerDialogClose(int);
|
2016-09-08 21:03:05 +03:00
|
|
|
void onCaptureClicked(bool);
|
2016-09-25 11:49:49 +03:00
|
|
|
void onGetBlockDescriptionsClicked(bool);
|
2016-09-13 21:42:38 +03:00
|
|
|
void onConnectClicked(bool);
|
2016-09-28 00:37:20 +03:00
|
|
|
void onEventTracingPriorityChange(bool _checked);
|
|
|
|
void onEventTracingEnableChange(bool _checked);
|
2016-11-13 22:02:47 +03:00
|
|
|
void onFrameTimeEditFinish();
|
2017-03-07 01:09:27 +03:00
|
|
|
void onFrameTimeChanged();
|
2016-09-13 21:42:38 +03:00
|
|
|
|
2016-09-25 11:49:49 +03:00
|
|
|
void onBlockStatusChange(::profiler::block_id_t _id, ::profiler::EasyBlockStatus _status);
|
|
|
|
|
2016-06-30 21:39:04 +03:00
|
|
|
private:
|
|
|
|
|
2016-08-04 23:46:04 +03:00
|
|
|
// Private non-virtual methods
|
|
|
|
|
2016-10-02 12:13:12 +03:00
|
|
|
void clear();
|
|
|
|
|
2016-11-23 22:54:59 +03:00
|
|
|
void refreshDiagram();
|
|
|
|
|
2016-12-11 03:27:42 +03:00
|
|
|
void addFileToList(const QString& filename);
|
2016-08-23 22:44:04 +03:00
|
|
|
void loadFile(const QString& filename);
|
2016-09-25 11:49:49 +03:00
|
|
|
void readStream(::std::stringstream& data);
|
2016-08-04 23:12:41 +03:00
|
|
|
|
2016-08-07 19:35:58 +03:00
|
|
|
void loadSettings();
|
2016-08-23 23:50:30 +03:00
|
|
|
void loadGeometry();
|
2016-09-06 22:23:55 +03:00
|
|
|
void saveSettingsAndGeometry();
|
2016-06-30 21:39:04 +03:00
|
|
|
|
2016-12-08 22:22:09 +03:00
|
|
|
void setDisconnected(bool _showMessage = true);
|
2016-11-18 22:58:44 +03:00
|
|
|
|
2016-08-18 23:26:41 +03:00
|
|
|
}; // END of class EasyMainWindow.
|
2016-06-26 20:54:16 +03:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#endif // EASY_PROFILER_GUI__MAIN_WINDOW__H
|