#============================================================================== # # Project: SharpImage # Module: SelectSeeds.py # Language: IronPython # Author: Dan Mueller # Date: $Date: 2007-07-06 10:57:00 +1000 (Fri, 06 Jul 2007) $ # Revision: $Revision: 2 $ # # 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 SelectSeedsScript(ScriptObject): # ------------------------------------------------------------------------- Name = "SelectSeeds" Help = """Allow for the selection of multiple seeds by a point-and-click method. The selected seeds are listed in the tool window. Once complete, this script prints the seeds to the console.""" 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 = siFormSelectSeeds( self.Renderer ) self.Form.Continue += self.Continue self.Form.Cancel += self.Cancel self.ParentApplication.AddTool( self.Form ) self.StartedWork() self.WriteLineToConsole("Selecting seeds...") 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 Finalise(self): """ Finalise the environment after running this script. """ """ NOTE: This function is invoked on the main UI thread. """ self.Form.Continue -= self.Continue self.Form.Cancel -= self.Cancel self.Form = None ScriptObject.Finalise( self ) def Continue(self, sender, args): """ Displays the seeds before closing the form. """ strSeeds = String.Empty for seed in self.Form.PointsSelection.GetIndicies(self.Input): self.WriteLineToConsole("Seed=" + seed.ToString()) strSeeds += seed.ToString().Trim('[',']').Replace(",", "") + " " self.WriteLineToConsole("All Seeds=" + strSeeds) self.FinishedWork( True ) 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. """ ScriptObject.FinishedWork( self, success ) if ( success ): self.ParentApplication.Invoke( CallTarget0(self.Finalise) )