Add data loader module

This commit is contained in:
Jonathan Grangien
2018-05-30 15:15:35 -04:00
committed by Matthias Berg
parent 26761b4bcb
commit 2f13e8665b
8 changed files with 289 additions and 1 deletions
+3 -1
View File
@@ -3,6 +3,8 @@
/bin/
/build/
/cache/
/data/.internal/*
!/data/.internal/readme.md
/doc
/documentation
/ext/SGCT
@@ -34,4 +36,4 @@ cmake-build-*
x64/
customization.lua
COMMIT.md
screenshots
screenshots
+2
View File
@@ -0,0 +1,2 @@
# Internal data
Directory managed by OpenSpace internally, edit carefully
+47
View File
@@ -0,0 +1,47 @@
##########################################################################################
# #
# OpenSpace #
# #
# Copyright (c) 2014-2018 #
# #
# 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(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake)
set(HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dataloadermodule.h
${CMAKE_CURRENT_SOURCE_DIR}/reader.h
)
source_group("Header Files" FILES ${HEADER_FILES})
set(SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/dataloadermodule.cpp
${CMAKE_CURRENT_SOURCE_DIR}/reader.cpp
)
option(OPENSPACE_MODULE_DATALOADER "Use Data Loader Module" ON)
source_group("Source Files" FILES ${SOURCE_FILES})
create_new_module(
"DataLoader"
dataloader_module
STATIC
${HEADER_FILES} ${SOURCE_FILES}
)
+46
View File
@@ -0,0 +1,46 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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/dataloader/dataloadermodule.h>
#include <modules/dataloader/reader.h>
#include <openspace/util/factorymanager.h>
#include <ghoul/misc/assert.h>
namespace openspace {
using namespace dataloader;
DataLoaderModule::DataLoaderModule() : OpenSpaceModule(Name) {}
void DataLoaderModule::internalInitialize(const ghoul::Dictionary&) {
// auto rFactory = FactoryManager::ref().factory<Renderable>();
// ghoul_assert(rFactory, "No renderable factory existed");
// rFactory->registerClass<RenderableTimeVaryingVolume>("RenderableTimeVaryingVolume");
_reader = std::make_unique<openspace::dataloader::Reader>();
addPropertySubOwner(*_reader);
}
} // namespace openspace
+47
View File
@@ -0,0 +1,47 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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 __OPENSPACE_MODULE_DATALOADER___DATALOADERMODULE___H__
#define __OPENSPACE_MODULE_DATALOADER___DATALOADERMODULE___H__
#include <openspace/util/openspacemodule.h>
#include <modules/dataloader/reader.h>
namespace openspace {
class DataLoaderModule : public OpenSpaceModule {
public:
constexpr static const char* Name = "DataLoader";
DataLoaderModule();
void internalInitialize(const ghoul::Dictionary&) override;
private:
std::unique_ptr<openspace::dataloader::Reader> _reader;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_DATALOADER___DATALOADERMODULE___H__
View File
+93
View File
@@ -0,0 +1,93 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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/dataloader/reader.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/filesystem/filesystem.h>
namespace {
constexpr const char* _loggerCat = "Reader";
} // namespace
namespace {
static const openspace::properties::Property::PropertyInfo VolumesInfo = {
"Volumes",
"List of volumes stored internally and ready to load",
"This list contains names of volume data files converted from the CDF format"
};
static const openspace::properties::Property::PropertyInfo ReadVolumeTriggerInfo = {
"Volume Trigger",
"Trigger load volume data files",
"If this property is triggered it will call the function to load volume data"
};
}
namespace openspace::dataloader {
Reader::Reader()
: PropertyOwner({ "Reader" })
, _volumes(VolumesInfo)
, _readVolumeTrigger(ReadVolumeTriggerInfo)
{
_topDir = ghoul::filesystem::Directory(
"${DATA}/.internal",
ghoul::filesystem::Directory::RawPath::No
);
_readVolumeTrigger.onChange([this](){
loadVolumeDataItems();
});
addProperty(_volumes);
addProperty(_readVolumeTrigger);
}
void Reader::readVolumeDataItems() {
// Go into data/.internal(
ghoul::filesystem::Directory volumeDir(
_topDir.path() +
ghoul::filesystem::FileSystem::PathSeparator +
"CDF"
);
// Read files
std::vector<std::string> files = volumeDir.readFiles(
ghoul::filesystem::Directory::Recursive::No,
ghoul::filesystem::Directory::Sort::Yes
);
// Print vector
for (auto el : files) {
LINFO("A file: " + el);
}
// For each folder
// Take first part of file name
// Add to list
// Store a reference somehow if necessary
}
}
+51
View File
@@ -0,0 +1,51 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2018 *
* *
* 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 __OPENSPACE_MODULE_DATALOADER___READER___H__
#define __OPENSPACE_MODULE_DATALOADER___READER___H__
#include <openspace/properties/propertyowner.h>
#include <openspace/properties/property.h> // do we need this
#include <openspace/properties/stringlistproperty.h>
#include <openspace/properties/triggerproperty.h>
#include <ghoul/filesystem/directory.h>
namespace openspace::dataloader {
class Reader : public properties::PropertyOwner {
public:
Reader();
void readVolumeDataItems();
private:
properties::StringListProperty _volumes;
properties::TriggerProperty _readVolumeTrigger;
ghoul::filesystem::Directory _topDir;
};
}
#endif // __OPENSPACE_MODULE_DATALOADER___READER___H__