diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5bdde91510416136f123ec4ce5d72026d11cfbd..e498fdf4d39c6c735a164597ed4bb7761bdc19f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,9 @@ SET(VITE_HDRS interface/Interface_graphic.hpp interface/Node_select.hpp interface/viteqtreewidget.hpp + interface/Interval_select.hpp + interface/qxtspanslider.h + interface/qxtspanslider_p.h # Core header core/Core.hpp core/getopt.h @@ -143,6 +146,7 @@ SET(VITE_UIS interface/global_cmd.ui interface/list_of_counter_to_export.ui interface/node_select.ui + interface/interval_select.ui ) SET(VITE_SRCS @@ -214,6 +218,8 @@ SET(VITE_SRCS interface/Interface_graphic.cpp interface/Node_select.cpp interface/viteqtreewidget.cpp + interface/Interval_select.cpp + interface/qxtspanslider.cpp # Plugin code file plugin/Command_window.cpp plugin/Plugin_window.cpp diff --git a/src/common/Info.cpp b/src/common/Info.cpp index 16fbe4621a343eac2df9bb6f87b53acae5fbec87..cf5593df2af5d656f5faf655bbfaaf8b1456571c 100644 --- a/src/common/Info.cpp +++ b/src/common/Info.cpp @@ -69,6 +69,8 @@ bool Info::Render::_key_alt = false; bool Info::Render::_key_ctrl = false; Element_pos Info::Render::_x_min_visible = 0.0; Element_pos Info::Render::_x_max_visible = 0.0; +Element_pos Info::Render::_x_min = 0.0; +Element_pos Info::Render::_x_max = 0.0; Element_pos Info::Render::_info_x = 0.0; Element_pos Info::Render::_info_y = 0.0; @@ -84,8 +86,8 @@ bool Info::Splitter::load_splitted = false; bool Info::Splitter::preview = false; std::string Info::Splitter::path ; std::string Info::Splitter::filename ; -Element_pos Info::Splitter::_x_min = 0.; -Element_pos Info::Splitter::_x_max = 0.; +Element_pos Info::Splitter::_x_min = 0.0; +Element_pos Info::Splitter::_x_max = 0.0; int Info::Trace::depth=0; diff --git a/src/common/Info.hpp b/src/common/Info.hpp index b38fc9a294595b6a72d2e9225453aaa74a729784..c50374c438f50681b3fc622d061ca39cc613af11 100644 --- a/src/common/Info.hpp +++ b/src/common/Info.hpp @@ -199,6 +199,16 @@ public: */ static Element_pos _x_min_visible; + /*! + * \brief Contains the trace maximum visible time. + */ + static Element_pos _x_max; + + /*! + * \brief Contains the trace minimum visible time, uncorrected (state width isn't removed) + */ + static Element_pos _x_min; + /*! * \brief Contains the trace maximum visible time. */ diff --git a/src/interface/Interface_graphic.cpp b/src/interface/Interface_graphic.cpp index 86cf166366f222be3fcf4c69468b999d0dcbe619..0b8cf1df0bad997d89427be2c7254e700563da5e 100644 --- a/src/interface/Interface_graphic.cpp +++ b/src/interface/Interface_graphic.cpp @@ -119,6 +119,7 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa _plugin_window = NULL; _ui_settings = NULL; _ui_node_selection=NULL; + _ui_interval_selection=NULL; // _cmd_window = NULL; _cmd_window = new Command_window(this,this); @@ -130,6 +131,13 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa connect(quit, SIGNAL(triggered()), _ui_node_selection, SLOT(close())); } + if (!_ui_interval_selection) { + _ui_interval_selection = new Interval_select(this, 0); + + //connect( _ui_node_selection, SIGNAL(settings_changed()), this, SLOT(update_settings())); + // To close the window when we quit the application + connect(quit, SIGNAL(triggered()), _ui_interval_selection, SLOT(close())); + } // For drag and drop operations setAcceptDrops(true); } @@ -436,6 +444,9 @@ void Interface_graphic::change_zoom_box_value(int new_value){ else{ _ui_zoom_box->setCurrentIndex(index);/* value exists, select it */ } + + //update the interval selection display + if(_ui_interval_selection!=NULL)_ui_interval_selection->update_values(); } @@ -727,6 +738,7 @@ void Interface_graphic::on_close_triggered(){ void Interface_graphic::on_quit_triggered(){ ((QWidget*)_ui_node_selection)->close(); + ((QWidget*)_ui_interval_selection)->close(); ((QWidget*)_ui_help_window)->close(); ((QWidget*)this)->close(); } @@ -863,6 +875,21 @@ void Interface_graphic::on_show_settings_triggered() { //} _ui_node_selection->show(); } + + void Interface_graphic::on_interval_selection_triggered() { + + //if (!_ui_node_selection) { + // _ui_node_selection = new Node_select(this, 0); + if(!_ui_interval_selection->get_trace() && _core->get_trace()){//first use + _ui_interval_selection->set_trace(_core->get_trace()); + + } + //connect( _ui_node_selection, SIGNAL(settings_changed()), this, SLOT(update_settings())); + // To close the window when we quit the application + //connect(quit, SIGNAL(triggered()), _ui_node_selection, SLOT(close())); + //} + _ui_interval_selection->show(); + } void Interface_graphic::on_actionCommand_triggered(){ if(_core->get_trace()){ @@ -1004,6 +1031,9 @@ void Interface_graphic::closeEvent(QCloseEvent *event){ if(_ui_node_selection) _ui_node_selection->close(); + + if(_ui_interval_selection) + _ui_interval_selection->close(); } const std::string Interface_graphic::get_filename() const{ @@ -1018,6 +1048,11 @@ Core * Interface_graphic::get_console(){ Node_select* Interface_graphic::get_node_select(){ return _ui_node_selection; } + +Interval_select* Interface_graphic::get_interval_select(){ + return _ui_interval_selection; +} + void Interface_graphic::update_recent_files_menu() { const QStringList filenames = Session::get_recent_files(); QString absoluteFilename; diff --git a/src/interface/Interface_graphic.hpp b/src/interface/Interface_graphic.hpp index af603d23f57e00dd936f592646d50330a2b37aca..3ba90bf8288679e8279554120e53ff27d063fc89 100644 --- a/src/interface/Interface_graphic.hpp +++ b/src/interface/Interface_graphic.hpp @@ -71,6 +71,7 @@ class QProgressDialog; #include "interface/Interface.hpp" #include "interface/Settings_window.hpp" #include "interface/Node_select.hpp" +#include "interface/Interval_select.hpp" /*! *\brief This class is a graphical interface which creates a window, it inherited from the Interface interface. @@ -224,6 +225,11 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public */ Node_select* _ui_node_selection; + /*! + * \brief Dialog box to allow user to select nodes to display + */ + Interval_select* _ui_interval_selection; + /*! * \brief Text area which informs the user about the trace resume. */ @@ -483,6 +489,13 @@ public: */ Node_select* get_node_select(); + + /*! + * \fn get_interval_select() + * \brief To get the node selection console + */ + Interval_select* get_interval_select(); + /*! * \fn update_recent_files_menu() * \brief update the recent files opened menu @@ -607,6 +620,11 @@ protected slots: */ void on_node_selection_triggered(); + /*! + *\brief A slot called when 'Node selection' in the menu is clicked. + */ + void on_interval_selection_triggered(); + /*! * \brief A slot called when 'command' in the menu is clicked. */ diff --git a/src/interface/Interval_select.cpp b/src/interface/Interval_select.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f95b756aa1302adb3a4aa30caa50cc3be6cba02a --- /dev/null +++ b/src/interface/Interval_select.cpp @@ -0,0 +1,325 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +#include <iostream> +#include <sstream> +#include <fstream> +#include <string> +#include <map> +#include <set> +#include <list> +#include <stack> +#include <vector> + +/* -- */ +#include "common/common.hpp" +#include "common/Info.hpp" +#include "common/Message.hpp" +#include "interface/resource.hpp" +#include "interface/Interface.hpp" + +#include "core/Core.hpp" +#include "interface/Interface_graphic.hpp" +/* -- */ +#include "trace/values/Values.hpp" +#include "trace/EntityValue.hpp" +#include "trace/EntityTypes.hpp" +#include "trace/Entitys.hpp" +#include "trace/tree/Interval.hpp" +#include "trace/Container.hpp" +/* -- */ +#include <QKeyEvent> + +#include "interface/Interval_select.hpp" + +using namespace std; + +Interval_select::Interval_select(Interface_graphic * console,QWidget *parent) : QDialog(parent), _trace(NULL),_console(console) { + setupUi(this); + connect( minSpinBox, SIGNAL(valueChanged( double )), SLOT(minSpinBoxValueChanged( double ) ) ); + connect( interval_slider, SIGNAL(lowerValueChanged( int )), SLOT(minSliderValueChanged( int ) ) ); + connect( maxSpinBox, SIGNAL(valueChanged( double )), SLOT(maxSpinBoxValueChanged( double ) ) ); + connect( interval_slider, SIGNAL(upperValueChanged( int )), SLOT(maxSliderValueChanged( int ) ) ); + QMetaObject::connectSlotsByName(NULL); + _auto_refresh=auto_refresh_box->isChecked();//true by default + _applied=false; + //interval_slider->setHandleMovementMode(QxtSpanSlider::NoOverlapping); +} + +Interval_select::~Interval_select() { +} + +Trace* Interval_select::get_trace() { + return _trace; +} + +void Interval_select::set_trace(Trace *trace) { + // Initialize _trace + _trace = trace; + //double max =_trace->get_max_date().get_value(); + min_value->setText(QString().setNum (Info::Entity::x_min)); + max_value->setText(QString().setNum (Info::Entity::x_max)); + minSpinBox->setMinimum(Info::Entity::x_min); + minSpinBox->setMaximum(Info::Entity::x_max); + maxSpinBox->setMinimum(Info::Entity::x_min); + maxSpinBox->setMaximum(Info::Entity::x_max); + //the slider stays in int, we will translate its values + /*interval_slider->setMinimum(0); + interval_slider->setMaximum(99);*/ + + double delta=Info::Entity::x_max-Info::Entity::x_min; + double step= 0.001*delta; //make steps of .1% for spinboxes + minSpinBox->setSingleStep(step); + maxSpinBox->setSingleStep(step); + + update_values(); +} + +//called if a zoom is triggered outside of the window, to update slider position and spinboxes with the real values +void Interval_select::update_values() { + + if(_trace!=NULL){//if init + +Element_pos _min; +Element_pos _max; + +//choose which value to load the actual position from (can change if we are loading from a splitted file set) +if(Info::Splitter::preview==true){ + _min=Info::Entity::x_min; + _max=Info::Entity::x_max; +}else if(Info::Splitter::load_splitted==true){ + Info::Render::_x_min=Info::Splitter::_x_min; + Info::Render::_x_max=Info::Splitter::_x_max; + auto_refresh_box->setChecked(false);//set the checkbox to false because reload is expensive for splitted mode + _min=Info::Splitter::_x_min; + _max=Info::Splitter::_x_max; +}else{ + _min=Info::Render::_x_min; + _max=Info::Render::_x_max; + } + bool v = minSpinBox->blockSignals(true); + bool v2 = maxSpinBox->blockSignals(true); + bool v3 = interval_slider->blockSignals(true); + int maxvalue=int(_max*(interval_slider->maximum() - interval_slider->minimum())/(minSpinBox->maximum() - minSpinBox->minimum())); + interval_slider->setUpperValue(maxvalue); + interval_slider->setLowerValue(int(_min*(interval_slider->maximum() - interval_slider->minimum())/(minSpinBox->maximum() - minSpinBox->minimum()))); + maxSpinBox->setValue(_max); + minSpinBox->setValue(_min); + minSpinBox->blockSignals(v); + maxSpinBox->blockSignals(v2); + interval_slider->blockSignals(v3); + _applied=false; + } +} + + +void Interval_select::minSpinBoxValueChanged( double _value ) +{ + QPalette myPalette(minSpinBox->palette()); + + if(_value < maxSpinBox->value()){ + + bool v = interval_slider->blockSignals(true); + interval_slider->setLowerValue( int(_value *(interval_slider->maximum() - interval_slider->minimum())/(minSpinBox->maximum() - minSpinBox->minimum())) ); + + interval_slider->blockSignals(v); + emit( minValueChanged( minSpinBox->value() ) ); + myPalette.setColor(QPalette::Active, QPalette::Text, Qt::black); + myPalette.setColor(QPalette::Active, QPalette::HighlightedText, Qt::white); + + if(_auto_refresh)apply_settings(); + }else{ + //min cannot be greater than max + //set the incorrect value to red, but don't change it in order to let the user type a full correct value + myPalette.setColor(QPalette::Active, QPalette::Text, Qt::red); + myPalette.setColor(QPalette::Active, QPalette::HighlightedText, Qt::red); + //minSliderValueChanged( maxSpinBox->value() ); + } + + minSpinBox->setPalette(myPalette); + maxSpinBox->setPalette(myPalette); + + _applied=false; + +} + +void Interval_select::minSliderValueChanged( int _value ) +{ + if(_value < interval_slider->upperValue()){ + bool v = minSpinBox->blockSignals(true); + minSpinBox->setValue( _value *(minSpinBox->maximum() - minSpinBox->minimum())/(interval_slider->maximum() - interval_slider->minimum())); + minSpinBox->blockSignals(v); + emit( minValueChanged( minSpinBox->value() ) ); + if(_auto_refresh)apply_settings(); + } + _applied=false; +} + +void Interval_select::maxSpinBoxValueChanged( double _value ) +{ + QPalette myPalette(minSpinBox->palette()); + if(_value > minSpinBox->value()){ + bool v = interval_slider->blockSignals(true); + interval_slider->setUpperValue( int(_value* (interval_slider->maximum() - interval_slider->minimum())/(maxSpinBox->maximum() - maxSpinBox->minimum()))); + interval_slider->blockSignals(v); + emit( maxValueChanged( maxSpinBox->value() ) ); + myPalette.setColor(QPalette::Active, QPalette::Text, Qt::black); + myPalette.setColor(QPalette::Active, QPalette::HighlightedText, Qt::white); + if(_auto_refresh)apply_settings(); + }else{ + //max cannot be lower than min + + myPalette.setColor(QPalette::Active, QPalette::Text, Qt::red); + myPalette.setColor(QPalette::Active, QPalette::HighlightedText, Qt::red); + //maxSliderValueChanged( minSpinBox->value() ) ; + } + maxSpinBox->setPalette(myPalette); + minSpinBox->setPalette(myPalette); + _applied=false; +} + +void Interval_select::maxSliderValueChanged( int _value ) +{ + + if(_value > interval_slider->lowerValue()){ + bool v = maxSpinBox->blockSignals(true); + maxSpinBox->setValue( _value * (maxSpinBox->maximum() - maxSpinBox->minimum())/(interval_slider->maximum() - interval_slider->minimum())); + maxSpinBox->blockSignals(v); + emit( maxValueChanged( maxSpinBox->value() ) ); + if(_auto_refresh)apply_settings(); + } + _applied=false; +} + + +void Interval_select::apply_settings(){ + if(minSpinBox->value()!=maxSpinBox->value()){ + Element_pos zoom[2]={minSpinBox->value(), maxSpinBox->value()}; + + Info::Render::_x_min_visible = 0.0; + Info::Render::_x_max_visible = 0.0; + _console->get_console()->launch_action(Core:: _STATE_CLEAN_RENDER_AREA); + + //reload data from disk if needed + #if defined(USE_ITC) && defined(BOOST_SERIALIZE) + Info::Splitter::_x_min=zoom[0]; + Info::Splitter::_x_max=zoom[1]; + _trace->updateTrace(new Interval(zoom[0], zoom[1])); + #endif + + _console->get_console()->draw_trace(_console->get_filename(),Core::_DRAW_OPENGL); + + _console->get_console()->launch_action(Core:: _STATE_ZOOM_IN_AN_INTERVAL, &zoom); + _console->get_console()->launch_action(Core:: _STATE_RENDER_UPDATE); + } +} + + +void Interval_select::on_apply_button_clicked(){ + apply_settings(); + _applied=true; +} + +void Interval_select::on_cancel_button_clicked(){ + hide(); +} + +void Interval_select::on_ok_button_clicked(){ + + if(!_applied)on_apply_button_clicked(); + hide(); +} + + +void Interval_select::on_reset_button_clicked(){ + //maxValueChanged( interval_slider->maximum() ); + //minValueChanged( interval_slider->minimum() ); + interval_slider->setUpperValue(interval_slider->maximum()); + interval_slider->setLowerValue(interval_slider->minimum()); + //maxSliderValueChanged( interval_slider->maximum() ); + //minSliderValueChanged( interval_slider->minimum() ); +} + + +void Interval_select::on_auto_refresh_box_stateChanged(){ + _auto_refresh=auto_refresh_box->isChecked(); +} + +/* +void Stats_window::init() { + // We set the names of the containers for the tree widget + _nodes_selected->clear(); + set_container_names(); + + // We init the times + _start_time = Info::Render::_x_min_visible; + _end_time = Info::Render::_x_max_visible; + + QString temp; + temp.setNum(_start_time); + _start_time_widget->setText(temp); + temp.setNum(_end_time); + _end_time_widget->setText(temp); + + _ui_stats_area->clear(); + Reinit_scroll_bars(); +} + +void Stats_window::clear() { + _ui_stats_area->makeCurrent(); + _nodes_selected->clear(); + _ui_stats_area->clear(); + _kind_of_state_box->clear(); + Reinit_scroll_bars(); + _ui_stats_area->doneCurrent(); +} + +void Stats_window::set_arguments(std::map<std::string , QVariant *>) { +} + +void Stats_window::execute() { + on_reload_button_clicked(); +} + +string Stats_window::get_name() { + return "Statistics window"; +}*/ diff --git a/src/interface/Interval_select.hpp b/src/interface/Interval_select.hpp new file mode 100644 index 0000000000000000000000000000000000000000..48b40ddb03ba1abbcce6b322842dab199cd6235f --- /dev/null +++ b/src/interface/Interval_select.hpp @@ -0,0 +1,135 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/*! + *\file Interval_select.hpp + */ + +#ifndef INTERVAL_SELECT_HPP +#define INTERVAL_SELECT_HPP + +class Interval_select; + +/* For moc compilation */ +#include <string> +#include <map> +#include <list> +/* -- */ +#include <QWidget> +#include "ui_interval_select.h" + +#include "trace/values/Values.hpp" +#include "trace/EntityValue.hpp" +#include "trace/EntityTypes.hpp" +#include "trace/Entitys.hpp" +#include "trace/tree/Interval.hpp" +#include "trace/Trace.hpp" + +#include "interface/Interface_graphic.hpp" + +/* -- */ + + + + +/*! + * \class Node select + * \brief Class used to select which containers should be displayed + * + */ + +class Interval_select : public QDialog, protected Ui::interval_selector { + + Q_OBJECT + + private: + + Trace* _trace; + Interface_graphic *_console; + bool _applied; + bool _auto_refresh; +public: + /*! + * Default constructor + * \param parent The parent widget of the window. + */ + Interval_select( Interface_graphic *console, QWidget *parent = 0); + + ~Interval_select(); + + /*! + * \fn set_trace(Trace *trace) + * \brief Set the trace parsed (give the container names) + * \param trace The trace. + */ + void set_trace(Trace *trace); + + /*! + * \fn get_trace() + * \brief returns the trace + */ + Trace * get_trace(); + + void apply_settings(); + void update_values(); + + + private slots: + void minSpinBoxValueChanged( double value ); + void minSliderValueChanged( int value ); + void maxSpinBoxValueChanged( double value ); + void maxSliderValueChanged( int value ); + + void on_ok_button_clicked(); + void on_cancel_button_clicked(); + void on_reset_button_clicked(); + void on_apply_button_clicked(); + void on_auto_refresh_box_stateChanged(); + +signals: + void minValueChanged( double value ); + void maxValueChanged( double value ); + + +}; + +#endif // INTERVAL_SELECT_HPP diff --git a/src/interface/Node_select.cpp b/src/interface/Node_select.cpp index 992fd25e5a59cf327463e9272f5f33528c925c27..4e97c5904f13455f7a4d53a31c2f75f07de3fa25 100644 --- a/src/interface/Node_select.cpp +++ b/src/interface/Node_select.cpp @@ -260,7 +260,7 @@ void Stats_window::set_selected_nodes(string kind_of_state){ _nodes_displayed->clear(); //can we load that from _nodes_original instead ? set_displayed_container_names(); - Element_pos zoom[2]={Info::Render::_x_min_visible, Info::Render::_x_max_visible}; + Element_pos zoom[2]={Info::Render::_x_min, Info::Render::_x_max}; Info::Render::_x_min_visible = 0.0; Info::Render::_x_max_visible = 0.0; _trace->set_view_root_containers(_displayed_containers); @@ -335,7 +335,7 @@ void Node_select::on_load_button_clicked(){ build_displayed_nodes(_displayed_containers); _trace->set_view_root_containers(_displayed_containers); - Element_pos it[2]={Info::Render::_x_min_visible, Info::Render::_x_max_visible}; + Element_pos it[2]={Info::Render::_x_min, Info::Render::_x_max}; Info::Render::_x_min_visible = 0.0; Info::Render::_x_max_visible = 0.0; diff --git a/src/interface/Node_select.hpp b/src/interface/Node_select.hpp index 39f67ef2a9eb0eecf290f78dc661236c2138a4b1..c619ed1dfe9f388c8ad22240489ad06f3ad4503d 100644 --- a/src/interface/Node_select.hpp +++ b/src/interface/Node_select.hpp @@ -189,7 +189,6 @@ private slots: void on_export_button_clicked(); void on_load_button_clicked(); -public slots: // just for testing, remove void on_display_button_clicked(); }; diff --git a/src/interface/interval_select.ui b/src/interface/interval_select.ui new file mode 100644 index 0000000000000000000000000000000000000000..15416abc8de9453e84011d6010bcf4cb0e903a78 --- /dev/null +++ b/src/interface/interval_select.ui @@ -0,0 +1,220 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>interval_selector</class> + <widget class="QDialog" name="interval_selector"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>522</width> + <height>283</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>522</width> + <height>283</height> + </size> + </property> + <property name="windowTitle"> + <string>Interval Selection</string> + </property> + <widget class="QxtSpanSlider" name="interval_slider"> + <property name="geometry"> + <rect> + <x>60</x> + <y>140</y> + <width>401</width> + <height>20</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="QDoubleSpinBox" name="minSpinBox"> + <property name="geometry"> + <rect> + <x>140</x> + <y>80</y> + <width>101</width> + <height>22</height> + </rect> + </property> + </widget> + <widget class="QDoubleSpinBox" name="maxSpinBox"> + <property name="geometry"> + <rect> + <x>350</x> + <y>80</y> + <width>101</width> + <height>22</height> + </rect> + </property> + </widget> + <widget class="QLabel" name="label"> + <property name="geometry"> + <rect> + <x>30</x> + <y>140</y> + <width>21</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>Min</string> + </property> + </widget> + <widget class="QLabel" name="label_2"> + <property name="geometry"> + <rect> + <x>470</x> + <y>140</y> + <width>31</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>Max</string> + </property> + </widget> + <widget class="QLabel" name="min_value"> + <property name="geometry"> + <rect> + <x>10</x> + <y>160</y> + <width>46</width> + <height>13</height> + </rect> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + <widget class="QLabel" name="max_value"> + <property name="geometry"> + <rect> + <x>460</x> + <y>160</y> + <width>46</width> + <height>13</height> + </rect> + </property> + <property name="text"> + <string>0</string> + </property> + </widget> + <widget class="QLabel" name="label_5"> + <property name="geometry"> + <rect> + <x>60</x> + <y>80</y> + <width>81</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>New min value :</string> + </property> + </widget> + <widget class="QLabel" name="label_6"> + <property name="geometry"> + <rect> + <x>270</x> + <y>80</y> + <width>81</width> + <height>16</height> + </rect> + </property> + <property name="text"> + <string>New max value :</string> + </property> + </widget> + <widget class="QPushButton" name="ok_button"> + <property name="geometry"> + <rect> + <x>300</x> + <y>240</y> + <width>75</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>OK</string> + </property> + </widget> + <widget class="QPushButton" name="cancel_button"> + <property name="geometry"> + <rect> + <x>390</x> + <y>240</y> + <width>75</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + <widget class="QPushButton" name="reset_button"> + <property name="geometry"> + <rect> + <x>120</x> + <y>240</y> + <width>75</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Reset</string> + </property> + </widget> + <widget class="QPushButton" name="apply_button"> + <property name="geometry"> + <rect> + <x>210</x> + <y>240</y> + <width>75</width> + <height>23</height> + </rect> + </property> + <property name="text"> + <string>Apply</string> + </property> + </widget> + <widget class="QCheckBox" name="auto_refresh_box"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>350</x> + <y>180</y> + <width>171</width> + <height>17</height> + </rect> + </property> + <property name="text"> + <string>Auto Refresh (disable if slow)</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </widget> + <customwidgets> + <customwidget> + <class>QxtSpanSlider</class> + <extends>QSlider</extends> + <header>interface/qxtspanslider.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> diff --git a/src/interface/main_window.ui b/src/interface/main_window.ui index 1b566645c451d867156ea3ca00340a4d4eb430fa..0b33d4fe76d431ffe102700559526258c1e0957d 100644 --- a/src/interface/main_window.ui +++ b/src/interface/main_window.ui @@ -249,6 +249,7 @@ <addaction name="separator"/> <addaction name="show_settings"/> <addaction name="node_selection"/> + <addaction name="interval_selection"/> </widget> <addaction name="menuFile"/> <addaction name="menuView"/> @@ -536,6 +537,11 @@ <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> diff --git a/src/interface/qxtpimpl.h b/src/interface/qxtpimpl.h new file mode 100644 index 0000000000000000000000000000000000000000..52a52a894d15d372e88e39d25a896e75a8956788 --- /dev/null +++ b/src/interface/qxtpimpl.h @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) Adam Higerd <coda@bobandgeorge.com>. Some rights reserved. +** +** This file is part of the QxtCore module of the +** Qt eXTension library <http://libqxt.sourceforge.net> +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License as published by the Free Software Foundation; either +** version 2.1 of the License, or any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** There is aditional information in the LICENSE file of libqxt. +** If you did not receive a copy of the file try to download it or +** contact the libqxt Management +** +****************************************************************************/ +/** +\class QxtPimpl QxtPimpl +\ingroup core +\brief Hide private details of a class + +Application code generally doesn't have to be concerned about hiding its +implementation details, but when writing library code it is important to +maintain a constant interface, both source and binary. Maintaining a constant +source interface is easy enough, but keeping the binary interface constant +means moving implementation details into a private class. The PIMPL, or +d-pointer, idiom is a common method of implementing this separation. QxtPimpl +offers a convenient way to connect the public and private sides of your class. + +\section start Getting Started +Before you declare the public class, you need to make a forward declaration +of the private class. The private class must have the same name as the public +class, followed by the word Private. For example, a class named MyTest would +declare the private class with: +\code +class MyTestPrivate; +\endcode + +\subsection pub The Public Class +Generally, you shouldn't keep any data members in the public class without a +good reason. Functions that are part of the public interface should be declared +in the public class, and functions that need to be available to subclasses (for +calling or overriding) should be in the protected section of the public class. +To connect the private class to the public class, include the +QXT_DECLARE_PRIVATE macro in the private section of the public class. In the +example above, the private class is connected as follows: +\code +private: + QXT_DECLARE_PRIVATE(MyTest); +\endcode + +Additionally, you must include the QXT_INIT_PRIVATE macro in the public class's +constructor. Continuing with the MyTest example, your constructor might look +like this: +\code +MyTest::MyTest() { + // initialization + QXT_INIT_PRIVATE(MyTest); +} +\endcode + +\subsection priv The Private Class +As mentioned above, data members should usually be kept in the private class. +This allows the memory layout of the private class to change without breaking +binary compatibility for the public class. Functions that exist only as +implementation details, or functions that need access to private data members, +should be implemented here. + +To define the private class, inherit from the template QxtPrivate class, and +include the QXT_DECLARE_PUBLIC macro in its public section. The template +parameter should be the name of the public class. For example: +\code +class MyTestPrivate : public QxtPrivate<MyTest> { +public: + MyTestPrivate(); + QXT_DECLARE_PUBLIC(MyTest); +}; +\endcode + +\section cross Accessing Private Members +Use the qxt_d() function (actually a function-like object) from functions in +the public class to access the private class. Similarly, functions in the +private class can invoke functions in the public class by using the qxt_p() +function (this one's actually a function). + +For example, assume that MyTest has methods named getFoobar and doBaz(), +and MyTestPrivate has a member named foobar and a method named doQuux(). +The code might resemble this example: +\code +int MyTest::getFoobar() { + return qxt_d().foobar; +} + +void MyTestPrivate::doQuux() { + qxt_p().doBaz(foobar); +} +\endcode +*/ + +#ifndef QXTPIMPL_H +#define QXTPIMPL_H + +/*! \relates QxtPimpl + * Declares that a public class has a related private class. + * + * This shuold be put in the private section of the public class. The parameter is the name of the public class. + */ +#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d; +/*! \relates QxtPimpl + * Declares that a private class has a related public class. + * + * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class. + */ +#define QXT_DECLARE_PUBLIC(PUB) friend class PUB; +/*! \relates QxtPimpl + * Initializes resources owned by the private class. + * + * This should be called from the public class's constructor, + * before qxt_d() is used for the first time. The parameter is the name of the public class. + */ +#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); + +#ifdef QXT_DOXYGEN_RUN +/*! \relates QxtPimpl + * Returns a reference to the private class. + * + * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + */ +QxtPrivate<PUB>& qxt_d(); + +/*! \relates QxtPimpl + * Returns a const reference to the private class. + * + * This function is only available in a class using \a QXT_DECLARE_PRIVATE. + * This overload will be automatically used in const functions. + */ +const QxtPrivate<PUB>& qxt_d(); + +/*! \relates QxtPimpl + * Returns a reference to the public class. + * + * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + */ +PUB& qxt_p(); + +/*! \relates QxtPimpl + * Returns a const reference to the public class. + * + * This function is only available in a class using \a QXT_DECLARE_PUBLIC. + * This overload will be automatically used in const functions. + */ +const PUB& qxt_p(); +#endif + +#ifndef QXT_DOXYGEN_RUN +template <typename PUB> +class QxtPrivate { +public: + virtual ~QxtPrivate() {} + inline void QXT_setPublic(PUB* pub) { qxt_p_ptr = pub; } + +protected: + inline PUB& qxt_p() { return *qxt_p_ptr; } + inline const PUB& qxt_p() const { return *qxt_p_ptr; } + +private: + PUB* qxt_p_ptr; +}; + +template <typename PUB, typename PVT> +class QxtPrivateInterface { +friend class QxtPrivate<PUB>; +public: + QxtPrivateInterface() { pvt = new PVT; } + ~QxtPrivateInterface() { delete pvt; } + + inline void setPublic(PUB* pub) { pvt->QXT_setPublic(pub); } + inline PVT& operator()() { return *static_cast<PVT*>(pvt); } + inline const PVT& operator()() const { return *static_cast<PVT*>(pvt); } +private: + QxtPrivate<PUB>* pvt; +}; +#endif + +#endif \ No newline at end of file diff --git a/src/interface/qxtspanslider.cpp b/src/interface/qxtspanslider.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1c72fbee4053d71f27efcbfe0db118608804efe4 --- /dev/null +++ b/src/interface/qxtspanslider.cpp @@ -0,0 +1,744 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** <http://libqxt.org> <foundation@libqxt.org> + ** + ****************************************************************************/ +#include "qxtspanslider.h" +#include "qxtspanslider_p.h" +#include <QKeyEvent> +#include <QMouseEvent> +#include <QApplication> +#include <QStylePainter> +#include <QStyleOptionSlider> + +QxtSpanSliderPrivate::QxtSpanSliderPrivate() : + lower(0), + upper(0), + lowerPos(0), + upperPos(0), + offset(0), + position(0), + lastPressed(QxtSpanSlider::NoHandle), + mainControl(QxtSpanSlider::LowerHandle), + lowerPressed(QStyle::SC_None), + upperPressed(QStyle::SC_None), + movement(QxtSpanSlider::FreeMovement), + firstMovement(false), + blockTracking(false) +{ +} + +void QxtSpanSliderPrivate::initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle) const +{ + const QxtSpanSlider* p = &qxt_p(); + p->initStyleOption(option); + option->sliderPosition = (handle == QxtSpanSlider::LowerHandle ? lowerPos : upperPos); + option->sliderValue = (handle == QxtSpanSlider::LowerHandle ? lower : upper); +} + +int QxtSpanSliderPrivate::pixelPosToRangeValue(int pos) const +{ + QStyleOptionSlider opt; + initStyleOption(&opt); + + int sliderMin = 0; + int sliderMax = 0; + int sliderLength = 0; + const QSlider* p = &qxt_p(); + const QRect gr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p); + const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p); + if (p->orientation() == Qt::Horizontal) + { + sliderLength = sr.width(); + sliderMin = gr.x(); + sliderMax = gr.right() - sliderLength + 1; + } + else + { + sliderLength = sr.height(); + sliderMin = gr.y(); + sliderMax = gr.bottom() - sliderLength + 1; + } + return QStyle::sliderValueFromPosition(p->minimum(), p->maximum(), pos - sliderMin, + sliderMax - sliderMin, opt.upsideDown); +} + +void QxtSpanSliderPrivate::handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle) +{ + QStyleOptionSlider opt; + initStyleOption(&opt, handle); + QxtSpanSlider* p = &qxt_p(); + const QStyle::SubControl oldControl = control; + control = p->style()->hitTestComplexControl(QStyle::CC_Slider, &opt, pos, p); + const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p); + if (control == QStyle::SC_SliderHandle) + { + position = value; + offset = pick(pos - sr.topLeft()); + lastPressed = handle; + p->setSliderDown(true); + emit p->sliderPressed(handle); + } + if (control != oldControl) + p->update(sr); +} + +void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const +{ + QColor highlight = qxt_p().palette().color(QPalette::Highlight); + QLinearGradient gradient(x1, y1, x2, y2); + gradient.setColorAt(0, highlight.dark(120)); + gradient.setColorAt(1, highlight.light(108)); + painter->setBrush(gradient); + + if (orientation == Qt::Horizontal) + painter->setPen(QPen(highlight.dark(130), 0)); + else + painter->setPen(QPen(highlight.dark(150), 0)); +} + +void QxtSpanSliderPrivate::drawSpan(QStylePainter* painter, const QRect& rect) const +{ + QStyleOptionSlider opt; + initStyleOption(&opt); + const QSlider* p = &qxt_p(); + + // area + QRect groove = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p); + if (opt.orientation == Qt::Horizontal) + groove.adjust(0, 0, -1, 0); + else + groove.adjust(0, 0, 0, -1); + + // pen & brush + painter->setPen(QPen(p->palette().color(QPalette::Dark).light(110), 0)); + if (opt.orientation == Qt::Horizontal) + setupPainter(painter, opt.orientation, groove.center().x(), groove.top(), groove.center().x(), groove.bottom()); + else + setupPainter(painter, opt.orientation, groove.left(), groove.center().y(), groove.right(), groove.center().y()); + + // draw groove + painter->drawRect(rect.intersected(groove)); +} + +void QxtSpanSliderPrivate::drawHandle(QStylePainter* painter, QxtSpanSlider::SpanHandle handle) const +{ + QStyleOptionSlider opt; + initStyleOption(&opt, handle); + opt.subControls = QStyle::SC_SliderHandle; + QStyle::SubControl pressed = (handle == QxtSpanSlider::LowerHandle ? lowerPressed : upperPressed); + if (pressed == QStyle::SC_SliderHandle) + { + opt.activeSubControls = pressed; + opt.state |= QStyle::State_Sunken; + } + painter->drawComplexControl(QStyle::CC_Slider, opt); +} + +void QxtSpanSliderPrivate::triggerAction(QAbstractSlider::SliderAction action, bool main) +{ + int value = 0; + bool no = false; + bool up = false; + const int min = qxt_p().minimum(); + const int max = qxt_p().maximum(); + const QxtSpanSlider::SpanHandle altControl = (mainControl == QxtSpanSlider::LowerHandle ? QxtSpanSlider::UpperHandle : QxtSpanSlider::LowerHandle); + + blockTracking = true; + + switch (action) + { + case QAbstractSlider::SliderSingleStepAdd: + if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle)) + { + value = qBound(min, upper + qxt_p().singleStep(), max); + up = true; + break; + } + value = qBound(min, lower + qxt_p().singleStep(), max); + break; + case QAbstractSlider::SliderSingleStepSub: + if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle)) + { + value = qBound(min, upper - qxt_p().singleStep(), max); + up = true; + break; + } + value = qBound(min, lower - qxt_p().singleStep(), max); + break; + case QAbstractSlider::SliderToMinimum: + value = min; + if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle)) + up = true; + break; + case QAbstractSlider::SliderToMaximum: + value = max; + if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle)) + up = true; + break; + case QAbstractSlider::SliderMove: + if ((main && mainControl == QxtSpanSlider::UpperHandle) || (!main && altControl == QxtSpanSlider::UpperHandle)) + up = true; + case QAbstractSlider::SliderNoAction: + no = true; + break; + default: + qWarning("QxtSpanSliderPrivate::triggerAction: Unknown action"); + break; + } + + if (!no && !up) + { + if (movement == QxtSpanSlider::NoCrossing) + value = qMin(value, upper); + else if (movement == QxtSpanSlider::NoOverlapping) + value = qMin(value, upper - 1); + + if (movement == QxtSpanSlider::FreeMovement && value > upper) + { + swapControls(); + qxt_p().setUpperPosition(value); + } + else + { + qxt_p().setLowerPosition(value); + } + } + else if (!no) + { + if (movement == QxtSpanSlider::NoCrossing) + value = qMax(value, lower); + else if (movement == QxtSpanSlider::NoOverlapping) + value = qMax(value, lower + 1); + + if (movement == QxtSpanSlider::FreeMovement && value < lower) + { + swapControls(); + qxt_p().setLowerPosition(value); + } + else + { + qxt_p().setUpperPosition(value); + } + } + + blockTracking = false; + qxt_p().setLowerValue(lowerPos); + qxt_p().setUpperValue(upperPos); +} + +void QxtSpanSliderPrivate::swapControls() +{ + qSwap(lower, upper); + qSwap(lowerPressed, upperPressed); + lastPressed = (lastPressed == QxtSpanSlider::LowerHandle ? QxtSpanSlider::UpperHandle : QxtSpanSlider::LowerHandle); + mainControl = (mainControl == QxtSpanSlider::LowerHandle ? QxtSpanSlider::UpperHandle : QxtSpanSlider::LowerHandle); +} + +void QxtSpanSliderPrivate::updateRange(int min, int max) +{ + Q_UNUSED(min); + Q_UNUSED(max); + // setSpan() takes care of keeping span in range + qxt_p().setSpan(lower, upper); +} + +void QxtSpanSliderPrivate::movePressedHandle() +{ + switch (lastPressed) + { + case QxtSpanSlider::LowerHandle: + if (lowerPos != lower) + { + bool main = (mainControl == QxtSpanSlider::LowerHandle); + triggerAction(QAbstractSlider::SliderMove, main); + } + break; + case QxtSpanSlider::UpperHandle: + if (upperPos != upper) + { + bool main = (mainControl == QxtSpanSlider::UpperHandle); + triggerAction(QAbstractSlider::SliderMove, main); + } + break; + default: + break; + } +} + +/*! + \class QxtSpanSlider + \inmodule QxtGui + \brief The QxtSpanSlider widget is a QSlider with two handles. + + QxtSpanSlider is a slider with two handles. QxtSpanSlider is + handy for letting user to choose an span between min/max. + + The span color is calculated based on QPalette::Highlight. + + The keys are bound according to the following table: + \table + \header \o Orientation \o Key \o Handle + \row \o Qt::Horizontal \o Qt::Key_Left \o lower + \row \o Qt::Horizontal \o Qt::Key_Right \o lower + \row \o Qt::Horizontal \o Qt::Key_Up \o upper + \row \o Qt::Horizontal \o Qt::Key_Down \o upper + \row \o Qt::Vertical \o Qt::Key_Up \o lower + \row \o Qt::Vertical \o Qt::Key_Down \o lower + \row \o Qt::Vertical \o Qt::Key_Left \o upper + \row \o Qt::Vertical \o Qt::Key_Right \o upper + \endtable + + Keys are bound by the time the slider is created. A key is bound + to same handle for the lifetime of the slider. So even if the handle + representation might change from lower to upper, the same key binding + remains. + + \image qxtspanslider.png "QxtSpanSlider in Plastique style." + + \bold {Note:} QxtSpanSlider inherits QSlider for implementation specific + reasons. Adjusting any single handle specific properties like + \list + \o QAbstractSlider::sliderPosition + \o QAbstractSlider::value + \endlist + has no effect. However, all slider specific properties like + \list + \o QAbstractSlider::invertedAppearance + \o QAbstractSlider::invertedControls + \o QAbstractSlider::minimum + \o QAbstractSlider::maximum + \o QAbstractSlider::orientation + \o QAbstractSlider::pageStep + \o QAbstractSlider::singleStep + \o QSlider::tickInterval + \o QSlider::tickPosition + \endlist + are taken into consideration. + */ + +/*! + \enum QxtSpanSlider::HandleMovementMode + + This enum describes the available handle movement modes. + + \value FreeMovement The handles can be moved freely. + \value NoCrossing The handles cannot cross, but they can still overlap each other. The lower and upper values can be the same. + \value NoOverlapping The handles cannot overlap each other. The lower and upper values cannot be the same. + */ + +/*! + \enum QxtSpanSlider::SpanHandle + + This enum describes the available span handles. + + \omitvalue NoHandle \omit Internal only (for now). \endomit + \value LowerHandle The lower boundary handle. + \value UpperHandle The upper boundary handle. + */ + +/*! + \fn QxtSpanSlider::lowerValueChanged(int lower) + + This signal is emitted whenever the \a lower value has changed. + */ + +/*! + \fn QxtSpanSlider::upperValueChanged(int upper) + + This signal is emitted whenever the \a upper value has changed. + */ + +/*! + \fn QxtSpanSlider::spanChanged(int lower, int upper) + + This signal is emitted whenever both the \a lower and the \a upper + values have changed ie. the span has changed. + */ + +/*! + \fn QxtSpanSlider::lowerPositionChanged(int lower) + + This signal is emitted whenever the \a lower position has changed. + */ + +/*! + \fn QxtSpanSlider::upperPositionChanged(int upper) + + This signal is emitted whenever the \a upper position has changed. + */ + +/*! + \fn QxtSpanSlider::sliderPressed(SpanHandle handle) + + This signal is emitted whenever the \a handle has been pressed. + */ + +/*! + Constructs a new QxtSpanSlider with \a parent. + */ +QxtSpanSlider::QxtSpanSlider(QWidget* parent) : QSlider(parent) +{ + QXT_INIT_PRIVATE(QxtSpanSlider); + connect(this, SIGNAL(rangeChanged(int, int)), &qxt_d(), SLOT(updateRange(int, int))); + connect(this, SIGNAL(sliderReleased()), &qxt_d(), SLOT(movePressedHandle())); +} + +/*! + Constructs a new QxtSpanSlider with \a orientation and \a parent. + */ +QxtSpanSlider::QxtSpanSlider(Qt::Orientation orientation, QWidget* parent) : QSlider(orientation, parent) +{ + QXT_INIT_PRIVATE(QxtSpanSlider); + connect(this, SIGNAL(rangeChanged(int, int)), &qxt_d(), SLOT(updateRange(int, int))); + connect(this, SIGNAL(sliderReleased()), &qxt_d(), SLOT(movePressedHandle())); +} + +/*! + Destructs the span slider. + */ +QxtSpanSlider::~QxtSpanSlider() +{ +} + +/*! + \property QxtSpanSlider::handleMovementMode + \brief the handle movement mode + */ +QxtSpanSlider::HandleMovementMode QxtSpanSlider::handleMovementMode() const +{ + return qxt_d().movement; +} + +void QxtSpanSlider::setHandleMovementMode(QxtSpanSlider::HandleMovementMode mode) +{ + qxt_d().movement = mode; +} + +/*! + \property QxtSpanSlider::lowerValue + \brief the lower value of the span + */ +int QxtSpanSlider::lowerValue() const +{ + return qMin(qxt_d().lower, qxt_d().upper); +} + +void QxtSpanSlider::setLowerValue(int lower) +{ + setSpan(lower, qxt_d().upper); +} + +/*! + \property QxtSpanSlider::upperValue + \brief the upper value of the span + */ +int QxtSpanSlider::upperValue() const +{ + return qMax(qxt_d().lower, qxt_d().upper); +} + +void QxtSpanSlider::setUpperValue(int upper) +{ + setSpan(qxt_d().lower, upper); +} + +/*! + Sets the span from \a lower to \a upper. + */ +void QxtSpanSlider::setSpan(int lower, int upper) +{ + const int low = qBound(minimum(), qMin(lower, upper), maximum()); + const int upp = qBound(minimum(), qMax(lower, upper), maximum()); + if (low != qxt_d().lower || upp != qxt_d().upper) + { + if (low != qxt_d().lower) + { + qxt_d().lower = low; + qxt_d().lowerPos = low; + emit lowerValueChanged(low); + } + if (upp != qxt_d().upper) + { + qxt_d().upper = upp; + qxt_d().upperPos = upp; + emit upperValueChanged(upp); + } + emit spanChanged(qxt_d().lower, qxt_d().upper); + update(); + } +} + +/*! + \property QxtSpanSlider::lowerPosition + \brief the lower position of the span + */ +int QxtSpanSlider::lowerPosition() const +{ + return qxt_d().lowerPos; +} + +void QxtSpanSlider::setLowerPosition(int lower) +{ + if (qxt_d().lowerPos != lower) + { + qxt_d().lowerPos = lower; + if (!hasTracking()) + update(); + if (isSliderDown()) + emit lowerPositionChanged(lower); + if (hasTracking() && !qxt_d().blockTracking) + { + bool main = (qxt_d().mainControl == QxtSpanSlider::LowerHandle); + qxt_d().triggerAction(SliderMove, main); + } + } +} + +/*! + \property QxtSpanSlider::upperPosition + \brief the upper position of the span + */ +int QxtSpanSlider::upperPosition() const +{ + return qxt_d().upperPos; +} + +void QxtSpanSlider::setUpperPosition(int upper) +{ + if (qxt_d().upperPos != upper) + { + qxt_d().upperPos = upper; + if (!hasTracking()) + update(); + if (isSliderDown()) + emit upperPositionChanged(upper); + if (hasTracking() && !qxt_d().blockTracking) + { + bool main = (qxt_d().mainControl == QxtSpanSlider::UpperHandle); + qxt_d().triggerAction(SliderMove, main); + } + } +} + +/*! + \reimp + */ +void QxtSpanSlider::keyPressEvent(QKeyEvent* event) +{ + QSlider::keyPressEvent(event); + + bool main = true; + SliderAction action = SliderNoAction; + switch (event->key()) + { + case Qt::Key_Left: + main = (orientation() == Qt::Horizontal); + action = !invertedAppearance() ? SliderSingleStepSub : SliderSingleStepAdd; + break; + case Qt::Key_Right: + main = (orientation() == Qt::Horizontal); + action = !invertedAppearance() ? SliderSingleStepAdd : SliderSingleStepSub; + break; + case Qt::Key_Up: + main = (orientation() == Qt::Vertical); + action = invertedControls() ? SliderSingleStepSub : SliderSingleStepAdd; + break; + case Qt::Key_Down: + main = (orientation() == Qt::Vertical); + action = invertedControls() ? SliderSingleStepAdd : SliderSingleStepSub; + break; + case Qt::Key_Home: + main = (qxt_d().mainControl == QxtSpanSlider::LowerHandle); + action = SliderToMinimum; + break; + case Qt::Key_End: + main = (qxt_d().mainControl == QxtSpanSlider::UpperHandle); + action = SliderToMaximum; + break; + default: + event->ignore(); + break; + } + + if (action) + qxt_d().triggerAction(action, main); +} + +/*! + \reimp + */ +void QxtSpanSlider::mousePressEvent(QMouseEvent* event) +{ + if (minimum() == maximum() || (event->buttons() ^ event->button())) + { + event->ignore(); + return; + } + + qxt_d().handleMousePress(event->pos(), qxt_d().upperPressed, qxt_d().upper, QxtSpanSlider::UpperHandle); + if (qxt_d().upperPressed != QStyle::SC_SliderHandle) + qxt_d().handleMousePress(event->pos(), qxt_d().lowerPressed, qxt_d().lower, QxtSpanSlider::LowerHandle); + + qxt_d().firstMovement = true; + event->accept(); +} + +/*! + \reimp + */ +void QxtSpanSlider::mouseMoveEvent(QMouseEvent* event) +{ + if (qxt_d().lowerPressed != QStyle::SC_SliderHandle && qxt_d().upperPressed != QStyle::SC_SliderHandle) + { + event->ignore(); + return; + } + + QStyleOptionSlider opt; + qxt_d().initStyleOption(&opt); + const int m = style()->pixelMetric(QStyle::PM_MaximumDragDistance, &opt, this); + int newPosition = qxt_d().pixelPosToRangeValue(qxt_d().pick(event->pos()) - qxt_d().offset); + if (m >= 0) + { + const QRect r = rect().adjusted(-m, -m, m, m); + if (!r.contains(event->pos())) + { + newPosition = qxt_d().position; + } + } + + // pick the preferred handle on the first movement + if (qxt_d().firstMovement) + { + if (qxt_d().lower == qxt_d().upper) + { + if (newPosition < lowerValue()) + { + qxt_d().swapControls(); + qxt_d().firstMovement = false; + } + } + else + { + qxt_d().firstMovement = false; + } + } + + if (qxt_d().lowerPressed == QStyle::SC_SliderHandle) + { + if (qxt_d().movement == NoCrossing) + newPosition = qMin(newPosition, upperValue()); + else if (qxt_d().movement == NoOverlapping) + newPosition = qMin(newPosition, upperValue() - 1); + + if (qxt_d().movement == FreeMovement && newPosition > qxt_d().upper) + { + qxt_d().swapControls(); + setUpperPosition(newPosition); + } + else + { + setLowerPosition(newPosition); + } + } + else if (qxt_d().upperPressed == QStyle::SC_SliderHandle) + { + if (qxt_d().movement == NoCrossing) + newPosition = qMax(newPosition, lowerValue()); + else if (qxt_d().movement == NoOverlapping) + newPosition = qMax(newPosition, lowerValue() + 1); + + if (qxt_d().movement == FreeMovement && newPosition < qxt_d().lower) + { + qxt_d().swapControls(); + setLowerPosition(newPosition); + } + else + { + setUpperPosition(newPosition); + } + } + event->accept(); +} + +/*! + \reimp + */ +void QxtSpanSlider::mouseReleaseEvent(QMouseEvent* event) +{ + QSlider::mouseReleaseEvent(event); + setSliderDown(false); + qxt_d().lowerPressed = QStyle::SC_None; + qxt_d().upperPressed = QStyle::SC_None; + update(); +} + +/*! + \reimp + */ +void QxtSpanSlider::paintEvent(QPaintEvent* event) +{ + Q_UNUSED(event); + QStylePainter painter(this); + + // groove & ticks + QStyleOptionSlider opt; + qxt_d().initStyleOption(&opt); + opt.sliderValue = 0; + opt.sliderPosition = 0; + opt.subControls = QStyle::SC_SliderGroove | QStyle::SC_SliderTickmarks; + painter.drawComplexControl(QStyle::CC_Slider, opt); + + // handle rects + opt.sliderPosition = qxt_d().lowerPos; + const QRect lr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); + const int lrv = qxt_d().pick(lr.center()); + opt.sliderPosition = qxt_d().upperPos; + const QRect ur = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); + const int urv = qxt_d().pick(ur.center()); + + // span + const int minv = qMin(lrv, urv); + const int maxv = qMax(lrv, urv); + const QPoint c = QRect(lr.center(), ur.center()).center(); + QRect spanRect; + if (orientation() == Qt::Horizontal) + spanRect = QRect(QPoint(minv, c.y() - 2), QPoint(maxv, c.y() + 1)); + else + spanRect = QRect(QPoint(c.x() - 2, minv), QPoint(c.x() + 1, maxv)); + qxt_d().drawSpan(&painter, spanRect); + + // handles + switch (qxt_d().lastPressed) + { + case QxtSpanSlider::LowerHandle: + qxt_d().drawHandle(&painter, QxtSpanSlider::UpperHandle); + qxt_d().drawHandle(&painter, QxtSpanSlider::LowerHandle); + break; + case QxtSpanSlider::UpperHandle: + default: + qxt_d().drawHandle(&painter, QxtSpanSlider::LowerHandle); + qxt_d().drawHandle(&painter, QxtSpanSlider::UpperHandle); + break; + } +} diff --git a/src/interface/qxtspanslider.h b/src/interface/qxtspanslider.h new file mode 100644 index 0000000000000000000000000000000000000000..f0b853994c4fe15f0505d528870e5ccd97397ee6 --- /dev/null +++ b/src/interface/qxtspanslider.h @@ -0,0 +1,98 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** <http://libqxt.org> <foundation@libqxt.org> + ** + ****************************************************************************/ +#ifndef QXTSPANSLIDER_H +#define QXTSPANSLIDER_H + +#include <QSlider> +#include "interface/qxtpimpl.h" + +class QxtSpanSliderPrivate; + +class QxtSpanSlider : public QSlider +{ + Q_OBJECT + QXT_DECLARE_PRIVATE(QxtSpanSlider) + Q_PROPERTY(int lowerValue READ lowerValue WRITE setLowerValue) + Q_PROPERTY(int upperValue READ upperValue WRITE setUpperValue) + Q_PROPERTY(int lowerPosition READ lowerPosition WRITE setLowerPosition) + Q_PROPERTY(int upperPosition READ upperPosition WRITE setUpperPosition) + Q_PROPERTY(HandleMovementMode handleMovementMode READ handleMovementMode WRITE setHandleMovementMode) + Q_ENUMS(HandleMovementMode) + +public: + explicit QxtSpanSlider(QWidget* parent = 0); + explicit QxtSpanSlider(Qt::Orientation orientation, QWidget* parent = 0); + virtual ~QxtSpanSlider(); + + enum HandleMovementMode + { + FreeMovement, + NoCrossing, + NoOverlapping + }; + + enum SpanHandle + { + NoHandle, + LowerHandle, + UpperHandle + }; + + HandleMovementMode handleMovementMode() const; + void setHandleMovementMode(HandleMovementMode mode); + + int lowerValue() const; + int upperValue() const; + + int lowerPosition() const; + int upperPosition() const; + +public Q_SLOTS: + void setLowerValue(int lower); + void setUpperValue(int upper); + void setSpan(int lower, int upper); + + void setLowerPosition(int lower); + void setUpperPosition(int upper); + +Q_SIGNALS: + void spanChanged(int lower, int upper); + void lowerValueChanged(int lower); + void upperValueChanged(int upper); + + void lowerPositionChanged(int lower); + void upperPositionChanged(int upper); + + void sliderPressed(SpanHandle handle); + +protected: + virtual void keyPressEvent(QKeyEvent* event); + virtual void mousePressEvent(QMouseEvent* event); + virtual void mouseMoveEvent(QMouseEvent* event); + virtual void mouseReleaseEvent(QMouseEvent* event); + virtual void paintEvent(QPaintEvent* event); +}; + +#endif // QXTSPANSLIDER_H diff --git a/src/interface/qxtspanslider_p.h b/src/interface/qxtspanslider_p.h new file mode 100644 index 0000000000000000000000000000000000000000..290415efb124e1de4400ce6123e2e886df031b4d --- /dev/null +++ b/src/interface/qxtspanslider_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** + ** + ** Copyright (C) Qxt Foundation. Some rights reserved. + ** + ** This file is part of the QxtGui module of the Qxt library. + ** + ** This library is free software; you can redistribute it and/or modify it + ** under the terms of the Common Public License, version 1.0, as published + ** by IBM, and/or under the terms of the GNU Lesser General Public License, + ** version 2.1, as published by the Free Software Foundation. + ** + ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY + ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY + ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR + ** FITNESS FOR A PARTICULAR PURPOSE. + ** + ** You should have received a copy of the CPL and the LGPL along with this + ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files + ** included with the source distribution for more information. + ** If you did not receive a copy of the licenses, contact the Qxt Foundation. + ** + ** <http://libqxt.org> <foundation@libqxt.org> + ** + ****************************************************************************/ +#ifndef QXTSPANSLIDER_P_H +#define QXTSPANSLIDER_P_H + +#include <QStyle> +#include <QObject> +#include "interface/qxtspanslider.h" +#include "interface/qxtpimpl.h" + +QT_FORWARD_DECLARE_CLASS(QStylePainter) +QT_FORWARD_DECLARE_CLASS(QStyleOptionSlider) + +class QxtSpanSliderPrivate : public QObject, public QxtPrivate<QxtSpanSlider> +{ + Q_OBJECT + +public: + QXT_DECLARE_PUBLIC(QxtSpanSlider) + + QxtSpanSliderPrivate(); + void initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle = QxtSpanSlider::UpperHandle) const; + int pick(const QPoint& pt) const + { + return qxt_p().orientation() == Qt::Horizontal ? pt.x() : pt.y(); + } + int pixelPosToRangeValue(int pos) const; + void handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle); + void drawHandle(QStylePainter* painter, QxtSpanSlider::SpanHandle handle) const; + void setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const; + void drawSpan(QStylePainter* painter, const QRect& rect) const; + void triggerAction(QAbstractSlider::SliderAction action, bool main); + void swapControls(); + + int lower; + int upper; + int lowerPos; + int upperPos; + int offset; + int position; + QxtSpanSlider::SpanHandle lastPressed; + QxtSpanSlider::SpanHandle mainControl; + QStyle::SubControl lowerPressed; + QStyle::SubControl upperPressed; + QxtSpanSlider::HandleMovementMode movement; + bool firstMovement; + bool blockTracking; + +public Q_SLOTS: + void updateRange(int min, int max); + void movePressedHandle(); +}; + +#endif // QXTSPANSLIDER_P_H diff --git a/src/parser/mt_ParserPaje.cpp b/src/parser/mt_ParserPaje.cpp index c9f20dffb713104d91f2fd261de4da6fb096c47c..fecbf386565a3b2f948c83036bc9e053bdd26dfa 100644 --- a/src/parser/mt_ParserPaje.cpp +++ b/src/parser/mt_ParserPaje.cpp @@ -122,7 +122,6 @@ mt_ParserPaje::~mt_ParserPaje() { void mt_ParserPaje::parse(Trace &trace, bool finish_trace_after_parse) { - static const string PERCENT = "%"; #ifdef DBG_PARSER_PAJE diff --git a/src/render/Geometry.cpp b/src/render/Geometry.cpp index ca0b352a86c5f885acbbec2b78e5e99a82976947..017bef9ea8b8ba9ff822bfcc5d5e1471c4854b7c 100644 --- a/src/render/Geometry.cpp +++ b/src/render/Geometry.cpp @@ -201,6 +201,8 @@ Element_pos Geometry::coeff_trace_render_y() const { void Geometry::update_visible_interval_value() const { Info::Render::_x_min_visible = max(Info::Entity::x_min, (_x_state_translate - _default_entity_x_translate )/coeff_trace_render_x()); + Info::Render::_x_min=max(Info::Entity::x_min, _x_state_translate/coeff_trace_render_x()); + Info::Render::_x_max=min(Info::Entity::x_max, (_x_state_translate- _default_entity_x_translate + Info::Render::width)/coeff_trace_render_x()); Info::Render::_x_max_visible = min(Info::Entity::x_max, (_x_state_translate - _default_entity_x_translate + Info::Render::width)/coeff_trace_render_x()); } /* diff --git a/src/render/Hook_event.cpp b/src/render/Hook_event.cpp index bdfc18b8c752e44cc4d52417aed5d4a9a00603ec..8815a23bb0fd2b9e9a9babd790f92a56f48d37c9 100644 --- a/src/render/Hook_event.cpp +++ b/src/render/Hook_event.cpp @@ -497,8 +497,7 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po int buf; _x_state_scale *= (Info::Render::width*(1-_x_scale_container_state)) / screen_to_render_x(x_max - x_min); - buf = (int)(100*_x_state_scale); - _core->launch_action(_core->_STATE_ZOOM_BOX_VALUE, &buf); + _y_state_scale *= (Info::Render::height - _ruler_height) / screen_to_render_y(y_max - y_min); @@ -531,7 +530,8 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po } #endif - + buf = (int)(100*_x_state_scale); + _core->launch_action(_core->_STATE_ZOOM_BOX_VALUE, &buf); /* Update render */ updateRender(); refresh_scroll_bars(true); diff --git a/src/src.pro b/src/src.pro index ed0b65f02ca0c0958e18b91e93c8d13f36fefc8c..6e11722231e773599366fbe705926a40e22dcbb7 100644 --- a/src/src.pro +++ b/src/src.pro @@ -54,9 +54,9 @@ TARGET = vite macx:QMAKE_LIBS_OPENGL += -framework -lobjc DEPENDPATH += . INCLUDEPATH += . -QMAKE_CFLAGS += -O2 -Wall -g +QMAKE_CFLAGS += -O2 -Wall -g -DMT_PARSING -DBOOST_GZIP #-DMT_PARSING -QMAKE_CXXFLAGS += -O2 -Wall -g -DMT_PARSING +QMAKE_CXXFLAGS += -O2 -Wall -g -DMT_PARSING -DBOOST_GZIP #TRANSLATIONS = ViTE_fr.ts #LIBS += -lGLEW @@ -81,6 +81,9 @@ HEADERS += common/common.hpp \ interface/resource.hpp \ interface/Node_select.hpp \ interface/viteqtreewidget.hpp \ + interface/Interval_select.hpp \ + interface/qxtspanslider.h \ + interface/qxtspanslider_p.h \ # Core header core/Core.hpp \ # Render headers @@ -167,7 +170,8 @@ FORMS += interface/info_window.ui \ interface/stats_viewer.ui \ interface/global_cmd.ui \ interface/list_of_counter_to_export.ui\ - interface/node_select.ui + interface/node_select.ui \ + interface/interval_select.ui SOURCES += common/Message.cpp \ common/Errors.cpp \ @@ -238,6 +242,8 @@ SOURCES += common/Message.cpp \ interface/interface_graphic.cpp \ interface/Node_select.cpp \ interface/viteqtreewidget.cpp \ + interface/Interval_select.cpp + interface/qxtspanslider.cpp # Core code file core/Core.cpp \ # Plugin code file diff --git a/src/trace/Container.cpp b/src/trace/Container.cpp index d33d1cbc2b5b190a00f31c4624e81d41f8cffd5e..fa2941050d8ca187cf3f97f0c7c5d992249352d0 100644 --- a/src/trace/Container.cpp +++ b/src/trace/Container.cpp @@ -634,7 +634,7 @@ void Container::loadItcInside(Interval* splitInterval){ if((*it)->_loaded==false){ sprintf(name, "%s/%d_%d",Info::Splitter::path.c_str(),_uid ,i); - //printf("%s : need to load itc beginning at %lf and finishing at %lf, file %s \n", _name.to_string().c_str(), (*it)->_beginning.get_value(), (*it)->_end.get_value(), name); + // printf("%s : need to load itc beginning at %lf and finishing at %lf, file %s \n", _name.to_string().c_str(), (*it)->_beginning.get_value(), (*it)->_end.get_value(), name); loading=(*it)->retrieve(name); if(loading==true)(*it)->_loaded=true; @@ -642,7 +642,15 @@ void Container::loadItcInside(Interval* splitInterval){ } - } + }else{ + //if the itc is loaded, unload it ! + if((*it)->_loaded==true){ + (*it)->unload(); + (*it)->_loaded=false; + // printf("%s :unload itc beginning at %lf and finishing at %lf, file %s \n", _name.to_string().c_str(), (*it)->_beginning.get_value(), (*it)->_end.get_value(), name); + } + + } i++; @@ -709,13 +717,17 @@ void Container::finish(const Date &time) { //boolean to check if the intervalOfcontainer is fully inside the visible interval, in order not to check each state if yes // bool fully_contained=false; +if(_event_tree)delete _event_tree; +if(_state_tree!=NULL)delete _state_tree; +_event_tree=NULL; +_state_tree=NULL; if(Info::Splitter::load_splitted==false){ if (_destruction_time.get_value() == 0.0) destroy(time); - if(_n_events!=0)delete _event_tree; - if(_n_states!=0)delete _state_tree; + + _states.clear(); _links.clear(); _variables.clear(); diff --git a/src/trace/Serializer_container.hpp b/src/trace/Serializer_container.hpp index 2f864bf692df42a37ba5041867f82536e418f074..f76c048bd8d4eb6439d1b8eb24f02df535335a59 100644 --- a/src/trace/Serializer_container.hpp +++ b/src/trace/Serializer_container.hpp @@ -96,6 +96,9 @@ ar & itc->_beginning; ar & itc->_end; ar & itc->_states_values_map; + + if(itc->_beginning<Info::Entity::x_min)Info::Entity::x_min=itc->_beginning.get_value(); + if(itc->_end>Info::Entity::x_max)Info::Entity::x_max=itc->_end.get_value(); _intervalsOfContainer.push_back(itc); } } diff --git a/src/trace/Trace.cpp b/src/trace/Trace.cpp index 4f752e404368ba271c28e4c7b8598ebfc43a1f66..eae762cd218293f760df89f1da53aaf0db0fe050 100644 --- a/src/trace/Trace.cpp +++ b/src/trace/Trace.cpp @@ -414,13 +414,15 @@ void Trace::finish() { #if defined(USE_ITC) && defined(BOOST_SERIALIZE) void Trace::updateTrace(Interval* interval){ -if(Info::Splitter::preview==false){ - loadTraceInside(interval); - finish(); -}else{ - loadPreview(); +if(Info::Splitter::load_splitted==true){ + if(Info::Splitter::preview==false){ + loadTraceInside(interval); + finish(); + }else{ + loadPreview(); } + } } diff --git a/src/trace/tree/Node.hpp b/src/trace/tree/Node.hpp index cb142486c715c2ca72fee3335a14adabdc9df5f7..fc7e32719aafd6258246fd30f247b9ef26d0a94f 100644 --- a/src/trace/tree/Node.hpp +++ b/src/trace/tree/Node.hpp @@ -87,7 +87,7 @@ public: delete _left_child; if(_right_child) delete _right_child; - delete _element; + // delete _element; _element = NULL; _left_child = NULL; _right_child = NULL;