//============================================================================
//PointPair4 Class
//Copyright ?2006  Jerry Vos & John Champion
//
//This library is free software; you can redistribute it and/or
//modify it under the terms of the GNU Lesser General Public
//License as published by the Free Software Foundation; either
//version 2.1 of the License, or (at your option) any later version.
//
//This library is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public
//License along with this library; if not, write to the Free Software
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//=============================================================================
using System;
using System.Drawing;
using System.Runtime.Serialization;
using System.Security.Permissions;
using IComparer = System.Collections.IComparer;
namespace DrawGraph
{
	/// 
	/// The basic  class holds three data values (X, Y, Z).  This
	/// class extends the basic PointPair to contain four data values (X, Y, Z, T).
	/// 
	/// 
	///  John Champion 
	///  $Revision: 3.3 $ $Date: 2007/03/17 18:43:44 $ 
	[Serializable]
	public class PointPair4 : PointPair, ISerializable
	{
	#region Member variables
		/// 
		/// This PointPair4's T coordinate.
		/// 
		public double T;
	#endregion
	#region Constructors
		/// 
		/// Default Constructor
		/// 
		public PointPair4() : base()
		{
			this.T = 0;
		}
		/// 
		/// Creates a point pair with the specified X, Y, Z, and T value.
		/// 
		/// This pair's x coordinate.
		/// This pair's y coordinate.
		/// This pair's z coordinate.
		/// This pair's t coordinate.
		public PointPair4( double x, double y, double z, double t ) : base( x, y, z )
		{
			this.T = t;
		}
		/// 
		/// Creates a point pair with the specified X, Y, base value, and
		/// label ().
		/// 
		/// This pair's x coordinate.
		/// This pair's y coordinate.
		/// This pair's z coordinate.
		/// This pair's t coordinate.
		/// This pair's string label ()
		public PointPair4( double x, double y, double z, double t, string label ) :
					base( x, y, z, label )
		{
			this.T = t;
		}
		/// 
		/// The PointPair4 copy constructor.
		/// 
		/// The basis for the copy.
		public PointPair4( PointPair4 rhs ) : base( rhs )
		{
			this.T = rhs.T;
		}
	#endregion
	#region Serialization
		/// 
		/// Current schema value that defines the version of the serialized file
		/// 
		public const int schema3 = 11;
		/// 
		/// Constructor for deserializing objects
		/// 
		/// A  instance that defines the serialized data
		/// 
		/// A  instance that contains the serialized data
		/// 
		protected PointPair4( SerializationInfo info, StreamingContext context ) : base( info, context )
		{
			// The schema value is just a file version parameter.  You can use it to make future versions
			// backwards compatible as new member variables are added to classes
			int sch = info.GetInt32( "schema3" );
			T = info.GetDouble( "T" );
		}
		/// 
		/// Populates a  instance with the data needed to serialize the target object
		/// 
		/// A  instance that defines the serialized data
		/// A  instance that contains the serialized data
		[SecurityPermissionAttribute( SecurityAction.Demand, SerializationFormatter = true )]
		public override void GetObjectData( SerializationInfo info, StreamingContext context )
		{
			base.GetObjectData( info, context );
			info.AddValue( "schema2", schema3 );
			info.AddValue( "T", T );
		}
	#endregion
	#region Properties
		/// 
		/// Readonly value that determines if either the X, Y, Z, or T
		/// coordinate in this PointPair4 is an invalid (not plotable) value.
		/// It is considered invalid if it is missing (equal to System.Double.Max),
		/// Infinity, or NaN.
		/// 
		/// true if any value is invalid
		public bool IsInvalid4D
		{
			get
			{
				return this.X == PointPair.Missing ||
						this.Y == PointPair.Missing ||
						this.Z == PointPair.Missing ||
						this.T == PointPair.Missing ||
						Double.IsInfinity( this.X ) ||
						Double.IsInfinity( this.Y ) ||
						Double.IsInfinity( this.Z ) ||
						Double.IsInfinity( this.T ) ||
						Double.IsNaN( this.X ) ||
						Double.IsNaN( this.Y ) ||
						Double.IsNaN( this.Z ) ||
						Double.IsNaN( this.T );
			}
		}
	#endregion
	#region Methods
		/// 
		/// Format this PointPair4 value using the default format.  Example:  "( 12.345, -16.876 )".
		/// The two double values are formatted with the "g" format type.
		/// 
		/// true to show the third "Z" and fourth "T" value coordinates
		/// A string representation of the PointPair4
		public new string ToString( bool isShowZT )
		{
			return this.ToString( PointPair.DefaultFormat, isShowZT );
		}
		/// 
		/// Format this PointPair value using a general format string.
		/// Example:  a format string of "e2" would give "( 1.23e+001, -1.69e+001 )".
		/// If 
		/// is true, then the third "Z" coordinate is also shown.
		/// 
		/// A format string that will be used to format each of
		/// the two double type values (see ).
		/// A string representation of the PointPair
		/// true to show the third "Z" or low dependent value coordinate
		public new string ToString( string format, bool isShowZT )
		{
			return "( " + this.X.ToString( format ) +
					", " + this.Y.ToString( format ) +
					( isShowZT ? ( ", " + this.Z.ToString( format ) +
							", " + this.T.ToString( format ) ): "" ) + " )";
		}
		/// 
		/// Format this PointPair value using different general format strings for the X, Y, and Z values.
		/// Example:  a format string of "e2" would give "( 1.23e+001, -1.69e+001 )".
		/// 
		/// A format string that will be used to format the X
		/// double type value (see ).
		/// A format string that will be used to format the Y
		/// double type value (see ).
		/// A format string that will be used to format the Z
		/// double type value (see ).
		/// A format string that will be used to format the T
		/// double type value (see ).
		/// A string representation of the PointPair
		public string ToString( string formatX, string formatY, string formatZ, string formatT )
		{
			return "( " + this.X.ToString( formatX ) +
					", " + this.Y.ToString( formatY ) +
					", " + this.Z.ToString( formatZ ) +
					", " + this.T.ToString( formatT ) +
					" )";
		}
	#endregion
	}
}