From c62734ef59524c7e6fffd7c6f85ed0c69dd98fa7 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Wed, 6 Sep 2006 17:09:07 +0000 Subject: [PATCH] - Quick hack to the code of SimulationWidget to draw the interval [a, b) of History (where b is the front), instead than (a, b]. - TODO: SimulationWidget would sincerely benefit from some more comments in the code git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1027 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/simulation_widget.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/simulation_widget.cc b/src/simulation_widget.cc index eead754..5ccb854 100644 --- a/src/simulation_widget.cc +++ b/src/simulation_widget.cc @@ -223,7 +223,7 @@ SimulationWidget::draw_grid(cairo_t* ctx) // useful constants const History& hist = _simulation->get_history(); - const unsigned int hist_front = hist.get_front(); + const unsigned int hist_front = hist.get_front() == 0 ? 0 : hist.get_front() - 1; const double top_margin = _yu_top_margin * _y_unit; // const double left_margin = _x_unit; const double left_graph_margin = _xu_left_graph_margin * _x_unit; @@ -302,7 +302,7 @@ SimulationWidget::draw_bars(cairo_t* ctx) // useful constants const History& hist = _simulation->get_history(); - const unsigned int hist_front = hist.get_front(); + unsigned int hist_front = hist.get_front(); const double top_margin = _yu_top_margin * _y_unit; // const double left_margin = _x_unit; const double left_graph_margin = _xu_left_graph_margin * _x_unit; @@ -328,6 +328,13 @@ SimulationWidget::draw_bars(cairo_t* ctx) from_time = 1; } + // We draw the interval [0, front) + // so if front <= 1, we've nothing to draw + if(hist_front <= 1) + return; + else + hist_front--; + #ifndef NDEBUG std::cout << " SimulationWidget::draw_bars from:" << from_time << " to:" << hist_front << std::endl; #endif