/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2010 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_MASK_LAYER_H
#define OSGEARTH_MASK_LAYER_H 1

#include <osgEarth/Common>
#include <osgEarth/Layer>
#include <osgEarth/Config>
#include <osgEarth/ModelSource>
#include <osg/Node>

namespace osgEarth
{
    class Map;

    /**
     * A MaskLayer is a specialized layer used to mask out a part of the terrain.
     * Typically you would use this if you had a pre-built 3D terrain model for an inset area.
     *
     * TODO: move this to osgEarth::Util and give it a reasonable API.
     */
    class OSGEARTH_EXPORT MaskLayer : public Layer
    {
    public:
        /**
         * Constructs a new mask layer based on a configuration setup.
         */
        MaskLayer( const ConfigOptions& options =ConfigOptions() );

        /**
         * Gets the reference URI (for resolving relative paths)
         */
        const std::string& getReferenceURI() const { return _referenceURI; }

        /**
         * Access the underlying model source.
         */
        ModelSource* getModelSource() const { return _modelSource.get(); }

    public:

        osg::Node* getOrCreateNode( ProgressCallback* progress =0L );

    public:

        void initialize( const std::string& referenceURI, const Map* map );

        virtual Config getConfig() const;

    private:
        std::string _referenceURI;
        osg::ref_ptr<ModelSource> _modelSource;
        DriverConfigOptions _driverOptions;
        osg::ref_ptr<osg::Node> _node;
    };
}

#endif // OSGEARTH_MASK_LAYER_H

