/* -*-c++-*- */
/* osgEarth - Geospatial SDK for OpenSceneGraph
 * Copyright 2018 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_VIEWPOINTS_EXTENSION
#define OSGEARTH_VIEWPOINTS_EXTENSION 1

#include <osgEarth/Extension>
#include <osgEarth/Viewpoint>
#include <osgEarthUtil/Controls>
#include <osgGA/GUIEventAdapter>
#include <osg/View>
#include <vector>

namespace osgEarth { namespace Viewpoints
{
    using namespace osgEarth;
    using namespace osgEarth::Util::Controls;

    /**
     * Loads a collection of viewpoints and makes them available
     * through a Controls UI.
     */
    class ViewpointsExtension : public Extension,
                                public ExtensionInterface<osg::View>,
                                public ExtensionInterface<Control>,
                                public ConfigOptions
    {
    public:
        META_OE_Extension(osgEarth, ViewpointsExtension, viewpoints);

        // CTORs
        ViewpointsExtension();
        ViewpointsExtension(const ConfigOptions& options);

        // DTOR
        virtual ~ViewpointsExtension();


    public: // Extension

        void setDBOptions(const osgDB::Options* dbOptions);

        // Use "this" since this class derives from ConfigOptions.
        const ConfigOptions& getConfigOptions() const { return *this; }


    public: // ExtensionInterface<osg::View>

        bool connect(osg::View* view);

        bool disconnect(osg::View* view);


    public: // ExtensionInterface<Control>

        bool connect(Control* control);

        bool disconnect(Control* control);

    private:
        osg::ref_ptr<const osgDB::Options>   _dbOptions;
        osg::ref_ptr<osgGA::GUIEventHandler> _handler;
    };

} } // namespace osgEarth::Viewpoints

#endif // OSGEARTH_VIEWPOINTS_EXTENSION
