From b5c4de954ba69c55abb64981b60e56b9ddc93e79 Mon Sep 17 00:00:00 2001 From: Olivier Lagrasse <olivier.lagrasse@gmail.com> Date: Thu, 20 Aug 2009 14:50:37 +0000 Subject: [PATCH] - Temporary commit for unified render. --- src/CMakeLists.txt | 2 + src/common/info.cpp | 12 +- src/common/info.hpp | 28 ++- src/core/Core.cpp | 73 ++++-- src/core/Core.hpp | 14 +- src/interface/Interface_graphic.cpp | 10 +- src/render/Geometry.cpp | 194 ++++++++++++++++ src/render/Geometry.hpp | 335 +++++++++++++++++++++++++++ src/render/Hook_event.cpp | 81 ++----- src/render/Hook_event.hpp | 341 ++++------------------------ src/render/Render_opengl.cpp | 312 +++++++++++++++++++++++-- src/render/Render_opengl.hpp | 228 +++++++++++++------ src/render/Render_opengl_dl.hpp | 51 +++-- src/render/render_svg.hpp | 2 +- src/src.pro | 9 +- src/trace/Container.cpp | 7 +- src/trace/DrawTrace.hpp | 9 +- src/trace/DrawTree.hpp | 3 + src/trace/values/Date.cpp | 12 + tests/render/Makefile | 10 + tests/render/Render.hpp | 24 ++ tests/render/Render_opengl.hpp | 18 ++ tests/render/Trace.hpp | 21 ++ tests/render/main.cpp | 18 ++ 24 files changed, 1305 insertions(+), 509 deletions(-) create mode 100644 src/render/Geometry.cpp create mode 100644 src/render/Geometry.hpp create mode 100644 tests/render/Makefile create mode 100644 tests/render/Render.hpp create mode 100644 tests/render/Render_opengl.hpp create mode 100644 tests/render/Trace.hpp create mode 100644 tests/render/main.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50965bc1..7ce96f1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,7 @@ SET(VITE_HDRS trace/Trace.hpp # Render headers render/render.hpp + render/Geometry.hpp render/Hook_event.hpp render/Render_opengl_dl.hpp render/Render_opengl.hpp @@ -158,6 +159,7 @@ SET(VITE_SRCS trace/Container.cpp trace/Trace.cpp # Render code files + render/Geometry.cpp render/Hook_event.cpp render/Render_opengl.cpp render/render_svg.cpp diff --git a/src/common/info.cpp b/src/common/info.cpp index b3fab4c9..c11616ca 100644 --- a/src/common/info.cpp +++ b/src/common/info.cpp @@ -73,11 +73,15 @@ // const int Info::Core::_STATE_RENDER_DISPLAY_INFORMATION = 21; // const int Info::Core::_STATE_RENDER_UPDATE = 22; -int Info::Container::x_min = 0; -int Info::Container::x_max = 0; +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::Entity::x_min = 0; -int Info::Entity::x_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; bool Info::Render::_key_alt = false; bool Info::Render::_key_ctrl = false; diff --git a/src/common/info.hpp b/src/common/info.hpp index c0ca2d53..9cb66281 100644 --- a/src/common/info.hpp +++ b/src/common/info.hpp @@ -220,12 +220,22 @@ public: /*! * \brief Minimum x position. */ - static int x_min; + static Element_pos x_min; /*! * \brief Maximum x position. */ - static int x_max; + static Element_pos x_max; + + /*! + * \brief Minimum y position. + */ + static Element_pos y_min; + + /*! + * \brief Maximum y position. + */ + static Element_pos y_max; }; @@ -237,12 +247,22 @@ public: /*! * \brief Minimum x position. */ - static int x_min; + static Element_pos x_min; /*! * \brief Maximum x position. */ - static int x_max; + static Element_pos x_max; + + /*! + * \brief Minimum y position. + */ + static Element_pos y_min; + + /*! + * \brief Maximum y position. + */ + static Element_pos y_max; }; diff --git a/src/core/Core.cpp b/src/core/Core.cpp index e7e352fa..65117720 100644 --- a/src/core/Core.cpp +++ b/src/core/Core.cpp @@ -62,9 +62,12 @@ #include "common/Errors.hpp" #include "common/Tools.hpp" /* -- */ -#include "render/render.hpp" -#include "render/render_svg.hpp" -#include "render/Render_opengl_dl.hpp" + +#include "render/Render_opengl.hpp" +//#include "render/render.hpp" +#include "render/Render_svg.hpp" +#include "render/Render.hpp" +//#include "render/Render_opengl_dl.hpp" /* -- */ #include "trace/values/Values.hpp" #include "trace/tree/Interval.hpp" @@ -187,9 +190,17 @@ Core::~Core(){ bool Core::draw_trace(const string & filename, const int format){ Parser *parser; - Svg svg; - DrawTrace<Render_opengl> drawing_ogl; - DrawTrace<Svg> drawing_svg; + // Svg svg; + + /* MOD */ + DrawTrace/*<Render_opengl>*/ drawing_ogl; + // _render_opengl = new Render_opengl(this, _main_window); + Render<Render_opengl> render(_render_opengl); + + //Render<Render_opengl> drawing_ogl; + + // DrawTrace<Svg> drawing_svg; + QTime time_elapsed; ostringstream buf_txt; int time_buf; @@ -225,7 +236,8 @@ bool Core::draw_trace(const string & filename, const int format){ QApplication::setOverrideCursor(Qt::WaitCursor); if (_DRAW_SVG == format) - svg.init(_path_to_export.c_str()); + _render_svg = new Render_svg(&_path_to_export);// svg.init(_path_to_export.c_str()); + if (NULL == _trace) { /* no trace is loaded, parse the file */ @@ -319,22 +331,28 @@ bool Core::draw_trace(const string & filename, const int format){ *Message::get_instance() << "Try to use file: " << filename << " instead of a previous parsed file: " << _file_opened << Message::ende; } - Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) ); - // Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) ); + //Interval interval(_time_start, ((0==_time_end)?_trace->get_max_date():_time_end) ); + Interval interval(Info::Render::_x_min_visible, Info::Render::_x_max_visible); + // std::cout << __FILE__ << " " << __LINE__ << " " << Info::Render::_x_min_visible << " " << Info::Render::_x_max_visible << std::endl; if (_DRAW_OPENGL == format) { - drawing_ogl.build(_render_opengl, _trace); + drawing_ogl.build(&render, _trace); _render_opengl->build(); _render_opengl->updateGL(); _render_opengl->refresh_scroll_bars(); _file_opened = filename;/* store filename for a future export */ }else if (_DRAW_SVG == format) { - drawing_svg.build(&svg, _trace); - svg.end(); + + Render<Render_svg> render(_render_svg); + drawing_ogl.build(&render, _trace); + delete _render_svg;/* Release the svg render */ + // svg.end(); }else{/* error */ *Message::get_instance() << "No kind of render recognized" << Message::ende; return false; } + // std::cout << _trace->get_max_date().get_value() << __FILE__ << __LINE__ << std::endl; + _is_trace_loaded = true; QApplication::restoreOverrideCursor(); @@ -373,11 +391,11 @@ int Core::get_state(int argc, char** argv){ /*The following statics must be initialised in case their are not overrided by a command line request*/ - Svg::set_height_factor (20); + /* Svg::set_height_factor (20); Svg::set_wide_factor (100); Svg::set_interval(0, 0); Svg::set_accuracy(0.1); - Svg::set_scale_frequency(50); + Svg::set_scale_frequency(50);*/ if(argc == 1){ // just the name of the program, launch the window interface @@ -446,7 +464,7 @@ int Core::get_state(int argc, char** argv){ return _STATE_UNKNOWN; } else { - Svg::set_accuracy(accuracy); + // Svg::set_accuracy(accuracy); } } } @@ -462,7 +480,7 @@ int Core::get_state(int argc, char** argv){ return _STATE_UNKNOWN; } else { - Svg::set_wide_factor(wide); + // Svg::set_wide_factor(wide); } } else if((string)argv[i] == "-grow") { @@ -477,7 +495,7 @@ int Core::get_state(int argc, char** argv){ return _STATE_UNKNOWN; } else { - Svg::set_height_factor(grow); + // Svg::set_height_factor(grow); } } else if((string)argv[i] == "-scale") { @@ -492,7 +510,7 @@ int Core::get_state(int argc, char** argv){ return _STATE_UNKNOWN; } else { - Svg::set_scale_frequency(scale); + // Svg::set_scale_frequency(scale); } } else if((string)argv[i] == "-interval") { @@ -518,7 +536,7 @@ int Core::get_state(int argc, char** argv){ return _STATE_UNKNOWN; } - Svg::set_interval(t1, t2); + // Svg::set_interval(t1, t2); i += 2; } else { @@ -567,7 +585,7 @@ void Core::extract_times(const char *name) { void Core::launch_action(int state, void* arg) { - DrawTrace<Render_opengl> buf; + DrawTrace/*<Render_opengl>*/ buf; switch(state) { @@ -580,7 +598,11 @@ void Core::launch_action(int state, void* arg) { _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_dl(this, _main_window); + /* MOD */ + // _render_opengl = new Render_opengl_dl(this, _main_window); + _render_opengl = new Render_opengl(this, _main_window); + + _main_window->bind_render_area((QGLWidget*)_render_opengl); _is_window_displayed = true; @@ -590,7 +612,12 @@ void Core::launch_action(int state, void* arg) { information(string("Opening the file: ")+_file_opened); _main_window = new Interface_graphic(this);/* launch the window interface and open a file */ Message::set_interface(_main_window);/* define which interface will receive messages */ - _render_opengl = new Render_opengl_dl(this, _main_window); + + /* MOD */ + // _render_opengl = new Render_opengl_dl(this, _main_window); + _render_opengl = new Render_opengl(this, _main_window); + + _main_window->bind_render_area((QGLWidget*)_render_opengl); _main_window->opening_file(_file_opened);/* Must be called after binding the render area to the main window */ @@ -658,7 +685,7 @@ void Core::launch_action(int state, void* arg) { cout << "the end of the trace."; } - Svg::set_interval(_time_start, _time_end); + // Svg::set_interval(_time_start, _time_end); draw_trace(_file_opened, _DRAW_SVG); break; diff --git a/src/core/Core.hpp b/src/core/Core.hpp index 769a845c..690e5f29 100644 --- a/src/core/Core.hpp +++ b/src/core/Core.hpp @@ -50,9 +50,12 @@ class Core; class Interface_graphic; class Render_opengl; +class Render_svg; class Trace; +#include "render/Render.hpp" class Variable; + #include "interface/Interface.hpp" /*! @@ -250,9 +253,16 @@ protected: Interface_graphic* _main_window; /*! - * \brief Contains the OpenGL render area instance. + * \brief Contains the OpenGL render instance. + */ + /* MOD */ + Render_opengl* _render_opengl; + //Render<Render_opengl>* _render_opengl; + + /*! + * \brief Contains the SVG render instance. */ - Render_opengl* _render_opengl; + Render_svg* _render_svg; /*! * \brief Contains the main Qt application instance. diff --git a/src/interface/Interface_graphic.cpp b/src/interface/Interface_graphic.cpp index f3046ca4..3231eba2 100644 --- a/src/interface/Interface_graphic.cpp +++ b/src/interface/Interface_graphic.cpp @@ -61,7 +61,7 @@ #include "trace/Entitys.hpp" #include "trace/Trace.hpp" /* -- */ -#include "render/render.hpp" +//#include "render/render.hpp" #include "render/render_svg.hpp" /* -- */ #include "statistics/Stats_window.hpp" @@ -560,10 +560,10 @@ void Interface_graphic::option_export_ok_pressed(){ double accuracy = convert_to_double(_ui_accuracy_export->text().toStdString()); double height = convert_to_double(_ui_grow_export->text().toStdString()); double wide = convert_to_double(_ui_wide_export->text().toStdString()); - + /* if(_ui_more_options_export->isChecked()) { if(accuracy >= 0. && _ui_CheckBox_accuracy_export->isChecked()) - Svg::set_accuracy(accuracy); + Svg::set_accuracy(accuracy); else { // Default value Svg::set_accuracy(0.); } @@ -578,13 +578,13 @@ void Interface_graphic::option_export_ok_pressed(){ Svg::set_wide_factor(wide); else { // Default value Svg::set_wide_factor(100.); - } + } } else{ // Default values Svg::set_accuracy(0.); Svg::set_height_factor(20.); Svg::set_wide_factor(100.); - } + }*/ _core->launch_action(Core::_STATE_EXPORT_FILE_IN_INTERVAL); } diff --git a/src/render/Geometry.cpp b/src/render/Geometry.cpp new file mode 100644 index 00000000..531b499f --- /dev/null +++ b/src/render/Geometry.cpp @@ -0,0 +1,194 @@ +/* +** 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 Geometry.cpp + */ + +#include "common/common.hpp" +#include "common/info.hpp" +/* -- */ +#include "render/Geometry.hpp" + + +using namespace std; + +#define message *Message::get_instance() << "(" << __FILE__ << " l." << __LINE__ << "): " + + +/*********************************** + * + * + * + * Constructor and destructor. + * + * + * + **********************************/ + +Geometry::Geometry(){ + + _counter_last_x = 0.0; + _counter_last_y = 0.0; + + /* init main informations about OpenGL scene and QGLWidget size */ + + + + _render_width = 100; /* 100 OpenGL units for the render scene width */ + _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 */ + + _container_x_max = 0; + _container_y_max = 0; + _container_x_min = 0; + _container_y_min = 0; + + _state_y_max = 0; + _state_y_min = 0; + + // _ruler_distance = 5; + + // _minimum_distance_for_selection = 5;/* 5 pixels */ + + // _selection_rectangle_alpha = 0.5; + + _x_state_scale = 1;/* for states scaling */ + _x_state_translate = 0;/* for states translation */ + _y_state_scale = 1;/* for states scaling */ + _y_state_translate = 0;/* for states translation */ + _x_scroll_pos = 0;/* horizontal bar placed on 0 */ + _y_scroll_pos = 0;/* vertical bar placed on 0 */ + + /* Camera is placed on (0,0,0) and looks to (0,0,-1) */ + + _z_ruler_over = -0.5; + _z_container = -1.0; + _z_container_under = -1.2; + _z_ruler = -1.5; + _z_ruler_under = -1.6; + _z_arrow = -2.0;/* closer to camera than containers or states (MUST be negative)*/ + _z_event = -3.0;/* closer to camera than containers or states (MUST be negative)*/ + _z_counter = -4.0; + _z_state = -5.0; + + /* Set in the child class */ + _screen_width = 0; + _screen_height = 0; + +} + + +Geometry::~Geometry(){ +} + + + + /*********************************** + * + * + * + * Coordinate convert functions. + * + * + * + **********************************/ + + +Element_pos Geometry::screen_to_render_x(Element_pos e){ + + return e * (Element_pos)_render_width / (Element_pos)_screen_width; +} + +Element_pos Geometry::screen_to_render_y(Element_pos e){ + + return e * (Element_pos)_render_height / (Element_pos)_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); +} + +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); +} + +Element_pos Geometry::render_to_screen_x(Element_pos e){ + + return e * (Element_pos)_screen_width / (Element_pos)_render_width; +} + +Element_pos Geometry::render_to_screen_y(Element_pos e){ + + return e * (Element_pos)_screen_height / (Element_pos)_render_height; +} + +Element_pos Geometry::trace_to_render_x(Element_pos e){ + + return e * coeff_trace_render_x() + + _default_entity_x_translate - _x_state_translate; +} + +Element_pos Geometry::trace_to_render_y(Element_pos e){ + + return e *coeff_trace_render_y() + + _ruler_y + _ruler_height - _y_state_translate; +} + +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); +} + +Element_pos Geometry::coeff_trace_render_y(){ + + return ((_render_height-_ruler_height)*_y_state_scale) / (_container_y_max-_container_y_min); +} diff --git a/src/render/Geometry.hpp b/src/render/Geometry.hpp new file mode 100644 index 00000000..cb11ad22 --- /dev/null +++ b/src/render/Geometry.hpp @@ -0,0 +1,335 @@ +/* +** 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 Geometry.hpp + */ + + +#ifndef GEOMETRY_HPP +#define GEOMETRY_HPP + +//class Element_pos; +#include "common/common.hpp" + +/*! + * \brief This class provide some tools to manage the window and render area geometry. + */ +class Geometry +{ + +protected: + + /*! + * \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 objects over the ruler. + */ + Element_pos _z_ruler_over; + + /*! + * \brief z position for objects under the ruler. + */ + Element_pos _z_ruler_under; + + /*! + * \brief z position for containers. + */ + Element_pos _z_container; + + /*! + * \brief z position for objects under containers. + */ + Element_pos _z_container_under; + + /*! + * z position for states. + */ + Element_pos _z_state; + + /*! + * z position for events. + */ + Element_pos _z_event; + + /*! + * z position for arrows. + */ + Element_pos _z_arrow; + + /*! + * z position for counters. + */ + Element_pos _z_counter; + + /*! + * Default offset of entities drawing. + */ + Element_pos _default_entity_x_translate; + + /*! + * Distance between two ruler measures. + */ + Element_pos _ruler_distance; + + /*! + * Height of the ruler. + */ + Element_pos _ruler_height; + + /*! + * Highness of the ruler. + */ + Element_pos _ruler_y; + + /*! + * Width of the ruler. + */ + Element_pos _ruler_width; + + /*! + * \brief The percentage taken by container display in the render area. + */ + Element_pos _x_scale_container_state; + + /*! + * \brief the x scale of state drawing. + */ + Element_pos _x_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. + */ + Element_pos _x_state_translate; + + /*! + * \brief The y position of camera view for state drawing area. + */ + Element_pos _y_state_translate; + + /*! + * \brief The x position of the horizontal scroll bar. + */ + Element_pos _x_scroll_pos; + + /*! + * \brief The y position of the vertical scroll bar. + */ + Element_pos _y_scroll_pos; + + + /*********************************** + * + * Constructor and destructor. + * + **********************************/ +public: + + + /*! + * \brief The constructor. + */ + Geometry(); + + /*! + * \brief The destructor + */ + virtual ~Geometry(); + + + /*********************************** + * + * Coordinate convert functions. + * + **********************************/ + + /*! + * \brief This function convert a X screen coordinate into render coordinate. + * \param e A X screen coordinate. + * \return A X render coordinate corresponding to e but in render area coordinate. + */ + Element_pos screen_to_render_x(Element_pos e); + + /*! + * \brief This function convert a Y screen coordinate into render coordinate. + * \param e A Y screen coordinate. + * \return A Y render coordinate corresponding to e but in render area coordinate. + */ + Element_pos screen_to_render_y(Element_pos e); + + /*! + * \brief This function convert a X render coordinate into trace coordinate. + * \param e A X render coordinate. + * \return A X trace coordinate corresponding to e but in trace coordinate. + */ + Element_pos render_to_trace_x(Element_pos e); + + /*! + * \brief This function convert a Y render coordinate into trace coordinate. + * \param e A Y render coordinate. + * \return A Y trace coordinate corresponding to e but in trace coordinate. + */ + Element_pos render_to_trace_y(Element_pos e); + + /*! + * \brief Dual of screen_to_render_x. + * \param e A X render coordinate. + * \return A X screen coordinate corresponding to e but in screen coordinate. + */ + Element_pos render_to_screen_x(Element_pos e); + + /*! + * \brief Dual of screen_to_render_y. + * \param e A Y render coordinate. + * \return A Y screen coordinate corresponding to e but in screen coordinate. + */ + Element_pos render_to_screen_y(Element_pos e); + + /*! + * \brief Dual of render_to_trace_x. + * \param e A X trace coordinate. + * \return A X render coordinate corresponding to e but in render area coordinate. + */ + Element_pos trace_to_render_x(Element_pos e); + + /*! + * \brief Dual of render_to_trace_y. + * \param e A Y trace coordinate. + * \return A Y render coordinate corresponding to e but in render area coordinate. + */ + Element_pos trace_to_render_y(Element_pos e); + + /*! + * \brief Return the coefficient used to convert from horizontal trace scale to the horizontal render scale by multiplication. + * \return A number with which an horizontal trace width number must be multiply to get its horizontal render width. + */ + Element_pos coeff_trace_render_x(); + + /*! + * \brief Return the coefficient used to convert from vertical trace scale to the vertical render scale by multiplication. + * \return A number with which a vertical trace height number must be multiply to get its vertical render height. + */ + Element_pos coeff_trace_render_y(); + +}; + + + +#endif diff --git a/src/render/Hook_event.cpp b/src/render/Hook_event.cpp index 9d81a41e..6de76dd2 100644 --- a/src/render/Hook_event.cpp +++ b/src/render/Hook_event.cpp @@ -48,8 +48,9 @@ #include "common/common.hpp" #include "common/info.hpp" /* -- */ -#include "render/render.hpp" +//#include "render/render.hpp" #include "render/Render_opengl.hpp" +//#include "render/Geometry.hpp" #include "render/Hook_event.hpp" /* -- */ using namespace std; @@ -113,37 +114,11 @@ Hook_event::Hook_event(Render_opengl* render_instance, Core* core, QWidget *pare _wait_timer = NULL; _wait_spf = DRAWING_TIMER_DEFAULT;/* DRAWING_TIMER_DEFAULT milliseconds per frame */ - _counter_last_x = 0.0; - _counter_last_y = 0.0; - - _line_already_begun = false; - - /* 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) */ - _render_width = 100; /* 100 OpenGL units for the render scene width */ - _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 */ - - _container_x_max = 0; - _container_y_max = 0; - _container_x_min = 0; - _container_y_min = 0; - - _state_x_max = 0; - _state_y_max = 0; - _state_x_min = 0; - _state_y_min = 0; - _ruler_distance = 5; _mouse_x = 0; @@ -163,25 +138,6 @@ Hook_event::Hook_event(Render_opengl* render_instance, Core* core, QWidget *pare _list_ruler = 0; - _x_state_scale = 1;/* for states scaling */ - _x_state_translate = 0;/* for states translation */ - _y_state_scale = 1;/* for states scaling */ - _y_state_translate = 0;/* for states translation */ - _x_scroll_pos = 0;/* horizontal bar placed on 0 */ - _y_scroll_pos = 0;/* vertical bar placed on 0 */ - - /* Camera is placed on (0,0,0) and looks to (0,0,-1) */ - - _z_ruler_over = -0.5; - _z_container = -1.0; - _z_container_under = -1.2; - _z_ruler = -1.5; - _z_ruler_under = -1.6; - _z_arrow = -2.0;/* closer to camera than containers or states (MUST be negative)*/ - _z_event = -3.0;/* closer to camera than containers or states (MUST be negative)*/ - _z_counter = -4.0; - _z_state = -5.0; - setAutoFillBackground(false); setMouseTracking (true);/* to catch mouse events */ @@ -330,11 +286,12 @@ void Hook_event::mouseDoubleClickEvent ( QMouseEvent * event ){ /* * 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-_default_entity_x_translate)*_x_state_scale); - + // x_result *= (_state_x_max - _state_x_min)/((_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 = (_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)/((_render_width-_default_entity_x_translate)*_x_state_scale);//_state_x_max/_render_width; _core->launch_action(_core->_STATE_RENDER_DISPLAY_INFORMATION, NULL); }/* end else of if (x_click...) */ @@ -451,10 +408,10 @@ void Hook_event::apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_po /* * Work out the horizontal middle of the selection area (the selection area width divide by 2 plus the x left coordinate) - * Note: mouse positions are converted to render area coordinate with the coeff _render_width/_screen_width. + * Note: mouse positions are converted to render area coordinate with screen_to_render_**() methods. */ - x_middle_selection = (x_min + (x_max - x_min)/2 )*(_render_width/_screen_width); - y_middle_selection = (y_min + (y_max - y_min)/2 )*(_render_height/_screen_height); + x_middle_selection = screen_to_render_x(x_min + (x_max - x_min)/2 ); + y_middle_selection = screen_to_render_y(y_min + (y_max - y_min)/2 ); /* @@ -462,15 +419,15 @@ 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*/)*(_screen_width/((x_max - x_min))); + y_scaled_middle_selection = (y_middle_selection + _y_state_translate /*- _ruler_height*/ )*(_screen_height/((y_max - y_min))); /* * 2nd step: * * Work out the distance between the state origin and the render area middle (_render_width/2). */ - x_distance_between_state_origin_and_render_middle = _x_state_translate - _default_entity_x_translate + _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; /* @@ -731,8 +688,11 @@ void Hook_event::registered_translate(int id){ _y_state_translate = (Element_pos)_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 + _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))); + 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 @@ -778,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(_state_x_min, (_x_state_translate - _default_entity_x_translate)/(_x_state_scale*((_render_width-_default_entity_x_translate)/(_state_x_max-_state_x_min)) )); - Info::Render::_x_max_visible = min(_state_x_max, (_x_state_translate - _default_entity_x_translate + _render_width)/(_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*((_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)) )); } @@ -794,7 +754,7 @@ void Hook_event::update_visible_interval_value(){ * * **********************************/ - +/* Element_pos Hook_event::screen_to_render_x(Element_pos e){ @@ -849,3 +809,4 @@ Element_pos Hook_event::coeff_trace_render_y(){ return ((_render_height-_ruler_height)*_y_state_scale) / (_container_y_max-_container_y_min); } +*/ diff --git a/src/render/Hook_event.hpp b/src/render/Hook_event.hpp index f39184be..372b7899 100644 --- a/src/render/Hook_event.hpp +++ b/src/render/Hook_event.hpp @@ -49,50 +49,52 @@ #define HOOK_EVENT_HPP #include "core/Core.hpp" +#include "render/Geometry.hpp" class Hook_event; class Core; class Render_opengl; -/*! - * \brief Structure used to store event information. - */ -struct Event_{ - /*! - * \brief time of an event - */ - Element_pos time; - /*! - * \brief height of an event - */ - Element_pos height; - /*! - * \brief height of the container - */ - Element_pos container_height; -}; -/*! - * \brief Structure used to store arrow information. - */ -struct Arrow_{ - /*! - * \brief time when the arrow starts. - */ - Element_pos start_time; - /*! - * \brief time when the arrow ends. - */ - Element_pos end_time; - /*! - * \brief The start height of the arrow. - */ - Element_pos start_height; - /*! - * \brief The end height of the arrow. - */ - Element_pos end_height; -}; +// /*! +// * \brief Structure used to store event information. +// */ +// struct Event_{ +// /*! +// * \brief time of an event +// */ +// Element_pos time; +// /*! +// * \brief height of an event +// */ +// Element_pos height; +// /*! +// * \brief height of the container +// */ +// Element_pos container_height; +// }; + +// /*! +// * \brief Structure used to store arrow information. +// */ +// struct Arrow_{ +// /*! +// * \brief time when the arrow starts. +// */ +// Element_pos start_time; +// /*! +// * \brief time when the arrow ends. +// */ +// Element_pos end_time; +// /*! +// * \brief The start height of the arrow. +// */ +// Element_pos start_height; +// /*! +// * \brief The end height of the arrow. +// */ +// Element_pos end_height; +// }; /*! @@ -132,7 +134,7 @@ struct Selection_{ /*! * \brief This class redefined the OpenGL widget - QGLWidget - to display the trace. */ -class Hook_event : public QGLWidget/*, public Render*/ +class Hook_event : public QGLWidget, public Geometry { Q_OBJECT @@ -154,12 +156,12 @@ protected: /*! * \brief Contains arrow informations. */ - std::vector<Arrow_> _arrows; + // std::vector<Arrow_> _arrows; /*! * \brief Contains event informations. */ - std::vector<Event_> _events; + // std::vector<Event_> _events; /*! * \brief Contains the previous selection coordinates. @@ -313,187 +315,6 @@ protected: */ GLuint _list_ruler; - /*! - * \brief Used for draw counter. - */ - bool _line_already_begun; - - /*! - * \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 objects over the ruler. - */ - Element_pos _z_ruler_over; - - /*! - * \brief z position for objects under the ruler. - */ - Element_pos _z_ruler_under; - - /*! - * \brief z position for containers. - */ - Element_pos _z_container; - - /*! - * \brief z position for objects under containers. - */ - Element_pos _z_container_under; - - /*! - * z position for states. - */ - Element_pos _z_state; - - /*! - * z position for events. - */ - Element_pos _z_event; - - /*! - * z position for arrows. - */ - Element_pos _z_arrow; - - /*! - * z position for counters. - */ - Element_pos _z_counter; - - /*! - * Default offset of entities drawing. - */ - Element_pos _default_entity_x_translate; - - /*! - * Distance between two ruler measures. - */ - Element_pos _ruler_distance; - - /*! - * Height of the ruler. - */ - Element_pos _ruler_height; - - /*! - * Highness of the ruler. - */ - Element_pos _ruler_y; - - /*! - * Width of the ruler. - */ - Element_pos _ruler_width; - - /*! - * \brief The percentage taken by container display in the render area. - */ - Element_pos _x_scale_container_state; - - /*! - * \brief the x scale of state drawing. - */ - Element_pos _x_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. - */ - Element_pos _x_state_translate; - - /*! - * \brief The y position of camera view for state drawing area. - */ - Element_pos _y_state_translate; - - /*! - * \brief The x position of the horizontal scroll bar. - */ - Element_pos _x_scroll_pos; - - /*! - * \brief The y position of the vertical scroll bar. - */ - Element_pos _y_scroll_pos; - - /*********************************** * @@ -664,82 +485,6 @@ public: */ void apply_zoom_box(Element_pos x_min, Element_pos x_max, Element_pos y_min, Element_pos y_max); - - - /*********************************** - * - * Coordinate convert functions. - * - **********************************/ - - /*! - * \brief This function convert a X screen coordinate into render coordinate. - * \param e A X screen coordinate. - * \return A X render coordinate corresponding to e but in render area coordinate. - */ - Element_pos screen_to_render_x(Element_pos e); - - /*! - * \brief This function convert a Y screen coordinate into render coordinate. - * \param e A Y screen coordinate. - * \return A Y render coordinate corresponding to e but in render area coordinate. - */ - Element_pos screen_to_render_y(Element_pos e); - - /*! - * \brief This function convert a X render coordinate into trace coordinate. - * \param e A X render coordinate. - * \return A X trace coordinate corresponding to e but in trace coordinate. - */ - Element_pos render_to_trace_x(Element_pos e); - - /*! - * \brief This function convert a Y render coordinate into trace coordinate. - * \param e A Y render coordinate. - * \return A Y trace coordinate corresponding to e but in trace coordinate. - */ - Element_pos render_to_trace_y(Element_pos e); - - /*! - * \brief Dual of screen_to_render_x. - * \param e A X render coordinate. - * \return A X screen coordinate corresponding to e but in screen coordinate. - */ - Element_pos render_to_screen_x(Element_pos e); - - /*! - * \brief Dual of screen_to_render_y. - * \param e A Y render coordinate. - * \return A Y screen coordinate corresponding to e but in screen coordinate. - */ - Element_pos render_to_screen_y(Element_pos e); - - /*! - * \brief Dual of render_to_trace_x. - * \param e A X trace coordinate. - * \return A X render coordinate corresponding to e but in render area coordinate. - */ - Element_pos trace_to_render_x(Element_pos e); - - /*! - * \brief Dual of render_to_trace_y. - * \param e A Y trace coordinate. - * \return A Y render coordinate corresponding to e but in render area coordinate. - */ - Element_pos trace_to_render_y(Element_pos e); - - /*! - * \brief Return the coefficient used to convert from horizontal trace scale to the horizontal render scale by multiplication. - * \return A number with which an horizontal trace width number must be multiply to get its horizontal render width. - */ - Element_pos coeff_trace_render_x(); - - /*! - * \brief Return the coefficient used to convert from vertical trace scale to the vertical render scale by multiplication. - * \return A number with which a vertical trace height number must be multiply to get its vertical render height. - */ - Element_pos coeff_trace_render_y(); - }; diff --git a/src/render/Render_opengl.cpp b/src/render/Render_opengl.cpp index 31641f6a..b6e9b453 100644 --- a/src/render/Render_opengl.cpp +++ b/src/render/Render_opengl.cpp @@ -47,12 +47,14 @@ #include "common/common.hpp" #include "common/info.hpp" /* -- */ -#include "render/render.hpp" +//#include "render/render.hpp" #include "render/Hook_event.hpp" + #include "render/Render_opengl.hpp" /* -- */ #include "interface/resource.hpp" //#include "interface/interface.hpp" +#include "render/Render.hpp" #include "core/Core.hpp" /* -- */ @@ -72,9 +74,12 @@ using namespace std; * **********************************/ -Render_opengl::Render_opengl(Render_opengl* render, Core* core, QWidget *parent) - : Hook_event(render, core, parent){ +Render_opengl::Render_opengl(Core* core, QWidget *parent) + : Hook_event(this, core, parent){ + _arrows.clear(); + _circles.clear(); + _texts.clear(); setAutoFillBackground(false); } @@ -168,24 +173,58 @@ void Render_opengl::paintGL(){ static float a = 0; a ++; - glTranslated(0.0, _render_height, 100.0); + glTranslated(0.0, _render_height, 100.0); glRotated(180.0, 1.0, 0.0, 0.0); - /* Translate containers and entities of the ruler height */ - glTranslated(0.0, _ruler_height, 0.0); - - - display_container(0, 0); - display_state(0, 0, 0, 0, 0, 0); - if (false == Info::Render::_no_arrows)/* display arrows */ - display_arrow(0, 0, 0, 0, 0, 0); + // display_container(0, 0); + glPushMatrix(); + { + + /* Translate containers and entities of the ruler height */ + // glTranslated(0.0, _ruler_height, 0.0); + // 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(_x_scale_container_state/0.20, _y_state_scale, 1.0); + + if (glIsList(_list_containers) == GL_FALSE) + *Message::get_instance() << tr("ERROR LIST not exist for containers.").toStdString() << Message::ende; + else + glCallList(_list_containers); + } + glPopMatrix(); + + + glPushMatrix(); + { + glTranslated(-_x_state_translate, -_y_state_translate, 0.0); + glScalef(_x_state_scale, _y_state_scale, 1.0); + + if (glIsList(_list_states) == GL_FALSE) + *Message::get_instance() << tr("ERROR LIST not exist for states.").toStdString() << Message::ende; + else + glCallList(_list_states); + } + glPopMatrix(); + + draw_stored_arrows(); + draw_stored_circles(); + draw_stored_texts(); + + + +// display_state(0, 0, 0, 0, 0, 0); + +// if (false == Info::Render::_no_arrows)/* display arrows */ +// display_arrow(0, 0, 0, 0, 0, 0); - if (false == Info::Render::_no_events)/* display events */ - display_event(0, 0, 0, 0); +// if (false == Info::Render::_no_events)/* display events */ +// display_event(0, 0, 0, 0); - display_counter(0, 0, 0, 0); +// display_counter(0, 0, 0, 0); /* Untranslate ruler */ @@ -294,7 +333,7 @@ bool Render_opengl::build(){ if (NULL == _render_instance) return true; - return _render_instance->display_build(); + return true;//_render_instance->display_build(); } @@ -339,23 +378,27 @@ bool Render_opengl::unbuild(){ Info::Render::_ui_render_min_value->setText(""); Info::Render::_ui_render_max_value->setText(""); - _state_x_max = 0; + Info::Entity::x_max = 0; + Info::Entity::x_min = 0; + // _state_x_max = 0; _state_y_max = 0; - _state_x_min = 0; + // _state_x_min = 0; _state_y_min = 0; /* clear lists to store container texts */ _text_pos.clear(); _text_value.clear(); + _arrows.clear(); + _circles.clear(); + _texts.clear(); + /* clear the event vector */ - _events.clear(); + // _events.clear(); /* clear the arrow vector */ - _arrows.clear(); + // _arrows.clear(); - _line_already_begun = false; - /* empty the selection stack */ while(false == _previous_selection.empty()) _previous_selection.pop(); @@ -363,7 +406,7 @@ bool Render_opengl::unbuild(){ if (NULL == _render_instance) return true; - return _render_instance->display_unbuild(); + return true;//_render_instance->display_unbuild(); } @@ -793,3 +836,226 @@ void Render_opengl::call_ruler(){ } } + + +void Render_opengl::set_color(float r, float g, float b){ + _red = r; + _green = g; + _blue = b; +} + +void Render_opengl::draw_text(const Element_pos x, const Element_pos y, const Element_pos z, const std::string s){ + Container_text_ buf; + + buf.x = x; + buf.y = y; + buf.value = s; + + _texts.push_back(buf); +} + + +void Render_opengl::draw_quad(Element_pos x, Element_pos y, Element_pos z, Element_pos w, Element_pos h){ + + glBegin(GL_QUADS); + { + glColor3d(_red, _green, _blue); + glVertex3d(x, y, z); + glVertex3d(x, y + h, z); + glColor3d(_red/1.5, _green/1.5, _blue/1.5); + glVertex3d(x + w, y + h, z); + glVertex3d(x + w, y, z); + } + glEnd(); +} + +void Render_opengl::draw_triangle(Element_pos x, Element_pos y, + Element_pos size, Element_pos r){ +} + +void Render_opengl::draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2, Element_pos z){ + glBegin(GL_LINES); + { + glColor3d(_red, _green, _blue); + glVertex3d(x1, y1, z); + glVertex3d(x2, y2, z); + } + glEnd(); +} + +void Render_opengl::draw_circle(Element_pos x, Element_pos y, Element_pos z, Element_pos r){ + + Circle_ buf; + + buf.x = x; + buf.y = y; + buf.z = z; + buf.r = r; + + _circles.push_back(buf); +} + + +void Render_opengl::start_draw(){ + +} + +void Render_opengl::start_draw_containers(){ + _list_containers = glGenLists(1);/* create the list */ + if (_list_containers == 0) { + *Message::get_instance() << tr("Error when creating list.").toStdString() << Message::endw; + } + + glNewList(_list_containers, GL_COMPILE);/* open the list */ +} + +void Render_opengl::draw_container(const Element_pos x, const Element_pos y, const Element_pos w, const Element_pos h){ + +} + +void Render_opengl::draw_container_text(const Element_pos x, const Element_pos y, const std::string value){ +} + +void Render_opengl::end_draw_containers(){ + glEndList();/* close the list */ +} + +void Render_opengl::start_draw_states(){ + _list_states = glGenLists(1);/* create the list */ + if (_list_states == 0) { + *Message::get_instance() << tr("Error when creating list.").toStdString() << Message::endw; + } + + glNewList(_list_states, GL_COMPILE);/* open the list */ +} + +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){ +} + +void Render_opengl::end_draw_states(){ + +} + +void Render_opengl::start_draw_arrows(){ +} + +void Render_opengl::draw_arrow(const Element_pos start_time, const Element_pos end_time, const Element_pos start_height, const Element_pos end_height){ + + Arrow_ buf; + + buf.start_time = start_time; + buf.end_time = end_time; + buf.start_height = start_height; + buf.end_height = end_height; + + _arrows.push_back(buf); +} + +void Render_opengl::end_draw_arrows(){ +} + +void Render_opengl::draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height){ +} + +void Render_opengl::start_draw_counter(){ +} + +void Render_opengl::draw_counter(const Element_pos x, const Element_pos y){ +} + +void Render_opengl::end_draw_counter(){ +} + +void Render_opengl::end_draw(){ + glEndList();/* close the states list */ +} + + +void Render_opengl::draw_stored_texts(){ + + glColor3d(1, 1, 1); + for (unsigned int i=0 ; i<_texts.size() ; i++){ + + glPushMatrix(); + { + + glRasterPos2f(_texts[i].x * _x_scale_container_state/0.20, /* 0.20 is the default value of _x_scale_container_state */ + _texts[i].y*_y_state_scale - _y_state_translate); + // std::cout << __FILE__ << " " << __LINE__ << " " << _texts[i].x << std::endl; + + 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); + 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); + if(length > size_of_container){ + break; + }*/ + glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, letter); + } + } + glPopMatrix(); + } +} + +void Render_opengl::draw_stored_arrows(){ + + /* Only draw triangle. Lines are already in a display list */ + const Element_pos coeff = 180.0f/M_PI; + Element_pos angle; + Element_pos start_time, end_time, start_height, end_height; + + + for (unsigned int i=0 ; i<_arrows.size() ; i++){ + + start_time = _arrows[i].start_time; + end_time = _arrows[i].end_time; + start_height = _arrows[i].start_height; + end_height = _arrows[i].end_height; + + glPushMatrix(); + { + + glTranslated(_x_state_scale*end_time - _x_state_translate, _y_state_scale*end_height - _y_state_translate, _z_arrow); + + if (start_time != end_time){ + angle = atan2((end_height - start_height), (end_time - start_time))*coeff;/* arc tangent */ + glRotatef(angle, 0, 0, 1); + } + else + glRotatef(90, 0, 0, 1);/* vertical alignment */ + + glBegin(GL_TRIANGLES); + { + glColor3d(_red, _green, _blue); + glVertex2d(0.0, 0.0); + glVertex2d(-1.2, -0.4); + glVertex2d(-1.2, 0.4); + } + glEnd(); + } + glPopMatrix(); + } +} + +void Render_opengl::draw_stored_circles(){ + const int step = 20;/* 20 polygons for the circle */ + const float angle = M_PI/2.0f; + const float delta_angle = 2*M_PI/step; + + for (unsigned int i=0 ; i<_circles.size() ; i++){ + + glBegin(GL_POLYGON); + { + glColor3d(_red, _green, _blue); + for(int i = 0 ; i < step ; i ++){ + glVertex3d(_circles[i].x + cos(angle+delta_angle*i)*_circles[i].r , + _circles[i].y + sin(angle+delta_angle*i)*_circles[i].r , + _circles[i].z); + } + } + glEnd(); + } +} + diff --git a/src/render/Render_opengl.hpp b/src/render/Render_opengl.hpp index 312399e7..914e6c43 100644 --- a/src/render/Render_opengl.hpp +++ b/src/render/Render_opengl.hpp @@ -50,16 +50,39 @@ #include <QGLWidget> #include "core/Core.hpp" -#include "render/render.hpp" #include "render/Hook_event.hpp" +#include "render/Render_template.hpp" class Render_opengl; class Interface_console; +struct Container_text_; + + +/*! + * \brief Structure used to store arrow information. + */ +struct Arrow_{ + /*! + * \brief Coordinates. + */ + Element_pos start_time, end_time, start_height, end_height; +}; + +/*! + * \brief Structure used to store circle information. + */ +struct Circle_{ + /*! + * \brief Coordinates and radius. + */ + Element_pos x, y, z, r; +}; + /*! * \brief This class redefined the OpenGL widget - QGLWidget - to display the trace. */ -class Render_opengl : /*public QGLWidget,*/ public Hook_event, public Render +class Render_opengl : /*public QGLWidget,*/ public Hook_event, public Render_template { Q_OBJECT @@ -100,7 +123,12 @@ protected: * \brief The wait GLu list. */ // GLuint _wait_list; + + float _red, _green, _blue; + std::vector<Container_text_> _texts; + std::vector<Arrow_> _arrows; + std::vector<Circle_> _circles; public: @@ -114,7 +142,7 @@ public: /*! * \brief The default constructor */ - Render_opengl(Render_opengl* render, Core* core, QWidget *parent); + Render_opengl(Core* core, QWidget *parent); /*! * \brief The destructor @@ -171,22 +199,22 @@ public: /*! * \brief This function constructs the trace. */ - virtual bool display_build() =0; + // bool display_build() ; /*! * \brief This function releases the trace. */ - virtual bool display_unbuild() =0; + // bool display_unbuild() ; /*! * \brief Proceeds with the initialization of the OpenGL draw functions. */ - virtual void start_draw() =0; + void start_draw(); /*! * \brief Creates and opens the display list for container draws. */ - virtual void start_draw_containers() =0; + void start_draw_containers(); /*! * \brief Draw a container according to the parameters @@ -195,7 +223,7 @@ public: * \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; + 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. @@ -205,17 +233,17 @@ public: * * This function stores text in a list. This list will be display each time the render area need to be updated. */ - virtual void draw_container_text(const Element_pos x, const Element_pos y, const std::string value) =0; + void draw_container_text(const Element_pos x, const Element_pos y, const std::string value); /*! * \brief Closes the container display list. */ - virtual void end_draw_containers() =0; + void end_draw_containers(); /*! * \brief Creates and opens the display list for stater draws. */ - virtual void start_draw_states() =0; + void start_draw_states(); /*! * \brief Draw a state of the trace. @@ -227,17 +255,17 @@ public: * \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; + 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. */ - virtual void end_draw_states() =0; + void end_draw_states(); /*! * \brief Open the arrow display list. */ - virtual void start_draw_arrows() =0; + void start_draw_arrows(); /*! * \brief Draw an arrow. @@ -248,18 +276,18 @@ public: * * This function stores all the information of the arrow to display it each time the render area need to be updated. */ - 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; + 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. */ - virtual void end_draw_arrows() =0; + void end_draw_arrows(); /*! * \brief Draw arrows contained in the Arrow_ vector * \param arrows An arrow vector. */ - virtual void draw_stored_arrows(std::vector<Arrow_> &arrows) =0; + // void draw_stored_arrows(std::vector<Arrow_> &arrows); /*! * \brief Draw an event. @@ -267,20 +295,23 @@ public: * \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. * + * + * \brief Creates and opens the display list for container draws. + * * This function stores all the information of the event to display it each time the render area need to be updated. */ - virtual void draw_event(const Element_pos time, const Element_pos height, const Element_pos container_height) =0; + 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. */ - virtual void draw_stored_events(std::vector<Event_> &events) =0; + // void draw_stored_events(std::vector<Event_> &events); /*! * \brief Creates and opens the display list for counter draws. */ - virtual void start_draw_counter() =0; + void start_draw_counter(); /*! * \brief Draw a point of the counter. @@ -289,17 +320,17 @@ public: * * 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; + void draw_counter(const Element_pos x, const Element_pos y); /*! * \brief Closes the counter display list. */ - virtual void end_draw_counter() =0; + void end_draw_counter(); /*! * \brief Do nothing (it is present for compatibility of the Render class). */ - virtual void end_draw() =0; + void end_draw(); @@ -350,65 +381,126 @@ public: * **********************************/ + // /*! +// * \brief Display on screen containers between container_begin and container_end. +// * \param container_begin integer value : id of the first container. +// * \param container_end integer value : id of the last container. +// */ +// void display_container(Element_count container_begin, Element_count container_end) =0; + +// /*! +// * \brief Display on screen states between timer_begin and time_end, +// * container_begin and container_end and with timer width between depth_begin and depth_end. +// * \param time_begin floating point value : time of the first state. +// * \param time_end floating point value : time of the last state. +// * \param container_begin integer value : id of the first container. +// * \param container_end integer value : id of the last container. +// * \param depth_begin floating point value : width of the narrowest state. +// * \param depth_end floating point value : width of the widest state. +// */ +// void display_state(Element_pos time_begin, Element_pos time_end, +// Element_count container_begin, Element_count container_end, +// Element_pos depth_begin, Element_pos depth_end) =0; + +// /*! +// * \brief Display on screen arrows between timer_begin and time_end, +// * container_begin and container_end and with timer width between depth_begin and depth_end. +// * \param time_begin floating point value : time of the smallest arrow time value. +// * \param time_end floating point value : time of the higher arrow time value. +// * \param container_begin integer value : id of the first container. +// * \param container_end integer value : id of the last container. +// * \param depth_begin floating point value : the narrowest difference between +// * the beginning time and the ending time of the arrow. +// * \param depth_end floating point value : width of the widest difference between +// * the beginning time and the ending time of the arrow. +// */ +// virtual void display_arrow(Element_pos time_begin, Element_pos time_end, +// Element_count container_begin, Element_count container_end, +// Element_pos depth_begin, Element_pos depth_end) =0; + +// /*! +// * \brief Display on screen events between timer_begin and time_end, +// * container_begin and container_end. +// * \param time_begin floating point value : time of the first event. +// * \param time_end floating point value : time of the last event. +// * \param container_begin integer value : id of the first container. +// * \param container_end integer value : id of the last container. +// */ +// virtual void display_event(Element_pos time_begin, Element_pos time_end, +// Element_count container_begin, Element_count container_end) =0; + +// /*! +// * \brief Display on screen counters between timer_begin and time_end, +// * container_begin and container_end. +// * \param time_begin floating point value : time of the smallest counter time value. +// * \param time_end floating point value : time of the higher counter time value. +// * \param container_begin integer value : id of the first container. +// * \param container_end integer value : id of the last container. +// */ +// virtual void display_counter(Element_pos time_begin, Element_pos time_end, +// Element_count container_begin, Element_count container_end) =0; + /*! - * \brief Display on screen containers between container_begin and container_end. - * \param container_begin integer value : id of the first container. - * \param container_end integer value : id of the last container. + * \brief Set the color for the further drawings. + * \param r the red value. Within [0 ; 1]. + * \param g the green value. Within [0 ; 1]. + * \param b the blue value. Within [0 ; 1]. */ - virtual void display_container(Element_count container_begin, Element_count container_end) =0; + void set_color(float r, float g, float b); /*! - * \brief Display on screen states between timer_begin and time_end, - * container_begin and container_end and with timer width between depth_begin and depth_end. - * \param time_begin floating point value : time of the first state. - * \param time_end floating point value : time of the last state. - * \param container_begin integer value : id of the first container. - * \param container_end integer value : id of the last container. - * \param depth_begin floating point value : width of the narrowest state. - * \param depth_end floating point value : width of the widest state. + * \brief Draw a text. + * \param x the horizontal position of the left bottom corner of the text. + * \param y the vertical position of the left bottom corner of the text. + * \param z the deep position of the text. + * \param s the text. */ - virtual void display_state(Element_pos time_begin, Element_pos time_end, - Element_count container_begin, Element_count container_end, - Element_pos depth_begin, Element_pos depth_end) =0; + virtual void draw_text(const Element_pos x, const Element_pos y, const Element_pos z, const std::string s); /*! - * \brief Display on screen arrows between timer_begin and time_end, - * container_begin and container_end and with timer width between depth_begin and depth_end. - * \param time_begin floating point value : time of the smallest arrow time value. - * \param time_end floating point value : time of the higher arrow time value. - * \param container_begin integer value : id of the first container. - * \param container_end integer value : id of the last container. - * \param depth_begin floating point value : the narrowest difference between - * the beginning time and the ending time of the arrow. - * \param depth_end floating point value : width of the widest difference between - * the beginning time and the ending time of the arrow. + * \brief Draw a quad. + * \param x the horizontal position of the left bottom corner of the quad. + * \param y the vertical position of the left bottom corner of the quad. + * \param z the deep position of the quad. + * \param w the width of the quad. + * \param h the height of the quad. */ - virtual void display_arrow(Element_pos time_begin, Element_pos time_end, - Element_count container_begin, Element_count container_end, - Element_pos depth_begin, Element_pos depth_end) =0; + void draw_quad(Element_pos x, Element_pos y, Element_pos z, Element_pos w, Element_pos h); /*! - * \brief Display on screen events between timer_begin and time_end, - * container_begin and container_end. - * \param time_begin floating point value : time of the first event. - * \param time_end floating point value : time of the last event. - * \param container_begin integer value : id of the first container. - * \param container_end integer value : id of the last container. + * \brief Draw a triangle. + * \param x the horizontal position of the triangle center. + * \param y the vertical position of the triangle center. + * \param size the edge size. + * \param r the rotation of triangle. (clockwise and in degree) */ - virtual void display_event(Element_pos time_begin, Element_pos time_end, - Element_count container_begin, Element_count container_end) =0; + void draw_triangle(Element_pos x, Element_pos y, + Element_pos size, Element_pos r); + + /*! + * \brief Draw a line. + * \param x1 the horizontal position of the first point. + * \param y1 the vertical position of the firt point. + * \param x2 the horizontal position of the second point. + * \param y2 the vertical position of the second point. + * \param z the deep position of the triangle. + */ + void draw_line(Element_pos x1, Element_pos y1, Element_pos x2, Element_pos y2, Element_pos z); /*! - * \brief Display on screen counters between timer_begin and time_end, - * container_begin and container_end. - * \param time_begin floating point value : time of the smallest counter time value. - * \param time_end floating point value : time of the higher counter time value. - * \param container_begin integer value : id of the first container. - * \param container_end integer value : id of the last container. + * \brief Draw a circle. + * \param x the horizontal position of the circle center. + * \param y the vertical position of the circle center. + * \param z the deep position of the circle. + * \param r the circle radius. */ - virtual void display_counter(Element_pos time_begin, Element_pos time_end, - Element_count container_begin, Element_count container_end) =0; - + void draw_circle(Element_pos x, Element_pos y, Element_pos z, Element_pos r); + + /* Temporary methods. Use to draw stored arrows and circles. It is to prevent scaling */ + void draw_stored_arrows(); + void draw_stored_circles(); + + void draw_stored_texts(); }; diff --git a/src/render/Render_opengl_dl.hpp b/src/render/Render_opengl_dl.hpp index aab63af6..82e73fec 100644 --- a/src/render/Render_opengl_dl.hpp +++ b/src/render/Render_opengl_dl.hpp @@ -79,6 +79,12 @@ protected: */ GLuint _wait_list; + + /*! + * \brief Used to draw counter. + */ + bool _start_new_line; + public: /*********************************** @@ -308,6 +314,16 @@ public: void display_counter(Element_pos time_begin, Element_pos time_end, Element_count container_begin, Element_count container_end); + + void set_color(float, float, float){} + void draw_quads(Element_pos, Element_pos, Element_pos, Element_pos, Element_pos){} + void draw_text(Element_pos, Element_pos, Element_pos, std::string){} + void draw_triangle(Element_pos, Element_pos, Element_pos, + Element_pos, Element_pos, Element_pos, + Element_pos, Element_pos, Element_pos){} + void draw_line(Element_pos, Element_pos, Element_pos, + Element_pos, Element_pos, Element_pos){} + void draw_circle(Element_pos, Element_pos, Element_pos, Element_pos){} }; @@ -709,40 +725,43 @@ inline void Render_opengl_dl::start_draw_counter(){ } glNewList(_list_counters, GL_COMPILE);/* open the list */ + _start_new_line = true; } inline void Render_opengl_dl::draw_counter(const Element_pos x, const Element_pos y){ - if (x <= 0.0){ - if (_line_already_begun){/* it is not the first call */ - glColor3d(1.0, 1.0, 1.0);glVertex2d(_state_x_max, _counter_last_y); - glEnd(); - }else - _line_already_begun = true; + if (_start_new_line){/* Start a new line */ glBegin(GL_LINE_STRIP);/* set of connected verteces */ glColor3d(1.0, 1.0, 1.0);glVertex2d(0.0, y);/* draw the init point */ + + _counter_last_x = x; + _counter_last_y = y; + _start_new_line = false; - _counter_last_x = 0.0; - - } - else { + }else{/* line is already started */ - glColor3d(1.0, 1.0, 1.0);glVertex2d(x, _counter_last_y); - glColor3d(1.0, 1.0, 1.0);glVertex2d(x, y); + if (x <= 0.0){/* convention: the line is over */ - _counter_last_x = x; - } + glColor3d(1.0, 1.0, 1.0);glVertex2d(_state_x_max, _counter_last_y); + glEnd(); + _start_new_line = true; + }else{/* add new points to the line */ - _counter_last_y = y; + glColor3d(1.0, 1.0, 1.0);glVertex2d(x, _counter_last_y); + glColor3d(1.0, 1.0, 1.0);glVertex2d(x, y); + _counter_last_x = x; + _counter_last_y = y; + } + } } inline void Render_opengl_dl::end_draw_counter(){ - if (_line_already_begun) {/* if a line was previously opened */ + if (!_start_new_line) {/* if a line was previously opened */ glEnd();/* suppose that line is not ended */ } glEndList();/* close the list */ diff --git a/src/render/render_svg.hpp b/src/render/render_svg.hpp index 3e56c31f..65594bda 100644 --- a/src/render/render_svg.hpp +++ b/src/render/render_svg.hpp @@ -49,7 +49,7 @@ /*! * \brief This class provides a SVG display ,it inherited from the Render interface. */ -class Svg : public Render{ +class Svg{ private: diff --git a/src/src.pro b/src/src.pro index 84d8d129..a46cf1fa 100644 --- a/src/src.pro +++ b/src/src.pro @@ -83,11 +83,13 @@ HEADERS += common/common.hpp \ # Core header core/Core.hpp \ # Render headers + render/Render.hpp \ render/render.hpp \ + render/Geometry.hpp \ render/Hook_event.hpp \ - render/Render_opengl_dl.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 \ @@ -187,9 +189,10 @@ SOURCES += common/Message.cpp \ parser/ParserEventOTF.cpp \ parser/ParserOTF.cpp \ # Render code files + render/Geometry.cpp \ render/Hook_event.cpp \ 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/trace/Container.cpp b/src/trace/Container.cpp index 91fdedd3..1e5eaa2a 100644 --- a/src/trace/Container.cpp +++ b/src/trace/Container.cpp @@ -55,6 +55,9 @@ /* -- */ #include "statistics/Statistic.hpp" /* -- */ +#include "common/common.hpp" +#include "common/info.hpp" +/* -- */ using namespace std; @@ -154,7 +157,8 @@ void Container::new_event(Date time, EventType *type, EntityValue *value, map<st _n_events++; } -void Container::start_link(Date time, LinkType *type, Container *source, EntityValue *value, String key, map<string, Value *> &opt) { + +void Container::start_link(Date time, LinkType *type, Container *source, EntityValue *value, String key, map<std::string, Value *> &opt) { current_link_t t(time, type, source, value, opt); _current_links[key] = t; } @@ -203,6 +207,7 @@ void Container::add_variable(Date time, VariableType *type, Double value) { else { (*i).second->add_value(time, (*i).second->get_last_value() + value); } + } void Container::sub_variable(Date time, VariableType *type, Double value) { diff --git a/src/trace/DrawTrace.hpp b/src/trace/DrawTrace.hpp index cbdf9b78..e3827f49 100644 --- a/src/trace/DrawTrace.hpp +++ b/src/trace/DrawTrace.hpp @@ -94,7 +94,7 @@ * \class DrawTrace * \brief Browse the trace and call back T drawing methods */ -template<class T> +/*template<class T>*/ class DrawTrace { @@ -190,6 +190,7 @@ public: * \param draw_object the kind of object which will be drawn (OpenGL, SVG...). * \param trace the trace data. */ + template<class T> void build(T* draw_object, Trace* trace) { double zoom = trace->get_filter(); Interval * interval;// = trace->get_interval_constrained(); @@ -261,6 +262,7 @@ public: * \fn browse_container_tree(T* draw_object, Trace* trace, std::vector<Container *> container) * \brief Function that browses the containers of the trace argument that are in the set container and make them painted with a T object */ + template<class T> inline void browse_container_tree(T* draw_object, Trace* trace, std::vector< const Container *> *container){ /*** Drawing containers ***/ int position = 0; @@ -284,6 +286,7 @@ public: * \brief Recursive function that browse a container to draw it if it is in the set of container with a T painting object in position, knowing the current depth in the tree */ + template<class T> int browse_container(T* draw_object, const Container *container, int position, int depth, std::vector< const Container *> *set_container) { int size = 0; @@ -332,6 +335,7 @@ public: * \param depth Depth of container in the tree * \param text Name of the container */ + template<class T> inline void draw_container(T* draw_object, int position, int size, int depth, const std::string &text) { Element_pos x = depth*(_container_width+_container_h_space) + _container_h_space/2; Element_pos y = position*(_container_height+_container_v_space) + _container_v_space/2; @@ -342,6 +346,7 @@ public: /*! * \brief Browse the states list and draw them */ + template<class T> inline void browse_entities(T* draw_object, double zoom, Interval* interval, std::vector<const Container *> *set_container) { ////////////////////////////////////////////////////////// const Container *container; @@ -467,6 +472,7 @@ public: * \param value Value of of the variable (between 0.0 and 1.0) * \param position Line where the variable is drawn */ + template<class T> inline void draw_variable_value(T *draw_object, double time, double value, int position) { Element_pos y = (position+1)*(_container_height+_container_v_space) - _container_v_space/2 - value*_container_height; @@ -481,6 +487,7 @@ public: * \param start Line of the start of the link * \param end Line of the end of the link */ + template<class T> inline void draw_link(T *draw_object, double starttime, double endtime, double start, double end) { Element_pos y1 = (start+0.5)*(_container_height+_container_v_space); Element_pos y2 = (end+0.5)*(_container_height+_container_v_space); diff --git a/src/trace/DrawTree.hpp b/src/trace/DrawTree.hpp index efd594eb..b7a7c3f5 100644 --- a/src/trace/DrawTree.hpp +++ b/src/trace/DrawTree.hpp @@ -52,6 +52,9 @@ #include <iostream> */ + + + /*! * \class DrawTree * \brief Class called to draw a binary tree of type E using a D painting object diff --git a/src/trace/values/Date.cpp b/src/trace/values/Date.cpp index 58c4bbeb..cdb98a8d 100644 --- a/src/trace/values/Date.cpp +++ b/src/trace/values/Date.cpp @@ -46,14 +46,25 @@ #include <iomanip> // For std::setprecision /* -- */ #include "common/Tools.hpp" +#include "common/common.hpp" +#include "common/info.hpp" /* -- */ #include "trace/values/Value.hpp" #include "trace/values/Date.hpp" +#include <iostream> + Date::Date() : _value(0.0) { } Date::Date(double value) : _value(value) { + + 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){ @@ -61,6 +72,7 @@ bool Date::instantiate(const std::string &in, Date &out){ value = convert_to_double(in); + if(value != -1.) { out = Date(value); return true; diff --git a/tests/render/Makefile b/tests/render/Makefile new file mode 100644 index 00000000..f2570d95 --- /dev/null +++ b/tests/render/Makefile @@ -0,0 +1,10 @@ +render_test: main.cpp Render.hpp Render_opengl.hpp Trace.hpp + g++ -c Render.hpp -o Render.o + g++ -c Render_opengl.hpp -o Render_opengl.o + g++ -c Trace.hpp -o Trace.o + g++ main.cpp -o render_test -LRender.o -LRender_opengl.o -LTrace.o + +clean: + rm *.o + rm render_test + rm *~ \ No newline at end of file diff --git a/tests/render/Render.hpp b/tests/render/Render.hpp new file mode 100644 index 00000000..237d33ac --- /dev/null +++ b/tests/render/Render.hpp @@ -0,0 +1,24 @@ +#ifndef RENDER_HPP +#define RENDER_HPP + +#include<iostream> + + +template<class T> +class Render{ + + T* render_instance; +public: + Render(T* instance){ + std::cout << "Render constructor" << std::endl; + render_instance = instance; + } + + void draw(){ + std::cout << "Render draw" << std::endl; + render_instance->drawRect(); + } + +}; + +#endif diff --git a/tests/render/Render_opengl.hpp b/tests/render/Render_opengl.hpp new file mode 100644 index 00000000..cbcbc697 --- /dev/null +++ b/tests/render/Render_opengl.hpp @@ -0,0 +1,18 @@ +#ifndef RENDER_OPENGL_HPP +#define RENDER_OPENGL_HPP +#include<iostream> + + +class Render_opengl{ +public: + Render_opengl(){ + std::cout << "Render_opengl constructor" << std::endl; + } + + void drawRect(){ + std::cout << "Render_opengl drawRect" << std::endl; + } + +}; + +#endif diff --git a/tests/render/Trace.hpp b/tests/render/Trace.hpp new file mode 100644 index 00000000..03b40e6d --- /dev/null +++ b/tests/render/Trace.hpp @@ -0,0 +1,21 @@ +#ifndef TRACE_HPP +#define TRACE_HPP + +#include "Render.hpp" +#include "Render_opengl.hpp" + +class Trace{ +public: + Trace(){ + std::cout << "Trace constructor" << std::endl; + } + + template <class B> + void build(B r){ + std::cout << "Trace build" << std::endl; + r.draw(); + } + +}; + +#endif diff --git a/tests/render/main.cpp b/tests/render/main.cpp new file mode 100644 index 00000000..58bf1ce8 --- /dev/null +++ b/tests/render/main.cpp @@ -0,0 +1,18 @@ +#include<cstdio> +#include<cstdlib> + +#include "Trace.hpp" +#include "Render.hpp" +#include "Render_opengl.hpp" + + + +int main(int argc, char** argv){ + + Render<Render_opengl> r(new Render_opengl()); + Trace t; + + t.build(r); + + return EXIT_SUCCESS; +} -- GitLab