/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */
#ifndef OSGEARTH_ANNO_IMAGE_OVERLAY_EDITOR_H
#define OSGEARTH_ANNO_IMAGE_OVERLAY_EDITOR_H

#include <osgEarth/Common>
#include <osgEarth/ImageOverlay>
#include <osgEarth/Draggers>
#include <osgEarth/MapNode>
#include <osg/MatrixTransform>
#include <osgGA/GUIEventHandler>

namespace osgEarth { namespace Contrib
{
    class OSGEARTH_EXPORT ImageOverlayEditor : public osg::Group
    {
    public:
        typedef std::map< ImageOverlay::ControlPoint, osg::ref_ptr< Dragger > >  ControlPointDraggerMap;

        ImageOverlayEditor(ImageOverlay* overlay, bool singleVert=false);

        ControlPointDraggerMap& getDraggers() { return _draggers; }

        ImageOverlay* getOverlay() { return _overlay.get();}

        void updateDraggers();

        /**
         * Gets or sets whether to move individual verts, allowing you to skew the image.
         * Otherwise the image will remain north up and rectangular.
         */
        bool getSingleVert() const;        

    protected:

        virtual ~ImageOverlayEditor();
        void addDragger( ImageOverlay::ControlPoint controlPoint );

        osg::ref_ptr< ImageOverlay > _overlay;
        osg::ref_ptr< ImageOverlay::ImageOverlayCallback > _overlayCallback;
        ControlPointDraggerMap _draggers;
        bool _singleVert;
    };

} }

#endif // OSGEARTH_ANNO_IMAGE_OVERLAY_EDITOR_H

