Definition
The data type d3_window supports three-dimensional visualization.
It uses a LEDA window to visualize and animate
three-dimensional drawings of graph.
For this purpose we need to assign positions in 3d space to all nodes of the
graph (see init-operations and set_position-operation). The edges of the
visualized graph are drawn as straight-line-segments between the 3d positions of
their source and target nodes. Note all edges of the graph must have a reversal edge.
If the graph to be shown is a planar map the faces can be shaded in different
grey scales (if the solid flag is true).
The graph can be drawn with the draw-operation and animated with the move-operation.
The draw-operation draws a frontal projection of the graph on the output window.
The move-operation starts a simple animation mode.
First it draws the graph, then it rotates it (the rotation depends on the x_rotation
and y_rotation flags and the mouse position) and finally returns the pressed mouse button.
Every object of type d3_window maintains a set of parameters:
In addition, a d3_window stores information assigned to the nodes and edges of the visualized graph.
#include < LEDA/graphics/d3_window.h >
Creation
d3_window | D(window& W, const graph& G, double rot1=0, double rot2=0) | |
creates an instance D of the data type d3_window. The output window of D is W. The visualized graph is G. | ||
d3_window | D(window& W, const graph& G, const node_array<vector>& pos) | |
creates an instance D of the data type d3_window. The output window of D is W. The visualized graph is G. The positions of the nodes are given in pos. Precondition the vectors in pos are three-dimensional. | ||
d3_window | D(window& W, const graph& G, const node_array<rat_vector>& pos) | |
creates an instance D of the data type d3_window. The output window of D is W. The visualized graph is G. The positions of the nodes are given in pos. Precondition the vectors in pos are three-dimensional. |
Operations
void | D.init(const node_array<vector>& pos) | |
initializes D by setting the node positions of the visualized graph to the positions given in pos. Precondition the vectors in pos are three-dimensional. | ||
void | D.init(const node_array<rat_vector>& pos) | |
initializes D by setting the node positions of the visualized graph to the positions given in pos. Precondition the vectors in pos are three-dimensional. | ||
void | D.init(const graph& G, const node_array<vector>& pos) | |
initializes D by setting the visualized graph to G and the node positions of the visualized graph to the positions given in pos. Precondition the vectors in pos are three-dimensional. | ||
void | D.draw() | draws the contents of D (see also Definition). |
int | D.move() | animates the contents of D until a button is pressed and returns the pressed mouse button. If the movement is stopped or no mouse button is pressed, NO_BUTTON will be returned, else the number of the pressed mouse button will be returned (see also Definition and the get_mouse operation of the window data type). |
int | D.get_mouse() | does the same as move. |
int | D.read_mouse() | calls move as long as move returns NO_BUTTON. Else the movement is stopped, and the number of the pressed mouse button is returned. |
void | D.set_position(node v, double x, double y, double z) | |
sets the position of node v in the visualized graph D to (x,y,z). |
Get- and set-operations
The following operations can be used to get and set the parameters of D.
The set-operations return the previous value of the parameter.
bool | D.get_x_rotation() | returns true, if D has rotation about the x-axis enabled, false otherwise. |
bool | D.get_y_rotation() | returns true, if D has rotation about the y-axis enabled, false otherwise. |
bool | D.set_x_rotation(bool b) | enables (disables) rotation about the x-axis. |
bool | D.set_y_rotation(bool b) | enables (disables) rotation about the y-axis. |
bool | D.get_elim() | returns the hidden line elimination flag. |
bool | D.set_elim(bool b) | sets the hidden line elimination flag to b. If b is true, hidden lines will be eliminated, if b is false, hidden lines will be shown. |
bool | D.get_solid() | returns the solid flag of D. |
bool | D.set_solid(bool b) | sets the solid flag of D to b. If b is true and the current graph of D is a planar map, its faces will be painted in different grey scales, otherwise the faces will be painted white. |
bool | D.get_draw_edges() | return true, if edges will be drawn, false otherwise. |
bool | D.set_draw_edges(bool b) | enables (disables) the redraw of the edges of D. |
string | D.get_message() | returns the message that will be displayed on top of the drawing area of the window. |
string | D.set_message(string msg) | sets the message that will be displayed on top of the drawing area of the window to msg . |
void | D.set_node_color(color c) | sets the color of all nodes of D to c. |
void | D.set_edge_color(color c) | sets the color of all edges of D to c. |
color | D.get_color(node v) | returns the color of node v. |
color | D.set_color(node v, color c) | |
sets the color of node v to c. | ||
color | D.get_color(edge e) | returns the color of edge e. |
color | D.set_color(edge e, color c) | |
sets the color of edge e to c. | ||
bool | D.get_arrow(edge e) | returns true, if e will be painted with an arrow, false otherwise. |
bool | D.set_arrow(edge e, bool ar) | |
if ar is true, e will be painted with an arrow, otherwise without an arrow. | ||
void | D.get_d2_position(node_array<point>& d2pos) | |
returns the two-dimensional positions of the nodes of the graph of D in d2pos. |