From 856395a194637ca9d95ec417f908bb718daf83ce Mon Sep 17 00:00:00 2001
From: THIOLIERE Martin <Martin.Thioliere@bordeaux-inp.fr>
Date: Wed, 16 Mar 2022 18:01:34 +0100
Subject: [PATCH] Adding a new class `multirender_window`, child of
 `Ui_default_window`. This class implements a way to dynamically add/remove a
 render area in the main window. Modifying class `Interface_graphic`, so that
 the main window can display several render areas at a time.

---
 src/CMakeLists.txt                   |    1 +
 src/core/Core.cpp                    |    2 +-
 src/interface/Interface_graphic.cpp  |   15 +-
 src/interface/Interface_graphic.hpp  |   18 +-
 src/interface/main_window.ui         | 1144 +++++++++++++-------------
 src/interface/multirender_window.cpp |   62 ++
 src/interface/multirender_window.hpp |   32 +
 src/trace/DrawTrace.hpp              |    2 +-
 8 files changed, 684 insertions(+), 592 deletions(-)
 create mode 100644 src/interface/multirender_window.cpp
 create mode 100644 src/interface/multirender_window.hpp

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 237969bb..9d2e49e9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -203,6 +203,7 @@ set(VITE_SRCS
   interface/Settings_window.cpp
   interface/qxtspanslider.cpp
   interface/viteqtreewidget.cpp
+  interface/multirender_window.cpp
   # Plugin code file
   plugin/Command_window.cpp
   plugin/Plugin.cpp
diff --git a/src/core/Core.cpp b/src/core/Core.cpp
index 8f05beed..245354d1 100644
--- a/src/core/Core.cpp
+++ b/src/core/Core.cpp
@@ -791,7 +791,7 @@ void Core::launch_action(int state, void* arg) {
         //     else
         //         message <<  QObject::tr("An overlay format was originally asked, but was not created").toStdString () << Message::endw;
         // }
-        _main_window->bind_render_area(_render_windowed);
+        _main_window->bind_render_area(_render_windowed, 0);
 
         /* Wait that the open gl renderer calls waitGUIInit->quit() to load the file */
         waitGUIInit->exec();
diff --git a/src/interface/Interface_graphic.cpp b/src/interface/Interface_graphic.cpp
index ebbf73a0..f6882ffc 100644
--- a/src/interface/Interface_graphic.cpp
+++ b/src/interface/Interface_graphic.cpp
@@ -324,10 +324,17 @@ void Interface_graphic::opening_file(const string &path){
     QApplication::restoreOverrideCursor();
 }
 
-void Interface_graphic::bind_render_area(Render_windowed *render_area){
+void Interface_graphic::bind_render_area(Render_windowed *render_area, int index){
     /* Bind the render area to a layout (_ui_render_area_layout) */
-    _ui_render_area = render_area;
-    _ui_render_area_layout->addWidget(_ui_render_area->get_render_widget());
+    while (index >= _ui_render_areas.size())
+        _ui_render_areas.push_back(nullptr);
+    _ui_render_areas[index] = render_area;
+
+    _render_area_layouts[index]->addWidget(render_area->get_render_widget());
+}
+
+int Interface_graphic::get_nb_render_areas() {
+    return (int) _renders.size();
 }
 
 void Interface_graphic::set_scroll_bars_length(Element_pos new_x_virtual_length, Element_pos new_y_virtual_length){
@@ -534,7 +541,7 @@ void Interface_graphic::on_export_file_triggered(){
     }
     else if (extension == QLatin1String("png") || extension == QLatin1String("jpg") || extension == QLatin1String("jpeg")) {
 
-        QImage tempImage = _ui_render_area->grab_frame_buffer();
+        QImage tempImage = _ui_render_areas[0]->grab_frame_buffer();
 
         if ( !tempImage.save( filename, extension.toUpper().toStdString().c_str()) ){
             error("The trace cannot be exported into "+filename.toStdString()+" file.");
diff --git a/src/interface/Interface_graphic.hpp b/src/interface/Interface_graphic.hpp
index cbc5451f..d28e6b70 100644
--- a/src/interface/Interface_graphic.hpp
+++ b/src/interface/Interface_graphic.hpp
@@ -66,7 +66,7 @@ class QProgressDialog;
 #include "common/Session.hpp"
 #include "render/Render.hpp"
 /* -- */
-#include "ui_main_window.h" /* the main window graphical interface */
+#include "multirender_window.hpp" /* the main window graphical interface */
 
 /* Global informations */
 #include "interface/Interface.hpp"
@@ -78,7 +78,7 @@ class QProgressDialog;
 /*!
  *\brief This class is a graphical interface which creates a window, it inherited from the Interface interface.
  */
-class Interface_graphic : public QMainWindow,  protected Ui::main_window, public Interface{
+class Interface_graphic : public QMainWindow, public Ui::multirender_window, public Interface {
     Q_OBJECT
     protected:
 
@@ -127,12 +127,7 @@ class Interface_graphic : public QMainWindow,  protected Ui::main_window, public
     /*!
      * \brief This variable contains the OpenGL render area.
      */
-    Render_windowed* _ui_render_area;
-
-    /*!
-     * \brief Layout which will contain the render area.
-     */
-    QVBoxLayout* _ui_render_area_layout;
+    std::vector<Render_windowed*> _ui_render_areas;
 
     /*!
      * \brief This variable contains the instance of the horizontal scroll bar.
@@ -429,7 +424,12 @@ public:
      * \brief Bind a render area to the main window.
      * \param render_area A pointer to a QGLWidget.
      */
-    void bind_render_area(Render_windowed *render_area);
+    void bind_render_area(Render_windowed *render_area, int index);
+
+    /*!
+     * \return The number of render areas currently shown by the window
+     */
+    int get_nb_render_areas();
 
     /*!
      * \brief Ajust scroll bar length.
diff --git a/src/interface/main_window.ui b/src/interface/main_window.ui
index 1e256569..b9daf052 100644
--- a/src/interface/main_window.ui
+++ b/src/interface/main_window.ui
@@ -1,587 +1,577 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
- <class>main_window</class>
- <widget class="QMainWindow" name="main_window">
-  <property name="windowModality">
-   <enum>Qt::NonModal</enum>
-  </property>
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>1060</width>
-    <height>628</height>
-   </rect>
-  </property>
-  <property name="sizePolicy">
-   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-    <horstretch>0</horstretch>
-    <verstretch>0</verstretch>
-   </sizepolicy>
-  </property>
-  <property name="windowTitle">
-   <string>ViTE</string>
-  </property>
-  <property name="windowIcon">
-   <iconset resource="vite.qrc">
-    <normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset>
-  </property>
-  <widget class="QWidget" name="centralwidget">
-   <layout class="QVBoxLayout" name="verticalLayout_2">
-    <item>
-     <layout class="QHBoxLayout" name="horizontalLayout_2">
-      <item>
-       <layout class="QVBoxLayout" name="render_area_layout"/>
-      </item>
-      <item>
-       <widget class="QScrollBar" name="y_scroll">
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
+    <class>default_window</class>
+    <widget class="QMainWindow" name="main_window">
+        <property name="windowModality">
+            <enum>Qt::NonModal</enum>
         </property>
-       </widget>
-      </item>
-     </layout>
-    </item>
-    <item>
-     <layout class="QHBoxLayout" name="horizontalLayout_3">
-      <item>
-       <widget class="QLabel" name="label_3">
-        <property name="text">
-         <string>Scale containers/states: </string>
+        <property name="geometry">
+            <rect>
+                <x>0</x>
+                <y>0</y>
+                <width>1060</width>
+                <height>628</height>
+            </rect>
         </property>
-        <property name="textFormat">
-         <enum>Qt::PlainText</enum>
-        </property>
-        <property name="scaledContents">
-         <bool>false</bool>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QSlider" name="scale_container_state">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="focusPolicy">
-         <enum>Qt::NoFocus</enum>
-        </property>
-        <property name="value">
-         <number>20</number>
-        </property>
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="Line" name="line">
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QLabel" name="label_2">
-        <property name="text">
-         <string>Change position:</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QScrollBar" name="x_scroll">
         <property name="sizePolicy">
-         <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="Line" name="line_2">
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QLabel" name="label_4">
-        <property name="text">
-         <string>Zoom: </string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QComboBox" name="zoom_box">
-        <property name="font">
-         <font>
-          <italic>true</italic>
-         </font>
-        </property>
-        <property name="editable">
-         <bool>true</bool>
-        </property>
-        <property name="currentIndex">
-         <number>5</number>
-        </property>
-        <property name="maxCount">
-         <number>2147483640</number>
+            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                <horstretch>0</horstretch>
+                <verstretch>0</verstretch>
+            </sizepolicy>
         </property>
-        <property name="insertPolicy">
-         <enum>QComboBox::InsertAtBottom</enum>
+        <property name="windowTitle">
+            <string>ViTE</string>
         </property>
-        <property name="sizeAdjustPolicy">
-         <enum>QComboBox::AdjustToContents</enum>
+        <property name="windowIcon">
+            <iconset resource="vite.qrc">
+                <normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset>
         </property>
-        <item>
-         <property name="text">
-          <string>1000%</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string/>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>500%</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>200%</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>150%</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>100%</string>
-         </property>
-        </item>
-        <item>
-         <property name="text">
-          <string>75%</string>
-         </property>
-        </item>
-       </widget>
-      </item>
-     </layout>
-    </item>
-   </layout>
-  </widget>
-  <widget class="QMenuBar" name="menubar">
-   <property name="geometry">
-    <rect>
-     <x>0</x>
-     <y>0</y>
-     <width>1060</width>
-     <height>23</height>
-    </rect>
-   </property>
-   <widget class="QMenu" name="menuHelp">
-    <property name="title">
-     <string>&amp;Help</string>
-    </property>
-    <addaction name="help"/>
-    <addaction name="separator"/>
-    <addaction name="about"/>
-   </widget>
-   <widget class="QMenu" name="menuView">
-    <property name="title">
-     <string>&amp;View</string>
-    </property>
-    <addaction name="show_info"/>
-    <addaction name="toolbar_menu"/>
-    <addaction name="minimap_menu"/>
-    <addaction name="separator"/>
-    <addaction name="zoom_in"/>
-    <addaction name="zoom_out"/>
-    <addaction name="show_all_trace"/>
-    <addaction name="goto_start"/>
-    <addaction name="goto_end"/>
-    <addaction name="separator"/>
-    <addaction name="shaded_states"/>
-    <addaction name="vertical_line"/>
-    <addaction name="separator"/>
-    <addaction name="fullscreen"/>
-    <addaction name="separator"/>
-    <addaction name="no_warning"/>
-    <addaction name="no_arrows"/>
-    <addaction name="no_events"/>
-    <addaction name="reload_from_file"/>
-   </widget>
-   <widget class="QMenu" name="menuFile">
-    <property name="title">
-     <string>&amp;File</string>
-    </property>
-    <widget class="QMenu" name="menuRecent_Files">
-     <property name="title">
-      <string>Recent Files</string>
-     </property>
-     <addaction name="clear_recent_files"/>
-     <addaction name="separator"/>
+        <widget class="QWidget" name="centralwidget">
+            <layout class="QVBoxLayout" name="verticalLayout_2">
+                <item>
+                    <layout class="QVBoxLayout" name="render_areas">
+                    </layout>
+                </item>
+                <item>
+                    <layout class="QHBoxLayout" name="horizontalLayout_3">
+                        <item>
+                            <widget class="QLabel" name="label_3">
+                                <property name="text">
+                                    <string>Scale containers/states: </string>
+                                </property>
+                                <property name="textFormat">
+                                    <enum>Qt::PlainText</enum>
+                                </property>
+                                <property name="scaledContents">
+                                    <bool>false</bool>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="QSlider" name="scale_container_state">
+                                <property name="sizePolicy">
+                                    <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+                                        <horstretch>0</horstretch>
+                                        <verstretch>0</verstretch>
+                                    </sizepolicy>
+                                </property>
+                                <property name="focusPolicy">
+                                    <enum>Qt::NoFocus</enum>
+                                </property>
+                                <property name="value">
+                                    <number>20</number>
+                                </property>
+                                <property name="orientation">
+                                    <enum>Qt::Horizontal</enum>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="Line" name="line">
+                                <property name="orientation">
+                                    <enum>Qt::Vertical</enum>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="QLabel" name="label_2">
+                                <property name="text">
+                                    <string>Change position:</string>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="QScrollBar" name="x_scroll">
+                                <property name="sizePolicy">
+                                    <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+                                        <horstretch>0</horstretch>
+                                        <verstretch>0</verstretch>
+                                    </sizepolicy>
+                                </property>
+                                <property name="orientation">
+                                    <enum>Qt::Horizontal</enum>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="Line" name="line_2">
+                                <property name="orientation">
+                                    <enum>Qt::Vertical</enum>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="QLabel" name="label_4">
+                                <property name="text">
+                                    <string>Zoom: </string>
+                                </property>
+                            </widget>
+                        </item>
+                        <item>
+                            <widget class="QComboBox" name="zoom_box">
+                                <property name="font">
+                                    <font>
+                                        <italic>true</italic>
+                                    </font>
+                                </property>
+                                <property name="editable">
+                                    <bool>true</bool>
+                                </property>
+                                <property name="currentIndex">
+                                    <number>5</number>
+                                </property>
+                                <property name="maxCount">
+                                    <number>2147483640</number>
+                                </property>
+                                <property name="insertPolicy">
+                                    <enum>QComboBox::InsertAtBottom</enum>
+                                </property>
+                                <property name="sizeAdjustPolicy">
+                                    <enum>QComboBox::AdjustToContents</enum>
+                                </property>
+                                <item>
+                                    <property name="text">
+                                        <string>1000%</string>
+                                    </property>
+                                </item>
+                                <item>
+                                    <property name="text">
+                                        <string/>
+                                    </property>
+                                </item>
+                                <item>
+                                    <property name="text">
+                                        <string>500%</string>
+                                    </property>
+                                </item>
+                                <item>
+                                    <property name="text">
+                                        <string>200%</string>
+                                    </property>
+                                </item>
+                                <item>
+                                    <property name="text">
+                                        <string>150%</string>
+                                    </property>
+                                </item>
+                                <item>
+                                    <property name="text">
+                                        <string>100%</string>
+                                    </property>
+                                </item>
+                                <item>
+                                    <property name="text">
+                                        <string>75%</string>
+                                    </property>
+                                </item>
+                            </widget>
+                        </item>
+                    </layout>
+                </item>
+            </layout>
+        </widget>
+        <widget class="QMenuBar" name="menubar">
+            <property name="geometry">
+                <rect>
+                    <x>0</x>
+                    <y>0</y>
+                    <width>1060</width>
+                    <height>23</height>
+                </rect>
+            </property>
+            <widget class="QMenu" name="menuHelp">
+                <property name="title">
+                    <string>&amp;Help</string>
+                </property>
+                <addaction name="help"/>
+                <addaction name="separator"/>
+                <addaction name="about"/>
+            </widget>
+            <widget class="QMenu" name="menuView">
+                <property name="title">
+                    <string>&amp;View</string>
+                </property>
+                <addaction name="show_info"/>
+                <addaction name="toolbar_menu"/>
+                <addaction name="minimap_menu"/>
+                <addaction name="separator"/>
+                <addaction name="zoom_in"/>
+                <addaction name="zoom_out"/>
+                <addaction name="show_all_trace"/>
+                <addaction name="goto_start"/>
+                <addaction name="goto_end"/>
+                <addaction name="separator"/>
+                <addaction name="shaded_states"/>
+                <addaction name="vertical_line"/>
+                <addaction name="separator"/>
+                <addaction name="fullscreen"/>
+                <addaction name="separator"/>
+                <addaction name="no_warning"/>
+                <addaction name="no_arrows"/>
+                <addaction name="no_events"/>
+                <addaction name="reload_from_file"/>
+            </widget>
+            <widget class="QMenu" name="menuFile">
+                <property name="title">
+                    <string>&amp;File</string>
+                </property>
+                <widget class="QMenu" name="menuRecent_Files">
+                    <property name="title">
+                        <string>Recent Files</string>
+                    </property>
+                    <addaction name="clear_recent_files"/>
+                    <addaction name="separator"/>
+                </widget>
+                <addaction name="open"/>
+                <addaction name="reload"/>
+                <addaction name="menuRecent_Files"/>
+                <addaction name="export_file"/>
+                <addaction name="separator"/>
+                <addaction name="close"/>
+                <addaction name="separator"/>
+                <addaction name="quit"/>
+            </widget>
+            <widget class="QMenu" name="menuPreferences">
+                <property name="title">
+                    <string>&amp;Preferences</string>
+                </property>
+                <addaction name="actionCommand"/>
+                <addaction name="show_plugins"/>
+                <addaction name="separator"/>
+                <addaction name="show_settings"/>
+                <addaction name="node_selection"/>
+                <addaction name="interval_selection"/>
+            </widget>
+            <addaction name="menuFile"/>
+            <addaction name="menuView"/>
+            <addaction name="menuPreferences"/>
+            <addaction name="menuHelp"/>
+        </widget>
+        <widget class="QToolBar" name="toolBar">
+            <property name="windowTitle">
+                <string>toolBar</string>
+            </property>
+            <property name="movable">
+                <bool>true</bool>
+            </property>
+            <property name="floatable">
+                <bool>true</bool>
+            </property>
+            <attribute name="toolBarArea">
+                <enum>TopToolBarArea</enum>
+            </attribute>
+            <attribute name="toolBarBreak">
+                <bool>false</bool>
+            </attribute>
+            <addaction name="open"/>
+            <addaction name="reload"/>
+            <addaction name="close"/>
+            <addaction name="export_file"/>
+            <addaction name="separator"/>
+            <addaction name="zoom_in"/>
+            <addaction name="zoom_out"/>
+            <addaction name="goto_start"/>
+            <addaction name="goto_end"/>
+            <addaction name="show_all_trace"/>
+            <addaction name="fullscreen"/>
+            <addaction name="separator"/>
+            <addaction name="help"/>
+            <addaction name="no_arrows"/>
+            <addaction name="no_events"/>
+        </widget>
+        <action name="open">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/folder_yellow_open.png</normaloff>:/icon/icon/folder_yellow_open.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;Open</string>
+            </property>
+            <property name="shortcut">
+                <string>Ctrl+O</string>
+            </property>
+        </action>
+        <action name="close">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/fileclose.png</normaloff>:/icon/icon/fileclose.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;Close</string>
+            </property>
+            <property name="shortcut">
+                <string>Ctrl+W</string>
+            </property>
+        </action>
+        <action name="quit">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/quit.png</normaloff>:/icon/icon/quit.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;Quit</string>
+            </property>
+            <property name="shortcut">
+                <string>Ctrl+Q</string>
+            </property>
+        </action>
+        <action name="help">
+            <property name="checkable">
+                <bool>false</bool>
+            </property>
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/help_index.png</normaloff>:/icon/icon/help_index.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;Help</string>
+            </property>
+            <property name="shortcut">
+                <string>F1</string>
+            </property>
+        </action>
+        <action name="about">
+            <property name="checkable">
+                <bool>false</bool>
+            </property>
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/about.png</normaloff>:/icon/icon/about.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;About ViTE</string>
+            </property>
+        </action>
+        <action name="fullscreen">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/fullscreen_mode.png</normaloff>:/icon/icon/fullscreen_mode.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;Fullscreen</string>
+            </property>
+            <property name="shortcut">
+                <string>F11</string>
+            </property>
+        </action>
+        <action name="show_info">
+            <property name="checkable">
+                <bool>false</bool>
+            </property>
+            <property name="checked">
+                <bool>false</bool>
+            </property>
+            <property name="text">
+                <string>Show infos window</string>
+            </property>
+        </action>
+        <action name="export_file">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/export_svg.png</normaloff>:/icon/icon/export_svg.png</iconset>
+            </property>
+            <property name="text">
+                <string>&amp;Export</string>
+            </property>
+            <property name="shortcut">
+                <string>Ctrl+E</string>
+            </property>
+        </action>
+        <action name="zoom_in">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/zoom_in.png</normaloff>:/icon/icon/zoom_in.png</iconset>
+            </property>
+            <property name="text">
+                <string>Zoom in</string>
+            </property>
+            <property name="shortcut">
+                <string>+</string>
+            </property>
+        </action>
+        <action name="zoom_out">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/zoom_out.png</normaloff>:/icon/icon/zoom_out.png</iconset>
+            </property>
+            <property name="text">
+                <string>Zoom out</string>
+            </property>
+            <property name="shortcut">
+                <string>-</string>
+            </property>
+        </action>
+        <action name="toolbar_menu">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="checked">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>Show toolbar</string>
+            </property>
+        </action>
+        <action name="goto_end">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/goto_end.png</normaloff>:/icon/icon/goto_end.png</iconset>
+            </property>
+            <property name="text">
+                <string>Move to end</string>
+            </property>
+            <property name="shortcut">
+                <string>End</string>
+            </property>
+        </action>
+        <action name="goto_start">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/goto_start.png</normaloff>:/icon/icon/goto_start.png</iconset>
+            </property>
+            <property name="text">
+                <string>Move to start</string>
+            </property>
+            <property name="shortcut">
+                <string>Home</string>
+            </property>
+        </action>
+        <action name="show_all_trace">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/print_all.png</normaloff>:/icon/icon/print_all.png</iconset>
+            </property>
+            <property name="text">
+                <string>Show all</string>
+            </property>
+            <property name="shortcut">
+                <string>Ctrl+Shift+A</string>
+            </property>
+        </action>
+        <action name="no_warning">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>No warning</string>
+            </property>
+        </action>
+        <action name="actionZoom_control">
+            <property name="text">
+                <string>zoom_control</string>
+            </property>
+        </action>
+        <action name="no_arrows">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>No arrows</string>
+            </property>
+        </action>
+        <action name="no_events">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>No events</string>
+            </property>
+        </action>
+        <action name="actionCommand">
+            <property name="text">
+                <string>Command</string>
+            </property>
+        </action>
+        <action name="clear_recent_files">
+            <property name="text">
+                <string>Clear</string>
+            </property>
+        </action>
+        <action name="reload">
+            <property name="icon">
+                <iconset resource="vite.qrc">
+                    <normaloff>:/icon/icon/reload.png</normaloff>:/icon/icon/reload.png</iconset>
+            </property>
+            <property name="text">
+                <string>Reload</string>
+            </property>
+            <property name="shortcut">
+                <string>Ctrl+R</string>
+            </property>
+        </action>
+        <action name="minimap_menu">
+            <property name="checkable">
+                <bool>false</bool>
+            </property>
+            <property name="checked">
+                <bool>false</bool>
+            </property>
+            <property name="text">
+                <string>Show minimap</string>
+            </property>
+        </action>
+        <action name="show_plugins">
+            <property name="text">
+                <string>Plugins</string>
+            </property>
+        </action>
+        <action name="show_settings">
+            <property name="text">
+                <string>Settings</string>
+            </property>
+        </action>
+        <action name="node_selection">
+            <property name="text">
+                <string>Node Selection</string>
+            </property>
+        </action>
+        <action name="interval_selection">
+            <property name="text">
+                <string>Interval Selection</string>
+            </property>
+        </action>
+        <action name="shaded_states">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="checked">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>Shaded states</string>
+            </property>
+        </action>
+        <action name="vertical_line">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="checked">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>Vertical Line</string>
+            </property>
+        </action>
+        <action name="reload_from_file">
+            <property name="checkable">
+                <bool>true</bool>
+            </property>
+            <property name="checked">
+                <bool>true</bool>
+            </property>
+            <property name="text">
+                <string>Reload from file</string>
+            </property>
+            <property name="toolTip">
+                <string>When pressing reload, reload the whole trace from file</string>
+            </property>
+        </action>
     </widget>
-    <addaction name="open"/>
-    <addaction name="reload"/>
-    <addaction name="menuRecent_Files"/>
-    <addaction name="export_file"/>
-    <addaction name="separator"/>
-    <addaction name="close"/>
-    <addaction name="separator"/>
-    <addaction name="quit"/>
-   </widget>
-   <widget class="QMenu" name="menuPreferences">
-    <property name="title">
-     <string>&amp;Preferences</string>
-    </property>
-    <addaction name="actionCommand"/>
-    <addaction name="show_plugins"/>
-    <addaction name="separator"/>
-    <addaction name="show_settings"/>
-    <addaction name="node_selection"/>
-    <addaction name="interval_selection"/>
-   </widget>
-   <addaction name="menuFile"/>
-   <addaction name="menuView"/>
-   <addaction name="menuPreferences"/>
-   <addaction name="menuHelp"/>
-  </widget>
-  <widget class="QToolBar" name="toolBar">
-   <property name="windowTitle">
-    <string>toolBar</string>
-   </property>
-   <property name="movable">
-    <bool>true</bool>
-   </property>
-   <property name="floatable">
-    <bool>true</bool>
-   </property>
-   <attribute name="toolBarArea">
-    <enum>TopToolBarArea</enum>
-   </attribute>
-   <attribute name="toolBarBreak">
-    <bool>false</bool>
-   </attribute>
-   <addaction name="open"/>
-   <addaction name="reload"/>
-   <addaction name="close"/>
-   <addaction name="export_file"/>
-   <addaction name="separator"/>
-   <addaction name="zoom_in"/>
-   <addaction name="zoom_out"/>
-   <addaction name="goto_start"/>
-   <addaction name="goto_end"/>
-   <addaction name="show_all_trace"/>
-   <addaction name="fullscreen"/>
-   <addaction name="separator"/>
-   <addaction name="help"/>
-   <addaction name="no_arrows"/>
-   <addaction name="no_events"/>
-  </widget>
-  <action name="open">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/folder_yellow_open.png</normaloff>:/icon/icon/folder_yellow_open.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;Open</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+O</string>
-   </property>
-  </action>
-  <action name="close">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/fileclose.png</normaloff>:/icon/icon/fileclose.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;Close</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+W</string>
-   </property>
-  </action>
-  <action name="quit">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/quit.png</normaloff>:/icon/icon/quit.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;Quit</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+Q</string>
-   </property>
-  </action>
-  <action name="help">
-   <property name="checkable">
-    <bool>false</bool>
-   </property>
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/help_index.png</normaloff>:/icon/icon/help_index.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;Help</string>
-   </property>
-   <property name="shortcut">
-    <string>F1</string>
-   </property>
-  </action>
-  <action name="about">
-   <property name="checkable">
-    <bool>false</bool>
-   </property>
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/about.png</normaloff>:/icon/icon/about.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;About ViTE</string>
-   </property>
-  </action>
-  <action name="fullscreen">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/fullscreen_mode.png</normaloff>:/icon/icon/fullscreen_mode.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;Fullscreen</string>
-   </property>
-   <property name="shortcut">
-    <string>F11</string>
-   </property>
-  </action>
-  <action name="show_info">
-   <property name="checkable">
-    <bool>false</bool>
-   </property>
-   <property name="checked">
-    <bool>false</bool>
-   </property>
-   <property name="text">
-    <string>Show infos window</string>
-   </property>
-  </action>
-  <action name="export_file">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/export_svg.png</normaloff>:/icon/icon/export_svg.png</iconset>
-   </property>
-   <property name="text">
-    <string>&amp;Export</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+E</string>
-   </property>
-  </action>
-  <action name="zoom_in">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/zoom_in.png</normaloff>:/icon/icon/zoom_in.png</iconset>
-   </property>
-   <property name="text">
-    <string>Zoom in</string>
-   </property>
-   <property name="shortcut">
-    <string>+</string>
-   </property>
-  </action>
-  <action name="zoom_out">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/zoom_out.png</normaloff>:/icon/icon/zoom_out.png</iconset>
-   </property>
-   <property name="text">
-    <string>Zoom out</string>
-   </property>
-   <property name="shortcut">
-    <string>-</string>
-   </property>
-  </action>
-  <action name="toolbar_menu">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="checked">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>Show toolbar</string>
-   </property>
-  </action>
-  <action name="goto_end">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/goto_end.png</normaloff>:/icon/icon/goto_end.png</iconset>
-   </property>
-   <property name="text">
-    <string>Move to end</string>
-   </property>
-   <property name="shortcut">
-    <string>End</string>
-   </property>
-  </action>
-  <action name="goto_start">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/goto_start.png</normaloff>:/icon/icon/goto_start.png</iconset>
-   </property>
-   <property name="text">
-    <string>Move to start</string>
-   </property>
-   <property name="shortcut">
-    <string>Home</string>
-   </property>
-  </action>
-  <action name="show_all_trace">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/print_all.png</normaloff>:/icon/icon/print_all.png</iconset>
-   </property>
-   <property name="text">
-    <string>Show all</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+Shift+A</string>
-   </property>
-  </action>
-  <action name="no_warning">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>No warning</string>
-   </property>
-  </action>
-  <action name="actionZoom_control">
-   <property name="text">
-    <string>zoom_control</string>
-   </property>
-  </action>
-  <action name="no_arrows">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>No arrows</string>
-   </property>
-  </action>
-  <action name="no_events">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>No events</string>
-   </property>
-  </action>
-  <action name="actionCommand">
-   <property name="text">
-    <string>Command</string>
-   </property>
-  </action>
-  <action name="clear_recent_files">
-   <property name="text">
-    <string>Clear</string>
-   </property>
-  </action>
-  <action name="reload">
-   <property name="icon">
-    <iconset resource="vite.qrc">
-     <normaloff>:/icon/icon/reload.png</normaloff>:/icon/icon/reload.png</iconset>
-   </property>
-   <property name="text">
-    <string>Reload</string>
-   </property>
-   <property name="shortcut">
-    <string>Ctrl+R</string>
-   </property>
-  </action>
-  <action name="minimap_menu">
-   <property name="checkable">
-    <bool>false</bool>
-   </property>
-   <property name="checked">
-    <bool>false</bool>
-   </property>
-   <property name="text">
-    <string>Show minimap</string>
-   </property>
-  </action>
-  <action name="show_plugins">
-   <property name="text">
-    <string>Plugins</string>
-   </property>
-  </action>
-  <action name="show_settings">
-   <property name="text">
-    <string>Settings</string>
-   </property>
-  </action>
-  <action name="node_selection">
-   <property name="text">
-    <string>Node Selection</string>
-   </property>
-  </action>
-  <action name="interval_selection">
-   <property name="text">
-    <string>Interval Selection</string>
-   </property>
-  </action>
-  <action name="shaded_states">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="checked">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>Shaded states</string>
-   </property>
-  </action>
-  <action name="vertical_line">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="checked">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>Vertical Line</string>
-   </property>
-  </action>
-  <action name="reload_from_file">
-   <property name="checkable">
-    <bool>true</bool>
-   </property>
-   <property name="checked">
-    <bool>true</bool>
-   </property>
-   <property name="text">
-    <string>Reload from file</string>
-   </property>
-   <property name="toolTip">
-    <string>When pressing reload, reload the whole trace from file</string>
-   </property>
-  </action>
- </widget>
- <resources>
-  <include location="vite.qrc"/>
- </resources>
- <connections/>
+    <resources>
+        <include location="vite.qrc"/>
+    </resources>
+    <connections/>
 </ui>
diff --git a/src/interface/multirender_window.cpp b/src/interface/multirender_window.cpp
new file mode 100644
index 00000000..36dc9f5b
--- /dev/null
+++ b/src/interface/multirender_window.cpp
@@ -0,0 +1,62 @@
+
+#include "multirender_window.hpp"
+
+using namespace Ui;
+
+
+std::string concatenate(const char* name, int index) {
+    std::string str = std::string(name) + std::to_string(index);
+    return str;
+}
+
+
+void multirender_window::setupUi(QMainWindow *main_window) {
+    Ui_default_window::setupUi(main_window);
+    this->addRender();
+}
+
+
+void multirender_window::addRender() {
+    int index = render_areas->count();
+
+    QHBoxLayout* render = new QHBoxLayout();
+    _renders.push_back(render);
+    render->setObjectName(QString::fromUtf8(concatenate("render", index).c_str()));
+
+    QVBoxLayout* render_area_layout = new QVBoxLayout();
+    _render_area_layouts.push_back(render_area_layout);
+    render_area_layout->setObjectName(QString::fromUtf8(concatenate("render_area_layout", index).c_str()));
+
+    render->addLayout(render_area_layout);
+
+    QScrollBar* y_scroll = new QScrollBar(centralwidget);
+    _scrolls.push_back(y_scroll);
+    y_scroll->setObjectName(QString::fromUtf8(concatenate("y_scroll", index).c_str()));
+    y_scroll->setOrientation(Qt::Vertical);
+
+    render->addWidget(y_scroll);
+
+    render_areas->addLayout(render);
+}
+
+
+void multirender_window::removeRender() {
+    if (_renders.size() <= 1) return;
+
+    QHBoxLayout* render = _renders.back();
+    _renders.pop_back();
+
+    QVBoxLayout* render_area_layout = _render_area_layouts.back();
+    _render_area_layouts.pop_back();
+    render->removeItem(render_area_layout);
+    delete render_area_layout;
+
+    QScrollBar* y_scroll = _scrolls.back();
+    _scrolls.pop_back();
+
+    render->removeWidget(y_scroll);
+    delete y_scroll;
+
+    render_areas->removeItem(render);
+    delete render;
+}
\ No newline at end of file
diff --git a/src/interface/multirender_window.hpp b/src/interface/multirender_window.hpp
new file mode 100644
index 00000000..448e8e79
--- /dev/null
+++ b/src/interface/multirender_window.hpp
@@ -0,0 +1,32 @@
+
+#include "ui_main_window.h"
+
+namespace Ui {
+
+    class multirender_window: protected Ui_default_window {
+    
+    protected:
+        std::vector<QHBoxLayout*> _renders;
+        std::vector<QVBoxLayout*> _render_area_layouts;
+        std::vector<QScrollBar*> _scrolls;
+
+    public:
+
+        /*!
+         * \brief Sets up the displayed elements on the window
+         * \param main_window The window which is to setup (equal to `this`)
+         */
+        void setupUi(QMainWindow *main_window);
+
+        /*!
+         * \brief This method adds a new empty render area to be displayed on the window
+         */
+        void addRender();
+
+        /*!
+         * \brief Removes the last (lower) render area of the window
+         */
+        void removeRender();
+
+    };
+}
\ No newline at end of file
diff --git a/src/trace/DrawTrace.hpp b/src/trace/DrawTrace.hpp
index 37376358..9eb15d7c 100644
--- a/src/trace/DrawTrace.hpp
+++ b/src/trace/DrawTrace.hpp
@@ -957,7 +957,7 @@ public:
             }
 
             template<class T>
-                void draw_text_variable_values(T* render, std::map<long int, double>* var_map,  double date){
+            void draw_text_variable_values(T* render, std::map<long int, double>* var_map, double date){
                 std::map<long int, double>::const_iterator it=var_map->begin();
                 const std::map<long int, double>::const_iterator it_end=var_map->end();
 
-- 
GitLab