From f01bb177b7049b50ea42154f940553ebd9323dd7 Mon Sep 17 00:00:00 2001 From: Camille Ordronneau <camille.ordronneau@inria.fr> Date: Mon, 29 Jul 2024 13:57:46 +0200 Subject: [PATCH] Remove Info::Container This fixes container names not being displayed at the right height when several traces were displayed Because there was only one "container max y" variable for every render --- src/common/Info.cpp | 13 --------- src/common/Info.hpp | 32 --------------------- src/interface/Interface_graphic.cpp | 3 -- src/render/GanttDiagram.hpp | 43 +++++++++++++++++------------ src/render/Geometry.cpp | 3 +- src/render/Geometry.hpp | 6 ++++ src/render/opengl/Render_opengl.cpp | 3 ++ src/render/vbo/Render_alternate.cpp | 3 ++ src/trace/DrawTrace.cpp | 1 - 9 files changed, 40 insertions(+), 67 deletions(-) diff --git a/src/common/Info.cpp b/src/common/Info.cpp index 418a1cce..7ff25c6f 100644 --- a/src/common/Info.cpp +++ b/src/common/Info.cpp @@ -26,11 +26,6 @@ using namespace std; unsigned int Info::Screen::width = 800; unsigned 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::Render::width = 100; /* 100 OpenGL units for 1 pixel */ Element_pos Info::Render::height = 100; /* 100 OpenGL units for 1 pixel */ @@ -53,11 +48,3 @@ std::string Info::Splitter::filename; std::string Info::Splitter::xml_filename; Element_pos Info::Splitter::_x_min = 0.0; Element_pos Info::Splitter::_x_max = 0.0; - -void Info::release_all() { - - Info::Container::x_min = 0; - Info::Container::x_max = 0; - Info::Container::y_min = 0; - Info::Container::y_max = 0; -} diff --git a/src/common/Info.hpp b/src/common/Info.hpp index 369b77d0..eef201ee 100644 --- a/src/common/Info.hpp +++ b/src/common/Info.hpp @@ -42,11 +42,6 @@ public: */ virtual ~Info(); - /*! - * \brief Release all Info class attributes. - */ - static void release_all(); - /*! * \brief Sub structure to store screen information. */ @@ -64,33 +59,6 @@ public: static unsigned int height; }; - /*! - * \brief Sub structure to store container information. - */ - struct Container - { - - /*! - * \brief Minimum x position. - */ - static Element_pos x_min; - - /*! - * \brief Maximum x position. - */ - static Element_pos x_max; - - /*! - * \brief Minimum y position. - */ - static Element_pos y_min; - - /*! - * \brief Maximum y position. - */ - static Element_pos y_max; - }; - /*! * \brief Sub structure to store render area information. */ diff --git a/src/interface/Interface_graphic.cpp b/src/interface/Interface_graphic.cpp index 54417ad9..23afdf43 100644 --- a/src/interface/Interface_graphic.cpp +++ b/src/interface/Interface_graphic.cpp @@ -1146,9 +1146,6 @@ void Interface_graphic::release_render_area() { _render_layouts.front()->delete_trace(); } get_render_area()->update_render(); - - /* Release all data */ - Info::release_all(); } void Interface_graphic::redraw_trace() { diff --git a/src/render/GanttDiagram.hpp b/src/render/GanttDiagram.hpp index 335feed8..b9efc4f9 100644 --- a/src/render/GanttDiagram.hpp +++ b/src/render/GanttDiagram.hpp @@ -66,6 +66,16 @@ private: */ bool _start_new_line; + /*! + * \brief Containers minimum x position + */ + Element_pos _container_max_x; + + /*! + * \brief Containers minimum y position + */ + Element_pos _container_min_y; + std::vector<Container_> _containers; std::vector<Container_text_> _container_texts; @@ -85,10 +95,11 @@ public: /*! * \brief The default constructor */ - GanttDiagram(Render *instance) { - _render = instance; - _start_new_line = false; - } + GanttDiagram(Render *instance) : + _render(instance), + _start_new_line(false), + _container_max_x(0), + _container_min_y(0) { } /*! * \brief The destructor @@ -147,22 +158,20 @@ public: _container_texts.push_back(buft); - if ((x + w) > Info::Container::x_max) - Info::Container::x_max = x + w; + if ((x + w) > _container_max_x) + _container_max_x = x + w; - if ((y + h) > Info::Container::y_max) - Info::Container::y_max = y + h; - - if (Info::Container::x_min > x) - Info::Container::x_min = x; + if ((y + h) > _trace_height) { + _trace_height = y + h; + } - if (Info::Container::y_min > y) - Info::Container::y_min = y; + if (_container_min_y > y) + _container_min_y = 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: " << Info::Container::x_max << " - " << Info::Container::x_min << " ymax-ymin: " << Info::Container::y_max << " - " << Info::Container::y_min << std::endl; + std::cerr << "x: " << x << " y: " << y << " w: " << w << " h: " << h << " xmax: " << _container_max_x << " ymax-ymin: " << _container_max_y << " - " << _container_min_y << std::endl; #endif } @@ -187,10 +196,10 @@ public: */ inline void end_draw_containers() { static float j = 0.6f; - float coeffx = (Info::Render::width / Info::Container::x_max) * _x_scale_container_state; - float coeffy = ((Info::Render::height - _ruler_height) / Info::Container::y_max) * _y_state_scale; + float coeffx = (Info::Render::width / _container_max_x) * _x_scale_container_state; + float coeffy = ((Info::Render::height - _ruler_height) / (_trace_height - _container_min_y)) * _y_state_scale; - /* Before calling start_draw_container(), Info::Container::y_max should have a correct value */ + /* Before calling start_draw_container(), _container_max_y should have a correct value */ _render->start_draw_containers(); for (const auto &_container: _containers) { diff --git a/src/render/Geometry.cpp b/src/render/Geometry.cpp index f1042fcb..98c4bcf9 100644 --- a/src/render/Geometry.cpp +++ b/src/render/Geometry.cpp @@ -92,6 +92,7 @@ void Geometry::init_geometry() { _min_visible_time = 0; _max_visible_time = 0; _trace_length = 1; /* Default value can't be 0 because we divide by it so 1 was chosen */ + _trace_height = 1; /* Default value can't be 0 because we divide by it so 1 was chosen */ } void Geometry::set_trace_length(float new_trace_length) { @@ -162,7 +163,7 @@ Element_pos Geometry::coeff_trace_render_x() const { Element_pos Geometry::coeff_trace_render_y() const { - return ((Info::Render::height - _ruler_height) * _y_state_scale) / (Info::Container::y_max - Info::Container::y_min); + return ((Info::Render::height - _ruler_height) * _y_state_scale) / _trace_height; } void Geometry::update_visible_interval_value() { diff --git a/src/render/Geometry.hpp b/src/render/Geometry.hpp index eb2b2238..80831bc2 100644 --- a/src/render/Geometry.hpp +++ b/src/render/Geometry.hpp @@ -203,6 +203,12 @@ protected: */ Element_pos _max_visible_time; + /** + * \brief Height of the trace on which Geometry works on + * Used for coeff_trace_render_y to convert trace y coordinate into render y coordinate + */ + Element_pos _trace_height; + /*********************************** * * Constructor and destructor. diff --git a/src/render/opengl/Render_opengl.cpp b/src/render/opengl/Render_opengl.cpp index 1f7f24a5..2d5746c5 100644 --- a/src/render/opengl/Render_opengl.cpp +++ b/src/render/opengl/Render_opengl.cpp @@ -740,6 +740,9 @@ void Render_opengl::draw_quad(Element_pos x, Element_pos y, Element_pos /*z*/, E if (!_draw_container) offset_x = -_default_entity_x_translate; + else if (_trace_height < y + h) { + _trace_height = y + h; + } glBegin(GL_QUADS); { diff --git a/src/render/vbo/Render_alternate.cpp b/src/render/vbo/Render_alternate.cpp index 3148fc74..234ee95c 100644 --- a/src/render/vbo/Render_alternate.cpp +++ b/src/render/vbo/Render_alternate.cpp @@ -905,6 +905,9 @@ void Render_alternate::draw_quad(Element_pos x, Element_pos y, Element_pos z, El _containers.add((x + w) + offset_x, (y + h) + offset_y, _r, _g, _b); _containers.add(x + offset_x, (y + h) + offset_y, _r, _g, _b); _containers.add(x + offset_x, y + offset_y, _r, _g, _b); + if (_trace_height < y + h) { + _trace_height = y + h; + } } else if (_draw_states) { offset_x = -_default_entity_x_translate; diff --git a/src/trace/DrawTrace.cpp b/src/trace/DrawTrace.cpp index 78d7151f..2fb24410 100644 --- a/src/trace/DrawTrace.cpp +++ b/src/trace/DrawTrace.cpp @@ -405,7 +405,6 @@ void DrawTrace::add(std::vector<const Container *> *container, std::stack<Contai } void DrawTrace::build(GanttDiagram *draw_object, Trace *trace) { - Info::Container::y_max = 0; // reset the vertical zoom when rebuilding double zoom = trace->get_filter(); Interval *interval; // = trace->get_interval_constrained(); // clear entities -- GitLab