//
//	Copyright © 2005 Nemetschek North America 
//	All Rights Reserved.
//
// Created by Vladislav Stanev

#ifndef VECTORWORKS_OBJECT__H
#define VECTORWORKS_OBJECT__H

#pragma once

namespace VWFC
{
	using namespace Tools;
	using namespace Math;
	
	namespace VWObjects
	{
		// --------------------------------------------------------------------------------------------------
		typedef std::vector<MCObjectHandle>					TMCObjectHandlesSTLArray;

		// ---------------------------------------------------------------------------------------------
		class VWObject
		{
		protected:
								VWObject();
		public:
								VWObject(MCObjectHandle hObj);
								VWObject(const VWObject&);
			VWObject&			operator=(const VWObject&);

			virtual				~VWObject();

			operator MCObjectHandle() const;

			// object manipulation
			void				DeleteObject(bool bUseUndo=true);
			void				ResetObject();

			// object class
			VWClass				GetObjectClass() const;
			void				SetObjectClass(const VWClass& clas);
			VWObjectAttr&		GetObjectAttribs();
			const VWObjectAttr&	GetObjectAttribs() const;

			// hierarchy
			void				AddObjectToContainer(MCObjectHandle container);
			void				InsertAfterObject(MCObjectHandle afterObj);
			void				InsertBeforeObject(MCObjectHandle beforeObj);

			// traversing
			MCObjectHandle		GetThisObject() const;
			MCObjectHandle		GetNextObject() const;
			MCObjectHandle		GetPrevObject() const;
			MCObjectHandle		GetParentObject() const;
			MCObjectHandle		GetParentLayer() const;
			void				GetContainerInfo(MCObjectHandle* pOutContainerHandle, short* pOutContainerType, double* pOutContainerScale) const;

			// state&data
			short				GetType() const;
			bool				IsVisible() const;
			void				SetVisible(bool bVisible=true);
			bool				IsLocked() const;
			void				SetLock(bool bLock=true);
			bool				IsSelected() const;
			void				SetSelected(bool bSelect=true);
			virtual TXString	GetObjectName() const;
			virtual void		SetObjectName(const TXString& name);

			virtual void		GetObjectBounds(VWRectangle2D& bounds) const;

			// object position & transformation
			virtual void		MoveObject(const VWPoint2D& offset);
			virtual void		MoveObject(double dx, double dy);
			virtual void		MoveObject3D(const VWPoint3D& offset);
			virtual void		MoveObject3D(double dx, double dy, double dz);
			virtual void		RotateObject(const VWPoint2D& pt, double dAngle);
			virtual void		GetObjectMatrix(VWTransformMatrix& outMatrix) const;
			virtual void		SetObjectMatrix(const VWTransformMatrix& matrix);
			virtual void		ApplyObjectMatrix(const VWTransformMatrix& matrix);

			// aux list managment
			void				AttachAuxObject(MCObjectHandle hAuxObject);
			void				DeleteAuxObject(MCObjectHandle hAuxObject);
			MCObjectHandle		FindAuxObject(short type, MCObjectHandle hLastAuxObject=NULL) const;
			MCObjectHandle		GetFirstAuxObject() const;
			VWObjectIterator	GetFirstAuxObjectIterator() const;

		// Tools
		public:
			static void				ResetObjectsVisibility();
			static bool				IsSelected(MCObjectHandle hObj);
			static void				DeselectAll();//XXX Vlado : this should be in the VWDocument
			static void				DeleteObject(MCObjectHandle hObj, bool bUseUndo=true);
			static void				ResetObject(MCObjectHandle hObj);
			static MCObjectHandle	GetNamedObject(const TXString& objName);


		protected:
			MCObjectHandle		fhObject;
			VWObjectAttr		fObjAttribs;
		};
	}
}

#endif // VECTORWORKS_OBJECT__H