/**********************************************************************
 *<
	FILE: SiteObject.h

	DESCRIPTION:	Template Utility

	CREATED BY:

	HISTORY:

 *>	Copyright (c) 1997, All Rights Reserved.
 **********************************************************************/

#ifndef __SITEOBJECT__H
#define __SITEOBJECT__H

#ifdef STRICT							// Already defined by stdafx,
#undef STRICT							// so we avoid warning linking msg
#endif
#ifdef _MBCS							// The same as above
#undef _MBCS
#endif

#include "AnimationSuite.h"


#pragma pack(push,8)
#include "iparamm.h"


class SiteObject;

class SiteObjectCreateCallBack: public CreateMouseCallBack {
protected:
    Point3 m_p0, m_p1;
    SiteObject *m_ob;
public:
    int proc( ViewExp *vpt,int msg, int point, int flags, IPoint2 m, Matrix3& mat );
    void SetObj(SiteObject *obj) { m_ob = obj; }
};

class ParamBlock;

class SiteObject : public HelperObject {
    protected:		
		static HWND m_hParams;
		static IObjParam *m_iObjParams;
		static IParamMap *m_pmapParam;


		// Params
		int m_triggerCount;
		float m_siteScale;
		int m_extDispFlags;

	
	public:

		IParamBlock *m_pblock;
		BOOL m_suspendSnap;

        SiteObject();
        ~SiteObject() {};
		
		void BeginEditParams( IObjParam *ip, ULONG flags,Animatable *prev);
		void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);

        IParamArray *GetParamBlock(){ return m_pblock; }

		ParamDimension *GetParameterDim(int pbIndex);

		void InitNodeName(TSTR& s) { s = GetString(IDS_DB_SITEOBJECT); }

		ObjectState Eval(TimeValue time);
		CreateMouseCallBack* GetCreateMouseCallBack();


		ObjectHandle ApplyTransform(Matrix3& matrix) {return this;}
		Interval ObjectValidity(TimeValue t) {return FOREVER;}
		int CanConvertToType(Class_ID obtype) {return FALSE;}
		Object* ConvertToType(TimeValue t, Class_ID obtype) {assert(0);return NULL;}		
		int DoOwnSelectHilite()	{ return 1; }


		int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);
		void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);
		void SetExtendedDisplay(int flags);
		int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags);
		void GetWorldBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box );
		void GetLocalBoundBox(TimeValue t, INode *mat, ViewExp *vpt, Box3& box );


		// Animatable methods
		void DeleteThis() { delete this; }
		Class_ID ClassID() { return SITEOBJECT_CLASS_ID; }  
		void GetClassName(TSTR& s) { s = TSTR(GetString(IDS_DB_SITE_HELPER)); }
		int IsKeyable(){ return 1;}

		// This method returns the number of sub-anims this plug-in
		// has.  Is has one, the parameter block.
		int NumSubs()  { return 1; }
		// This methods returns the ith sub-anim (parameter)
		Animatable* SubAnim(int i);
		// This method returns the name of the ith sub-anim.
		TSTR SubAnimName(int i);


	
		// From ref
		// reference the parameter block and the helper
		int NumRefs() { return 1;};
		// This method returns the ith reference.
		RefTargetHandle GetReference(int i);
		// This method sets the ith reference to the target passed.
		void SetReference(int i, RefTargetHandle rtarg);

		// This method recieves the change notification methods
		RefResult NotifyRefChanged(Interval, RefTargetHandle, PartID&, RefMessage);

		RefTargetHandle Clone(RemapDir& remap = NoRemap());
		IOResult Load(ILoad *iload);
		IOResult Save(ISave *isave);

};

#pragma pack(pop)

#endif // __SITEOBJECT__H
