/* -*-c++-*- 
 * 
 * osgART - ARToolKit for OpenSceneGraph
 * Copyright (C) 2005-2008 Human Interface Technology Laboratory New Zealand
 * 
 * This file is part of osgART 2.0
 *
 * osgART 2.0 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * osgART 2.0 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with osgART 2.0.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef OSGART_MARKER
#define OSGART_MARKER 1


// General
#include <string>

// STL headers
#include <vector>

// local headers
#include "osgART/Export"
#include "osgART/Field"

// OSG headers
#include <osg/Matrix>
#include <osg/Vec3>
#include <osg/Referenced>
#include <osg/ImageStream>


namespace osgART {

	/**
	* \class Marker
	* \brief A base class from which specific types of markers are derived.
	*/
	class OSGART_EXPORT Marker : public osg::Referenced, public FieldContainer<Marker>
	{
	public:
	
        virtual bool isSameKindAs(const osg::Object* obj) const {
            return dynamic_cast<const Marker*>(obj) != 0L;
        }
        virtual const char* className() const { return "Marker"; }

		enum MarkerType
		{
			ART_UNKOWN = 0,	//<! unknown marker type
			ART_SINGLE,		//<! a single marker
			ART_MULTI,		//<! a multimarker
			ART_NFT,		//<! a natural feature
			ART_BAZAR
		};
		
		/** 
		* \brief default constructor.
		*
		*/
		Marker();

		/**
		* Return the type of the Marker. 
		* \return type of marker
		*/
		virtual MarkerType getType() const;
		
		/**
		* Determine if the marker is visible.
		* Return the validity of the marker, mainly valid with no occlusion,
		* no loss of tracking, in the FOV of the camera, correct recognition, etc.
		* \return the validity of the marker (true if valid).
		*/
		virtual bool valid() const;

		/**
		* Obtain the transformation of the marker.
		* Return return a 4x4 transformation of the marker (european order).
		* \return a 4x4 matrix
		*/
		const osg::Matrix& getTransform() const;		
		
		/**
		* \brief set name of the marker
		* \param name identifier name for the marker
		*/
		void setName(const std::string& name);
		
		/** 
		* \brief retrieve name of the marker
		* \return marker name 
		*/
		const std::string& getName() const;

		/**
		* \brief set the respective marker active 
		* \param active set to TRUE if the marker should be tracked
		*/
		virtual void setActive(bool active);	

		/**
		* \brief retrieve activity status from the marker
		* \return TRUE if the marker is active
		*/
		bool active() const;

		
		inline float getConfidence() const { return _confidence; };

		
	protected: 
	
	
		/**
		* \brief destructor.
		*/
		virtual ~Marker(); 
		
	protected:

		/**
		 * Internal update of matrix
		 */
		void updateTransform(const osg::Matrix& transform);


		float _confidence;
		
		
		bool m_valid;		
		bool m_active;
		
		osg::Matrix m_transform;
		
		std::string m_name;
	};


};

#endif
