- 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)
|
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_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
|
// draw circle
|
||||||
cairo_arc (cr, _pos.real(), _pos.imag(), _radius, 0, 2 * M_PI);
|
CairoElements cel(cr);
|
||||||
// filling
|
// filling
|
||||||
switch(_schedulable->get_state())
|
switch(_schedulable->get_state())
|
||||||
{
|
{
|
||||||
case Schedulable::state_running:
|
case Schedulable::state_running:
|
||||||
// cairo_set_source_rgb (cr, 0, 1, 0);
|
color = &green;
|
||||||
// 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);
|
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_ready:
|
case Schedulable::state_ready:
|
||||||
// cairo_set_source_rgb (cr, 1, 1, 0);
|
color = &yellow;
|
||||||
// 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);
|
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_blocked:
|
case Schedulable::state_blocked:
|
||||||
// cairo_set_source_rgb (cr, 1, 0, 0);
|
color = &red;
|
||||||
// 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);
|
|
||||||
break;
|
break;
|
||||||
case Schedulable::state_future:
|
case Schedulable::state_future:
|
||||||
//cairo_set_source_rgb (cr, 0.5, 0.5, 1);
|
|
||||||
break;
|
|
||||||
case Schedulable::state_terminated:
|
case Schedulable::state_terminated:
|
||||||
cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
|
// should never get here
|
||||||
break;
|
assert((_schedulable->get_state() & (Schedulable::state_future | Schedulable::state_terminated)) == 0);
|
||||||
}
|
}
|
||||||
cairo_fill_preserve (cr);
|
|
||||||
// outline
|
cel.draw_3dsphere(center, _radius, *color);
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
|
||||||
|
|
||||||
// clip text outside region
|
// clip text outside region
|
||||||
cairo_clip_preserve (cr);
|
//cairo_clip_preserve (cr); // TODO: re-enable clipping asap
|
||||||
// draw text
|
// draw text
|
||||||
cairo_text_extents_t extents;
|
cairo_text_extents_t extents;
|
||||||
cairo_text_extents(cr, _schedulable->get_name().c_str(), &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_move_to(cr, _pos.real() - extents.width/2, _pos.imag() + extents.height/2);
|
||||||
cairo_show_text(cr, _schedulable->get_name().c_str());
|
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
|
// stroke all
|
||||||
cairo_stroke (cr);
|
cairo_stroke (cr);
|
||||||
cairo_restore(cr); // restore context state
|
cairo_restore(cr); // restore context state
|
||||||
cairo_pattern_destroy(gradient);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 HoltSchedulable::get_intersection_to(Vec2 pt)
|
Vec2 HoltSchedulable::get_intersection_to(Vec2 pt)
|
||||||
|
|
Loading…
Reference in New Issue