Commit 2026cfee authored by Mathieu Faverge's avatar Mathieu Faverge

Add counter exports

parent 8a2bfac1
......@@ -122,6 +122,9 @@ SET(VITE_UIS
interface/option_export_window.ui
interface/stats_viewer.ui
interface/global_cmd.ui
interface/global_cmd.ui
interface/kind_of_export.ui
interface/list_of_counter_to_export.ui
)
SET(VITE_SRCS
......
......@@ -53,7 +53,8 @@
#include <iostream>/* to use the C standard library input output functions */
#include <string>
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
#include <math.h> /* for min and max functions */
#include <math.h> /* for M_PI */
#include <algorithm> /* for min and max functions */
#include <sstream>
/* -- */
/* -- */
......
This diff is collapsed.
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......@@ -51,6 +51,7 @@ class Core;
class Interface_graphic;
class Render_opengl;
class Trace;
class Variable;
#include "interface/Interface.hpp"
......@@ -439,8 +440,11 @@ public:
Trace *get_trace() const;
/*!
*\brief Export a counter
* Need to choose a counter, and a filename
*/
void export_variable(Variable *var, std::string filename);
public slots:
......
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......@@ -46,6 +46,7 @@
*/
#include <fstream>
#include <string>
#include <stack>
#include <map>
#include <list>
/* -- */
......@@ -56,6 +57,9 @@
#include "common/Tools.hpp"
/* -- */
#include "trace/values/Values.hpp"
#include "trace/EntityTypes.hpp"
#include "trace/Entitys.hpp"
#include "trace/Trace.hpp"
/* -- */
#include "render/render.hpp"
#include "render/render_svg.hpp"
......@@ -102,7 +106,7 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa
setMouseTracking (true);/* to catch mouse events */
_stats_window = new Stats_window(this);
_stats_window = NULL; // Creation when needed (when it has to be shown)
// _cmd_window = NULL;
_cmd_window = new Command_window(this,this);
......@@ -110,7 +114,8 @@ Interface_graphic::Interface_graphic(Core* core, QWidget *parent):QMainWindow(pa
Interface_graphic::~Interface_graphic(){
delete _stats_window;
if(_stats_window != NULL)
delete _stats_window;
/* Qt desallocates this, _ui_info_window and _render_area automatically */
}
......@@ -133,6 +138,8 @@ void Interface_graphic::load_windows(){
QFile file_info( ":/window/info_window.ui");
QFile file_selection_export(":/window/option_export_window.ui");
QFile file_help(":/window/help_window.ui");
QFile file_kind_of_export(":/window/kind_of_export.ui");
QFile file_counter_to_export(":/window/list_of_counter_to_export.ui");
if (!QGLFormat::hasOpenGL())
qFatal("This system has no OpenGL support");
......@@ -147,11 +154,25 @@ void Interface_graphic::load_windows(){
CKFP(_ui_time_selection_export = loader.load(&file_selection_export, this), "Cannot open the .ui file : " << ":/window/option_export_window.ui");
file_selection_export.close();
/* Load the choice counter for export box */
file_counter_to_export.open(QFile::ReadOnly);
CKFP(_ui_counter_choice_to_export = loader.load(&file_counter_to_export, this), "Cannot open the .ui file : " << ":/window/option_export_window.ui");
CKFP(_counter_list_names = qFindChild<QComboBox*>(_ui_counter_choice_to_export, "combobox"), "Cannot find the svg export button in the .ui file");
file_counter_to_export.close();
/* Load the help dialog box from a .ui file */
file_help.open(QFile::ReadOnly);
CKFP(_ui_help_window = loader.load(&file_help, this), "Cannot open the .ui file : " << ":/window/help_window.ui");
file_help.close();
/* Load the export combo box choice from a .ui file */
file_kind_of_export.open(QFile::ReadOnly);
CKFP(_ui_kind_of_export_choice = loader.load(&file_kind_of_export, this), "Cannot open the .ui file : " << ":/window/kind_of_export.ui");
CKFP(_ui_svg_export_button = qFindChild<QRadioButton*>(_ui_kind_of_export_choice, "svg_export"), "Cannot find the svg export button in the .ui file");
CKFP(_ui_counter_export_button = qFindChild<QRadioButton*>(_ui_kind_of_export_choice, "counter_export"), "Cannot find the svg export button in the .ui file");
file_kind_of_export.close();
/* Set some windows properties */
_ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint);/* Always display info_window on top */
_ui_time_selection_export->setWindowFlags(_ui_time_selection_export->windowFlags() | Qt::WindowStaysOnTopHint);
......@@ -193,6 +214,11 @@ void Interface_graphic::load_windows(){
CKFP(_ui_help_ok_button = qFindChild<QPushButton*>(_ui_help_window, "help_ok"), "Cannot find the ok push button in the help dialog .ui file");
connect(_ui_counter_choice_to_export, SIGNAL(accepted()),
this, SLOT(counter_choosed_triggered()));
connect(_ui_kind_of_export_choice, SIGNAL(accepted()),
this, SLOT(choice_of_the_export_pressed()));
connect(_ui_export_ok_button, SIGNAL(pressed()),
this, SLOT(option_export_ok_pressed()));
......@@ -448,22 +474,58 @@ void Interface_graphic::on_open_triggered(){
}
void Interface_graphic::choice_of_the_export_pressed() {
if(_ui_svg_export_button->isChecked()) {
ostringstream temp;
temp.str("");
temp << Info::Render::_x_min_visible;
_ui_min_time_export->setText(temp.str().c_str());
temp.str("");
temp << Info::Render::_x_max_visible;
_ui_max_time_export->setText(temp.str().c_str());
_ui_time_selection_export->show();
}
else if (_ui_counter_export_button->isChecked()) {
// In order to easily retrieve the good variable, we store them with an index representing the container name followed by the variabletype name (because a variable has no name)
_all_variables.clear();
_core->get_trace()->get_all_variables(_all_variables);
map<string, Variable *>::const_iterator it_end = _all_variables.end();
_counter_list_names->clear();
for(map<string, Variable *>::const_iterator it = _all_variables.begin();
it != it_end ;
it ++) {
_counter_list_names->addItem(QString::fromStdString((*it).first));
}
if(_counter_list_names->count() == 0) {
error("The trace has no counter");
return;
}
_ui_counter_choice_to_export->show();
}
}
void Interface_graphic::counter_choosed_triggered() {
// Il faut faire choisir le nom du fichier! et enfin on peut lancer l'action !
const QString path_by_default = QString(_trace_path.substr(0, _trace_path.find_last_of('.')).c_str()) + ".txt";
QString filename = QFileDialog::getSaveFileName(this, QObject::tr("Export File"),
path_by_default,
QObject::tr("All files"));
Variable *temp = _all_variables[_counter_list_names->currentText().toStdString()];
_core->export_variable(temp, filename.toStdString());
}
void Interface_graphic::on_export_file_triggered(){
if(_is_rendering_trace == false)
return;
ostringstream temp;
temp.str("");
temp << Info::Render::_x_min_visible;
_ui_min_time_export->setText(temp.str().c_str());
temp.str("");
temp << Info::Render::_x_max_visible;
_ui_max_time_export->setText(temp.str().c_str());
_ui_time_selection_export->show();
_ui_kind_of_export_choice->show();
}
void Interface_graphic::option_export_ok_pressed(){
......@@ -619,14 +681,11 @@ void Interface_graphic::on_help_triggered(){
void Interface_graphic::on_about_triggered(){
/* QMessageBox::about(this, tr("About ViTE"),
tr("<b>ViTE</b> is a trace format visualizer developped "
"by french engineering school students for INRIA researchers (<a href='http://www.inria.fr'>http://www.inria.fr</a>).<br/><br/>"
"It is licensed under <i>CECILL-A</i>."));*/
QMessageBox::about(this, tr("About ViTE"),
tr("<h2>ViTE</h2>"
"the <b>Vi</b><i>sual </i><b>T</b><i>race</i> <b>E</b><i>xplorer</i> - <i>version 1.0</i> - <i>June 2009</i>.<br /><br />"
"the <b>Vi</b><i>sual </i><b>T</b><i>race</i> <b>E</b><i>xplorer</i> - <i>version "
VITE_VERSION
"</i> - <i>June 2009</i>.<br /><br />"
"Under the CeCILL A licence. The content can be found <a href=\"http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt\">here</a>."
"<p><b>Developers:</b><ul><li>Kevin COULOMB</li><li>Mathieu FAVERGE</li><li>Johnny JAZEIX</li><li>Olivier LAGRASSE</li><li>Jule MARCOUEILLE</li><li>Pascal NOISETTE</li><li>Arthur REDONDY</li><li>Cl&eacute;ment VUCHENER</li></ul></p>"
"The main page project is: <a href=\"http://vite.gforge.inria.fr/\">http://vite.gforge.inria.fr/</a>.<br /><br />"));
......@@ -634,6 +693,11 @@ void Interface_graphic::on_about_triggered(){
void Interface_graphic::on_show_stats_triggered(){
if(_core->get_trace() != NULL) {
if(_stats_window == NULL) { //Creation of the window
_stats_window = new Stats_window(this);
}
_stats_window->set_filename(_core->get_filename());
_stats_window->set_trace(_core->get_trace());
_stats_window->init_window();
......
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......@@ -53,7 +53,7 @@ class Core;
class Stats_window;
class Command_window;
class Svg;
class Variable;
#include "ui_main_window.h"/* the main window graphical interface */
......@@ -260,6 +260,27 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
Command_window * _cmd_window;
/***********************************
*
* Export windows.
*
**********************************/
/*!
* \brief ComboBox which allow the choice between svg export and counter export.
*/
QWidget* _ui_kind_of_export_choice;
QRadioButton* _ui_svg_export_button;
QRadioButton* _ui_counter_export_button;
/*!
* \brief ComboBox which allow the choice between all the counters to be exported.
*/
QWidget* _ui_counter_choice_to_export;
QComboBox *_counter_list_names;
std::map <std::string, Variable *> _all_variables;
/***********************************
*
* Help window.
......@@ -460,6 +481,16 @@ protected slots:
*/
void on_export_file_triggered();
/*!
*\brief A slot called when the choice of the export is done and ok.
*/
void choice_of_the_export_pressed();
/*!
*\brief A slot called when the choice of the counter is done and ok.
*/
void counter_choosed_triggered();
/*!
*\brief A slot called when the options in export are ok.
*/
......
<ui version="4.0" >
<class>kind_of_export</class>
<widget class="QDialog" name="kind_of_export" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>255</height>
</rect>
</property>
<property name="windowTitle" >
<string>Kind of export</string>
</property>
<property name="windowIcon" >
<iconset resource="vite.qrc" >
<normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="title" >
<string>Choose the kind of export:</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QRadioButton" name="svg_export" >
<property name="text" >
<string>Svg export of all the trace</string>
</property>
<property name="checked" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="counter_export" >
<property name="text" >
<string>Counter export</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<zorder>buttonBox</zorder>
<zorder>groupBox</zorder>
</widget>
<resources>
<include location="vite.qrc" />
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>kind_of_export</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>kind_of_export</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>184</x>
<y>229</y>
</hint>
<hint type="destinationlabel" >
<x>184</x>
<y>127</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<ui version="4.0" >
<class>counter_choice_box</class>
<widget class="QDialog" name="counter_choice_box" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>245</width>
<height>153</height>
</rect>
</property>
<property name="windowTitle" >
<string>Selection of the counter</string>
</property>
<property name="windowIcon" >
<iconset resource="vite.qrc" >
<normaloff>:/icon/icon/vite.png</normaloff>:/icon/icon/vite.png</iconset>
</property>
<property name="modal" >
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Choose the counter to export
in the following list</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combobox" />
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
<zorder>buttonBox</zorder>
<zorder>label</zorder>
<zorder>combobox</zorder>
</widget>
<resources>
<include location="vite.qrc" />
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>counter_choice_box</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>counter_choice_box</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -30,5 +30,7 @@
<file>main_window.ui</file>
<file>option_export_window.ui</file>
<file>stats_viewer.ui</file>
<file>kind_of_export.ui</file>
<file>list_of_counter_to_export.ui</file>
</qresource>
</RCC>
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......@@ -41,7 +41,7 @@
**
*/
/*!
* \file command_window.cpp
* \file Command_window.cpp
*/
#include <vector>
......
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......@@ -59,7 +59,6 @@ class Interface_graphic;
class Container;
class Trace;
class QTreeWidgetItem;
class QProcess;
class Command_window : public QMainWindow, protected Ui::Execution{
......@@ -70,7 +69,6 @@ private :
Trace* _trace;
// _node_selected;
QStringList _cmd;
QProcess * _process;
QVBoxLayout * _ui_layout;
QLineEdit* _ui_cmd_box;
QLineEdit* _ui_start_box;
......
......@@ -222,8 +222,8 @@ inline void Render_stats_svg::start_draw(){
}
inline void Render_stats_svg::draw_text(const Element_pos x, const Element_pos y, const std::string value) {
_y_min = fmin(y-5, _y_min);
_y_max = fmax(y+5, _y_max);
_y_min = std::min(y-5, _y_min);
_y_max = std::max(y+5, _y_max);
_text_pos.push_back(x);
_text_pos.push_back(y);
......@@ -231,8 +231,8 @@ inline void Render_stats_svg::draw_text(const Element_pos x, const Element_pos y
}
inline void Render_stats_svg::draw_line(const Element_pos x, const Element_pos y, const Element_pos x2, const Element_pos y2) {
_y_min = fmin(fmin(y, y2), _y_min);
_y_max = fmax(fmax(y, y2), _y_max);
_y_min = std::min(std::min(y, y2), _y_min);
_y_max = std::max(std::max(y, y2), _y_max);
_line_pos.push_back(x);
_line_pos.push_back(y);
......@@ -241,8 +241,8 @@ inline void Render_stats_svg::draw_line(const Element_pos x, const Element_pos y
}
inline void Render_stats_svg::draw_horizontal_line(const Element_pos x, const Element_pos y, const Element_pos size_x){
_y_min = fmin(y, _y_min);
_y_max = fmax(y, _y_max);
_y_min = std::min(y, _y_min);
_y_max = std::max(y, _y_max);
_line_pos.push_back(x);
_line_pos.push_back(y);
......@@ -252,8 +252,8 @@ inline void Render_stats_svg::draw_horizontal_line(const Element_pos x, const El
inline void Render_stats_svg::draw_vertical_line(const Element_pos x, const Element_pos y, const Element_pos size_y){
_y_min = fmin(fmin(y, y+size_y), _y_min);
_y_max = fmax(fmax(y, y+size_y), _y_max);
_y_min = std::min(std::min(y, y+size_y), _y_min);
_y_max = std::max(std::max(y, y+size_y), _y_max);
_line_pos.push_back(x);
_line_pos.push_back(y);
......@@ -268,8 +268,8 @@ inline void Render_stats_svg::draw_axis(const Element_pos x, const Element_pos y
inline void Render_stats_svg::draw_rect(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h, const Element_pos r, const Element_pos g, const Element_pos b) {
_y_min = fmin(fmin(y, y+h), _y_min);
_y_max = fmax(fmax(y, y+h), _y_max);
_y_min = std::min(std::min(y, y+h), _y_min);
_y_max = std::max(std::max(y, y+h), _y_max);
_rect_pos.push_back(x);
_rect_pos.push_back(y);
......
......@@ -145,7 +145,8 @@ HEADERS += common/common.hpp \
plugin/Command_window.hpp
FORMS += interface/info_window.ui interface/main_window.ui interface/option_export_window.ui interface/stats_viewer.ui interface/global_cmd.ui
FORMS += interface/info_window.ui interface/main_window.ui interface/option_export_window.ui interface/stats_viewer.ui interface/global_cmd.ui interface/kind_of_export.ui list_of_counter_to_export.ui
SOURCES += common/Message.cpp \
common/Errors.cpp \
common/Tools.cpp \
......
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......
......@@ -28,7 +28,7 @@
** knowledge of the CeCILL-A license and that you accept its terms.
**
**
** ViTE developpers are (for version 0.* to 1.0):
** ViTE developers are (for version 0.* to 1.0):
**
** - COULOMB Kevin
** - FAVERGE Mathieu
......
......@@ -126,14 +126,16 @@ void Container::set_state(Date time, StateType *type, EntityValue *value, map<st
_current_states.pop();
}
_current_states.push((current_state_t){time, type, value, opt});
current_state_t t(time, type, value, opt);
_current_states.push(t);
}
void Container::push_state(Date time, StateType *type, EntityValue *value, map<std::string, Value *> &opt) {
if (!_current_states.empty())
add_current_state(time);
_current_states.push((current_state_t){time, type, value, opt});
current_state_t t(time, type, value, opt);
_current_states.push(t);
}
void Container::pop_state(Date time) {
......@@ -153,7 +155,8 @@ void Container::new_event(Date time, EventType *type, EntityValue *value, map<st
}
void Container::start_link(Date time, LinkType *type, Container *source, EntityValue *value, String key, map<std::string, Value *> &opt) {
_current_links[key] = (current_link_t){time, type, source, value, opt};
current_link_t t(time, type, source, value, opt);
_current_links[key] = t;
}
void Container::end_link(Date time, Container *destination, String key, map<std::string, Value *> &opt) {
......
......@@ -82,6 +82,8 @@ private:
StateType *type;
EntityValue *value;
std::map<std::string, Value *> opt;
current_state_t(Date t,StateType *st,EntityValue *val, std::map<std::string, Value *> o) : start(t), type(st), value(val), opt(o) {}
current_state_t() : start(0), type(NULL), value(NULL) {}
};
std::stack<current_state_t> _current_states;
......@@ -94,6 +96,10 @@ private:
Container *source;
EntityValue *value;
std::map<std::string, Value *> opt;
current_link_t(Date st, LinkType *ty, Container *src, EntityValue *val, std::map<std::string, Value *> o) : start(st), type(ty), source(src), value(val), opt(o) {}
current_link_t() : start(0), type(NULL), source(NULL), value(NULL) {}
};
std::map<String, current_link_t, String::less_than> _current_links;
......
......@@ -58,15 +58,23 @@
#include "trace/Entitys.hpp"
#include "trace/Trace.hpp"
/* -- */
#include "trace/tree/Interval.hpp"
/* -- */
using namespace std;
Trace::Trace(): _max_date(0.0) {
_selected_container = NULL;
_filter = 0;
_interval_constrained = NULL;
}
Trace::~Trace() {
if(_interval_constrained != NULL) {
delete _interval_constrained;
_interval_constrained = NULL;
}
// Delete containers
while (!_root_containers.empty()){
delete _root_containers.front();
......@@ -282,6 +290,29 @@ const list <Container *> *Trace::get_root_containers() const {
return &_root_containers;
}
void Trace::get_all_containers(std::list <Container *> &list_to_fill) const {
for (list<Container *>::const_iterator it = _root_containers.begin();
it != _root_containers.end();
it ++) {
list_to_fill.push_back(*it);
// Recursivity to add the children names
add_containers(list_to_fill, *it);
}
}
void Trace::add_containers(list <Container *> &containers, const Container *parent) const {
const list<Container *> *children = parent->get_children();
for (list<Container *>::const_iterator it = children->begin();
it != children->end();
it ++) {
// We create the node and we do the recursivity
containers.push_back(*it);
add_containers(containers , *it);
}
}