Commit 0bd1e163f383c855b7caa83fa9d7760d11b0fa77
1 parent
4cea1d31
Exists in
master
and in
68 other branches
ADD: Synchronize with the 3D plane slices
Showing
1 changed file
with
52 additions
and
1 deletions
Show diff stats
invesalius/data/viewer_volume.py
... | ... | @@ -321,11 +321,56 @@ class SlicePlane: |
321 | 321 | self.original_orientation = project.original_orientation |
322 | 322 | self.Create() |
323 | 323 | self.__bind_evt() |
324 | - | |
324 | + self.__bind_vtk_evt() | |
325 | + | |
325 | 326 | def __bind_evt(self): |
326 | 327 | ps.Publisher().subscribe(self.Enable, 'Enable plane') |
327 | 328 | ps.Publisher().subscribe(self.Disable, 'Disable plane') |
328 | 329 | ps.Publisher().subscribe(self.ChangeSlice, 'Change slice from slice plane') |
330 | + | |
331 | + def __bind_vtk_evt(self): | |
332 | + self.plane_x.AddObserver("InteractionEvent", self.PlaneEvent) | |
333 | + self.plane_y.AddObserver("InteractionEvent", self.PlaneEvent) | |
334 | + self.plane_z.AddObserver("InteractionEvent", self.PlaneEvent) | |
335 | + | |
336 | + def PlaneEvent(self, obj, evt): | |
337 | + | |
338 | + number = obj.GetSliceIndex() | |
339 | + plane_axis = obj.GetPlaneOrientation() | |
340 | + | |
341 | + if (self.original_orientation == const.AXIAL): | |
342 | + if (plane_axis == 0): | |
343 | + orientation = "SAGITAL" | |
344 | + elif(plane_axis == 1): | |
345 | + orientation = "CORONAL" | |
346 | + dimen = obj.GetInput().GetDimensions() | |
347 | + number = abs(dimen[0] - number) | |
348 | + else: | |
349 | + orientation = "AXIAL" | |
350 | + | |
351 | + elif(self.original_orientation == const.SAGITAL): | |
352 | + if (plane_axis == 0): | |
353 | + orientation = "CORONAL" | |
354 | + elif(plane_axis == 1): | |
355 | + orientation = "AXIAL" | |
356 | + dimen = obj.GetInput().GetDimensions() | |
357 | + number = abs(dimen[0] - number) | |
358 | + else: | |
359 | + orientation = "SAGITAL" | |
360 | + else: | |
361 | + if (plane_axis == 0): | |
362 | + orientation = "SAGITAL" | |
363 | + elif(plane_axis == 1): | |
364 | + orientation = "AXIAL" | |
365 | + dimen = obj.GetInput().GetDimensions() | |
366 | + number = abs(dimen[0] - number) | |
367 | + else: | |
368 | + orientation = "CORONAL" | |
369 | + | |
370 | + | |
371 | + if (obj.GetSlicePosition() != 0.0): | |
372 | + ps.Publisher().sendMessage(('Set scroll position', \ | |
373 | + orientation), number) | |
329 | 374 | |
330 | 375 | def Create(self): |
331 | 376 | |
... | ... | @@ -414,6 +459,12 @@ class SlicePlane: |
414 | 459 | self.plane_y.On() |
415 | 460 | elif(label == "Sagital"): |
416 | 461 | self.plane_x.On() |
462 | + a = self.plane_x.GetTexturePlaneProperty() | |
463 | + a.SetBackfaceCulling(0) | |
464 | + c = self.plane_x.GetTexture() | |
465 | + c.SetRestrictPowerOf2ImageSmaller(1) | |
466 | + #print dir(a) | |
467 | + | |
417 | 468 | elif(self.original_orientation == const.SAGITAL): |
418 | 469 | if(label == "Axial"): |
419 | 470 | self.plane_y.On() | ... | ... |