diff --git a/plugins/CriticalPath/CMakeLists.txt b/plugins/CriticalPath/CMakeLists.txt index 1575f094d8169dd4509d9ec3d2433922dcd12a41..02fa4b071e4cf652e6ba09c23556339fce5b1c4f 100644 --- a/plugins/CriticalPath/CMakeLists.txt +++ b/plugins/CriticalPath/CMakeLists.txt @@ -38,6 +38,7 @@ set(CRITICALPATH_FORMS_TMP ${CMAKE_SOURCE_DIR}/src/interface/ui/interval_select.ui ${CMAKE_SOURCE_DIR}/src/interface/ui/main_window.ui ${CMAKE_SOURCE_DIR}/src/interface/ui/node_select.ui + ${CMAKE_SOURCE_DIR}/src/interface/ui/select_info_window.ui ${CMAKE_SOURCE_DIR}/src/interface/ui/settings.ui ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4c552f373a0742c1b2f5fe021c32c9a0d7fe833a..57dc7831954b8048240735c0fa8a536cb27f00d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,6 +108,7 @@ set(VITE_HDRS render/Render_abstract.hpp # Interface headers interface/resource.hpp + interface/SelectInfo.hpp interface/Settings_window.hpp interface/Interface_graphic.hpp interface/Node_select.hpp @@ -208,6 +209,7 @@ set(VITE_SRCS interface/IntervalSelect.cpp interface/IntervalSelectLayout.cpp interface/Node_select.cpp + interface/SelectInfo.cpp interface/Settings_window.cpp interface/RangeSliderWidget.cpp interface/viteqtreewidget.cpp diff --git a/src/interface/Interface_graphic.cpp b/src/interface/Interface_graphic.cpp index 64cbfb40bbc24f40e1017467ad60d616c492533a..7f620f6ca4b4f5db2085fd083539a312f2fc1c94 100644 --- a/src/interface/Interface_graphic.cpp +++ b/src/interface/Interface_graphic.cpp @@ -157,20 +157,8 @@ void Interface_graphic::load_windows() { exit(EXIT_FAILURE); } - /* Load the window about information on a selection from a .ui file */ - if (file_select_info.exists()) { - file_select_info.open(QFile::ReadOnly); - CKFP(_ui_select_info_window = loader->load(&file_select_info, this), "Cannot open the .ui file: :/window/select_info_window.ui"); - file_select_info.close(); - } - else { - cerr << __FILE__ << ":" << __LINE__ << ": The following .ui file doesn't exist: :/window/select_info_window.ui" << endl; - exit(EXIT_FAILURE); - } - /* Set some windows properties */ _ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint); /* Always display info_window on top */ - _ui_select_info_window->setWindowFlags(_ui_select_info_window->windowFlags() | Qt::WindowStaysOnTopHint); /* Always display select_info_window on top */ /* Load widget from the .ui file */ CKFP(_ui_render_area_container_layout = this->findChild<QVBoxLayout *>(QStringLiteral("render_container_layout")), "Cannot find the render_area_container_layout in the .ui file"); @@ -178,7 +166,6 @@ void Interface_graphic::load_windows() { CKFP(_ui_fullscreen_menu = this->findChild<QAction *>(QStringLiteral("fullscreen")), "Cannot find the fullscreen menu in the .ui file"); CKFP(_ui_info_trace_text = _ui_info_window->findChild<QTextEdit *>(QStringLiteral("info_trace_text")), "Cannot find the info_trace_text QTextEdit widget in the .ui file"); - CKFP(_ui_info_selection_tabs = _ui_select_info_window->findChild<QTabWidget *>(QStringLiteral("info_selection_tab")), "Cannot find the info_selection_tab QTabWidget widget in the .ui file"); CKFP(_ui_toolbar = this->findChild<QToolBar *>(QStringLiteral("toolBar")), "Cannot find the tool bar in the .ui file"); CKFP(_ui_recent_files_menu = this->findChild<QMenu *>(QStringLiteral("menuRecent_Files")), "Cannot find the button \"menuRecent_Files\" in the .ui file"); @@ -240,32 +227,6 @@ void Interface_graphic::information(const string &s) const { _ui_info_trace_text->insertHtml(QStringLiteral("<font color='green'>") + buf + QStringLiteral("</font><br /><br />")); } -/*********************************** - * - * Selected Trace entity informative function. - * - **********************************/ - -void Interface_graphic::selection_information_clear() const { - _ui_info_selection_tabs->clear(); /* Remove all tabs in the QTabWidget*/ -} - -void Interface_graphic::selection_information_show() const { - _ui_select_info_window->show(); /* show select_info_window */ -} - -void Interface_graphic::selection_information(const std::string &tab_name, const string &content) const { - // Create and setup the tab - QTextEdit *text_widget = new QTextEdit(_ui_info_selection_tabs); - text_widget->setReadOnly(true); - text_widget->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); - - // Fill the text content and add the tab to the window - text_widget->insertHtml(QStringLiteral("<font color='blue'>") + QString::fromStdString(content) + QStringLiteral("</font>")); - text_widget->moveCursor(QTextCursor::Start); // Make the text edit scroll to the top - _ui_info_selection_tabs->addTab(text_widget, QString::fromStdString(tab_name)); -} - /*********************************** * * Widget slot functions. @@ -362,9 +323,7 @@ void Interface_graphic::remove_render_area(RenderLayout *render_layout) { * Clear the informative window texts and hide it. */ _ui_info_trace_text->clear(); /* Clear the current text (if exists) */ - _ui_info_selection_tabs->clear(); /* Clear the current text (if exists) */ _ui_info_window->hide(); /* Hide the informative window */ - _ui_select_info_window->hide(); /* Hide the selection information window */ if (_ui_settings) { _ui_settings->hide(); @@ -402,8 +361,6 @@ void Interface_graphic::on_quit_triggered() { ((QWidget *)_ui_interval_selection)->close(); if (nullptr != _ui_info_window) ((QWidget *)_ui_info_window)->close(); - if (nullptr != _ui_select_info_window) - ((QWidget *)_ui_select_info_window)->close(); ((QWidget *)this)->close(); } diff --git a/src/interface/Interface_graphic.hpp b/src/interface/Interface_graphic.hpp index ed4732b700f0caf64687c465d610d14a58ae7c74..82549410ad191e1b7e3339ef186b1552312ac4aa 100644 --- a/src/interface/Interface_graphic.hpp +++ b/src/interface/Interface_graphic.hpp @@ -135,11 +135,6 @@ protected: */ QWidget *_ui_info_window; - /*! - * \brief This variable contains the floatting box window for information on user selection in the application. - */ - QWidget *_ui_select_info_window; - /*! * \brief Dialog box to allow user to set its ViTE environment. (change color, text size, etc.) */ @@ -160,11 +155,6 @@ protected: */ QTextEdit *_ui_info_trace_text; - /*! - * \brief Text area which informs the user about the selected entity information. - */ - QTabWidget *_ui_info_selection_tabs; - /*! * \brief The menu where recent files are printed */ @@ -250,28 +240,6 @@ public: */ void information(const std::string &string) const override; - /*********************************** - * - * Selected Trace entity informative function. - * - **********************************/ - - /*! - * \brief Clear all entity tabs in the select_info_window. - */ - void selection_information_clear() const; - - /*! - * \brief Show the select_info_window. - */ - void selection_information_show() const; - - /*! - * \brief The function takes strings and/or numbers then displayed it in the entity informative text area in the info window. - * \param string The string to be displayed. - */ - void selection_information(const std::string &tab_name, const std::string &content) const; - /*********************************** * * Parsing functions. diff --git a/src/interface/SelectInfo.cpp b/src/interface/SelectInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f3cb1078e31716761721b7df5cc433d4cfe92acc --- /dev/null +++ b/src/interface/SelectInfo.cpp @@ -0,0 +1,102 @@ +/** + * + * @file src/interface/SelectInfo.cpp + * + * @copyright 2008-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @author Camille Ordronneau + * + * @date 2024-08-06 + */ +/*! + *\file SelectInfo.cpp + *\brief This file defines a class for the window popping up when the user double click on an entity + * This window displays information on the Entity clicked + * When several Entities are clicked on at the same time, information for each are displayed in tabs + */ + +#include "interface/SelectInfo.hpp" +/* -- */ +#include "render/RenderLayout.hpp" +/* -- */ +#include <QTextEdit> + +SelectInfo::SelectInfo(RenderLayout *render_layout) : + QDialog(nullptr), _render_layout(render_layout) { + setupUi(this); +} + +SelectInfo::~SelectInfo() = default; + +void SelectInfo::clear() { + info_selection_tab->clear(); /* Remove all tabs in the QTabWidget*/ + _entity_dates.clear(); +} + +void SelectInfo::add_info_tab(const std::string &tab_name, const std::string &content, const Element_pos &begin, const Element_pos &end) { + // Create and setup the tab + QTextEdit *text_widget = new QTextEdit(info_selection_tab); + text_widget->setReadOnly(true); + text_widget->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + + // Fill the text content and add the tab to the window + text_widget->insertHtml(QStringLiteral("<font color='blue'>") + QString::fromStdString(content) + QStringLiteral("</font>")); + text_widget->moveCursor(QTextCursor::Start); // Make the text edit scroll to the top + info_selection_tab->addTab(text_widget, QString::fromStdString(tab_name)); + + // The name of the widget is set to tab_name because the text of the label can't be accessed + // This name needs to be accessible to know on which entity to center if the buttons were to be pressed + text_widget->setObjectName(QString::fromStdString(tab_name)); + + // Pair linking a begin time with an end time + const std::pair<Element_pos, Element_pos> dates(begin, end); + // Pair linking a tab_name and a couple of dates + const std::pair<std::string, std::pair<double, double>> entity_dates_pair(tab_name, std::move(dates)); + // Add the pair (tab_name, dates) to a map + _entity_dates.insert(std::move(entity_dates_pair)); +} + +void SelectInfo::set_title(const QString &title) { + // Spaces are added at the end otherwise the text can be clipped depending on the default font (under Debian for example) + this->setWindowTitle(title + QString::fromStdString(" ")); +} + +void SelectInfo::on_info_selection_tab_currentChanged() { + // If there is no tab, hide the buttons + if (info_selection_tab->count() == 0) { + center_begin->hide(); + center_end->hide(); + return; + } + + _current_tab_dates = _entity_dates[info_selection_tab->currentWidget()->objectName().toStdString()]; + + // When the dates of start and finish are the same (for Event and Variable) only show one button + if (_current_tab_dates.first == _current_tab_dates.second) { + center_begin->setText(QString::fromStdString("Center on ") + info_selection_tab->currentWidget()->objectName()); + center_begin->show(); + center_end->hide(); + return; + } + + // For State and Link Entity show every buttons + center_begin->setText(QString::fromStdString("Center on ") + info_selection_tab->currentWidget()->objectName() + QString::fromStdString(" Start")); + center_begin->show(); + + center_end->setText(QString::fromStdString("Center on ") + info_selection_tab->currentWidget()->objectName() + QString::fromStdString(" End")); + center_end->show(); +} + +void SelectInfo::show_window() { + on_info_selection_tab_currentChanged(); + show(); +} + +void SelectInfo::on_center_begin_pressed() { + _render_layout->get_render_area()->set_center_on(_current_tab_dates.first); +} + +void SelectInfo::on_center_end_pressed() { + _render_layout->get_render_area()->set_center_on(_current_tab_dates.second); +} diff --git a/src/interface/SelectInfo.hpp b/src/interface/SelectInfo.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eb2657005dfcbebb495d2bfc9a49dbf27834308f --- /dev/null +++ b/src/interface/SelectInfo.hpp @@ -0,0 +1,104 @@ +/** + * + * @file src/interface/SelectInfo.hpp + * + * @copyright 2008-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, + * Univ. Bordeaux. All rights reserved. + * + * @author Camille Ordronneau + * + * @date 2024-08-06 + */ +/*! + *\file SelectInfo.hpp + */ + +#ifndef SELECT_INFO_HPP +#define SELECT_INFO_HPP + +#include <QDialog> +#include <QShowEvent> +#include <QTabWidget> +/* -- */ +#include "ui_select_info_window.h" +/* -- */ +#include "common/common.hpp" +/* -- */ +#include "trace/values/Date.hpp" + +class RenderLayout; + +/*! + * \class SelectInfo + * \brief Class used to view information on a selected Entity + * + */ + +class SelectInfo : public QDialog, protected Ui::select_info_window +{ + + Q_OBJECT + +private: + RenderLayout *_render_layout; + + /*! + * \brief This variable contains a map linking the name of a tab to the date a begin and end of the Entity in the tab + * This is used to be able to centre on Entity depending on the selected tab + */ + std::map<const std::string, const std::pair<Element_pos, Element_pos>> _entity_dates; + + /*! + * \brief Buffer to have access to the dates of the current tab when buttons are pressed + */ + std::pair<Element_pos, Element_pos> _current_tab_dates; + +public: + /*! + * Default constructor + * \param parent The parent widget of the window. + */ + SelectInfo(RenderLayout *render_layout); + + ~SelectInfo(); + + /*! + * \brief Clear all entity tabs in the select_info_window. + */ + void clear(); + + /*! + * \brief The function takes strings and/or numbers then displayed it in the entity informative text area in the info window. + * \param string The string to be displayed. + */ + void add_info_tab(const std::string &tab_name, const std::string &content, const Element_pos &begin, const Element_pos &end); + + /*! + * \brief Show the window and the great number of button depending on the typeof entity + */ + void show_window(); + + /*! + * \brief Set the title of the SelectInfo window + * \param title the new title + */ + void set_title(const QString &title); + +private Q_SLOTS: + /*! + * \brief Update the way buttons are displayed depending on the type of Entity current tab shows + */ + void on_info_selection_tab_currentChanged(); + + /*! + * \brief Set the start of the Entity to be the center of the view + */ + void on_center_begin_pressed(); + + /*! + * \brief Set the end of the Entity to be the center of the view + */ + void on_center_end_pressed(); +}; + +#endif // NODE_SELECT_HPP diff --git a/src/interface/ui/select_info_window.ui b/src/interface/ui/select_info_window.ui index 66d9c27cac569ddcce201e630998c27b6c92b578..515726f1f02f5d13a5e166448724d65f9d5084a1 100644 --- a/src/interface/ui/select_info_window.ui +++ b/src/interface/ui/select_info_window.ui @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>select_info_window</class> - <widget class="QMainWindow" name="select_info_window"> + <widget class="QDialog" name="select_info_window"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>565</width> - <height>400</height> + <height>450</height> </rect> </property> <property name="windowTitle"> @@ -17,49 +17,61 @@ <iconset resource="vite.qrc"> <normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset> </property> - <widget class="QWidget" name="centralwidget"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QGroupBox" name="verticalGroupBox"> + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="rightMargin"> - <number>0</number> + <widget class="QTabWidget" name="info_selection_tab"> + <property name="currentIndex"> + <number>-1</number> </property> - <property name="bottomMargin"> - <number>0</number> + <property name="movable"> + <bool>true</bool> </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="button_layout"> + <item> + <widget class="QPushButton" name="center_begin"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Center on Begin</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> <item> - <widget class="QGroupBox" name="info_selection"> - <property name="title"> - <string>Selection Information </string> + <widget class="QPushButton" name="center_end"> + <property name="focusPolicy"> + <enum>Qt::NoFocus</enum> + </property> + <property name="text"> + <string>Center on End</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QTabWidget" name="info_selection_tab"> - <property name="currentIndex"> - <number>-1</number> - </property> - <property name="movable"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> </widget> </item> </layout> </item> </layout> - </item> - </layout> - </widget> + </widget> + </item> + </layout> </widget> <resources> <include location="vite.qrc"/> diff --git a/src/render/Hook_event.cpp b/src/render/Hook_event.cpp index e408718edc1cbff763bf4ccc6c90ff15cda003f0..a9b95a6dcb05545110b9f038dfd826789babb828 100644 --- a/src/render/Hook_event.cpp +++ b/src/render/Hook_event.cpp @@ -238,7 +238,7 @@ void Hook_event::mouseDoubleClickEvent(QMouseEvent *event) { if (Qt::LeftButton == event->button()) { DrawTrace buf; - buf.display_information(_interface_graphic, _layout->get_trace(), render_to_trace_x(screen_to_render_x(_mouse_x)), render_to_trace_y(screen_to_render_y(_mouse_y)), 1 / coeff_trace_render_x()); + buf.display_information(_layout->get_select_info_window(), _layout->get_trace(), render_to_trace_x(screen_to_render_x(_mouse_x)), render_to_trace_y(screen_to_render_y(_mouse_y)), 1 / coeff_trace_render_x()); _mouse_pressed = false; update_render(); diff --git a/src/render/RenderLayout.cpp b/src/render/RenderLayout.cpp index 50397e03dc392115c39eb7ee5bae067232c02d33..8c9aa59967d1aef8e3412a4faaee70a40e1161cd 100644 --- a/src/render/RenderLayout.cpp +++ b/src/render/RenderLayout.cpp @@ -25,6 +25,8 @@ /* -- */ #include "common/Export.hpp" /* -- */ +#include "interface/SelectInfo.hpp" +/* -- */ #include "trace/Trace.hpp" #define BUTTON_SIZE 24 @@ -32,7 +34,8 @@ RenderLayout::RenderLayout(Interface_graphic *interface_graphic, QWidget *parent_widget, QVBoxLayout *parent_layout, Render_windowed *render_area) : QObject(), _interface_graphic(interface_graphic), - _slider_x_position(0), _slider_y_position(0) { + _slider_x_position(0), _slider_y_position(0), + _select_info_window(this) { // In the following code Qt objects are allocated using new // Qt desallocate automatically these object @@ -66,6 +69,7 @@ RenderLayout::RenderLayout(Interface_graphic *interface_graphic, QWidget *parent connect(close_button, &QPushButton::pressed, this, [=]() { splitter->hide(); _interface_graphic->remove_render_area(this); + _select_info_window.close(); }); buttons_scroll_layout->addWidget(close_button); @@ -253,6 +257,7 @@ RenderLayout::~RenderLayout() { if (nullptr != _trace) { delete _trace; } + _select_info_window.close(); } QSlider *RenderLayout::get_scale_container_slider() const { @@ -279,8 +284,13 @@ Render_windowed *RenderLayout::get_render_area() { return _render_area; } +SelectInfo *RenderLayout::get_select_info_window() { + return &_select_info_window; +} + void RenderLayout::set_trace(Trace *trace) { _trace = trace; + _select_info_window.set_title(QString::fromStdString(trace->get_filename())); } Trace *RenderLayout::get_trace() const { diff --git a/src/render/RenderLayout.hpp b/src/render/RenderLayout.hpp index 1927d6852524e8907ade96c9406402fd615f323e..cbc85a80cdd3a92d4731bce9266ce706fe60b8d4 100644 --- a/src/render/RenderLayout.hpp +++ b/src/render/RenderLayout.hpp @@ -19,6 +19,7 @@ #define _RENDER_LAYOUT_ #include "interface/Interface_graphic.hpp" +#include "interface/SelectInfo.hpp" /* -- */ #include "Render_windowed.hpp" /* -- */ @@ -57,6 +58,7 @@ private: // This event loop is used to wait for the OpenGL initialization QEventLoop _wait_gl_init; + SelectInfo _select_info_window; /*! * \brief Contains the conversion factor between x virtual and real scroll unit. @@ -106,6 +108,11 @@ public: Trace *get_trace() const; void delete_trace(); + /*! + * \brief Getter for the select info window + */ + SelectInfo *get_select_info_window(); + /*! * \brief Getter for the QEventLoop wait_gl_init */ diff --git a/src/render/Render_abstract.cpp b/src/render/Render_abstract.cpp index 6cc67b392c8721878d274fcd6a954e737146ca6c..119ea60e7a5c9ead3b1929ad15e58c2245a16650 100644 --- a/src/render/Render_abstract.cpp +++ b/src/render/Render_abstract.cpp @@ -282,13 +282,19 @@ void Render_abstract::replace_translate_y(const Element_pos &new_translate) { } void Render_abstract::goto_start() { - _x_state_translate = _default_entity_x_translate - (Element_pos)Info::Render::width / 2.0; + _x_state_translate = (_default_entity_x_translate - (Element_pos)Info::Render::width) / 2.0; + refresh_scroll_bars(); + update_render(); +} + +void Render_abstract::set_center_on(const Element_pos &date) { + _x_state_translate = (_default_entity_x_translate - (Element_pos)Info::Render::width) / 2.0 + date * coeff_trace_render_x(); refresh_scroll_bars(); update_render(); } void Render_abstract::goto_end() { - _x_state_translate = (_default_entity_x_translate - (Element_pos)Info::Render::width / 2.0 + (Info::Render::width - _default_entity_x_translate) * _x_state_scale); + _x_state_translate = (_default_entity_x_translate - (Element_pos)Info::Render::width) / 2.0 + (Info::Render::width - _default_entity_x_translate) * _x_state_scale; refresh_scroll_bars(); update_render(); } diff --git a/src/render/Render_abstract.hpp b/src/render/Render_abstract.hpp index 8b2a8271c304d5f33078381f155971bf5da38a28..afdd2e4d28cc3be125eb1f9d6c4ed0c72a328e86 100644 --- a/src/render/Render_abstract.hpp +++ b/src/render/Render_abstract.hpp @@ -155,6 +155,12 @@ public: */ void goto_start() override; + /*! + * \brief Set the visible center of the view to a given date + * \param date The date to which set the center + */ + void set_center_on(const Element_pos &date) override; + /*! * \brief Translate trace so the ending is in the middle of the window */ diff --git a/src/render/Render_windowed.hpp b/src/render/Render_windowed.hpp index 0e88654d1606a5030597a39f4b5e3ff9e43221e6..9c6665db0c25fb6f7f678842bd00f92bd671b36a 100644 --- a/src/render/Render_windowed.hpp +++ b/src/render/Render_windowed.hpp @@ -106,6 +106,12 @@ public: */ virtual void goto_start() = 0; + /*! + * \brief Set the visible center of the view to a given date + * \param date The date to which set the center + */ + virtual void set_center_on(const Element_pos &date) = 0; + /*! * \brief Translate trace so the ending is in the middle of the window */ diff --git a/src/trace/DrawTrace.cpp b/src/trace/DrawTrace.cpp index bad05ff95ba19c9397652c294bea12b701dece90..5eb58908661b4129cc1c1500de571d1065c64aac 100644 --- a/src/trace/DrawTrace.cpp +++ b/src/trace/DrawTrace.cpp @@ -23,7 +23,7 @@ #include "common/Log.hpp" #include "common/Message.hpp" /* -- */ -#include "interface/Interface_graphic.hpp" +#include "interface/SelectInfo.hpp" /* -- */ #include "render/GanttDiagram.hpp" /* -- */ @@ -61,7 +61,7 @@ void print_extra_fields(const std::string &name, const std::map<std::string, Val } } -void display_link_info(const Link *link, const Interface_graphic *window, const int &index) { +void display_link_info(const Link *link, SelectInfo *select_info, const int &index) { std::stringstream message_buffer; message_buffer.str(""); message_buffer << "<center><strong>Link</strong></center>" @@ -74,10 +74,10 @@ void display_link_info(const Link *link, const Interface_graphic *window, const print_extra_fields("Link", link->get_extra_fields(), &message_buffer); print_extra_fields("Value", link->get_value()->get_extra_fields(), &message_buffer); print_extra_fields("Type", link->get_type()->get_extra_fields(), &message_buffer); - window->selection_information("Link " + std::to_string(index), message_buffer.str()); + select_info->add_info_tab("Link " + std::to_string(index), message_buffer.str(), link->get_start_time().get_value(), link->get_end_time().get_value()); } -void display_event_info(const Event *event, const Interface_graphic *window, const int &index) { +void display_event_info(const Event *event, SelectInfo *select_info, const int &index) { std::stringstream message_buffer; message_buffer.str(""); message_buffer << "<center><strong>Event</strong></center>" @@ -88,9 +88,9 @@ void display_event_info(const Event *event, const Interface_graphic *window, con print_extra_fields("Event", event->get_extra_fields(), &message_buffer); print_extra_fields("Value", event->get_value()->get_extra_fields(), &message_buffer); print_extra_fields("Type", event->get_type()->get_extra_fields(), &message_buffer); - window->selection_information("Event " + std::to_string(index), message_buffer.str()); + select_info->add_info_tab("Event " + std::to_string(index), message_buffer.str(), event->get_time().get_value(), event->get_time().get_value()); } -void display_state_info(const State *state, const Interface_graphic *window) { +void display_state_info(const State *state, SelectInfo *select_info) { std::stringstream message_buffer; message_buffer.str(""); message_buffer << "<center><strong>State</strong></center>" @@ -102,9 +102,9 @@ void display_state_info(const State *state, const Interface_graphic *window) { print_extra_fields("State", state->get_extra_fields(), &message_buffer); print_extra_fields("Value", state->get_value()->get_extra_fields(), &message_buffer); print_extra_fields("Type", state->get_type()->get_extra_fields(), &message_buffer); - window->selection_information("State", message_buffer.str()); + select_info->add_info_tab("State", message_buffer.str(), state->get_start_time().get_value(), state->get_end_time().get_value()); } -void display_variable_info(const Variable *variable, const Times &x, const Interface_graphic *window) { +void display_variable_info(const Variable *variable, const Times &x, SelectInfo *select_info) { std::stringstream message_buffer; message_buffer.str(""); message_buffer << "<center><strong>Variable</strong></center>" @@ -115,7 +115,7 @@ void display_variable_info(const Variable *variable, const Times &x, const Inter << "<strong>Min:</strong> " << variable->get_min().get_value() << "<br />" << "<strong>Max:</strong> " << variable->get_max().get_value() << "<br />"; print_extra_fields("Type", variable->get_type()->get_extra_fields(), &message_buffer); - window->selection_information("Variable", message_buffer.str()); + select_info->add_info_tab("Variable", message_buffer.str(), x, x); } void DrawTrace::fill_link_list(const Container *container, const Element_pos &x, const Element_pos &y, const Element_pos &accuracy, Link::Vector *link_list) { @@ -186,7 +186,7 @@ void fill_event_list(const Node<Event> *node, const Element_pos &x, const Elemen return; } -void DrawTrace::display_information(const Interface_graphic *window, const Trace *trace, double x, double y, double d) { +void DrawTrace::display_information(SelectInfo *select_info, const Trace *trace, double x, double y, double d) { const Container *container = nullptr; const Container *ancestor = nullptr; @@ -195,7 +195,7 @@ void DrawTrace::display_information(const Interface_graphic *window, const Trace const State *state; const Variable *variable; - window->selection_information_clear(); + select_info->clear(); // find container needs to know the position of each container Element_pos yr = y; @@ -224,14 +224,14 @@ void DrawTrace::display_information(const Interface_graphic *window, const Trace if (((container->get_states() != NULL && !container->get_states()->empty()) || (container->get_events() != NULL && !container->get_events()->empty())) && yr < _container_height + _container_v_space) { #endif if ((state = find_state(container, x))) { - display_state_info(state, window); + display_state_info(state, select_info); } if (!Info::Render::_no_events) { if (container->get_events() != nullptr) { fill_event_list(container->get_events()->get_root(), x, d, &event_list); int i = 1; for (auto const &event: event_list) { - display_event_info(event, window, i); + display_event_info(event, select_info, i); i++; } } @@ -253,7 +253,7 @@ void DrawTrace::display_information(const Interface_graphic *window, const Trace } if (i != variable_map->end()) { variable = (*i).second; - display_variable_info(variable, (Times)x, window); + display_variable_info(variable, (Times)x, select_info); } } @@ -266,11 +266,11 @@ void DrawTrace::display_information(const Interface_graphic *window, const Trace } int i = 1; for (auto const &link: link_list) { - display_link_info(link, window, i); + display_link_info(link, select_info, i); i++; } } - window->selection_information_show(); + select_info->show_window(); return; } diff --git a/src/trace/DrawTrace.hpp b/src/trace/DrawTrace.hpp index cd04647f0b64661e132ee59a7e6ae65b8d563fc7..584d7ec1670409a3f285f57432eb9a260c6dc0b5 100644 --- a/src/trace/DrawTrace.hpp +++ b/src/trace/DrawTrace.hpp @@ -28,6 +28,8 @@ #include <cmath> /* -- */ +#include "interface/SelectInfo.hpp" +/* -- */ #include "render/Render_windowed.hpp" /* -- */ #include "trace/Container.hpp" @@ -174,13 +176,13 @@ public: /*! * \brief Browse and display information on entities in a range d from where the user has clicked - * \param window Interface_graphic used to get to the selection information window + * \param select_info the SelectInfo window in which the information are displayed * \param trace Trace to browse * \param x x coordinate of the click * \param y y coordinate of the click * \param d distance from the click, containing the entities */ - void display_information(const Interface_graphic *window, const Trace *trace, double x, double y, double d); + void display_information(SelectInfo *select_info, const Trace *trace, double x, double y, double d); /*! * \brief Return the closest container from the a designated container located on height y