예제 #1
0
    def close(self):
        # we play it safe... (the graph_editor/module_manager should have
        # disconnected us by now)
        for input_idx in range(len(self.get_input_descriptions())):
            self.set_input(input_idx, None)

        # get rid of our reference
        del self._splatMapper
        del self._otf
        del self._ctf
        del self._volumeProperty
        del self._volume

        del self._object_dict

        ColourDialogMixin.close(self)
        # we have to call this mixin close so that all inspection windows
        # can be taken care of.  They should be taken care of in anycase
        # when the viewFrame is destroyed, but we like better safe than
        # sorry
        IntrospectModuleMixin.close(self)

        # take care of our own window
        if self._view_frame is not None:
            self._view_frame.Destroy()
            del self._view_frame
예제 #2
0
    def close(self):
        # we play it safe... (the graph_editor/module_manager should have
        # disconnected us by now)
        for input_idx in range(len(self.get_input_descriptions())):
            self.set_input(input_idx, None)

        # get rid of our reference
        del self._splatMapper
        del self._otf
        del self._ctf
        del self._volumeProperty
        del self._volume

        del self._object_dict

        ColourDialogMixin.close(self)
        # we have to call this mixin close so that all inspection windows
        # can be taken care of.  They should be taken care of in anycase
        # when the viewFrame is destroyed, but we like better safe than
        # sorry
        IntrospectModuleMixin.close(self)

        # take care of our own window
        if self._view_frame is not None:
            self._view_frame.Destroy()
            del self._view_frame
예제 #3
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        ColourDialogMixin.__init__(
            self, module_manager.get_module_view_parent_window())

        # setup the whole VTK pipeline that we're going to use
        self._createPipeline()

        # this is a list of all the objects in the pipeline and will
        # be used by the object and pipeline introspection
        self._object_dict = {
            'splatMapper': self._splatMapper,
            'opacity TF': self._otf,
            'colour TF': self._ctf,
            'volumeProp': self._volumeProperty,
            'volume': self._volume
        }

        # setup some config defaults
        # for segmetented data
        self._config.threshold = 1.0
        # bony kind of colour
        self._config.colour = (1.0, 0.937, 0.859)
        # high quality, doh
        self._config.renderMode = 0
        # default.  if you don't understand, forget about it. :)
        self._config.gradientImageIsGradient = 0

        # create the gui
        self._view_frame = None

        self.sync_module_logic_with_config()
예제 #4
0
    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)
        ColourDialogMixin.__init__(
            self, module_manager.get_module_view_parent_window())

        # setup the whole VTK pipeline that we're going to use
        self._createPipeline()

        # this is a list of all the objects in the pipeline and will
        # be used by the object and pipeline introspection
        self._object_dict = {'splatMapper' : self._splatMapper,
                            'opacity TF' : self._otf,
                            'colour TF' : self._ctf,
                            'volumeProp' : self._volumeProperty,
                            'volume' : self._volume}

        # setup some config defaults
        # for segmetented data
        self._config.threshold = 1.0
        # bony kind of colour
        self._config.colour = (1.0, 0.937, 0.859)
        # high quality, doh
        self._config.renderMode = 0
        # default.  if you don't understand, forget about it. :)
        self._config.gradientImageIsGradient = 0

        # create the gui
        self._view_frame = None

        self.sync_module_logic_with_config()
예제 #5
0
    def __init__(self, module_manager):
        # call base constructor
        ModuleBase.__init__(self, module_manager)
        ColourDialogMixin.__init__(
            self, module_manager.get_module_view_parent_window())
        self._numDataInputs = self.NUM_INPUTS
        # use list comprehension to create list keeping track of inputs
        self._inputs = [{'Connected' : None, 'inputData' : None,
                         'vtkActor' : None, 'ipw' : None}
                       for i in range(self._numDataInputs)]
        # then the window containing the renderwindows
        self.threedFrame = None

        # the renderers corresponding to the render windows
        self._threedRenderer = None

        self._outline_source = vtk.vtkOutlineSource()
        om = vtk.vtkPolyDataMapper()
        om.SetInputConnection(self._outline_source.GetOutputPort())
        self._outline_actor = vtk.vtkActor()
        self._outline_actor.SetMapper(om)
        self._cube_axes_actor2d = vtk.vtkCubeAxesActor2D()
        self._cube_axes_actor2d.SetFlyModeToOuterEdges()
        #self._cube_axes_actor2d.SetFlyModeToClosestTriad()


        # use box widget for VOI selection
        self._voi_widget = vtk.vtkBoxWidget()
        # we want to keep it aligned with the cubic volume, thanks
        self._voi_widget.SetRotationEnabled(0)
        self._voi_widget.AddObserver('InteractionEvent',
                                     self.voiWidgetInteractionCallback)
        self._voi_widget.AddObserver('EndInteractionEvent',
                                     self.voiWidgetEndInteractionCallback)
        self._voi_widget.NeedsPlacement = True

        # also create the VTK construct for actually extracting VOI from data
        #self._extractVOI = vtk.vtkExtractVOI()
        self._currentVOI = 6 * [0]

        # set the whole UI up!
        self._create_window()

        # our interactor styles (we could add joystick or something too)
        self._cInteractorStyle = vtk.vtkInteractorStyleTrackballCamera()


        # set the default
        self.threedFrame.threedRWI.SetInteractorStyle(self._cInteractorStyle)
        
        rwi = self.threedFrame.threedRWI
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)        

        # initialise our sliceDirections, this will also setup the grid and
        # bind all slice UI events
        self.sliceDirections = sliceDirections(
            self, self.controlFrame.sliceGrid)

        self.selectedPoints = selectedPoints(
            self, self.controlFrame.pointsGrid)

        # we now have a wx.ListCtrl, let's abuse it
        self._tdObjects = tdObjects(self,
                                    self.controlFrame.objectsListGrid)

        self._implicits = implicits(self,
                                    self.controlFrame.implicitsGrid)


        # setup orientation widget stuff
        # NB NB NB: we switch interaction with this off later
        # (InteractiveOff()), thus disabling direct translation and
        # scaling.  If we DON'T do this, interaction with software 
        # raycasters are greatly slowed down.
        self._orientation_widget = vtk.vtkOrientationMarkerWidget()
        
        self._annotated_cube_actor = aca = vtk.vtkAnnotatedCubeActor()
        #aca.TextEdgesOff()

        aca.GetXMinusFaceProperty().SetColor(1,0,0)
        aca.GetXPlusFaceProperty().SetColor(1,0,0)
        aca.GetYMinusFaceProperty().SetColor(0,1,0)
        aca.GetYPlusFaceProperty().SetColor(0,1,0)
        aca.GetZMinusFaceProperty().SetColor(0,0,1)
        aca.GetZPlusFaceProperty().SetColor(0,0,1)
        
        self._axes_actor = vtk.vtkAxesActor()

        self._orientation_widget.SetInteractor(
            self.threedFrame.threedRWI)
        self._orientation_widget.SetOrientationMarker(
            self._axes_actor)
        self._orientation_widget.On()
       
        # make sure interaction is off; when on, interaction with
        # software raycasters is greatly slowed down!
        self._orientation_widget.InteractiveOff()
예제 #6
0
    def close(self):
        # shut down the orientationWidget/Actor stuff
        self._orientation_widget.Off()
        self._orientation_widget.SetInteractor(None)
        self._orientation_widget.SetOrientationMarker(None)
        del self._orientation_widget
        del self._annotated_cube_actor
        
        # take care of scalarbar
        self._showScalarBarForProp(None)
        
        # this is standard behaviour in the close method:
        # call set_input(idx, None) for all inputs
        for idx in range(self._numDataInputs):
            self.set_input(idx, None)

        # take care of the sliceDirections
        self.sliceDirections.close()
        del self.sliceDirections

        # the points
        self.selectedPoints.close()
        del self.selectedPoints

        # take care of the threeD objects
        self._tdObjects.close()
        del self._tdObjects

        # the implicits
        self._implicits.close()
        del self._implicits

        # don't forget to call the mixin close() methods
        IntrospectModuleMixin.close(self)
        ColourDialogMixin.close(self)
        
        # unbind everything that we bound in our __init__
        del self._outline_source
        del self._outline_actor
        del self._cube_axes_actor2d

        del self._voi_widget
        #del self._extractVOI

        del self._cInteractorStyle

        # make SURE there are no props in the Renderer
        self._threedRenderer.RemoveAllViewProps()
        # take care of all our bindings to renderers
        del self._threedRenderer

        if BACKGROUND_RENDERER:
            # also do the background renderer
            self._background_renderer.RemoveAllViewProps()
            del self._background_renderer

        # the remaining bit of logic is quite crucial:
        # we can't explicitly Destroy() the frame, as the RWI that it contains
        # will only disappear when it's reference count reaches 0, and we
        # can't really force that to happen either.  If you DO Destroy() the
        # frame before the RW destructs, it will cause the application to
        # crash because the RW assumes a valid WindowId in its dtor
        #
        # we have two solutions:
        # 1. call a WindowRemap on the RenderWindows so that they reparent
        #    themselves to newly created windowids
        # 2. attach event handlers to the RenderWindow DeleteEvent and
        #    destroy the containing frame from there
        #
        # method 2 doesn't alway work, so we use WindowRemap

        # hide it so long
        #self.threedFrame.Show(0)

        #self.threedFrame.threedRWI.GetRenderWindow().SetSize(10,10)
        #self.threedFrame.threedRWI.GetRenderWindow().WindowRemap()

        # finalize should be available everywhere
        self.threedFrame.threedRWI.GetRenderWindow().Finalize()
        # zero the RenderWindow
        self.threedFrame.threedRWI.SetRenderWindow(None)
        # and get rid of the threedRWI interface
        del self.threedFrame.threedRWI
        
        # all the RenderWindow()s are now reparented, so we can destroy
        # the containing frame
        self.threedFrame.Destroy()
        # unbind the _view_frame binding
        del self.threedFrame

        # take care of the objectAnimationFrame
        self.objectAnimationFrame.Destroy()
        del self.objectAnimationFrame

        # take care of the controlFrame too
        self.controlFrame.Destroy()
        del self.controlFrame

        # if we don't give time up here, things go wrong (BadWindow error,
        # invalid glcontext, etc).  we'll have to integrate this with the
        # eventual module front-end / back-end split.  This time-slice
        # allows wx time to destroy all windows which somehow also leads
        # to VTK being able to deallocate everything that it has.
        wx.SafeYield()
예제 #7
0
    def __init__(self, module_manager):
        # call base constructor
        ModuleBase.__init__(self, module_manager)
        ColourDialogMixin.__init__(
            self, module_manager.get_module_view_parent_window())
        self._numDataInputs = self.NUM_INPUTS
        # use list comprehension to create list keeping track of inputs
        self._inputs = [{
            'Connected': None,
            'inputData': None,
            'vtkActor': None,
            'ipw': None
        } for i in range(self._numDataInputs)]
        # then the window containing the renderwindows
        self.threedFrame = None

        # the renderers corresponding to the render windows
        self._threedRenderer = None

        self._outline_source = vtk.vtkOutlineSource()
        om = vtk.vtkPolyDataMapper()
        om.SetInputConnection(self._outline_source.GetOutputPort())
        self._outline_actor = vtk.vtkActor()
        self._outline_actor.SetMapper(om)
        self._cube_axes_actor2d = vtk.vtkCubeAxesActor2D()
        self._cube_axes_actor2d.SetFlyModeToOuterEdges()
        #self._cube_axes_actor2d.SetFlyModeToClosestTriad()

        # use box widget for VOI selection
        self._voi_widget = vtk.vtkBoxWidget()
        # we want to keep it aligned with the cubic volume, thanks
        self._voi_widget.SetRotationEnabled(0)
        self._voi_widget.AddObserver('InteractionEvent',
                                     self.voiWidgetInteractionCallback)
        self._voi_widget.AddObserver('EndInteractionEvent',
                                     self.voiWidgetEndInteractionCallback)
        self._voi_widget.NeedsPlacement = True

        # also create the VTK construct for actually extracting VOI from data
        #self._extractVOI = vtk.vtkExtractVOI()
        self._currentVOI = 6 * [0]

        # set the whole UI up!
        self._create_window()

        # our interactor styles (we could add joystick or something too)
        self._cInteractorStyle = vtk.vtkInteractorStyleTrackballCamera()

        # set the default
        self.threedFrame.threedRWI.SetInteractorStyle(self._cInteractorStyle)

        rwi = self.threedFrame.threedRWI
        rwi.Unbind(wx.EVT_MOUSEWHEEL)
        rwi.Bind(wx.EVT_MOUSEWHEEL, self._handler_mousewheel)

        # initialise our sliceDirections, this will also setup the grid and
        # bind all slice UI events
        self.sliceDirections = sliceDirections(self,
                                               self.controlFrame.sliceGrid)

        self.selectedPoints = selectedPoints(self,
                                             self.controlFrame.pointsGrid)

        # we now have a wx.ListCtrl, let's abuse it
        self._tdObjects = tdObjects(self, self.controlFrame.objectsListGrid)

        self._implicits = implicits(self, self.controlFrame.implicitsGrid)

        # setup orientation widget stuff
        # NB NB NB: we switch interaction with this off later
        # (InteractiveOff()), thus disabling direct translation and
        # scaling.  If we DON'T do this, interaction with software
        # raycasters are greatly slowed down.
        self._orientation_widget = vtk.vtkOrientationMarkerWidget()

        self._annotated_cube_actor = aca = vtk.vtkAnnotatedCubeActor()
        #aca.TextEdgesOff()

        aca.GetXMinusFaceProperty().SetColor(1, 0, 0)
        aca.GetXPlusFaceProperty().SetColor(1, 0, 0)
        aca.GetYMinusFaceProperty().SetColor(0, 1, 0)
        aca.GetYPlusFaceProperty().SetColor(0, 1, 0)
        aca.GetZMinusFaceProperty().SetColor(0, 0, 1)
        aca.GetZPlusFaceProperty().SetColor(0, 0, 1)

        self._axes_actor = vtk.vtkAxesActor()

        self._orientation_widget.SetInteractor(self.threedFrame.threedRWI)
        self._orientation_widget.SetOrientationMarker(self._axes_actor)
        self._orientation_widget.On()

        # make sure interaction is off; when on, interaction with
        # software raycasters is greatly slowed down!
        self._orientation_widget.InteractiveOff()
예제 #8
0
    def close(self):
        # shut down the orientationWidget/Actor stuff
        self._orientation_widget.Off()
        self._orientation_widget.SetInteractor(None)
        self._orientation_widget.SetOrientationMarker(None)
        del self._orientation_widget
        del self._annotated_cube_actor

        # take care of scalarbar
        self._showScalarBarForProp(None)

        # this is standard behaviour in the close method:
        # call set_input(idx, None) for all inputs
        for idx in range(self._numDataInputs):
            self.set_input(idx, None)

        # take care of the sliceDirections
        self.sliceDirections.close()
        del self.sliceDirections

        # the points
        self.selectedPoints.close()
        del self.selectedPoints

        # take care of the threeD objects
        self._tdObjects.close()
        del self._tdObjects

        # the implicits
        self._implicits.close()
        del self._implicits

        # don't forget to call the mixin close() methods
        IntrospectModuleMixin.close(self)
        ColourDialogMixin.close(self)

        # unbind everything that we bound in our __init__
        del self._outline_source
        del self._outline_actor
        del self._cube_axes_actor2d

        del self._voi_widget
        #del self._extractVOI

        del self._cInteractorStyle

        # make SURE there are no props in the Renderer
        self._threedRenderer.RemoveAllViewProps()
        # take care of all our bindings to renderers
        del self._threedRenderer

        if BACKGROUND_RENDERER:
            # also do the background renderer
            self._background_renderer.RemoveAllViewProps()
            del self._background_renderer

        # the remaining bit of logic is quite crucial:
        # we can't explicitly Destroy() the frame, as the RWI that it contains
        # will only disappear when it's reference count reaches 0, and we
        # can't really force that to happen either.  If you DO Destroy() the
        # frame before the RW destructs, it will cause the application to
        # crash because the RW assumes a valid WindowId in its dtor
        #
        # we have two solutions:
        # 1. call a WindowRemap on the RenderWindows so that they reparent
        #    themselves to newly created windowids
        # 2. attach event handlers to the RenderWindow DeleteEvent and
        #    destroy the containing frame from there
        #
        # method 2 doesn't alway work, so we use WindowRemap

        # hide it so long
        #self.threedFrame.Show(0)

        #self.threedFrame.threedRWI.GetRenderWindow().SetSize(10,10)
        #self.threedFrame.threedRWI.GetRenderWindow().WindowRemap()

        # finalize should be available everywhere
        self.threedFrame.threedRWI.GetRenderWindow().Finalize()
        # zero the RenderWindow
        self.threedFrame.threedRWI.SetRenderWindow(None)
        # and get rid of the threedRWI interface
        del self.threedFrame.threedRWI

        # all the RenderWindow()s are now reparented, so we can destroy
        # the containing frame
        self.threedFrame.Destroy()
        # unbind the _view_frame binding
        del self.threedFrame

        # take care of the objectAnimationFrame
        self.objectAnimationFrame.Destroy()
        del self.objectAnimationFrame

        # take care of the controlFrame too
        self.controlFrame.Destroy()
        del self.controlFrame

        # if we don't give time up here, things go wrong (BadWindow error,
        # invalid glcontext, etc).  we'll have to integrate this with the
        # eventual module front-end / back-end split.  This time-slice
        # allows wx time to destroy all windows which somehow also leads
        # to VTK being able to deallocate everything that it has.
        wx.SafeYield()