Commit b24f21c3 authored by Kevin Coulomb's avatar Kevin Coulomb
Browse files

Modification (not yet functionnal) to only show some containers

parent 4359b7fa
......@@ -184,7 +184,8 @@ bool Interface_console::draw_trace(const string & filename, const int format){
time_elapsed.start();
buf_txt.str("");
while(!(parser.is_end_of_parsing() && thread.isFinished())) {
while(!parser.is_end_of_parsing()) {
loaded_f = parser.get_size_loaded();/* value between 0 and 1. Should be multiplied by 100 to obtain a percentage */
loaded = (int)(loaded_f*100.0f);
......@@ -215,7 +216,7 @@ bool Interface_console::draw_trace(const string & filename, const int format){
_progress_dialog->setLabelText(QString( buf_txt.str().c_str()));
buf_txt.str("");
}
}
cout << endl;
......@@ -244,7 +245,7 @@ bool Interface_console::draw_trace(const string & filename, const int format){
_main_window->setDisabled (false);
}
// Wait for the end of the thread
while(!thread.wait()) {
while(!thread.isFinished()) {
}
......@@ -261,6 +262,12 @@ bool Interface_console::draw_trace(const string & filename, const int format){
_render_opengl->updateGL();
_render_opengl->refresh_scroll_bars();
_file_opened = filename;/* store filename for a future export */
}else if (format == _DRAW_OPENGL_PARTIAL ){
/////////////////////////////////TODO
drawing_ogl.build_partial(_render_opengl,_trace,0);
_render_opengl->build();
_render_opengl->updateGL();
_render_opengl->refresh_scroll_bars();
}else if (_DRAW_SVG == format) {
drawing_svg.build(&svg, _trace, 0, interval);
svg.end();
......@@ -661,21 +668,24 @@ void Interface_console::launch_action(int state, void* arg) {
void Interface_console::display_help(){
cout << endl
<< "Usage: vite [OPTION...] [[-f] inputfile] [-e outputfile] " << endl
<< endl
<< " -h display this help " << endl
<< " -f inputfile open the inputfile " << endl
<< " -a display all the inputfile (Default)" << endl
<< " -t [T0]:[T1] display the interval [T0:T1] (Default: T0 = 0 and T1 = Tmax)" << endl
<< " -e outputfile export the trace file in the svg format to outpufile" << endl
<< " -epsilon eps specify the epsilon value for export" << endl
<< " -wide w specify the witdh factor for export" << endl
<< " -grow g specify the height factor for export" << endl
<< endl;
cerr << endl
<< " *** ViTE ***" << endl << endl << endl
<< "SYNOPSIS:" << endl
<< "vite [argument list]" << endl << endl
<< "ARGUMENT LIST:" << endl
<< "-h : display the help" << endl
<< "(-f) [file path] : open the trace file and display it." << endl
<< "-a [file path] : open the trace file and display all of it." << endl
<< "[file path] -t ([time_init]):([time_end]) : open the trace file and display it in the interval. There could be no time_init or time_end."
<< " In these cases, the trace will be printed from the start and/or to the end." << endl
<< "-f [path-source] -e [path-dest] : export the trace file in the svg format." << endl
<< "-f [path-source] -e [path-dest] -t ([time_init]):([time_end]) : export the trace file in the svg format in the interval given." << endl
<< "[-epsilon float_values][-wide float_values][-grow float_values]"<< endl << endl;
}
/***********************************
*
*
......@@ -727,3 +737,4 @@ void Interface_console::set_max_value_for_export(const double d) {
Trace *Interface_console::get_trace() const {
return _trace;
}
......@@ -210,6 +210,10 @@ public:
*/
static const int _STATE_RENDER_UPDATE = 22;
/*!
*\brief To draw a part of the drace (without all the containers)
*/
static const int _DRAW_OPENGL_PARTIAL = 23;
/*!
* \brief Launch an action according to the argument state value.
......@@ -343,6 +347,7 @@ protected:
public:
......@@ -454,6 +459,9 @@ public:
Trace *get_trace() const;
public slots:
......
......@@ -77,14 +77,19 @@ Interface_graphic::Interface_graphic(Interface_console* core, QWidget *parent):Q
load_windows();
setMouseTracking (true);/* to catch mouse events */
_help_widget = new Help();
_stats_window = new Stats_window(this);
// _cmd_window = NULL;
_cmd_window = new Command_window(this,this);
}
Interface_graphic::~Interface_graphic(){
delete _stats_window;
delete _help_widget;
/* Qt desallocates this, _ui_info_window and _render_area automatically */
}
......@@ -106,7 +111,7 @@ void Interface_graphic::load_windows(){
QUiLoader loader;
QFile file_info( ":/window/info_window.ui");
QFile file_selection_export(":/window/option_export_window.ui");
QFile file_help(":/window/help_window.ui");
if (!QGLFormat::hasOpenGL())
qFatal("This system has no OpenGL support");
......@@ -118,14 +123,9 @@ void Interface_graphic::load_windows(){
/* Load the _option_export_window from a .ui file */
file_selection_export.open(QFile::ReadOnly);
CKFP(_ui_time_selection_export = loader.load(&file_selection_export, this), "Cannot open the .ui file : " << ":/window/option_export_window.ui");
CKFP(_ui_time_selection_export = loader.load(&file_selection_export, this), "Cannot open the .ui file : " << "option_export_window.ui");
file_selection_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();
/* Set some windows properties */
_ui_info_window->setWindowFlags(_ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint);/* Always display info_window on top */
......@@ -144,7 +144,7 @@ void Interface_graphic::load_windows(){
CKFP(_ui_zoom_box = qFindChild<QComboBox*>(this, "zoom_box"), "Cannot find the zoom box in the .ui file");
/* Export window */
// Export window
CKFP(_ui_export_ok_button = qFindChild<QPushButton*>(_ui_time_selection_export, "option_export_ok"), "Cannot find the ok push button in the export dialog .ui file");
CKFP(_ui_min_time_export = qFindChild<QLineEdit*>(_ui_time_selection_export, "min_time"), "Cannot find the ok push button in the export dialog .ui file");
......@@ -160,15 +160,10 @@ void Interface_graphic::load_windows(){
CKFP(_ui_CheckBox_accuracy_export = qFindChild<QCheckBox*>(_ui_time_selection_export, "checkBox_accuracy"), "Cannot find the Line text \"accuracy\" in the export dialog .ui file");
CKFP(_ui_more_options_export = qFindChild<QCommandLinkButton*>(_ui_time_selection_export, "more_options"), "Cannot find the button \"more_options\" in the export dialog .ui file");
/* Help window */
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_export_ok_button, SIGNAL(pressed()),
this, SLOT(option_export_ok_pressed()));
connect(_ui_help_ok_button, SIGNAL(clicked()),
_ui_help_window, SLOT(close()));
/*
Special function of Qt which allows methods declared as slots and which name are 'on_[widget]_[action]()' to be called when the 'widget' triggered the signal corresponding to 'action'.
/!\ -> use NULL as argument, else messages will be duplicated!
......@@ -534,7 +529,7 @@ void Interface_graphic::on_close_triggered(){
void Interface_graphic::on_quit_triggered(){
((QWidget*)_ui_help_window)->close();
((QWidget*)_help_widget)->close();
((QWidget*)this)->close();
}
......@@ -577,11 +572,11 @@ void Interface_graphic::on_show_info_triggered(){
void Interface_graphic::on_help_triggered(){
if(_ui_help_window->isVisible()){
_ui_help_window->hide();
if(_help_widget->isVisible()){
_help_widget->hide();
}
else{
_ui_help_window->show();
_help_widget->show();
}
}
......@@ -613,6 +608,20 @@ void Interface_graphic::on_show_stats_triggered(){
}
}
void Interface_graphic::on_actionCommand_triggered(){
//TODO
if(_core->get_trace()){
// _cmd_window = new Command_window(_core->get_trace(),this);
_cmd_window->set_trace(_core->get_trace());
_cmd_window->init_window();
_cmd_window->show();
}
else{
error("Must load a trace before using an external command on a trace");
}
}
void Interface_graphic::on_no_warning_triggered(){
_no_warning = !_no_warning;
}
......@@ -722,7 +731,7 @@ void Interface_graphic::on_scale_container_state_valueChanged(int new_value){
void Interface_graphic::closeEvent(QCloseEvent *event){
// _ui_help_window->close();
_help_widget->close();
if(isEnabled()){
event->accept();/* accept to hide the window for a further destruction */
......@@ -735,3 +744,10 @@ void Interface_graphic::closeEvent(QCloseEvent *event){
const std::string Interface_graphic::get_filename() const{
return _trace_path;
}
Interface_console * Interface_graphic::get_console(){
return _core;
}
......@@ -61,9 +61,10 @@ class Interface_graphic;
#include "interface_console.hpp"
#include "resource.hpp"
//#include "help.hpp"
#include "help.hpp"
#include "../statistics/Stats_window.hpp"
#include "../plugin/Command_window.hpp"
/*!
*\brief This class is a graphical interface which creates a window, it inherited from the Interface interface.
......@@ -235,11 +236,6 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QWidget* _ui_time_selection_export;
/*!
* \brief Dialog box to give some help for user.
*/
QWidget* _ui_help_window;
/*!
* \brief Text area which informs the user about the trace resume.
*/
......@@ -255,21 +251,21 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
*/
QPushButton* _ui_export_ok_button;
/*!
* \brief Text area which informs the user about the selected entity information.
*/
Help *_help_widget;
/*!
* \brief The window used to print stats.
*/
Stats_window *_stats_window;
/***********************************
*
* Help window.
*
**********************************/
/*!
* \brief Button uses to close the help window.
* \brief The window to use an extern command on the trace
*/
QPushButton* _ui_help_ok_button;
Command_window * _cmd_window;
/***********************************
*
......@@ -294,6 +290,7 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public
bool _on_manual_change;
public:
......@@ -431,6 +428,13 @@ public:
*/
const std::string get_filename() const;
/*!
* \brief To get the interface console
* \fn get_console()
*/
Interface_console *get_console();
protected slots:
......@@ -497,6 +501,11 @@ protected slots:
*/
void on_show_stats_triggered();
/*!
* \brief A slot called when 'command' in the menu is clicked.
*/
void on_actionCommand_triggered();
/*!
*\brief A slot called when 'no_warning' in the menu is clicked.
*/
......@@ -562,7 +571,6 @@ protected slots:
*/
void on_scale_container_state_valueChanged(int new_value);/* temporary slot */
};
......
This diff is collapsed.
......@@ -78,6 +78,7 @@ HEADERS += message/Message.hpp \
interface/interface_graphic.hpp \
interface/parsing_thread.hpp \
interface/resource.hpp \
interface/help.hpp \
# Render headers
render/render.hpp \
render/Render_area.hpp \
......@@ -134,9 +135,12 @@ HEADERS += message/Message.hpp \
statistics/Statistic.hpp \
statistics/DrawStats.hpp \
statistics/DrawVDiagram.hpp \
statistics/DrawHDiagram.hpp
statistics/DrawHDiagram.hpp \
# plugin header
plugin/Command_window.hpp
FORMS += interface/info_window.ui interface/main_window.ui interface/option_export_window.ui interface/stats_viewer.ui
FORMS += interface/info_window.ui interface/main_window.ui interface/option_export_window.ui interface/stats_viewer.ui interface/global_cmd.ui
SOURCES += message/Message.cpp \
message/Errors.cpp \
main.cpp \
......@@ -146,6 +150,7 @@ SOURCES += message/Message.cpp \
interface/interface_console.cpp \
interface/interface_graphic.cpp \
interface/parsing_thread.cpp \
interface/help.cpp \
# Render code files
render/Render_area.cpp \
render/Render_opengl.cpp \
......@@ -188,6 +193,8 @@ SOURCES += message/Message.cpp \
general/Tools.cpp \
# Statistics code files
statistics/Stats_window.cpp \
statistics/Statistic.cpp
statistics/Statistic.cpp\
# Plugin code files
plugin/Command_window.cpp
RESOURCES += interface/vite.qrc
......@@ -212,7 +212,28 @@ public:
draw_object->end_draw();
}
/*!
* \fn build_partial(T* draw_object, Trace* trace, double zoom, const Interval & interval, std::vector<Container *> container)
* \brief The trace building function that do not draw all the containers but only a part.
* \param draw_object the kind of object which will be drawn (OpenGL, SVG...).
* \param trace the trace data.
* \param zoom The level of zoom where we do not draw under
* \param interval The interval we want to display in
* \param container the set of container that are to be drawn
*/
void build_partial(T* draw_object, Trace* trace, double zoom) {
Interval * interval = trace->get_interval_constrained();
std::vector<Container *> *container = trace->get_selected_container();
draw_object->start_draw();
draw_object->start_draw_containers();
browse_container_tree_partial(draw_object, trace,container);
draw_object->end_draw_containers();
browse_entities_partial(draw_object,zoom,interval,container);
draw_object->end_draw();
}
/***********************************
*
......@@ -240,6 +261,26 @@ public:
}/* end browse_container_tree */
/*
* \fn browse_container_tree_partial(T* draw_object, Trace* trace, std::vector<Container *> container)
* \brief Function that browses the containers of the trace argument that are in the set container and make them painted with a T object
*/
inline void browse_container_tree_partial(T* draw_object, Trace* trace, std::vector<Container *> *container){
/*** Drawing containers ***/
int position = 0;
const list<Container *> *root_containers = trace->get_root_containers();
if (root_containers->empty()) {
*Message::get_instance() << "There is no container. The trace can not be drawn." << Message::endw;
}
else
for (list<Container *>::const_iterator i = root_containers->begin();
i != root_containers->end();
i++)
// Use the fact a container is selected implies all his ancestors are
if(is_in_set(*i,container))
position += browse_container(draw_object, *i, position, 0);
}/* end browse_container_tree_partial */
/*
* \fn browse_container(T* draw_object, const Container *container, int position, int depth)
......@@ -284,6 +325,55 @@ public:
return size;
}
/*
* \fn browse_container(T* draw_object, const Container *container, int position, int depth, std::vector<Container *> set_container)
* \brief Recursive function that browse a container to draw it if it is in the set of container with a T painting object in position, knowing the current depth in the tree
*/
int browse_container_partial(T* draw_object, const Container *container, int position, int depth, std::vector<Container *> *set_container) {
int size = 0;
// Draw children
const list<Container *> *children = container->get_children();
for (list<Container *>::const_iterator i = children->begin();
i != children->end();
i++) {
if(is_in_set(i,set_container))
size += browse_container(draw_object, (*i), position+size, depth+1);
}
// Store the position to draw links
_container_positions[container] = position + size; // First line after children
// Use one line for states and events
if (!container->get_states()->empty() || !container->get_events()->empty()) {
size++;
_entity_containers.push_back(container);
}
// Use one line for each variable
if (container->get_variable_number() > 0) {
_variable_containers.push_back(container);
size += container->get_variable_number();
}
if (size < 1) // Minimum size
size = 1;
// Push containers with links to draw
if (!container->get_links()->empty())
_link_containers.push_back(container);
// Draw this container
draw_container(draw_object, position, size, depth, container->get_name().to_string());
return size;
}
/*!
* \brief Draw a container
* \param draw_object Object that contains drawing methods to call
......@@ -406,6 +496,119 @@ public:
}
/*!
* \brief Browse the states list and draw them
*/
inline void browse_entities_partial(T* draw_object, double zoom, Interval* interval, std::vector<Container *> *set_container) {
//////////////////////////////////////////////////////////
const Container *container;
BinaryTree<StateChange> *state_tree;
BinaryTree<Event> *event_tree;
const list<Link *> *link_list;
Link *link;
const map<VariableType *, Variable *> *variable_map;
Variable *var;
const list<pair<Date, Double> > *variable_values;
int position;
Element_pos lvl_zoom;
if(zoom>=0)
lvl_zoom = zoom;
else
lvl_zoom = 0;
draw_object->start_draw_states();
for (list<const Container *>::const_iterator c = _entity_containers.begin();
c != _entity_containers.end();
c++) {
if(is_in_set(*c,set_container)){
container = *c;
position = (int)_container_positions[container];
state_tree = container->get_states();
event_tree = container->get_events();
if (!state_tree->empty() || !event_tree->empty()) {
// Browse states
DrawTree<T, StateChange>(draw_object, position, lvl_zoom,
_container_height, _container_v_space, _state_height, _state_v_space)
.draw_tree(state_tree, *interval);
// Browse events
DrawTree<T, Event>(draw_object, position, lvl_zoom,
_container_height, _container_v_space, _state_height, _state_v_space)
.draw_tree(event_tree, *interval);
}
}
}/* end for (!_stack_states.empty()) */
draw_object->end_draw_states();
draw_object->start_draw_arrows();
for (list<const Container *>::const_iterator c = _link_containers.begin();
c != _link_containers.end();
c++) {
if(is_in_set(*c,set_container)){
container = *c;
// Browse links
link_list = container->get_links();
for (list<Link *>::const_iterator it = link_list->begin();
it != link_list->end();
it++) {
link = *it;
if(link_is_in_set(link,set_container)){
draw_link(draw_object, link->get_start_time().get_value(), link->get_end_time().get_value(),
_container_positions[link->get_source()], _container_positions[link->get_destination()]);
}
}/* end for */
}//end for
}/* end while (!_stack_states.empty()) */
draw_object->end_draw_arrows();
draw_object->start_draw_counter();
for (list<const Container *>::const_iterator c = _entity_containers.begin();
c != _entity_containers.end();
c++) {
if(is_in_set(*c,set_container)){
container = *c;
position = (int)_container_positions[container];
if (!container->get_states()->empty() || !container->get_events()->empty())
position++;
// Browse variables
variable_map = container->get_variables();
for (map<VariableType *, Variable *>::const_iterator i = variable_map->begin();
i != variable_map->end();
i++) {
var = (*i).second;
double min = var->get_min().get_value();
double max = var->get_max().get_value();
variable_values = var->get_values();
draw_variable_value(draw_object, 0.0, 0.0, position);
for (list<pair<Date, Double> >::const_iterator value = variable_values->begin();
value != variable_values->end();
value++) {
/* Call the object state drawing function */
draw_variable_value(draw_object, (*value).first.get_value(), ((*value).second.get_value()-min)/(max-min), position);
}
draw_variable_value(draw_object, 0.0, 0.0, position);
position++; // One line was used
}/* end for */
}
}//end for
draw_object->end_draw_counter();
}
/*!
* \brief Draw a point of a variable curve
......@@ -651,6 +854,7 @@ public:
c = -(a*x1 + b*y1);
double e = a*x + b*y + c;