#============================================================================== # # Project: SharpImage # Module: AddPaths.py # Language: IronPython # Author: Dan Mueller # Date: $Date$ # Revision: $Revision$ # # Copyright (c) Queensland University of Technology (QUT) 2007. # All rights reserved. # # This software is distributed WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the above copyright notices for more information. # #============================================================================== # Import the relevent class import Script from Script import * class AddPathsScript(ScriptObject): # ------------------------------------------------------------------------- Name = "AddPaths" Help = """Adds all paths to the input using the given pattern.""" Parameters = """(String) Default = the pattern used to search for paths. ("Path")""" Renderer = None Default = "Path" # ------------------------------------------------------------------------- def Initialise(self): """ Initialise the environment for running this script. """ """ NOTE: This function is invoked on the main UI thread. """ ScriptObject.Initialise( self ) self.Renderer = self.ParentApplication.CurrentRenderer self.ParentApplication.SetApplicationAsReady( 0 ) def DoWork(self): """ Perform the main functions of the script. """ """ NOTE: This function is invoked on the main UI thread. """ for renderer in self.GetAllRenderersMatchingPattern( self.Default ): if (renderer != self.Renderer): task = "Searching: " + Path.GetFileName(renderer.Inputs[0].Name) added = None for dataobj in renderer.Inputs: if ( Type.GetType("itk.itkParametricPath, ManagedITK.Common").IsInstanceOfType(dataobj) ): added = " (Added Paths)" self.Renderer.Inputs.Add( dataobj ) self.WriteTask( task + added ) self.Renderer.Repaint( ) def Finalise(self): """ Finalise the environment after running this script. """ """ NOTE: This function is invoked on the main UI thread. """ self.ParentApplication.SetApplicationAsReady( 0 ) self.Handlers["ScriptFinalised"]()