An instance of data type GeoWin is an editor for sets of geometric objects. It can be used for the visualization of result and progression of geometric algorithms.
GeoWin manages the geometric objects in so called scenes. A scene contains a container storing geometric objects (the contents of the scene) and provides all operations that GeoWin needs to edit it. Every scene maintains a set of parameters:
There are three kinds of scenes:
The basic scene type works on every container type that provides an interface as the list of the STL library. More precisely, has to support the following type definitions and operations:
That means, that LEDA lists can be used as well as containers.
A scene of type is a user editable scene. GeoWin is an editor for this kind of containers.
A scene of type is not independently editable. Instead its contents (a container of type ) is computed by a user defined update function or update object with an update function. The update function computes the contents of the result scene every time when another scene (the input scene for the result scene) changes. The update function
gets the contents of this input scene (a container of type ) and computes the contents of the result scene. We say that the result scene depends on its input scene.
Both Edit and Result scenes are derived from Basic scenes. The geometric objects stored in the containers of the scenes have to support input and output operators for IO-streams and the LEDA window and the output operator to the LEDA class for Postscript output. Please note that the type is the scene item type used in . It is a pointer to the base class of all scene types.
| |
creates a GeoWin gw with frame label .
| |
| |
creates a GeoWin gw. gw is constructed with
frame label and physical size .
|
a) Main Operations
The and operations use member templates. If your compiler does not support member templates, you should use the function templates and with gw as an additional first parameter.
The following operation can be used to create edit scenes. The has to be a (where T is the type of your geometric objects) and must be registered in (see Registration of types).
| ||
|
| |
creates a new edit scene for . will be edited by gw . |
The following operations can be used to create result scenes.
Result scenes use the contents of another scene (the input scene)
as the input for a function (the update function).
This function computes the contents of the result scene. The update function
is called every time when the contents of the input scene changes.
Instead of using an update function you can use an update object that encapsulates
an update function.
The type of this update object has to be
( - type of the container in the input scene,
- type of the container in the result scene) or a class derived from it.
A derived class should overwrite the virtual update function
of the base class to provide a user defined update function. The class has 3 constructors getting function pointers as arguments:
These functions will be called in the update function of the update object. The first is the normal update function that gets the contents of the input scene and computes the contents of the output scene. In the second variant the contents of the result scene will first be cleared, then the update function will be called and will be inserted in the result scene. In the third variant the contents of the result scene will be cleared, and then the object returned by the update function will be inserted in the result scene.
It is also possible to provide user defined redraw for a scene. For this purpose we use redraw objects derived from class . The derived class has to overwrite the virtual redraw function
of the base class to provide a user defined redraw function. The first three parameters of this function are the redraw window and the first and second drawing color ( and ) of the scene. If you want user defined postscript output, the derived class has to overwrite the virtual function
of the base class. The first parameter of this function is the output Postscript file (see Manual/contrib in your LEDA distribution for a documentation of the ps_file class), the other parameters are the first and second drawing color ( and ) of the scene. The function has to return false, if the contents of the scene should be drawn to the Postscript output file too, true otherwise.
In the following member-templates and have to be a , where is the type of your geometric objects. is the type of the contents of the input scene, the type of the contents of the created result scene.
| ||||
|
| |||
where is the type , creates a new result scene with name . The input scene for this new result scene will be . The update function will be . Note that this member-template does not work with Visual C++. You should use there one of the other member templates for creating result scenes. | ||||
| ||||
|
| |||
creates a new result scene with name . The input scene for this new result scene will be . The update object will be . | ||||
| ||||
|
| |||
creates a new result scene with name . The input scene for this new result scene will be . The update object will be . The redraw object will be . | ||||
| ||||
|
| |||
If the contents of scene matches type , then the contents of scene is copied to . | ||||
|
| starts the interactive mode of gw . The operation returns if either the or button was pressed. | ||
|
| |||
edits scene . Returns when the Quit Button was pressed, otherwise. Precondition: must be an edit scene. |
b) Window Operations
|
| closes gw . | ||
|
| returns the minimal x-coordinate of the drawing area. | ||
|
| returns the minimal y-coordinate of the drawing area. | ||
|
| returns the maximal x-coordinate of the drawing area. | ||
|
| returns the maximal y-coordinate of the drawing area. | ||
|
| |||
opens gw at . | ||||
|
| returns a reference to the drawing window. | ||
|
| |||
same as ::init(, , ). | ||||
|
| |||
initializes the window so that the rectangle with lower left corner and upper right corner is visible at whole. The window must be open. | ||||
|
| redraws the contents of gw (all visible scenes). | ||
|
| |||
sets the mouse cursor to . |
c) Scene Operations
|
| |
returns the scene named or nil if there is no scene named . | ||
|
| |
makes scene the active scene of gw. | ||
|
| |
returns the active scene of gw. | ||
|
| |
returns true if is an active scene in a GeoWin. |
The following and operations can be used for retrieving and
changing scene parameters. All operations return the previous
value.
|
| |
returns the name of scene . | ||
|
| |
gives scene the name . If there is already a scene with name , another name is constructed based on and is given to . The operation will return the given name. | ||
|
| |
returns the boundary drawing color of scene . | ||
|
| |
sets the boundary drawing color of scene to . | ||
|
| |
returns the second drawing color (used for selected boundaries) of scene . | ||
|
| |
sets the second drawing color of scene (used for selected boundaries) to . | ||
|
| |
returns the fill color of . | ||
|
| |
sets the fill color of to . Use color for disable filling. | ||
|
| |
returns the line width of . | ||
|
| |
returns the active line width of . | ||
|
| |
sets the line width for scene to . | ||
|
| |
sets the active line width for scene to . | ||
|
| |
returns the line style of . | ||
|
| |
sets the line style of scene to . | ||
|
| |
returns the visible flag of scene . | ||
|
| |
sets the visible flag of scene to . | ||
|
| |
sets the visible flag of all scenes that are currently in gw to . | ||
|
| |
returns the point style of . | ||
|
| |
sets the point style of to . |
The following operations can be used to set/get
individual attributes of objects in scenes.
All set operations return the previous value.
The first parameter is the scene, where the object belongs to.
The second parameter is a generic pointer to the object.
Precondition: the object belongs to the scene (is in the container
of the scene).
Note that the following operations are member templates.
| ||||
|
| |||
returns the boundary color of the object at . | ||||
| ||||
|
| |||
sets the boundary color of the object at to . | ||||
| ||||
|
| |||
returns the interior color of the object at . | ||||
| ||||
|
| |||
sets the interior color of the object at to . | ||||
| ||||
|
| |||
returns the line style of the object at . | ||||
| ||||
|
| |||
sets the line style of the object at to . |
d) Input and Output Operations
|
| |
reads the contents of from input stream . The contents of is cleared before. | ||
|
| |
writes the contents of to output stream . | ||
|
| |
writes the contents of the active scene of gw to output stream . |
e) View Operations
|
| The visible range is reduced to the half. |
|
| The visible range is doubled. |
|
| reads a rectangle from the drawing window and makes it the visible range. |
|
| changes window coordinate system, so that the objects of the currently active scene fill the window. |
|
| |
returns the name of the current background pixmap. | ||
|
| |
changes the window background pixmap to pixmap with name . For the names of supported pixmaps see /pixmaps in your LEDA include directory. The function returns the name of the previous background pixmap. |
f) Event Handling
gw provides operations for changing its default handling of events. As in the LEDA class the user can define what action should follow a mouse or key event. Constants are defined as in the LEDA class :
|
| |
Set action on condition to . is a function of type . For the corresponding action is deleted. | ||
|
| |
Get action defined for condition . | ||
|
| |
Set all actions to their default values. |
Default values are defined as follows :
|
| |
clears all actions. |
Scene events
The following event handling functions can be set for edit scenes:
The add handlers will be called when a user tries to add an object to an edit scene in GeoWin, the delete handlers will be called when the user tries to delete an object and the change handlers will be called when the user tries to change an object (for instance by moving or rotating it). The templated set operations for setting handlers uses member templates. If your compiler does not support member templates, you should use instead the templated functions , where is one the following handlers. All handling functions get as the first parameter a reference to the , where the scene belongs to.
| ||||
|
| |||
sets the handler that is called before an object is added to . must have type . gets a reference to the added object. If returns false, the object will not be added to the scene. | ||||
| ||||
|
| |||
sets the handler that is called after an object is added to . must have type . gets a reference to the added object. | ||||
| ||||
|
| |||
sets the handler that is called before an object is deleted from . must have type . gets a reference to the added object. If returns true, the object will be deleted, if returns false, the object will not be deleted. | ||||
| ||||
|
| |||
sets the handler that is called after an object is deleted from . must have type . | ||||
| ||||
|
| |||
sets the handler that is called when a geometric object from starts changing (for instance when you move it or rotate it). must have type . The handler function gets a reference to the object. | ||||
| ||||
|
| |||
sets the handler that is called before every move operation. must have type . The handler gets as the second parameter a reference to the object, as the third parameter and fourth parameter the move vector. If the handler returns true, the change operation will be executed, if the handler returns false, it will not be executed. | ||||
| ||||
|
| |||
sets the handler that is called after every move operation. must have type . The handler gets as the second parameter a reference to the object, as the third parameter and fourth parameter the move vector. | ||||
| ||||
|
| |||
sets the handler that is called before every rotate operation. must have type . The handler gets as the second parameter a reference to the object, as the 3., 4. and 5. parameter the rotation parameters. If the handler returns true, the rotate operation will be executed, if the handler returns false, it will not be executed. | ||||
| ||||
|
| |||
sets the handler that is called after every rotate operation. must have type . | ||||
| ||||
|
| |||
sets the handler that is called when a geometric object from ends changing. gets the object as the second parameter. must have type . |
Generator functions:
The following operation can be used to set a generator function for an edit scene.
The operation uses member templates.
If your compiler does not support member templates, you should use instead
the templated function instead.
| ||
|
| |
(where is the type ), sets the generator function for edit scene . The function gets the GeoWin where belongs to and a reference to the container of . The function should write the generated objects to . | ||
|
| |
(where is the type ), sets a handler function that is called when the user clicks the quit menu button. should return true for allowing quiting, false otherwise. | ||
|
| |
(where is the type ), sets a handler function that is called when the user clicks the done menu button. should return true for allowing quiting, false otherwise. |
g) Further Operations
|
| |
makes scene dependent from . That means that will be updated when the contents of changes. | ||
|
| |
deletes the dependence of scene from . | ||
|
| |
makes the frame label of gw. | ||
|
| returns the version number. |
|
| |
displays message on top of the drawing area. If is the empty string, a previously written message is deleted. | ||
|
| |
displays message in the message window of gw. If the message window is not open, it will be opened. | ||
|
| closes the message window. |
|
| clears the message window. |
|
| |||
sets a function for computing 3d output. The parameters of the function are the for that it will be set and a function pointer. The function will get the scene for that it was set, a reference to a LEDA that will be the output window and a parametrized LEDA GRAPH that will be used for visualization. |
gw can be pined at a point in the plane. As standard behavior it is
defined that moves of geometric objects will be rotations around the
pin point.
|
| |
returns the pin point in if it is set. | ||
|
| |
sets the pin point to . | ||
|
| |
deletes the pin point. | ||
|
| |
adds the help text contained in with label to the help menu of the main window. The file must exist either in the current working directory or in . Note that this operation must be called before . |
The templated operation uses member templates. If your
compiler does not support member templates, you should use
the templated function with
gw as an additional first parameter.
| ||
|
| |
adds a menu item to the "User" menu of gw. The user defined function is called whenever this menu button was pressed. This menu definition has to be finished before gw is opened. |