- Use 3d spheres to show processes or threads. I've temporarily
disabled clipping on the schedulables name since I'm busy on other tasks now, I'll fix that later this afternoon. This is an intermediate commit. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1041 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
a681f92dcb
commit
449af3cd3e
|
@ -168,61 +168,50 @@ HoltSchedulable::~HoltSchedulable()
|
|||
|
||||
void HoltSchedulable::draw(cairo_t *cr)
|
||||
{
|
||||
static const Color red(1, 0, 0);
|
||||
static const Color yellow(1, 1, 0);
|
||||
static const Color green(0, 1, 0);
|
||||
|
||||
|
||||
cairo_save(cr); // save context state
|
||||
cairo_pattern_t* gradient;
|
||||
gradient = cairo_pattern_create_radial( _pos.real(), _pos.imag(), 0.0, _pos.real(), _pos.imag(), _radius);
|
||||
|
||||
const Point center(_pos.real(), _pos.imag());
|
||||
const Color* color;
|
||||
|
||||
// draw circle
|
||||
cairo_arc (cr, _pos.real(), _pos.imag(), _radius, 0, 2 * M_PI);
|
||||
CairoElements cel(cr);
|
||||
// filling
|
||||
switch(_schedulable->get_state())
|
||||
{
|
||||
case Schedulable::state_running:
|
||||
// cairo_set_source_rgb (cr, 0, 1, 0);
|
||||
// green
|
||||
cairo_pattern_add_color_stop_rgba(gradient, 0.00, 0.5, 1.0, 0.5, 0.7);
|
||||
cairo_pattern_add_color_stop_rgba(gradient, 1.00, 0.0, 1.0, 0.0, 1.0);
|
||||
cairo_set_source(cr, gradient);
|
||||
color = &green;
|
||||
break;
|
||||
case Schedulable::state_ready:
|
||||
// cairo_set_source_rgb (cr, 1, 1, 0);
|
||||
// yellow
|
||||
cairo_pattern_add_color_stop_rgba(gradient, 0.00, 1.0, 1.0, 0.5, 0.7);
|
||||
cairo_pattern_add_color_stop_rgba(gradient, 1.00, 1.0, 1.0, 0.0, 1.0);
|
||||
cairo_set_source(cr, gradient);
|
||||
color = &yellow;
|
||||
break;
|
||||
case Schedulable::state_blocked:
|
||||
// cairo_set_source_rgb (cr, 1, 0, 0);
|
||||
// red
|
||||
cairo_pattern_add_color_stop_rgba(gradient, 0.00, 1.0, 0.5, 0.5, 0.7);
|
||||
cairo_pattern_add_color_stop_rgba(gradient, 1.00, 1.0, 0.0, 0.0, 1.0);
|
||||
cairo_set_source(cr, gradient);
|
||||
color = &red;
|
||||
break;
|
||||
case Schedulable::state_future:
|
||||
//cairo_set_source_rgb (cr, 0.5, 0.5, 1);
|
||||
break;
|
||||
case Schedulable::state_terminated:
|
||||
cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
|
||||
break;
|
||||
// should never get here
|
||||
assert((_schedulable->get_state() & (Schedulable::state_future | Schedulable::state_terminated)) == 0);
|
||||
}
|
||||
cairo_fill_preserve (cr);
|
||||
// outline
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
|
||||
cel.draw_3dsphere(center, _radius, *color);
|
||||
|
||||
// clip text outside region
|
||||
cairo_clip_preserve (cr);
|
||||
//cairo_clip_preserve (cr); // TODO: re-enable clipping asap
|
||||
// draw text
|
||||
cairo_text_extents_t extents;
|
||||
cairo_text_extents(cr, _schedulable->get_name().c_str(), &extents);
|
||||
// cairo_move_to(cr, xpos - _radius, ypos - _radius + extents.height);
|
||||
cairo_move_to(cr, _pos.real() - extents.width/2, _pos.imag() + extents.height/2);
|
||||
cairo_show_text(cr, _schedulable->get_name().c_str());
|
||||
cairo_reset_clip (cr); // reset clip region
|
||||
//cairo_reset_clip (cr); // reset clip region // TODO: re-enable clipping asap
|
||||
|
||||
// stroke all
|
||||
cairo_stroke (cr);
|
||||
cairo_restore(cr); // restore context state
|
||||
cairo_pattern_destroy(gradient);
|
||||
}
|
||||
|
||||
Vec2 HoltSchedulable::get_intersection_to(Vec2 pt)
|
||||
|
|
Loading…
Reference in New Issue