/****************************************************************************************


		IWorkingBox.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Joshua
		Date:	2/22/98

		Revision History

		when		who			what & why
		==========	==========	======================================================
		7/6/99		Alec		removed working box appearance fields
		4/9/99		EricG		Added extra planes
		
*****************************************************************************************/

#ifndef __IWORKINGBOX__
#define __IWORKINGBOX__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "PublicUtilities.h"
//#include "Transforms.h"
#include "MCColorRGBA.h"
#include "I3DShRenderable.h"

struct I3DEditorHostPart;
struct IWorkingBoxPlane;
struct IShRasterLayer;
class  TTreeTransform;

//****** Globally Unique Ids *************************************************

MCDEFINE_GUID(IID_IWorkingBox, 0x4f83b9c0, 0xcaab, 0x11d2, 0x88, 0x7f, 0x0, 0x60, 0x97, 0x14, 0x85, 0x21);
MCDEFINE_GUID(IID_IWorkingBoxPlane, 0x4f83b9c1, 0xcaab, 0x11d2, 0x88, 0x7f, 0x0, 0x60, 0x97, 0x14, 0x85, 0x21);

//****************************************************************************

// We can have up to 6 planes attached to a Working Box, although everybody but the Free Form and Vertex
// Modeler only use the 3 first ones. So by default the 4, 5th and 6th ones are "off"
#define kWBPlanesCount	7
#define kWBBottomPlane	0
#define kWBRightPlane	1
#define kWBLeftPlane	2
#define kWBExtraPlane	3
#define kWBXDrawPlane	5
#define kWBYDrawPlane	3
#define kWBZDrawPlane	4
#define kWBUVPlane		6
/// \addtogroup ExternalInterface
/// \{

///  A Working Box is a 3D Box with a 3D Transform in global space.
///
///  The Working Box maintains 6 Working Box Planes which correspond
///  to the walls of the working box, plus extra ones that you can
///  use as you wish (they are hidden by default).  Access these working box
///  planes to get a transform pipeline for moving to and from
///  the plane projected space.
///
///  The Working Box maintains renderables which can be handed to
///  the renderer for rendering
///
///  Each Plane has an index number, and the planes are set up this
///  way by default :
/// \verbatim
///           _
///          /|\
///         / | \          Bottom PLane is #0
///        /  |  \         Right Plane is #1
///       | 2 | 1 |        Left Plane is #2
///       |  / \  |        Extra Plane (not shown) is #3
///       | /   \ |
///       |/     \|        Use the constants defined above.
///        \  0  /
///         \   /
///          \_/
///kWBXDrawPlane is parallel to plane 1
///kWBYDrawPlane is parallel to plane 2
///kWBZDrawPlane is parallel to plane 0
/// \endverbatim
///
///Note that kWBExtraPlane and kWBYDrawPlane are one and the same plane
struct IWorkingBox : public IMCUnknown
{
	//Main working box attributes
	//Sets the global transform of the working box
	virtual void			MCCOMAPI	SetTransform			(const TTransform3D& inTransform)=0;

	//returns the global transform of the working box
	virtual TTransform3D&	MCCOMAPI	GetTransform			()=0;
	virtual void			MCCOMAPI	SetBoundingBox			(const TBBox3D& inBBox)=0;
	virtual void			MCCOMAPI	GetBoundingBox			(TBBox3D& outBBox)=0;

	//Working Box Planes 
	virtual void			MCCOMAPI	GetPlane				(uint16 inIndex, IWorkingBoxPlane** outWorkingBoxPlane)=0;
	virtual uint16			MCCOMAPI	GetCurrentPlane			()=0;
	virtual void			MCCOMAPI	SetCurrentPlane			(uint16 inCurrentPlaneIndex)=0; 

	//Get renderables of the working box for rendering
	virtual void			MCCOMAPI	AddRenderables			(TRenderableAndTfmArray& outRenderables)=0;
	virtual void			MCCOMAPI	InvalidateRenderables	()=0;

	// 3D Cursor mode
	virtual void			MCCOMAPI	Set3DCursorMode			(boolean value)=0;
	virtual boolean			MCCOMAPI	Get3DCursorMode			()=0;
	virtual void			MCCOMAPI	Get3DCursorPosition		(TVector3& position) = 0;
	virtual void			MCCOMAPI	Set3DCursorPosition		(const TVector3& position) = 0;
	virtual void			MCCOMAPI	GetWBCenter				(TVector3& position) = 0;
	virtual void			MCCOMAPI	SetWBCenter				(const TVector3& position) = 0;
	virtual void			MCCOMAPI	SetGlobalGrid			(boolean value)=0;
	virtual boolean			MCCOMAPI	GetGlobalGrid			()=0;
	virtual void			MCCOMAPI	CustomFeature			(int16 feature, boolean value)=0;

	virtual void			MCCOMAPI	SetHideGridOnGroundPlane(boolean hideGridOnGroundPlane) = 0;
};

///  A Working Box Plane is a plane of a Working Box.
///
///  The location and orientation of a Working Box Plane is defined by
///  a TTreeTransform, but you can get a TPlane for your convenience
///  if you wish.
///
///  You will probably never need to set individually the transformation 
///  of the 3 first planes of a Working Box. The Working Box takes care
///  of it for you, use IWorkingBox::SetTreeTransform().
///  IWorkingBoxPlane::SetTreeTransform() is generally used only for 
///  setting the position and orientation of the "Extra Plane" (the 4th one).
struct IWorkingBoxPlane : public IMCUnknown
{
	//-- Transform Accessors

	// Gets the TTreeTransform which represents the plane
	virtual const TTransform3D&				MCCOMAPI GetTransform			()=0;

	// Gets the basic plane information
	virtual const TPlane*					MCCOMAPI GetPlane				() const=0;

	// Set the TTreeTransform which represents the plane
	virtual void							MCCOMAPI SetTransform			(const TTransform3D& transform)=0;

	//-- Misc. methods
	virtual	TVector2 MCCOMAPI ConstrainDirections	(const TVector2& inOldHit, const TVector2& inNewHit) const=0;
	virtual	TVector2 MCCOMAPI SnapVector			(const TVector2& inOldHit, const TVector2& inNewHit) const=0;
	virtual TVector2 MCCOMAPI SnapPoint				(const TVector2& inWhere) const=0;

	//-- Attributes Get methods
	virtual void	 MCCOMAPI GetMinMax				(TVector2& outMin, TVector2& outMax)=0;
	virtual void	 MCCOMAPI GetDelta				(TVector2& outDelta)=0;
	virtual int32	 MCCOMAPI GetSpacing			() const=0;
	virtual boolean  MCCOMAPI GetDrawGrid			() const=0;
	virtual boolean  MCCOMAPI GetDrawCentered		() const=0;
	virtual boolean  MCCOMAPI GetDrawOutline		() const=0;
	virtual void	 MCCOMAPI GetDrawOutlineSide	(boolean& outDrawLeft, boolean& outDrawRight, boolean& outDrawTop, 
													 boolean& outDrawBottom)=0;
	virtual TMCColorRGBA MCCOMAPI	GetGridColor	() const=0;
	virtual TMCColorRGBA MCCOMAPI	GetOutlineColor	() const=0;

	virtual void	 MCCOMAPI GetPlaneVectors		(TVector3& ii, TVector3& jj, TVector3& kk, TVector3& oo, boolean global)=0;

	//-- Attributes Set methods
	virtual void	MCCOMAPI SetMinMax				(const TVector2&	inMin, const TVector2& inMax)=0;
	virtual void	MCCOMAPI SetDelta				(const TVector2& inDelta)=0;
	virtual void	MCCOMAPI SetSpacing				(int32 inSpacing)=0;
	virtual void	MCCOMAPI SetDrawGrid			(boolean inDrawGrid)=0;
	virtual void	MCCOMAPI SetDrawCentered		(boolean inDrawCentered)=0;
	virtual void	MCCOMAPI SetDrawOutline			(boolean inDrawOutline)=0;
	virtual void	MCCOMAPI SetDrawOutlineSide		(boolean inDrawLeft, boolean inDrawRight, boolean inDrawTop, boolean inDrawBottom)=0;
	virtual void	MCCOMAPI SetDrawAll				(boolean inDraw)=0;	// = SetDrawGrid+SetDrawOutline+SetDrawOutline
	virtual void	MCCOMAPI SetGridColor			(const TMCColorRGBA& color)=0;
	virtual void	MCCOMAPI SetOutlineColor		(const TMCColorRGBA& color)=0;

	//	Rendering
	virtual void	MCCOMAPI AddRenderables			(TRenderableAndTfmArray& outRenderables)=0;
	virtual void	MCCOMAPI InvalidateRenderables	()=0;

	/// Create an image attached to the working plane based on an image file path.
	virtual void	MCCOMAPI SetPlaneImageWithPathName(const TMCString& filePath)=0;

	/// Create an image attached to the working plane based on a raster layer.
	virtual void	MCCOMAPI SetPlaneImage(IShRasterLayer* rasterLayer)=0;

	///Return a pointer to an image attached to this plane
	virtual IShRasterLayer* MCCOMAPI GetPlaneImageNoAddRef()=0;

	/// Activate or deactivate the use of the image attached to the working plane
	virtual void	MCCOMAPI ActivatePlaneImage		(boolean active)=0;

	// ****************************************************************************
	//								IsPlaneImageActive
	// 
	/// 
	/// \return true if the image attached to this plane is active, false oherwise. This flag does not guarantee that an image is actually attached to the plane.
	/// 
	virtual boolean	MCCOMAPI IsPlaneImageActive			()=0;
};
/// \}
#endif