Skip to content

Commit 7b61414

Browse files
committed
move remaining three vtk calls to node pipeline
1 parent 4f7deb5 commit 7b61414

4 files changed

Lines changed: 177 additions & 130 deletions

File tree

‎src/ansys/visor/viewer/renderer/local_renderer.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,46 +160,49 @@ def deregister_all(self) -> None:
160160
def apply_visibility(self, node_id: int, visible: bool) -> None:
161161
"""See :meth:`IRenderer.apply_visibility`.
162162
163-
Mutates the actor itself, not its property. An unknown *node_id*
164-
is a logged no-op, never a raise.
163+
Resolves the pipeline and delegates to
164+
:meth:`VtkNodePipeline.set_visibility`. An unknown *node_id* is a
165+
logged no-op, never a raise.
165166
"""
166167
pipe = self._pipelines.get(node_id)
167168
if pipe is None:
168169
logger.debug(
169170
"apply_visibility: no pipeline for node %s; skipping.", node_id
170171
)
171172
return
172-
pipe.actor.SetVisibility(1 if visible else 0)
173+
pipe.set_visibility(visible)
173174

174175
def apply_opacity(self, node_id: int, opacity: float) -> None:
175176
"""See :meth:`IRenderer.apply_opacity`.
176177
177-
Mutates the actor's property. An unknown *node_id* is a logged
178-
no-op, never a raise.
178+
Resolves the pipeline and delegates to
179+
:meth:`VtkNodePipeline.set_opacity`. An unknown *node_id* is a
180+
logged no-op, never a raise.
179181
"""
180182
pipe = self._pipelines.get(node_id)
181183
if pipe is None:
182184
logger.debug(
183185
"apply_opacity: no pipeline for node %s; skipping.", node_id
184186
)
185187
return
186-
pipe.actor.GetProperty().SetOpacity(opacity)
188+
pipe.set_opacity(opacity)
187189

188190
def apply_diffuse_color(
189191
self, node_id: int, r: float, g: float, b: float
190192
) -> None:
191193
"""See :meth:`IRenderer.apply_diffuse_color`.
192194
193-
Mutates the actor property's diffuse colour only. An unknown
194-
*node_id* is a logged no-op, never a raise.
195+
Resolves the pipeline and delegates to
196+
:meth:`VtkNodePipeline.set_diffuse_color`. An unknown *node_id*
197+
is a logged no-op, never a raise.
195198
"""
196199
pipe = self._pipelines.get(node_id)
197200
if pipe is None:
198201
logger.debug(
199202
"apply_diffuse_color: no pipeline for node %s; skipping.", node_id
200203
)
201204
return
202-
pipe.actor.GetProperty().SetDiffuseColor(r, g, b)
205+
pipe.set_diffuse_color(r, g, b)
203206

204207
def apply_edge_visibility(self, node_id: int, edge_visible: bool) -> None:
205208
"""No-op in Story 1.2. Phase 3 populates."""

‎src/ansys/visor/viewer/vtk/node_pipeline.py‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def set_selected(self, selected: bool, diffuse_rgb: list[float]) -> None:
127127
The part's diffuse colour, re-applied unconditionally on both
128128
branches -- selection changes the ambient/diffuse lighting
129129
terms, it does not replace the part's colour.
130+
131+
Note: :meth:`set_diffuse_color` also writes ``SetDiffuseColor``;
132+
this method is not a substitute for it and vice versa.
130133
"""
131134
prop = self.actor.GetProperty()
132135
if selected:
@@ -138,6 +141,46 @@ def set_selected(self, selected: bool, diffuse_rgb: list[float]) -> None:
138141
prop.SetAmbient(0.0)
139142
prop.SetDiffuseColor(*diffuse_rgb)
140143

144+
def set_visibility(self, visible: bool) -> None:
145+
"""Show or hide this part.
146+
147+
Mutates the actor itself, not its property.
148+
149+
Parameters
150+
----------
151+
visible:
152+
Target state. Absolute, never a toggle.
153+
"""
154+
self.actor.SetVisibility(1 if visible else 0)
155+
156+
def set_opacity(self, opacity: float) -> None:
157+
"""Set this part's opacity.
158+
159+
Mutates the actor's property.
160+
161+
Parameters
162+
----------
163+
opacity:
164+
The opacity value to apply, passed through unchanged.
165+
"""
166+
self.actor.GetProperty().SetOpacity(opacity)
167+
168+
def set_diffuse_color(self, r: float, g: float, b: float) -> None:
169+
"""Set this part's diffuse colour.
170+
171+
Mutates the actor property's diffuse colour only.
172+
173+
Parameters
174+
----------
175+
r, g, b:
176+
The diffuse colour components, passed through unchanged.
177+
178+
Note: :meth:`set_selected` also writes ``SetDiffuseColor`` on both
179+
of its branches; this method is not a substitute for it and vice
180+
versa.
181+
"""
182+
self.actor.GetProperty().SetDiffuseColor(r, g, b)
183+
141184
def set_color_variable(
142185
self,
143186
association: VisorVtkVariableType,

0 commit comments

Comments
 (0)