/*============================================================================= Project: SharpImage Module: siSelection.cs Language: C# 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. =============================================================================*/ using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Windows.Forms; using System.Diagnostics; using SharpImage.Main; using SharpImage.Properties; namespace SharpImage.Rendering { public abstract class siSelection : siActor { #region Constants //===================================================================== protected static readonly Color COLOR_OUTLINE = Color.Red; protected static readonly Color COLOR_FILL = Color.FromArgb(50, COLOR_OUTLINE); protected static readonly Color COLOR_CONTROL_FILL = Color.White; protected static readonly Color COLOR_CONTROL_OUTLINE = Color.Black; protected const float PEN_OUTLINE_WIDTH = 1.5F; protected const float PEN_CONTROL_OUTLINE_WIDTH = 0.5F; protected const float CONTROL_WIDTH = 6.0F; //========================================================================= #endregion #region Construction and Disposal //===================================================================== //===================================================================== #endregion #region Properties //===================================================================== #region TypeName //===================================================================== /// /// Gets a string describing the selection type. /// Eg. "Spherical", "Rectangular", etc. /// public virtual string TypeName { get { return "Selection"; } } //===================================================================== #endregion #region GenerateMaskImageFilterType //===================================================================== /// /// Gets a string indicating the type of selection for the /// itkGenerateMaskImageFilter. For example: "Ellipse", "Point", etc. /// public virtual string GenerateMaskImageFilterType { get { return "NotSupported"; } } //===================================================================== #endregion //===================================================================== #endregion #region Public Methods //===================================================================== //===================================================================== #endregion #region Protected Methods //===================================================================== /// /// Throws a new NotSupportedException with a helpful message. /// protected void ThrowNotSupported() { throw new NotSupportedException(this.TypeName + " selections do not support this method."); } /// /// Throws a new NotSupportedException with a helpful message. /// /// protected void ThrowNotSupported(string extra) { if (extra == null || extra.Length == 0) { this.ThrowNotSupported(); } else { extra = extra.Trim(' ', '.'); extra = extra[0].ToString().ToLower() + extra.Substring(2); throw new NotSupportedException(this.TypeName + " selections do not support this method: " + extra + "."); } } /// /// Return the first input from the renderer as an itk.itkImageBase. /// Returns null on failure. /// /// /// protected itk.itkImageBase GetInputAsImage(siRenderer renderer) { return this.GetInputAsImage(renderer, 0); } /// /// Return the given input from the renderer as an itk.itkImageBase. /// Returns null on failure. /// /// /// /// protected itk.itkImageBase GetInputAsImage(siRenderer renderer, int index) { if (renderer != null && renderer.Inputs != null && renderer.Inputs.Count > index && renderer.Inputs[index] is itk.itkImageBase) return renderer.Inputs[index] as itk.itkImageBase; else return null; } //===================================================================== #endregion } }