- cairo_widget.cc - doc. updated
- simulation_widget.?? - doc. completed - test-holt_widget - warnings removed git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1169 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
9fc743e2a8
commit
737324f250
|
@ -341,16 +341,24 @@ CairoWidget::resize_redraw()
|
||||||
// Determine the final drawing dimensions before to start drawing
|
// Determine the final drawing dimensions before to start drawing
|
||||||
_draw_w = _draw_h = 0; // default no scaling
|
_draw_w = _draw_h = 0; // default no scaling
|
||||||
calc_drawing_size(ctx, _draw_w, _draw_h);
|
calc_drawing_size(ctx, _draw_w, _draw_h);
|
||||||
|
cairo_destroy(ctx);
|
||||||
|
|
||||||
calc_scale_factors();
|
calc_scale_factors();
|
||||||
|
|
||||||
|
// invalidate all widget's surface
|
||||||
|
queue_draw();
|
||||||
|
|
||||||
set_size_request((int)_scale_x*_draw_w, (int)_scale_y*_draw_h);
|
set_size_request((int)_scale_x*_draw_w, (int)_scale_y*_draw_h);
|
||||||
cairo_destroy(ctx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// invalidate all widget's surface
|
||||||
|
queue_draw();
|
||||||
|
}
|
||||||
|
|
||||||
// invalidate all widget's surface
|
// invalidate all widget's surface
|
||||||
queue_draw();
|
// queue_draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -58,45 +58,31 @@ SimulationWidget::SimulationWidget(Simulation& simulation)
|
||||||
// Register this HistoryObserver:
|
// Register this HistoryObserver:
|
||||||
_simulation->get_history().attach(*this);
|
_simulation->get_history().attach(*this);
|
||||||
|
|
||||||
count_elements();
|
// count_elements();
|
||||||
|
|
||||||
/**
|
// define top margin in y units
|
||||||
* top margin in y units
|
|
||||||
*/
|
|
||||||
_yu_top_margin = 1.0;
|
_yu_top_margin = 1.0;
|
||||||
|
|
||||||
/**
|
// define left margin in x units
|
||||||
* left margin in x units
|
|
||||||
*/
|
|
||||||
_xu_left_margin = 1.0;
|
_xu_left_margin = 1.0;
|
||||||
|
|
||||||
/**
|
// define graph left margin in x units
|
||||||
* left margin in x units
|
|
||||||
*/
|
|
||||||
_xu_left_graph_margin = 11.0;
|
_xu_left_graph_margin = 11.0;
|
||||||
|
|
||||||
/**
|
// define process bar spacing in y units
|
||||||
* process bar spacing in y units
|
|
||||||
*/
|
|
||||||
_yu_process_bar_spacing = 1.0;
|
_yu_process_bar_spacing = 1.0;
|
||||||
|
|
||||||
/**
|
// define process bar height in y units
|
||||||
* process bar height in y units
|
|
||||||
*/
|
|
||||||
_yu_process_bar_height = 2.0;
|
_yu_process_bar_height = 2.0;
|
||||||
|
|
||||||
/**
|
// define thread bar spacing in y units
|
||||||
* thread bar spacing in y units
|
|
||||||
*/
|
|
||||||
_yu_thread_bar_spacing = 0.5;
|
_yu_thread_bar_spacing = 0.5;
|
||||||
|
|
||||||
/**
|
// define thread bar height in y units
|
||||||
* thread bar height in y units
|
|
||||||
*/
|
|
||||||
_yu_thread_bar_height = 1.0;
|
_yu_thread_bar_height = 1.0;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
_ready_process_gradient = 0;
|
_ready_process_gradient = 0;
|
||||||
_running_process_gradient = 0;
|
_running_process_gradient = 0;
|
||||||
_blocked_process_gradient = 0;
|
_blocked_process_gradient = 0;
|
||||||
|
@ -118,21 +104,14 @@ SimulationWidget::~SimulationWidget()
|
||||||
void
|
void
|
||||||
SimulationWidget::update(const Simulation& /* changed_simulation */ )
|
SimulationWidget::update(const Simulation& /* changed_simulation */ )
|
||||||
{
|
{
|
||||||
// Force redraw
|
|
||||||
//count_elements();
|
|
||||||
// nedd redraw only last
|
|
||||||
_partial_redraw = true;
|
|
||||||
// resize_redraw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SimulationWidget::update(const History& changed_history )
|
SimulationWidget::update(const History& /* changed_history */ )
|
||||||
{
|
{
|
||||||
// Force redraw
|
// Force redraw and resize
|
||||||
_last_drawn = 0;
|
_last_drawn = 0;
|
||||||
_partial_redraw = false;
|
_partial_redraw = false;
|
||||||
// MOVED in calc_drawing_size(...)
|
|
||||||
// count_elements();
|
|
||||||
resize_redraw();
|
resize_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +127,6 @@ SimulationWidget::set_show_threads(bool show)
|
||||||
{
|
{
|
||||||
bool old_show = _show_threads;
|
bool old_show = _show_threads;
|
||||||
_show_threads = show;
|
_show_threads = show;
|
||||||
// resize_redraw();
|
|
||||||
return old_show;
|
return old_show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +136,7 @@ SimulationWidget::draw_widget(cairo_t* ctx)
|
||||||
{
|
{
|
||||||
if(_n_proc<1) // nothing to draw
|
if(_n_proc<1) // nothing to draw
|
||||||
{
|
{
|
||||||
cairo_move_to(ctx, 20.0, 20.0);
|
cairo_move_to(ctx, 2.0*_x_unit, 2.0*_y_unit);
|
||||||
cairo_show_text(ctx, _("Nothing to see here... add some processes! Right-click on the Schedulables view in this window."));
|
cairo_show_text(ctx, _("Nothing to see here... add some processes! Right-click on the Schedulables view in this window."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +156,7 @@ SimulationWidget::draw_names(cairo_t* ctx)
|
||||||
const History& hist = _simulation->get_history();
|
const History& hist = _simulation->get_history();
|
||||||
const double top_margin = _yu_top_margin * _y_unit;
|
const double top_margin = _yu_top_margin * _y_unit;
|
||||||
const double left_margin = _x_unit;
|
const double left_margin = _x_unit;
|
||||||
// const double left_graph_margin = _xu_left_graph_margin * _x_unit;
|
const double left_graph_margin = _xu_left_graph_margin * _x_unit;
|
||||||
const double process_bar_spacing = _yu_process_bar_spacing * _y_unit;
|
const double process_bar_spacing = _yu_process_bar_spacing * _y_unit;
|
||||||
const double process_bar_height = _yu_process_bar_height * _y_unit;
|
const double process_bar_height = _yu_process_bar_height * _y_unit;
|
||||||
const double process_height = (_yu_process_bar_height + 2*_yu_process_bar_spacing) * _y_unit;
|
const double process_height = (_yu_process_bar_height + 2*_yu_process_bar_spacing) * _y_unit;
|
||||||
|
@ -187,26 +165,33 @@ SimulationWidget::draw_names(cairo_t* ctx)
|
||||||
|
|
||||||
// set a rectangular clip region to cut long names
|
// set a rectangular clip region to cut long names
|
||||||
// - set the rectangle
|
// - set the rectangle
|
||||||
/*
|
|
||||||
cairo_rectangle(ctx, 0, top_margin,
|
cairo_rectangle(ctx, 0, top_margin,
|
||||||
left_graph_margin - left_margin,
|
left_graph_margin - left_margin,
|
||||||
_n_proc*process_height + _n_thr*thread_height);
|
_n_proc*process_height + _n_thr*thread_height);
|
||||||
// - set the clip region
|
// - set the clip region
|
||||||
cairo_clip(ctx);
|
cairo_clip(ctx);
|
||||||
*/
|
|
||||||
// draw schedulables names
|
// text start position: margin + half of text height
|
||||||
double ypos = top_margin + _y_unit / 2.0; // margin + half of text height
|
double ypos = top_margin + _y_unit / 2.0;
|
||||||
const Environment::Processes& processes = hist.get_last_environment().get_processes();
|
const Environment::Processes& processes = hist.get_last_environment().get_processes();
|
||||||
Environment::Processes::const_iterator proc_iter = processes.begin();
|
Environment::Processes::const_iterator proc_iter = processes.begin();
|
||||||
// - draw processes names
|
// - draw all processes names
|
||||||
while(proc_iter!=processes.end())
|
while(proc_iter!=processes.end())
|
||||||
{
|
{
|
||||||
|
// take pointer to current process
|
||||||
Process* p = (*proc_iter);
|
Process* p = (*proc_iter);
|
||||||
proc_iter++;
|
proc_iter++;
|
||||||
ypos += process_bar_spacing + process_bar_height/2.0; // white row before text
|
|
||||||
|
// move to bar center adding a white row before
|
||||||
|
ypos += process_bar_spacing + process_bar_height/2.0;
|
||||||
cairo_move_to(ctx, left_margin, ypos);
|
cairo_move_to(ctx, left_margin, ypos);
|
||||||
|
// show process name
|
||||||
cairo_show_text(ctx,p->get_name().c_str());
|
cairo_show_text(ctx,p->get_name().c_str());
|
||||||
ypos += process_bar_height/2.0; // height of process bar
|
|
||||||
|
// calc position to next row skipping height of process bar
|
||||||
|
ypos += process_bar_height/2.0;
|
||||||
|
|
||||||
|
// - draw (if needed) threads names
|
||||||
if(_show_threads)
|
if(_show_threads)
|
||||||
{
|
{
|
||||||
const std::vector<Thread*>& tvect = p->get_threads();
|
const std::vector<Thread*>& tvect = p->get_threads();
|
||||||
|
@ -215,30 +200,33 @@ SimulationWidget::draw_names(cairo_t* ctx)
|
||||||
{
|
{
|
||||||
Thread* t = (*thr_iter);
|
Thread* t = (*thr_iter);
|
||||||
thr_iter++;
|
thr_iter++;
|
||||||
|
// move to bar center adding white space as needed
|
||||||
ypos += thread_height/2.0;
|
ypos += thread_height/2.0;
|
||||||
cairo_move_to(ctx, left_margin+_x_unit, ypos);
|
cairo_move_to(ctx, left_margin+_x_unit, ypos);
|
||||||
|
// show thread name
|
||||||
cairo_show_text(ctx,t->get_name().c_str());
|
cairo_show_text(ctx,t->get_name().c_str());
|
||||||
|
|
||||||
|
// calc position to next thread bar begin
|
||||||
ypos += thread_height/2.0; // height of thread bar
|
ypos += thread_height/2.0; // height of thread bar
|
||||||
} // ~ while(thr_iter!=tvect.end())
|
} // ~ while(thr_iter!=tvect.end())
|
||||||
} // ~ if(_show_threads)
|
} // ~ if(_show_threads)
|
||||||
|
|
||||||
|
// calc position to next process bar begin
|
||||||
ypos += process_bar_spacing; // white row after text
|
ypos += process_bar_spacing; // white row after text
|
||||||
} // ~ while(proc_iter!=processes.end())
|
} // ~ while(proc_iter!=processes.end())
|
||||||
// cairo_reset_clip(ctx); // remove clip region
|
|
||||||
|
// remove clip region
|
||||||
|
cairo_reset_clip(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SimulationWidget::draw_grid(cairo_t* ctx)
|
SimulationWidget::draw_grid(cairo_t* ctx)
|
||||||
{
|
{
|
||||||
// std::cout << " SimulationWidget::draw_grid p=" << _n_proc << " t=" << _n_thr << std::endl;
|
|
||||||
// useful constants
|
|
||||||
const History& hist = _simulation->get_history();
|
const History& hist = _simulation->get_history();
|
||||||
|
|
||||||
const unsigned int hist_front = hist.get_front() == 0 ? 0 : hist.get_front() - 1;
|
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 top_margin = _yu_top_margin * _y_unit;
|
||||||
// const double left_margin = _x_unit;
|
|
||||||
const double left_graph_margin = _xu_left_graph_margin * _x_unit;
|
const double left_graph_margin = _xu_left_graph_margin * _x_unit;
|
||||||
// const double process_bar_spacing = _yu_process_bar_spacing * _y_unit;
|
|
||||||
// const double process_bar_height = _yu_process_bar_height * _y_unit;
|
|
||||||
const double process_height = (_yu_process_bar_height + 2*_yu_process_bar_spacing) * _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;
|
const double thread_height = (2.0*_yu_thread_bar_spacing+_yu_thread_bar_height) * _y_unit;
|
||||||
const double graph_width = (2.0 + hist_front) * _x_unit;
|
const double graph_width = (2.0 + hist_front) * _x_unit;
|
||||||
|
@ -248,23 +236,26 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
||||||
double ypos = top_margin;
|
double ypos = top_margin;
|
||||||
const Environment::Processes& processes = hist.get_last_environment().get_processes();
|
const Environment::Processes& processes = hist.get_last_environment().get_processes();
|
||||||
Environment::Processes::const_iterator proc_iter = processes.begin();
|
Environment::Processes::const_iterator proc_iter = processes.begin();
|
||||||
|
|
||||||
// - draw all HOR lines
|
// - draw all HOR lines
|
||||||
while(proc_iter!=processes.end())
|
while(proc_iter!=processes.end())
|
||||||
{
|
{
|
||||||
Process* p = (*proc_iter);
|
Process* p = (*proc_iter);
|
||||||
proc_iter++;
|
proc_iter++;
|
||||||
// draw one (every) )HOR line
|
// draw one HOR line per process
|
||||||
cairo_move_to(ctx, left_graph_margin, ypos);
|
cairo_move_to(ctx, left_graph_margin, ypos);
|
||||||
cairo_rel_line_to(ctx, graph_width, 0);
|
cairo_rel_line_to(ctx, graph_width, 0);
|
||||||
|
|
||||||
// calc next line position
|
// calc next line position
|
||||||
ypos += process_height; // skip a process heigh
|
ypos += process_height; // skip a process heigh
|
||||||
if(_show_threads)
|
if(_show_threads)
|
||||||
{
|
{
|
||||||
int nt = p->get_threads().size();
|
int nt = p->get_threads().size();
|
||||||
// calc next line position (if thread)
|
// calc next line position (if show thread enabled)
|
||||||
ypos += thread_height * nt;
|
ypos += thread_height * nt;
|
||||||
} // ~ if(_show_threads)
|
} // ~ if(_show_threads)
|
||||||
} // ~ while(proc_iter!=processes.end())
|
} // ~ while(proc_iter!=processes.end())
|
||||||
|
|
||||||
// draw last HOR line
|
// draw last HOR line
|
||||||
cairo_move_to(ctx, left_graph_margin, ypos);
|
cairo_move_to(ctx, left_graph_margin, ypos);
|
||||||
cairo_rel_line_to(ctx, graph_width, 0);
|
cairo_rel_line_to(ctx, graph_width, 0);
|
||||||
|
@ -273,6 +264,7 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
||||||
cairo_move_to(ctx, left_graph_margin, top_margin);
|
cairo_move_to(ctx, left_graph_margin, top_margin);
|
||||||
cairo_rel_line_to(ctx, 0, graph_height);
|
cairo_rel_line_to(ctx, 0, graph_height);
|
||||||
|
|
||||||
|
// right close the graph only if simulation stopped
|
||||||
if(_simulation->get_state()==Simulation::state_stopped)
|
if(_simulation->get_state()==Simulation::state_stopped)
|
||||||
{
|
{
|
||||||
// - draw right VER line
|
// - draw right VER line
|
||||||
|
@ -280,9 +272,10 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
||||||
cairo_rel_line_to(ctx, 0, graph_height);
|
cairo_rel_line_to(ctx, 0, graph_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trace lines on output context
|
||||||
cairo_stroke(ctx);
|
cairo_stroke(ctx);
|
||||||
|
|
||||||
// Draw a vertical line every fifth step
|
// Draw a grey vertical line every fifth step
|
||||||
cairo_save(ctx);
|
cairo_save(ctx);
|
||||||
cairo_set_line_width(ctx, 0.125 * cairo_get_line_width(ctx));
|
cairo_set_line_width(ctx, 0.125 * cairo_get_line_width(ctx));
|
||||||
cairo_set_source_rgb(ctx, 0.3, 0.3, 0.3);
|
cairo_set_source_rgb(ctx, 0.3, 0.3, 0.3);
|
||||||
|
@ -301,15 +294,20 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
||||||
cairo_set_source_rgb(ctx, 0, 0, 0);
|
cairo_set_source_rgb(ctx, 0, 0, 0);
|
||||||
cairo_set_line_width(ctx, 0.25*cairo_get_line_width(ctx));
|
cairo_set_line_width(ctx, 0.25*cairo_get_line_width(ctx));
|
||||||
|
|
||||||
|
// "T" label
|
||||||
cairo_move_to(ctx, left_graph_margin,
|
cairo_move_to(ctx, left_graph_margin,
|
||||||
top_margin + graph_height + 2.0 * _y_unit);
|
top_margin + graph_height + 2.0 * _y_unit);
|
||||||
cairo_show_text(ctx,"T");
|
cairo_show_text(ctx,"T");
|
||||||
|
|
||||||
|
// ruler drawing cycle
|
||||||
for(unsigned int t=0; t<=hist_front; t++)
|
for(unsigned int t=0; t<=hist_front; t++)
|
||||||
{
|
{
|
||||||
|
// tick
|
||||||
cairo_move_to(ctx, left_graph_margin + (t+1)*_x_unit,
|
cairo_move_to(ctx, left_graph_margin + (t+1)*_x_unit,
|
||||||
top_margin + graph_height);
|
top_margin + graph_height);
|
||||||
cairo_rel_line_to(ctx, 0, 0.5 * _y_unit);
|
cairo_rel_line_to(ctx, 0, 0.5 * _y_unit);
|
||||||
|
|
||||||
|
// value
|
||||||
Glib::ustring val;
|
Glib::ustring val;
|
||||||
to_string<int>(t, val);
|
to_string<int>(t, val);
|
||||||
cairo_move_to(ctx, left_graph_margin + (t+1)*_x_unit,
|
cairo_move_to(ctx, left_graph_margin + (t+1)*_x_unit,
|
||||||
|
@ -323,26 +321,19 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
||||||
void
|
void
|
||||||
SimulationWidget::draw_bars(cairo_t* ctx)
|
SimulationWidget::draw_bars(cairo_t* ctx)
|
||||||
{
|
{
|
||||||
//std::cout << " SimulationWidget::draw_bars " << std::endl;
|
|
||||||
// show processes (and thread) bars...
|
|
||||||
|
|
||||||
// useful constants
|
// useful constants
|
||||||
const History& hist = _simulation->get_history();
|
const History& hist = _simulation->get_history();
|
||||||
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 top_margin = _yu_top_margin * _y_unit;
|
||||||
// const double left_margin = _x_unit;
|
|
||||||
const double left_graph_margin = _xu_left_graph_margin * _x_unit;
|
const double left_graph_margin = _xu_left_graph_margin * _x_unit;
|
||||||
const double process_bar_spacing = _yu_process_bar_spacing * _y_unit;
|
const double process_bar_spacing = _yu_process_bar_spacing * _y_unit;
|
||||||
const double process_bar_height = _yu_process_bar_height * _y_unit;
|
const double process_bar_height = _yu_process_bar_height * _y_unit;
|
||||||
const double thread_bar_spacing = _yu_thread_bar_spacing * _y_unit;
|
const double thread_bar_spacing = _yu_thread_bar_spacing * _y_unit;
|
||||||
const double thread_bar_height = _yu_thread_bar_height * _y_unit;
|
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;
|
const double thread_height = (2.0*_yu_thread_bar_spacing+_yu_thread_bar_height) * _y_unit;
|
||||||
unsigned int from_time;
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
|
// need to use gradients then make they
|
||||||
make_gradients();
|
make_gradients();
|
||||||
|
|
||||||
if(_partial_redraw && _last_drawn>0)
|
if(_partial_redraw && _last_drawn>0)
|
||||||
|
@ -359,6 +350,7 @@ SimulationWidget::draw_bars(cairo_t* ctx)
|
||||||
std::cout << " SimulationWidget::draw_bars from:" << from_time << " to:" << hist_front << std::endl;
|
std::cout << " SimulationWidget::draw_bars from:" << from_time << " to:" << hist_front << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// time cycle
|
||||||
for(unsigned int t=from_time; t<=hist_front; t++)
|
for(unsigned int t=from_time; t<=hist_front; t++)
|
||||||
{
|
{
|
||||||
// We draw the interval [0, front), entirely, and
|
// We draw the interval [0, front), entirely, and
|
||||||
|
@ -372,17 +364,23 @@ SimulationWidget::draw_bars(cairo_t* ctx)
|
||||||
double ypos = top_margin; // vertical start of first process
|
double ypos = top_margin; // vertical start of first process
|
||||||
const Environment::Processes& processes = hist.get_environment_at(t).get_processes();
|
const Environment::Processes& processes = hist.get_environment_at(t).get_processes();
|
||||||
Environment::Processes::const_iterator proc_iter = processes.begin();
|
Environment::Processes::const_iterator proc_iter = processes.begin();
|
||||||
// - draw processes names
|
|
||||||
|
// - draw each process' bar
|
||||||
while(proc_iter!=processes.end())
|
while(proc_iter!=processes.end())
|
||||||
{
|
{
|
||||||
Process* p = (*proc_iter);
|
Process* p = (*proc_iter);
|
||||||
proc_iter++;
|
proc_iter++;
|
||||||
ypos += process_bar_spacing; // white row before bar
|
ypos += process_bar_spacing; // white row before bar
|
||||||
|
|
||||||
|
// show a single process rectangle
|
||||||
draw_instant_rect(ctx, xpos, ypos,
|
draw_instant_rect(ctx, xpos, ypos,
|
||||||
_x_unit * width_percent, process_bar_height,
|
_x_unit * width_percent, process_bar_height,
|
||||||
p->get_state());
|
p->get_state());
|
||||||
ypos += process_bar_height; // height of process bar
|
|
||||||
|
// skip height of process bar
|
||||||
|
ypos += process_bar_height;
|
||||||
|
|
||||||
|
// paint threads' bars if needed
|
||||||
if(_show_threads)
|
if(_show_threads)
|
||||||
{
|
{
|
||||||
const std::vector<Thread*>& tvect = p->get_threads();
|
const std::vector<Thread*>& tvect = p->get_threads();
|
||||||
|
@ -391,9 +389,13 @@ SimulationWidget::draw_bars(cairo_t* ctx)
|
||||||
{
|
{
|
||||||
Thread* t = (*thr_iter);
|
Thread* t = (*thr_iter);
|
||||||
thr_iter++;
|
thr_iter++;
|
||||||
|
|
||||||
|
// show a single thread rectangle
|
||||||
draw_instant_rect(ctx, xpos, ypos + thread_bar_spacing,
|
draw_instant_rect(ctx, xpos, ypos + thread_bar_spacing,
|
||||||
_x_unit * width_percent, thread_bar_height, t->get_state());
|
_x_unit * width_percent, thread_bar_height, t->get_state());
|
||||||
ypos += thread_height; // height of thread bar
|
|
||||||
|
// skip height of thread bar
|
||||||
|
ypos += thread_height;
|
||||||
} // ~ while(thr_iter!=tvect.end())
|
} // ~ while(thr_iter!=tvect.end())
|
||||||
} // ~ if(_show_threads)
|
} // ~ if(_show_threads)
|
||||||
ypos += process_bar_spacing; // white row after bar
|
ypos += process_bar_spacing; // white row after bar
|
||||||
|
@ -404,6 +406,7 @@ SimulationWidget::draw_bars(cairo_t* ctx)
|
||||||
_partial_redraw = false;
|
_partial_redraw = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draw single rectangle using gradients
|
||||||
void
|
void
|
||||||
SimulationWidget::draw_instant_rect(cairo_t* ctx, double x, double y,
|
SimulationWidget::draw_instant_rect(cairo_t* ctx, double x, double y,
|
||||||
double w, double h, Schedulable::state state)
|
double w, double h, Schedulable::state state)
|
||||||
|
@ -413,36 +416,42 @@ SimulationWidget::draw_instant_rect(cairo_t* ctx, double x, double y,
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
case Schedulable::state_running:
|
case Schedulable::state_running:
|
||||||
// cairo_set_source_rgb(ctx, 0, 1, 0);
|
|
||||||
cairo_save(ctx);
|
cairo_save(ctx);
|
||||||
cairo_set_source(ctx, _running_process_gradient);
|
cairo_set_source(ctx, _running_process_gradient);
|
||||||
// cairo_matrix_init_scale(&matrix, 1.0, y);
|
|
||||||
// cairo_matrix_translate(&matrix, 0, -y);
|
// translate the gradient at desired position
|
||||||
cairo_matrix_init_translate(&matrix, 0, -y);
|
cairo_matrix_init_translate(&matrix, 0, -y);
|
||||||
cairo_pattern_set_matrix (_running_process_gradient, &matrix);
|
cairo_pattern_set_matrix (_running_process_gradient, &matrix);
|
||||||
|
|
||||||
|
// put the filled rectangle
|
||||||
cairo_rectangle(ctx, x, y, w, h);
|
cairo_rectangle(ctx, x, y, w, h);
|
||||||
cairo_fill(ctx);
|
cairo_fill(ctx);
|
||||||
cairo_restore(ctx);
|
cairo_restore(ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Schedulable::state_ready:
|
case Schedulable::state_ready:
|
||||||
// cairo_set_source_rgb(ctx, 1, 1, 0);
|
|
||||||
cairo_save(ctx);
|
cairo_save(ctx);
|
||||||
cairo_set_source(ctx, _ready_process_gradient);
|
cairo_set_source(ctx, _ready_process_gradient);
|
||||||
|
|
||||||
|
// translate the gradient at desired position
|
||||||
cairo_matrix_init_translate(&matrix, 0, -y);
|
cairo_matrix_init_translate(&matrix, 0, -y);
|
||||||
// cairo_matrix_scale(&matrix, 1.0, y);
|
|
||||||
cairo_pattern_set_matrix (_ready_process_gradient, &matrix);
|
cairo_pattern_set_matrix (_ready_process_gradient, &matrix);
|
||||||
|
|
||||||
|
// put the filled rectangle
|
||||||
cairo_rectangle(ctx, x, y, w, h);
|
cairo_rectangle(ctx, x, y, w, h);
|
||||||
cairo_fill(ctx);
|
cairo_fill(ctx);
|
||||||
cairo_restore(ctx);
|
cairo_restore(ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Schedulable::state_blocked:
|
case Schedulable::state_blocked:
|
||||||
// cairo_set_source_rgb(ctx, 1, 0, 0);
|
|
||||||
cairo_save(ctx);
|
cairo_save(ctx);
|
||||||
cairo_set_source(ctx, _blocked_process_gradient);
|
cairo_set_source(ctx, _blocked_process_gradient);
|
||||||
|
|
||||||
|
// translate the gradient at desired position
|
||||||
cairo_matrix_init_translate(&matrix, 0, -y);
|
cairo_matrix_init_translate(&matrix, 0, -y);
|
||||||
cairo_pattern_set_matrix (_blocked_process_gradient, &matrix);
|
cairo_pattern_set_matrix (_blocked_process_gradient, &matrix);
|
||||||
|
|
||||||
|
// put the filled rectangle
|
||||||
cairo_rectangle(ctx, x, y, w, h);
|
cairo_rectangle(ctx, x, y, w, h);
|
||||||
cairo_fill(ctx);
|
cairo_fill(ctx);
|
||||||
cairo_restore(ctx);
|
cairo_restore(ctx);
|
||||||
|
@ -451,9 +460,9 @@ SimulationWidget::draw_instant_rect(cairo_t* ctx, double x, double y,
|
||||||
case Schedulable::state_future:
|
case Schedulable::state_future:
|
||||||
return; // don't draw
|
return; // don't draw
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Schedulable::state_terminated:
|
case Schedulable::state_terminated:
|
||||||
return; // don't draw
|
return; // don't draw
|
||||||
// cairo_set_source_rgb(ctx, 0, 0, 0);
|
|
||||||
break;
|
break;
|
||||||
} // ~ switch(state)
|
} // ~ switch(state)
|
||||||
}
|
}
|
||||||
|
@ -465,12 +474,13 @@ SimulationWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
||||||
if(!_simulation)
|
if(!_simulation)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// evaluate number of processes and threads
|
||||||
count_elements();
|
count_elements();
|
||||||
const History& hist = _simulation->get_history();
|
|
||||||
// const Environment::Processes& processes = hist.get_last_environment().get_processes();
|
|
||||||
int pos = _simulation->get_history().get_front();
|
|
||||||
cairo_text_extents_t extents;
|
|
||||||
|
|
||||||
|
int pos = _simulation->get_history().get_front();
|
||||||
|
|
||||||
|
// units are defined in terms of text dimensions
|
||||||
|
cairo_text_extents_t extents;
|
||||||
Glib::ustring val("999");
|
Glib::ustring val("999");
|
||||||
cairo_text_extents(ctx, val.c_str(), &extents);
|
cairo_text_extents(ctx, val.c_str(), &extents);
|
||||||
if(_x_unit<extents.width)
|
if(_x_unit<extents.width)
|
||||||
|
@ -480,15 +490,20 @@ SimulationWidget::calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height)
|
||||||
|
|
||||||
// left margin, labels, graph
|
// left margin, labels, graph
|
||||||
width = (size_t)((_xu_left_graph_margin + 3.0 + pos) * _x_unit);
|
width = (size_t)((_xu_left_graph_margin + 3.0 + pos) * _x_unit);
|
||||||
// top margin,
|
// top margin, processes*height and space evaluation
|
||||||
height = (size_t)((_yu_top_margin + (_yu_process_bar_spacing*2.0+_yu_process_bar_height) * _n_proc + 3.0) * _y_unit);
|
height = (size_t)((_yu_top_margin +
|
||||||
|
(_yu_process_bar_spacing*2.0+_yu_process_bar_height)
|
||||||
|
* _n_proc + 3.0) * _y_unit);
|
||||||
|
|
||||||
|
// optional threads*height and space evaluation
|
||||||
if(_show_threads)
|
if(_show_threads)
|
||||||
height += (size_t) (_n_thr * (_yu_thread_bar_spacing*2.0+_yu_thread_bar_height) * _y_unit);
|
height += (size_t)
|
||||||
|
(_n_thr * (_yu_thread_bar_spacing*2.0+_yu_thread_bar_height) * _y_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// evaluate number of processes and threads
|
||||||
void
|
void
|
||||||
SimulationWidget::count_elements()
|
SimulationWidget::count_elements()
|
||||||
{
|
{
|
||||||
|
@ -497,15 +512,17 @@ SimulationWidget::count_elements()
|
||||||
const History& hist = _simulation->get_history();
|
const History& hist = _simulation->get_history();
|
||||||
const Environment& env = hist.get_last_environment();
|
const Environment& env = hist.get_last_environment();
|
||||||
|
|
||||||
// iter trough processes
|
// count processes
|
||||||
const Environment::Processes& pvect = env.get_processes();
|
const Environment::Processes& pvect = env.get_processes();
|
||||||
_n_proc = pvect.size();
|
_n_proc = pvect.size();
|
||||||
|
|
||||||
|
// iterate trough processes to compute threads number
|
||||||
Environment::Processes::const_iterator proc_iter = pvect.begin();
|
Environment::Processes::const_iterator proc_iter = pvect.begin();
|
||||||
while(proc_iter!=pvect.end())
|
while(proc_iter!=pvect.end())
|
||||||
{
|
{
|
||||||
Process* p = (*proc_iter);
|
Process* p = (*proc_iter);
|
||||||
proc_iter++;
|
proc_iter++;
|
||||||
// if(_show_threads)
|
if(_show_threads)
|
||||||
_n_thr += p->get_threads().size();
|
_n_thr += p->get_threads().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,6 +531,8 @@ SimulationWidget::count_elements()
|
||||||
void
|
void
|
||||||
SimulationWidget::make_gradients()
|
SimulationWidget::make_gradients()
|
||||||
{
|
{
|
||||||
|
// linear gradients are referred to 0, 0
|
||||||
|
// must be translated if used elsewhere
|
||||||
|
|
||||||
_ready_process_gradient = cairo_pattern_create_linear(0, 0, 0, _yu_process_bar_height * _y_unit);
|
_ready_process_gradient = cairo_pattern_create_linear(0, 0, 0, _yu_process_bar_height * _y_unit);
|
||||||
// yellow
|
// yellow
|
||||||
|
@ -535,10 +554,11 @@ SimulationWidget::make_gradients()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// brings a popup menu to select scaling
|
||||||
bool
|
bool
|
||||||
SimulationWidget::on_button_press_event(GdkEventButton* event)
|
SimulationWidget::on_button_press_event(GdkEventButton* event)
|
||||||
{
|
{
|
||||||
|
// activate on right button press
|
||||||
if((event->type & Gdk::BUTTON_PRESS) == Gdk::BUTTON_PRESS && (event->button == 3))
|
if((event->type & Gdk::BUTTON_PRESS) == Gdk::BUTTON_PRESS && (event->button == 3))
|
||||||
{
|
{
|
||||||
Glib::ustring ui_info =
|
Glib::ustring ui_info =
|
||||||
|
@ -549,7 +569,7 @@ SimulationWidget::on_button_press_event(GdkEventButton* event)
|
||||||
|
|
||||||
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
|
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
|
||||||
|
|
||||||
|
// adds action and menu item for "no scaling"
|
||||||
if(scaling!=CairoWidget::scaling_none)
|
if(scaling!=CairoWidget::scaling_none)
|
||||||
{
|
{
|
||||||
action_group->add( Gtk::Action::create("ScalingNone", "_No scaling"),
|
action_group->add( Gtk::Action::create("ScalingNone", "_No scaling"),
|
||||||
|
@ -557,6 +577,7 @@ SimulationWidget::on_button_press_event(GdkEventButton* event)
|
||||||
ui_info += " <menuitem action='ScalingNone'/>";
|
ui_info += " <menuitem action='ScalingNone'/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adds action and menu item for "fit in window"
|
||||||
if(scaling!=CairoWidget::scaling_min)
|
if(scaling!=CairoWidget::scaling_min)
|
||||||
{
|
{
|
||||||
// scaling==scaling_none
|
// scaling==scaling_none
|
||||||
|
@ -565,6 +586,7 @@ SimulationWidget::on_button_press_event(GdkEventButton* event)
|
||||||
ui_info += " <menuitem action='ScalingFit'/>";
|
ui_info += " <menuitem action='ScalingFit'/>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adds action and menu item for "stretch in window"
|
||||||
if(scaling!=CairoWidget::scaling_all)
|
if(scaling!=CairoWidget::scaling_all)
|
||||||
{
|
{
|
||||||
// scaling==scaling_none
|
// scaling==scaling_none
|
||||||
|
@ -580,9 +602,11 @@ SimulationWidget::on_button_press_event(GdkEventButton* event)
|
||||||
" </popup>"
|
" </popup>"
|
||||||
"</ui>";
|
"</ui>";
|
||||||
|
|
||||||
|
// insert menu
|
||||||
UIManager->add_ui_from_string(ui_info);
|
UIManager->add_ui_from_string(ui_info);
|
||||||
Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu"));
|
Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu"));
|
||||||
|
|
||||||
|
// run the menu
|
||||||
menu->popup(event->button, event->time);
|
menu->popup(event->button, event->time);
|
||||||
return true; //It has been handled.
|
return true; //It has been handled.
|
||||||
}
|
}
|
||||||
|
@ -601,7 +625,7 @@ SimulationWidget::_on_no_scaling()
|
||||||
std::cout << "after SimulationWidget::_on_no_scaling mode=" << get_scaling_mode() << std::endl;
|
std::cout << "after SimulationWidget::_on_no_scaling mode=" << get_scaling_mode() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
resize_redraw();
|
resize_redraw();
|
||||||
set_size_request (20, 20); // force container redimensioning
|
// set_size_request (20, 20); // force container redimensioning
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,7 +640,7 @@ SimulationWidget::_on_fit_scaling()
|
||||||
std::cout << "after SimulationWidget::_on_fit_scaling mode=" << get_scaling_mode() << std::endl;
|
std::cout << "after SimulationWidget::_on_fit_scaling mode=" << get_scaling_mode() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
resize_redraw();
|
resize_redraw();
|
||||||
set_size_request (20, 20); // force container redimensioning
|
// set_size_request (20, 20); // force container redimensioning
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -630,5 +654,5 @@ SimulationWidget::_on_stretch_scaling()
|
||||||
std::cout << "after SimulationWidget::_on_stretch_scaling mode=" << get_scaling_mode() << std::endl;
|
std::cout << "after SimulationWidget::_on_stretch_scaling mode=" << get_scaling_mode() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
resize_redraw();
|
resize_redraw();
|
||||||
set_size_request (20, 20); // force container redimensioning
|
// set_size_request (20, 20); // force container redimensioning
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace sgpem
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* \brief Implements a cairo widget to draw the simulation
|
* \brief Implements a cairo widget to draw the simulation
|
||||||
* processes ststus graphical rapresentation.
|
* processes status graphical rapresentation.
|
||||||
*
|
*
|
||||||
* It shows the simulation processes (and threads if flag is enabled)
|
* It shows the simulation processes (and threads if flag is enabled)
|
||||||
* names on the left and a bar for each of these on the right.
|
* names on the left and a bar for each of these on the right.
|
||||||
|
@ -64,6 +64,8 @@ namespace sgpem
|
||||||
* \brief default and unique constructor.
|
* \brief default and unique constructor.
|
||||||
*
|
*
|
||||||
* Saves the passed argument in data member _simulation.
|
* Saves the passed argument in data member _simulation.
|
||||||
|
*
|
||||||
|
* \param simulation the observed Simulation
|
||||||
*/
|
*/
|
||||||
SimulationWidget(Simulation& simulation);
|
SimulationWidget(Simulation& simulation);
|
||||||
|
|
||||||
|
@ -76,6 +78,8 @@ namespace sgpem
|
||||||
* \brief SimulationObserver's update method redefinition.
|
* \brief SimulationObserver's update method redefinition.
|
||||||
*
|
*
|
||||||
* Actually is a dummy method.
|
* Actually is a dummy method.
|
||||||
|
*
|
||||||
|
* \param changed_simulation the observed Simulation
|
||||||
*/
|
*/
|
||||||
virtual void update(const Simulation& changed_simulation);
|
virtual void update(const Simulation& changed_simulation);
|
||||||
|
|
||||||
|
@ -83,21 +87,28 @@ namespace sgpem
|
||||||
* \brief HistoryObserver's update method redefinition.
|
* \brief HistoryObserver's update method redefinition.
|
||||||
*
|
*
|
||||||
* Updates the widget to reflects history current state.
|
* Updates the widget to reflects history current state.
|
||||||
|
*
|
||||||
|
* \param changed_history the observed History
|
||||||
*/
|
*/
|
||||||
virtual void update(const History& changed_history);
|
virtual void update(const History& changed_history);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Gets the _show_threads flag current status.
|
* \brief Gets the _show_threads flag current status.
|
||||||
|
*
|
||||||
|
* \return true if threads visualization is enabled
|
||||||
*/
|
*/
|
||||||
bool get_show_threads();
|
bool get_show_threads();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sets gets the _show_threads flag status.
|
* \brief Sets and gets the _show_threads flag status.
|
||||||
*
|
*
|
||||||
* If _show_threads is enabled both processes and threads
|
* If _show_threads is enabled both processes and threads
|
||||||
* will be drawn on widget.
|
* will be drawn on widget.
|
||||||
* If _show_threads is disabled only processes
|
* If _show_threads is disabled only processes
|
||||||
* will be shown.
|
* will be shown.
|
||||||
|
*
|
||||||
|
* \param show the new desired status of threads visualization
|
||||||
|
* \return the previous status
|
||||||
*/
|
*/
|
||||||
bool set_show_threads(bool show);
|
bool set_show_threads(bool show);
|
||||||
|
|
||||||
|
@ -105,18 +116,25 @@ namespace sgpem
|
||||||
/**
|
/**
|
||||||
* \brief Catches the mouse click to show a "scaling options"
|
* \brief Catches the mouse click to show a "scaling options"
|
||||||
* popup menu.
|
* popup menu.
|
||||||
|
*
|
||||||
|
* \param event the type and status of mouse event occurred
|
||||||
*/
|
*/
|
||||||
virtual bool on_button_press_event(GdkEventButton* event);
|
virtual bool on_button_press_event(GdkEventButton* event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Execute the widget painting when needed.
|
* \brief Execute the widget painting when needed.
|
||||||
*
|
*
|
||||||
* \see CairoWidget() for more.
|
* \param ctx the cairo context to draw to
|
||||||
|
* \see CairoWidget for more.
|
||||||
*/
|
*/
|
||||||
void draw_widget(cairo_t* ctx);
|
void draw_widget(cairo_t* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief calculated the needed drawing surface dimensions.
|
* \brief calculated the needed drawing surface dimensions.
|
||||||
|
*
|
||||||
|
* \param ctx the cairo context to calc draw related dimensions
|
||||||
|
* \param width the return parameter for desired width
|
||||||
|
* \param height the return parameter for desired height
|
||||||
*/
|
*/
|
||||||
virtual void calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height);
|
virtual void calc_drawing_size(cairo_t* ctx, size_t& width, size_t& height);
|
||||||
|
|
||||||
|
@ -131,21 +149,34 @@ namespace sgpem
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used internally by draw_widget to show processes/threads name.
|
* \brief Used internally by draw_widget to show processes/threads name.
|
||||||
|
*
|
||||||
|
* \param ctx the cairo context to draw to
|
||||||
*/
|
*/
|
||||||
void draw_names(cairo_t* ctx);
|
void draw_names(cairo_t* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used internally by draw_widget to show the bars container grid.
|
* \brief Used internally by draw_widget to show the bars container grid.
|
||||||
|
*
|
||||||
|
* \param ctx the cairo context to draw to
|
||||||
*/
|
*/
|
||||||
void draw_grid(cairo_t* ctx);
|
void draw_grid(cairo_t* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used internally by draw_widget to show processes/threads bars.
|
* \brief Used internally by draw_widget to show processes/threads bars.
|
||||||
|
*
|
||||||
|
* \param ctx the cairo context to draw to
|
||||||
*/
|
*/
|
||||||
void draw_bars(cairo_t* ctx);
|
void draw_bars(cairo_t* ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used internally by draw_widget to build the bars.
|
* \brief Used internally by draw_widget to build the bars.
|
||||||
|
*
|
||||||
|
* \param ctx the cairo context to draw to
|
||||||
|
* \param x horizontal coordinate of starting point
|
||||||
|
* \param y vertical coordinate of starting point
|
||||||
|
* \param w width of rectangle
|
||||||
|
* \param h height of rectangle
|
||||||
|
* \param state select the color to apply
|
||||||
*/
|
*/
|
||||||
void draw_instant_rect(cairo_t* ctx, double x, double y,
|
void draw_instant_rect(cairo_t* ctx, double x, double y,
|
||||||
double w, double h, sgpem::Schedulable::state state);
|
double w, double h, sgpem::Schedulable::state state);
|
||||||
|
@ -153,23 +184,26 @@ namespace sgpem
|
||||||
/**
|
/**
|
||||||
* \brief Build the gradients used to picture the bars.
|
* \brief Build the gradients used to picture the bars.
|
||||||
*
|
*
|
||||||
* Gradinets are filling colors soft degrading.
|
* Gradients are filling colors soft degrading.
|
||||||
* Please refer to cairo documentetion for more.
|
* Please refer to cairo documentetion for more.
|
||||||
*/
|
*/
|
||||||
void make_gradients();
|
void make_gradients();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief "No scaling" menu command responding mathod.
|
* \brief "No scaling" menu command responding mathod.
|
||||||
|
* Sets the actual scaling mode to scaling_none.
|
||||||
*/
|
*/
|
||||||
void _on_no_scaling();
|
void _on_no_scaling();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief "Fit scaling" menu command responding mathod.
|
* \brief "Fit scaling" menu command responding mathod.
|
||||||
|
* Sets the actual scaling mode to scaling_min.
|
||||||
*/
|
*/
|
||||||
void _on_fit_scaling();
|
void _on_fit_scaling();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief "Stetch scaling" menu command responding mathod.
|
* \brief "Stetch scaling" menu command responding mathod.
|
||||||
|
* Sets the actual scaling mode to scaling_all.
|
||||||
*/
|
*/
|
||||||
void _on_stretch_scaling();
|
void _on_stretch_scaling();
|
||||||
|
|
||||||
|
|
|
@ -106,9 +106,9 @@ public:
|
||||||
ReadyQueue* sl = Scheduler::get_instance().get_ready_queue();
|
ReadyQueue* sl = Scheduler::get_instance().get_ready_queue();
|
||||||
if(sl && sl->size()>=2)
|
if(sl && sl->size()>=2)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < sl->size(); i++)
|
for (size_t i = 0; i < sl->size(); i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < sl->size() - 1; j++)
|
for (size_t j = 0; j < sl->size() - 1; j++)
|
||||||
{
|
{
|
||||||
if ( (sl->get_item_at(j).get_current_priority() < sl->get_item_at(j + 1).get_current_priority())
|
if ( (sl->get_item_at(j).get_current_priority() < sl->get_item_at(j + 1).get_current_priority())
|
||||||
|| ((sl->get_item_at(j).get_current_priority() == sl->get_item_at(j + 1).get_current_priority())
|
|| ((sl->get_item_at(j).get_current_priority() == sl->get_item_at(j + 1).get_current_priority())
|
||||||
|
@ -288,7 +288,10 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
MainWindow::MainWindow(Simulation& simulation)
|
MainWindow::MainWindow(Simulation& simulation)
|
||||||
: _start_button("Start"),
|
:
|
||||||
|
_simulation_widget(simulation),
|
||||||
|
_holt_widget(simulation),
|
||||||
|
_start_button("Start"),
|
||||||
_stop_button("Stop"),
|
_stop_button("Stop"),
|
||||||
_pause_button("Pause"),
|
_pause_button("Pause"),
|
||||||
_runmode_button("Continue"),
|
_runmode_button("Continue"),
|
||||||
|
@ -299,8 +302,6 @@ MainWindow::MainWindow(Simulation& simulation)
|
||||||
_horizontal_radio("dispose horizontal"),
|
_horizontal_radio("dispose horizontal"),
|
||||||
_vertical_radio("dispose vertical"),
|
_vertical_radio("dispose vertical"),
|
||||||
_circular_radio("dispose circular"),
|
_circular_radio("dispose circular"),
|
||||||
_simulation_widget(simulation),
|
|
||||||
_holt_widget(simulation),
|
|
||||||
_sim_state(Simulation::state_stopped),
|
_sim_state(Simulation::state_stopped),
|
||||||
_holt_container(simulation)
|
_holt_container(simulation)
|
||||||
{
|
{
|
||||||
|
@ -556,7 +557,8 @@ int
|
||||||
main(int argc, char** argv)
|
main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
ostream& info = cout;
|
ostream& info = cout;
|
||||||
ostream& test = cerr;
|
// actually unused test - leave for future use
|
||||||
|
// ostream& test = cerr;
|
||||||
|
|
||||||
Gtk::Main kit(argc, argv);
|
Gtk::Main kit(argc, argv);
|
||||||
|
|
||||||
|
@ -637,19 +639,19 @@ void fillHistory(History &hist)
|
||||||
Process& p3 = hist.add_process(Glib::ustring("Process 3"), 5, 5); // name, arrival time, priority
|
Process& p3 = hist.add_process(Glib::ustring("Process 3"), 5, 5); // name, arrival time, priority
|
||||||
|
|
||||||
// add a process - name, arrival time, priority
|
// add a process - name, arrival time, priority
|
||||||
Process& p4 = hist.add_process(Glib::ustring("Very Long Named Process 4"), 9, 1); // name, arrival time, priority
|
Process& p4 = hist.add_process(Glib::ustring("Very Long Named Process 4 with more and more characters"), 9, 1); // name, arrival time, priority
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p1_t1 = hist.add_thread(Glib::ustring("P1 - Th 1"), p1, 14, 0, 2);
|
Thread& p1_t1 = hist.add_thread(Glib::ustring("P1 - Th 1"), p1, 14, 0, 2);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p1_t2 = hist.add_thread(Glib::ustring("P1 - Th 2"), p1, 3, 3, 5);
|
/* Thread& p1_t2 = */ hist.add_thread(Glib::ustring("P1 - Th 2"), p1, 3, 3, 5);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p1_t3 = hist.add_thread(Glib::ustring("P1 - Th 3"), p1, 4, 3, 5);
|
/* Thread& p1_t3 = */ hist.add_thread(Glib::ustring("P1 - Th 3"), p1, 4, 3, 5);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p1_t4 = hist.add_thread(Glib::ustring("P1 - Th 4"), p1, 5, 3, 4);
|
/*Thread& p1_t4 = */ hist.add_thread(Glib::ustring("P1 - Th 4"), p1, 5, 3, 4);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p2_t1 = hist.add_thread(Glib::ustring("P2 - Th 1"), p2, 20, 0, 2);
|
Thread& p2_t1 = hist.add_thread(Glib::ustring("P2 - Th 1"), p2, 20, 0, 2);
|
||||||
|
@ -658,34 +660,34 @@ void fillHistory(History &hist)
|
||||||
Thread& p3_t1 = hist.add_thread(Glib::ustring("P3 - Th 2"), p3, 12, 0, 2);
|
Thread& p3_t1 = hist.add_thread(Glib::ustring("P3 - Th 2"), p3, 12, 0, 2);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p4_t1 = hist.add_thread(Glib::ustring("P4 - Th 1"), p4, 7, 0, 2);
|
/* Thread& p4_t1 = */ hist.add_thread(Glib::ustring("P4 - Th 1"), p4, 7, 0, 2);
|
||||||
|
|
||||||
// add a thread - name, parent, cpu time, arrival time, priority
|
// add a thread - name, parent, cpu time, arrival time, priority
|
||||||
Thread& p4_t2 = hist.add_thread(Glib::ustring("P4 - Th 2"), p4, 3, 6, 2);
|
/* Thread& p4_t2 = */ hist.add_thread(Glib::ustring("P4 - Th 2"), p4, 3, 6, 2);
|
||||||
|
|
||||||
// add a request - Thread, time
|
// add a request - Thread, time
|
||||||
Request& req1 = hist.add_request(p1_t1, 3);
|
Request& req1 = hist.add_request(p1_t1, 3);
|
||||||
|
|
||||||
// add a sub request - Request, resource_key, duration, places
|
// add a sub request - Request, resource_key, duration, places
|
||||||
SubRequest& req1_sub1 = hist.add_subrequest(req1, respair.first, 6);
|
/* SubRequest& req1_sub1 = */ hist.add_subrequest(req1, respair.first, 6);
|
||||||
|
|
||||||
// add a request - Thread, time
|
// add a request - Thread, time
|
||||||
Request& req2 = hist.add_request(p2_t1, 1);
|
Request& req2 = hist.add_request(p2_t1, 1);
|
||||||
|
|
||||||
// add a sub request - Request, resource_key, duration, places
|
// add a sub request - Request, resource_key, duration, places
|
||||||
SubRequest& req2_sub1 = hist.add_subrequest(req2, respair.first, 4);
|
/* SubRequest& req2_sub1 = */ hist.add_subrequest(req2, respair.first, 4);
|
||||||
|
|
||||||
// add a request - Thread, time
|
// add a request - Thread, time
|
||||||
Request& req3 = hist.add_request(p3_t1, 0);
|
Request& req3 = hist.add_request(p3_t1, 0);
|
||||||
|
|
||||||
// add a sub request - Request, resource_key, duration, places
|
// add a sub request - Request, resource_key, duration, places
|
||||||
SubRequest& req3_sub1 = hist.add_subrequest(req3, respair.first, 5);
|
/* SubRequest& req3_sub1 = */ hist.add_subrequest(req3, respair.first, 5);
|
||||||
|
|
||||||
// add a request - Thread, time
|
// add a request - Thread, time
|
||||||
Request& req3bis = hist.add_request(p3_t1, 7);
|
Request& req3bis = hist.add_request(p3_t1, 7);
|
||||||
|
|
||||||
// add a sub request - Request, resource_key, duration, places
|
// add a sub request - Request, resource_key, duration, places
|
||||||
SubRequest& req3bis_sub1 = hist.add_subrequest(req3bis, respair.first, 5);
|
/* SubRequest& req3bis_sub1 = */ hist.add_subrequest(req3bis, respair.first, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -695,19 +697,28 @@ Glib::ustring get_schedulable_state_name(Schedulable::state st)
|
||||||
{
|
{
|
||||||
case Schedulable::state_running:
|
case Schedulable::state_running:
|
||||||
return Glib::ustring("Schedulable::state_running");
|
return Glib::ustring("Schedulable::state_running");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Schedulable::state_ready:
|
case Schedulable::state_ready:
|
||||||
return Glib::ustring("Schedulable::state_ready");
|
return Glib::ustring("Schedulable::state_ready");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Schedulable::state_blocked:
|
case Schedulable::state_blocked:
|
||||||
return Glib::ustring("Schedulable::state_blocked");
|
return Glib::ustring("Schedulable::state_blocked");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Schedulable::state_future:
|
case Schedulable::state_future:
|
||||||
return Glib::ustring("Schedulable::state_future");
|
return Glib::ustring("Schedulable::state_future");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Schedulable::state_terminated:
|
case Schedulable::state_terminated:
|
||||||
return Glib::ustring("Schedulable::state_terminated");
|
return Glib::ustring("Schedulable::state_terminated");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Glib::ustring("Schedulable::state_UNKNOWN");
|
||||||
|
// break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,20 +727,29 @@ Glib::ustring get_request_state_name(Request::state st)
|
||||||
switch(st)
|
switch(st)
|
||||||
{
|
{
|
||||||
case Request::state_unallocable:
|
case Request::state_unallocable:
|
||||||
return Glib::ustring("state_unallocable");
|
return Glib::ustring("Request::state_unallocable");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Request::state_allocated:
|
case Request::state_allocated:
|
||||||
return Glib::ustring("state_allocated");
|
return Glib::ustring("Request::state_allocated");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Request::state_future:
|
case Request::state_future:
|
||||||
return Glib::ustring("state_future");
|
return Glib::ustring("Request::state_future");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Request::state_exhausted:
|
case Request::state_exhausted:
|
||||||
return Glib::ustring("state_exhausted");
|
return Glib::ustring("Request::state_exhausted");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Request::state_allocable:
|
case Request::state_allocable:
|
||||||
return Glib::ustring("state_allocable");
|
return Glib::ustring("Request::state_allocable");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Glib::ustring("Request::state_UNKNOWN");
|
||||||
|
// break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,13 +760,20 @@ Glib::ustring get_simulation_state_name(Simulation::state st)
|
||||||
{
|
{
|
||||||
case Simulation::state_running:
|
case Simulation::state_running:
|
||||||
return Glib::ustring("Simulation::state_running");
|
return Glib::ustring("Simulation::state_running");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Simulation::state_paused:
|
case Simulation::state_paused:
|
||||||
return Glib::ustring("Simulation::state_paused");
|
return Glib::ustring("Simulation::state_paused");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Simulation::state_stopped:
|
case Simulation::state_stopped:
|
||||||
return Glib::ustring("Simulation::state_stopped");
|
return Glib::ustring("Simulation::state_stopped");
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Glib::ustring("Simulation::state_UNKNOWN");
|
||||||
|
// break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue