- 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
This commit is contained in:
paolo 2006-09-08 05:03:57 +00:00
parent e91cea9676
commit c2819ab0ea
1 changed files with 28 additions and 1 deletions

View File

@ -41,6 +41,8 @@
#include <iostream>
#endif
#include <sstream>
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())