- fixed redrawing bug
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1014 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
3e35ed278f
commit
51ce976d65
|
@ -94,6 +94,8 @@ SimulationWidget::SimulationWidget(Simulation& simulation)
|
|||
_running_process_gradient = 0;
|
||||
_blocked_process_gradient = 0;
|
||||
|
||||
_partial_redraw = false;
|
||||
_last_drawn = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,14 +113,18 @@ SimulationWidget::update(const Simulation& /* changed_simulation */ )
|
|||
{
|
||||
// Force redraw
|
||||
//count_elements();
|
||||
resize_redraw();
|
||||
// nedd redraw only last
|
||||
_partial_redraw = true;
|
||||
// resize_redraw();
|
||||
}
|
||||
|
||||
void
|
||||
SimulationWidget::update(const History& /* changed_history */ )
|
||||
{
|
||||
// Force redraw
|
||||
//count_elements();
|
||||
_last_drawn = 0;
|
||||
_partial_redraw = false;
|
||||
count_elements();
|
||||
resize_redraw();
|
||||
}
|
||||
|
||||
|
@ -143,35 +149,17 @@ void
|
|||
SimulationWidget::draw_widget(cairo_t* ctx)
|
||||
{
|
||||
if(_n_proc<1) // nothing to draw
|
||||
{
|
||||
cairo_move_to(ctx, 10.0, 10.0);
|
||||
cairo_show_text(ctx, "Simulation Widget: nothing to draw...");
|
||||
return;
|
||||
}
|
||||
|
||||
draw_names(ctx);
|
||||
draw_grid(ctx);
|
||||
draw_bars(ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
// top margin in y units
|
||||
_yu_top_margin = 1.0;
|
||||
|
||||
// left margin in x units
|
||||
_xu_left_margin = 1.0;
|
||||
|
||||
// left margin in x units
|
||||
_xu_left_graph_margin = 11.0;
|
||||
|
||||
// bar spacing in y units
|
||||
_yu_process_bar_spacing = 1.0;
|
||||
|
||||
// process bar height in y units
|
||||
_yu_process_bar_height = 1.0;
|
||||
|
||||
// thread bar spacing in y units
|
||||
_yu_thread_bar_spacing = 0.2;
|
||||
|
||||
// thread bar height in y units
|
||||
_yu_thread_bar_height = 0.6;
|
||||
*/
|
||||
|
||||
void
|
||||
SimulationWidget::draw_names(cairo_t* ctx)
|
||||
|
@ -276,9 +264,13 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
|||
// - draw left VER line
|
||||
cairo_move_to(ctx, left_graph_margin, top_margin);
|
||||
cairo_rel_line_to(ctx, 0, graph_height);
|
||||
|
||||
if(_simulation->get_state()==Simulation::state_stopped)
|
||||
{
|
||||
// - draw right VER line
|
||||
cairo_move_to(ctx, left_graph_margin + graph_width, top_margin);
|
||||
cairo_rel_line_to(ctx, 0, graph_height);
|
||||
}
|
||||
cairo_stroke(ctx);
|
||||
|
||||
// draw and write time line
|
||||
|
@ -323,13 +315,24 @@ SimulationWidget::draw_bars(cairo_t* ctx)
|
|||
const double thread_bar_height = _yu_thread_bar_height * _y_unit;
|
||||
const double process_height = (_yu_process_bar_height + 2*_yu_process_bar_spacing) * _y_unit;
|
||||
const double thread_height = (2.0*_yu_thread_bar_spacing+_yu_thread_bar_height) * _y_unit;
|
||||
unsigned int from_time;
|
||||
// const double graph_width = (2.0 + hist_front) * _x_unit;
|
||||
// const double graph_height = _n_proc * process_height + (_show_threads?_n_thr:0) * thread_height;
|
||||
|
||||
|
||||
make_gradients();
|
||||
|
||||
for(unsigned int t=1; t<=hist_front; t++)
|
||||
if(_partial_redraw && _last_drawn>0)
|
||||
{
|
||||
from_time = _last_drawn;
|
||||
}
|
||||
else
|
||||
{
|
||||
from_time = 1;
|
||||
}
|
||||
|
||||
std::cout << " SimulationWidget::draw_bars from:" << from_time << " to:" << hist_front << std::endl;
|
||||
for(unsigned int t=from_time; t<=hist_front; t++)
|
||||
{
|
||||
// draw schedulables bars
|
||||
double xpos = left_graph_margin + t * _x_unit; // left start of first process
|
||||
|
@ -361,7 +364,9 @@ SimulationWidget::draw_bars(cairo_t* ctx)
|
|||
} // ~ if(_show_threads)
|
||||
ypos += process_bar_spacing; // white row after bar
|
||||
} // ~ while(proc_iter!=processes.end())
|
||||
} // ~ for(int t=0; t<=hist_size; t++)
|
||||
} // ~ for(int t=0; t<=hist_front; t++)
|
||||
_last_drawn = hist_front;
|
||||
_partial_redraw = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -646,7 +651,7 @@ SimulationWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
|||
_y_unit=extents.height;
|
||||
|
||||
// left margin, labels, graph
|
||||
width = (size_t)((_xu_left_graph_margin + _xu_left_graph_margin + 3.0 + pos) * _x_unit);
|
||||
width = (size_t)((_xu_left_graph_margin + 3.0 + pos) * _x_unit);
|
||||
// top margin,
|
||||
height = (size_t)((_yu_top_margin + (_yu_process_bar_spacing*2.0+_yu_process_bar_height) * _n_proc + 3.0) * _y_unit);
|
||||
if(_show_threads)
|
||||
|
|
|
@ -122,6 +122,19 @@ namespace sgpem
|
|||
cairo_pattern_t* _ready_process_gradient;
|
||||
cairo_pattern_t* _running_process_gradient;
|
||||
cairo_pattern_t* _blocked_process_gradient;
|
||||
|
||||
/**
|
||||
* Used to redraw partially the widget.
|
||||
* If the redraw come from Simulation update this flag is true
|
||||
* and are redrawn only the last time tics.
|
||||
* If the redraw is needed by History update or resize this flag is false.
|
||||
*/
|
||||
bool _partial_redraw;
|
||||
|
||||
/**
|
||||
* Last time tic drawn.
|
||||
*/
|
||||
unsigned int _last_drawn;
|
||||
};
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
|
Loading…
Reference in New Issue