コード例 #1
0
bool
Trainer::on_drawing_press(GdkEventButton * event)
{
	if (event->button == 1)
	{
		cur_char_.new_stroke();
		cur_char_.add_point(event->x, event->y);
		last_x = static_cast<int>(event->x);
		last_y = static_cast<int>(event->y);

		Glib::RefPtr<Gdk::Window> win = drawing_.get_window();
		Glib::RefPtr<Gdk::GC> gc = drawing_.get_style()->get_black_gc();

		// draw a number before each stroke
		Glib::RefPtr<Pango::Layout> num = create_pango_layout(chrasis::toString(++stroke_num));
		int lx, ly;
		num->get_size(lx, ly);
		gc->set_rgb_fg_color(colors[2]);
		win->draw_layout(
			gc,
			static_cast<int>(event->x - lx / Pango::SCALE - 5),
			static_cast<int>(event->y - ly / Pango::SCALE - 5),
			num
		);

		// draw a dot
		gc->set_rgb_fg_color(colors[0]);
		win->draw_arc( gc, true,
			static_cast<int>(event->x) - 3,
			static_cast<int>(event->y) - 3,
			5, 5, 0, 23040);
	}

	return false;
}
コード例 #2
0
void
Trainer::draw_character()
{
	Glib::RefPtr<Gdk::Window> win = drawing_.get_window();
	Glib::RefPtr<Gdk::GC> gc = drawing_.get_style()->get_black_gc();

	stroke_num = 0;
	for (chrasis::Stroke::iterator si = cur_char_.strokes_begin();
	     si != cur_char_.strokes_end();
	     ++si)
	{
		// draw the stroke body
		gc->set_rgb_fg_color(colors[2]);
		for (chrasis::Point::iterator pi = si->points_begin();
		     pi != si->points_end() - 1;
		     ++pi)
		{
			win->draw_line( gc,
				static_cast<int>(pi->x()),
				static_cast<int>(pi->y()),
				static_cast<int>((pi+1)->x()),
				static_cast<int>((pi+1)->y())
			);
		}

		// draw a number before each stroke
		stringstream ss;
		ss << ++stroke_num;
		Glib::RefPtr<Pango::Layout> num = create_pango_layout(ss.str());
		int lx, ly;
		num->get_size(lx, ly);
		win->draw_layout(
			gc,
			static_cast<int>(si->points_begin()->x() - lx / Pango::SCALE - 5),
			static_cast<int>(si->points_begin()->y() - ly / Pango::SCALE - 5),
			num
		);

		// enchant the beginning and ending points
		chrasis::Point::iterator pi[2] =
			{ si->points_begin(), si->points_end() - 1 };

		for (int i=0;i<2;++i)
		{
			gc->set_rgb_fg_color(colors[i]);
			win->draw_arc( gc, true,
				static_cast<int>(pi[i]->x() - 3),
				static_cast<int>(pi[i]->y() - 3),
				5, 5, 0, 23040);
		}
	}
}
コード例 #3
0
ファイル: dialog_setup.cpp プロジェクト: ZurbaXI/synfig
bool
RedBlueLevelSelector::redraw(GdkEventExpose */*bleh*/)
{
	//!Check if the window we want draw is ready
	Glib::RefPtr<Gdk::Window> window = get_window();
	if(!window) return true;

	const int w(get_width()),h(get_height());

	Gdk::Color color;

	Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));

	int i;

	// Draw the gradient
	for(i=0;i<w;i++)
	{
		float red_blue(((float(i)/float(w)+0.5f)-1.0f)/2.0f+1.0f);
		float blue_red(2.0f-(red_blue));
		if(red_blue>1.0f)red_blue=1.0f;
		if(blue_red>1.0f)blue_red=1.0f;

		color.set_rgb(
			round_to_int(min(red_blue,1.0f)*65535),
			round_to_int(sqrt(min(red_blue,blue_red))*65535),
			round_to_int(min(blue_red,1.0f)*65535)
		);

		gc->set_rgb_fg_color(color);
		window->draw_rectangle(gc, true, i, 0, 1, h);
	}

	// Draw a frame
	gc->set_rgb_fg_color(Gdk::Color("#000000"));
	window->draw_rectangle(gc, false, 0, 0, w-1, h-1);

	// Draw the position of the current value
	i=(int)(((level-1.0f)*2.0f+1.0f-0.5f)*w+0.5);
	gc->set_rgb_fg_color(Gdk::Color("#00ff00"));
	window->draw_rectangle(gc, true, i, 1, 1, h-1);

	// Print out the value
	Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
	layout->set_text(etl::strprintf("%0.02f",level));
	layout->set_alignment(Pango::ALIGN_CENTER);
	gc->set_rgb_fg_color(Gdk::Color("#a00000"));
	window->draw_layout(gc, w/2, 4, layout);

	return true;
}
コード例 #4
0
bool Creater::on_drawing_press(GdkEventButton * event)
{
	if (event->button == 1)
	{
		if (cur_chars_.size() == 0)
		{
			this->on_popup_new();

			return false;
		}

		cur_char_->new_stroke();

		cur_char_->add_point(event->x, event->y);

		Glib::RefPtr<Gdk::Window> win = drawing_.get_window();
		Glib::RefPtr<Gdk::GC> gc = drawing_.get_style()->get_black_gc();

		// draw a number before each stroke
		Glib::RefPtr<Pango::Layout> num =
			create_pango_layout(boost::lexical_cast<std::string>(++stroke_num));
		int lx, ly;
		num->get_size(lx, ly);
		gc->set_rgb_fg_color(colors[2]);
		win->draw_layout(
			gc,
			event->x - lx / Pango::SCALE - 5,
			event->y - ly / Pango::SCALE - 5,
			num
		);

		// draw a dot
		gc->set_rgb_fg_color(colors[0]);
		win->draw_arc( gc, true,
			event->x - 3,
			event->y - 3,
			5, 5, 0, 23040);

		last_x = event->x;
		last_y = event->y;
	}

	return false;
}
コード例 #5
0
ファイル: dialog_setup.cpp プロジェクト: ZurbaXI/synfig
bool
BlackLevelSelector::redraw(GdkEventExpose */*bleh*/)
{
	//!Check if the window we want draw is ready
	Glib::RefPtr<Gdk::Window> window = get_window();
	if(!window) return true;

	const int w(get_width()),h(get_height());

	Gdk::Color color;

	Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));

	int i;

	// Draw the gradient
	for(i=0;i<w;i++)
	{
		color.set_rgb(i*65536/w,i*65536/w,i*65536/w);

		gc->set_rgb_fg_color(color);
		window->draw_rectangle(gc, true, i, 0, 1, h);
	}

	// Draw a frame
	gc->set_rgb_fg_color(Gdk::Color("#000000"));
	window->draw_rectangle(gc, false, 0, 0, w-1, h-1);

	// Draw the position of the current value
	i=(int)(level*w+0.5);
	gc->set_rgb_fg_color(Gdk::Color("#ff0000"));
	window->draw_rectangle(gc, true, i, 1, 1, h-1);

	// Print out the value
	Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
	layout->set_text(etl::strprintf("%0.01f%%",level*100.0f));
	layout->set_alignment(Pango::ALIGN_CENTER);
	gc->set_rgb_fg_color(Gdk::Color("#a00000"));
	window->draw_layout(gc, w/2, 4, layout);

	return true;
}
コード例 #6
0
ファイル: classificationcell.cpp プロジェクト: tommite/csmaa
bool ClassificationCell::on_expose_event(GdkEventExpose *e)
{
  char buf[10];
  sprintf (buf, "%.0f", round(value));

  //  std::stringstream buf;
  //buf.precision(0);
  //buf.setf(std::ios::fixed, std::ios::floatfield);
  int w=0, h=0;

  Glib::RefPtr<Gdk::Window> window = get_window();
  if (value > 50.0)
    window->set_background(green);
  else if (value > 25.0)
    window->set_background(lightgreen);
  else if (value > 0.05)
    window->set_background(lightred);
  else
    window->set_background(white);

  window->clear();
  window->draw_rectangle(gc, false, 0, 0, 39, 29);

  //  buf << value;
  
  
  //  printf ("string %s\n", buf.str().c_str());

  Glib::RefPtr<Pango::Layout> p = create_pango_layout(Glib::ustring(buf));
  p->set_alignment(Pango::ALIGN_CENTER);
  p->get_pixel_size(w, h);
  int nx = (40-w) / 2 + 1;
  int ny = (30-h) / 2 + 1;
  window->draw_layout(gc, nx, ny, p);
  window->invalidate_rect(Gdk::Rectangle(0,0,40,30), false);
  
  return true;
}
コード例 #7
0
void Creater::draw_character()
{
	if (cur_chars_.size() == 0)
		return;

	Glib::RefPtr<Gdk::Window> win = drawing_.get_window();
	Glib::RefPtr<Gdk::GC> gc = drawing_.get_style()->get_black_gc();

	stroke_num = 0;
	for (Stroke::iterator si = cur_char_->strokes_begin();
	     si != cur_char_->strokes_end();
	     ++si)
	{
		// draw the stroke body
		gc->set_rgb_fg_color(colors[2]);
		for (Point::iterator pi = si->points_begin();
		     pi != si->points_end() - 1;
		     ++pi)
		{
			win->draw_line( gc,
				pi->x(), pi->y(),
				(pi+1)->x(), (pi+1)->y());
		}

		// draw a number before each stroke
		stringstream ss;
		ss << ++stroke_num;
		Glib::RefPtr<Pango::Layout> num = create_pango_layout(ss.str());
		int lx, ly;
		num->get_size(lx, ly);
		win->draw_layout(
			gc,
			si->points_begin()->x() - lx / Pango::SCALE - 5,
			si->points_begin()->y() - ly / Pango::SCALE - 5,
			num
		);

		// enchant the beginning and ending points
		Point::iterator pi[2] =
			{ si->points_begin(), si->points_end() - 1 };

		for (int i=0;i<2;++i)
		{
			gc->set_rgb_fg_color(colors[i]);
			win->draw_arc( gc, true,
				pi[i]->x() - 3, pi[i]->y() - 3,
				5, 5, 0, 23040);
		}
	}

	// get the recognizer instance
	Recognizer & rec = Recognizer::Instance();

	stroke_num = 0;
	// draw the normalized version
	int scale = 100;
	Character nc = rec.normalize( *cur_char_ );
	for (Stroke::iterator si = nc.strokes_begin();
	     si != nc.strokes_end();
	     ++si)
	{
		gc->set_rgb_fg_color(colors[3]);
		for (Point::iterator pi = si->points_begin();
		     pi != si->points_end() - 1;
		     ++pi)
		{
			win->draw_line( gc,
				pi->x() * scale, pi->y() * scale,
				(pi+1)->x() * scale, (pi+1)->y() * scale);
			win->draw_arc( gc, true,
				pi->x() * scale - 3, pi->y() * scale - 3,
				5, 5, 0, 23040);
		}

		// draw a number before each stroke
		Glib::RefPtr<Pango::Layout> num =
			create_pango_layout(boost::lexical_cast<std::string>(++stroke_num));
		int lx, ly;
		num->get_size(lx, ly);
		win->draw_layout(
			gc,
			si->points_begin()->x() * scale - lx / Pango::SCALE - 5,
			si->points_begin()->y() * scale - ly / Pango::SCALE - 5,
			num
		);

		// enchant the beginning and ending points
		Point::iterator pi[2] =
			{ si->points_begin(), si->points_end() - 1 };

		for (int i=0;i<2;++i)
		{
			gc->set_rgb_fg_color(colors[i]);
			win->draw_arc( gc, true,
				pi[i]->x() * scale - 3, pi[i]->y() * scale - 3,
				5, 5, 0, 23040);
		}
	}

}
コード例 #8
0
bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
{
	Glib::RefPtr<Gdk::Window> window = get_window();

	if(!window) return false;

	Glib::RefPtr<Gdk::GC>	gc = Gdk::GC::create(window);
	if(!gc) return false;

	//synfig::info("Drawing Timeslider");
	//clear	and update to current values
	//invalidated = false;
	//update_times();

	//draw grey rectangle
	Gdk::Color	c("#7f7f7f");
	gc->set_rgb_fg_color(c);
	gc->set_background(c);

	//Get the data for the window and the params to draw it...
	int w = get_width(), h = get_height();

	window->draw_rectangle(gc,true,0,0,w,h);

	const double EPSILON = 1e-6;
	if(!adj_timescale || w == 0) return true;

	//Get the time information since we now know it's valid
	double 	start = adj_timescale->get_lower(),
			end = adj_timescale->get_upper(),
			current = adj_timescale->get_value();

	if(end-start < EPSILON) return true;

	//synfig::info("Drawing Lines");

	//draw all the time stuff
	double dtdp = (end - start)/get_width();
	double dpdt = 1/dtdp;

	//lines

	//Draw the time line...
	double tpx = (current-start)*dpdt;
	gc->set_rgb_fg_color(Gdk::Color("#ffaf00"));
	window->draw_line(gc,round_to_int(tpx),0,round_to_int(tpx),fullheight);

	//normal line/text color
	gc->set_rgb_fg_color(Gdk::Color("#333333"));

	int ifps = round_to_int(fps);
	if (ifps < 1) ifps = 1;

	std::vector<double> ranges;

	unsigned int pos = 0;

	// build a list of all the factors of the frame rate
	for (int i = 1; i*i <= ifps; i++)
		if ((ifps%i) == 0)
		{
			ranges.insert(ranges.begin()+pos, i/fps);
			if (i*i != ifps)
				ranges.insert(ranges.begin()+pos+1, ifps/i/fps);
			pos++;
		}

	// fill in any gaps where one factor is more than 2 times the previous
	std::vector<double>::iterator iter, next;
	pos = 0;
	for (pos = 0; pos < ranges.size()-1; pos++)
	{
		iter = ranges.begin()+pos;
		next = iter+1;
		if (*iter*2 < *next)
			ranges.insert(next, *iter*2);
	}

	double more_ranges[] = {
		2, 3, 5, 10, 20, 30, 60, 90, 120, 180,
		300, 600, 1200, 1800, 2700, 3600, 3600*2,
		3600*4, 3600*8, 3600*16, 3600*32, 3600*64,
		3600*128, 3600*256, 3600*512, 3600*1024 };

	ranges.insert(ranges.end(), more_ranges, more_ranges + sizeof(more_ranges)/sizeof(double));

	double lowerrange = dtdp*140, upperrange = dtdp*280;
	double midrange = (lowerrange + upperrange)/2;

	//find most ideal scale
	double scale;
	next = binary_find(ranges.begin(), ranges.end(), midrange);
	iter = next++;

	if (iter == ranges.end()) iter--;
	if (next == ranges.end()) next--;

	if (abs(*next - midrange) < abs(*iter - midrange))
		iter = next;

	scale = *iter;

	// subdivide into this many tick marks (8 or less)
	int subdiv = round_to_int(scale * ifps);

	if (subdiv > 8)
	{
		const int ideal = subdiv;

		// find a number of tick marks that nicely divides the scale
		// (5 minutes divided by 6 is 50s, but that's not 'nice' -
		//  5 ticks of 1m each is much simpler than 6 ticks of 50s)
		for (subdiv = 8; subdiv > 0; subdiv--)
			if ((ideal <= ifps*2       && (ideal % (subdiv           )) == 0) ||
				(ideal <= ifps*2*60    && (ideal % (subdiv*ifps      )) == 0) ||
				(ideal <= ifps*2*60*60 && (ideal % (subdiv*ifps*60   )) == 0) ||
				(true                  && (ideal % (subdiv*ifps*60*60)) == 0))
				break;

		// if we didn't find anything, use 4 ticks
		if (!subdiv)
			subdiv = 4;
	}

	time_per_tickmark = scale / subdiv;

	//get first valid line and its position in pixel space
	double time = 0;
	double pixel = 0;

	int sdindex = 0;

	double subr = scale / subdiv;

	//get its position inside...
	time = ceil(start/subr)*subr - start;
	pixel = time*dpdt;

	//absolute time of the line to be drawn
	time += start;

	{ //inside the big'n
		double t = (time/scale - floor(time/scale))*subdiv; // the difference from the big mark in 0:1
		//sdindex = (int)floor(t + 0.5); //get how far through the range it is...
		sdindex = round_to_int(t); //get how far through the range it is...
		if (sdindex == subdiv) sdindex = 0;

		//synfig::info("Extracted fr %.2lf -> %d", t, sdindex);
	}

	//synfig::info("Initial values: %.4lf t, %.1lf pixels, %d i", time,pixel,sdindex);

	//loop to draw
	const int heightbig = 12;
	const int heightsmall = 4;

	int width = get_width();
	while( pixel < width )
	{
		int xpx = round_to_int(pixel);

		//draw big
		if(sdindex == 0)
		{
			window->draw_line(gc,xpx,0,xpx,heightbig);
			//round the time to nearest frame and draw the text
			Time tm((double)time);
			if(get_global_fps()) tm.round(get_global_fps());
			Glib::ustring timecode(tm.get_string(get_global_fps(),App::get_time_format()));

			//gc->set_rgb_fg_color(Gdk::Color("#000000"));
			layout->set_text(timecode);
			Pango::AttrList attr_list;
			// Aproximately a font size of 8 pixels.
			// Pango::SCALE = 1024
			// create_attr_size waits a number in 1000th of pixels.
			// Should be user customizable in the future. Now it is fixed to 10
			Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10));
			pango_size.set_start_index(0);
			pango_size.set_end_index(64);
			attr_list.change(pango_size);
			layout->set_attributes(attr_list);
			window->draw_layout(gc,xpx+2,0,layout);
		}else
		{
			window->draw_line(gc,xpx,0,xpx,heightsmall);
		}

		//increment time and position
		pixel += subr / dtdp;
		time += subr;

		//increment index
		if(++sdindex >= subdiv) sdindex -= subdiv;
	}

	return true;
}
コード例 #9
0
bool DimRegionChooser::on_expose_event(GdkEventExpose* event)
{
    if (!region) return true;

    // This is where we draw on the window
    Glib::RefPtr<Gdk::Window> window = get_window();
    Glib::RefPtr<Pango::Context> context = get_pango_context();

    Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context);

    window->clear();

    // draw labels on the left (reflecting the dimension type)
    int y = 0;
    double maxwidth = 0;
    for (int i = 0 ; i < region->Dimensions ; i++) {
        int nbZones = region->pDimensionDefinitions[i].zones;
        if (nbZones) {
            const char* dstr;
            char dstrbuf[10];
            switch (region->pDimensionDefinitions[i].dimension) {
            case gig::dimension_none: dstr="none"; break;
            case gig::dimension_samplechannel: dstr="samplechannel"; break;
            case gig::dimension_layer: dstr="layer"; break;
            case gig::dimension_velocity: dstr="velocity"; break;
            case gig::dimension_channelaftertouch: dstr="channelaftertouch"; break;
            case gig::dimension_releasetrigger: dstr="releasetrigger"; break;
            case gig::dimension_keyboard: dstr="keyboard"; break;
            case gig::dimension_roundrobin: dstr="roundrobin"; break;
            case gig::dimension_random: dstr="random"; break;
            case gig::dimension_smartmidi: dstr="smartmidi"; break;
            case gig::dimension_roundrobinkeyboard: dstr="roundrobinkeyboard"; break;
            case gig::dimension_modwheel: dstr="modwheel"; break;
            case gig::dimension_breath: dstr="breath"; break;
            case gig::dimension_foot: dstr="foot"; break;
            case gig::dimension_portamentotime: dstr="portamentotime"; break;
            case gig::dimension_effect1: dstr="effect1"; break;
            case gig::dimension_effect2: dstr="effect2"; break;
            case gig::dimension_genpurpose1: dstr="genpurpose1"; break;
            case gig::dimension_genpurpose2: dstr="genpurpose2"; break;
            case gig::dimension_genpurpose3: dstr="genpurpose3"; break;
            case gig::dimension_genpurpose4: dstr="genpurpose4"; break;
            case gig::dimension_sustainpedal: dstr="sustainpedal"; break;
            case gig::dimension_portamento: dstr="portamento"; break;
            case gig::dimension_sostenutopedal: dstr="sostenutopedal"; break;
            case gig::dimension_softpedal: dstr="softpedal"; break;
            case gig::dimension_genpurpose5: dstr="genpurpose5"; break;
            case gig::dimension_genpurpose6: dstr="genpurpose6"; break;
            case gig::dimension_genpurpose7: dstr="genpurpose7"; break;
            case gig::dimension_genpurpose8: dstr="genpurpose8"; break;
            case gig::dimension_effect1depth: dstr="effect1depth"; break;
            case gig::dimension_effect2depth: dstr="effect2depth"; break;
            case gig::dimension_effect3depth: dstr="effect3depth"; break;
            case gig::dimension_effect4depth: dstr="effect4depth"; break;
            case gig::dimension_effect5depth: dstr="effect5depth"; break;
            default:
                sprintf(dstrbuf, "%d",
                        region->pDimensionDefinitions[i].dimension);
                dstr = dstrbuf;
                break;
            }
            layout->set_text(dstr);

            Pango::Rectangle rectangle = layout->get_logical_extents();
            double text_w = double(rectangle.get_width()) / Pango::SCALE;
            if (text_w > maxwidth) maxwidth = text_w;
            double text_h = double(rectangle.get_height()) / Pango::SCALE;
            Glib::RefPtr<const Gdk::GC> fg = get_style()->get_fg_gc(get_state());
            window->draw_layout(fg, 4, int(y + (h - text_h) / 2 + 0.5), layout);

        }
        y += h;
    }

    // draw dimensions' zones areas
    y = 0;
    int bitpos = 0;
    label_width = int(maxwidth + 10);
    for (int i = 0 ; i < region->Dimensions ; i++) {
        int nbZones = region->pDimensionDefinitions[i].zones;
        if (nbZones) {
            // draw focus rectangle around dimension's label and zones
            if (has_focus() && focus_line == i) {
                Gdk::Rectangle farea(0, y, 150, 20);
                get_style()->paint_focus(window, get_state(), farea, *this, "",
                                         0, y, label_width, 20);
            }

            Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();
            // draw top and bottom lines of dimension's zones
            window->draw_line(black, label_width, y, w - 1, y);
            window->draw_line(black, w - 1, y + h - 1, label_width, y + h - 1);
            // erase whole dimension's zones area
            window->draw_rectangle(get_style()->get_white_gc(), true,
                                   label_width + 1, y + 1, (w - label_width - 2), h - 2);

            int c = 0;
            if (dimregno >= 0) {
                int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos);
                c = dimregno & mask; // mask away this dimension
            }
            bool customsplits =
                ((region->pDimensionDefinitions[i].split_type == gig::split_type_normal &&
                 region->pDimensionRegions[c]->DimensionUpperLimits[i]) ||
                (region->pDimensionDefinitions[i].dimension == gig::dimension_velocity &&
                 region->pDimensionRegions[c]->VelocityUpperLimit));

            // draw dimension's zone borders
            if (customsplits) {
                window->draw_line(black, label_width, y + 1, label_width, y + h - 2);
                for (int j = 0 ; j < nbZones ; j++) {
                    gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
                    int upperLimit = d->DimensionUpperLimits[i];
                    if (!upperLimit) upperLimit = d->VelocityUpperLimit;
                    int v = upperLimit + 1;
                    int x = int((w - label_width - 1) * v / 128.0 + 0.5);
                    window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2);
                }
            } else {
                for (int j = 0 ; j <= nbZones ; j++) {
                    int x = int((w - label_width - 1) * j / double(nbZones) + 0.5);
                    window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2);
                }
            }

            // draw fill for currently selected zone
            if (dimregno >= 0) {
                gc->set_foreground(red);
                int dr = (dimregno >> bitpos) & ((1 << region->pDimensionDefinitions[i].bits) - 1);
                if (customsplits) {
                    int x1 = 0;
                    for (int j = 0 ; j < nbZones ; j++) {
                        gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
                        int upperLimit = d->DimensionUpperLimits[i];
                        if (!upperLimit) upperLimit = d->VelocityUpperLimit;
                        int v = upperLimit + 1;
                        int x2 = int((w - label_width - 1) * v / 128.0 + 0.5);
                        if (j == dr && x1 < x2) {
                            window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1,
                                                   (x2 - x1) - 1, h - 2);
                            break;
                        }
                        x1 = x2;
                    }
                } else {
                    if (dr < nbZones) {
                        int x1 = int((w - label_width - 1) * dr / double(nbZones) + 0.5);
                        int x2 = int((w - label_width - 1) * (dr + 1) / double(nbZones) + 0.5);
                        window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1,
                                               (x2 - x1) - 1, h - 2);
                    }
                }
            }

            y += h;
        }
        bitpos += region->pDimensionDefinitions[i].bits;
    }