Skip to content

Commit da50996

Browse files
authored
First version of tutorial for SoViewportRegion (#111)
1 parent ad05258 commit da50996

File tree

16 files changed

+818
-0
lines changed

16 files changed

+818
-0
lines changed

mevislab.github.io/content/examples/basic_mechanisms/soviewportregion.mlab

Lines changed: 654 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: "Example 6: Creating Multi-View Layouts Using SoViewportRegion"
3+
date: 2025-04-22
4+
status: "OK"
5+
draft: false
6+
weight: 460
7+
tags: ["Beginner", "Tutorial", "SoViewportRegion", "Layout", "Multi-View"]
8+
menu:
9+
main:
10+
identifier: "soviewportregion"
11+
title: "Creating Multi-View Layouts Using SoViewportRegion"
12+
weight: 460
13+
parent: "basicmechanisms"
14+
---
15+
# Example 6: Creating Multi-View Layouts Using SoViewportRegion
16+
17+
## Introduction
18+
In this guide, we will show how to use the `SoViewportRegion` module to create custom layouts within the `SoRenderArea` module. This allows you to display multiple views or slices in a single window.
19+
20+
We will demonstrate how to:
21+
* Divide the render area into multiple regions.
22+
* Assign different content to each region.
23+
* Use alternative methods, such as SoView2D, when applicable.
24+
25+
26+
## Prepare your network
27+
28+
### Displaying three images in one panel
29+
Add an `ImageLoad` module to your workspace and select a 3D image like *./MeVisLab/Resources/DemoData/MRI_Head.tif* from the MeVisLab demo data directory. Connect an `OrthoReformat3` module and add three `View2D` modules.
30+
31+
![Image Display Setup](/images/tutorials/basicmechanics/E6_1.png "Image Display Setup")
32+
33+
Opening the three `View2D` module panels now shows the data in 3 orthogonal views. The module `OrthoReformat3` transforms the input image (by rotating and/or flipping) into the three main views commonly used.
34+
35+
![3 Views in 3 Viewers](/images/tutorials/basicmechanics/E6_2.png "3 Views in 3 Viewers")
36+
37+
The module `SoViewportRegion` divides the render window into multiple areas, allowing different views or slices to be shown in the same window. It's useful in medical applications, like displaying MRI or CT images from different angles (axial, sagittal, coronal) at once, making data analysis easier and faster.
38+
39+
Add three `SoViewportRegion` modules and connect each one to a `View2D` module. To display the hidden outputs of the `View2D` module, press {{< keyboard "SPACE" >}} and connect the output to the input of `SoViewportRegion`, as shown below.
40+
41+
![Connect SoViewportRegion with View2D](/images/tutorials/basicmechanics/E6_3.png "Connect SoViewportRegion with View2D")
42+
43+
Add a `SoRenderArea` for your final result to the network and connect all three `SoViewportRegion` modules to it.
44+
45+
The result is that all of your viewers are initially displayed on top of each other in the bottom right corner.
46+
47+
![All three viewers on top of each other](/images/tutorials/basicmechanics/E6_4.png "All three viewers on top of each other")
48+
49+
This happens, because all three `SoViewportRegion` modules have the same settings for position and height or width.
50+
51+
![SoViewportRegion](/images/tutorials/basicmechanics/E6_5.png "SoViewportRegion")
52+
53+
The `SoViewportRegion` module allows to define the X- and Y-position and the width and height of the image in the `SoRenderArea` module.
54+
55+
Values can be in pixels or as fractions from 0 to 1:
56+
57+
* 0 means the start of the render area (depending on the reference)
58+
* 0.5 means the center of the render area
59+
* 1 means the end of the render area (depending on the reference)
60+
61+
We want to create a layout with the following setting:
62+
* Axial view on the left side
63+
* Coronal view on the top right side
64+
* Sagittal view on the bottom right side
65+
66+
![Target Layout](/images/tutorials/basicmechanics/E6_6.png "Target Layout")
67+
68+
Now open the left `SoViewportRegion` module and change settings:
69+
70+
* **X-Position and Width**
71+
* *Left Border* to 0
72+
* *Right Border* to 0.5
73+
* *Domain* Fraction of width
74+
* *Reference* Left window border
75+
* **Y-Position and Height**
76+
* *Lower Border* to 1
77+
* *Upper Border* to 0
78+
* *Domain* Fraction of height
79+
* *Reference* Upper window border
80+
81+
![Axial View](/images/tutorials/basicmechanics/E6_7.png "Axial View")
82+
83+
Continue with the middle `SoViewportRegion` module and change settings:
84+
85+
* **X-Position and Width**
86+
* *Left Border* to 0
87+
* *Right Border* to 0.5
88+
* *Domain* Fraction of width
89+
* *Reference* Right window border
90+
* **Y-Position and Height**
91+
* *Lower Border* to 0.5
92+
* *Upper Border* to 0
93+
* *Domain* Fraction of smallest dimension
94+
* *Reference* Upper window border
95+
96+
![Coronal View](/images/tutorials/basicmechanics/E6_8.png "Coronal View")
97+
98+
The right `SoViewportRegion` module should look as follows:
99+
100+
* **X-Position and Width**
101+
* *Left Border* to 0.5
102+
* *Right Border* to 0
103+
* *Domain* Fraction of width
104+
* *Reference* Right window border
105+
* **Y-Position and Height**
106+
* *Lower Border* to 1
107+
* *Upper Border* to 0.5
108+
* *Domain* Fraction of smallest dimension
109+
* *Reference* Upper window border
110+
111+
![Sagittal View](/images/tutorials/basicmechanics/E6_9.png "Sagittal View")
112+
113+
#### Displaying four images in one panel
114+
In the next example, the `SoRenderArea` will display four views at the same time: axial, coronal, sagittal, and a 3D view.
115+
116+
![3D View Layout](/images/tutorials/basicmechanics/E6_11.png "3D View Layout")
117+
118+
These views will be arranged in a single panel, split into two sides, with each side showing two images. To add the 3D view, insert a `View3D` module and connect it to the `ImageLoad` module. Then connect the `View3D` to `SoCameraInteraction`, connect that to another `SoViewportRegion`, and finally to `SoRenderArea`.
119+
120+
![3D View Network](/images/tutorials/basicmechanics/E6_10.png "3D View Network")
121+
122+
Now open the left `SoViewportRegion` module and change settings:
123+
124+
* **X-Position and Width**
125+
* *Left Border* to 0
126+
* *Right Border* to 0.5
127+
* *Domain* Fraction of width
128+
* *Reference* Left window border
129+
* **Y-Position and Height**
130+
* *Lower Border* to **0.5**
131+
* *Upper Border* to 0
132+
* *Domain* Fraction of height
133+
* *Reference* Upper window border
134+
135+
Open the right `SoViewportRegion` connected to the `SoCameraInteraction` module and change settings:
136+
137+
* **X-Position and Width**
138+
* *Left Border* to 0
139+
* *Right Border* to 0.5
140+
* *Domain* Fraction of width
141+
* *Reference* Left window border
142+
* **Y-Position and Height**
143+
* *Lower Border* to 1
144+
* *Upper Border* to 0.5
145+
* *Domain* Fraction of height
146+
* *Reference* Upper window border
147+
148+
This setup will let you interact with the 3D view and display all four views together, as shown in the figure below.
149+
150+
![3D View](/images/tutorials/basicmechanics/E6_12.png "3D View")
151+
152+
You will see that the orientation cube of the 3D viewer appears in the bottom right corner of the `SoRenderArea`. To resolve this, you can check *Render delayed paths* in the `SoViewportRegion` module of the 3D viewer.
153+
154+
![Final Network](/images/tutorials/basicmechanics/E6_13.png "Final Network")
155+
156+
## Exercise
157+
You can play around with the different `SoViewportRegion` modules to create your own layouts by setting the values a little different.
158+
159+
![Exercise](/images/tutorials/basicmechanics/E6_14.png "Exercise")
160+
161+
## Summary
162+
* Own layouts can be created by using multiple `SoViewportRegion` modules
163+
164+
{{< networkfile "examples/basic_mechanisms/soviewportregion.mlab" >}}
26.5 KB
Loading
104 KB
Loading
9.93 KB
Loading
267 KB
Loading
535 KB
Loading
13 KB
Loading
399 KB
Loading
34 KB
Loading

0 commit comments

Comments
 (0)