#============================================================================== # # Project: SharpImage # Module: UpdateVolume.py # Language: IronPython # Author: Dan Mueller # Date: $Date: 2007-07-13 06:30:23 +1000 (Fri, 13 Jul 2007) $ # Revision: $Revision: 8 $ # # 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 base script class import Script from Script import * class UpdateVolumeScript(ScriptObject): # ------------------------------------------------------------------------- Name = "UpdateVolume" Help = """Updates the named input in the current volume rendering with the given image.""" Parameters = """(string) Name = either "Value", "Gradient", "Extra1", or "Extra2". ("Extra1") (string) Input = the absolute filepath or pattern for the new input image. ("Input")""" Name = "Extra1" Input = "Input" Renderer = None # ------------------------------------------------------------------------- def Run(self): """ The entry-point for this script. """ try: self.Initialise() self.DoWork() except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise() def Initialise(self): """ Initialise the environment for running this script. """ """ NOTE: This function is invoked on the main UI thread. """ try: # Initialise the base class ScriptObject.Initialise( self ) self.Renderer = self.ParentApplication.CurrentRenderer except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise( ) def DoWork(self): """ Perform the main functions of the script. """ """ NOTE: This function is invoked on the main UI thread. """ try: self.StartedWork() # Get the input image if (self.Input != None and Path.IsPathRooted(self.Input)): self.Input = self.ParentApplication.OpenImage( self.Input ) elif (self.Input != None): self.Input = self.GetOpenImageMatchingPattern( self.Input ) if (self.Input == None): raise ArgumentException( "A valid input must be provided." ) else: self.Renderer.UpdateInput( self.Name, self.Input ) # Finish self.FinishedWork( True ) self.Finalise( ) except Exception, ex: self.HandleException( ex ) self.FinishedWork( False ) self.Finalise( )