Commit 93cfccd2dcedf8bd6e0ed88f7ee04261fc353071

Authored by Paulo Henrique Junqueira Amorim
1 parent 51c65c2f

ENH: Added surface interpolation option

invesalius/data/surface.py
@@ -128,8 +128,8 @@ class SurfaceManager(): @@ -128,8 +128,8 @@ class SurfaceManager():
128 128
129 ps.Publisher().subscribe(self.OnDuplicate, "Duplicate surfaces") 129 ps.Publisher().subscribe(self.OnDuplicate, "Duplicate surfaces")
130 ps.Publisher().subscribe(self.OnRemove,"Remove surfaces") 130 ps.Publisher().subscribe(self.OnRemove,"Remove surfaces")
131 -  
132 - 131 + ps.Publisher().subscribe(self.UpdateSurfaceInterpolation, 'Update Surface Interpolation')
  132 +
133 def OnDuplicate(self, pubsub_evt): 133 def OnDuplicate(self, pubsub_evt):
134 selected_items = pubsub_evt.data 134 selected_items = pubsub_evt.data
135 proj = prj.Project() 135 proj = prj.Project()
@@ -508,7 +508,7 @@ class SurfaceManager(): @@ -508,7 +508,7 @@ class SurfaceManager():
508 smoother.Update() 508 smoother.Update()
509 polydata = smoother.GetOutput() 509 polydata = smoother.GetOutput()
510 510
511 - print "Normals" 511 +
512 normals = vtk.vtkPolyDataNormals() 512 normals = vtk.vtkPolyDataNormals()
513 normals.SetInput(polydata) 513 normals.SetInput(polydata)
514 normals.SetFeatureAngle(80) 514 normals.SetFeatureAngle(80)
@@ -537,7 +537,6 @@ class SurfaceManager(): @@ -537,7 +537,6 @@ class SurfaceManager():
537 # Represent an object (geometry & properties) in the rendered scene 537 # Represent an object (geometry & properties) in the rendered scene
538 actor = vtk.vtkActor() 538 actor = vtk.vtkActor()
539 actor.SetMapper(mapper) 539 actor.SetMapper(mapper)
540 -  
541 # Create Surface instance 540 # Create Surface instance
542 if overwrite: 541 if overwrite:
543 surface = Surface(index = self.last_surface_index) 542 surface = Surface(index = self.last_surface_index)
@@ -550,6 +549,13 @@ class SurfaceManager(): @@ -550,6 +549,13 @@ class SurfaceManager():
550 actor.GetProperty().SetColor(colour) 549 actor.GetProperty().SetColor(colour)
551 actor.GetProperty().SetOpacity(1-surface.transparency) 550 actor.GetProperty().SetOpacity(1-surface.transparency)
552 551
  552 + prop = actor.GetProperty()
  553 +
  554 + interpolation = int(ses.Session().surface_interpolation)
  555 +
  556 + prop.SetInterpolation(interpolation)
  557 + #prop.SetInterpolationToPhong()
  558 +
553 # Remove temporary files 559 # Remove temporary files
554 #if sys.platform == "win32": 560 #if sys.platform == "win32":
555 # try: 561 # try:
@@ -606,6 +612,16 @@ class SurfaceManager(): @@ -606,6 +612,16 @@ class SurfaceManager():
606 612
607 ps.Publisher().sendMessage('End busy cursor') 613 ps.Publisher().sendMessage('End busy cursor')
608 614
  615 +
  616 + def UpdateSurfaceInterpolation(self, pub_evt):
  617 + interpolation = int(ses.Session().surface_interpolation)
  618 + key_actors = self.actors_dict.keys()
  619 +
  620 + for key in self.actors_dict:
  621 + self.actors_dict[key].GetProperty().SetInterpolation(interpolation)
  622 + ps.Publisher().sendMessage('Render volume viewer')
  623 +
  624 +
609 def RemoveActor(self, index): 625 def RemoveActor(self, index):
610 """ 626 """
611 Remove actor, according to given actor index. 627 Remove actor, according to given actor index.
@@ -626,7 +642,6 @@ class SurfaceManager(): @@ -626,7 +642,6 @@ class SurfaceManager():
626 index, value = pubsub_evt.data 642 index, value = pubsub_evt.data
627 self.ShowActor(index, value) 643 self.ShowActor(index, value)
628 644
629 -  
630 def ShowActor(self, index, value): 645 def ShowActor(self, index, value):
631 """ 646 """
632 Show or hide actor, according to given actor index and value. 647 Show or hide actor, according to given actor index and value.
invesalius/data/viewer_volume.py
@@ -181,6 +181,8 @@ class Viewer(wx.Panel): @@ -181,6 +181,8 @@ class Viewer(wx.Panel):
181 181
182 ps.Publisher().subscribe(self.RemoveVolume, 'Remove Volume') 182 ps.Publisher().subscribe(self.RemoveVolume, 'Remove Volume')
183 183
  184 +
  185 +
184 def SetStereoMode(self, pubsub_evt): 186 def SetStereoMode(self, pubsub_evt):
185 mode = pubsub_evt.data 187 mode = pubsub_evt.data
186 ren_win = self.interactor.GetRenderWindow() 188 ren_win = self.interactor.GetRenderWindow()
invesalius/gui/frame.py
@@ -332,11 +332,10 @@ class Frame(wx.Frame): @@ -332,11 +332,10 @@ class Frame(wx.Frame):
332 332
333 ses.Session().rendering = values[const.RENDERING] 333 ses.Session().rendering = values[const.RENDERING]
334 ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION] 334 ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION]
335 - 335 +
336 ps.Publisher().sendMessage('Remove Volume') 336 ps.Publisher().sendMessage('Remove Volume')
337 ps.Publisher().sendMessage('Reset Reaycasting') 337 ps.Publisher().sendMessage('Reset Reaycasting')
338 -  
339 - 338 + ps.Publisher().sendMessage('Update Surface Interpolation')
340 339
341 def ShowAbout(self): 340 def ShowAbout(self):
342 """ 341 """