def __init__(self, root, w=600, h=600): self.root = root # VTK setup Globals.ren = vtk.vtkRenderer() Globals.renWin = vtk.vtkRenderWindow() Globals.renWin.AddRenderer(Globals.ren) # setup main actor Globals.imagePipeline = ImagePipeline(Globals.ren) def SetReferenceSpacing(): spacing = Globals.imagePipeline.GetSpacing() if spacing[2] > 0: Globals.referenceSize = min(spacing) else: Globals.referenceSize = min(spacing[0:2]) SetReferenceSpacing() Globals.ren.AddActor(Globals.imagePipeline.actor) Globals.SetDefaultRenderProps() Globals.SetDefaultPreferences() Globals.crossHair = CrossHair.CrossHairWidget() # setup observer chain for main events Globals.objectSet = Region.RegionSet() self.imageObservers = [Globals.objectSet.UpdateFromGUI] self.InitializeGUI(w, h) # initialize the interactor iren = self.renderWidget.GetRenderWindow().GetInteractor() Globals.ren.SetBackground(.5, .5, .5) Globals.ren.ResetCamera() iren.Initialize() self.mode = Mode.Navigation() self.mode.Start() # set the interactor style Globals.renWin.Render() iren.Start() # set the initial position of the pointer in the center bounds = Globals.imagePipeline.slicer.GetOutput().GetBounds() centerX = .5 * (bounds[0] + bounds[1]) centerY = .5 * (bounds[2] + bounds[3]) Globals.crossHair.SetPosition(centerX, centerY)
def ChangeMode(self): # destructor for previous mode self.mode.Finish() mode = self.radioVar.get() if mode == 0: self.mode = Mode.Navigation() elif mode == 1: self.mode = Mode.AddRegion(self) elif mode == 2: self.mode = Mode.Laplace(self) elif mode == 3: self.mode = Mode.ProfileInspector(self) elif mode == 4: self.mode = Mode.Highlight(self) else: self.mode = Mode.DeleteRegion(self) self.mode.Start()