/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */

#ifndef OSGEARTH_PICKER_H
#define OSGEARTH_PICKER_H 1

#include <osgEarth/Common>
#include <osgEarth/ObjectIndex>
#include <osgGA/GUIEventHandler>

namespace osgEarth
{
    /**
     * Base class for an object picker. Header only (no export)
     */
    class Picker : public osgGA::GUIEventHandler
    {
    public:
        struct Callback : public osg::Referenced
        {
            // Called when an ID is hit
            virtual void onHit(ObjectID id) { }

            // Called when a query results in nothing
            virtual void onMiss() { }

            // Called to ask whether to perform a query based on events
            virtual bool accept(const osgGA::GUIEventAdapter& ea, const osgGA::GUIActionAdapter& aa) { return false; }
        };

    public:
        
        /**
         * Initiate a pick. The picker will invoke the callback when the pick is complete.
         * Returns true is the pick was successfully queued.
         */
        virtual bool pick(osg::View* view, float mouseX, float mouseY, Callback* callback) = 0;

    protected:

        virtual ~Picker() { }
    };

} // namespace osgEarth

#endif // OSGEARTH_PICKER
