Algorithmic Solutions > LEDA > LEDA Guide > GeoWin > Programming Interface > Redraw Functions and Objects > Example Redraw Functions

Example Redraw Functions

The following program shows how to use an alternative redraw function for a scene in GeoWin. (See also Example Update and Redraw Objects.)

The redraw function draw_seg() draws a segment s as a red arrow in window w and returns a reference to w.

The main function defines a GeoWin geow and a list<segment> lseg. The segments are generated using an input scene sc of geow. Then the drawing function for sc is set to draw_seg(). Finally, geow is opened in interactive mode with edit scene sc_points.

Important Notice: Redraw functions are member template functions. Unfortunately, MSVC++ 6 does not support such functions. Please use redraw objects with this compiler.

#include <LEDA/geowin.h>
#include <LEDA/window.h>
#include <LEDA/segment.h>
#include <LEDA/float_geo_alg.h>

using namespace leda;

window& draw_seg(window& w, const segment& s, int)
{
  w.draw_arrow(s.source().to_float(), 
               s.target().to_float(), red);
  return w;
}

int main()
{
  GeoWin geow;
 
  list<segment> lseg;
  GeoEditScene<list<segment> >* sc= geow.new_scene(lseg);

  geowin_set_draw_object_fcn(sc, draw_seg);
 
  geow.edit(sc);

  return 0;
}

See also:

Redraw Functions and Objects

GeoWin

Programming Interface

Interactive Interface

Example Update and Redraw Objects


Windows


Geometry

Basic Data Types for 2D Geometry


Manual Pages:

Manual Page GeoWin




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH