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

		I3DEditorHostPart.h

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

		Author:	Greg
		Date:	7/9/98
		

		Revision History

		when		who			what & why
		==========	==========	======================================================
		11/8/99		Brice		Added DeactivatePanePart...
		7//6/99		Alec		removed interactive settings related calls
		4/8/99		EricB		Added ShowSideToolbar
		4/5/99		Greg		Added Get3D/2DToolWindow
		3/12/99		Joshua		Added ActivatePane to API
		3/9/99		Joshua		Added SetPaneText
		03/01/99	pbk			Changed the API of RenderDraw. 
		2/24/99		Joshua		Added I3DEditorHostPart::GetWorkingBox
		2/16/99		Joshua		Added GetIsActive, AllocatePanes, and kPaneArray for Storyboard
		1/25/99		Greg		Changed Add/RemoveClientCamera to Add/RemoveCamera
		10/14/98	Joshua		Added call SetDefaultPaneCameraConfig
		10/01/98	EricG		Simplified access by alternate modules

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

#ifndef __I3DEDITORHOSTPART__
#define __I3DEDITORHOSTPART__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCCompObj.h"
#include "APITypes.h"
#include "InterfaceIDs.h"

#include "I3DExInteractiveRenderer.h"
#include "I3DShCamera.h"

struct I3DExPickRenderer;
struct InstanceAndTransform;
struct I3DEditorHostPanePart;
struct IEx3DEditorHostPanePart;
struct IWorkingBox;
struct IMFWindow;
struct IMFMenu;
struct I3DExRendererBox;
struct I3DRenderingCallbacks;
struct IMFToolbarPart;
struct IChangeListener;
struct IRenderableData;
struct IMFPart;
struct ISceneDocument;

class  TMCRealRect;
class  TTreeProjectionTransform;


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

MCDEFINE_GUID(IID_I3DEditorHostPart,		0x8e168021, 0x1837, 0x11d2, 0xa0, 0xe0, 0x0,  0xaa, 0x0,  0xd3, 0x7,  0xeb);
MCDEFINE_GUID(IID_I3DEditorHostPanePart,	0x8e168020, 0x1837, 0x11d2, 0xa0, 0xe0, 0x0,  0xaa, 0x0,  0xd3, 0x7,  0xeb);
MCDEFINE_GUID(IID_I3DEditorHostPanePart2,	0xc9acb16, 0x715, 0x4b3e, 0x89, 0x3d, 0xe7, 0xc1, 0xd5, 0xe3, 0xf1, 0x2d);


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

#define kInitZoom .8f	// Default zoom value for a grid of 30*30*30
#define kInitSize 30.0f // Default workingBox size

enum EPaneConfig
{
	kOnePane	 = 0,			//MUST be the first value of the enum
	kTwoPaneHorizontal,
	kTwoPaneVertical,
	kTwoPaneInset,
	kThreePaneBottom,
	kThreePaneTop,
	kThreePaneLeft,
	kThreePaneRight,
	kFourPane,
	kPaneArray,

	kNoPane,					//MUST be the last value of the enum
	kPaneConfigMax = 0x7FFFFFFF
};

/// Used to save the custom position of a camera
///
struct TSavedPosition
{
	TTransform3D 	fTransform; ///< Camera postion
	TMCString255	fName;		///< Name of the position
};


// Messages for the listener
#define kWPCActivatedPlane	'WPC1'	// ((uint32)data) = plane index
#define kWPCToggledPlane	'WPC2'	// ((uint32)data) = plane index
#define kWPCToggledGround	'WPC3'	// ((uint32)data) = on (1) or off (0)

/// \addtogroup ShellInterface
/// \{


// ****************************************************************************
//								I3DEditorHostPart
// 
/// Interface of the part that embeds interactive renderers. The 3D Editor Host
/// is designed to deal with the camera tools and encapsulate a 3D view. It deals
/// with multiple panes. You can implement your own pane part in a modeler so that
/// you can control what it contains.
///
/// <P>-Note: to use a local camera toolbar, in MCSketch:</P>
///		- add the extra token tbId followed by the id of your toolbar.
///		- add the extra token DadY followed by the id of the parent that contains both the host and your toolbar.
///
/// <P>If you create a modeler, you can use the 3DEditorHostPart in your windows. To
/// include it, you must add a NodePart with the part extension '3dHO'. When you load
/// the window (or dialog) from the resource, a 3DEditorHostPart will be created. You
/// can then search that part by ID (usually the 'host' ID is used) and set the type
/// of pane extension you want to use.</P>
///
/// <P>The initialisation code of your modeler could look like this:</P>
///
/// \code
///
/// void CreateWindows()
/// {
///   void* oldResources = NULL;
///   gResourceUtilities->SetupComponentResources('modu',myModelerID, &oldResources);
///
///   fModule->CreateWindowByResource(&fWindow,myWindowsResID,true);
///   ThrowIfNil(fWindow);
///   
///   TMCCountedPtr<IMFPart> hostPart;
///   fWindow->FindChildPartByID(&hostPart, 'host');
///   ThrowIfNil(hostPart);
///   
///   TMCCountedPtr<I3DEditorHostPart> my3DEditorHostPart;
///   hostPart->QueryInterface(IID_I3DEditorHostPart, (void **)&my3DEditorHostPart);
///   ThrowIfNil(my3DEditorHostPart);
///
///   TMCCountedPtr<IMFResponder> actionResponder;
///   fDocument->QueryInterface(IID_IMFResponder, (void**)&actionResponder);
///   f3DEditorHostPart->SetActionResponder(actionResponder);
///
///   my3DEditorHostPart->SetPaneExtension('xxxx');
///
///   ...  //(allocate the panes...)
/// }
/// \endcode
/// 
struct I3DEditorHostPart : public IMCUnknown
{
	// ****************************************************************************
	//								InitEditorHost
	// 
	/// Sets the working scale
	/// 
	/// \param sceneMagnitude  The scale of the scene
	///
	virtual void			MCCOMAPI InitEditorHost				(real32 sceneMagnitude) = 0;

	// ****************************************************************************
	//								SetPaneExtension
	// 
	/// Sets the ID of the part extension that is used as pane part. This part
	/// should implement the interface I3DEditorHostPanePart.
	/// 
	/// \param paneExtension  The class ID of the part extension.
	/// 
	virtual void			MCCOMAPI SetPaneExtension			(IDType paneExtension) = 0;

	// ****************************************************************************
	//								GetPaneConfig
	// 
	/// Returns the current pane configuration. See EPaneConfig for more info.
	/// 
	/// 
	virtual EPaneConfig 	MCCOMAPI GetPaneConfig				() = 0;


	// ****************************************************************************
	//								SetPaneConfig
	// 
	/// Sets the current pane configuration. See EPaneConfig for more info.
	/// 
	/// \param config  The configuration of the panes.
	/// 
	virtual void			MCCOMAPI SetPaneConfig				(EPaneConfig config) = 0;

	// ****************************************************************************
	//								SetPaneArrayDimensions
	// 
	/// Sets the number of panes in the window rect.
	/// 
	/// \param x  Number of panes horizontally.
	/// \param y  Number of panes vertically.
	/// 
	virtual void			MCCOMAPI SetPaneArrayDimensions		(uint32 x, uint32 y) = 0;


	// ****************************************************************************
	//								SetDefaultPaneCameraConfig
	// 
	/// Sets the default camera on the current panes.
	/// 
	/// 
	virtual void			MCCOMAPI SetDefaultPaneCameraConfig () = 0;

	// ****************************************************************************
	//								GetPanes
	// 
	/// Returns the list of visible panes. To get all the panes of the editorHostPart,
	/// use GetAllPanes(...)
	/// 
	/// \param panes  The list of the visible panes that is returned.
	/// 
	virtual void			MCCOMAPI GetPanes(TMCCountedPtrArray<I3DEditorHostPanePart>	&panes) = 0;

	// ****************************************************************************
	//								ShowSideToolbar
	// 
	/// Sets the visibility status of the tool bar on the side of the window (The
	/// toolbar that contains the part configurations and the rendering modes).
	/// 
	/// \param doShowPaneModes     True if the panes configurations icons should be visible.
	/// \param doShowDisplayModes  True if the rendering modes icons should be visible.
	/// 
	virtual void			MCCOMAPI ShowSideToolbar			(boolean	doShowPaneModes, boolean doShowDisplayModes) = 0;

	// ****************************************************************************
	//								SetActionResponder
	// 
	/// Sets the action responder on the part. In the case of a modeler (or module)
	/// the action responder is usually the document associated with the module.
	/// You must call this function after creating a 3DEditorHost part to set the
	/// action responder for Undo/Redo (normally the document's responder)
	/// 
	/// \param responder  The action responder.
	/// 
	virtual void			MCCOMAPI SetActionResponder			(IMFResponder* responder) = 0;


	// ****************************************************************************
	//								AllocatePanes
	// 
	/// Allocates the total number of panes that can be used with the 3DEditorHost.
	/// (Usually 4). Note that depending on the pane configuration (see SetPaneConfig())
	/// they will not all be visible at the same time.
	/// 
	/// \param numPanes  Total number of pane parts.
	/// 
	virtual void			MCCOMAPI AllocatePanes				(uint32 numPanes) = 0;
	
	/// Deprecated
	virtual void			MCCOMAPI GetWorkingBox				(IWorkingBox** workingBox) = 0;

	/// Returns the working box that is associated with the part.
	virtual IWorkingBox*	MCCOMAPI GetWorkingBox				() const = 0;

	// ****************************************************************************
	//								MapDrawingPlanes
	// 
	/// Set to true to use a custom drawing plane instead of the 
	/// working box ones.
	/// 
	/// \param value  The state of the drawing.
	/// 
	virtual void			MCCOMAPI MapDrawingPlanes			(boolean value) = 0;

	// ****************************************************************************
	//								AreDrawingPlanesMapped
	// 
	/// Returns true if the custom drawing planes are used instead of
	/// the working box ones.
	///
	/// \see MapDrawingPlanes()
	/// 
	virtual boolean			MCCOMAPI AreDrawingPlanesMapped		() = 0;

//	virtual void			MCCOMAPI LockWindows				(boolean value) = 0;
//	virtual boolean			MCCOMAPI IsLocked					() = 0;
//	virtual void			MCCOMAPI GetLockCenter				(TVector3& center) = 0;
//	virtual void			MCCOMAPI SetLockCenter				(const TVector3& center) = 0;
//	virtual real			MCCOMAPI GetLockScale				() = 0;
//	virtual void			MCCOMAPI SetLockScale				(real scale) = 0;
//	virtual void			MCCOMAPI SetLockPerspectiveOffset	(const TVector3& offset, int32 paneIndex) = 0;
//	virtual void			MCCOMAPI GetLockPerspectiveOffset	(TVector3& offset, int32 paneIndex) = 0;

	// ****************************************************************************
	//								IsCanonicalCamera
	// 
	/// Returns true if the camera is one of the default camera (director, top, left, front, ...)
	/// 
	/// \param camera  The camera that is tested.
	/// 
	virtual boolean			MCCOMAPI IsCanonicalCamera			(const I3DShCamera* camera) = 0;
	
	// ****************************************************************************
	//								GetCanonicalCameras
	// 
	/// Returns the list of all the canonical cameras (director, top, left, front, ...)
	/// 
	/// \param canonicalCameras  The list of canonical cameras that is returned.
	/// 
	virtual void			MCCOMAPI GetCanonicalCameras		(TMCCountedPtrArray<I3DShCamera>& canonicalCameras) = 0;
	
	// ****************************************************************************
	//								SetCanonicalCameras
	// 
	/// Sets the list of all the canonical cameras (director, top, left, front, ...)
	/// 
	/// \param inCameras  The list of canonical cameras.
	/// 
	virtual void			MCCOMAPI SetCanonicalCameras		(const TMCCountedPtrArray<I3DShCamera>& inCameras) = 0;

	// ****************************************************************************
	//								GetClientCameras
	// 
	/// Returns the list of all the client cameras. The client camera are all the
	/// cameras except the canonical cameras (see GetCanonicalCameras()).
	/// 
	/// \param clientCameras  The list of all the client cameras.
	/// 
	virtual void			MCCOMAPI GetClientCameras			(TMCCountedPtrArray<I3DShCamera>& clientCameras) = 0;
	
	// ****************************************************************************
	//								SetClientCameras
	// 
	/// Sets the client cameras. (by opposition to canonical cameras).
	/// 
	/// \param inCameras  The list of all the client cameras.
	/// 
	virtual void			MCCOMAPI SetClientCameras			(const TMCCountedPtrArray<I3DShCamera>& inCameras) = 0;

	
	// ****************************************************************************
	//								GetCameraToolBar
	// 
	/// Returns a pointer to the toolbar that contains the camera tools (rotate, track...)
	/// It is identical to GetCameraToolWindow() except that it does an extra QueryInterface().
	///
	/// \param outToolBar  A pointer to the toolbar.
	/// 
	virtual void			MCCOMAPI GetCameraToolBar			(IMFToolbarPart** outToolBar) = 0;

	// ****************************************************************************
	//								GetDefault2DZoom
	// 
	/// Returns the default 2D zoom.
	/// 
	virtual real			MCCOMAPI GetDefault2DZoom			() = 0;
	
	// ****************************************************************************
	//								SetDefault2DZoom
	// 
	/// Sets the default 2D Zoom
	/// 
	/// \param default2DZoom  The value of zoom.
	/// 
	virtual void			MCCOMAPI SetDefault2DZoom			(real default2DZoom) = 0;

	// ****************************************************************************
	//								GetDefaultMovementSpeed
	// 
	/// Returns the default movement speed for the camera trackers
	/// 
	/// \param outMovSpeed  The value of the movement speed
	/// \param outRotSpeed  The value of the rotation speed
	///
	virtual void			MCCOMAPI GetDefaultSpeeds	(real32 &outMovSpeed, real32 &outRotSpeed) const = 0;
	
	// ****************************************************************************
	//								SetDefaultMovementSpeed
	// 
	/// Sets the default speeds for the camera trackers
	/// 
	/// \param inMovSpeed  The value of the movement speed (1.0 is the default)
	/// \param inRotSpeed  The value of the rotation speed (1.0 is the default)
	/// 
	virtual void			MCCOMAPI SetDefaultSpeeds	(real32 inMovSpeed, real32 inRotSpeed) = 0;

	// ****************************************************************************
	//								GetGeneralSize
	// 
	/// Returns the general size (order of magnitude) of what is displayed
	///
	virtual real32			MCCOMAPI GetGeneralSize	() const = 0;
	
	// ****************************************************************************
	//								SetGeneralSize
	// 
	/// Sets the general size of what will be displayed in this host part. It is 
	///	used as the scene's order of magnitude when there is no scene (previews, 
	/// modelers...), in order to correctly set parameters related to the cameras.
	/// 
	/// \param inSize  The size, in inches (1.0 is the default)
	/// 
	virtual void			MCCOMAPI SetGeneralSize	(real32 inSize) = 0;

	// ****************************************************************************
	//								SetTopLeftPopup
	// 
	/// Sets the menu that is used at the top of left of each pane.
	/// 
	/// \param popup  A pointer to menu.
	/// 
	virtual void			MCCOMAPI SetTopLeftPopup			(IMFMenu*	popup) = 0;

	// ****************************************************************************
	//								EnableTrackingOptimizations
	// 
	/// Enable/Disable the tracking optimizations. When the optimizations are enabled
	/// the 3DEditorHost is not redrawed while the user is resizing the Window.
	/// 
	/// \param inEnable  True if the optimizations are enabled.
	/// 
	virtual void			MCCOMAPI EnableTrackingOptimizations(boolean inEnable) = 0;
	
	// ****************************************************************************
	//								IsGroundPlaneActivated
	// 
	/// \deprecated Returns true if the ground plane is activated.
	/// 
	/// 
	virtual boolean			MCCOMAPI IsGroundPlaneActivated		()= 0;
	
	// ****************************************************************************
	//								ActivateGroundPlane
	// 
	/// \deprecated Activate/Deactivate the ground plane.
	/// 
	/// \param activate  True if the ground plane should be activated.
	/// 
	virtual void			MCCOMAPI ActivateGroundPlane		(boolean activate) = 0; 
		
	// ****************************************************************************
	//								ToggleWorkingBoxPlane
	// 
	/// Change the state of a plane of the working box.
	/// 
	/// \param planeindex    The index of the plane.
	/// \param doInvalidate  True if the views should be rerendered.
	/// \param forceState    True if the state should be changed.
	/// \param shown         True if the plane is visible.
	/// 
	virtual void			MCCOMAPI ToggleWorkingBoxPlane		(int32 planeindex, boolean doInvalidate= true, boolean forceState= false, boolean shown= true) = 0;
	
	
	// ****************************************************************************
	//								ActivateWorkingBoxPlane
	// 
	/// Change the active plane of the working box.
	/// 
	/// \param planeindex  Index of the plane that should be active.
	/// 
	virtual void			MCCOMAPI ActivateWorkingBoxPlane	(int32 planeindex) = 0;

	// ****************************************************************************
	//								BuildMenuBar
	// 
	/// Build the menu bar.
	/// 
	/// 
	virtual void			MCCOMAPI BuildMenuBar				() = 0;

	// ****************************************************************************
	//								SetImmediateMode
	// 
	/// Turn on/off the immediate mode. The immediate mode is used for interactive
	/// manipulations by the user. When it is on, the rendering is blit directly
	/// to the screen without going through the back buffer.
	/// 
	/// \param on  True if the immediate mode should be on.
	/// 
	virtual void			MCCOMAPI SetImmediateMode			(boolean on)=0;


	// ****************************************************************************
	//								SetCurrentCameraToDirectorCamera
	// 
	/// Use the director camera as the current camera.
	/// 
	/// \param paneIndex  The index of the pane in which the camera is changed.
	/// 
	virtual	void			MCCOMAPI SetCurrentCameraToDirectorCamera(int32 paneIndex) = 0;
	
	// ****************************************************************************
	//								GetAllPanes
	// 
	/// Fill an array with the panes of the editor host.
	/// 
	/// \param panes  The array to be filled
	/// 
	virtual void			MCCOMAPI GetAllPanes(TMCCountedPtrArray<I3DEditorHostPanePart>	&panes) = 0;

	// ****************************************************************************
	//								GetCustomPositions
	// 
	/// Gets the saved position of the custom camera positions.
	/// 
	/// \param customPositions  The list of camera positions.
	/// 
	virtual void			MCCOMAPI GetCustomPositions(TMCArray<TSavedPosition>&customPositions)=0;

	// ****************************************************************************
	//								SetCustomPositions
	// 
	/// Set the saved position of the custom camera positions.
	/// 
	/// \param customPositions  The array of custom positions.
	/// 
	virtual void			MCCOMAPI SetCustomPositions(TMCArray<TSavedPosition>&customPositions)=0;

	// ****************************************************************************
	//								SetInteractiveRendererToPane
	// 
	/// Sets a renderer to a particular pane.
	/// 
	/// \param paneIndex    The index of the pane in the pane array of the editorHost.
	/// \param newRenderer  The new renderer for the pane.
	/// 
	virtual void			MCCOMAPI SetInteractiveRendererToPane( const int32 paneIndex, I3DExRendererBox* newRenderer)=0;

	// ****************************************************************************
	//								SetZoomValuesFromWorkingBoxSize
	// 
	/// Sets the defaultZoom value of the 3D view so the working box will
	/// fit in the view when the zoom is set to 100%.
	/// 
	/// \param maxSize  The max dimension of the working box.
	/// 
	virtual void			MCCOMAPI SetZoomValuesFromWorkingBoxSize( real32 maxSize )=0;


	// ****************************************************************************
	//								RegisterListener
	// 
	/// Register a listener.
	/// See messages above. Note : there is no channels, just 1 listener is stored.
	///
	/// \param listener  The listener that is registered.
	/// 
	virtual void			MCCOMAPI RegisterListener		(IChangeListener* listener)=0;		

	// ****************************************************************************
	//								UnregisterListener
	// 
	/// Unegister a listener.
	/// 
	/// \param listener  The listener that is unregistered.
	/// 
	virtual void			MCCOMAPI UnregisterListener		(IChangeListener* listener)=0;

	// ****************************************************************************
	//								IsWorkingBoxPlaneShown
	// 
	/// Returns true if the given plane is shown
	/// 
	/// \param planeindex  The index of the plane.
	/// 
	virtual boolean 		MCCOMAPI IsWorkingBoxPlaneShown(int32 planeindex) = 0;

	// ****************************************************************************
	//								UpdateWorkingBoxImages
	// 
	/// Update the rendering of the images attached to the working box
	/// 
	virtual void			MCCOMAPI UpdateWorkingBoxImages() = 0;


	// ****************************************************************************
	//								SetExtraToolPart
	// 
	/// Adds an extra part to the side of the window (under the regular toolbars)
	/// 
	/// \param inPart  A pointer to the extra tool part.
	/// 
	virtual void			MCCOMAPI SetExtraToolPart(IMFPart* inPart) = 0;
	virtual void			MCCOMAPI AddCamera(
								I3DShCamera* 	inCamera, 
								boolean 		inIsCanonical,				
								boolean 		inRebuildMenu) = 0;
	virtual void			MCCOMAPI RemoveCamera(
								I3DShCamera* 	inCamera, 
								boolean 		inIsCanonical,
								boolean 		inRebuildMenu) = 0;
};













// ****************************************************************************
//								I3DEditorHostPanePart
// 
/// This is the interface for the panes of the 3D Editor Host.
/// You can derive a part extension from IEx3DEditorHostPanePart if you want to implement
/// a pane for a 3DEditorHostPart. See I3DEditorHostPart for more info.
/// 
/// 
struct I3DEditorHostPanePart : public IMCUnknown
{
	// ****************************************************************************
	//								GetCurrentCameraNoAddRef
	// 
	/// Returns the current camera used for this view (pane).
	/// 
	virtual I3DShCamera*	MCCOMAPI GetCurrentCameraNoAddRef	() const = 0;
	
	// ****************************************************************************
	//								SetCurrentCamera
	// 
	/// Sets the current camera for this view.
	/// 
	/// \param camera           A pointer to the camera.
	/// \param resetPanAndZoom  True if the zoom and pan should be reset.
	/// 
	virtual void			MCCOMAPI SetCurrentCamera			(I3DShCamera* camera,boolean resetPanAndZoom) = 0;
	
	// ****************************************************************************
	//								GetInteractiveRenderer
	// 
	/// Returns a pointer to the interactive renderer of this pane.
	/// 
	/// \param renderer  A pointer to the interactive renderer.
	/// 
	virtual void			MCCOMAPI GetInteractiveRenderer		(I3DExRendererBox** renderer) = 0;

	// ****************************************************************************
	//								GetPaneExtension
	// 
	/// Returns a pointer to the external pane interface.
	/// 
	/// \param paneExtension  A pointer the pane interface.
	/// 
	virtual void			MCCOMAPI GetPaneExtension			(IEx3DEditorHostPanePart** paneExtension) = 0;
	
	// ****************************************************************************
	//								SetPaneText
	// 
	/// Sets the text that is displayed at the bottom of the pane in a pane array.
	/// (For example the time in the storyboard room).
	/// 
	/// \param text  The text.
	/// 
	virtual	void			MCCOMAPI SetPaneText				(const TMCString& text)=0;
	
	// ****************************************************************************
	//								SetPaneIcon
	// 
	/// Sets the icon that is displayed at the bottom of the pane in a pane array.
	/// (For example the time in the storyboard room).
	/// 
	/// \param inResourceID  Resource ID of the icon. (should point to a UIImage resource)
	/// 
	virtual	void			MCCOMAPI SetPaneIcon				(uint32 inResourceID)=0;
	
	// ****************************************************************************
	//								ActivatePane
	// 
	/// Called when the pane becomes active.
	/// 
	virtual	void			MCCOMAPI ActivatePane				()=0;
	
	// ****************************************************************************
	//								DeactivatePane
	// 
	/// Calls when the pane is not active any longer.
	/// 
	virtual	void			MCCOMAPI DeactivatePane				()=0;
	
	// ****************************************************************************
	//								LocalToRenderSpace
	// 
	/// Converts from window coordinates (pixels) in pixels to screen coordinates (uv)
	/// that can be used by the camera.
	/// 
	/// \param local   The window coordinates (local) in pixels
	/// \param render  The screen coordinates (render)
	/// 
	virtual void			MCCOMAPI LocalToRenderSpace			(const TMCPoint& local, TVector2& render) = 0;
	
	// ****************************************************************************
	//								RenderToLocalSpace
	// 
	/// Converts from screen coordinates (uv) in pixels to window coordinates (pixels)
	/// that can be used by the camera.
	/// 
	/// \param render  The screen coordinates (render)
	/// \param local   The window coordinates (local) in pixels
	/// 
	virtual void			MCCOMAPI RenderToLocalSpace			(const TVector2& render, TMCPoint& local) = 0;

	// ****************************************************************************
	//								PixelRay
	// 
	/// Creates a ray from the current camera through the local (pixel) space.
	/// 
	/// \param pixelPos        The position in pixels.
	/// \param worldOrigin     The origin of the ray in global coordinates.
	/// \param worldDirection  The direction of the ray in global coordinates.
	/// 
	virtual void			MCCOMAPI PixelRay					(const TMCPoint& pixelPos, 
																TVector3& worldOrigin, TVector3& worldDirection)=0;


	// ****************************************************************************
	//								RenderDraw
	// 
	/// Immediately renders and blits.  Calls the extension's SelfRenderDraw for content.
	/// 
	/// \param inContext			The graphic context.
	/// \param inZone				The zone that needs to be rendered.
	/// \param associatedSceneDoc	The associated scene document (used to lock the pane part render see ISceneDocument::ShouldRenderPanePart())
	/// 
	virtual void			MCCOMAPI RenderDraw					(IMCGraphicContext* inContext,TMCRect* inZone,ISceneDocument* associatedSceneDoc)=0;
	
	// ****************************************************************************
	//								InvalidateRender
	// 
	/// Re-render next time RenderDraw is called
	/// 
	virtual void			MCCOMAPI InvalidateRender			()=0;
	
	// ****************************************************************************
	//								NeedsReRender
	// 
	/// Returns true if a new rendering is needed.
	/// 
	virtual boolean			MCCOMAPI NeedsReRender				()=0;
		
	// ****************************************************************************
	//								GetIsActive
	// 
	/// Returns true if the pane is the active pane.
	/// 
	virtual boolean			MCCOMAPI GetIsActive				()=0;

	// ****************************************************************************
	//								SetPopupCurrentItem
	// 
	/// Sets the current item of the Pop up menu.
	/// Use this with I3DEditorHostPart::SetTopLeftPopup to handle the top-left popup menu 
	/// 
	/// \param index  The index of the current item in the Popup menu.
	/// 
	virtual void			MCCOMAPI SetPopupCurrentItem		(int16 index) = 0;
	
	
	// ****************************************************************************
	//								GetPopupCurrentItem
	// 
	/// Returns the current item of the Pop up menu
	/// 
	virtual int16			MCCOMAPI GetPopupCurrentItem		() = 0;
	
	
	// ****************************************************************************
	//								DrawTopLeftPopup
	// 
	/// Draws the popup menu at the top left of the pane.
	/// 
	/// \param inContext  The graphic context
	/// \param inZone     The rectangle of the pane.
	/// 
	virtual	void			MCCOMAPI DrawTopLeftPopup			(IMCGraphicContext* inContext,TMCRect* inZone) = 0;


	// ****************************************************************************
	//								ZoomToCenter
	// 
	/// Zoom to the center of the view
	/// 
	/// \param zoom  The new zoom
	/// 
	virtual void			MCCOMAPI ZoomToCenter(double zoom) = 0;

	// ****************************************************************************
	//								ZoomToRect
	// 
	/// Zoom the pane to a given rectange.
	/// 
	/// \param rect  
	/// 
	virtual void			MCCOMAPI ZoomToRect					(const TMCRealRect& rect) = 0;

	// ****************************************************************************
	//								ZoomTo
	// 
	/// Zoom the pane to a given rectangle
	/// 
	/// \param localRect  The rectangle is given in local coordinates of the pane (pixels)
	/// 
	virtual void			MCCOMAPI ZoomTo						(const TMCRect& localRect) = 0;

	// ****************************************************************************
	//								ZoomTo
	// 
	/// Zoom in or out
	/// 
	/// \param localPos  New center.
	/// \param zoomIn    True if we zoom in, false if we zoom out
	/// 
	virtual void			MCCOMAPI ZoomTo						(const TMCPoint& localPos,boolean zoomIn) = 0;


	// ****************************************************************************
	//								DoAreaRender
	// 
	/// Performs an area render in the pane part
	/// 
	/// \param rect  The rectangle in local coordinates of the pane (pixels)
	/// \param callbacks The function called when each tile is done. If null, standard callbacks are used.
	/// 
	virtual void MCCOMAPI DoAreaRender(const TMCRect & rect,I3DRenderingCallbacks* callbacks = NULL) = 0;
	
	// ****************************************************************************
	//								DoFinalBlit
	// 
	/// Perform the final blit of the rendering.
	/// 
	/// \param IsBlit  
	/// 
	virtual void			MCCOMAPI DoFinalBlit				(boolean IsBlit)=0;

	// ****************************************************************************
	//								GetZoom
	// 
	/// Returns the current zoom.
	/// 
	virtual	double			MCCOMAPI GetZoom					() = 0;
	
	// ****************************************************************************
	//								SetZoom
	// 
	/// Sets the current zoom of the pane.
	/// 
	/// \param zoom  The zoom.
	/// 
	virtual	void			MCCOMAPI SetZoom					(double zoom) = 0;
	
	// ****************************************************************************
	//								GetPan
	// 
	/// Returns the current pan (2D translation) of the pane.
	/// 
	/// 
	virtual	TVector2		MCCOMAPI GetPan						()  = 0;
	
	// ****************************************************************************
	//								SetPan
	// 
	/// Sets the current pan of the pane.
	/// 
	/// \param pan  The pan (2D translation).
	/// 
	virtual	void			MCCOMAPI SetPan						(TVector2 pan) = 0;
	
	// ****************************************************************************
	//								GetTreeScreenBounds
	// 
	/// Returns a rectangle in pixels that contains the tree element.
	/// 
	/// \param tree          A tree element.
	/// \param screenBounds  The bounding box on the screen.
	/// 
	virtual	void			MCCOMAPI GetTreeScreenBounds		(I3DShTreeElement* tree,TMCRect& screenBounds) = 0;
	
	// ****************************************************************************
	//								SetImmediateMode
	// 
	/// Turn on/off the immediate mode. The immediate mode is used for interactive
	/// manipulations by the user. When it is on, the rendering is blit directly
	/// to the screen without going through the back buffer.
	/// 
	/// \param on  True if the immediate mode should be on.
	/// 
	virtual void			MCCOMAPI SetImmediateMode			(boolean on) = 0;

	// ****************************************************************************
	//								GetImmediateMode
	// 
	/// Return the current state of the immediate mode
	/// 
	virtual boolean			MCCOMAPI GetImmediateMode			() = 0;

	// ****************************************************************************
	//								DeleteRenderingCaches
	// 
	/// Delete all rendering caches
	/// 
	/// 
	virtual void			MCCOMAPI	DeleteRenderingCaches	()=0;

	// ****************************************************************************
	//								Get3DEditorHost
	// 
	/// Returns the 3DEditorHost that contains this part (and the other pane parts of the window)
	/// 
	virtual I3DEditorHostPart* MCCOMAPI Get3DEditorHost			()=0;


	virtual void			MCCOMAPI	CreateRay	(const TMCPoint& localPoint, Ray3D& outRay) const = 0;

	/// Creates a ray by the current camera through the center of the part.
	virtual void			MCCOMAPI	CreateRayFromPaneCenter (Ray3D& outRay) const = 0;

	/// Creates a TreeProjectionTransform using the given renderableData
	virtual void			MCCOMAPI	GetTreeProjectionTransform	(	IRenderableData*	inRenderableData, 
																		const int32			projIndex, 
																		TTreeProjectionTransform& outTransform) const = 0;

	/// Returns the transform of the current camera.
	virtual const TTransform3D*		MCCOMAPI GetCurrentCameraTransform			() const = 0;
	virtual const TTransform3D*		MCCOMAPI GetCurrentCameraInverseTransform	() const = 0;
	
	// ****************************************************************************
	//								ViewBox
	// 
	/// Moves the camera so that it sees the given bbox.
	/// Works only for perspective cameras.
	/// Posts an undoable action if the camera is not canonical.
	/// 
	/// \param bbox  the bounding box (in global coordinates)
	/// 
	virtual void			MCCOMAPI	ViewBox						(const TBBox3D& bbox) = 0;
};

struct I3DEditorHostPanePart2 : public I3DEditorHostPanePart
{
	// ****************************************************************************
	//								CameraMoved
	//
	/// Alerts the pane part that the camera has moved
	///
	virtual void			MCCOMAPI	CameraMoved() = 0;
};


struct I3DShTreeElement;

/// This interface represents data that can be attached to a renderable manipulated by your pane extension
/// That data is also linked to a specific pane part. So for one tree, you'll have as many datas as views managed by the 3deditor host.
/// It doesn't derive from IMCUnknown because it is not meant to be counted
struct IRenderableData
{
	///returns the GlobalTreeTransform of the object to which this data is attached
	virtual void					MCCOMAPI GetGlobalTreeTransform			(TTreeTransform& outGlobalTT) = 0;

	virtual void					MCCOMAPI GetLocalTreeTransform			(TTreeTransform& outLocalTT) = 0;
	virtual void					MCCOMAPI GetGlobalTransform3D			(TTransform3D& outGlobalTT) = 0;
	virtual void					MCCOMAPI GetInverseGlobalTransform3D	(TTransform3D& outGlobalTT) = 0;

	///returns the pane part to which the data is attached
	virtual I3DEditorHostPanePart*	MCCOMAPI GetPanePart					() = 0;

	
	virtual void					MCCOMAPI GetBoundingBox					(TBBox3D& outBox) = 0;

	virtual void					MCCOMAPI GetReferencePoint				(TVector3& outReferencePoint) = 0;

	virtual boolean					MCCOMAPI WantsReferencePointHandle		() = 0;

	virtual real32					MCCOMAPI GetManipulatorsSizeFactor		() = 0;

	virtual boolean					MCCOMAPI GetGimbalEuler					(	TVector3&			outAngles, 
																				EEulerAnglesOrder&	outOrder,
																				TMatrix33&			outGimbalToLocRotation,
																				TTreeTransform&		outLocalTT,
																				TTransform3D&		outGlobalTT) = 0;

	virtual void					MCCOMAPI GetScalingCenter				(TVector3& outScaleCenter) = 0;
};


/// \}

#endif