
//**************************************************************************/
// Copyright (c) 2008 Autodesk, Inc.
// All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
//
//**************************************************************************/
// DESCRIPTION:
// CREATED: June 2009
//**************************************************************************/

namespace mudbox {

/// This class represents a collection of faces among one or more
/// mesh objects.
class MBDLL_DECL SelectionSet : public TreeNode
{
public:
	DECLARE_CLASS;

protected:
	/// \brief Constructor.  Do not use it directly; Use CreateInstance() instead.
	///
	/// \code
	///		SelectionSet *mySelectionSet = CreateInstance<SelectionSet>();
	/// \endcode
	SelectionSet( const QString &sName = "" );  

public:

	/// This structure holds the collection of faces for
	/// a given mesh.
	struct MeshInfo 
	{
		MeshInfo( Mesh *pM );
		Mesh *m_pMesh;
		Store<unsigned int> m_aFaces;
	};

	/// Add a mesh to the set.
	/// @param pMesh the mesh to add
	/// @return pMesh's corresponding MeshInfo. Note the SelectionSet owns this memory.
	MeshInfo *AddMesh( Mesh *pMesh );

	/// Hides or shows the members of the set.
	void SetVisible( bool bVisible );

	/// Saves or loads from the given stream.
	void Serialize( Stream & );

	/// Accessor for the array of members of this collection
	inline QList<MeshInfo*>& MeshInfos() { return m_lMeshInfos; }

	// internal use only. do not use.
	inline bool Active() { return m_bActive; }

	// internal use only. do not use.
	inline void SetActive( bool bActive ) { m_bActive = bActive; }

protected:
	bool m_bActive;
	QList<MeshInfo *> m_lMeshInfos;
};

}; // end of namespace mudbox
