Cherry pick commit by Erik Broberg

This commit is contained in:
Erik Broberg
2016-11-29 16:18:12 +01:00
committed by Alexander Bock
parent 5589de995b
commit d90a51297d
4 changed files with 195 additions and 0 deletions

View File

@@ -101,6 +101,7 @@ set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/loadjob.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/tileloadjob.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/cachingtileprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/presentationslideprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/singleimageprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/sizereferencetileprovider.h
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/temporaltileprovider.h
@@ -166,6 +167,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/asynctiledataprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/pixelregion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/rawtile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tilediskcache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileindex.cpp
@@ -174,6 +176,7 @@ set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/diskcachedtileloadjob.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/loadjob/tileloadjob.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/cachingtileprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/presentationslideprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/singleimageprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/sizereferencetileprovider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tile/tileprovider/temporaltileprovider.cpp

View File

@@ -37,6 +37,7 @@
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <modules/globebrowsing/tile/tileprovider/tileproviderbylevel.h>
#include <modules/globebrowsing/tile/tileprovider/tileproviderbyindex.h>
#include <modules/globebrowsing/tile/tileprovider/presentationslideprovider.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderable.h>
@@ -119,6 +120,9 @@ void GlobeBrowsingModule::internalInitialize() {
fTileProvider->registerClass<tileprovider::TileProviderByLevel>("ByLevel");
fTileProvider->registerClass<tileprovider::TileProviderByIndex>("ByIndex");
fTileProvider->registerClass<tileprovider::TileProviderByLevel>("ByLevel");
fTileProvider->registerClass<tileprovider::TileProviderByIndex>("ByIndex");
fTileProvider->registerClass<tileprovider::PresentationSlideProvider>("PresentationSlides");
FactoryManager::ref().addFactory(std::move(fTileProvider));
}

View File

@@ -0,0 +1,116 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <modules/globebrowsing/geometry/geodetic2.h>
#include <modules/globebrowsing/tile/tileprovider/presentationslideprovider.h>
#include <modules/globebrowsing/tile/tileindex.h>
#include <ghoul/io/texture/texturereader.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <openspace/engine/openspaceengine.h>
namespace {
const std::string _loggerCat = "PresentationSlideProvider";
const std::string KeyDefaultProvider = "DefaultProvider";
const std::string KeySlideProviders = "SlideProviders";
const std::string KeyTileIndex = "TileIndex";
const std::string KeyTileProvider = "TileProvider";
}
namespace openspace {
namespace globebrowsing {
PresentationSlideProvider::PresentationSlideProvider(const ghoul::Dictionary& dictionary) {
setName("SlideProvider");
ghoul::Dictionary defaultProviderDict = dictionary.value<ghoul::Dictionary>(KeyDefaultProvider);
TileProvider* defaultProvider = TileProvider::createFromDictionary(defaultProviderDict);
_defaultProvider = std::unique_ptr<TileProvider>(defaultProvider);
ghoul::Dictionary tileIndexDict = dictionary.value<ghoul::Dictionary>(KeyTileIndex);
_tileIndex = TileIndex(tileIndexDict);
ghoul::Dictionary slideProvidersDict = dictionary.value<ghoul::Dictionary>(KeySlideProviders);
_slideProviders.resize(slideProvidersDict.size());
for (size_t i = 0; i < slideProvidersDict.size(); i++) {
std::string dictKey = std::to_string(i + 1);
ghoul::Dictionary providerDict = slideProvidersDict.value<ghoul::Dictionary>(dictKey);
TileProvider* tileProvider = TileProvider::createFromDictionary(providerDict);
_slideProviders[i].reset(tileProvider);
}
_slideIndex = std::make_unique<properties::IntProperty>("slideIndex", "slideIndex", 0, 0, _slideProviders.size()-1);
addProperty(_slideIndex.get());
}
Tile PresentationSlideProvider::getTile(const TileIndex& tileIndex) {
if(tileIndex == _tileIndex){
return slideProvider()->getTile(tileIndex);
}
return Tile::TileUnavailable;
}
Tile PresentationSlideProvider::getDefaultTile() {
return _defaultProvider->getDefaultTile();
}
Tile::Status PresentationSlideProvider::getTileStatus(const TileIndex& tileIndex) {
if(tileIndex == _tileIndex){
return slideProvider()->getTileStatus(tileIndex);
}
return Tile::Status::Unavailable;
}
TileDepthTransform PresentationSlideProvider::depthTransform() {
slideProvider()->depthTransform();
}
void PresentationSlideProvider::update() {
slideProvider()->update();
_defaultProvider->update();
}
void PresentationSlideProvider::reset() {
for(auto& tp : _slideProviders){
tp->reset();
}
_defaultProvider->reset();
}
int PresentationSlideProvider::maxLevel() {
return _defaultProvider->maxLevel();
}
TileProvider* PresentationSlideProvider::slideProvider(){
int maxIndex = (int)_slideProviders.size() - 1;
return _slideProviders[std::max(0, std::min(_slideIndex->value(), maxIndex))].get();
}
} // namespace globebrowsing
} // namespace openspace

View File

@@ -0,0 +1,72 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __PRESENTATION_SLIDE_PROVIDER__
#define __PRESENTATION_SLIDE_PROVIDER__
#include <modules/globebrowsing/geometry/geodetic2.h>
#include <modules/globebrowsing/tile/tileprovider/tileprovider.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/opengl/texture.h>
#include <openspace/properties/scalarproperty.h>
#include <memory>
#include <unordered_map>
namespace openspace {
namespace globebrowsing {
using namespace ghoul::opengl;
class PresentationSlideProvider : public TileProvider {
public:
PresentationSlideProvider(const ghoul::Dictionary& dictionary);
PresentationSlideProvider(const std::string& imagePath);
virtual ~PresentationSlideProvider() { }
virtual Tile getTile(const TileIndex& tileIndex);
virtual Tile getDefaultTile();
virtual Tile::Status getTileStatus(const TileIndex& index);
virtual TileDepthTransform depthTransform();
virtual void update();
virtual void reset();
virtual int maxLevel();
private:
TileProvider* slideProvider();
TileIndex _tileIndex;
std::unique_ptr<properties::IntProperty> _slideIndex;
std::vector<std::unique_ptr<TileProvider>> _slideProviders;
std::unique_ptr<TileProvider> _defaultProvider;
};
} // namespace globebrowsing
} // namespace openspace
#endif // __PRESENTATION_SLIDE_PROVIDER__