Search
Display Graphs in 3D

The DiagramView3D control allows displaying diagrams in 3D. It could be used to display graphs with associated 3D spatial data, such as structural formulas of chemical compounds, or to display dense graphs that otherwise would look too cluttered in 2D. Look at the SpringLayout solution in the Samples folder that demonstrates how to apply a 3D SpringLayout algorithm and display a 3D view of the diagram.

Set the camera position programmatically

The CameraPosition property specifies the position of the camera in 3D space. To specify the camera's pitch, roll and yaw angles, set the CameraRotation property. PointCameraTo lets you direct the camera to a specified point. The ViewerDistance property specifies the distance of the viewer from the camera. After changing the camera position or direction, or after changing the location of graph nodes, call the ResetProjection method. It calculates the new projection coordinates of nodes and updates the view.

Set the camera position interactively

The following mouse and keyboard actions allow moving the camera around the 3D scene:

  • Mouse drag: Moves the camera across the plane perpendicular to direction of the camera.
  • CTRL+mouse drag: Rotate the camera by changing the pitch and yaw angles.
  • Mouse wheel: Causes moving the camera forwards or backwards.
  • CTRL+mouse wheel: Rolls the camera around the Z-axis.

Set the EnableOrbitingCamera property to true to enable using the CTRL key to move the camera in an orbit around a node.

Coordinate system

DiagramView3D uses the following coordinate system:

The X axis is horizontal and points to the right.
The Y axis is vertical and points upwards.
The Z axis specifies depth and its values grow with distance.

Edit graphs in 3D

Set the Behavior property to a value different than DoNothing to allow users select and modify existing items or draw new ones. New items are drawn in a plane in front of the camera, orthogonal to the camera direction. The distance from the camera to this plane can be specified through the CreationPlaneDistance property.