#============================================================================== # # Project: SharpImage # Module: SelectPaths.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 SelectPathsScript(ScriptObject): # ------------------------------------------------------------------------- Name = "SelectPaths" Help = """Allow for the selection of multiple paths by a point-and-click method. The points in the path are displayed in a tool window.""" Parameters = """None""" Renderer = None Input = None Form = None # ------------------------------------------------------------------------- def Run(self): """ The entry-point for this script. """ self.Initialise() self.DoWork() # NOTE: Finalise() will be invoked when Continue or Cancel are clicked. 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.Input = self.Renderer.Inputs[0] self.Form = siFormSelectPaths( self.Renderer ) self.Form.Continue += self.Continue self.Form.Cancel += self.Cancel self.ParentApplication.AddTool( self.Form ) self.StartedWork() self.WriteLineToConsole("Selecting paths...") def DoWork(self): """ Perform the main functions of the script. """ """ NOTE: This function is invoked on the main UI thread. """ self.ParentApplication.SetApplicationAsReady(0) def Continue(self, sender, args): """ Extracts the path using the specified points. """ self.DoWork( ) def Cancel(self, sender, args): """ Cancel the script. """ self.WriteLineToConsole("Script cancelled by user.") self.FinishedWork( True ) def FinishedWork(self, success): """ Inform listeners that the work has finished. """ self.UnregisterEventHandlers( ) ScriptObject.FinishedWork( self, success ) if ( success ): self.ParentApplication.Invoke( CallTarget0(self.Finalise) ) def UnregisterEventHandlers(self): """ Unregister all the event handlers. """ if (self.Form != None): self.Form.Continue -= self.Continue self.Form.Cancel -= self.Cancel self.Form = None