Navigation: Up, Table of Contents, Bibliography, Index, Title Page

## CGAL::Window_stream

#include <CGAL/IO/Window_stream.h>

### Definition

The functionality described in this section is provided through LEDA or the CGAL port of the LEDA window lib. The CGAL port has an interface close to the LEDA window, but operations using LEDA geometry classes were removed and the names of the used types and enums were changed from leda_name to CGAL::name, leda_string was replaced by std::string and leda_list was replaced by std::list. If the window port is used, the macro CGAL_USE_CGAL_WINDOW is defined. The header file <CGAL/IO/cgal_window_redefine.h> offers redefinitions of the LEDA names. If you use this file you should include it after the inclusion of your other CGAL headers. The CGAL port of the LEDA window lib can be downloaded for various platforms from the CGAL web page. Note that Algorithmic Solutions Software GmbH has offered us the possibility to provide the ported version of the LEDA window.

An instance of type Window_stream is a two-dimensional window for graphical IO. The input and output operations perform a mapping from object coordinates to window coordinates. Actually, Window_stream is identical to the LEDA class leda_window, if LEDA is used and to the ported version of the LEDA window class, if LEDA is not used. Therefore, the rich functionality of leda_window is available on Window_stream as well, for example panels. In addition, the class Window_stream provides input and output operators for the classes which are defined in the CGAL kernel. Instances of Window_stream should be initialized with a coordinate frame (by calling member function init) and must be displayed (by calling member function display) before drawing.

For further information on leda_window, we refer to the LEDA manual.

### Creation

Window_stream W;
| creates a squared window with maximal possible edge length (minimum of width and height of the display).
Window_stream W ( const char* label);
| creates a maximal squared window with frame label label.
Window_stream W ( float width, float height);
| creates a window W of physical size width × height pixels.
Window_stream W ( float width, float height, const char* label);
| creates a window W of physical size width × height pixels and frame label label.

In addition, instances of type Window_stream can be created by the functions

Window_stream* | create_demo_window ()
|  | creates a window of 512 × 512 pixels, sets the window label to CGAL, and initializes the object space that is mapped to the physical window to [-1.0, 1.0] × [-1.0, 1.0]. Returns a pointer to the window created.
Window_stream* | create_and_display_demo_window ()
|  | creates a window of 512 × 512 pixels, sets the window label to CGAL, initializes the object space that is mapped to the physical window to [-1.0, 1.0] × [-1.0, 1.0] and displays it at default position on the display. Returns a pointer to the window created.
Window_stream* |
create_demo_window ( | float width, float height, const char* str, double x_extension)
|  | creates a window of width × height pixels, sets the window label to str, and initializes the x-range in object space that is mapped to the physical window by [-x_extension, x_extension]. The y-range is initialized such that the origin is at the center of the window. Returns a pointer to the window created.
Window_stream* |
create_and_display_demo_window ( | float width, float height, const char* str, double x_extension)
|  | creates a window of width × height pixels, sets the window label to str, and initializes the x-range in object space that is mapped to the physical window by [-x_extension, x_extension]. The y-range is initialized such that the origin is at the center of the window. The window is displayed at default position on the display. Returns a pointer to the window created.

### Operations

A window is initialized by a part of the object space by

void | W.init ( double x0, double x1, double y0)
|  | initializes the part of the object space that is mapped to the physical window to [x0,x1] × [y0,y0 + height*(x1-x0)/width], where width and height are the width and the height of the window in pixels.

To display a window, the following functions can be used. Note that W.display() has to be called before all drawing operations on W and that all operations adding panel items to W have to be called before the first call of W.display().

void | W.display () | opens W and displays it at the default position, i.e. with its right upper corner in the upper right corner of the screen.
void | W.display ( int x, int y)
|  | opens W and displays it with its left upper corner at position (x,y).
void | W.display ( Window_stream& W0, int x, int y)
void | W.display ( int x, int y, Window_stream& W0)
|  | opens W and displays it with its left upper corner at position (x,y) relative to the upper left corner of window W0.

See the LEDA Manual [MNSU] for further operations on leda_window.

### Output Operators

The output operator is defined for all geometric classes in the CGAL kernel.

Window_stream& | Window_stream &W << Class c
|  | inserts object c into the stream W.
Window_stream& | Window_stream &W << Color c
|  | changes the foreground color for the next objects that will be inserted into W.

Note that CGAL points are drawn using LEDA functions for drawing nodes of a graph. Before drawing points, the size for drawing nodes should be adjusted, either by calling member function set_node_width(int) or by

void | cgalize ( Window_stream& w)
|  | sets a few default values for drawing in window w. In particular, node width is set to 3 and line width to 2.

### Input Operators

The input operator is defined for all geometric classes in the CGAL kernel. The coordinates of the geometric objects are in object space. Data are entered with the left mouse button.

Window_stream& | Window_stream &W >> Class &c
|  | extracts object c from the stream W.

### 3D Objects with Window Stream

3D objects can be used with Window_stream. The stream output operator << projects them to the xy-plane. The stream input operator >> sets the z coordinate to zero.

#include <CGAL/IO/window_stream_xy_3.h>

Navigation: Table of Contents, Bibliography, Index, Title Page

The CGAL Project . Tue, December 21, 2004 .