From c2819ab0ea452a25afe31a43b8dce682749a2781 Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 8 Sep 2006 05:03:57 +0000 Subject: [PATCH] - holt_widget: changed clipping; label too large aligned left git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1058 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/holt_widget.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/holt_widget.cc b/src/holt_widget.cc index a7e8a96..95f975b 100644 --- a/src/holt_widget.cc +++ b/src/holt_widget.cc @@ -41,6 +41,8 @@ #include #endif +#include + using namespace sgpem; using namespace std; @@ -207,7 +209,10 @@ void HoltSchedulable::draw(cairo_t *cr) // draw text cairo_text_extents_t extents; cairo_text_extents(cr, _schedulable->get_name().c_str(), &extents); - cairo_move_to(cr, _pos.real() - extents.width/2, _pos.imag() + extents.height/2); + double text_width = extents.width; + if(text_width>_radius*2.0) + text_width=_radius*2.0; + cairo_move_to(cr, _pos.real() - text_width/2, _pos.imag() + extents.height/2); cairo_show_text(cr, _schedulable->get_name().c_str()); // stroke all @@ -664,7 +669,27 @@ void HoltWidget::draw_widget(cairo_t* ctx) { std::cout << "HoltWidget::draw_widget" << endl; + + // dispose objects arrange(); + + // draw text: T = n as title + if(_draw_w>0) + { + const History& hist = _simulation->get_history(); + const unsigned int hist_front = hist.get_front() == 0 ? 0 : hist.get_front() - 1; + cairo_text_extents_t extents; + stringstream ss; + ss << "T = " << hist_front; + cairo_text_extents(ctx, ss.str().c_str(), &extents); + cairo_move_to(ctx, _draw_w/2 - extents.width/2.0, extents.height*2.0); + cairo_show_text(ctx, ss.str().c_str()); + cairo_stroke(ctx); + } + + + + // draw all resources typedef HoltResources::const_iterator holt_res_iterator; holt_res_iterator riter = _holt_resources.begin(); while(riter!=_holt_resources.end()) @@ -674,6 +699,7 @@ HoltWidget::draw_widget(cairo_t* ctx) riter++; } + // draw all schedulables typedef HoltProcesses::const_iterator holt_proc_iterator; holt_proc_iterator piter = _holt_schedulables.begin(); while(piter!=_holt_schedulables.end()) @@ -683,6 +709,7 @@ HoltWidget::draw_widget(cairo_t* ctx) piter++; } + // draw all arrows typedef HoltRequests::const_iterator holt_requ_iterator; holt_requ_iterator reqiter = _holt_requests.begin(); while(reqiter!=_holt_requests.end())