-
Notifications
You must be signed in to change notification settings - Fork 766
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
491 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# MapInspector Extension | ||
# | ||
|
||
SET(TARGET_SRC | ||
MapInspectorPlugin.cpp | ||
MapInspectorExtension.cpp | ||
MapInspectorUI.cpp) | ||
|
||
SET(LIB_PUBLIC_HEADERS | ||
MapInspectorExtension | ||
MapInspectorUI) | ||
|
||
SET(TARGET_H | ||
${LIB_PUBLIC_HEADERS} ) | ||
|
||
SET(TARGET_COMMON_LIBRARIES ${TARGET_COMMON_LIBRARIES} | ||
osgEarthUtil | ||
osgEarthFeatures | ||
osgEarthSymbology) | ||
|
||
SETUP_EXTENSION(osgearth_mapinspector) | ||
|
||
SET(LIB_NAME mapinspector) | ||
|
||
INCLUDE(ModuleInstallOsgEarthExtensionIncludes OPTIONAL) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* -*-c++-*- */ | ||
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph | ||
* Copyright 2008-2014 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_MAPINSPECTOR_EXTENSION | ||
#define OSGEARTH_MAPINSPECTOR_EXTENSION 1 | ||
|
||
#include <osgEarth/Extension> | ||
#include <osgEarth/MapNode> | ||
#include <osgEarth/MapCallback> | ||
#include <osgEarthUtil/Controls> | ||
|
||
namespace osgEarth { namespace MapInspector | ||
{ | ||
using namespace osgEarth; | ||
using namespace osgEarth::Util::Controls; | ||
|
||
/** | ||
* Displays visual metadata about the visible layers in a map. | ||
*/ | ||
class MapInspectorExtension : public Extension, | ||
public ExtensionInterface<MapNode>, | ||
public ExtensionInterface<Control>, | ||
public MapCallback | ||
{ | ||
public: | ||
META_Object(osgearth_ext_MapInspector, MapInspectorExtension); | ||
|
||
// CTORs | ||
MapInspectorExtension(); | ||
MapInspectorExtension(const ConfigOptions& options); | ||
|
||
// DTOR | ||
virtual ~MapInspectorExtension(); | ||
|
||
|
||
public: // ExtensionInterface<MapNode> | ||
|
||
bool connect(MapNode* mapNode); | ||
|
||
bool disconnect(MapNode* mapNode); | ||
|
||
|
||
public: // ExtensionInterface<Control> | ||
|
||
bool connect(Control* control); | ||
|
||
bool disconnect(Control* control); | ||
|
||
|
||
public: // MapCallback | ||
|
||
void onMapModelChanged(const MapModelChange& change); | ||
|
||
|
||
protected: // Object | ||
|
||
MapInspectorExtension(const MapInspectorExtension& rhs, const osg::CopyOp& op) { } | ||
|
||
|
||
private: | ||
osg::observer_ptr<MapNode> _mapNode; | ||
osg::ref_ptr<Control> _ui; | ||
|
||
void ctor(); | ||
}; | ||
|
||
} } // namespace osgEarth::MapInspector | ||
|
||
#endif // OSGEARTH_MAPINSPECTOR_EXTENSION |
106 changes: 106 additions & 0 deletions
106
src/osgEarthExtensions/mapinspector/MapInspectorExtension.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* -*-c++-*- */ | ||
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph | ||
* Copyright 2008-2014 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/> | ||
*/ | ||
#include "MapInspectorExtension" | ||
#include "MapInspectorUI" | ||
|
||
using namespace osgEarth; | ||
using namespace osgEarth::Util; | ||
using namespace osgEarth::Util::Controls; | ||
using namespace osgEarth::MapInspector; | ||
|
||
#define LC "[MapInspector] " | ||
|
||
MapInspectorExtension::MapInspectorExtension() | ||
{ | ||
ctor(); | ||
} | ||
|
||
MapInspectorExtension::MapInspectorExtension(const ConfigOptions& options) | ||
{ | ||
ctor(); | ||
} | ||
|
||
MapInspectorExtension::~MapInspectorExtension() | ||
{ | ||
// nop | ||
} | ||
|
||
void | ||
MapInspectorExtension::ctor() | ||
{ | ||
OE_INFO << LC << "loaded\n"; | ||
_ui = new MapInspectorUI(); | ||
} | ||
|
||
|
||
void | ||
MapInspectorExtension::onMapModelChanged(const MapModelChange& change) | ||
{ | ||
osg::ref_ptr<MapNode> mapNode; | ||
_mapNode.lock(mapNode); | ||
static_cast<MapInspectorUI*>(_ui.get())->reinit(mapNode.get()); | ||
} | ||
|
||
bool | ||
MapInspectorExtension::connect(MapNode* mapNode) | ||
{ | ||
OE_INFO << LC << "connected\n"; | ||
if ( mapNode ) | ||
{ | ||
_mapNode = mapNode; | ||
_mapNode->getMap()->addMapCallback(this); | ||
static_cast<MapInspectorUI*>(_ui.get())->reinit(mapNode); | ||
} | ||
return true; | ||
} | ||
|
||
bool | ||
MapInspectorExtension::disconnect(MapNode* mapNode) | ||
{ | ||
OE_INFO << LC << "disconnected\n"; | ||
|
||
if ( mapNode ) | ||
mapNode->getMap()->removeMapCallback(this); | ||
|
||
_mapNode = 0L; | ||
static_cast<MapInspectorUI*>(_ui.get())->reinit(0L); | ||
return true; | ||
} | ||
|
||
bool | ||
MapInspectorExtension::connect(Control* control) | ||
{ | ||
Container* container = dynamic_cast<Container*>(control); | ||
if ( container && _ui.valid() ) | ||
{ | ||
container->addControl( _ui.get() ); | ||
} | ||
return true; | ||
} | ||
|
||
bool | ||
MapInspectorExtension::disconnect(Control* control) | ||
{ | ||
Container* container = dynamic_cast<Container*>(control); | ||
if ( container && _ui.valid() ) | ||
{ | ||
container->removeChild( _ui.get() ); | ||
} | ||
return true; | ||
} |
55 changes: 55 additions & 0 deletions
55
src/osgEarthExtensions/mapinspector/MapInspectorPlugin.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* -*-c++-*- */ | ||
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph | ||
* Copyright 2008-2014 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/> | ||
*/ | ||
#include "MapInspectorExtension" | ||
|
||
#include <osgDB/ReaderWriter> | ||
#include <osgDB/Registry> | ||
#include <osgDB/FileNameUtils> | ||
|
||
namespace osgEarth { namespace MapInspector | ||
{ | ||
/** | ||
* Plugin entry point | ||
*/ | ||
class MapInspectorPlugin : public osgDB::ReaderWriter | ||
{ | ||
public: // Plugin stuff | ||
|
||
MapInspectorPlugin() { | ||
supportsExtension( "osgearth_mapinspector", "osgEarth MapInspector Extension" ); | ||
} | ||
|
||
const char* className() { | ||
return "osgEarth MapInspector Extension"; | ||
} | ||
|
||
virtual ~MapInspectorPlugin() { } | ||
|
||
ReadResult readObject(const std::string& filename, const osgDB::Options* dbOptions) const | ||
{ | ||
if ( !acceptsExtension(osgDB::getLowerCaseFileExtension(filename)) ) | ||
return ReadResult::FILE_NOT_HANDLED; | ||
|
||
return ReadResult( new MapInspectorExtension(Extension::getConfigOptions(dbOptions)) ); | ||
} | ||
}; | ||
|
||
REGISTER_OSGPLUGIN(osgearth_mapinspector, MapInspectorPlugin) | ||
|
||
} } // namespace osgEarth::MapInspector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* -*-c++-*- */ | ||
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph | ||
* Copyright 2008-2014 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_MAPINSPECTOR_UI | ||
#define OSGEARTH_MAPINSPECTOR_UI 1 | ||
|
||
#include <osgEarth/MapCallback> | ||
#include <osgEarth/MapNode> | ||
#include <osgEarthUtil/Controls> | ||
#include <osg/View> | ||
|
||
namespace osgEarth { namespace MapInspector | ||
{ | ||
using namespace osgEarth; | ||
|
||
class MapInspectorUI : public osgEarth::Util::Controls::Grid | ||
{ | ||
public: | ||
/** create UI */ | ||
MapInspectorUI(); | ||
|
||
/** rebuild everything */ | ||
void reinit(MapNode* mapNode); | ||
|
||
private: | ||
//osg::observer_ptr<MapNode> _mapNode; | ||
osg::ref_ptr<osg::Group> _annos; | ||
|
||
void addTerrainLayer(class TerrainLayer* layer, MapNode* mapNode); | ||
void addModelLayer (class ModelLayer* layer, MapNode* mapNode); | ||
}; | ||
|
||
} } // namespace | ||
|
||
#endif // OSGEARTH_MAPINSPECTOR_UI |
Oops, something went wrong.