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

		I3DExSceneCommand.h

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

		I3DExSceneCommand definition

		Author:	Joshua
		Date:	6/23/98

		Revision History

		when		who			what & why
		==========	==========	======================================================
		08/26/99	cph					Added family ids

*****************************************************************************************/
#ifndef __I3DEXSCENECOMMAND__
#define __I3DEXSCENECOMMAND__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "IExtension.h"
#include "InterfaceIDs.h"

struct ISceneDocument;

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

MCDEFINE_GUID_H(IID_I3DExSceneCommand);

//****** Family Id *************************************************

const FourCharT kSceneCommandFamilyID = kRID_SceneCommandFamilyID;


/// Callback used to check if the scene command is active for a given scene selection
///
struct ISelfPrepareMenuCallBack : public IMCUnknown
{
	virtual boolean MCCOMAPI SelfPrepareMenu(ISceneDocument* sceneDocument) = 0;
};

#ifndef qDemoVersion //regular interface

/// \addtogroup ExternalInterface
///
/// \{

///	<P>Formely known as Scene Operations, they add features to the Scene.</P>
///
///	<P>They work is a very similar manner as regular actions, with a Do(), Undo() and
///	Redo() methods.</P>
///
///	<P>The 'scmd' resource</P>
///
///	<P>You MUST provide a 'scmd' resource to specify additionnal information:</P>
///	
///	- You MUST give a UNIQUE Action Number (registered with EOVIA)
///
/// - Then you specify the menu ID to which the command will be added (-1 goes to the default menu aka edit)
///	
///	- Then you specify the list of the Rooms in which the Scene Commmand is valid.
///	Giving none means "all".
///
///	<P>Note : one instance of each type of Scene Command will be created at the
///	application startup. This instance will be used only for menu enabling
///	purposes by calling the SelfPrepareMenus() method. All other methods of these
///	instances will NEVER be called, including Init(). Therefore, the 
///	I3DExSceneCommand::SelfPrepareMenus() proc should be completely self-sufficient.</P>
///
struct I3DExSceneCommand : public IMCUnknown
{
	
	// ****************************************************************************
	//								GetMenuCallBack
	// 
	/// Returns a callBack that is called to check if this scene command is enabled
	/// for a given document. Note that the returned object should never keep a
	/// reference to the scene document or anything in the scene since it will only
	/// be deleted when the application shutsdown
	///
	///
	/// \param callBack A reference to the callBack
	///
	virtual void  MCCOMAPI GetMenuCallBack(ISelfPrepareMenuCallBack** callBack) = 0;

	/// Init() is called after the Scene Command is instanciated. Use sceneDocument to 
	/// get the selection or any other Scene data you would need to perform your action
	///
	/// \param sceneDocument The scene document
	///
	virtual MCCOMErr MCCOMAPI Init(ISceneDocument* sceneDocument) = 0;

	/// Prepare allows you to perform any preparation work needed (even posting a dialog).
	/// Make sure you return MC_S_OK if it is OK to proceed with the Scene Command.
	/// If your Scene Command has a PMap resource and the corresponding 'Node' UI resources,
	/// then the application will create a modal dialog for you just after Prepare().
	///
	virtual MCCOMErr MCCOMAPI Prepare() = 0;

	/// Returns true if the Scene Command is undoable
	///
	virtual boolean  MCCOMAPI CanUndo() = 0;

	/// Do phase. Returns true if your actually changed something in the Scene
	///
	virtual boolean  MCCOMAPI Do() = 0;

	/// Undo phase. Returns true if your actually changed something in the Scene
	///
	virtual boolean  MCCOMAPI Undo() = 0;

	/// Redo phase. Returns true if your actually changed something in the Scene
	///
	virtual boolean  MCCOMAPI Redo() = 0;


	///	PostPrepare is called after Prepare and the options dialog for the pmap
	///	so that you can create data caches needed for do/undo/redo operations
	///
	///	\return true if the scene command can go on, 
	///			false if the scene command must be stopped
	///
	virtual boolean	 MCCOMAPI PostPrepare() = 0;
};

/// \}

#else 	//(qDemoVersion) begin scrambled interface

struct I3DExSceneCommand : public IMCUnknown
{
	virtual boolean  MCCOMAPI Redo() = 0;	
	virtual MCCOMErr MCCOMAPI Prepare() = 0;
	virtual MCCOMErr MCCOMAPI Init(ISceneDocument* sceneDocument) = 0;	
	virtual boolean  MCCOMAPI CanUndo() = 0;	
	virtual boolean	 MCCOMAPI PostPrepare() = 0;
	virtual boolean  MCCOMAPI Undo() = 0;
	virtual boolean  MCCOMAPI Do() = 0;
//	virtual boolean  MCCOMAPI SelfPrepareMenus(ISceneDocument* sceneDocument) = 0;	
	virtual void	 MCCOMAPI GetMenuCallBack(ISelfPrepareMenuCallBack** callBack) = 0;
};

#endif	//(qDemoVersion) end scrambled

#endif
