Commit cd846ac9fe6fc8e8e5b33f87a6f9ef006493cd60

Authored by tatiana
1 parent cfd1a0b9

ADD: Surface duplication working... :)

Showing 1 changed file with 7 additions and 8 deletions   Show diff stats
invesalius/data/surface.py
@@ -128,11 +128,9 @@ class SurfaceManager(): @@ -128,11 +128,9 @@ 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 - ps.Publisher().subscribe(self.OnDuplicate, "Duplicate surfaces")  
132 131
133 132
134 def OnDuplicate(self, pubsub_evt): 133 def OnDuplicate(self, pubsub_evt):
135 -  
136 selected_items = pubsub_evt.data 134 selected_items = pubsub_evt.data
137 proj = prj.Project() 135 proj = prj.Project()
138 surface_dict = proj.surface_dict 136 surface_dict = proj.surface_dict
@@ -151,7 +149,6 @@ class SurfaceManager(): @@ -151,7 +149,6 @@ class SurfaceManager():
151 volume = original_surface.volume) 149 volume = original_surface.volume)
152 150
153 151
154 -  
155 def OnRemove(self, pubsub_evt): 152 def OnRemove(self, pubsub_evt):
156 selected_items = pubsub_evt.data 153 selected_items = pubsub_evt.data
157 proj = prj.Project() 154 proj = prj.Project()
@@ -230,7 +227,6 @@ class SurfaceManager(): @@ -230,7 +227,6 @@ class SurfaceManager():
230 def CreateSurfaceFromPolydata(self, polydata, overwrite=False, 227 def CreateSurfaceFromPolydata(self, polydata, overwrite=False,
231 name=None, colour=None, 228 name=None, colour=None,
232 transparency=None, volume=None): 229 transparency=None, volume=None):
233 -  
234 normals = vtk.vtkPolyDataNormals() 230 normals = vtk.vtkPolyDataNormals()
235 normals.SetInput(polydata) 231 normals.SetInput(polydata)
236 normals.SetFeatureAngle(80) 232 normals.SetFeatureAngle(80)
@@ -260,10 +256,7 @@ class SurfaceManager(): @@ -260,10 +256,7 @@ class SurfaceManager():
260 if name: 256 if name:
261 surface.name = name 257 surface.name = name
262 258
263 - # Set actor colour and transparency  
264 - actor.GetProperty().SetColor(surface.colour)  
265 - actor.GetProperty().SetOpacity(1-surface.transparency)  
266 - self.actors_dict[surface.index] = actor 259 +
267 260
268 # Append surface into Project.surface_dict 261 # Append surface into Project.surface_dict
269 proj = prj.Project() 262 proj = prj.Project()
@@ -274,6 +267,11 @@ class SurfaceManager(): @@ -274,6 +267,11 @@ class SurfaceManager():
274 surface.index = index 267 surface.index = index
275 self.last_surface_index = index 268 self.last_surface_index = index
276 269
  270 + # Set actor colour and transparency
  271 + actor.GetProperty().SetColor(surface.colour)
  272 + actor.GetProperty().SetOpacity(1-surface.transparency)
  273 + self.actors_dict[surface.index] = actor
  274 +
277 session = ses.Session() 275 session = ses.Session()
278 session.ChangeProject() 276 session.ChangeProject()
279 277
@@ -569,6 +567,7 @@ class SurfaceManager(): @@ -569,6 +567,7 @@ class SurfaceManager():
569 index, value = pubsub_evt.data 567 index, value = pubsub_evt.data
570 self.ShowActor(index, value) 568 self.ShowActor(index, value)
571 569
  570 +
572 def ShowActor(self, index, value): 571 def ShowActor(self, index, value):
573 """ 572 """
574 Show or hide actor, according to given actor index and value. 573 Show or hide actor, according to given actor index and value.