diff --git a/Doxyfile b/Doxyfile index 9fac5e78a7e6121e9809c0de596dc853e57746f8..8e57fc52901e9021e956fc75b434148cc80d0872 100644 --- a/Doxyfile +++ b/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = ViTE # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 2.0 +PROJECT_NUMBER = 3.0 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -487,7 +487,7 @@ WARN_IF_DOC_ERROR = YES # wrong or incomplete parameter documentation, but not about the absence of # documentation. -WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text @@ -513,7 +513,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = src/interface/ src/message/ src/parser/ src/render/ src/trace/ src/trace/values/ src/main.cpp src/main_resource.hpp tests/interface tests/message tests/parser tests/trace +INPUT = src/interface/ src/message/ src/parser/ src/render/ src/trace/ src/trace/values/ src/main.cpp src/main_resource.hpp tests/interface tests/message tests/parser tests/trace src/Tools.cpp src/Tools.hpp # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/src/Tools.cpp b/src/Tools.cpp index 4c5cde4bc12b0d22ea71fa1ed62b4a325dae90e8..3fa2f9371f4b8c1f0f850d0bc43fbb92d2eb62ef 100644 --- a/src/Tools.cpp +++ b/src/Tools.cpp @@ -2,9 +2,9 @@ using namespace std; -double convert_to_double(const char *arg){ +double convert_to_double(const string arg){ double value = -1.0; // value returned - string arg_temp = (string)arg + " 3"; + string arg_temp = arg + " 3"; int useless; if(sscanf(arg_temp.c_str(), "%lf %d", &value, &useless) == 2){ return value; // It is the good format diff --git a/src/Tools.hpp b/src/Tools.hpp index b52e87bb67f645795dd172d3cb865f27a82228e9..97a12f2a2a39e308e84a141857bb8e336b28b5a4 100644 --- a/src/Tools.hpp +++ b/src/Tools.hpp @@ -13,7 +13,7 @@ * \brief Convert the string in double * \arg arg : the string to be doublized. */ -double convert_to_double(const char *arg); +double convert_to_double(const std::string arg); #endif // TOOLS_HPP diff --git a/src/interface/Progress_bar_thread.cpp b/src/interface/Progress_bar_thread.cpp index 6e8f1c599edc0c3e673c50f51925db6db5e224b8..5dc72e3b37c9610b20fb8d946afc881df1df7ab7 100644 --- a/src/interface/Progress_bar_thread.cpp +++ b/src/interface/Progress_bar_thread.cpp @@ -7,17 +7,14 @@ void Progress_bar_thread::init(Parser *p, Interface_console *i){ void Progress_bar_thread::run() { _file_size = _parser->get_total_size_of_file(); - _interface_console->get_progress_dialog()->setRange(0, 100); int loaded = 0; while(1) { - loaded = _parser->get_size_loaded()*10000/_file_size + 1; - + loaded = _parser->get_size_loaded()*100/_file_size + 1; msleep(500); // We wait 500 ms _interface_console->get_progress_dialog()->setValue(loaded); - - QApplication::processEvents(); + _interface_console->get_progress_dialog()->update(); } } diff --git a/src/interface/interface_console.cpp b/src/interface/interface_console.cpp index 6739e375bedb058b26b03caa9f8a2e0079592aae..214e200d59308768b995068f50aaa2b37471e897 100644 --- a/src/interface/interface_console.cpp +++ b/src/interface/interface_console.cpp @@ -109,8 +109,7 @@ bool Interface_console::draw_trace(const string & filename, const int format){ // Init of the thread Progress_bar_thread thread; thread.init(&parser, this); - _progress_dialog = new QProgressDialog(_main_window); - _progress_dialog->setLabelText("Parsing"); + _progress_dialog = new QProgressDialog("Parsing", "Cancel", 0, 100, _main_window); _progress_dialog->show(); thread.start(); @@ -118,7 +117,7 @@ bool Interface_console::draw_trace(const string & filename, const int format){ try{ parser.parse(filename, trace); } - catch (const string &error){ + catch (const string &error) { thread.terminate(); *Message::get_instance() << "Reason : " << error << Message::ende; QApplication::restoreOverrideCursor(); @@ -178,7 +177,7 @@ int Interface_console::run(){ /* * If a window is displayed, enter in the Qt event loop. */ - if ( true == _is_window_displayed){ + if (_is_window_displayed){ return app->exec(); } else{/* else, quit the application */ @@ -222,7 +221,6 @@ int Interface_console::get_state(int argc, char** argv){ for(int i = 1 ; i < argc ; i ++){ - cout << "argv[" << i <<"] : "<< argv[i] << endl; if((string)argv[i] == "-h"){ // display the help message return _STATE_DISPLAY_HELP; @@ -251,7 +249,7 @@ int Interface_console::get_state(int argc, char** argv){ return _STATE_UNKNOWN; } } - else if((string)argv[i] == "-t"){ + else if((string)argv[i] == "-t") { // We want to export the file which follow this argument extract_times(argv[++ i]); state |= _STATE_IN_AN_INTERVAL; @@ -259,49 +257,49 @@ int Interface_console::get_state(int argc, char** argv){ else if(argv[i][0] == '-') { // This is here where we put new options !! (for filters for example or export) - if((string)argv[i] == "-epsilon"){ + if((string)argv[i] == "-epsilon") { i ++; - if(i > argc){ + if(i > argc) { cerr << "need an other argument for epsilon" << endl; return _STATE_UNKNOWN; } - else{ + else { double accuracy = convert_to_double(argv[i]); if(accuracy < 0.) { cerr << "need a positive accuracy for epsilon" << endl; return _STATE_UNKNOWN; } - else{ + else { Svg::set_accuracy(accuracy); } } } - else if((string)argv[i] == "-interval"){ +// else if((string)argv[i] == "-interval") { - if (!(i +2 < argc)) { - cerr << "interval argc" << endl; - return _STATE_UNKNOWN; - } - if (argv[i+1][0] == '-') { - cerr << "interval -" << endl; - return _STATE_UNKNOWN; - } - if (!(argv[i+2][0] != '-')) { - cerr << "interval -" << endl; - return _STATE_UNKNOWN; - } +// if (!(i +2 < argc)) { +// cerr << "interval argc" << endl; +// return _STATE_UNKNOWN; +// } +// if (argv[i+1][0] == '-') { +// cerr << "interval -" << endl; +// return _STATE_UNKNOWN; +// } +// if (!(argv[i+2][0] != '-')) { +// cerr << "interval -" << endl; +// return _STATE_UNKNOWN; +// } - double t1 = atof(argv[i+1]); - double t2 = atof(argv[i+2]); +// double t1 = atof(argv[i+1]); +// double t2 = atof(argv[i+2]); - if (t1 >= t2) { - cerr << "interval neg" << endl; - return _STATE_UNKNOWN; - } - - Svg::set_interval(t1,t2); - i+=2; - } +// if (t1 >= t2) { +// cerr << "interval neg" << endl; +// return _STATE_UNKNOWN; +// } + +// Svg::set_interval(t1,t2); +// i+=2; +// } else if((string)argv[i] == "-wide") { if (i + 1 >= argc) { cerr << "wide argc" << endl; @@ -328,7 +326,7 @@ int Interface_console::get_state(int argc, char** argv){ Svg::set_height_factor(atof(argv[i+1])); i++; } - else if((string)argv[i] == "-scale"){ + else if((string)argv[i] == "-scale"){ if (!(i + 1 < argc)) { cerr << "scale argc" << endl; return _STATE_UNKNOWN; @@ -355,9 +353,10 @@ int Interface_console::get_state(int argc, char** argv){ return state; } -void Interface_console::extract_times(const char *name){ +void Interface_console::extract_times(const char *name) { bool has_time_start = false; bool has_time_end = false; + string temp = name; if(name[0] == '['){ has_time_start = true; } @@ -365,14 +364,18 @@ void Interface_console::extract_times(const char *name){ has_time_end = true; } - if(has_time_start && has_time_end){ - sscanf(name, "[%lf]:[%lf]", &_time_start, &_time_end); + if(has_time_start && has_time_end) { + string start = temp.substr(temp.find('[')+1, temp.find(']')-1); + temp = temp.substr(temp.find(']')+1); + string end = temp.substr(temp.find('[')+1, temp.find(']')-2); + _time_start = convert_to_double(start); + _time_end = convert_to_double(end); } - else if(has_time_start){ - sscanf(name, "[%lf]:", &_time_start); + else if(has_time_start) { + _time_start = convert_to_double(temp.substr(temp.find('[')+1, temp.find(']')-1)); } - else if(has_time_end){ - sscanf(name, ":[%lf]", &_time_end); + else if(has_time_end) { + _time_end = convert_to_double(temp.substr(temp.find('[')+1, temp.find(']')-2)); } else{ _time_start = 0; @@ -391,12 +394,12 @@ void Interface_console::launch_action(int state, void* arg){ case _STATE_LAUNCH_GRAPHICAL_INTERFACE : - _main_window = new Interface_graphic(this);/* launch the window interface */ - Message::set_interface(_main_window);/* define which interface will receive messages */ - _render_opengl = new Render_opengl(_main_window); - _main_window->bind_render_area((QGLWidget*)_render_opengl); + _main_window = new Interface_graphic(this);/* launch the window interface */ + Message::set_interface(_main_window);/* define which interface will receive messages */ + _render_opengl = new Render_opengl(_main_window); + _main_window->bind_render_area((QGLWidget*)_render_opengl); - _is_window_displayed = true; + _is_window_displayed = true; break; case _STATE_OPEN_FILE: @@ -417,17 +420,14 @@ void Interface_console::launch_action(int state, void* arg){ case _STATE_EXPORT_FILE: - if (true == _file_opened.empty()){ + if (_file_opened.empty()){ *Message::get_instance() << "Please to previously open a trace." << Message::endw; return; } *Message::get_instance() << "export of " << _file_opened << " to " << _path_to_export << Message::endi; - ///// Do the export ///// - { - draw_trace(_file_opened, _DRAW_SVG); - } - ///////////////////////// + + draw_trace(_file_opened, _DRAW_SVG); break; @@ -445,10 +445,10 @@ void Interface_console::launch_action(int state, void* arg){ else{ cout << "the end of the trace."; } - ///// Do the export ///// - - ///////////////////////// - + + Svg::set_interval(_time_start, _time_end); + draw_trace(_file_opened, _DRAW_SVG); + break; case _STATE_OPEN_FILE_IN_AN_INTERVAL: @@ -508,8 +508,8 @@ void Interface_console::launch_action(int state, void* arg){ break; default:/* like _STATE_UNKNOWN */ - display_help(); - warning(string("Cannot determine the arguments past. Please check the correct syntax.")); + display_help(); + warning(string("Cannot determine the arguments past. Please check the correct syntax.")); } } diff --git a/src/interface/interface_console.hpp b/src/interface/interface_console.hpp index 8a2fffd936e83ce0f1847786662496712e96c296..799f5d160ef03a99340dc4e9c47fa20f436df830 100644 --- a/src/interface/interface_console.hpp +++ b/src/interface/interface_console.hpp @@ -26,7 +26,7 @@ class Interface_console; /*! *\brief This class is an terminal interface, it inherited from the Interface interface. -*/ + */ class Interface_console : public Interface{ @@ -252,7 +252,7 @@ protected: - public: +public: /*********************************** @@ -325,7 +325,7 @@ protected: /*! \arg string : the string to be displayed. \brief The function takes a string then displayed it into the terminal, then killed the application. - */ + */ void error(const std::string) const; @@ -345,14 +345,14 @@ protected: /*! *\arg string : the string to be displayed. *\brief Only use in graphic interface. - */ + */ void selection_information(const std::string) const{ } /*! *\brief Return the progress dialog used during threads. - */ + */ QProgressDialog *get_progress_dialog(); }; diff --git a/src/interface/interface_graphic.cpp b/src/interface/interface_graphic.cpp index 64fdfc49687e6f67ee2ce825eb28f81fa54024be..0a1cb96d3d38285b7426d8f21a6c1564cb654baf 100644 --- a/src/interface/interface_graphic.cpp +++ b/src/interface/interface_graphic.cpp @@ -38,7 +38,7 @@ Interface_graphic::~Interface_graphic(){ - /* Qt desallocates this, _ui_info_window and _render_area automatically */ + /* Qt desallocates this, _ui_info_window and _render_area automatically */ } @@ -94,11 +94,11 @@ void Interface_graphic::load_windows(){ connect(_ui_export_ok_button, SIGNAL(pressed()), - this, SLOT( option_export_ok_pressed())); + this, SLOT( option_export_ok_pressed())); /* 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! - */ + */ QMetaObject::connectSlotsByName(NULL); // QMetaObject::connectSlotsByName(_ui_time_selection_export); @@ -194,8 +194,8 @@ void Interface_graphic::opening_file(const string &path){ QApplication::setOverrideCursor(Qt::WaitCursor); /* if (_core->draw_trace(path)==false){ - error("Draw trace failed"); - }*/ + error("Draw trace failed"); + }*/ // _ui_render_area->build(); @@ -375,17 +375,17 @@ 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>."));*/ + 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 0.3</i> - <i>March 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>Johnny JAZEIX</li><li>Olivier LAGRASSE</li><li>Jule MARCOUEILLE</li><li>Pascal NOISETTE</li><li>Arthur REDONDY</li><li>Clément VUCHENER</li></ul></p>" -"This software was made for a school engineering project for INRIA researchers.<br />" -"The main page project is: <a href=\"https://gforge.inria.fr/projects/vite/\">https://gforge.inria.fr/projects/vite/</a>.<br /><br />")); + "<p><b>Developers:</b><ul><li>Kevin COULOMB</li><li>Johnny JAZEIX</li><li>Olivier LAGRASSE</li><li>Jule MARCOUEILLE</li><li>Pascal NOISETTE</li><li>Arthur REDONDY</li><li>Clément VUCHENER</li></ul></p>" + "This software was made for a school engineering project for INRIA researchers.<br />" + "The main page project is: <a href=\"https://gforge.inria.fr/projects/vite/\">https://gforge.inria.fr/projects/vite/</a>.<br /><br />")); } @@ -420,7 +420,7 @@ void Interface_graphic::on_goto_start_triggered(){ else/* on X axe */ id = Info::Render::X_TRACE_BEGINNING; - _core->launch_action(Interface_console::_STATE_RENDER_AREA_REGISTERED_TRANSLATE, &id); + _core->launch_action(Interface_console::_STATE_RENDER_AREA_REGISTERED_TRANSLATE, &id); } void Interface_graphic::on_goto_end_triggered(){ diff --git a/src/interface/interface_graphic.hpp b/src/interface/interface_graphic.hpp index fbb00c5959f4b2c77e9d31e0a34ca6c7fb7be825..aec853873af6b4e36ba76cc408687d0649833ad4 100644 --- a/src/interface/interface_graphic.hpp +++ b/src/interface/interface_graphic.hpp @@ -23,15 +23,12 @@ class Interface_graphic; /*! *\brief This class is a graphical interface which creates a window, it inherited from the Interface interface. -*/ + */ class Interface_graphic : public QMainWindow, protected Ui::main_window, public Interface{ - Q_OBJECT - - - protected: + protected: /*********************************** @@ -68,9 +65,9 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public */ QAction* _ui_toolbar_check; - /* - *\brief This variable contains the toolbar - */ + /* + *\brief This variable contains the toolbar + */ QToolBar* _ui_toolbar; /*! @@ -129,7 +126,7 @@ class Interface_graphic : public QMainWindow, protected Ui::main_window, public */ QTextEdit* _ui_info_selection_text; - /*! + /*! * \brief Text area which informs the user about the selected entity information. */ QPushButton* _ui_export_ok_button; @@ -195,14 +192,14 @@ public: /*! *\arg string : the string to be displayed. *\brief The function takes strings and/or numbers then displayed an info box containing it, then the program go on with an indeterminated behaviour. - */ + */ void warning(const std::string) const; /*! *\arg string : the string to be displayed. *\brief The function takes strings and/or numbers then displayed an info box containing it, then the program go on. - */ + */ void information(const std::string) const; @@ -216,7 +213,7 @@ public: /*! *\arg string : the string to be displayed. *\brief The function takes strings and/or numbers then displayed it in the entity informative text area in the info window. - */ + */ void selection_information(const std::string) const; @@ -231,7 +228,7 @@ public: /*! * \brief Create a Parser and a DataStructure to display a trace file. * \arg path The path of the file. - */ + */ void opening_file(const std::string &path); /*! @@ -268,12 +265,12 @@ protected slots: /*! *\brief A slot called when 'open' in the menu is clicked. - */ + */ void on_open_triggered(); /*! *\brief A slot called when 'export' in the menu is clicked. - */ + */ void on_export_file_triggered(); /*! @@ -283,52 +280,52 @@ protected slots: /*! *\brief A slot called when 'close' in the menu is clicked. - */ + */ void on_close_triggered(); /*! *\brief A slot called when 'quit' in the menu is clicked. - */ + */ void on_quit_triggered(); /*! *\brief A slot called when 'fullscreen' in the menu is clicked. - */ + */ void on_fullscreen_triggered(); /*! *\brief A slot called when 'Show tool bar' in the menu is clicked. - */ + */ void on_toolbar_menu_triggered(); /*! *\brief A slot called when 'show infos' in the menu is clicked. - */ + */ void on_show_info_triggered(); /*! *\brief A slot called when 'help' in the menu is clicked. - */ + */ void on_help_triggered(); /*! *\brief A slot called when 'about' in the menu is clicked. - */ + */ void on_about_triggered(); /*! *\brief A slot called when 'no_warning' in the menu is clicked. - */ + */ void on_no_warning_triggered(); /*! *\brief A slot called when 'zoom_in' in the menu is clicked. - */ + */ void on_zoom_in_triggered(); /*! *\brief A slot called when 'zoom_out' in the menu is clicked. - */ + */ void on_zoom_out_triggered(); /*! @@ -350,7 +347,7 @@ protected slots: *\brief A slot called when 'zoom_box' widget is triggered. * * \arg s The new string value of the zoom box. - */ + */ void on_zoom_box_textChanged(QString s); /*! diff --git a/src/interface/option_export_window.ui b/src/interface/option_export_window.ui index 90b44fa3b75c7c8a128fc90267410ebdd1ec890a..7f04a4cf991fe4cd9df54983bbfdb32b6e253fde 100644 --- a/src/interface/option_export_window.ui +++ b/src/interface/option_export_window.ui @@ -341,12 +341,12 @@ <slot>setVisible(bool)</slot> <hints> <hint type="sourcelabel" > - <x>81</x> - <y>36</y> + <x>92</x> + <y>30</y> </hint> <hint type="destinationlabel" > - <x>131</x> - <y>100</y> + <x>136</x> + <y>65</y> </hint> </hints> </connection> @@ -357,12 +357,12 @@ <slot>setVisible(bool)</slot> <hints> <hint type="sourcelabel" > - <x>125</x> - <y>41</y> + <x>136</x> + <y>30</y> </hint> <hint type="destinationlabel" > - <x>249</x> - <y>100</y> + <x>270</x> + <y>65</y> </hint> </hints> </connection> @@ -373,8 +373,8 @@ <slot>setVisible(bool)</slot> <hints> <hint type="sourcelabel" > - <x>93</x> - <y>173</y> + <x>103</x> + <y>113</y> </hint> <hint type="destinationlabel" > <x>69</x> @@ -389,12 +389,12 @@ <slot>setVisible(bool)</slot> <hints> <hint type="sourcelabel" > - <x>45</x> - <y>205</y> + <x>66</x> + <y>160</y> </hint> <hint type="destinationlabel" > - <x>51</x> - <y>240</y> + <x>73</x> + <y>195</y> </hint> </hints> </connection> @@ -405,12 +405,12 @@ <slot>setVisible(bool)</slot> <hints> <hint type="sourcelabel" > - <x>37</x> - <y>273</y> + <x>58</x> + <y>234</y> </hint> <hint type="destinationlabel" > - <x>35</x> - <y>308</y> + <x>57</x> + <y>269</y> </hint> </hints> </connection> @@ -425,8 +425,8 @@ <y>29</y> </hint> <hint type="destinationlabel" > - <x>45</x> - <y>69</y> + <x>57</x> + <y>65</y> </hint> </hints> </connection> @@ -437,12 +437,44 @@ <slot>setVisible(bool)</slot> <hints> <hint type="sourcelabel" > - <x>169</x> - <y>32</y> + <x>180</x> + <y>30</y> </hint> <hint type="destinationlabel" > - <x>163</x> - <y>85</y> + <x>194</x> + <y>65</y> + </hint> + </hints> + </connection> + <connection> + <sender>cancel</sender> + <signal>clicked()</signal> + <receiver>time_selector</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>104</x> + <y>318</y> + </hint> + <hint type="destinationlabel" > + <x>105</x> + <y>300</y> + </hint> + </hints> + </connection> + <connection> + <sender>option_export_ok</sender> + <signal>pressed()</signal> + <receiver>time_selector</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>180</x> + <y>312</y> + </hint> + <hint type="destinationlabel" > + <x>180</x> + <y>291</y> </hint> </hints> </connection> diff --git a/src/main.cpp b/src/main.cpp index 1ac5982c6d62e85e8c0759bb76e7d946bd9cb8ee..7ba2c3e24adf908b23b51fdfb71fb53555997adb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,14 +19,13 @@ *\brief The main function of ViTE. */ - int main(int argc, char **argv) { - +int main(int argc, char **argv) { - Q_INIT_RESOURCE(vite); + Q_INIT_RESOURCE(vite); - Info::Render::_key_alt = false;/* no CTRL key pushed */ + Info::Render::_key_alt = false;/* no CTRL key pushed */ - Interface_console console(argc, argv); + Interface_console console(argc, argv); - return console.run(); - } + return console.run(); +} diff --git a/src/main_resource.hpp b/src/main_resource.hpp index 298d996103434c5a23fc869675f3de50c386f685..75836252d1396a3ee0c42927642051faf9377910 100644 --- a/src/main_resource.hpp +++ b/src/main_resource.hpp @@ -13,12 +13,6 @@ #include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */ - - - - - - /*! * \brief unity for count elements such as number of states or events... NOT USED YET */ @@ -38,9 +32,6 @@ typedef double Element_col; typedef double Times; - - - /* Message management */ #include "message/Message.hpp" @@ -48,7 +39,7 @@ typedef double Times; /* Example: * *Message::get_instance() << "Test:" << 45 << " and " << true << Message::endi; * -> display as an informative message. -*/ + */ #endif diff --git a/src/message/Errors.cpp b/src/message/Errors.cpp index 6e65f52c51db6f5fc47b994b9fd3a1a75a9435dc..2bbed1ce1a1a2898fc54bb685517a20238e00e7c 100644 --- a/src/message/Errors.cpp +++ b/src/message/Errors.cpp @@ -2,8 +2,8 @@ using namespace std; -std::queue<std::string> Error::_errors; -std::queue<std::string> Error::_warnings; +queue<string> Error::_errors; +queue<string> Error::_warnings; const string Error::_PARSE = "expected \" before end of file"; const string Error::_MMAP = "mmap error"; diff --git a/src/message/Errors.hpp b/src/message/Errors.hpp index a14ee6e131505d947d1d6bcf2b3f1ad80ea0232d..7e1dcdbce9bf8736019d2c29aaaae37d89a03703 100644 --- a/src/message/Errors.hpp +++ b/src/message/Errors.hpp @@ -157,7 +157,7 @@ public: - /*! + /*! * \fn set(const std::string kind_of_error, const int priority) static void * \brief raise an error or a warning * \param kind_of_error : content of error @@ -165,7 +165,7 @@ public: */ static void set(const std::string kind_of_error, const int priority); - /*! + /*! * \fn set_and_print(const std::string kind_of_error, const int priority) static void * \brief raise and throw to the interface an error or a warning * \param kind_of_error : content of error @@ -173,7 +173,7 @@ public: */ static void set_and_print(const std::string kind_of_error, const int priority); - /*! + /*! * \fn set_and_print(const std::string kind_of_error, const unsigned int line_number, const int priority) static void * \brief raise and throw to the interface an error or a warning and the line when it occurs * \param kind_of_error : content of error @@ -182,14 +182,14 @@ public: */ static void set_and_print(const std::string kind_of_error, const unsigned int line_number, const int priority); - /*! + /*! * \fn print(const int priority) static void * \brief print the current error * \param priority : _ERROR or _WARNING */ static void print(const int priority); - /*! + /*! * \fn set_if(bool condition, const std::string kind_of_error, const unsigned int line_number, const int priority) static bool * \brief raise an error or a warning and the line when it occurs if the condition is satisfied * \param condition : a condition @@ -200,13 +200,13 @@ public: */ static bool set_if(bool condition, const std::string kind_of_error, const unsigned int line_number, const int priority); - /*! + /*! * \fn print_numbers() static void * \brief throw to the interface a message about the number of errors and warnings */ static void print_numbers(); - /*! + /*! * \fn flush_in_file(const std::string &filename) static void * \brief print all the errors and warnings saved in a file and empty the queues _errors and _warnings * \param filename : a file path diff --git a/src/parser/Parser.hpp b/src/parser/Parser.hpp index 8a8307805688ca4b40fc0d8f3e0ddd5ee59ba553..bad2ba4689d13a891f6c702a670bf23be6a28943 100644 --- a/src/parser/Parser.hpp +++ b/src/parser/Parser.hpp @@ -29,16 +29,16 @@ public: /*! - * \fn long get_size_loaded() = 0; + * \fn const int get_size_loaded() const = 0; * \return the size already loaded of the file by the parser */ - virtual long get_size_loaded() = 0; + virtual const int get_size_loaded() const = 0; /*! - * \fn get_total_size_of_file() + * \fn const int get_total_size_of_file() const = 0 * \return the size of the file parsed */ - virtual long get_total_size_of_file() = 0; + virtual const int get_total_size_of_file() const = 0; }; diff --git a/src/parser/ParserPaje.cpp b/src/parser/ParserPaje.cpp index 8260c0ad00c8cd10287e60e00e5ce92390f710ce..74767d94b6bc7553e2a2e9517e99b0953df06b37 100644 --- a/src/parser/ParserPaje.cpp +++ b/src/parser/ParserPaje.cpp @@ -71,12 +71,11 @@ void ParserPaje::set_file_to_parse(const string filename){ } -long ParserPaje::get_size_loaded(){ - static long temporary_solution = 0; - return (++ temporary_solution); +const int ParserPaje::get_size_loaded() const{ + return (TokenSource::get_size_loaded()); } -long ParserPaje::get_total_size_of_file(){ +const int ParserPaje::get_total_size_of_file() const{ struct stat buf; if(stat(_file_to_parse.c_str(), &buf) == -1){ perror(_file_to_parse.c_str()); diff --git a/src/parser/ParserPaje.hpp b/src/parser/ParserPaje.hpp index 5bf1528c71369a3c814c94646ce26ce4d5af4bb4..74f9d8dbae2d107b1ac9e14a612346bd7b5be0f5 100644 --- a/src/parser/ParserPaje.hpp +++ b/src/parser/ParserPaje.hpp @@ -44,13 +44,13 @@ public: * \fn get_size_loaded() * \return the size already loaded of the file by the parser */ - long get_size_loaded(); + const int get_size_loaded() const; /*! * \fn get_total_size_of_file() * \return the size of the file parsed */ - long get_total_size_of_file(); + const int get_total_size_of_file() const; }; #endif // PARSERPAJE_HPP diff --git a/src/parser/TokenSource.cpp b/src/parser/TokenSource.cpp index b4f54de76230fa6b12cfb118bef90c7e7dbffe67..765b3d424507a134cb8d7e08bcc0e0257c894c74 100644 --- a/src/parser/TokenSource.cpp +++ b/src/parser/TokenSource.cpp @@ -17,10 +17,10 @@ TokenSource::~TokenSource(){ #ifdef WIN32 _file.close(); #else - if (munmap(_buffer, _filesize) == -1){ - Error::set_and_print(Error::_MUNMAP, Error::_WARNING); - } - close(_fd); + if (munmap(_buffer, _filesize) == -1){ + Error::set_and_print(Error::_MUNMAP, Error::_WARNING); + } + close(_fd); #endif } @@ -33,37 +33,33 @@ void TokenSource::open(const char *filename){ _file.open(filename, ios::in); fill_buffer(); #else - if ((_fd = ::open(filename, O_RDONLY)) == -1){ - //Error::set_and_print(Error::_OPEN, Error::_ERROR); - throw Error::_OPEN; + if ((_fd = ::open(filename, O_RDONLY)) == -1) { + throw Error::_OPEN; } struct stat buf; - if(fstat(_fd, &buf) == -1){ - //Error::set_and_print(Error::_FSTAT, Error::_ERROR); - throw Error::_FSTAT; + if(fstat(_fd, &buf) == -1) { + throw Error::_FSTAT; } _filesize = buf.st_size; - if(_filesize == 0){ - //Error::set_and_print(Error::_EMPTY_FILE, Error::_ERROR); - throw Error::_EMPTY_FILE; + if(_filesize == 0) { + throw Error::_EMPTY_FILE; } - if ((_buffer = (char *)mmap(0, _filesize, PROT_READ, MAP_PRIVATE, _fd, 0)) == MAP_FAILED){ - //Error::set_and_print(Error::_MMAP, Error::_ERROR); - throw Error::_MMAP; + if ((_buffer = (char *)mmap(0, _filesize, PROT_READ, MAP_PRIVATE, _fd, 0)) == MAP_FAILED) { + throw Error::_MMAP; } #endif } #ifdef WIN32 -bool TokenSource::fill_buffer(){ - if (_file.eof()){ +bool TokenSource::fill_buffer() { + if (_file.eof()) { return false; } - else{ + else { _file.read(_buffer, BUFFER_SIZE); _buffer_size = _file.gcount(); return true; @@ -71,12 +67,12 @@ bool TokenSource::fill_buffer(){ } #endif -bool TokenSource::go_to_next_token(){ - while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t'){ +bool TokenSource::go_to_next_token() { + while(_buffer[_cursor] == ' ' || _buffer[_cursor] == '\t') { _cursor ++; #ifdef WIN32 - if (_cursor >= _buffer_size){ - if (!fill_buffer()){ + if (_cursor >= _buffer_size) { + if (!fill_buffer()) { return true; } _cursor = 0; @@ -86,7 +82,6 @@ bool TokenSource::go_to_next_token(){ break; #endif } - return false; } @@ -102,7 +97,7 @@ void TokenSource::build_composite_token() { _cursor = 0; } #else - if (ensure_capacity()){ + if (ensure_capacity()) { Error::set_and_print(Error::_FSTAT, Error::_WARNING); return; } @@ -111,7 +106,7 @@ void TokenSource::build_composite_token() { _token.push_back(_buffer[_cursor]); _cursor ++; - if (ensure_capacity()){ + if (ensure_capacity()) { break; } } @@ -121,7 +116,7 @@ void TokenSource::build_composite_token() { ensure_capacity(); } -void TokenSource::build_simple_token(){ +void TokenSource::build_simple_token() { while(_buffer[_cursor] != ' ' && _buffer[_cursor] != '\n' && _buffer[_cursor] != '\t'){ _token.push_back(_buffer[_cursor]); _cursor ++; @@ -132,10 +127,10 @@ void TokenSource::build_simple_token(){ } } -bool TokenSource::ensure_capacity(){ +bool TokenSource::ensure_capacity() { #ifdef WIN32 - if (_cursor >= _buffer_size){ - if (!fill_buffer()){ + if (_cursor >= _buffer_size) { + if (!fill_buffer()) { _is_eof = true; return true; } @@ -143,60 +138,65 @@ bool TokenSource::ensure_capacity(){ } return false; #else - if (_cursor < _filesize) - return false; - _is_eof = true; - return true; + if (_cursor < _filesize) + return false; + _is_eof = true; + return true; #endif } -void TokenSource::build_line_breaks(){ - while(_buffer[_cursor] == '\n'){ +void TokenSource::build_line_breaks() { + while(_buffer[_cursor] == '\n') { _cursor ++; - if (ensure_capacity()){ + if (ensure_capacity()) { break; } } _token.push_back('\n'); } -void TokenSource::build_definition_starter(){ +void TokenSource::build_definition_starter() { _cursor ++; ensure_capacity(); _token.push_back('%'); } -std::string *TokenSource::read_token(){ +std::string *TokenSource::read_token() { //regexp recognition //a token is //(1) a line break //(2) composite : a char buffer delimited by \" //(3) a char buffer delimited by space - if (!_token.empty()){ + if (!_token.empty()) { _token.clear(); } - if (_is_eof){ + if (_is_eof || go_to_next_token()) { return NULL; } - if(go_to_next_token()) - return NULL; - - if (_buffer[_cursor] == '\n'){ + if (_buffer[_cursor] == '\n') { build_line_breaks(); } - else if (_buffer[_cursor] == '%'){ + else if (_buffer[_cursor] == '%') { build_definition_starter(); } - else if (_buffer[_cursor] != '"'){ + else if (_buffer[_cursor] != '"') { build_simple_token(); } - else{ + else { build_composite_token(); } return &_token; } + +const int TokenSource::get_size_loaded() { +#ifdef WIN32 + return _file.tellg(); +#else + return 42; // Temporary!! +#endif +} diff --git a/src/parser/TokenSource.hpp b/src/parser/TokenSource.hpp index 5527b9cf21c35cdabcdb8e4deb5a257ac4e424e3..1ed8c038305bc20f42531cca6c4074066055873c 100644 --- a/src/parser/TokenSource.hpp +++ b/src/parser/TokenSource.hpp @@ -95,6 +95,9 @@ public: * \return a \\0-ended character string (char*), NULL if the file ended, NULL if no file is opened */ std::string* read_token(); + + + static const int get_size_loaded(); }; diff --git a/src/render/render.hpp b/src/render/render.hpp index 1df7b85685a999746d90c7a0550b96db63b2a05f..445b13a71533d9a664f8adb2db8aede6c6b4b2cc 100644 --- a/src/render/render.hpp +++ b/src/render/render.hpp @@ -12,137 +12,135 @@ class Render; #include "resource.hpp" - - /*! * \brief This class provides an interface for render classes like OpenGL or SVG. */ class Render - { +{ - public: +public: - /*! - * \brief Proceeds with the initialization of draw functions. - */ - virtual void start_draw() = 0; + /*! + * \brief Proceeds with the initialization of draw functions. + */ + virtual void start_draw() = 0; - /*! - * \brief Proceeds with the initialization of container draw functions. - */ - virtual void start_draw_containers() = 0; + /*! + * \brief Proceeds with the initialization of container draw functions. + */ + virtual void start_draw_containers() = 0; - /*! + /*! * \brief Draw a container according to the parameters * \param x the x position of the container * \param y the y position of the container * \param w the width of the container * \param h the height of the container */ - virtual void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) = 0; + virtual void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) = 0; - /*! - * \brief Draw the text of a container. - * \param x the x position of the text. - * \param y the y position of the text. - * \param value the string value of the text. - */ - virtual void draw_container_text(const Element_pos x, const Element_pos y, const std::string value) = 0; + /*! + * \brief Draw the text of a container. + * \param x the x position of the text. + * \param y the y position of the text. + * \param value the string value of the text. + */ + virtual void draw_container_text(const Element_pos x, const Element_pos y, const std::string value) = 0; - /*! - * \brief Called when all container draws are finished. - */ - virtual void end_draw_containers() = 0; + /*! + * \brief Called when all container draws are finished. + */ + virtual void end_draw_containers() = 0; - /*! - * \brief Proceeds with the initialization of state draw functions. - */ - virtual void start_draw_states() = 0; - - /*! - * \brief Draw a state of the trace. - * \param start the beginning time of the state. - * \param end the ending time of the state. - * \param base vertical position of the state. - * \param height the state height. - * \param r the red color rate of the state. - * \param g the green color rate of the state. - * \param b the blue color rate of the state. - */ - virtual void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) = 0; - - /*! - * \brief Called when all state draws are finished. - */ - virtual void end_draw_states() = 0; - - /*! - * \brief Proceeds with the initialization of arrow draw functions. - */ - virtual void start_draw_arrows() = 0; - - /*! - * \brief Draw an arrow. - * \param start_time the beginning time of the arrow. - * \param end_time the ending time of the arrow. - * \param start_height vertical position of the begining time of the arrow. - * \param end_height vertical position of the ending time of the arrow. - */ - virtual void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height) = 0; - - /*! - * \brief Called when all arrow draws are finished. - */ - virtual void end_draw_arrows() = 0; - - /*! - * \brief Draw an event. - * \param time time when the event occurs. - * \param height vertical position of the event. - * \param container_height information to draw event. It corresponds to the container height when they are drawn horizontally. - */ - virtual void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height) = 0; - - /*! - * \brief Proceeds with the initialization of counter draw functions. - */ - virtual void start_draw_counter() = 0; + /*! + * \brief Proceeds with the initialization of state draw functions. + */ + virtual void start_draw_states() = 0; + + /*! + * \brief Draw a state of the trace. + * \param start the beginning time of the state. + * \param end the ending time of the state. + * \param base vertical position of the state. + * \param height the state height. + * \param r the red color rate of the state. + * \param g the green color rate of the state. + * \param b the blue color rate of the state. + */ + virtual void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) = 0; + + /*! + * \brief Called when all state draws are finished. + */ + virtual void end_draw_states() = 0; + + /*! + * \brief Proceeds with the initialization of arrow draw functions. + */ + virtual void start_draw_arrows() = 0; + + /*! + * \brief Draw an arrow. + * \param start_time the beginning time of the arrow. + * \param end_time the ending time of the arrow. + * \param start_height vertical position of the begining time of the arrow. + * \param end_height vertical position of the ending time of the arrow. + */ + virtual void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height) = 0; + + /*! + * \brief Called when all arrow draws are finished. + */ + virtual void end_draw_arrows() = 0; + + /*! + * \brief Draw an event. + * \param time time when the event occurs. + * \param height vertical position of the event. + * \param container_height information to draw event. It corresponds to the container height when they are drawn horizontally. + */ + virtual void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height) = 0; + + /*! + * \brief Proceeds with the initialization of counter draw functions. + */ + virtual void start_draw_counter() = 0; - /*! - * \brief Draw a point of the counter. - * \param x x position of the point. - * \param y y position of the point. - * - * Each time counter is increased, this function is called with the coordinates of the new point. - */ - virtual void draw_counter(const Element_pos x, const Element_pos y) = 0; + /*! + * \brief Draw a point of the counter. + * \param x x position of the point. + * \param y y position of the point. + * + * Each time counter is increased, this function is called with the coordinates of the new point. + */ + virtual void draw_counter(const Element_pos x, const Element_pos y) = 0; - /*! - * \brief Called when all counter draws are finished. - */ - virtual void end_draw_counter() = 0; + /*! + * \brief Called when all counter draws are finished. + */ + virtual void end_draw_counter() = 0; - /*! - * \brief Called when all draws are finished. - */ - virtual void end_draw() = 0; + /*! + * \brief Called when all draws are finished. + */ + virtual void end_draw() = 0; /*! * \brief Set Statistics and Informations about input trace */ - virtual void set_total_width(Element_pos w) = 0; + virtual void set_total_width(Element_pos w) = 0; /*! * \brief Set Statistics and Informations about input trace */ - virtual void set_total_time(Times t) = 0; + virtual void set_total_time(Times t) = 0; /*! * \brief display the scale */ - virtual void display_time_scale() = 0; - }; + virtual void display_time_scale() = 0; +}; - #endif +#endif diff --git a/src/render/render_opengl.cpp b/src/render/render_opengl.cpp index ad5e80d90c4f0221e9f5a33131ae0e0e62616e48..5ce1c6c8740d5ae06969778c765fd8e6f8ac8449 100644 --- a/src/render/render_opengl.cpp +++ b/src/render/render_opengl.cpp @@ -9,6 +9,8 @@ extern bool Info::Render::_key_alt; using namespace std; + + #define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): " @@ -22,14 +24,13 @@ using namespace std; * **********************************/ -Render_opengl::Render_opengl(QWidget *parent) - : QGLWidget(parent){ +Render_opengl::Render_opengl(QWidget *parent) : QGLWidget(parent){ // GLenum glew_code; - if (!QGLFormat::hasOpenGL()){ + if (!QGLFormat::hasOpenGL()){ QMessageBox::information(0, "ViTE: Fatal OpenGL error","This system does not support OpenGL."); - } + } @@ -41,19 +42,19 @@ Render_opengl::Render_opengl(QWidget *parent) /* init the wait animation */ _wait_list = 0;/* init list */ - _wait_angle=0.0f;/* begin with 0 rad angle */ - _wait_angle_y=0.0f;/* begin with 0 rad angle */ + _wait_angle = 0.0f;/* begin with 0 rad angle */ + _wait_angle_y = 0.0f;/* begin with 0 rad angle */ _wait_timer = NULL; - _wait_spf=DRAWING_TIMER_DEFAULT;/* DRAWING_TIMER_DEFAULT milliseconds per frame */ + _wait_spf = DRAWING_TIMER_DEFAULT;/* DRAWING_TIMER_DEFAULT milliseconds per frame */ /* init the trace drawing */ - _drawing_list=0; + _drawing_list = 0; - _counter_last_x=0.0; - _counter_last_y=0.0; + _counter_last_x = 0.0; + _counter_last_y = 0.0; _line_already_begun = false; @@ -100,7 +101,7 @@ Render_opengl::Render_opengl(QWidget *parent) // Info::Render::_key_alt = false;/* no CTRL key pushed */ /* OpenGL lists */ - _list_containers =0; + _list_containers = 0; _list_states = 0; _list_counters = 0; @@ -129,28 +130,28 @@ Render_opengl::Render_opengl(QWidget *parent) updateGL(); - // glew_code = glewInit();/* use for VBO and shaders */ + // glew_code = glewInit();/* use for VBO and shaders */ -// if(GLEW_OK != glew_code){ -// message << "Cannot initialize GLEW: " << glewGetErrorString(glew_code) << Message::ende; -// } + // if(GLEW_OK != glew_code){ + // message << "Cannot initialize GLEW: " << glewGetErrorString(glew_code) << Message::ende; + // } -// /*Check if VBO is supported */ -// if (GL_FALSE == glewIsSupported("GL_ARB_vertex_buffer_object")){ -// message << "VBO OpenGL extension is not supported by your graphic card." << Message::ende; -// } + // /*Check if VBO is supported */ + // if (GL_FALSE == glewIsSupported("GL_ARB_vertex_buffer_object")){ + // message << "VBO OpenGL extension is not supported by your graphic card." << Message::ende; + // } } Render_opengl::~Render_opengl(){ - if (glIsList(_wait_list)==GL_TRUE) + if (glIsList(_wait_list) == GL_TRUE) glDeleteLists(_wait_list, 1); - if (glIsList(_drawing_list)==GL_TRUE) + if (glIsList(_drawing_list) == GL_TRUE) glDeleteLists(_drawing_list, 1); - if (_wait_timer!=NULL){ + if (_wait_timer != NULL){ delete _wait_timer; _wait_timer=NULL; } @@ -167,20 +168,17 @@ Render_opengl::~Render_opengl(){ **********************************/ -void Render_opengl::initializeGL(){ +void Render_opengl::initializeGL() { glClearColor(0.5f, 0.5f, 0.55f, 1.0f); - glEnable(GL_DEPTH_TEST); glClearStencil(0); _wait_list = draw_wait(); - - } -void Render_opengl::resizeGL(int width, int height){ +void Render_opengl::resizeGL(int width, int height) { glViewport(0, 0, width, height); @@ -192,7 +190,7 @@ void Render_opengl::resizeGL(int width, int height){ glLoadIdentity(); - switch(_state){ + switch(_state) { case DRAWING_STATE_WAINTING:// A wait is drawn glOrtho(-50, 50, -50, 50, 0, 1000); @@ -207,7 +205,6 @@ void Render_opengl::resizeGL(int width, int height){ glMatrixMode(GL_MODELVIEW); - } @@ -220,8 +217,6 @@ void Render_opengl::paintGL(){ string buf_txt; - - resizeGL(width(), height()); glClearDepth(1.0); @@ -342,7 +337,6 @@ void Render_opengl::paintGL(){ const char letter = buf_txt.c_str()[i]; length += glutBitmapWidth(GLUT_BITMAP_HELVETICA_10, letter); if(length > size_of_container){ - break; } glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, letter); @@ -385,69 +379,64 @@ void Render_opengl::paintGL(){ draw_stored_events(_events);/* draw events without display lists */ + } - - - - - - } - glPopMatrix(); + glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); - glPushMatrix(); - { - // glTranslated(0.0, _container_y_max- 3*_ruler_height, 100.0);/* not accurate */ - glTranslated(0.0, 0.0, 100.0);/* not accurate */ + glPushMatrix(); + { + // glTranslated(0.0, _container_y_max- 3*_ruler_height, 100.0);/* not accurate */ + glTranslated(0.0, 0.0, 100.0);/* not accurate */ - if (true==_mouse_pressed){ + if (_mouse_pressed){ - glTranslated(0.0, 0.0, _z_container); + glTranslated(0.0, 0.0, _z_container); - Element_pos old_x, old_y, new_x, new_y; + Element_pos old_x, old_y, new_x, new_y; - old_x = _mouse_x*(_render_width/_screen_width); - old_y = _render_height - _mouse_y*(_render_height/_screen_height); - new_x = _new_mouse_x*(_render_width/_screen_width); - new_y = _render_height - _new_mouse_y*(_render_height/_screen_height); + old_x = _mouse_x*(_render_width/_screen_width); + old_y = _render_height - _mouse_y*(_render_height/_screen_height); + new_x = _new_mouse_x*(_render_width/_screen_width); + new_y = _render_height - _new_mouse_y*(_render_height/_screen_height); #ifdef DEBUG_MODE_RENDER_OPENGL - cerr << __FILE__ << " l." << __LINE__ << ":" << endl; - cerr << "Selection rectangle position: (" << old_x << ", " << old_y << ") - (" << new_x << ", " << new_y << ")" << endl; + cerr << __FILE__ << " l." << __LINE__ << ":" << endl; + cerr << "Selection rectangle position: (" << old_x << ", " << old_y << ") - (" << new_x << ", " << new_y << ")" << endl; #endif - glEnable(GL_ALPHA_TEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_ALPHA_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBegin(GL_QUADS); - { - glColor4d(0.9, 1.0, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, old_y); - glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, new_y); - glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, new_y); - glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, old_y); - } - glEnd(); + glBegin(GL_QUADS); + { + glColor4d(0.9, 1.0, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, old_y); + glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(old_x, new_y); + glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, new_y); + glColor4d(0.9, 0.9, 0.9, _selection_rectangle_alpha);glVertex2d(new_x, old_y); + } + glEnd(); - glDisable(GL_BLEND); - glDisable(GL_ALPHA_TEST); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); - }/* end if (true==_mouse_pressed) */ - } - glPopMatrix(); + }/* end if (true==_mouse_pressed) */ + } + glPopMatrix(); - break; + break; default: message << "Undefined value for the drawing state attribute - Render area" << Message::ende; } - glFlush(); + glFlush(); /* Check the errors */ @@ -472,63 +461,61 @@ void Render_opengl::mousePressEvent(QMouseEvent * event){ // QApplication::setOverrideCursor(Qt::ClosedHandCursor); /* - * Now determine where the user had clicked - */ + * Now determine where the user had clicked + */ x_click = _mouse_x * (Element_pos)_render_width/(Element_pos)_screen_width;/* x position of the click in the OpenGL scene */ y_click = _mouse_y * (Element_pos)_render_height/(Element_pos)_screen_height;/* y position of the click in the OpenGL scene */ // cerr << x_click << " " << y_click << " - " << _screen_width << " " << _screen_height << endl; - /* - * First, check the y position if user clicks on the ruler or other - */ + /* + * First, check the y position if user clicks on the ruler or other + */ - if ( y_click <= (_ruler_height+_ruler_y) )/* user had clicked on the ruler */ - return; + if (y_click <= (_ruler_height+_ruler_y))/* user had clicked on the ruler */ + return; - // cerr << "No click ruler" << endl; + // cerr << "No click ruler" << endl; - /* Work out the y value in Data Structure coordinates */ - // y_result = y_click/((Element_pos)_container_height + v_space); + /* Work out the y value in Data Structure coordinates */ + // y_result = y_click/((Element_pos)_container_height + v_space); - /* - * Second, check the x position if user click on the container or other - */ + /* + * Second, check the x position if user click on the container or other + */ - if (x_click <= (_x_scale_container_state*_render_width) ){/* user had clicked on the container */ - // cerr << "Click container" << endl; - } - else{ - /* - * Determine the time corresponding to the x click position. - * It is equal to the x click position in the OpenGL render area minus the default translation of entities. - * Also, near the container area time is 0 except if a translation had occured. - * So add the state translate and the x_result will be obtained. - * - * Take care that x_result can be negative. - */ - x_result = (x_click - _default_entity_x_translate + _state_translate); + if (x_click <= (_x_scale_container_state*_render_width) ){/* user had clicked on the container */ + // cerr << "Click container" << endl; + } + else{ + /* + * Determine the time corresponding to the x click position. + * It is equal to the x click position in the OpenGL render area minus the default translation of entities. + * Also, near the container area time is 0 except if a translation had occured. + * So add the state translate and the x_result will be obtained. + * + * Take care that x_result can be negative. + */ + x_result = (x_click - _default_entity_x_translate + _state_translate); - /* - * To convert from [0;_render_width*_state_scale] to [_state_x_min;_state_x_max] - */ - x_result *= (_state_x_max - _state_x_min)/(_render_width*_state_scale); + /* + * To convert from [0;_render_width*_state_scale] to [_state_x_min;_state_x_max] + */ + x_result *= (_state_x_max - _state_x_min)/(_render_width*_state_scale); - // message << "Click entity" << x_result << Message::endsi; - } + // message << "Click entity" << x_result << Message::endsi; + } } void Render_opengl::mouseMoveEvent(QMouseEvent * event){ - - - if (false==_mouse_pressed) return; + if (!_mouse_pressed) return; _new_mouse_x = event->x(); _new_mouse_y = event->y(); - updateGL(); + updateGL(); } @@ -548,13 +535,12 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * /*event*/){ * First, check if there is a significant difference between mouse coordinates. Prevent bad manipulations. */ - if ( ((_new_mouse_x-_mouse_x) < _minimum_distance_for_selection) - && ((_new_mouse_y-_mouse_y) < _minimum_distance_for_selection) ) - { - _mouse_pressed = false; - updateGL(); - return; - } + if (((_new_mouse_x-_mouse_x) < _minimum_distance_for_selection) + && ((_new_mouse_y-_mouse_y) < _minimum_distance_for_selection)) { + _mouse_pressed = false; + updateGL(); + return; + } /* * Now, we try to zoom on the selection rectangle. To perform this, the left of the selection rectangle must be fit with the left @@ -602,7 +588,7 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * /*event*/){ * Translate entities. */ _state_translate += x_scaled_middle_selection - x_distance_between_state_origin_and_render_middle; - _y_state_translate -= y_scaled_middle_selection - y_distance_between_state_origin_and_render_middle; + _y_state_translate -= y_scaled_middle_selection - y_distance_between_state_origin_and_render_middle; /* @@ -617,22 +603,23 @@ void Render_opengl::mouseReleaseEvent(QMouseEvent * /*event*/){ } -void Render_opengl::wheelEvent(QWheelEvent * event){ - int num_degrees = event->delta() / 8; - int num_steps = num_degrees / 15; - Element_pos scale_coeff = num_steps; - // cerr << Info::Render::_key_alt << endl; - if (true == Info::Render::_key_alt){/* Zoom on height */ - change_scale_y(scale_coeff); - }else{ /* Zoom on time */ - change_scale(scale_coeff); - } +void Render_opengl::wheelEvent(QWheelEvent * event) { + int num_degrees = event->delta() / 8; + int num_steps = num_degrees / 15; + Element_pos scale_coeff = num_steps; + // cerr << Info::Render::_key_alt << endl; + if (Info::Render::_key_alt) {/* Zoom on height */ + change_scale_y(scale_coeff); + } + else { /* Zoom on time */ + change_scale(scale_coeff); + } - event->accept();/* accept the event */ + event->accept();/* accept the event */ } -void Render_opengl::keyPressEvent(QKeyEvent * event){ +void Render_opengl::keyPressEvent(QKeyEvent * event) { int ctrl_factor = 1; @@ -645,7 +632,7 @@ void Render_opengl::keyPressEvent(QKeyEvent * event){ ctrl_factor *= _ctrl_scroll_factor; } - switch (event->key()){ + switch (event->key()) { case Qt::Key_Left: /* * Key 'left' pressed. @@ -704,10 +691,9 @@ void Render_opengl::keyPressEvent(QKeyEvent * event){ void Render_opengl::keyReleaseEvent(QKeyEvent * event){ - if (event->key() == Qt::Key_Alt) { // cerr << "Release" << endl; - Info::Render::_key_alt = false; + Info::Render::_key_alt = false; } } @@ -757,7 +743,7 @@ void Render_opengl::change_scale_y(Element_pos scale_coeff){ } -void Render_opengl::replace_scale(Element_pos new_scale){ +void Render_opengl::replace_scale(Element_pos new_scale){ _state_scale = new_scale; _state_translate += ( _state_translate - _default_entity_x_translate + (Element_pos)_render_width/2.0) * ((new_scale)/(_state_scale) - 1); @@ -766,10 +752,10 @@ void Render_opengl::replace_scale(Element_pos new_scale){ } -void Render_opengl::change_translate(int translate){ +void Render_opengl::change_translate(int translate){ - if ( ( translate > 0 ) /* translation to the left */ - && ( (_state_translate / _state_scale) >= _render_width ) ){ + if (( translate > 0 ) /* translation to the left */ + && ((_state_translate / _state_scale) >= _render_width )){ return; } else if ( ( translate < 0 ) /* translation to the right */ @@ -782,7 +768,7 @@ void Render_opengl::change_translate(int translate){ } -void Render_opengl::change_translate_y(int translate){ +void Render_opengl::change_translate_y(int translate){ if ( ( translate > 0 ) /* translation to the top */ && ( (-_y_state_translate / _y_state_scale) <= 0 ) ){ @@ -790,14 +776,14 @@ void Render_opengl::change_translate_y(int translate){ }else if ( ( translate < 0 ) /* translation to the bottom */ && ( (-_y_state_translate / _y_state_scale) >= 100 ) ){ return; - } + } _y_state_translate += translate; updateGL(); } -void Render_opengl::replace_translate(Element_pos new_translate){ +void Render_opengl::replace_translate(Element_pos new_translate){ _state_translate = new_translate; @@ -805,34 +791,34 @@ void Render_opengl::replace_translate(Element_pos new_translate){ } -void Render_opengl::replace_translate_y(Element_pos new_translate){ +void Render_opengl::replace_translate_y(Element_pos new_translate){ - // if (0 == new_translate){/* show the beginning states */ + // if (0 == new_translate){/* show the beginning states */ -// _y_state_translate = 0; + // _y_state_translate = 0; -// }else if (-1 == new_translate){/* show the latest states */ -// /*_y_state_translate = (_default_entity_x_translate - (Element_pos)_render_width/2.0 + _state_x_max*_state_scale -// *((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)));*/ + // }else if (-1 == new_translate){/* show the latest states */ + // /*_y_state_translate = (_default_entity_x_translate - (Element_pos)_render_width/2.0 + _state_x_max*_state_scale + // *((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)));*/ -// }else if (-2 == new_translate){/* show the entire trace */ + // }else if (-2 == new_translate){/* show the entire trace */ -// _state_translate = 0; -// _y_state_translate = 0; -// _state_scale = 1; -// _y_state_scale = 1; + // _state_translate = 0; + // _y_state_translate = 0; + // _state_scale = 1; + // _y_state_scale = 1; -// }else{/* Default, just replace the current translate the by new_translate value + // }else{/* Default, just replace the current translate the by new_translate value // */ - _y_state_translate = -new_translate; - // } + _y_state_translate = -new_translate; + // } updateGL(); } -void Render_opengl::registered_translate(int id){ +void Render_opengl::registered_translate(int id){ switch (id){ @@ -848,7 +834,7 @@ void Render_opengl::registered_translate(int id){ break; case Info::Render::Y_TRACE_ENDING:/* show the ending entities */ _y_state_translate = ( -_ruler_height + (Element_pos)_render_height/2.0 - _state_y_max*_y_state_scale - *((_render_height-_ruler_height)/(_state_y_max-_state_y_min))); + *((_render_height-_ruler_height)/(_state_y_max-_state_y_min))); break; case Info::Render::X_TRACE_ENTIRE:/* show the entire entities */ _state_translate = 0; @@ -866,7 +852,7 @@ void Render_opengl::registered_translate(int id){ } -void Render_opengl::change_scale_container_state(int view_size){ +void Render_opengl::change_scale_container_state(int view_size){ _x_scale_container_state = 0.01 * view_size; updateGL(); @@ -888,16 +874,16 @@ void Render_opengl::change_scale_container_state(int view_size){ bool Render_opengl::build(){ - if (glIsList(_wait_list)==GL_TRUE){/* if the list exists */ + if (glIsList(_wait_list) == GL_TRUE){/* if the list exists */ glDeleteLists(_wait_list, 1); _wait_list = 0; } - if (glIsList(_wait_list)==GL_TRUE){ + if (glIsList(_wait_list) == GL_TRUE){ message << "Cannot unbuild the waiting animation" << Message::endw; } - if (_wait_timer->isActive()==true)/* if timer for the wait animation is running */ + if (_wait_timer->isActive())/* if timer for the wait animation is running */ _wait_timer->stop(); _state = DRAWING_STATE_DRAWING;/* change the drawing state */ @@ -930,21 +916,21 @@ bool Render_opengl::unbuild(){ glDeleteLists(_list_containers, 1); _list_containers = 0; - if (glIsList(_list_containers)==GL_TRUE) /* if the list exists */ + if (glIsList(_list_containers) == GL_TRUE) /* if the list exists */ message << "Cannot delete container list" << Message::ende; /* Free state list */ glDeleteLists(_list_states, 1); _list_states = 0; - if (glIsList(_list_states)==GL_TRUE) /* if the list exists */ + if (glIsList(_list_states) == GL_TRUE) /* if the list exists */ message << "Cannot delete state list" << Message::ende; /* Free counter list */ glDeleteLists(_list_counters, 1); _list_counters = 0; - if (glIsList(_list_counters)==GL_TRUE) /* if the list exists */ + if (glIsList(_list_counters) == GL_TRUE) /* if the list exists */ message << "Cannot delete counter list" << Message::ende; @@ -954,7 +940,7 @@ bool Render_opengl::unbuild(){ * ********************/ - if (_wait_timer->isActive()==false)/* if timer for the wait animation is not running */ + if (!_wait_timer->isActive())/* if timer for the wait animation is not running */ _wait_timer->start(_wait_spf); @@ -964,7 +950,7 @@ bool Render_opengl::unbuild(){ * *****************/ - if (glIsList(_wait_list)==GL_FALSE) + if (glIsList(_wait_list) == GL_FALSE) _wait_list = draw_wait();/* create the wait draw */ else { message << "The wait draw was not released." << Message::endw; @@ -972,7 +958,7 @@ bool Render_opengl::unbuild(){ } /* if there is an error, do not display the wait an return immediatly */ - if (glIsList(_wait_list)==GL_FALSE) { + if (glIsList(_wait_list) == GL_FALSE) { message << "Cannot create the wait draw." << Message::endw; return false; } @@ -1137,7 +1123,7 @@ void Render_opengl::create_ruler(){ if ( (x_min<0.0) && ((entity_width+x_min)>graduation_distance)){/* we are not viewing the beginning of the trace (i.e. the 0.0 coordinate) but we still viewing the trace (not after the end) */ /* draw previous small graduations */ - for (char k=1 ; k<5 ; k++){ + for (char k = 1 ; k < 5 ; k ++){ glBegin(GL_LINES); { glColor3d(1.0, 1.0, 1.0);glVertex3d(start_delay-k*graduation_distance_per_5, _ruler_y, _z_ruler); @@ -1149,13 +1135,13 @@ void Render_opengl::create_ruler(){ /* Draw spaced graduation of _ruler_distance */ - for (Element_pos i=max(x_min, start_delay) ; i<=min(entity_width+x_min, _render_width) ; i+=graduation_distance){ + for (Element_pos i = max(x_min, start_delay) ; i<=min(entity_width+x_min, _render_width) ; i+=graduation_distance){ if (i != min(entity_width+x_min, _render_width) ){/* prepare small graduations between the current and the next main graduation */ /* draw small graduations */ - for (char k=1 ; k<5 ; k++){ + for (char k = 1 ; k < 5 ; k ++){ glBegin(GL_LINES); { glColor3d(1.0, 1.0, 1.0);glVertex3d(i+k*graduation_distance_per_5, _ruler_y, _z_ruler); @@ -1187,31 +1173,31 @@ void Render_opengl::create_ruler(){ buf_txt << buf_number; - for(unsigned int j=0;j<buf_txt.str().length();j++){ - glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]); + for(unsigned int j = 0 ; j < buf_txt.str().length() ; j ++){ + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]); } - buf_txt.str("");/* flush the buffer */ + buf_txt.str("");/* flush the buffer */ } /* Draw the ended graduation line */ - glBegin(GL_LINES); - { - glColor3d(1.0, 1.0, 1.0);glVertex3d(ruler_width*_ruler_distance, _ruler_y, _z_ruler); - glColor3d(1.0, 0.6, 0.6);glVertex3d(ruler_width*_ruler_distance, _ruler_y+_ruler_height, _z_ruler); - } - glEnd(); - - /* Draw the ended graduation text */ - /* glColor3d(1.0, 1.0, 1.0); - glRasterPos2f(entity_width, _ruler_y+_ruler_height); + glBegin(GL_LINES); + { + glColor3d(1.0, 1.0, 1.0);glVertex3d(ruler_width*_ruler_distance, _ruler_y, _z_ruler); + glColor3d(1.0, 0.6, 0.6);glVertex3d(ruler_width*_ruler_distance, _ruler_y+_ruler_height, _z_ruler); + } + glEnd(); + + /* Draw the ended graduation text */ + /* glColor3d(1.0, 1.0, 1.0); + glRasterPos2f(entity_width, _ruler_y+_ruler_height); - buf_txt << (ruler_width*_ruler_distance-x_min)*coeff; + buf_txt << (ruler_width*_ruler_distance-x_min)*coeff; - for(unsigned int j=0;j<buf_txt.str().length();j++){ + for(unsigned int j=0;j<buf_txt.str().length();j++){ glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]); - } - */ + } + */ } // void Render_opengl::create_ruler(){ diff --git a/src/render/render_opengl.hpp b/src/render/render_opengl.hpp index 18b3f81cdfc149493e1e3240dc2edbef64bd9609..2fd90faa4bd77201ccbb4cff293e0b96b48cf52d 100644 --- a/src/render/render_opengl.hpp +++ b/src/render/render_opengl.hpp @@ -5,11 +5,6 @@ #ifndef RENDER_OPENGL_HPP #define RENDER_OPENGL_HPP - - - - - class Render_opengl; /* Global informations */ @@ -20,7 +15,6 @@ class Render_opengl; #include "resource.hpp" - /*! * \brief Structure used to store event information. */ @@ -66,711 +60,711 @@ struct Arrow_{ * \brief This class redefined the OpenGL widget - QGLWidget - to display the trace. */ class Render_opengl : public QGLWidget, public Render - { - Q_OBJECT +{ + Q_OBJECT - protected: + protected: - /*! - * \brief Contains container text coordinates. - */ - std::list<Element_pos> _text_pos; + /*! + * \brief Contains container text coordinates. + */ + std::list<Element_pos> _text_pos; - /*! - * \brief Contains container strings. - */ - std::list<std::string> _text_value; + /*! + * \brief Contains container strings. + */ + std::list<std::string> _text_value; - /*! - * \brief Contains arrow informations. - */ - std::vector<Arrow_> _arrows; + /*! + * \brief Contains arrow informations. + */ + std::vector<Arrow_> _arrows; - /*! - * \brief Contains event informations. - */ - std::vector<Event_> _events; + /*! + * \brief Contains event informations. + */ + std::vector<Event_> _events; - /*********************************** - * - * Render area state attributes. - * - **********************************/ + /*********************************** + * + * Render area state attributes. + * + **********************************/ - /*! - * \brief State when there is no file opened. - */ - static const int DRAWING_STATE_WAINTING = 1; + /*! + * \brief State when there is no file opened. + */ + static const int DRAWING_STATE_WAINTING = 1; - /*! - * \brief State when the application is drawing traces. - */ - static const int DRAWING_STATE_DRAWING = 2; - - /*! - * \brief Contains the kind of state for the render area (drawing, waiting, etc.). - */ - int _state; - - /*! - * \brief Indicated if mouse is pressed or not. - */ - bool _mouse_pressed; - - /*! - * \brief Used to store the mouse last x position. - */ - int _mouse_x; - - /*! - * \brief Used to store the mouse last y position. - */ - int _mouse_y; - - /*! - * \brief Used to store the mouse current x position. - */ - int _new_mouse_x; - - /*! - * \brief Used to store the mouse current y position. - */ - int _new_mouse_y; - - /*! - * \brief Alpha color of the selection rectangle. - */ - double _selection_rectangle_alpha; - - /*! - * \brief Define the minimum width and height to draw the selection rectangle (avoid bas manipulations). - */ - Element_pos _minimum_distance_for_selection; + /*! + * \brief State when the application is drawing traces. + */ + static const int DRAWING_STATE_DRAWING = 2; + + /*! + * \brief Contains the kind of state for the render area (drawing, waiting, etc.). + */ + int _state; + + /*! + * \brief Indicated if mouse is pressed or not. + */ + bool _mouse_pressed; + + /*! + * \brief Used to store the mouse last x position. + */ + int _mouse_x; + + /*! + * \brief Used to store the mouse last y position. + */ + int _mouse_y; + + /*! + * \brief Used to store the mouse current x position. + */ + int _new_mouse_x; + + /*! + * \brief Used to store the mouse current y position. + */ + int _new_mouse_y; + + /*! + * \brief Alpha color of the selection rectangle. + */ + double _selection_rectangle_alpha; + + /*! + * \brief Define the minimum width and height to draw the selection rectangle (avoid bas manipulations). + */ + Element_pos _minimum_distance_for_selection; - /*! - * \brief Define the scrolling factor when CTRL key is pressed. - */ - static const int _ctrl_scroll_factor = 10; + /*! + * \brief Define the scrolling factor when CTRL key is pressed. + */ + static const int _ctrl_scroll_factor = 10; - /*! - * \brief Define the scrolling factor when CTRL key is pressed. - */ - static const int _ctrl_zoom_factor = 3; + /*! + * \brief Define the scrolling factor when CTRL key is pressed. + */ + static const int _ctrl_zoom_factor = 3; - /*********************************** - * - * Default QGLWidget functions. - * - **********************************/ + /*********************************** + * + * Default QGLWidget functions. + * + **********************************/ - /*! - * \brief Call by the system to initialize the OpenGL render area. - */ - void initializeGL(); + /*! + * \brief Call by the system to initialize the OpenGL render area. + */ + void initializeGL(); - /*! - * \brief Call by the system when the render area was resized (occurs during a window resizement). - * \arg width : the new width of the render area. - * height : the new height of the render area. - */ - void resizeGL(int width, int height); + /*! + * \brief Call by the system when the render area was resized (occurs during a window resizement). + * \arg width : the new width of the render area. + * height : the new height of the render area. + */ + void resizeGL(int width, int height); - /*! - * \brief Call by the system each time the render area need to be updated. - */ - void paintGL(); - - /*! - * \brief This functions receives all mouse press events. - * \arg event The event triggered by mouse. - */ - void mousePressEvent(QMouseEvent * event); - - /*! - * \brief If user press, this functions receives all mouse move events until user release mouse. - * \arg event The event triggered by mouse. - */ - void mouseMoveEvent(QMouseEvent * event); - - /*! - * \brief This functions receives all mouse release events. - * \arg event The event triggered by mouse. - */ - void mouseReleaseEvent(QMouseEvent * event); - - /*! - * \brief This functions receives all mouse wheel events. - * \arg event The event triggered by the mouse wheel. - */ - void wheelEvent(QWheelEvent * event); + /*! + * \brief Call by the system each time the render area need to be updated. + */ + void paintGL(); + + /*! + * \brief This functions receives all mouse press events. + * \arg event The event triggered by mouse. + */ + void mousePressEvent(QMouseEvent * event); + + /*! + * \brief If user press, this functions receives all mouse move events until user release mouse. + * \arg event The event triggered by mouse. + */ + void mouseMoveEvent(QMouseEvent * event); + + /*! + * \brief This functions receives all mouse release events. + * \arg event The event triggered by mouse. + */ + void mouseReleaseEvent(QMouseEvent * event); + + /*! + * \brief This functions receives all mouse wheel events. + * \arg event The event triggered by the mouse wheel. + */ + void wheelEvent(QWheelEvent * event); - /*! - * \brief This functions receives all keyboard events. - * \arg event The event triggered by the keyboard event. - */ - void keyPressEvent(QKeyEvent * event); - - /*! - * \brief This functions receives all keyboard release events. - * \arg event The event triggered by a keyboard release. - */ - void keyReleaseEvent(QKeyEvent * event); + /*! + * \brief This functions receives all keyboard events. + * \arg event The event triggered by the keyboard event. + */ + void keyPressEvent(QKeyEvent * event); + + /*! + * \brief This functions receives all keyboard release events. + * \arg event The event triggered by a keyboard release. + */ + void keyReleaseEvent(QKeyEvent * event); - /*********************************** - * - * The wait screen drawing. - * - **********************************/ + /*********************************** + * + * The wait screen drawing. + * + **********************************/ - /*********************************** - * The wait list Attributes. - **********************************/ + /*********************************** + * The wait list Attributes. + **********************************/ - /*! - * \brief Used for draw counter. - */ - bool _line_already_begun; + /*! + * \brief Used for draw counter. + */ + bool _line_already_begun; - /*! - * \brief The wait GLu list. - */ - GLuint _wait_list; + /*! + * \brief The wait GLu list. + */ + GLuint _wait_list; - /*! - * \brief The container GLu list. - */ - GLuint _list_containers; + /*! + * \brief The container GLu list. + */ + GLuint _list_containers; - /*! - * \brief The state GLu list. - */ - GLuint _list_states; + /*! + * \brief The state GLu list. + */ + GLuint _list_states; - /*! - * \brief The counter GLu list. - */ - GLuint _list_counters; + /*! + * \brief The counter GLu list. + */ + GLuint _list_counters; - /*! - * \brief Rotation angle for the wait. + /*! + * \brief Rotation angle for the wait. */ - float _wait_angle; + float _wait_angle; - /*! - * \brief Y rotation angle for the wait. + /*! + * \brief Y rotation angle for the wait. */ - float _wait_angle_y; + float _wait_angle_y; - /*! - * \brief Time in ms between two frames for the waiting screen. - */ - static const int DRAWING_TIMER_DEFAULT = 10; + /*! + * \brief Time in ms between two frames for the waiting screen. + */ + static const int DRAWING_TIMER_DEFAULT = 10; - /*! - * \brief Wait animation seconds per frame. - */ - int _wait_spf; + /*! + * \brief Wait animation seconds per frame. + */ + int _wait_spf; - /*! - * \brief Timer to animate the wait. - */ - QTimer* _wait_timer; + /*! + * \brief Timer to animate the wait. + */ + QTimer* _wait_timer; - /*********************************** - * Drawing function for the wait screen. - **********************************/ + /*********************************** + * Drawing function for the wait screen. + **********************************/ - /*! + /*! * \brief Display a wait on the screen if there is no file opened. * \return Asset value of the wait. */ - GLuint draw_wait(); + GLuint draw_wait(); - /*********************************** - * - * The trace drawing. - * - **********************************/ + /*********************************** + * + * The trace drawing. + * + **********************************/ - /*********************************** - * The drawing list Attributes. - **********************************/ + /*********************************** + * The drawing list Attributes. + **********************************/ - /*! - * \brief The trace Glu list. - */ - GLuint _drawing_list; - - /*! - * \brief The last x position of the point (for counter). - */ - Element_pos _counter_last_x; - - /*! - * \brief The last y position of the point (for counter). - */ - Element_pos _counter_last_y; - - /*! - * \brief The opengl render area width in pixels. - */ - Element_pos _screen_width; - - /*! - * \brief The opengl render area height in pixels. - */ - Element_pos _screen_height; - - /*! - * \brief The opengl visibled scene width in the OpenGL units. - */ - Element_pos _render_width; - - /*! - * \brief The opengl visibled scene height in the OpenGL units. - */ - Element_pos _render_height; - - /*! - * \brief The width of container area draw. - */ - Element_pos _container_x_max; - - /*! - * \brief The height of container area draw. - */ - Element_pos _container_y_max; - - /*! - * \brief The x base of container area draw. - */ - Element_pos _container_x_min; - - /*! - * \brief The y base of container area draw. - */ - Element_pos _container_y_min; - - /*! - * \brief The width of state area draw. - */ - Element_pos _state_x_max; - - /*! - * \brief The height of state area draw. - */ - Element_pos _state_y_max; - - /*! - * \brief The x base of state area draw. - */ - Element_pos _state_x_min; - - /*! - * \brief The y base of state area draw. - */ - Element_pos _state_y_min; + /*! + * \brief The trace Glu list. + */ + GLuint _drawing_list; + + /*! + * \brief The last x position of the point (for counter). + */ + Element_pos _counter_last_x; + + /*! + * \brief The last y position of the point (for counter). + */ + Element_pos _counter_last_y; + + /*! + * \brief The opengl render area width in pixels. + */ + Element_pos _screen_width; + + /*! + * \brief The opengl render area height in pixels. + */ + Element_pos _screen_height; + + /*! + * \brief The opengl visibled scene width in the OpenGL units. + */ + Element_pos _render_width; + + /*! + * \brief The opengl visibled scene height in the OpenGL units. + */ + Element_pos _render_height; + + /*! + * \brief The width of container area draw. + */ + Element_pos _container_x_max; + + /*! + * \brief The height of container area draw. + */ + Element_pos _container_y_max; + + /*! + * \brief The x base of container area draw. + */ + Element_pos _container_x_min; + + /*! + * \brief The y base of container area draw. + */ + Element_pos _container_y_min; + + /*! + * \brief The width of state area draw. + */ + Element_pos _state_x_max; + + /*! + * \brief The height of state area draw. + */ + Element_pos _state_y_max; + + /*! + * \brief The x base of state area draw. + */ + Element_pos _state_x_min; + + /*! + * \brief The y base of state area draw. + */ + Element_pos _state_y_min; - /*! - * \brief z position for the ruler. - */ - Element_pos _z_ruler; + /*! + * \brief z position for the ruler. + */ + Element_pos _z_ruler; - /*! - * \brief z position for containers. - */ - Element_pos _z_container; + /*! + * \brief z position for containers. + */ + Element_pos _z_container; - /*! - * z position for states. - */ - Element_pos _z_state; + /*! + * z position for states. + */ + Element_pos _z_state; - /*! - * z position for events. - */ - Element_pos _z_event; + /*! + * z position for events. + */ + Element_pos _z_event; - /*! - * z position for arrows. - */ - Element_pos _z_arrow; + /*! + * z position for arrows. + */ + Element_pos _z_arrow; - /*! - * z position for counters. - */ - Element_pos _z_counter; + /*! + * z position for counters. + */ + Element_pos _z_counter; - /*! - * Default offset of entities drawing. - */ - Element_pos _default_entity_x_translate; + /*! + * Default offset of entities drawing. + */ + Element_pos _default_entity_x_translate; - /*! - * Distance between two ruler measures. - */ - Element_pos _ruler_distance; + /*! + * Distance between two ruler measures. + */ + Element_pos _ruler_distance; - /*! - * Height of the ruler. - */ - Element_pos _ruler_height; + /*! + * Height of the ruler. + */ + Element_pos _ruler_height; - /*! - * Highness of the ruler. - */ - Element_pos _ruler_y; + /*! + * Highness of the ruler. + */ + Element_pos _ruler_y; - /*********************************** - * Trace Drawing functions and attributes. - **********************************/ + /*********************************** + * Trace Drawing functions and attributes. + **********************************/ - /*! - * \brief The percentage taken by container display in the render area. - */ - Element_pos _x_scale_container_state; + /*! + * \brief The percentage taken by container display in the render area. + */ + Element_pos _x_scale_container_state; - /*! - * \brief the scale of state drawing. - */ - Element_pos _state_scale; + /*! + * \brief the scale of state drawing. + */ + Element_pos _state_scale; - /*! - * \brief the y scale of state drawing. - */ - Element_pos _y_state_scale; + /*! + * \brief the y scale of state drawing. + */ + Element_pos _y_state_scale; - /*! - * \brief The x position of camera view for state drawing area. + /*! + * \brief The x position of camera view for state drawing area. */ - Element_pos _state_translate; + Element_pos _state_translate; - /*! - * \brief The y position of camera view for state drawing area. + /*! + * \brief The y position of camera view for state drawing area. */ - Element_pos _y_state_translate; + Element_pos _y_state_translate; /*! - * \brief The x position of the horizontal scroll bar. + * \brief The x position of the horizontal scroll bar. */ - Element_pos _x_scroll_pos; + Element_pos _x_scroll_pos; - /*! - * \brief The y position of the vertical scroll bar. + /*! + * \brief The y position of the vertical scroll bar. */ - Element_pos _y_scroll_pos; + Element_pos _y_scroll_pos; - public: +public: - /*********************************** - * - * Constructor and destructor. - * - **********************************/ + /*********************************** + * + * Constructor and destructor. + * + **********************************/ - /*! + /*! * \brief The default constructor */ - Render_opengl(QWidget *parent); + Render_opengl(QWidget *parent); - /*! + /*! * \brief The destructor */ - virtual ~Render_opengl(); + virtual ~Render_opengl(); - /*********************************** - * - * Pre register translate values. - * - **********************************/ + /*********************************** + * + * Pre register translate values. + * + **********************************/ // /*! -// * \brief To show the x beginning of the trace. -// */ -// static const int X_TRACE_BEGINNING = 0; - -// /*! -// * \brief To show the y beginning of the trace. -// */ -// static const int Y_TRACE_BEGINNING = 1; - -// /*! -// * \brief To show the x ending of the trace. -// */ -// static const int X_TRACE_ENDING = 2; - -// /*! -// * \brief To show the y ending of the trace. -// */ -// static const int Y_TRACE_ENDING = 3; - -// /*! -// * \brief To show the horizontal entire trace. -// */ -// static const int X_TRACE_ENTIRE = 4; - -// /*! -// * \brief To show the vertical entire trace. -// */ -// static const int Y_TRACE_ENTIRE = 5; - -// /*! -// * \brief To show the left screen of the current view. -// */ -// static const int X_SCREEN_LEFT_MOVE = 6; - -// /*! -// * \brief To show the right screen of the current view. -// */ -// static const int X_SCREEN_RIGHT_MOVE = 7; + // * \brief To show the x beginning of the trace. + // */ + // static const int X_TRACE_BEGINNING = 0; + + // /*! + // * \brief To show the y beginning of the trace. + // */ + // static const int Y_TRACE_BEGINNING = 1; + + // /*! + // * \brief To show the x ending of the trace. + // */ + // static const int X_TRACE_ENDING = 2; + + // /*! + // * \brief To show the y ending of the trace. + // */ + // static const int Y_TRACE_ENDING = 3; + + // /*! + // * \brief To show the horizontal entire trace. + // */ + // static const int X_TRACE_ENTIRE = 4; + + // /*! + // * \brief To show the vertical entire trace. + // */ + // static const int Y_TRACE_ENTIRE = 5; + + // /*! + // * \brief To show the left screen of the current view. + // */ + // static const int X_SCREEN_LEFT_MOVE = 6; + + // /*! + // * \brief To show the right screen of the current view. + // */ + // static const int X_SCREEN_RIGHT_MOVE = 7; - /*********************************** - * - * Scaling and scrolling functions. - * - **********************************/ + /*********************************** + * + * Scaling and scrolling functions. + * + **********************************/ - /*! + /*! * \brief Change the scale of state drawing. * \param scale_coeff The new coefficient scale value to add to the current scale. */ - void change_scale(Element_pos scale_coeff); + void change_scale(Element_pos scale_coeff); - /*! + /*! * \brief Change the scale of the y state drawing. * \param scale_coeff The new coefficient scale value to add to the current scale. */ - void change_scale_y(Element_pos scale_coeff); + void change_scale_y(Element_pos scale_coeff); - /*! + /*! * \brief Replace the current scale by a new scale. * \param new_scale The new scale value to replace the current scale. */ - void replace_scale(Element_pos new_scale); + void replace_scale(Element_pos new_scale); - /*! + /*! * \brief Change the x position of camera view for state drawing area. * \param translate The new position. */ - void change_translate(int translate);/* temporary -> to change the translate to view states */ + void change_translate(int translate);/* temporary -> to change the translate to view states */ - /*! + /*! * \brief Change the y position of camera view for state drawing area. * \param translate The new position. */ - void change_translate_y(int translate);/* temporary -> to change the translate to view states */ + void change_translate_y(int translate);/* temporary -> to change the translate to view states */ - /*! + /*! * \brief Replace the current x translate by a new translate. * \param new_translate The new translate value to replace the current translate. */ - void replace_translate(Element_pos new_translate); + void replace_translate(Element_pos new_translate); - /*! + /*! * \brief Replace the current y translate by a new translate. * \param new_translate The new translate value to replace the current translate. */ - void replace_translate_y(Element_pos new_translate); + void replace_translate_y(Element_pos new_translate); - /*! + /*! * \brief Pre registered translation values (for x or y translate). * \param id The pre registered translation id. */ - void registered_translate(int id); + void registered_translate(int id); - /*! + /*! * \brief Change the percentage taken by container display in the render area. * \param view_size The new percentage (between 0 to 100). */ - void change_scale_container_state(int view_size);/* temporary -> to change the size of container view */ + void change_scale_container_state(int view_size);/* temporary -> to change the size of container view */ - /*********************************** - * - * Building functions. - * - **********************************/ + /*********************************** + * + * Building functions. + * + **********************************/ - /*! - * \brief This function draws the trace. - * \arg trace the trace which be displayed. - */ - bool build(); + /*! + * \brief This function draws the trace. + * \arg trace the trace which be displayed. + */ + bool build(); - /*! - * \brief This function releases the trace. - */ - bool unbuild(); + /*! + * \brief This function releases the trace. + */ + bool unbuild(); - /*! - * \brief Proceeds with the initialization of the OpenGL draw functions. - */ - void start_draw(); + /*! + * \brief Proceeds with the initialization of the OpenGL draw functions. + */ + void start_draw(); - /*! - * \brief Creates and opens the display list for container draws. - */ - void start_draw_containers(); + /*! + * \brief Creates and opens the display list for container draws. + */ + void start_draw_containers(); - /*! + /*! * \brief Draw a container according to the parameters * \param x the x position of the container * \param y the y position of the container * \param w the width of the container * \param h the height of the container */ - void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h); - - /*! - * \brief Draw the text of a container. - * \param x the x position of the text. - * \param y the y position of the text. - * \param value the string value of the text. - * - * This function stores text in a list. This list will be display each time the render area need to be updated. - */ - void draw_container_text(const Element_pos x, const Element_pos y, const std::string value); - - /*! - * \brief Closes the container display list. - */ - void end_draw_containers(); + void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h); + + /*! + * \brief Draw the text of a container. + * \param x the x position of the text. + * \param y the y position of the text. + * \param value the string value of the text. + * + * This function stores text in a list. This list will be display each time the render area need to be updated. + */ + void draw_container_text(const Element_pos x, const Element_pos y, const std::string value); + + /*! + * \brief Closes the container display list. + */ + void end_draw_containers(); - /*! - * \brief Creates and opens the display list for stater draws. - */ - void start_draw_states(); - - /*! - * \brief Draw a state of the trace. - * \param start the beginning time of the state. - * \param end the ending time of the state. - * \param base vertical position of the state. - * \param height the state height. - * \param r the red color rate of the state. - * \param g the green color rate of the state. - * \param b the blue color rate of the state. - */ - void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b); - - /*! - * \brief Closes the state display list. - */ - void end_draw_states(); - - /*! - * \brief Open the arrow display list. - */ - void start_draw_arrows(); - - /*! - * \brief Draw an arrow. - * \param start_time the beginning time of the arrow. - * \param end_time the ending time of the arrow. - * \param start_height vertical position of the begining time of the arrow. - * \param end_height vertical position of the ending time of the arrow. - * - * This function stores all the information of the arrow to display it each time the render area need to be updated. - */ - void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height); - - /*! - * \brief Closes the arrow display list. - */ - void end_draw_arrows(); - - /*! - * \brief Draw arrows contained in the Arrow_ vector - * \param arrows An arrow vector. - */ - void draw_stored_arrows(std::vector<Arrow_> &arrows); - - /*! - * \brief Draw an event. - * \param time time when the event occurs. - * \param height vertical position of the event. - * \param container_height information to draw event. It corresponds to the container height when they are drawn horizontally. - * - * This function stores all the information of the event to display it each time the render area need to be updated. - */ - void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height); - - /*! - * \brief Draw events contained in the Event_ vector - * \param events An event vector. - */ - void draw_stored_events(std::vector<Event_> &events); - - /*! - * \brief Creates and opens the display list for counter draws. - */ - void start_draw_counter(); + /*! + * \brief Creates and opens the display list for stater draws. + */ + void start_draw_states(); + + /*! + * \brief Draw a state of the trace. + * \param start the beginning time of the state. + * \param end the ending time of the state. + * \param base vertical position of the state. + * \param height the state height. + * \param r the red color rate of the state. + * \param g the green color rate of the state. + * \param b the blue color rate of the state. + */ + void draw_state(const Element_pos start , const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b); + + /*! + * \brief Closes the state display list. + */ + void end_draw_states(); + + /*! + * \brief Open the arrow display list. + */ + void start_draw_arrows(); + + /*! + * \brief Draw an arrow. + * \param start_time the beginning time of the arrow. + * \param end_time the ending time of the arrow. + * \param start_height vertical position of the begining time of the arrow. + * \param end_height vertical position of the ending time of the arrow. + * + * This function stores all the information of the arrow to display it each time the render area need to be updated. + */ + void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height); + + /*! + * \brief Closes the arrow display list. + */ + void end_draw_arrows(); + + /*! + * \brief Draw arrows contained in the Arrow_ vector + * \param arrows An arrow vector. + */ + void draw_stored_arrows(std::vector<Arrow_> &arrows); + + /*! + * \brief Draw an event. + * \param time time when the event occurs. + * \param height vertical position of the event. + * \param container_height information to draw event. It corresponds to the container height when they are drawn horizontally. + * + * This function stores all the information of the event to display it each time the render area need to be updated. + */ + void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height); + + /*! + * \brief Draw events contained in the Event_ vector + * \param events An event vector. + */ + void draw_stored_events(std::vector<Event_> &events); + + /*! + * \brief Creates and opens the display list for counter draws. + */ + void start_draw_counter(); - /*! - * \brief Draw a point of the counter. - * \param x x position of the point. - * \param y y position of the point. - * - * Each time counter is increased, this function is called with the coordinates of the new point. - */ - void draw_counter(const Element_pos x, const Element_pos y); + /*! + * \brief Draw a point of the counter. + * \param x x position of the point. + * \param y y position of the point. + * + * Each time counter is increased, this function is called with the coordinates of the new point. + */ + void draw_counter(const Element_pos x, const Element_pos y); - /*! - * \brief Closes the counter display list. - */ - void end_draw_counter(); + /*! + * \brief Closes the counter display list. + */ + void end_draw_counter(); - /*! - * \brief Do nothing (it is present for compatibility of the Render class). - */ - void end_draw(); + /*! + * \brief Do nothing (it is present for compatibility of the Render class). + */ + void end_draw(); - /*! - * \brief Create the ruler disaply list. - */ - void create_ruler(); + /*! + * \brief Create the ruler disaply list. + */ + void create_ruler(); - /*! - * \brief Set Statistics and Informations about input trace - */ - void set_total_width(Element_pos w); + /*! + * \brief Set Statistics and Informations about input trace + */ + void set_total_width(Element_pos w); - /*! - * \brief Set Statistics and Informations about input trace - */ - void set_total_time(Times t); + /*! + * \brief Set Statistics and Informations about input trace + */ + void set_total_time(Times t); /*! * \brief display the scale */ - void display_time_scale(); + void display_time_scale(); - }; +}; @@ -805,7 +799,7 @@ inline void Render_opengl::start_draw(){ inline void Render_opengl::start_draw_containers(){ _list_containers = glGenLists(1);/* create the list */ - if (_list_containers==0){ + if (_list_containers == 0) { // _parent->warning("Error when creating list"); } @@ -817,7 +811,7 @@ inline void Render_opengl::start_draw_containers(){ inline void Render_opengl::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) { - float j=0.6; + float j = 0.6; glBegin(GL_QUADS);/* create a quads */ @@ -873,7 +867,7 @@ inline void Render_opengl::end_draw_containers(){ inline void Render_opengl::start_draw_states(){ _list_states = glGenLists(1);/* create the list */ - if (_list_states==0){ + if (_list_states == 0) { // _parent->warning("Error when creating list"); } @@ -882,7 +876,7 @@ inline void Render_opengl::start_draw_states(){ } -inline void Render_opengl::draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b){ +inline void Render_opengl::draw_state(const Element_pos start, const Element_pos end, const Element_pos base, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) { @@ -907,10 +901,10 @@ inline void Render_opengl::draw_state(const Element_pos start, const Element_pos } glEnd(); - if (end>_state_x_max) + if (end > _state_x_max) _state_x_max = end; - if ((base+height)>_state_y_max) + if ((base+height) > _state_y_max) _state_y_max = base+height; if (_state_x_min > start) @@ -958,7 +952,7 @@ inline void Render_opengl::draw_stored_arrows(std::vector<Arrow_> &arrows){ Element_pos angle; - for (long i=0 ; i<(long)arrows.size() ; i++){ + for (long i = 0 ; i < (long)arrows.size() ; i ++){ start_time = arrows[i].start_time*arrow_scale_x + _default_entity_x_translate -_state_translate; @@ -1015,7 +1009,7 @@ inline void Render_opengl::draw_stored_arrows(std::vector<Arrow_> &arrows){ } -inline void Render_opengl::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){ +inline void Render_opengl::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){ Event_ buf; @@ -1041,7 +1035,7 @@ inline void Render_opengl::draw_stored_events(std::vector<Event_> &events){ int step; - for (long i=0 ; i<(long)events.size() ; i++){ + for (long i = 0 ; i < (long)events.size() ; i ++){ time = events[i].time*event_scale_x + _default_entity_x_translate -_state_translate; height = events[i].height*event_scale_y +_y_state_translate; @@ -1068,7 +1062,7 @@ inline void Render_opengl::draw_stored_events(std::vector<Event_> &events){ glColor3d(0.5, 0.8, 0.5); glBegin(GL_POLYGON); { - for(int i =0 ; i<step ; i++){ + for(int i = 0 ; i < step ; i ++){ glVertex3d(time + cos(angle+delta_angle*i)*radius , height + sin(angle+delta_angle*i)*radius , _z_event); } } @@ -1096,7 +1090,7 @@ inline void Render_opengl::draw_stored_events(std::vector<Event_> &events){ inline void Render_opengl::start_draw_counter(){ _list_counters = glGenLists(1);/* create the list */ - if (_list_counters==0){ + if (_list_counters == 0) { std::cerr << "Error when creating list" << std::endl; } @@ -1108,9 +1102,9 @@ inline void Render_opengl::start_draw_counter(){ inline void Render_opengl::draw_counter(const Element_pos x, const Element_pos y){ - if (x <= 0.0 ){ - if (_line_already_begun==true){/* it is not the first call */ - glEnd(); + if (x <= 0.0){ + if (_line_already_begun){/* it is not the first call */ + glEnd(); }else _line_already_begun = true; @@ -1119,7 +1113,8 @@ inline void Render_opengl::draw_counter(const Element_pos x, const Element_pos y _counter_last_x = 0.0; - }else{ + } + else { glColor3d(1.0, 1.0, 1.0);glVertex2d(x, _counter_last_y); glColor3d(1.0, 1.0, 1.0);glVertex2d(x, y); @@ -1133,7 +1128,7 @@ inline void Render_opengl::draw_counter(const Element_pos x, const Element_pos y inline void Render_opengl::end_draw_counter(){ - if ( _line_already_begun == true){/* if a line was previously opened */ + if (_line_already_begun) {/* if a line was previously opened */ glEnd();/* suppose that line is not ended */ } @@ -1149,5 +1144,4 @@ inline void Render_opengl::end_draw(){ } - - #endif +#endif diff --git a/src/render/render_svg.cpp b/src/render/render_svg.cpp index dc198fc418407e428255b13c55e1a5b8d0239c80..630b5c03f6223132b0508b79c35ee993eeb6da39 100644 --- a/src/render/render_svg.cpp +++ b/src/render/render_svg.cpp @@ -1,45 +1,44 @@ #include "render_svg.hpp" #include "../message/Message.hpp" -using namespace std; - +using namespace std; void Svg::init(const char *path){ - _debug_svg_already_closed_once = false; + _debug_svg_already_closed_once = false; - std::cerr<< "interval : ["; - std::cerr<< _start_interval_time << ", "; - if ( _end_interval_time==0) - std::cerr<<"+oo[" << endl; - else - std::cerr<<_end_interval_time << "[" << endl; + cerr<< "interval : ["; + cerr<< _start_interval_time << ", "; + if ( _end_interval_time == 0) + cerr<<"+oo[" << endl; + else + cerr<<_end_interval_time << "[" << endl; - std::cerr<< "wide factor :"; - std::cerr<<_wide_factor << endl; + cerr<< "wide factor :"; + cerr << _wide_factor << endl; - std::cerr<< "height factor : "; - std::cerr<< _height_factor << endl; + cerr << "height factor : "; + cerr << _height_factor << endl; - std::cerr<< "accuracy : "; - std::cerr<< _epsilon << endl; + cerr << "accuracy : "; + cerr << _epsilon << endl; - _container_width_max = 0; + _container_width_max = 0; - _container_height_min = 1280; + _container_height_min = 1280; - _svg_file.open(path , std::ofstream::out | std::ofstream::trunc); + _svg_file.open(path , ofstream::out | ofstream::trunc); - if (_svg_file.is_open()==false){ + if (_svg_file.is_open()==false) { #ifdef TEST_SVG_MODE - std::cerr<<"unable to open file"; + cerr<<"unable to open file"; #else - // message_ns::message << "unable to open file " << message_ns::ende; + // message_ns::message << "unable to open file " << message_ns::ende; #endif } @@ -48,7 +47,7 @@ void Svg::init(const char *path){ #endif #ifdef TEST_SVG_MODE - std::cout<< "openning " << path << endl; + cout<< "openning " << path << endl; #else //message_ns::message << "openning " << message_ns::endi; #endif @@ -93,14 +92,12 @@ void Svg::init(const char *path){ void Svg::end(){ - if (_debug_svg_already_closed_once) - { - std::cerr<<"Svg::end() a deja été appellé"; - return; + if (_debug_svg_already_closed_once) { + cerr<<"Svg::end() already called"; + return; } - else - { - _debug_svg_already_closed_once = true; + else { + _debug_svg_already_closed_once = true; } _svg_file.write(_buffer.str().c_str(), _buffer.str().size()); @@ -116,16 +113,16 @@ void Svg::end(){ _thin_element_buffer << "\n<line id='cursor' x1='550' y1='0' x2='550' y2='100%' style='display:none;stroke:black;stroke-width:0.5'/><script><![CDATA[var cursor = document.getElementById('cursor');cursor.style.display='';document.onmousemove = function (event){cursor.setAttribute('x1',event.clientX);cursor.setAttribute('x2',event.clientX);}]]> </script></g></svg>"; - _svg_file.write(_thin_element_buffer.str().c_str(), _thin_element_buffer.str().size()); + _svg_file.write(_thin_element_buffer.str().c_str(), _thin_element_buffer.str().size()); _thin_element_buffer.flush(); _thin_element_buffer.str(""); _svg_file.close(); - std::cout<< "output written" << endl; + cout<< "output written" << endl; #ifdef TEST_SVG_MODE - std::cout<< "output written" << endl; + cout<< "output written" << endl; #else //message_ns::message << "output written" << message_ns::endi; #endif @@ -135,8 +132,7 @@ void Svg::end(){ } - void Svg::display_time_scale() - { +void Svg::display_time_scale() { _total_width = _total_time; Element_pos w = _total_width*_wide_factor; @@ -150,33 +146,31 @@ void Svg::end(){ _time_scale << "\n<rect class='scale' title='scale'" - <<" width='" << w - <<"' height='"<< h - <<"' x='" << x - <<"' y='" << y - <<"' fill='rgb("<<r<<","<<g<<","<<b - <<")' stroke='black'" + << " width='" << w + << "' height='" << h + << "' x='" << x + << "' y='" << y + << "' fill='rgb(" << r << "," << g << "," << b + << ")' stroke='black'" << " stroke-width='0.1'" << " />"; if (_end_interval_time) - _total_width = _total_time = min(_end_interval_time,_total_time); + _total_width = _total_time = min(_end_interval_time, _total_time); Element_pos inc; - inc = (_scale_frequency) / (_wide_factor); + inc = _scale_frequency / _wide_factor; - for(Element_pos i=_start_interval_time;i<_total_time;i+=inc){ - - - - x = (i)*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor; + for(Element_pos i = _start_interval_time ; i < _total_time ; i+=inc) { + + x = i*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor; - _time_scale << "<text x='" << x <<"' y='" << y + h << "'>|"; - _time_scale << i; - _time_scale << "</text>"; + _time_scale << "<text x='" << x <<"' y='" << y + h << "'>|"; + _time_scale << i; + _time_scale << "</text>"; } @@ -188,38 +182,33 @@ void Svg::end(){ } - void Svg::set_height_factor (Element_pos w){ -_height_factor = w; +void Svg::set_height_factor (Element_pos w) { + _height_factor = w; } - void Svg::set_wide_factor (Element_pos w){ - _wide_factor = w; +void Svg::set_wide_factor (Element_pos w) { + _wide_factor = w; } - void Svg::set_interval(Times t1,Times t2){ -_start_interval_time = t1; -_end_interval_time = t2; +void Svg::set_interval(Times t1, Times t2) { + _start_interval_time = t1; + _end_interval_time = t2; } - void Svg::set_accuracy(double epsilon){ - _epsilon = epsilon; +void Svg::set_accuracy(double epsilon) { + _epsilon = epsilon; } -void Svg::set_scale_frequency(Element_pos w){ - _scale_frequency = w; +void Svg::set_scale_frequency(Element_pos w) { + _scale_frequency = w; } - - -void Svg::set_total_width(Element_pos){ +void Svg::set_total_width(Element_pos) { } -void Svg::set_total_time(Times){ +void Svg::set_total_time(Times) { } - - - -Svg::~Svg(){ +Svg::~Svg() { } diff --git a/src/render/render_svg.hpp b/src/render/render_svg.hpp index 1cd85963e94f25439fbcfb1c83385a00ad493ad9..7c8d6c769db097bd90ba66407dad479ede95a4f6 100644 --- a/src/render/render_svg.hpp +++ b/src/render/render_svg.hpp @@ -53,38 +53,38 @@ #include "resource.hpp" -#define max(a,b) (a>b?a:b); -#define min(a,b) (a>b?b:a); +#define max(a,b) ((a)>(b)?(a):(b)); +#define min(a,b) ((a)>(b)?(b):(a)); /*! * \brief Trace can be exported on a selected period of time, beginning with _start_interval_time, default 0 and command line changed with -t _start_interval_time _end_interval_time or the static svg::set_interval(Times t1,Times t2) */ - static Times _start_interval_time; +static Times _start_interval_time; /*! * \brief Trace can be exported on a selected period of time, endding with _end_interval_time, default 0 (no upper selection) and command line changed with -t _start_interval_time _end_interval_time or the static svg::set_interval(Times t1,Times t2) */ - static Times _end_interval_time; +static Times _end_interval_time; /*! * \brief Svg display is widden by _wide_factor (in pixel/second), default 100, and command line changed with -w _wide_factor */ - static Element_pos _wide_factor; +static Element_pos _wide_factor; /* *\brief Svg display is grown by _height_factor (in pixel/second), default 20, and command line changed with -w _wide_factor -It corresponds to the height of a containers in pixel - */ + It corresponds to the height of a containers in pixel +*/ - static Element_pos _height_factor; +static Element_pos _height_factor; /*! * \brief accuracy required : an element less wide than _epsilon will not be printed */ - static double _epsilon; +static double _epsilon; /*! @@ -103,85 +103,86 @@ class Svg : public Render{ private: - /*! - * \brief buffer containing the main objets to be displayed - */ + /*! + * \brief buffer containing the main objets to be displayed + */ std::ostringstream _buffer; -/*! - * \brief buffer containning the smallest objet which must be display over main objet to be visible - */ + /*! + * \brief buffer containning the smallest objet which must be display over main objet to be visible + */ std::ostringstream _thin_element_buffer; -/*! - * \brief buffer containning each counters values - */ + /*! + * \brief buffer containning each counters values + */ std::ostringstream _chronogramme; -/*! - * \brief buffer containning the scale - */ + /*! + * \brief buffer containning the scale + */ std::ostringstream _time_scale; -/*! - * \brief State of the chronogramme drawer automaton - * the automaton can be INIT, WAIT_FOR_POINT and WAIT_NEW_CHRONO - */ + /*! + * \brief State of the chronogramme drawer automaton + * the automaton can be INIT, WAIT_FOR_POINT and WAIT_NEW_CHRONO + */ int _chronogramme_state; -/*! - * \brief output svg file - */ + /*! + * \brief output svg file + */ std::ofstream _svg_file; -/*! - * \brief width container sum which is the abscisse of the beginnig of the events display - */ + /*! + * \brief width container sum which is the abscisse of the beginnig of the events display + */ Element_pos _container_width_max; -/*! - * \brief minimum container height which is the height of any event - */ + /*! + * \brief minimum container height which is the height of any event + */ Element_pos _container_height_min; -/*! - * \brief Statistics and Informations about input trace computed in live - */ + /*! + * \brief Statistics and Informations about input trace computed in live + */ Element_pos _total_width; -/*! - * \brief Statistics and Informations about input trace computed in live - */ + /*! + * \brief Statistics and Informations about input trace computed in live + */ Times _total_time; -/*! - * \brief Statistics and Informations about input trace computed in live - */ - bool _debug_svg_already_closed_once; + /*! + * \brief Statistics and Informations about input trace computed in live + */ + bool _debug_svg_already_closed_once; -/*! - * \brief flush the buffer containing svg element on the file - */ + /*! + * \brief flush the buffer containing svg element on the file + */ inline void print(); -/*! - * \brief add a rectangle to the buffer of drawing - */ - inline void rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1,Element_pos y1, unsigned int r, unsigned int g, unsigned int b ); + /*! + * \brief add a rectangle to the buffer of drawing + */ + inline void rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1,Element_pos y1, unsigned int r, unsigned int g, unsigned int b); -/*! - * \brief add a line to the buffer of drawing - */ + /*! + * \brief add a line to the buffer of drawing + */ inline void line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2); -/*! - * \brief add a triangle shape to the buffer of drawing - */ + /*! + * \brief add a triangle shape to the buffer of drawing + */ inline void triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3); + public: @@ -190,39 +191,39 @@ public: /*! * \brief Trace can be exported on a selected period of time, starting with _start_interval_time and endding with _end_interval_time, default 0 (no upper selection) and command line changed with -t _start_interval_time _end_interval_time or the static svg::set_interval(Times t1,Times t2) */ - static void set_interval(Times t1,Times t2); + static void set_interval(Times t1, Times t2); /*! - * \brief Set the precision of SVG display. - * \param epsilon Precision - */ + * \brief Set the precision of SVG display. + * \param epsilon Precision + */ static void set_accuracy(double epsilon); /*! * \brief Svg display is widden by _wide_factor (in pixel/second), default 100, and command line changed with -w _wide_factor - */ + */ static void set_wide_factor (Element_pos w); /*! * \brief Svg display is grown by _height - */ + */ static void set_height_factor (Element_pos w); /*! * \brief the scale can be more accurate by increasing the _scale_frequency - */ + */ static void set_scale_frequency(Element_pos w); - /*Statistics : not yet implemented*/ + /*Statistics : not yet implemented*/ /*! * \brief The width of the trace - */ - void set_total_width(Element_pos); + */ + void set_total_width(Element_pos); /*! * \brief The time span of the trace - */ - void set_total_time(Times); + */ + void set_total_time(Times); @@ -257,7 +258,7 @@ public: * \param w the width of the container * \param h the height of the container */ - void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) ; + void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h); /*! * \brief Draw associated container name @@ -283,7 +284,7 @@ public: * \param level refer to the container which state belongs to. * \param height Unused parameter yet. */ - void draw_state(const Element_pos start , const Element_pos end, const Element_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) ; + void draw_state(const Element_pos start , const Element_pos end, const Element_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b); /*! * \brief unused @@ -291,9 +292,9 @@ public: void start_draw_arrows(); /*! - * \brief Draw an arrow - * - */ + * \brief Draw an arrow + * + */ void draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height); /*! @@ -332,7 +333,7 @@ public: /*! * \brief display the scale */ - void display_time_scale(); + void display_time_scale(); /*! @@ -341,7 +342,7 @@ public: void end_draw(); - ~Svg(); + ~Svg(); }; @@ -365,16 +366,16 @@ inline void Svg::start_draw(){ inline void Svg::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){ - Element_pos xprime,yprime; + Element_pos xprime,yprime; - /*positions are translated to MARGINTOP : the upper region reserved for scale*/ - /*heights are grown by _height_factor : conversion from time in ms to pixel*/ - yprime = _height_factor*y + MARGINTOP; - xprime = _height_factor*x; + /*positions are translated to MARGINTOP : the upper region reserved for scale*/ + /*heights are grown by _height_factor : conversion from time in ms to pixel*/ + yprime = _height_factor*y + MARGINTOP; + xprime = _height_factor*x; - _thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> "; - _thin_element_buffer << value; - _thin_element_buffer << "</text>"; + _thin_element_buffer << "<text x='" << xprime <<"' y='" << yprime << "'> "; + _thin_element_buffer << value; + _thin_element_buffer << "</text>"; } @@ -397,74 +398,64 @@ inline void Svg::end_draw_states(){ *******************/ inline void Svg::start_draw_counter(){ - _chronogramme_state=INIT; + _chronogramme_state = INIT; } inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ - /*computed position according to adjusted parameters*/ - /*widths are widen by _wide_factor : conversion from time in ms to pixel*/ - /*heights are grown by _height_factor : conversion from time in ms to pixel*/ - /*positions are translated to _container_width_max : the left region occupied by containers*/ - /*positions are translated to MARGINTOP : the upper region reserved for scale*/ - /*whenever a time selection is set : positions are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ + /*computed position according to adjusted parameters*/ + /*widths are widen by _wide_factor : conversion from time in ms to pixel*/ + /*heights are grown by _height_factor : conversion from time in ms to pixel*/ + /*positions are translated to _container_width_max : the left region occupied by containers*/ + /*positions are translated to MARGINTOP : the upper region reserved for scale*/ + /*whenever a time selection is set : positions are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ - Element_pos xprime = x*_wide_factor + _container_width_max ; - Element_pos yprime = y* _height_factor + MARGINTOP; - Element_pos switchvalue = _container_width_max; + Element_pos xprime = x*_wide_factor + _container_width_max ; + Element_pos yprime = y* _height_factor + MARGINTOP; + Element_pos switchvalue = _container_width_max; - if (_chronogramme_state==INIT) - { - if (xprime==switchvalue) - { + if (_chronogramme_state == INIT) { + if (xprime == switchvalue) { - _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor << " " << yprime; - _chronogramme_state=WAIT_FOR_POINT; - } - else - std::cerr<<"draw_counter not initialised"; + _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor << " " << yprime; + _chronogramme_state=WAIT_FOR_POINT; + } + else + std::cerr<<"draw_counter not initialised"; } - else if (_chronogramme_state==WAIT_FOR_POINT) - - { - - if (xprime==switchvalue) - { + else if (_chronogramme_state == WAIT_FOR_POINT) { + if (xprime == switchvalue) { - _chronogramme << "'/>"; - _svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size()); - _chronogramme.str(""); - _chronogramme_state=WAIT_NEW_CHRONO; - } - else - { - if (_end_interval_time) - if (x>_end_interval_time) - return; + _chronogramme << "'/>"; + _svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size()); + _chronogramme.str(""); + _chronogramme_state=WAIT_NEW_CHRONO; + } + else { + if (_end_interval_time && x > _end_interval_time) + return; - if (x<_start_interval_time) - return; + if (x<_start_interval_time) + return; - _total_time = max( _total_time,x); + _total_time = max(_total_time, x); - _chronogramme << " L" << xprime << " " << yprime; - } + _chronogramme << " L" << xprime << " " << yprime; + } } - else if (_chronogramme_state==WAIT_NEW_CHRONO) - { - if (xprime==switchvalue) - { - _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor<< " " << yprime; - _chronogramme_state=WAIT_FOR_POINT; - } - else - std::cerr<<"draw_counter not initialised"; + else if (_chronogramme_state==WAIT_NEW_CHRONO) { + if (xprime==switchvalue) { + _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor<< " " << yprime; + _chronogramme_state=WAIT_FOR_POINT; + } + else + std::cerr<<"draw_counter not initialised"; } @@ -472,9 +463,9 @@ inline void Svg::draw_counter(const Element_pos x, const Element_pos y){ } -inline void Svg::end_draw_counter(){ - if (_chronogramme_state!=WAIT_NEW_CHRONO && _chronogramme_state!=INIT) - std::cerr<<"draw_counter not un-initialised"; +inline void Svg::end_draw_counter() { + if (_chronogramme_state!=WAIT_NEW_CHRONO && _chronogramme_state!=INIT) + std::cerr<<"draw_counter not un-initialised"; } @@ -482,8 +473,8 @@ inline void Svg::end_draw(){ } -void Svg::rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1,Element_pos y1, unsigned int r, unsigned int g, unsigned int b ){ - _buffer << "\n<rect class='"<<name<<"' title='"<<name<<"' width='" << w +void Svg::rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1,Element_pos y1, unsigned int r, unsigned int g, unsigned int b) { + _buffer << "\n<rect class='"<<name<<"' title='"<<name<<"' width='" << w <<"' height='"<< h <<"' x='" << x1 <<"' y='" << y1 @@ -496,113 +487,105 @@ void Svg::rectangle(const char* name,Element_pos w, Element_pos h,Element_pos x1 -void Svg::triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3){ - _thin_element_buffer << "\n<polyline title='"<<name<<"' class='triangle' points='" - << x1 << "," << y1 - << " " << x2 << "," << y2 - << " " << x3 << "," << y3 - <<"' />"; +void Svg::triangle(const char* name,Element_pos x1,Element_pos y1,Element_pos x2,Element_pos y2, Element_pos x3,Element_pos y3) { + _thin_element_buffer << "\n<polyline title='"<<name<<"' class='triangle' points='" + << x1 << "," << y1 + << " " << x2 << "," << y2 + << " " << x3 << "," << y3 + <<"' />"; } -void Svg::print(){ - - _svg_file.write(_buffer.str().c_str(), _buffer.str().size()); - _buffer.str(""); +void Svg::print() { + _svg_file.write(_buffer.str().c_str(), _buffer.str().size()); + _buffer.str(""); } -inline void Svg::line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2){ - _thin_element_buffer << "\n<line title='"<<name<<"' x1='" << x1 - <<"' y1='" << y1 - <<"' x2='" << x2 - <<"' y2='" << y2 - <<"' />"; +inline void Svg::line(const char* name, Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2) { + _thin_element_buffer << "\n<line title='"<<name<<"' x1='" << x1 + <<"' y1='" << y1 + <<"' x2='" << x2 + <<"' y2='" << y2 + <<"' />"; print(); } inline void Svg::start_draw_arrows(){ } -inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){ +inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height) { - /*selection*/ + /*selection*/ /*may be outofrange*/ - if (_end_interval_time) - if (start_time>_end_interval_time) - return; - if (end_time<_start_interval_time) - return; - - /*arrow line equation y = a*x+b */ - Element_pos a = ( 1.0*(end_height - start_height) )/(end_time - start_time); - Element_pos b = start_height - a*(start_time); - - - /*parameter to be adjusted to the time selection*/ - Element_pos start_timeprime; - Element_pos end_timeprime; - Element_pos start_heightprime; - Element_pos end_heightprime; - - bool trunc = false; - - /*begining : left adjustement*/ - if (start_time<_start_interval_time) - { - start_timeprime = _start_interval_time ; - start_heightprime = a*start_timeprime+b; + if ((_end_interval_time && start_time>_end_interval_time) || (end_time < _start_interval_time)) + return; + + /*arrow line equation y = a*x+b */ + Element_pos a = (1.0*(end_height - start_height))/(end_time - start_time); + Element_pos b = start_height - a*(start_time); + + + /*parameter to be adjusted to the time selection*/ + Element_pos start_timeprime; + Element_pos end_timeprime; + Element_pos start_heightprime; + Element_pos end_heightprime; + + bool trunc = false; + + /*begining : left adjustement*/ + if (start_time<_start_interval_time) { + start_timeprime = _start_interval_time ; + start_heightprime = a*start_timeprime+b; } - else - { - start_timeprime = start_time ; - start_heightprime = start_height; + else { + start_timeprime = start_time ; + start_heightprime = start_height; } - /*endding as specified parameter*/ - end_timeprime = end_time ; - end_heightprime = end_height; + /*endding as specified parameter*/ + end_timeprime = end_time ; + end_heightprime = end_height; - /*except if an _end_interval_time is set */ - if (_end_interval_time) - { - if (end_time>_end_interval_time) - { - /*adjustement on the right and no spike !*/ - trunc = true; - end_timeprime = _end_interval_time; - end_heightprime = a*end_timeprime+b; - } + /*except if an _end_interval_time is set */ + if (_end_interval_time) { + if (end_time>_end_interval_time) { + /*adjustement on the right and no spike !*/ + trunc = true; + end_timeprime = _end_interval_time; + end_heightprime = a*end_timeprime+b; + } } - /*update of the time*/ - _total_time = max( _total_time,end_timeprime); + /*update of the time*/ + _total_time = max(_total_time, end_timeprime); - /*computed position according to adjusted parameters*/ - /*width are widen by _wide_factor : conversion from time in ms to pixel*/ - /*heights are grown by _height_factor : conversion from time in ms to pixel*/ - /*positions are translated to _container_width_max : the left region occupied by containers*/ - /*positions are translated to MARGINTOP : the upper region reserved for scale*/ - /*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ + /*computed position according to adjusted parameters*/ + /*width are widen by _wide_factor : conversion from time in ms to pixel*/ + /*heights are grown by _height_factor : conversion from time in ms to pixel*/ + /*positions are translated to _container_width_max : the left region occupied by containers*/ + /*positions are translated to MARGINTOP : the upper region reserved for scale*/ + /*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ - Element_pos x1=(start_timeprime )*_wide_factor + _container_width_max -_start_interval_time*_wide_factor ; - Element_pos y1=start_heightprime* _height_factor + MARGINTOP; - Element_pos x2=(end_timeprime)*_wide_factor+ _container_width_max -_start_interval_time*_wide_factor; - Element_pos y2=end_heightprime* _height_factor + MARGINTOP; + Element_pos x1=start_timeprime*_wide_factor + _container_width_max -_start_interval_time*_wide_factor ; + Element_pos y1=start_heightprime* _height_factor + MARGINTOP; + Element_pos x2=end_timeprime*_wide_factor+ _container_width_max -_start_interval_time*_wide_factor; + Element_pos y2=end_heightprime* _height_factor + MARGINTOP; - /*an arrow :*/ - Svg::line("arrow",x1 ,y1 ,x2,y2); + /*an arrow :*/ + Svg::line("arrow",x1 ,y1 ,x2,y2); - if (!trunc) - Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2); + if (!trunc) + Svg::triangle("arrow",x2 ,y2+ARROWSIZE,x2 ,y2-ARROWSIZE,x2+ARROWSIZE,y2); } @@ -611,127 +594,113 @@ inline void Svg::draw_arrow(const Element_pos start_time, const Element_pos end_ inline void Svg::end_draw_arrows(){ } -inline void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){ +inline void Svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h) { - Element_pos xprime,yprime,wprime,hprime; + Element_pos xprime,yprime,wprime,hprime; - if (h<=0 || w<=0 || x<0 || y<0){ - std::cerr<<"draw_container : specified argument isn't positive double"<<std::endl; - return; - } - - /*parameters are grown : conversion from time in ms to pixel*/ - /*positions are translated to MARGINTOP : the upper region reserved for scale*/ - wprime = _height_factor*w; - hprime = _height_factor*h; - yprime = _height_factor*y + MARGINTOP; - xprime = _height_factor*x; + if (h<=0 || w<=0 || x<0 || y<0){ + std::cerr<<"draw_container : specified argument isn't positive double"<<std::endl; + return; + } + + /*parameters are grown : conversion from time in ms to pixel*/ + /*positions are translated to MARGINTOP : the upper region reserved for scale*/ + wprime = _height_factor*w; + hprime = _height_factor*h; + yprime = _height_factor*y + MARGINTOP; + xprime = _height_factor*x; - Svg::rectangle("container",wprime, hprime, xprime, yprime, 0xbb, 0xbb, 0xbb); - + Svg::rectangle("container",wprime, hprime, xprime, yprime, 0xbb, 0xbb, 0xbb); - _container_width_max = max(wprime+xprime+ MARGIN,_container_width_max); - _container_height_min = min(hprime,_container_height_min); + _container_width_max = max(wprime+xprime+ MARGIN,_container_width_max); + _container_height_min = min(hprime,_container_height_min); } -inline void Svg::draw_state(const Element_pos start , const Element_pos end, const Element_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b){ - - +inline void Svg::draw_state(const Element_pos start , const Element_pos end, const Element_pos level, const Element_pos height, const Element_col r, const Element_col g, const Element_col b) { + Element_pos w; + Element_pos h; + Element_pos x; + Element_pos y; - Element_pos w; - Element_pos h; - Element_pos x; - Element_pos y; - - Element_pos startprime; - Element_pos endprime; + Element_pos startprime; + Element_pos endprime; - if (start<=0 || end <=0 || height<0 || level<0){ - std::cerr<<"draw_state : specified argument isn't positive double"<<std::endl; - return; - } + if (start<=0 || end <=0 || height<0 || level<0){ + std::cerr<<"draw_state : specified argument isn't positive double"<<std::endl; + return; + } - /*selection*/ + /*selection*/ /*an outofrange state will not be displayed*/ - if (_end_interval_time) - if (start>_end_interval_time) - return; - - if (end<_start_interval_time) - return; + if ((_end_interval_time && start>_end_interval_time) || end<_start_interval_time) + return; - /*a state may be shortenend on its left*/ - if (start<_start_interval_time) - startprime = _start_interval_time ; - else - startprime = start ; - - /*or on its end*/ - endprime = end; - if (_end_interval_time) - { - if (end>_end_interval_time) - endprime = _end_interval_time; + /*a state may be shortenend on its left*/ + if (start < _start_interval_time) + startprime = _start_interval_time; + else + startprime = start ; + + /*or on its end*/ + endprime = end; + if (_end_interval_time && end>_end_interval_time) { + endprime = _end_interval_time; } + - - _total_time = max( _total_time,endprime); + _total_time = max( _total_time,endprime); - /*adjusted parameter to positions*/ - /*states are widen by _wide_factor : conversion from time in ms to pixel*/ - /*states are grown by _height_factor : conversion from time in ms to pixel*/ - /*states are translated to _container_width_max : the left region occupied by containers*/ - /*states are translated to MARGINSTATE : the margin between two container*/ - /*states are translated to MARGINTOP : the upper region reserved for scale*/ - /*states height is not the specified parameter : container_height_min replaces height which enable the state to have an uniform size */ - /*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ + /*adjusted parameter to positions*/ + /*states are widen by _wide_factor : conversion from time in ms to pixel*/ + /*states are grown by _height_factor : conversion from time in ms to pixel*/ + /*states are translated to _container_width_max : the left region occupied by containers*/ + /*states are translated to MARGINSTATE : the margin between two container*/ + /*states are translated to MARGINTOP : the upper region reserved for scale*/ + /*states height is not the specified parameter : container_height_min replaces height which enable the state to have an uniform size */ + /*whenever a time selection is set : states are translated to -_start_interval_time (in ms, ie -_start_interval_time*_wide_factor pixel)*/ - w = endprime*_wide_factor-startprime*_wide_factor; - h = _container_height_min; - x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor; - y = level* _height_factor + MARGINTOP; + w = endprime*_wide_factor-startprime*_wide_factor; + h = _container_height_min; + x = (startprime )*_wide_factor + _container_width_max + MARGINSTATE -_start_interval_time*_wide_factor; + y = level* _height_factor + MARGINTOP; - if(w<_epsilon){ - return; - } + if(w < _epsilon){ + return; + } - Svg::rectangle("state",w,h, x,y,r*255 , g*255, b*255); + Svg::rectangle("state",w,h, x,y,r*255 , g*255, b*255); } - /*! - * \brief not yet implemented - */ -inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){ +/*! + * \brief not yet implemented + */ +inline void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height) { - if (time<=0 || height <=0 || container_height <=0){ - std::cerr<<"draw_event : specified argument isn't positive double"<<std::endl; - return; - } + if (time<=0 || height <=0 || container_height <=0){ + std::cerr<<"draw_event : specified argument isn't positive double"<<std::endl; + return; + } - std::cerr<<"draw_event : is called not yet implemented"<<std::endl; + std::cerr<<"draw_event : is called not yet implemented"<<std::endl; - /*an outofrange event will not be displayed*/ - if (_end_interval_time) - if (time>_end_interval_time) - return; + /*an outofrange event will not be displayed*/ + if ((_end_interval_time && time > _end_interval_time) || time < _start_interval_time) + return; - if (time<_start_interval_time) - return; - - _total_time = max( _total_time,time); + _total_time = max(_total_time, time); - Svg::rectangle("event",MARGIN,_container_height_min, time + _container_width_max -_start_interval_time*_wide_factor, height + MARGINTOP, 0x17, 0x60, 0xe7); + Svg::rectangle("event",MARGIN,_container_height_min, time + _container_width_max -_start_interval_time*_wide_factor, height + MARGINTOP, 0x17, 0x60, 0xe7); } diff --git a/src/trace/values/Color.cpp b/src/trace/values/Color.cpp index 1edd4d099d13f90bcf6b94acaf883ddc843f20bb..37cb5213c40a532e60fb6265c2bd7936d48074b8 100644 --- a/src/trace/values/Color.cpp +++ b/src/trace/values/Color.cpp @@ -27,9 +27,9 @@ bool Color::instantiate(const std::string &in, Color &out) { temp = temp.substr(position_of_space+1); } - r = convert_to_double(separated_color[0].c_str()); - g = convert_to_double(separated_color[1].c_str()); - b = convert_to_double(separated_color[2].c_str()); + r = convert_to_double(separated_color[0]); + g = convert_to_double(separated_color[1]); + b = convert_to_double(separated_color[2]); if((r == -1.) || (g == -1.) || (b == -1.)) { return false; diff --git a/src/trace/values/Date.cpp b/src/trace/values/Date.cpp index 10061a4dddf6baabee55c33da1a1fed955cb4cd6..fbb8ef42559a130a79d0becf9210a60c1c491209 100644 --- a/src/trace/values/Date.cpp +++ b/src/trace/values/Date.cpp @@ -11,7 +11,7 @@ Date::Date(double value){ bool Date::instantiate(const std::string &in, Date &out){ double value = 0.0; - value = convert_to_double(in.c_str()); + value = convert_to_double(in); if(value != -1.) { out = Date(value); diff --git a/src/trace/values/Double.cpp b/src/trace/values/Double.cpp index 21fade9335ba6e89251ee9e049244489a122a4e8..9124ff0fe5ab39de87e717f925f95dc4a9fac5a4 100644 --- a/src/trace/values/Double.cpp +++ b/src/trace/values/Double.cpp @@ -12,7 +12,7 @@ Double::Double(double value){ bool Double::instantiate(const std::string &in, Double &out){ double value = 0.0; - value = convert_to_double(in.c_str()); + value = convert_to_double(in); if(value != -1.) { out = Double(value);