#============================================================================== # # Project: SharpImage # Module: Properties.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 base script class import Script from Script import * class PropertiesScript(ScriptObject): Name = "Properties" Help = """Display and change the image properties. If no parameters are given the image properties are simply written to the console. If properties are changed, the changed properties are marked with an asterisk.""" Parameters = """(string) Name = the new value for the Image.Name property. (itkSize) Size = the new value for the Image.Size property. (itkSpacing) Spacing = the new value for the Image.Spacing property. (itkPoint) Origin = the new value for the Image.Origin property. (itkMatrix) Direction = the new value for the Image.Direction property.""" ParentApplication = None Handlers = None Name = None Size = None Spacing = None Origin = None Direction = None def Run(self): """ The entry-point for this script. """ self.Initialise() self.Input = self.ParentApplication.CurrentRenderer.Inputs[0] # Setup the labels labelName = "Name=" labelPixelType = "PixelType=" labelSize = "Size=" labelSpacing = "Spacing=" labelOrigin = "Origin=" labelDirection = "Direction=" labelBuffer = "Buffer=" labelMTime = "MTime=" # Change the information if (self.Name != None): self.Input.Name = self.Name labelName = "*" + labelName if (self.Size != None): self.Input.Size = self.Size labelSize = "*" + labelSize if (self.Spacing != None): self.Input.Spacing = self.Spacing labelSpacing = "*" + labelSpacing if (self.Origin != None): self.Input.Origin = self.Origin labelOrigin = "*" + labelOrigin if (self.Direction != None): self.Input.Direction = self.Direction labelDirection = "*" + labelDirection # Display the info to the console self.WriteLineToConsole( labelName + self.Input.Name ) self.WriteLineToConsole( labelPixelType + self.Input.PixelType.ToString() ) self.WriteLineToConsole( labelSize + self.Input.Size.ToString() ) self.WriteLineToConsole( labelSpacing + self.Input.Spacing.ToString("0.00000") ) self.WriteLineToConsole( labelOrigin + self.Input.Origin.ToString("0.00000") ) self.WriteLineToConsole( labelDirection + self.Input.Direction.ToString() ) self.WriteLineToConsole( labelBuffer + self.Input.Buffer.ToString() ) self.WriteLineToConsole( labelMTime + self.Input.MTime.ToString() ) # Finish self.ParentApplication.CurrentRenderer.Form.Refresh() self.Finalise()