Example 1: Drawing Curves
Introduction
In this example, you will draw one or more curves into a diagram and define different styles for the curves.
Steps to Do
Develop Your Network
A curve requires x- and y-coordinates to be printed. You can use the CurveCreator module as input for these coordinates. The SoDiagram2D draws the curves into a SoRenderArea. You can also define the style of the curves by using the StylePalette module.
Add the modules to your workspace and connect them as seen below.
Creating a Curve
Click on the output of the CurveCreator module and open the Output Inspector.
Double-click
on the
CurveCreator module and open the panel.
You can see a large input field
Enter the following into the
Curve Table
# My first curve
0 0
1 1
2 2
3 3
4 4
5 5
10 10
50 50
Now, your Output Inspector shows a yellow line through the previously entered coordinates. Exactly the same curve is shown in the SoRenderArea.
Creating Multiple Curves
Now, update the
:
Curve Table
# My first curves
0 0 0
1 1 2
2 2 4
3 3 6
4 4 8
5 5 10
10 10 20
50 50 100
You can see two curves. The second and third columns are printed as separate curves. Both appear yellow. After checking
If the flag
Titles and Styles
Let’s do this. Open the panel of the SoDiagram2D module and check CurveCreator module and click
.
You can also define a different location of the legend and set font sizes.
Now, open the panel of the StylePalette module.
The StylePalette module allows you to define twelve different styles for curves. Initially, without manual changes, the styles are applied one after the other. The first curve gets style 1, the second curve style 2, and so on.
Open the panel of your CurveCreator module again and define
your curves.
You now applied the style three for your first curve and style six for the second. This is how you can create twelve different curves with a unique appearance each.
Using Multiple Tables for Curve Generation
In addition to adding multiple columns for different y-coordinates, you can also define multiple tables as input, so that you can also have different x-coordinates for multiple curves.
Update the
:
Curve Table
# My first curves
0 0 0
1 1 2
2 2 4
3 3 6
4 4 8
5 5 10
10 10 20
50 50 100
---
# My third curve
0 0
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
9 81
10 100
Also add another title to your curves and define a third style.
Summary
- Curves can be created to draw two-dimensional diagrams.
- The
StylePalettemodule allows you to define the appearance of a curve. - Details of the different curves can be visualized by using the
SoDiagram2Dmodule.
CurveCreator module.












