/* -*-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_ENGINE_SEAMLESS_ENGINE_NODE_H
#define OSGEARTH_ENGINE_SEAMLESS_ENGINE_NODE_H 1

#include <osgEarth/TerrainEngineNode>
#include <osgEarth/TextureCompositor>

#include "SeamlessOptions"
#include "PatchSet"

namespace seamless
{
class SeamlessEngineNode : public osgEarth::TerrainEngineNode
{
public:
    SeamlessEngineNode();
    SeamlessEngineNode(const SeamlessEngineNode& rhs,
                       const osg::CopyOp& op = osg::CopyOp::DEEP_COPY_ALL);
    META_Node(osgEarth,SeamlessEngineNode);
    ~SeamlessEngineNode();
    // TerrainEngineNode overrides
    virtual void preInitialize(const osgEarth::Map* map,
                            const osgEarth::TerrainOptions& options);
    virtual void validateTerrainOptions(osgEarth::TerrainOptions& options);
    virtual const osgEarth::TerrainOptions& getTerrainOptions() const
    {
        return _terrainOptions;
    }
    // virtual osg::BoundingSphere computeBound() const;
    // MapCallback adapter functions
    void onMapProfileEstablished(const osgEarth::Profile* profile);
    void onImageLayerAdded(osgEarth::ImageLayer*, unsigned int index);
    void onImageLayerRemoved(osgEarth::ImageLayer* layer, unsigned int index);
    void onImageLayerMoved(osgEarth::ImageLayer* layer, unsigned int oldIndex,
                           unsigned int newIndex);
    void onElevationLayerAdded(osgEarth::ElevationLayer*, unsigned int index);
    void onElevationLayerRemoved(osgEarth::ElevationLayer* layer,
                                 unsigned int index);
    void onElevationLayerMoved(osgEarth::ElevationLayer* layer,
                               unsigned int oldIndex, unsigned int newIndex);
    
private:
    osg::ref_ptr<PatchSet> _patchSet;
    osgEarth::Drivers::SeamlessOptions _terrainOptions;
    osgEarth::MapFrame* _mapf;
};
}
#endif
