[io] add opacity management to contact objects
@@ -410,6 +410,7 @@ class InputObserver():
self.vview = vview
self._opacity = 1.0
self._opacity_static = 1.0
+ self._opacity_contact = 0.4
self._current_id = vtk.vtkIdTypeArray()
self._renderer = vview.renderer
self._renderer_window = vview.renderer_window
@@ -473,6 +474,13 @@ class InputObserver():
for actor,_,_ in actors:
actor.GetProperty().SetOpacity(self._opacity_static)
+ def set_opacity_contact(self):
+ for mu in self.vview.cf_prov._mu_coefs:
+ self.vview.cactor[mu].GetProperty().SetOpacity(self._opacity_contact)
+ self.vview.gactor[mu].GetProperty().SetOpacity(self._opacity_contact)
+ self.vview.clactor[mu].GetProperty().SetOpacity(self._opacity_contact)
+ self.vview.sactora[mu].GetProperty().SetOpacity(self._opacity_contact)
+ self.vview.sactorb[mu].GetProperty().SetOpacity(self._opacity_contact)
def key(self, obj, event):
@@ -507,20 +515,34 @@ class InputObserver():
self._time += self._time_step
if key == 't':
+ print('Decrease the opacity of bodies')
self._opacity -= .1
self.set_opacity()
if key == 'T':
+ print('Increase the opacity of bodies')
self._opacity += .1
self.set_opacity()
if key == 'y':
+ print('Decrease the opacity of static bodies')
self._opacity_static -= .1
self.set_opacity_static()
if key == 'Y':
+ print('Increase the opacity of static bodies')
self._opacity_static += .1
self.set_opacity_static()
+
+ if key == 'u':
+ print('Decrease the opacity of contact elements')
+ self._opacity_contact -= .1
+ self.set_opacity_contact()
+
+ if key == 'U':
+ print('Increase the opacity of contact elements')
+ self._opacity_contact += .1
+ self.set_opacity_contact()
if key == 'c':
print('camera position:', self._renderer.GetActiveCamera().GetPosition())
print('camera focal point', self._renderer.GetActiveCamera().GetFocalPoint())
@@ -906,7 +928,8 @@ class VView(object):
self.cmapper[mu].ScalarVisibilityOn()
self.cactor[mu] = vtk.vtkActor()
- self.cactor[mu].GetProperty().SetOpacity(0.4)
+
+ self.cactor[mu].GetProperty().SetOpacity(self.config.get('contact_opacity', 0.4))
self.cactor[mu].GetProperty().SetColor(0, 0, 1)
self.cactor[mu].SetMapper(self.cmapper[mu])
