/*	File: Figure.h
 *
 *	Interface Description:
 *		Provides an abstract concept and interface class Figure describing
 *		aspects common to	all kinds of geometrical figures designed for
 *		graphical output.
 *		A Figure has
 *		- a state which may be changed by the commands Show, Hide;
 *		- a reference point with respect to which the shape of the Figure is
 *		  described and which may be changed by the commands Move, MoveTo.
 *		- an extent which may be its length or perimeter.
 * General Notions and Concepts:
 *		- Attributes realize the state of an object. They are protected from
 *		  client accesses according to the concept of data encapsulation.
 *		  To achieve the semantics of a read-only attribute, a querie function
 *		  with the same name as the attribute, except for a capitalized first
 *		  letter, returning a constant reference to the attribute, is used.
 *		- The interface a class resp. an object supplies for its clients
 *		  consists of queries and commands.
 *		- Queries are functions returning information on the state of the
 *		  current object. Queries do not change attribute values, i.e. they do
 *		  not have side-effects and thus may be used in assertions.
 *		- Commands are void functions (procedures) transforming the state of
 *		  the current object. Commands change attribute values.
 *		- Assertions are boolean expressions describing correct states of a
 *		  program execution. Particular forms of assertions are invariants,
 *		  preconditions and postconditions.
 *		- Invariants are assertions describing consistency conditions on the
 *		  state of any object of a class.
 *		- Preconditions and postconditions are asseretions describing the
 *		  semantics of queries and commands.
 *		  If a command affects the result of a querie, i.e. if the results of
 *		  calls of the querie before and after a call of the command differ,
 *		  postconditions are used to express this change.
 *		  In all other cases, postconditions of the form
 *			  Querie () == old Querie ()
 *		  hold, where the right side means the querie's value before the call
 *		  of the command. These postconditions are not explicitly written.
 *	Adjustable Constants: -
 *	Input: -
 *	Output:
 *		Concrete figures derived from Figure can be drawn on the screen.
 *	Restrictions:
 *		General Precondition:
 *		Before an object of a type derived from Figure can be used,
 *		the Graphics module must have been initialized correctly.
 *	History:
 *		Date:		 Author:	 Change:
 *		97-05-05	 KHU		 Creation.
 *	Remark: -
 */

#ifndef FIGURE_H_
#define FIGURE_H_

	typedef double Float;
		// Possible types: float, double, long double.

	enum FigureState {hidden, shown};

	class CoordinatePair
	{
	public:
		// Attributes:

		Float x,
				y;

		// Constructors:

		CoordinatePair (Float x0 = 0.0, Float y0 = 0.0)
		{
			x = x0;
			y = y0;
		};
	}; // CoordinatePair

	const Float coordinateMax = 10e4;
	const Float coordinateMin = -coordinateMax;

	class Figure
	{
	protected:
		// Attributes:

		FigureState		state;

		CoordinatePair	refPoint;

		// Commands:

		virtual void Draw () = 0;

	public:
		// Queries:

		FigureState State () const
		{
			return state;
		};

		const CoordinatePair & RefPoint () const
		{
			return refPoint;
		};

		virtual Float Extent () const = 0;
			// Postcondition: result >= 0.0.

		// Commands:

		virtual void Show ();
			// Postcondition: State () == shown.

		virtual void Hide ();
			// Postcondition: State () == hidden.

		virtual void Move (/* IN */ const CoordinatePair & delta);
			// Postcondition: RefPoint () == old RefPoint () + delta.

		virtual void MoveTo (/* IN */ const CoordinatePair & newRefPoint);
			// Postcondition: RefPoint () == newRefPoint.

		// Constructors:

		Figure ()
		:	state (hidden),
			refPoint ()
		{
		};

	protected:
		virtual void CheckInvariant ();

	}; // Figure

#endif // FIGURE_H_