From 93cfccd2dcedf8bd6e0ed88f7ee04261fc353071 Mon Sep 17 00:00:00 2001 From: paulojamorim Date: Thu, 26 May 2011 19:06:22 +0000 Subject: [PATCH] ENH: Added surface interpolation option --- invesalius/data/surface.py | 25 ++++++++++++++++++++----- invesalius/data/viewer_volume.py | 2 ++ invesalius/gui/frame.py | 5 ++--- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/invesalius/data/surface.py b/invesalius/data/surface.py index 9f38c14..dc4aac7 100644 --- a/invesalius/data/surface.py +++ b/invesalius/data/surface.py @@ -128,8 +128,8 @@ class SurfaceManager(): ps.Publisher().subscribe(self.OnDuplicate, "Duplicate surfaces") ps.Publisher().subscribe(self.OnRemove,"Remove surfaces") - - + ps.Publisher().subscribe(self.UpdateSurfaceInterpolation, 'Update Surface Interpolation') + def OnDuplicate(self, pubsub_evt): selected_items = pubsub_evt.data proj = prj.Project() @@ -508,7 +508,7 @@ class SurfaceManager(): smoother.Update() polydata = smoother.GetOutput() - print "Normals" + normals = vtk.vtkPolyDataNormals() normals.SetInput(polydata) normals.SetFeatureAngle(80) @@ -537,7 +537,6 @@ class SurfaceManager(): # Represent an object (geometry & properties) in the rendered scene actor = vtk.vtkActor() actor.SetMapper(mapper) - # Create Surface instance if overwrite: surface = Surface(index = self.last_surface_index) @@ -550,6 +549,13 @@ class SurfaceManager(): actor.GetProperty().SetColor(colour) actor.GetProperty().SetOpacity(1-surface.transparency) + prop = actor.GetProperty() + + interpolation = int(ses.Session().surface_interpolation) + + prop.SetInterpolation(interpolation) + #prop.SetInterpolationToPhong() + # Remove temporary files #if sys.platform == "win32": # try: @@ -606,6 +612,16 @@ class SurfaceManager(): ps.Publisher().sendMessage('End busy cursor') + + def UpdateSurfaceInterpolation(self, pub_evt): + interpolation = int(ses.Session().surface_interpolation) + key_actors = self.actors_dict.keys() + + for key in self.actors_dict: + self.actors_dict[key].GetProperty().SetInterpolation(interpolation) + ps.Publisher().sendMessage('Render volume viewer') + + def RemoveActor(self, index): """ Remove actor, according to given actor index. @@ -626,7 +642,6 @@ class SurfaceManager(): index, value = pubsub_evt.data self.ShowActor(index, value) - def ShowActor(self, index, value): """ Show or hide actor, according to given actor index and value. diff --git a/invesalius/data/viewer_volume.py b/invesalius/data/viewer_volume.py index ab8fad9..0edf311 100755 --- a/invesalius/data/viewer_volume.py +++ b/invesalius/data/viewer_volume.py @@ -181,6 +181,8 @@ class Viewer(wx.Panel): ps.Publisher().subscribe(self.RemoveVolume, 'Remove Volume') + + def SetStereoMode(self, pubsub_evt): mode = pubsub_evt.data ren_win = self.interactor.GetRenderWindow() diff --git a/invesalius/gui/frame.py b/invesalius/gui/frame.py index 4769b79..526cee1 100755 --- a/invesalius/gui/frame.py +++ b/invesalius/gui/frame.py @@ -332,11 +332,10 @@ class Frame(wx.Frame): ses.Session().rendering = values[const.RENDERING] ses.Session().surface_interpolation = values[const.SURFACE_INTERPOLATION] - + ps.Publisher().sendMessage('Remove Volume') ps.Publisher().sendMessage('Reset Reaycasting') - - + ps.Publisher().sendMessage('Update Surface Interpolation') def ShowAbout(self): """ -- libgit2 0.21.2