44- vtkRTAnalyticSource generates a 3D structured grid with the "RTData" scalar.
55- Contour iso-surfaces are clipped by a plane so you can see inside.
66- A slice plane through the center shows continuous vs discrete coloring.
7- - ColormapController manages the color transfer function and wires it to
7+ - Both pipelines are merged via vtkAppendPolyData into a single mapper.
8+ - ColormapConfig manages the color transfer function and wires it to
89 the mapper.
9- - The colorbar widget provides an interactive preset picker, scale modes
10- (linear / log / symlog), discrete banding, and manual range override.
10+ - Four colorbar widgets (top, bottom, left, right) each provide an
11+ interactive preset picker, scale modes (linear / log / symlog),
12+ discrete banding, and manual range override.
1113
1214Run:
1315 cd <repo_root>
2022from trame .app import TrameApp
2123from trame .ui .vuetify3 import SinglePageLayout
2224from vtkmodules .vtkCommonDataModel import vtkPlane
23- from vtkmodules .vtkFiltersCore import vtkClipPolyData , vtkContourFilter , vtkCutter
25+ from vtkmodules .vtkFiltersCore import (
26+ vtkAppendPolyData ,
27+ vtkClipPolyData ,
28+ vtkContourFilter ,
29+ vtkCutter ,
30+ )
2431from vtkmodules .vtkImagingCore import vtkRTAnalyticSource
2532from vtkmodules .vtkRenderingCore import (
2633 vtkActor ,
@@ -44,27 +51,27 @@ def __init__(self, server=None):
4451
4552 self .top = colormaps .ColormapConfig (
4653 self .server ,
47- mapper = self .contour_mapper ,
54+ mapper = self .mapper ,
4855 data_array_fn = self .get_data_array ,
49- ).set_data_array ("RTData" , self .get_data_array , "points " )
56+ ).set_data_array ("RTData" , self .get_data_array , "point " )
5057
5158 self .right = colormaps .ColormapConfig (
5259 self .server ,
53- mapper = self .contour_mapper ,
60+ mapper = self .mapper ,
5461 data_array_fn = self .get_data_array ,
55- ).set_data_array ("RTData" , self .get_data_array , "points " )
62+ ).set_data_array ("RTData" , self .get_data_array , "point " )
5663
5764 self .left = colormaps .ColormapConfig (
5865 self .server ,
59- mapper = self .slice_mapper ,
66+ mapper = self .mapper ,
6067 data_array_fn = self .get_data_array ,
61- ).set_data_array ("RTData" , self .get_data_array , "points " )
68+ ).set_data_array ("RTData" , self .get_data_array , "point " )
6269
6370 self .bottom = colormaps .ColormapConfig (
6471 self .server ,
65- mapper = self .slice_mapper ,
72+ mapper = self .mapper ,
6673 data_array_fn = self .get_data_array ,
67- ).set_data_array ("RTData" , self .get_data_array , "points " )
74+ ).set_data_array ("RTData" , self .get_data_array , "point " )
6875
6976 # Auto render when mapper update
7077 for colormap in [self .top , self .right , self .bottom , self .left ]:
@@ -94,12 +101,6 @@ def _setup_vtk(self):
94101 clip_contour .SetClipFunction (clip_plane )
95102 clip_contour .Update ()
96103
97- contour_mapper = vtkPolyDataMapper ()
98- contour_mapper .SetInputConnection (clip_contour .GetOutputPort ())
99-
100- contour_actor = vtkActor ()
101- contour_actor .SetMapper (contour_mapper )
102-
103104 # --- Slice plane (perpendicular to clip — shows scalar gradient) ---
104105 slice_plane = vtkPlane ()
105106 slice_plane .SetOrigin (0 , 0 , 0 )
@@ -110,16 +111,21 @@ def _setup_vtk(self):
110111 slicer .SetCutFunction (slice_plane )
111112 slicer .Update ()
112113
113- slice_mapper = vtkPolyDataMapper ()
114- slice_mapper .SetInputConnection (slicer .GetOutputPort ())
114+ # --- Merge contour + slice into one mapper ---
115+ append = vtkAppendPolyData ()
116+ append .AddInputConnection (clip_contour .GetOutputPort ())
117+ append .AddInputConnection (slicer .GetOutputPort ())
118+ append .Update ()
119+
120+ mapper = vtkPolyDataMapper ()
121+ mapper .SetInputConnection (append .GetOutputPort ())
115122
116- slice_actor = vtkActor ()
117- slice_actor .SetMapper (slice_mapper )
123+ actor = vtkActor ()
124+ actor .SetMapper (mapper )
118125
119126 # --- Renderer ---
120127 renderer = vtkRenderer ()
121- renderer .AddActor (contour_actor )
122- renderer .AddActor (slice_actor )
128+ renderer .AddActor (actor )
123129 renderer .SetBackground (0.15 , 0.15 , 0.15 )
124130 renderer .ResetCamera ()
125131
@@ -134,8 +140,7 @@ def _setup_vtk(self):
134140 # Capture variables on class
135141 self .wavelet = wavelet
136142 self .render_window = render_window
137- self .contour_mapper = contour_mapper
138- self .slice_mapper = slice_mapper
143+ self .mapper = mapper
139144
140145 def get_data_array (self ):
141146 """Return the active scalar array from the wavelet output."""
0 commit comments