diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ce96f1b6c291aec294298e6c1c62b97464c1434..fc2bc506e0460047dee6e05325177b65b52ab210 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -80,12 +80,11 @@ SET(VITE_HDRS trace/DrawTree.hpp trace/Trace.hpp # Render headers - render/render.hpp + render/Render.hpp render/Geometry.hpp render/Hook_event.hpp - render/Render_opengl_dl.hpp render/Render_opengl.hpp - render/render_svg.hpp + render/Render_svg.hpp render/render_stats.hpp render/render_stats_opengl.hpp render/render_stats_svg.hpp @@ -161,8 +160,9 @@ SET(VITE_SRCS # Render code files render/Geometry.cpp render/Hook_event.cpp + render/Render.hpp render/Render_opengl.cpp - render/render_svg.cpp + render/Render_svg.cpp render/render_stats_opengl.cpp render/render_stats_svg.cpp #render/vbo.cpp diff --git a/src/common/info.cpp b/src/common/info.cpp index c11616cae4670483e8a9a16c882c88f0db2e9c70..4d97df7ff3d261c8dba2592035c69bfe4e9b50f5 100644 --- a/src/common/info.cpp +++ b/src/common/info.cpp @@ -73,15 +73,21 @@ // const int Info::Core::_STATE_RENDER_DISPLAY_INFORMATION = 21; // const int Info::Core::_STATE_RENDER_UPDATE = 22; -Element_pos Info::Container::x_min = 0; -Element_pos Info::Container::x_max = 0; -Element_pos Info::Container::y_min = 0; -Element_pos Info::Container::y_max = 0; +int Info::Screen::width = 800; +int Info::Screen::height = 600; + +Element_pos Info::Container::x_min = 0; +Element_pos Info::Container::x_max = 0; +Element_pos Info::Container::y_min = 0; +Element_pos Info::Container::y_max = 0; -Element_pos Info::Entity::x_min = 0; -Element_pos Info::Entity::x_max = 0; -Element_pos Info::Entity::y_min = 0; -Element_pos Info::Entity::y_max = 0; +Element_pos Info::Entity::x_min = 0; +Element_pos Info::Entity::x_max = 0; +Element_pos Info::Entity::y_min = 0; +Element_pos Info::Entity::y_max = 0; + +Element_pos Info::Render::width = 100; /* 100 OpenGL units for 1 pixel */ +Element_pos Info::Render::height = 100; /* 100 OpenGL units for 1 pixel */ bool Info::Render::_key_alt = false; bool Info::Render::_key_ctrl = false; @@ -95,5 +101,5 @@ Element_pos Info::Render::_info_accurate = 0.0; bool Info::Render::_no_arrows = false; bool Info::Render::_no_events = false; -QLabel* Info::Render::_ui_render_min_value = NULL; -QLabel* Info::Render::_ui_render_max_value = NULL; +QLabel* Info::Render::_ui_render_min_value = NULL; +QLabel* Info::Render::_ui_render_max_value = NULL; diff --git a/src/common/info.hpp b/src/common/info.hpp index 9cb66281b8866a85fa88c01f1f01acb4b9f9acb2..16259bf2c63658cf2b90b61c0c9cb4393e898f70 100644 --- a/src/common/info.hpp +++ b/src/common/info.hpp @@ -74,142 +74,20 @@ public: /*! - * \brief Sub structure to store core system informations. + * \brief Sub structure to store screen informations. */ - // struct Core{ - -// /*! -// * \brief Function pointer to the launch_action method of core system. -// */ -// static void (Interface_console::* launch_action)(int, void*); - -// /*********************************** -// * -// * The command line parameter processing functions. -// * -// **********************************/ - -// /*! -// *\brief An error state. -// */ -// static const int _STATE_UNKNOWN; - -// /*! -// *\brief A state which corresponds to display a help text. -// */ -// static const int _STATE_DISPLAY_HELP; - -// /*! -// *\brief A state which corresponds to display the trace within a time. -// */ -// static const int _STATE_IN_AN_INTERVAL; // 2^0 - -// /*! -// *\brief A state which corresponds to display a the ViTE window and opening a file. -// */ -// static const int _STATE_OPEN_FILE; // 2^1 - -// /*! -// *\brief A state which corresponds to display the trace within a time. -// */ -// static const int _STATE_OPEN_FILE_IN_AN_INTERVAL; - -// /*! -// *\brief A state which corresponds to an export of file. -// */ -// static const int _STATE_EXPORT_FILE; // 2^2 - -// /*! -// *\brief A state which corresponds to an export of file. -// */ -// static const int _STATE_EXPORT_FILE_IN_INTERVAL; - -// /*! -// *\brief A state which corresponds to release the OpenGL render area (display the wait screen). -// */ -// static const int _STATE_RELEASE_RENDER_AREA; - -// /*! -// *\brief A state which corresponds to change the render area translation. -// */ -// static const int _STATE_RENDER_AREA_CHANGE_TRANSLATE; - -// /*! -// *\brief A state which corresponds to change the render area scale. -// */ -// static const int _STATE_RENDER_AREA_CHANGE_SCALE; - -// /*! -// *\brief A state which corresponds to change the render area container/state scale. -// */ -// static const int _STATE_RENDER_AREA_CHANGE_CONTAINER_SCALE; - -// /*! -// *\brief Informs that a trace has to be parsed and displayed in the main window. -// */ -// static const int _DRAW_OPENGL; - -// /*! -// *\brief Informs that a trace has to be exported in svg format. -// */ -// static const int _DRAW_SVG; - -// /*! -// *\brief A state which corresponds to display the ViTE window. -// */ -// static const int _STATE_LAUNCH_GRAPHICAL_INTERFACE; - -// /*! -// *\brief A state which corresponds to replace the render area scale. -// */ -// static const int _STATE_RENDER_AREA_REPLACE_SCALE; - -// /*! -// *\brief A state which corresponds to replace the render area translate. -// */ -// static const int _STATE_RENDER_AREA_REPLACE_TRANSLATE; - -// /*! -// *\brief A state which corresponds to replace the render area translate. -// */ -// static const int _STATE_RENDER_AREA_REPLACE_TRANSLATE_Y; - -// /*! -// *\brief A state which corresponds to the registered render area translate. -// */ -// static const int _STATE_RENDER_AREA_REGISTERED_TRANSLATE; - -// /*! -// *\brief A state which corresponds to change the render area scale. -// */ -// static const int _STATE_RENDER_AREA_CHANGE_SCALE_Y; - -// /*! -// *\brief A state which corresponds to set new scroll bar length. -// */ -// static const int _STATE_AJUST_SCROLL_BARS; - -// /*! -// *\brief A state which corresponds to a scroll modification of the render area. -// */ -// static const int _STATE_REFRESH_SCROLL_BARS; - -// /*! -// *\brief Allow render area to change the graphical interface zoom box value. -// */ -// static const int _STATE_ZOOM_BOX_VALUE; - -// /*! -// *\brief Display information about a selected entity. -// */ -// static const int _STATE_RENDER_DISPLAY_INFORMATION; - -// /*! -// *\brief Update the render area. -// */ -// static const int _STATE_RENDER_UPDATE; - -// }; + struct Screen{ + + /*! + * \brief The screen width. (in pixel) + */ + static int width; + + /*! + * \brief The screen height. (in pixel) + */ + static int height; + }; /*! @@ -271,6 +149,16 @@ public: */ struct Render{ + /*! + * \brief The render width. (no unit) + */ + static Element_pos width; + + /*! + * \brief The render height. (no unit) + */ + static Element_pos height; + /*! * \brief Contains the state of tke ALT key. * true -> key pushed. diff --git a/src/interface/Interface_graphic.cpp b/src/interface/Interface_graphic.cpp index 3231eba23b7c64ffedaa9d2a0b7cf73fabfcaa1d..a19dc5813b4fc358d447b63d3ec0955280519b0f 100644 --- a/src/interface/Interface_graphic.cpp +++ b/src/interface/Interface_graphic.cpp @@ -62,7 +62,7 @@ #include "trace/Trace.hpp" /* -- */ //#include "render/render.hpp" -#include "render/render_svg.hpp" +//#include "render/render_svg.hpp" /* -- */ #include "statistics/Stats_window.hpp" /* -- */ diff --git a/src/render/Geometry.cpp b/src/render/Geometry.cpp index 531b499fc8731034187cce6ca75d5a6213c05be5..322568702d61bb7933fdc9afe575d05452dc9a9a 100644 --- a/src/render/Geometry.cpp +++ b/src/render/Geometry.cpp @@ -74,20 +74,20 @@ Geometry::Geometry(){ - _render_width = 100; /* 100 OpenGL units for the render scene width */ - _render_height = 100; /* 100 OpenGL units for the render scene height */ + // Info::Render::width = 100; + // Info::Render::height = 100; /* 100 OpenGL units for the render scene height */ _x_scale_container_state = 0.2;/* 20% of screen is used for containers then the other part for states */ _ruler_height = 4.0; /* height of the ruler */ _ruler_y = 0.0; /* highness of the ruler */ - _default_entity_x_translate = 20;/* _render_width * _x_scale_container_state */ + _default_entity_x_translate = 20;/* Info::Render::width * _x_scale_container_state */ - _container_x_max = 0; - _container_y_max = 0; - _container_x_min = 0; - _container_y_min = 0; + /*Info::Container::x_max = 0; + Info::Container::y_max = 0; + Info::Container::x_min = 0; + Info::Container::y_min = 0;*/ _state_y_max = 0; _state_y_min = 0; @@ -118,8 +118,8 @@ Geometry::Geometry(){ _z_state = -5.0; /* Set in the child class */ - _screen_width = 0; - _screen_height = 0; + // Info::Screen::width = 0; + //Info::Screen::height = 0; } @@ -142,33 +142,33 @@ Geometry::~Geometry(){ Element_pos Geometry::screen_to_render_x(Element_pos e){ - return e * (Element_pos)_render_width / (Element_pos)_screen_width; + return e * (Element_pos)Info::Render::width / (Element_pos)Info::Screen::width; } Element_pos Geometry::screen_to_render_y(Element_pos e){ - return e * (Element_pos)_render_height / (Element_pos)_screen_height; + return e * (Element_pos)Info::Render::height / (Element_pos)Info::Screen::height; } Element_pos Geometry::render_to_trace_x(Element_pos e){ return (e - _default_entity_x_translate + _x_state_translate) * - (Info::Entity::x_max - Info::Entity::x_min) / ((_render_width - _default_entity_x_translate) * _x_state_scale); + (Info::Entity::x_max - Info::Entity::x_min) / ((Info::Render::width - _default_entity_x_translate) * _x_state_scale); } Element_pos Geometry::render_to_trace_y(Element_pos e){ return (e-_ruler_y-_ruler_height + _y_state_translate) * - (_container_y_max - _container_y_min) / ((_render_height - _ruler_height) * _y_state_scale); + (Info::Container::y_max - Info::Container::y_min) / ((Info::Render::height - _ruler_height) * _y_state_scale); } Element_pos Geometry::render_to_screen_x(Element_pos e){ - return e * (Element_pos)_screen_width / (Element_pos)_render_width; + return e * (Element_pos)Info::Screen::width / (Element_pos)Info::Render::width; } Element_pos Geometry::render_to_screen_y(Element_pos e){ - return e * (Element_pos)_screen_height / (Element_pos)_render_height; + return e * (Element_pos)Info::Screen::height / (Element_pos)Info::Render::height; } Element_pos Geometry::trace_to_render_x(Element_pos e){ @@ -185,10 +185,10 @@ Element_pos Geometry::trace_to_render_y(Element_pos e){ Element_pos Geometry::coeff_trace_render_x(){ - return ((_render_width-_default_entity_x_translate)*_x_state_scale) / (Info::Entity::x_max - Info::Entity::x_min); + return ((Info::Render::width-_default_entity_x_translate)*_x_state_scale) / (Info::Entity::x_max - Info::Entity::x_min); } Element_pos Geometry::coeff_trace_render_y(){ - return ((_render_height-_ruler_height)*_y_state_scale) / (_container_y_max-_container_y_min); + return ((Info::Render::height-_ruler_height)*_y_state_scale) / (Info::Container::y_max - Info::Container::y_min); } diff --git a/src/render/Geometry.hpp b/src/render/Geometry.hpp index cb11ad22204d689047cb7a01341c73fb63d9534c..fc8e65ea487aced8201aa64017e4f561f5251695 100644 --- a/src/render/Geometry.hpp +++ b/src/render/Geometry.hpp @@ -72,42 +72,42 @@ protected: /*! * \brief The opengl render area width in pixels. */ - Element_pos _screen_width; + // Element_pos _screen_width; /*! * \brief The opengl render area height in pixels. */ - Element_pos _screen_height; + // Element_pos _screen_height; /*! * \brief The opengl visibled scene width in the OpenGL units. */ - Element_pos _render_width; + // Element_pos _render_width; /*! * \brief The opengl visibled scene height in the OpenGL units. */ - Element_pos _render_height; + // Element_pos _render_height; /*! * \brief The width of container area draw. */ - Element_pos _container_x_max; + // Element_pos _container_x_max; /*! * \brief The height of container area draw. */ - Element_pos _container_y_max; + // Element_pos _container_y_max; /*! * \brief The x base of container area draw. */ - Element_pos _container_x_min; + // Element_pos _container_x_min; /*! * \brief The y base of container area draw. */ - Element_pos _container_y_min; + //Element_pos _container_y_min; /*! * \brief The width of state area draw. diff --git a/src/render/Hook_event.cpp b/src/render/Hook_event.cpp index 6de76dd2c57b1f262e6d21087b04788d74ff83ad..574257f585640979782d45c65a70c01afca7d6e8 100644 --- a/src/render/Hook_event.cpp +++ b/src/render/Hook_event.cpp @@ -116,8 +116,8 @@ Hook_event::Hook_event(Render_opengl* render_instance, Core* core, QWidget *pare /* init main informations about OpenGL scene and QGLWidget size */ - _screen_width = width(); /* get the QGLWidget visibled width (in pixel) */ - _screen_height = height(); /* get the QGLWidget visibled height (in pixel) */ + Info::Screen::width = width(); /* get the QGLWidget visibled width (in pixel) */ + Info::Screen::height = height(); /* get the QGLWidget visibled height (in pixel) */ _ruler_distance = 5; @@ -253,8 +253,8 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){ /* * 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 */ + x_click = _mouse_x * (Element_pos)Info::Render::width/(Element_pos)Info::Screen::width;/* x position of the click in the OpenGL scene */ + y_click = _mouse_y * (Element_pos)Info::Render::height/(Element_pos)Info::Screen::height;/* y position of the click in the OpenGL scene */ /* * First, check the y position if user clicks on the ruler or other @@ -264,12 +264,12 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){ /* Work out the y value in Data Structure coordinates */ y_result = y_click-(_ruler_y+_ruler_height) + _y_state_translate; - y_result *= (_container_y_max-_container_y_min)/((_render_height-_ruler_height)*_y_state_scale); + y_result *= (Info::Container::y_max-Info::Container::y_min)/((Info::Render::height-_ruler_height)*_y_state_scale); /* * 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 */ + if (x_click <= (_x_scale_container_state*Info::Render::width) ){/* user had clicked on the container */ return; } else{ @@ -284,14 +284,14 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){ x_result = (x_click - _default_entity_x_translate + _x_state_translate); /* - * To convert from [0;_render_width*_state_scale] to [_state_x_min;_state_x_max] + * To convert from [0;Info::Render::width*_state_scale] to [_state_x_min;_state_x_max] */ - // x_result *= (_state_x_max - _state_x_min)/((_render_width-_default_entity_x_translate)*_x_state_scale); + // x_result *= (_state_x_max - _state_x_min)/((Info::Render::width-_default_entity_x_translate)*_x_state_scale); x_result /= coeff_trace_render_x(); Info::Render::_info_x = x_result; Info::Render::_info_y = y_result; - Info::Render::_info_accurate = 1/coeff_trace_render_x();//(_state_x_max - _state_x_min)/((_render_width-_default_entity_x_translate)*_x_state_scale);//_state_x_max/_render_width; + Info::Render::_info_accurate = 1/coeff_trace_render_x();//(_state_x_max - _state_x_min)/((Info::Render::width-_default_entity_x_translate)*_x_state_scale);//_state_x_max/Info::Render::width; _core->launch_action(_core->_STATE_RENDER_DISPLAY_INFORMATION, NULL); }/* end else of if (x_click...) */ @@ -395,7 +395,7 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po * of the render area. Idem for the right, the top and the bottom. * * Thus, we need to know the difference the scale between the rectangle width and height and the render area width and height. - * Results are given by the scale: _screen_width/(x_max - x_min) for the horizontal dimension. + * Results are given by the scale: Info::Screen::width/(x_max - x_min) for the horizontal dimension. * * Then, our selection rectangle is scaled. Nevertheless, it should not be centered inside the render area. So, we work out * the correct x and y translation to make both the render area middle and the selection rectangle middle fit. @@ -419,16 +419,16 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po * * Work out the new selection middle position after applying the scale. */ - x_scaled_middle_selection = (x_middle_selection + _x_state_translate /*- _default_entity_x_translate*/)*(_screen_width/((x_max - x_min))); - y_scaled_middle_selection = (y_middle_selection + _y_state_translate /*- _ruler_height*/ )*(_screen_height/((y_max - y_min))); + x_scaled_middle_selection = (x_middle_selection + _x_state_translate /*- _default_entity_x_translate*/)*(Info::Screen::width/((x_max - x_min))); + y_scaled_middle_selection = (y_middle_selection + _y_state_translate /*- _ruler_height*/ )*(Info::Screen::height/((y_max - y_min))); /* * 2nd step: * - * Work out the distance between the state origin and the render area middle (_render_width/2). + * Work out the distance between the state origin and the render area middle (Info::Render::width/2). */ - x_distance_between_state_origin_and_render_middle = _x_state_translate /*- _default_entity_x_translate*/ + _render_width/2; - y_distance_between_state_origin_and_render_middle = _y_state_translate /*- _ruler_height*/ + _render_height/2; + x_distance_between_state_origin_and_render_middle = _x_state_translate /*- _default_entity_x_translate*/ + Info::Render::width/2; + y_distance_between_state_origin_and_render_middle = _y_state_translate /*- _ruler_height*/ + Info::Render::height/2; /* * 3rd step: @@ -446,12 +446,12 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po /* NOTE: do not use replace_scale() because the translate will be also modified */ int buf; - _x_state_scale *= _screen_width/(x_max - x_min); + _x_state_scale *= Info::Screen::width/(x_max - x_min); buf = (int)(100*_x_state_scale); _core->launch_action(_core->_STATE_ZOOM_BOX_VALUE, &buf); - _y_state_scale *= _screen_height/(y_max - y_min); + _y_state_scale *= Info::Screen::height/(y_max - y_min); _mouse_pressed = false; _render_instance->updateGL(); @@ -523,18 +523,18 @@ void Hook_event::keyPressEvent(QKeyEvent * event) { * Key 'Page Up' pressed. */ if (true == Info::Render::_key_alt) - change_translate_y(-(int)_render_height); + change_translate_y(-(int)Info::Render::height); else - change_translate((int)_render_width); + change_translate((int)Info::Render::width); break; case Qt::Key_PageDown: /* * Key 'Page Down' pressed. */ if (true == Info::Render::_key_alt) - change_translate_y((int)_render_height); + change_translate_y((int)Info::Render::height); else - change_translate(-(int)_render_width); + change_translate(-(int)Info::Render::width); break; default: @@ -598,7 +598,7 @@ void Hook_event::replace_scale(Element_pos new_scale){ * Finally, translate the result. * */ - _x_state_translate += ( _x_state_translate - _default_entity_x_translate + (Element_pos)_render_width/2.0) * ((new_scale)/(_x_state_scale) - 1); + _x_state_translate += ( _x_state_translate - _default_entity_x_translate + (Element_pos)Info::Render::width/2.0) * ((new_scale)/(_x_state_scale) - 1); _x_state_scale = new_scale; buf = (int)(100*_x_state_scale); @@ -622,7 +622,7 @@ void Hook_event::replace_scale_y(Element_pos new_scale){ * Finally, translate the result. * */ - _y_state_translate += ( _y_state_translate - _ruler_height + (Element_pos)_render_height/2.0) * ((new_scale)/(_y_state_scale) - 1); + _y_state_translate += ( _y_state_translate - _ruler_height + (Element_pos)Info::Render::height/2.0) * ((new_scale)/(_y_state_scale) - 1); _y_state_scale = new_scale; /* TODO add a zoom box value for y zoom */ @@ -682,21 +682,21 @@ void Hook_event::registered_translate(int id){ switch (id){ case Info::Render::X_TRACE_BEGINNING:/* show the beginning entities */ - _x_state_translate = _default_entity_x_translate - (Element_pos)_render_width/2.0; + _x_state_translate = _default_entity_x_translate - (Element_pos)Info::Render::width/2.0; break; case Info::Render::Y_TRACE_BEGINNING:/* show the beginning entities */ - _y_state_translate = (Element_pos)_render_height/2.0 - _ruler_height; + _y_state_translate = (Element_pos)Info::Render::height/2.0 - _ruler_height; break; case Info::Render::X_TRACE_ENDING:/* show the ending entities */ - // _x_state_translate = (_default_entity_x_translate - (Element_pos)_render_width/2.0 + _state_x_max*_x_state_scale - // *((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min))); - _x_state_translate = (_default_entity_x_translate - (Element_pos)_render_width/2.0 + Info::Entity::x_max*coeff_trace_render_x());//_x_state_scale - // *((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min))); + // _x_state_translate = (_default_entity_x_translate - (Element_pos)Info::Render::width/2.0 + _state_x_max*_x_state_scale + // *((Info::Render::width-_default_entity_x_translate)/(_state_x_max-_state_x_min))); + _x_state_translate = (_default_entity_x_translate - (Element_pos)Info::Render::width/2.0 + Info::Entity::x_max*coeff_trace_render_x());//_x_state_scale + // *((Info::Render::width-_default_entity_x_translate)/(_state_x_max-_state_x_min))); 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))); + _y_state_translate = ( -_ruler_height + (Element_pos)Info::Render::height/2.0 - _state_y_max*_y_state_scale + *((Info::Render::height-_ruler_height)/(_state_y_max-_state_y_min))); break; case Info::Render::X_TRACE_ENTIRE:/* show the entire entities */ // replace_translate(0);//_x_state_translate = 0; @@ -738,8 +738,8 @@ void Hook_event::change_scale_container_state(int view_size){ } void Hook_event::update_visible_interval_value(){ - Info::Render::_x_min_visible = max(Info::Entity::x_min, (_x_state_translate - _default_entity_x_translate)/coeff_trace_render_x());//(_x_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)) )); - Info::Render::_x_max_visible = min(Info::Entity::x_max, (_x_state_translate - _default_entity_x_translate + _render_width)/coeff_trace_render_x());///(_x_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)) )); + Info::Render::_x_min_visible = max(Info::Entity::x_min, (_x_state_translate - _default_entity_x_translate)/coeff_trace_render_x());//(_x_state_scale*((Info::Render::width-_default_entity_x_translate)/(_state_x_max-_state_x_min)) )); + Info::Render::_x_max_visible = min(Info::Entity::x_max, (_x_state_translate - _default_entity_x_translate + Info::Render::width)/coeff_trace_render_x());///(_x_state_scale*((Info::Render::width-_default_entity_x_translate)/(_state_x_max-_state_x_min)) )); } @@ -758,34 +758,34 @@ void Hook_event::update_visible_interval_value(){ Element_pos Hook_event::screen_to_render_x(Element_pos e){ - return e * (Element_pos)_render_width / (Element_pos)_screen_width; + return e * (Element_pos)Info::Render::width / (Element_pos)Info::Screen::width; } Element_pos Hook_event::screen_to_render_y(Element_pos e){ - return e * (Element_pos)_render_height / (Element_pos)_screen_height; + return e * (Element_pos)Info::Render::height / (Element_pos)Info::Screen::height; } Element_pos Hook_event::render_to_trace_x(Element_pos e){ return (e - _default_entity_x_translate + _x_state_translate) * - (_state_x_max - _state_x_min) / ((_render_width - _default_entity_x_translate) * _x_state_scale); + (_state_x_max - _state_x_min) / ((Info::Render::width - _default_entity_x_translate) * _x_state_scale); } Element_pos Hook_event::render_to_trace_y(Element_pos e){ return (e-_ruler_y-_ruler_height + _y_state_translate) * - (_container_y_max - _container_y_min) / ((_render_height - _ruler_height) * _y_state_scale); + (Info::Container::y_max - Info::Container::y_min) / ((Info::Render::height - _ruler_height) * _y_state_scale); } Element_pos Hook_event::render_to_screen_x(Element_pos e){ - return e * (Element_pos)_screen_width / (Element_pos)_render_width; + return e * (Element_pos)Info::Screen::width / (Element_pos)Info::Render::width; } Element_pos Hook_event::render_to_screen_y(Element_pos e){ - return e * (Element_pos)_screen_height / (Element_pos)_render_height; + return e * (Element_pos)Info::Screen::height / (Element_pos)Info::Render::height; } Element_pos Hook_event::trace_to_render_x(Element_pos e){ @@ -802,11 +802,11 @@ Element_pos Hook_event::trace_to_render_y(Element_pos e){ Element_pos Hook_event::coeff_trace_render_x(){ - return ((_render_width-_default_entity_x_translate)*_x_state_scale) / (_state_x_max - _state_x_min); + return ((Info::Render::width-_default_entity_x_translate)*_x_state_scale) / (_state_x_max - _state_x_min); } Element_pos Hook_event::coeff_trace_render_y(){ - return ((_render_height-_ruler_height)*_y_state_scale) / (_container_y_max-_container_y_min); + return ((Info::Render::height-_ruler_height)*_y_state_scale) / (Info::Container::y_max-Info::Container::y_min); } */ diff --git a/src/render/Render.hpp b/src/render/Render.hpp index 8b046acc7833e4c5038e6cea6a27e05f08b8652b..4b7bb99a725739c7cb8a291c187b1c80cf5eeb6e 100755 --- a/src/render/Render.hpp +++ b/src/render/Render.hpp @@ -148,10 +148,9 @@ public: } /*! - * \brief Creates and opens the display list for container draws. + * \brief Initialize container draws. */ inline void start_draw_containers(){ - drawing_instance->start_draw_containers(); } /*! @@ -172,25 +171,25 @@ public: _containers.push_back(buf); - if ((x+w)>_container_x_max) - _container_x_max = x+w; - - if ((y+h)>_container_y_max) - _container_y_max = y+h; + if ((x+w)>Info::Container::x_max) + Info::Container::x_max = x+w; - if (_container_x_min > x) - _container_x_min = x; + if ((y+h)>Info::Container::y_max) + Info::Container::y_max = y+h; - if (_container_y_min > y) - _container_y_min = y; + if (Info::Container::x_min > x) + Info::Container::x_min = x; + if (Info::Container::y_min > y) + Info::Container::y_min = y; + #ifdef DEBUG_MODE_RENDER_AREA std::cerr << __FILE__ << " l." << __LINE__ << ":" << std::endl; std::cerr < "Container drawing:" << std::endl; - std::cerr << "x: " << x << " y: " << y << " w: " << w << " h: " << h << " xmax-xmin: " << _container_x_max << " - " << _container_x_min << " ymax-ymin: " << _container_y_max << " - " << _container_y_min << std::endl; + std::cerr << "x: " << x << " y: " << y << " w: " << w << " h: " << h << " xmax-xmin: " << Info::Container::x_max << " - " << Info::Container::x_min << " ymax-ymin: " << Info::Container::y_max << " - " << Info::Container::y_min << std::endl; #endif @@ -207,9 +206,8 @@ public: inline void draw_container_text(const Element_pos x, const Element_pos y, const std::string value){ Container_text_ buf; - // std::cout << y << std::endl; - buf.x = x * (_render_width/_container_x_max)*_x_scale_container_state; - buf.y = y * _y_state_scale*(_render_height-_ruler_height)/_container_y_max; + buf.x = x; + buf.y = y; buf.value = value; _container_texts.push_back(buf); @@ -221,16 +219,24 @@ public: inline void end_draw_containers(){ float j = 0.6; + // std::cout << __FILE__ << " ~~ " << __LINE__ << " " << Info::Container::y_max << " " << Info::Container::y_min << std::endl; + /* Before calling start_draw_container(), Info::Container::y_max should have a correct value */ + drawing_instance->start_draw_containers(); + for (unsigned int i=0 ; i<_containers.size() ; i++){ drawing_instance->set_color(0, 0, j); - drawing_instance->draw_quad(_containers[i].x * (_render_width/_container_x_max)*_x_scale_container_state, - trace_to_render_y(_containers[i].y),// * _y_state_scale*(_render_height-_ruler_height)/_container_y_max) - _y_state_translate + _ruler_y + _ruler_height, + drawing_instance->draw_quad(_containers[i].x * (Info::Render::width/Info::Container::x_max)*_x_scale_container_state, + trace_to_render_y(_containers[i].y),// * _y_state_scale*(_render_height-_ruler_height)/Info::Container::y_max) - _y_state_translate + _ruler_y + _ruler_height, _z_container, - _containers[i].w * (_render_width/_container_x_max)*_x_scale_container_state, - _containers[i].h * _y_state_scale*(_render_height-_ruler_height)/_container_y_max); + _containers[i].w * (Info::Render::width/Info::Container::x_max)*_x_scale_container_state, + _containers[i].h * _y_state_scale*(Info::Render::height-_ruler_height)/Info::Container::y_max); } - + // std::cout << __FILE__ << " ~ " << __LINE__ << " " << Info::Container::y_max << " " << Info::Container::y_min << std::endl; + for (unsigned int i=0 ; i<_container_texts.size() ; i++){ + _container_texts[i].x *= (Info::Render::width/Info::Container::x_max)*_x_scale_container_state; + _container_texts[i].y = trace_to_render_y(_container_texts[i].y);// + _render_height-_ruler_height)*coeff_trace_render_y(); + drawing_instance->draw_text(_container_texts[i].x, _container_texts[i].y, _z_container+1, _container_texts[i].value); } @@ -242,6 +248,7 @@ public: */ inline void start_draw_states(){ drawing_instance->start_draw_states(); + } /*! diff --git a/src/render/Render_opengl.cpp b/src/render/Render_opengl.cpp index b6e9b45391d7529fb1c09eda3c36270cce3b6a93..243384ea4a081455302cad9905c49defa20f6055 100644 --- a/src/render/Render_opengl.cpp +++ b/src/render/Render_opengl.cpp @@ -114,8 +114,8 @@ void Render_opengl::resizeGL(int width, int height) { glViewport(0, 0, width, height); /* update informations about widget size */ - _screen_width = width; - _screen_height = height; + Info::Screen::width = width; + Info::Screen::height = height; glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -125,7 +125,7 @@ void Render_opengl::resizeGL(int width, int height) { if(DRAWING_STATE_WAITING == _state){// A wait is drawn glOrtho(-50, 50, -50, 50, 0, 1000); }else if (DRAWING_STATE_DRAWING == _state){// A trace is drawn - glOrtho(0, _render_width, 0, _render_height, 0, -1000); + glOrtho(0, Info::Render::width, 0, Info::Render::height, 0, -1000); }else{ message << tr("Undefined value for the drawing state attribute - Render area").toStdString() << Message::ende; } @@ -173,7 +173,7 @@ void Render_opengl::paintGL(){ static float a = 0; a ++; - glTranslated(0.0, _render_height, 100.0); + glTranslated(0.0, Info::Render::height, 100.0); glRotated(180.0, 1.0, 0.0, 0.0); @@ -187,7 +187,7 @@ void Render_opengl::paintGL(){ // glTranslated(- _x_state_translate, -_y_state_translate, 0.0); glTranslatef(0.0f, -_y_state_translate, 0.0); - // glScalef( (_render_width/_container_x_max)*_x_scale_container_state, _y_state_scale*(_render_height-_ruler_height)/_container_y_max, 0.0f); + // glScalef( (Info::Render::width/Info::Container::x_max)*_x_scale_container_state, _y_state_scale*(Info::Render::height-_ruler_height)/Info::Container::y_max, 0.0f); glScalef(_x_scale_container_state/0.20, _y_state_scale, 1.0); if (glIsList(_list_containers) == GL_FALSE) @@ -210,18 +210,20 @@ void Render_opengl::paintGL(){ } glPopMatrix(); - draw_stored_arrows(); - draw_stored_circles(); - draw_stored_texts(); + + call_ruler(); + draw_stored_texts(); // display_state(0, 0, 0, 0, 0, 0); -// if (false == Info::Render::_no_arrows)/* display arrows */ + if (false == Info::Render::_no_arrows)/* display arrows */ + draw_stored_arrows(); // display_arrow(0, 0, 0, 0, 0, 0); -// if (false == Info::Render::_no_events)/* display events */ + if (false == Info::Render::_no_events)/* display events */ + draw_stored_circles(); // display_event(0, 0, 0, 0); // display_counter(0, 0, 0, 0); @@ -243,7 +245,7 @@ void Render_opengl::paintGL(){ glPushMatrix(); { - // glTranslated(0.0, _container_y_max- 3*_ruler_height, 100.0);/* not accurate */ + // glTranslated(0.0, Info::Container::y_max- 3*_ruler_height, 100.0);/* not accurate */ glTranslated(0.0, 0.0, 100.0);/* not accurate */ if (_mouse_pressed){ @@ -253,10 +255,10 @@ void Render_opengl::paintGL(){ 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*(Info::Render::width/Info::Screen::width); + old_y = Info::Render::height - _mouse_y*(Info::Render::height/Info::Screen::height); + new_x = _new_mouse_x*(Info::Render::width/Info::Screen::width); + new_y = Info::Render::height - _new_mouse_y*(Info::Render::height/Info::Screen::height); #ifdef DEBUG_MODE_RENDER_OPENGL @@ -370,10 +372,10 @@ bool Render_opengl::unbuild(){ _wait_angle_y=0.0f;/* begin with 0 rad angle */ /* init measurement attributes */ - _container_x_max = 0; - _container_y_max = 0; - _container_x_min = 0; - _container_y_min = 0; + Info::Container::x_max = 0; + Info::Container::y_max = 0; + Info::Container::x_min = 0; + Info::Container::y_min = 0; Info::Render::_ui_render_min_value->setText(""); Info::Render::_ui_render_max_value->setText(""); @@ -511,7 +513,7 @@ GLuint Render_opengl::draw_ruler() { /* * NOTE: * _ruler_distance is the desire distance between 2 graduations. - * There are ceil(_render_width/_ruler_distance) graduations. + * There are ceil(Info::Render::width/_ruler_distance) graduations. * Between 2 consecutive graduations, there are 4 small graduations. */ _ruler_distance = 1.0/nb_graduation; @@ -827,7 +829,7 @@ void Render_opengl::call_ruler(){ }*/ // cout << trace_to_render_x(i/graduation_value_adjustement)<< endl; - //if ( _render_width*_x_scale_container_state <= trace_to_render_x(i/adjustement) ){/* Do not write if graduation is inside container area */ + //if ( Info::Render::width*_x_scale_container_state <= trace_to_render_x(i/adjustement) ){/* Do not write if graduation is inside container area */ for(unsigned int j = 0 ; j < buf_txt.str().length() ; j ++){ glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, buf_txt.str().c_str()[j]); } @@ -985,7 +987,7 @@ void Render_opengl::draw_stored_texts(){ float length = 0; const unsigned int buf_text_size =_texts[i].value.length(); - const int size_of_container = (const int)(20*_x_scale_container_state*_render_width/_container_x_max); + const int size_of_container = (const int)(20*_x_scale_container_state*Info::Render::width/Info::Container::x_max); for(unsigned int j = 0 ; j < buf_text_size ; j ++){ const char letter = _texts[i].value.c_str()[j]; /* length += glutBitmapWidth(GLUT_BITMAP_HELVETICA_10, letter); diff --git a/src/render/Render_svg.cpp b/src/render/Render_svg.cpp index 8cfb70dfa33489e3ead618e35d810ffccfbf8897..ee73730a2b148c7f845c55635aa2f084fbc77826 100755 --- a/src/render/Render_svg.cpp +++ b/src/render/Render_svg.cpp @@ -97,24 +97,30 @@ void Render_svg::set_color(float r, float g, float b){ } void Render_svg::draw_text(const Element_pos x, const Element_pos y, const Element_pos z, const std::string s){ - /* _buffer.str(""); - _buffer << "<text x=\"" << x <<"\"" - << " y=\"" << y << "\">|" + _buffer.str(""); + _buffer << "<text x=\"" << render_to_screen_x(x) <<"\"" + << " y=\"" << render_to_screen_y(y) << "\"" + << " font-size=\"8\"" + << " fill=\"white\">" << s << "</text>\n"; - - _output_file.write(_buffer.str().c_str(), _buffer.str().size()); */ + + _output_file.write(_buffer.str().c_str(), _buffer.str().size()); } void Render_svg::draw_quad(Element_pos x, Element_pos y, Element_pos z, Element_pos w, Element_pos h){ + if (render_to_screen_x(w) < 1)/* less than 1 pixel */ + return; + _buffer.str(""); _buffer << "<rect " - << " x=\"" << x << "\"" - << " y=\"" << y << "\"" - << " width=\"" << w << "\"" - << " height=\"" << h << "\"" + << " x=\"" << render_to_screen_x(x) << "\"" + << " y=\"" << render_to_screen_y(y) << "\"" + << " width=\"" << render_to_screen_x(w) << "\"" + << " height=\"" << render_to_screen_y(h) << "\"" << " fill=\"rgb(" << _red*256 << "," << _green*256 << "," << _blue*256 << ")\""/* TODO: choice better scale than '*256' */ + << " style=\"stroke:white;stroke-width:0.05\"" << " />\n"; _output_file.write(_buffer.str().c_str(), _buffer.str().size()); @@ -124,10 +130,10 @@ void Render_svg::draw_triangle(Element_pos x, Element_pos y, Element_pos size, Element_pos r){ _buffer.str(""); _buffer << "<polygon points=\"" - << x << "," << y << "," - << x-1.2 << "," << y-0.4 << "," - << x-1.2 << "," << y+0.4 << "\"" - << " transform = \"rotate("<< r << " " << x << " " << y << " )\"" + << render_to_screen_x(x) << "," << render_to_screen_y(y) << "," + << render_to_screen_x(x-1.2) << "," << render_to_screen_y(y-0.4) << "," + << render_to_screen_x(x-1.2) << "," << render_to_screen_y(y+0.4) << "\"" + << " transform = \"rotate("<< r << " " << render_to_screen_x(x) << " " << render_to_screen_y(y) << " )\"" << " style=\"fill:yellow\"" << "/>\n"; @@ -137,11 +143,11 @@ void Render_svg::draw_triangle(Element_pos x, Element_pos y, void Render_svg::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2, Element_pos z){ _buffer.str(""); _buffer << "<line " - << " x1=\"" << x1 << "\"" - << " y1=\"" << y1 << "\"" - << " x2=\"" << x2 << "\"" - << " y2=\"" << y2 << "\"" - << " style=\"stroke:yellow;stroke-width:0.05\"" + << " x1=\"" << render_to_screen_x(x1) << "\"" + << " y1=\"" << render_to_screen_y(y1) << "\"" + << " x2=\"" << render_to_screen_x(x2) << "\"" + << " y2=\"" << render_to_screen_y(y2) << "\"" + << " style=\"stroke:yellow\"" << "/>\n"; _output_file.write(_buffer.str().c_str(), _buffer.str().size()); @@ -150,9 +156,9 @@ void Render_svg::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Eleme void Render_svg::draw_circle(Element_pos x, Element_pos y, Element_pos z, Element_pos r){ _buffer.str(""); _buffer << "<circle " - << "cx=\"" << x << "\"" - << "cy=\"" << y << "\"" - << "r=\"" << r << "\"" + << "cx=\"" << render_to_screen_x(x) << "\"" + << "cy=\"" << render_to_screen_x(y) << "\"" + << "r=\"" << max(render_to_screen_x(r), render_to_screen_y(r)) << "\"" << " style=\"fill:yellow\"" << "/>\n"; @@ -161,15 +167,21 @@ void Render_svg::draw_circle(Element_pos x, Element_pos y, Element_pos z, Elemen void Render_svg::start_draw(){ + const unsigned int w = (unsigned int)(Info::Entity::x_max - Info::Entity::x_min); _buffer.str(""); _buffer << "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" - << "<svg xmlns=\"http://www.w3.org/2000/svg\">\n"; + << "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" << Info::Screen::width << "\" height=\"" << Info::Screen::height << "\">\n"; _output_file.write(_buffer.str().c_str(), _buffer.str().size()); } void Render_svg::start_draw_containers(){ + /* _buffer.str(""); + _buffer << "<g transform=\"scale(" << 10 << "," << 800/(Info::Container::y_max-Info::Container::y_min) << "\">\n"; + std::cout << __FILE__ << " !! " << __LINE__ << " " << 600/(Info::Entity::x_max - Info::Entity::x_min) << " " << 800/(Info::Container::y_max-Info::Container::y_min) << std::endl; + + _output_file.write(_buffer.str().c_str(), _buffer.str().size()); */ } void Render_svg::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){ @@ -213,6 +225,7 @@ void Render_svg::end_draw_counter(){ void Render_svg::end_draw(){ _buffer.str(""); + // _buffer << " </g>"; _buffer << "</svg>"; _output_file.write(_buffer.str().c_str(), _buffer.str().size()); diff --git a/src/render/Render_svg.hpp b/src/render/Render_svg.hpp index cd6aef067e0e32d86ea859363cbde2fc01ad1b0d..c4fbf4045321eccec8e1e9b0da01c50826c1171c 100755 --- a/src/render/Render_svg.hpp +++ b/src/render/Render_svg.hpp @@ -48,11 +48,12 @@ #define RENDER_SVG_HPP #include "render/Render_template.hpp" +#include "render/Geometry.hpp" /*! * \brief This class redefined the OpenGL widget - QGLWidget - to display the trace. */ -class Render_svg : /*public QGLWidget,*/ public Render_template +class Render_svg : /*public QGLWidget,*/ public Render_template, public Geometry { protected: diff --git a/src/render/render.hpp b/src/render/render.hpp deleted file mode 100644 index a20185b6c8e8b100b13c3746be4dc53a20a29cf6..0000000000000000000000000000000000000000 --- a/src/render/render.hpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -** This file is part of the ViTE project. -** -** This software is governed by the CeCILL-A license under French law -** and abiding by the rules of distribution of free software. You can -** use, modify and/or redistribute the software under the terms of the -** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following -** URL: "http://www.cecill.info". -** -** As a counterpart to the access to the source code and rights to copy, -** modify and redistribute granted by the license, users are provided -** only with a limited warranty and the software's author, the holder of -** the economic rights, and the successive licensors have only limited -** liability. -** -** In this respect, the user's attention is drawn to the risks associated -** with loading, using, modifying and/or developing or reproducing the -** software by the user in light of its specific status of free software, -** that may mean that it is complicated to manipulate, and that also -** therefore means that it is reserved for developers and experienced -** professionals having in-depth computer knowledge. Users are therefore -** encouraged to load and test the software's suitability as regards -** their requirements in conditions enabling the security of their -** systems and/or data to be ensured and, more generally, to use and -** operate it in the same conditions as regards security. -** -** The fact that you are presently reading this means that you have had -** knowledge of the CeCILL-A license and that you accept its terms. -** -** -** ViTE developers are (for version 0.* to 1.0): -** -** - COULOMB Kevin -** - FAVERGE Mathieu -** - JAZEIX Johnny -** - LAGRASSE Olivier -** - MARCOUEILLE Jule -** - NOISETTE Pascal -** - REDONDY Arthur -** - VUCHENER Clément -** -*/ -/*! - *\file render.hpp - */ - -#ifndef RENDER_HPP -#define RENDER_HPP - - -class Render; - -/*! - * \brief This class provides an interface for render classes like OpenGL or SVG. - */ -class Render -{ - -public: - - /*! - * \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 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 - * \param value the string value of the text. - */ - void draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h, const std::string value); - - /*! - * \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 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 draws are finished. - */ - virtual void end_draw() = 0; -}; - - - -#endif diff --git a/src/render/render_svg.cpp b/src/render/render_svg.cpp deleted file mode 100644 index d89dd9a7519297c67540c34adebc6e9c667ee31b..0000000000000000000000000000000000000000 --- a/src/render/render_svg.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* -** This file is part of the ViTE project. -** -** This software is governed by the CeCILL-A license under French law -** and abiding by the rules of distribution of free software. You can -** use, modify and/or redistribute the software under the terms of the -** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following -** URL: "http://www.cecill.info". -** -** As a counterpart to the access to the source code and rights to copy, -** modify and redistribute granted by the license, users are provided -** only with a limited warranty and the software's author, the holder of -** the economic rights, and the successive licensors have only limited -** liability. -** -** In this respect, the user's attention is drawn to the risks associated -** with loading, using, modifying and/or developing or reproducing the -** software by the user in light of its specific status of free software, -** that may mean that it is complicated to manipulate, and that also -** therefore means that it is reserved for developers and experienced -** professionals having in-depth computer knowledge. Users are therefore -** encouraged to load and test the software's suitability as regards -** their requirements in conditions enabling the security of their -** systems and/or data to be ensured and, more generally, to use and -** operate it in the same conditions as regards security. -** -** The fact that you are presently reading this means that you have had -** knowledge of the CeCILL-A license and that you accept its terms. -** -** -** ViTE developers are (for version 0.* to 1.0): -** -** - COULOMB Kevin -** - FAVERGE Mathieu -** - JAZEIX Johnny -** - LAGRASSE Olivier -** - MARCOUEILLE Jule -** - NOISETTE Pascal -** - REDONDY Arthur -** - VUCHENER Clément -** -*/ - -#include <iostream> -#include <sstream> -#include <fstream> -/* -- */ -#include <QObject> -/* -- */ -#include "common/common.hpp" -#include "interface/resource.hpp" -/* -- */ -#include "render/render.hpp" -#include "render/render_svg.hpp" -/* -- */ -using namespace std; - -Times Svg::_start_interval_time = 0.; -Times Svg::_end_interval_time = 0.; -Element_pos Svg::_wide_factor = 200.; -Element_pos Svg::_height_factor = 20.; -double Svg::_epsilon = 0.1; -double Svg::_scale_frequency = 50.; - - -const double Svg::_MARGINSTATE = 0.5; -const int Svg::_MARGIN = 10; -const int Svg::_ARROWSIZE = 2; -const int Svg::_MARGINTOP = 20; -const int Svg::_WAIT_NEW_CHRONO = 0; -const int Svg::_INIT = 1; -const int Svg::_WAIT_FOR_POINT = 2; - -void Svg::init(const char *path){ - - _debug_svg_already_closed_once = false; - -// cerr << "wide factor : "; -// cerr << _wide_factor << endl; - - -// cerr << "height factor : "; -// cerr << _height_factor << endl; - -// cerr << "accuracy : "; -// cerr << _epsilon << endl; - - _container_width_max = 0; - - _container_height_min = 1280; - - - _svg_file.open(path, ofstream::out | ofstream::trunc); - - if (!_svg_file.is_open()) { - *Message::get_instance() << QObject::tr("Unable to open ").toStdString() << path << Message::ende; - } - - - _buffer << "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n" - << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" - << "<svg xmlns=\"http://www.w3.org/2000/svg\" x=\"0\" y=\"0\" id=\"svg2\" style=\"background-color:#c1e9ed;\" >\n" - << "\t<style type='text/css' id='stylecss' >\n" - << "\t\t#undef {\n" - << "\t\t\tfill:url(#Degrade);\n" - << "\t\t}\n" - << "\t\tline {\n" - << "\t\t\tstroke:white;stroke-width:1\n" - << "\t\t}\n" - << "\t\tpolyline {\n" - << "\t\t\tfill:white;stroke:white;stroke-width:1\n" - << "\t\t}\n" - << "\t\tpath {\n" - << "\t\t\tfill:none;stroke:green;stroke-width:1\n" - << "\t\t}\n" - << "\t\ttext {\n" - << "\t\t\tfill:black;font-size:8px;\n" - << "\t\t}\n" - << "\t</style>\n" - << "\t<desc>Rectangles</desc>\n" - << "<g>" - << "<defs>" - << "<linearGradient id='Degrade'>" - << "<stop offset='5%' stop-color='#F60' />" - << "<stop offset='95%' stop-color='#FF6' />" - << "</linearGradient>" - << "</defs>"; - - - print(); -} - -void Svg::end(){ - - if (_debug_svg_already_closed_once) { - *Message::get_instance()<< QObject::tr("Svg::end() already called").toStdString() << Message::ende; - return; - } - else { - _debug_svg_already_closed_once = true; - } - - _svg_file.write(_buffer.str().c_str(), _buffer.str().size()); - _buffer.flush(); - _buffer.str(""); - - - _svg_file.write(_chronogramme.str().c_str(), _chronogramme.str().size()); - _chronogramme.flush(); - _chronogramme.str(""); - - display_time_scale(); - - - _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()); - _thin_element_buffer.flush(); - _thin_element_buffer.str(""); - - - - _svg_file.close(); -#ifdef TEST_SVG_MODE - cout<< "output written" << endl; -#else - //message_ns::message << "output written" << message_ns::endi; -#endif - - - -} - - -void Svg::display_time_scale() { - _total_width = _total_time; - - Element_pos w = _total_width*_wide_factor; - Element_pos h = (_MARGINTOP*1.0)/2; - Element_pos x = _container_width_max + _MARGINSTATE; - Element_pos y = 0; - - Element_col r = 255; - Element_col g = 255; - Element_col b = 255; - - - _time_scale << "\n<rect class='scale' title='scale'" - << " 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); - - Element_pos inc; - - - 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; - - _time_scale << "<text x='" << x <<"' y='" << y + h << "'>|"; - _time_scale << i; - _time_scale << "</text>"; - - } - - - - _svg_file.write(_time_scale.str().c_str(), _time_scale.str().size()); - _time_scale.flush(); - _time_scale.str(""); - -} - -void Svg::set_height_factor (Element_pos h) { - _height_factor = h; -} - -void Svg::set_wide_factor (Element_pos w) { - _wide_factor = w; -} - -Element_pos Svg::get_height_factor() { - return _height_factor; -} - -Element_pos Svg::get_wide_factor() { - return _wide_factor; -} - - -void Svg::set_interval(const Times t1, const Times t2) { - _start_interval_time = t1; - _end_interval_time = t2; -} - -void Svg::set_accuracy(const double epsilon) { - _epsilon = epsilon; -} - - -void Svg::set_scale_frequency(const Element_pos w) { - _scale_frequency = w; -} - -void Svg::set_total_width(const Element_pos) { -} -void Svg::set_total_time(const Times) { -} - -Svg::~Svg() { - -} diff --git a/src/render/render_svg.hpp b/src/render/render_svg.hpp deleted file mode 100644 index 65594bdaeb439e1ed804f910e60708b3cf2c43cb..0000000000000000000000000000000000000000 --- a/src/render/render_svg.hpp +++ /dev/null @@ -1,751 +0,0 @@ -/* -** This file is part of the ViTE project. -** -** This software is governed by the CeCILL-A license under French law -** and abiding by the rules of distribution of free software. You can -** use, modify and/or redistribute the software under the terms of the -** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following -** URL: "http://www.cecill.info". -** -** As a counterpart to the access to the source code and rights to copy, -** modify and redistribute granted by the license, users are provided -** only with a limited warranty and the software's author, the holder of -** the economic rights, and the successive licensors have only limited -** liability. -** -** In this respect, the user's attention is drawn to the risks associated -** with loading, using, modifying and/or developing or reproducing the -** software by the user in light of its specific status of free software, -** that may mean that it is complicated to manipulate, and that also -** therefore means that it is reserved for developers and experienced -** professionals having in-depth computer knowledge. Users are therefore -** encouraged to load and test the software's suitability as regards -** their requirements in conditions enabling the security of their -** systems and/or data to be ensured and, more generally, to use and -** operate it in the same conditions as regards security. -** -** The fact that you are presently reading this means that you have had -** knowledge of the CeCILL-A license and that you accept its terms. -** -** -** ViTE developers are (for version 0.* to 1.0): -** -** - COULOMB Kevin -** - FAVERGE Mathieu -** - JAZEIX Johnny -** - LAGRASSE Olivier -** - MARCOUEILLE Jule -** - NOISETTE Pascal -** - REDONDY Arthur -** - VUCHENER Clément -** -*/ -/*! - *\file render_svg.hpp - */ -#ifndef RENDER_SVG -#define RENDER_SVG - -/*! - * \brief This class provides a SVG display ,it inherited from the Render interface. - */ -class Svg{ - - -private: - - /*! - * \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 - */ - std::ostringstream _thin_element_buffer; - - /*! - * \brief buffer containning each counters values - */ - std::ostringstream _chronogramme; - - /*! - * \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 - */ - int _chronogramme_state; - - /*! - * \brief output svg file - */ - std::ofstream _svg_file; - /*! - * \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 - */ - Element_pos _container_height_min; - - - /*! - * \brief Statistics and Informations about input trace computed in live - */ - Element_pos _total_width; - - - /*! - * \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 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 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 - */ - 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: - - - /*! - * \brief Distance between two container - */ - static const int _MARGIN; - - /*! - * \brief Spike size - */ - static const int _ARROWSIZE; - - - /*! - * \brief Distance between two states - */ - static const double _MARGINSTATE; - - /*! - * \brief offset between the top and the picture due to the scale - */ - static const int _MARGINTOP; - - /*! - * \brief a State of chronogramme drawer automaton - */ - static const int _WAIT_NEW_CHRONO; - - /*! - * \brief a State of chronogramme drawer automaton - */ - static const int _INIT; - - /*! - * \brief a State of chronogramme drawer automaton - */ - static const int _WAIT_FOR_POINT; - - - /*! - * \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; - - - /*! - * \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; - - - /*! - * \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; - - /*! - *\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 - */ - - static Element_pos _height_factor; - - /*! - * \brief accuracy required : an element less wide than _epsilon will not be printed - */ - static double _epsilon; - - - /*! - * \brief the scale can be more accurate by increasing the _scale_frequency - */ - static double _scale_frequency; - - /*STATIC : allows commands line parameter*/ - - /*! - * \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(const Times t1, const Times t2); - /*! - * \brief Set the precision of SVG display. - * \param epsilon Precision - */ - static void set_accuracy(const 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 (const Element_pos w); - /*! - * \brief Svg display is grown by _height - */ - static void set_height_factor (const Element_pos h); - - /*! - * \brief Return the height factor. - * \return The height factor. - */ - static Element_pos get_height_factor(); - - /*! - * \brief Return the widet factor. - * \return The wide factor. - */ - static Element_pos get_wide_factor(); - - /*! - * \brief the scale can be more accurate by increasing the _scale_frequency - */ - static void set_scale_frequency(const Element_pos w); - - - - - /*Statistics : not yet implemented*/ - - /*! - * \brief The width of the trace - */ - void set_total_width(const Element_pos); - /*! - * \brief The time span of the trace - */ - void set_total_time(const Times); - - - - - /*drawing functions*/ - - /*! - * \brief SVG header buiding - */ - void init(const char *path); - - /*! - * \brief SVG bottom file buiding - */ - void end(); - - - /*! - * \brief unused - */ - void start_draw(); - - /*! - * \brief unused - */ - 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 associated container name - */ - void draw_container_text(const Element_pos x, const Element_pos y, const std::string value); - /*! - * \brief unused - */ - void end_draw_containers(); - - /*! - * \brief unused - */ - void start_draw_states(); - - /*! - * \brief Draw a state of the trace. - * \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. - * \param start the beginning time of the state. - * \param end the ending time of the state. - * \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); - - /*! - * \brief unused - */ - void start_draw_arrows(); - - /*! - * \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); - - /*! - * \brief unused - */ - void end_draw_arrows(); - - /*! - * \brief unused - */ - void end_draw_states(); - - /*! - * \brief warning : not yet implemented - */ - void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height); - - - /*! - * \brief initialise drawer automaton - */ - void start_draw_counter(); - - - /*! - * \brief add a point or switch chronogramme drawing - */ - void draw_counter(const Element_pos x, const Element_pos y); - - /*! - * \brief close drawer automaton - */ - void end_draw_counter(); - - - /*! - * \brief display the scale - */ - void display_time_scale(); - - - /*! - * \brief unused - */ - void end_draw(); - - - virtual ~Svg(); - - -}; - - - -/*********************************** - * - * - * - * Drawing function for the trace. - * - * - * - **********************************/ - - -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; - - /*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>"; - -} - -inline void Svg::start_draw_containers(){ - -} - -inline void Svg::end_draw_containers(){ -} - -inline void Svg::start_draw_states(){ -} - -inline void Svg::end_draw_states(){ -} - - -/******************** - * Counter - *******************/ - -inline void Svg::start_draw_counter(){ - _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)*/ - - 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) { - - _chronogramme << "\n<path d='M"<< xprime + _start_interval_time*_wide_factor << " " << yprime; - _chronogramme_state=_WAIT_FOR_POINT; - } - else - std::cerr<<QObject::tr("draw_counter not initialised").toStdString(); - - } - 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 && x > _end_interval_time) - return; - - if (x<_start_interval_time) - return; - - - _total_time = std::max( _total_time,x); - - _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<<QObject::tr("draw_counter not initialised").toStdString(); - - - } - - -} - -inline void Svg::end_draw_counter() { - if (_chronogramme_state!=_WAIT_NEW_CHRONO && _chronogramme_state!=_INIT) - std::cerr<<QObject::tr("draw_counter not un-initialised").toStdString(); -} - - -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 - <<"' height='"<< h - <<"' x='" << x1 - <<"' y='" << y1 - <<"' fill='rgb("<<r<<","<<g<<","<<b - <<")'/>"; - print(); -} - - - - - -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(""); -} - - - - -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) { - - /*selection*/ - /*may be outofrange*/ - 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; - } - - - /*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; - } - - } - - - - /*update of the time*/ - _total_time = std::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)*/ - - - 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); - - if (!trunc) - Svg::triangle("arrow",x2 ,y2+_ARROWSIZE,x2 ,y2-_ARROWSIZE,x2+_ARROWSIZE,y2); - - -} - - -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) { - - Element_pos xprime,yprime,wprime,hprime; - - if (h<=0 || w<=0 || x<0 || y<0){ - std::cerr<<QObject::tr("draw_container : specified argument isn't positive double").toStdString()<<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); - - - - _container_width_max = std::max(wprime+xprime+ _MARGIN,_container_width_max); - _container_height_min = std::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) { - - Element_pos w; - Element_pos h; - Element_pos x; - Element_pos y; - - Element_pos startprime; - Element_pos endprime; - - if (start<=0 || end <=0 || height<0 || level<0){ - std::cerr<<QObject::tr("draw_state : specified argument isn't positive double").toStdString()<<std::endl; - return; - } - - - /*selection*/ - /*an outofrange state will not be displayed*/ - 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 && end>_end_interval_time) { - endprime = _end_interval_time; - } - - - - - _total_time = std::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)*/ - - 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; - } - - - Svg::rectangle("state", w, h, x, y, (unsigned int)r*255, (unsigned int)g*255, (unsigned int)b*255); -} - - - -/*! - * \fn void Svg::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height) - * \brief Draw the events in the svg - * \param time The time the element occur - * \param height The height of the event - * \param container_height The height of the container that contains it - */ -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<<QObject::tr("draw_event : specified argument isn't positive double").toStdString()<<std::endl; - return; - } - - - - /*an outofrange event will not be displayed*/ - if ((_end_interval_time && time > _end_interval_time) || time < _start_interval_time) - return; - - _total_time = std::max(_total_time, time); - - - _total_time = std::max( _total_time,time); - - Svg::rectangle("event",_MARGINSTATE,_container_height_min, time + _container_width_max -_start_interval_time*_wide_factor, height + _MARGINTOP, 0x17, 0x60, 0xe7); - -} - -#endif // RENDER_SVG diff --git a/src/src.pro b/src/src.pro index a46cf1fa61ca4859aae3d8a78bd9433ecadea9cd..70dce7ddad6442b1e938c97e39f09d6e600b8e1f 100644 --- a/src/src.pro +++ b/src/src.pro @@ -84,7 +84,7 @@ HEADERS += common/common.hpp \ core/Core.hpp \ # Render headers render/Render.hpp \ - render/render.hpp \ +# render/render.hpp \ render/Geometry.hpp \ render/Hook_event.hpp \ # render/Render_opengl_dl.hpp \ @@ -191,6 +191,7 @@ SOURCES += common/Message.cpp \ # Render code files render/Geometry.cpp \ render/Hook_event.cpp \ + render/Render.hpp \ render/Render_opengl.cpp \ render/Render_svg.cpp \ render/render_stats_opengl.cpp \ diff --git a/src/trace/values/Date.cpp b/src/trace/values/Date.cpp index cdb98a8dfc3503c17e770008f7aaceba04cc996b..b92d5292d9efb9488e2d620c3f616bfb144a4982 100644 --- a/src/trace/values/Date.cpp +++ b/src/trace/values/Date.cpp @@ -58,13 +58,13 @@ Date::Date() : _value(0.0) { } Date::Date(double value) : _value(value) { - + // std::cout << __FILE__ << " " << __LINE__ << " " << Info::Entity::x_max << std::endl; if (_value > Info::Entity::x_max) Info::Entity::x_max = _value; else if (Info::Entity::x_min > _value) Info::Entity::x_min = _value; - // std::cout << __FILE__ << " " << __LINE__ << " " << _value << std::endl; + } bool Date::instantiate(const std::string &in, Date &out){