From c2f9c66372c788fa0c8a2212bb22eeec485a5216 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Mon, 1 May 2017 11:22:37 -0400
Subject: [PATCH 01/23] Update Ghoul Update SGCT
---
ext/ghoul | 2 +-
ext/sgct | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ext/ghoul b/ext/ghoul
index 07b2d4c602..8afa0763b1 160000
--- a/ext/ghoul
+++ b/ext/ghoul
@@ -1 +1 @@
-Subproject commit 07b2d4c60272c345eb8e9de12d4497a6384b583c
+Subproject commit 8afa0763b1dc52b02384333abffa7e126146403c
diff --git a/ext/sgct b/ext/sgct
index 1eb6bcfa78..d73ac8eac4 160000
--- a/ext/sgct
+++ b/ext/sgct
@@ -1 +1 @@
-Subproject commit 1eb6bcfa78a08abf0caa4c7a03097316e76d701b
+Subproject commit d73ac8eac4babc24b3953d9faa1a3a2aa677fac8
From 63d607281a79735d641f80da418f8165535043c4 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Tue, 9 May 2017 10:30:35 +0100
Subject: [PATCH 02/23] Update SGCT repository Add property to toggle date
rendering independent from rendering statistics
---
ext/sgct | 2 +-
include/openspace/rendering/renderengine.h | 3 ++-
src/rendering/renderengine.cpp | 21 +++++++++++++++------
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/ext/sgct b/ext/sgct
index d73ac8eac4..9a1a7ab821 160000
--- a/ext/sgct
+++ b/ext/sgct
@@ -1 +1 @@
-Subproject commit d73ac8eac4babc24b3953d9faa1a3a2aa677fac8
+Subproject commit 9a1a7ab8219a1ffc728f8f883ab0c2dfa8bbf2ab
diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h
index bbd88093b8..cb5cdb8382 100644
--- a/include/openspace/rendering/renderengine.h
+++ b/include/openspace/rendering/renderengine.h
@@ -204,6 +204,7 @@ private:
//FrametimeType _frametimeType;
+ properties::BoolProperty _showDate;
properties::BoolProperty _showInfo;
properties::BoolProperty _showLog;
@@ -212,7 +213,7 @@ private:
properties::BoolProperty _applyWarping;
properties::BoolProperty _showFrameNumber;
properties::BoolProperty _disableMasterRendering;
- properties::BoolProperty _disableSceneOnMaster;
+ properties::BoolProperty _disableSceneTranslationOnMaster;
float _globalBlackOutFactor;
float _fadeDuration;
diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp
index a3add880e3..7f34cbedd1 100644
--- a/src/rendering/renderengine.cpp
+++ b/src/rendering/renderengine.cpp
@@ -105,6 +105,7 @@ RenderEngine::RenderEngine()
"Type of the frametime display",
properties::OptionProperty::DisplayType::Dropdown
)
+ , _showDate("showDate", "Show Date Information", true)
, _showInfo("showInfo", "Show Render Information", true)
, _showLog("showLog", "Show the OnScreen log", true)
, _takeScreenshot("takeScreenshot", "Take Screenshot")
@@ -112,7 +113,11 @@ RenderEngine::RenderEngine()
, _applyWarping("applyWarpingScreenshot", "Apply Warping to Screenshots", false)
, _showFrameNumber("showFrameNumber", "Show Frame Number", false)
, _disableMasterRendering("disableMasterRendering", "Disable Master Rendering", false)
- , _disableSceneOnMaster("disableSceneOnMaster", "Disable Scene on Master", false)
+ , _disableSceneTranslationOnMaster(
+ "disableSceneTranslationOnMaster",
+ "Disable Scene Translation on Master",
+ false
+ )
, _globalBlackOutFactor(1.f)
, _fadeDuration(2.f)
, _currentFadeTime(0.f)
@@ -147,6 +152,7 @@ RenderEngine::RenderEngine()
);
addProperty(_frametimeType);
+ addProperty(_showDate);
addProperty(_showInfo);
addProperty(_showLog);
@@ -165,8 +171,8 @@ RenderEngine::RenderEngine()
addProperty(_showFrameNumber);
+ addProperty(_disableSceneTranslationOnMaster);
addProperty(_disableMasterRendering);
- addProperty(_disableSceneOnMaster);
}
void RenderEngine::setRendererFromString(const std::string& renderingMethod) {
@@ -214,7 +220,7 @@ void RenderEngine::initialize() {
}
if (confManager.hasKey(ConfigurationManager::KeyDisableSceneOnMaster)) {
- _disableSceneOnMaster = confManager.value(
+ _disableSceneTranslationOnMaster = confManager.value(
ConfigurationManager::KeyDisableSceneOnMaster
);
}
@@ -395,7 +401,7 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
LTRACE("RenderEngine::render(begin)");
WindowWrapper& wrapper = OsEng.windowWrapper();
- if (_disableSceneOnMaster && wrapper.isMaster()) {
+ if (_disableSceneTranslationOnMaster && wrapper.isMaster()) {
_camera->sgctInternal.setViewMatrix(viewMatrix);
}
else {
@@ -805,9 +811,9 @@ void RenderEngine::renderInformation() {
fontResolution().y
//OsEng.windowWrapper().viewportPixelCoordinates().w
);
- penPosition.y -= _fontDate->height();
- if (_showInfo && _fontDate) {
+ if (_showDate && _fontDate) {
+ penPosition.y -= _fontDate->height();
RenderFontCr(
*_fontDate,
penPosition,
@@ -815,6 +821,9 @@ void RenderEngine::renderInformation() {
Time::ref().UTC().c_str()
);
}
+ else {
+ penPosition.y -= _fontInfo->height();
+ }
if (_showInfo && _fontInfo) {
RenderFontCr(
*_fontInfo,
From fdd5a98bcdce43a2b2d328200734d5e349640e12 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Tue, 9 May 2017 10:44:20 +0100
Subject: [PATCH 03/23] Render shutdown information correctly on MacOS
---
src/rendering/renderengine.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp
index 7f34cbedd1..aa58ccc34e 100644
--- a/src/rendering/renderengine.cpp
+++ b/src/rendering/renderengine.cpp
@@ -449,8 +449,8 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) {
);
glm::vec2 penPosition = glm::vec2(
- OsEng.windowWrapper().viewportPixelCoordinates().y - size.boundingBox.x,
- OsEng.windowWrapper().viewportPixelCoordinates().w - size.boundingBox.y
+ fontResolution().x - size.boundingBox.x - 10,
+ fontResolution().y - size.boundingBox.y
);
penPosition.y -= _fontDate->height();
From ab192959c5a9cf0acc8cbd151d41fb1e86ca3712 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Tue, 9 May 2017 10:55:36 +0100
Subject: [PATCH 04/23] Position frame number rendering correctly on MacOS Use
more efficient drawing method Small style fixes
---
src/rendering/renderengine.cpp | 54 ++++++++++++++++++++--------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp
index aa58ccc34e..27b05ed8e9 100644
--- a/src/rendering/renderengine.cpp
+++ b/src/rendering/renderengine.cpp
@@ -232,17 +232,27 @@ void RenderEngine::initialize() {
setRendererFromString(renderingMethod);
#ifdef GHOUL_USE_DEVIL
- ghoul::io::TextureReader::ref().addReader(std::make_shared());
+ ghoul::io::TextureReader::ref().addReader(
+ std::make_shared()
+ );
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
- ghoul::io::TextureReader::ref().addReader(std::make_shared());
+ ghoul::io::TextureReader::ref().addReader(
+ std::make_shared()
+ );
#endif // GHOUL_USE_FREEIMAGE
#ifdef GHOUL_USE_SOIL
- ghoul::io::TextureReader::ref().addReader(std::make_shared());
- ghoul::io::TextureWriter::ref().addWriter(std::make_shared());
+ ghoul::io::TextureReader::ref().addReader(
+ std::make_shared()
+ );
+ ghoul::io::TextureWriter::ref().addWriter(
+ std::make_shared()
+ );
#endif // GHOUL_USE_SOIL
- ghoul::io::TextureReader::ref().addReader(std::make_shared());
+ ghoul::io::TextureReader::ref().addReader(
+ std::make_shared()
+ );
MissionManager::initialize();
}
@@ -278,8 +288,8 @@ void RenderEngine::initializeGL() {
}
void RenderEngine::deinitialize() {
- for (auto screenspacerenderable : _screenSpaceRenderables) {
- screenspacerenderable->deinitialize();
+ for (std::shared_ptr ssr : _screenSpaceRenderables) {
+ ssr->deinitialize();
}
MissionManager::deinitialize();
@@ -326,8 +336,8 @@ void RenderEngine::updateRenderer() {
}
void RenderEngine::updateScreenSpaceRenderables() {
- for (auto& screenspacerenderable : _screenSpaceRenderables) {
- screenspacerenderable->update();
+ for (std::shared_ptr& ssr : _screenSpaceRenderables) {
+ ssr->update();
}
}
@@ -393,8 +403,6 @@ void RenderEngine::updateFade() {
}
}
-
-
void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMatrix,
const glm::mat4& projectionMatrix)
{
@@ -419,20 +427,20 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat
renderInformation();
}
- glm::vec2 penPosition = glm::vec2(
- OsEng.windowWrapper().viewportPixelCoordinates().y / 2 - 50,
- OsEng.windowWrapper().viewportPixelCoordinates().w / 3
- );
-
if (_showFrameNumber) {
- RenderFontCr(*_fontBig, penPosition, "%i", _frameNumber);
+ const glm::vec2 penPosition = glm::vec2(
+ fontResolution().x / 2 - 50,
+ fontResolution().y / 3
+ );
+
+ RenderFont(*_fontBig, penPosition, "%i", _frameNumber);
}
_frameNumber++;
- for (auto& screenSpaceRenderable : _screenSpaceRenderables) {
- if (screenSpaceRenderable->isEnabled() && screenSpaceRenderable->isReady()) {
- screenSpaceRenderable->render();
+ for (std::shared_ptr& ssr : _screenSpaceRenderables) {
+ if (ssr->isEnabled() && ssr->isReady()) {
+ ssr->render();
}
}
LTRACE("RenderEngine::render(end)");
@@ -742,7 +750,7 @@ void RenderEngine::unregisterScreenSpaceRenderable(
}
void RenderEngine::unregisterScreenSpaceRenderable(std::string name){
- auto s = screenSpaceRenderable(name);
+ std::shared_ptr s = screenSpaceRenderable(name);
if (s) {
unregisterScreenSpaceRenderable(s);
}
@@ -1285,7 +1293,9 @@ void RenderEngine::sortScreenspaceRenderables() {
std::sort(
_screenSpaceRenderables.begin(),
_screenSpaceRenderables.end(),
- [](auto j, auto i) {
+ [](const std::shared_ptr& j,
+ const std::shared_ptr& i)
+ {
return i->depth() > j->depth();
}
);
From 701b3afb2cbbfc256793b92b498baccbc15feab8 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Tue, 9 May 2017 11:17:14 +0100
Subject: [PATCH 05/23] Clean up interdace of Mission class
---
include/openspace/mission/mission.h | 12 ++++++------
src/mission/mission.cpp | 12 +++++++-----
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/include/openspace/mission/mission.h b/include/openspace/mission/mission.h
index 914afb040c..b5dfe70f50 100644
--- a/include/openspace/mission/mission.h
+++ b/include/openspace/mission/mission.h
@@ -62,26 +62,25 @@ public:
* Returns the name of the MissionPhase.
* \return The name of the MissionPhase
*/
- const std::string& name() const;
+ std::string name() const;
/**
* Returns the TimeRange of the MissionPhase.
* \return The TimeRange of the MissionPhase
*/
- const TimeRange& timeRange() const;
+ TimeRange timeRange() const;
/**
* Returns the description of the MissionPhase.
* \return The description of the MissionPhase
*/
- const std::string& description() const;
+ std::string description() const;
/**
* Returns all subphases sorted by start time.
* \return All subphases sorted by start time
*/
- const std::vector& phases() const;
-
+ std::vector phases() const;
using Trace = std::vector>;
@@ -111,6 +110,7 @@ protected:
* \param time The time which the subphases have to cover to be added to the \p trace
* \param trace The list of MissionPhase%s that are active during the time \p time
* \param maxDepth The maximum depth of levels that will be considered
+ * \pre maxDepth must not be negative
*/
void phaseTrace(double time, Trace& trace, int maxDepth) const;
@@ -139,7 +139,7 @@ using Mission = MissionPhase;
* \pre \p filename must not contain tokens
* \pre \p filename must exist
*/
-Mission missionFromFile(std::string filename);
+Mission missionFromFile(const std::string& filename);
} // namespace openspace
diff --git a/src/mission/mission.cpp b/src/mission/mission.cpp
index a73edd6397..107d486aae 100644
--- a/src/mission/mission.cpp
+++ b/src/mission/mission.cpp
@@ -137,19 +137,19 @@ MissionPhase::MissionPhase(const ghoul::Dictionary& dict) {
}
}
-const std::string & MissionPhase::name() const {
+std::string MissionPhase::name() const {
return _name;
}
-const TimeRange & MissionPhase::timeRange() const {
+TimeRange MissionPhase::timeRange() const {
return _timeRange;
}
-const std::string & MissionPhase::description() const {
+std::string MissionPhase::description() const {
return _description;
}
-const std::vector& MissionPhase::phases() const {
+std::vector MissionPhase::phases() const {
return _subphases;
}
@@ -163,6 +163,8 @@ MissionPhase::Trace MissionPhase::phaseTrace(double time, int maxDepth) const {
}
void MissionPhase::phaseTrace(double time, Trace& trace, int maxDepth) const {
+ ghoul_assert(maxDepth >= 0, "maxDepth must not be negative");
+
if (maxDepth == 0) {
return;
}
@@ -180,7 +182,7 @@ void MissionPhase::phaseTrace(double time, Trace& trace, int maxDepth) const {
}
}
-Mission missionFromFile(std::string filename) {
+Mission missionFromFile(const std::string& filename) {
ghoul_assert(!filename.empty(), "filename must not be empty");
ghoul_assert(!FileSys.containsToken(filename), "filename must not contain tokens");
ghoul_assert(FileSys.fileExists(filename), "filename must exist");
From fa7cee729c40ce0f8996622ea5b18aaaf426433d Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Tue, 9 May 2017 11:17:32 +0100
Subject: [PATCH 06/23] Add documentation to Keybinding doc file
---
data/web/keybindings/keybinding.hbs | 1 +
1 file changed, 1 insertion(+)
diff --git a/data/web/keybindings/keybinding.hbs b/data/web/keybindings/keybinding.hbs
index 29773e357e..4873cdef05 100644
--- a/data/web/keybindings/keybinding.hbs
+++ b/data/web/keybindings/keybinding.hbs
@@ -6,6 +6,7 @@
{{key}} {{#if remoteScripting}}Remote scripting{{else}}Local scripting{{/if}}
{{script}}
+ {{documentation}}
From ddc9ef1bc56ed04ef84bf99fc906ea8558892791 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Tue, 9 May 2017 18:06:14 +0100
Subject: [PATCH 07/23] Add abstract class to handle Handlebar-based
documentation file generation Apply Documented class to the
InteractionHandler Update Ghoul
---
ext/ghoul | 2 +-
.../interaction/interactionhandler.h | 8 +-
include/openspace/util/documented.h | 57 ++++
src/CMakeLists.txt | 2 +
src/engine/openspaceengine.cpp | 3 +-
src/interaction/interactionhandler.cpp | 291 ++++++++++--------
src/util/documented.cpp | 136 ++++++++
7 files changed, 368 insertions(+), 131 deletions(-)
create mode 100644 include/openspace/util/documented.h
create mode 100644 src/util/documented.cpp
diff --git a/ext/ghoul b/ext/ghoul
index 8afa0763b1..a2f58b3085 160000
--- a/ext/ghoul
+++ b/ext/ghoul
@@ -1 +1 @@
-Subproject commit 8afa0763b1dc52b02384333abffa7e126146403c
+Subproject commit a2f58b30857be62ff13ee4128dec28037d940be7
diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h
index 76ab9b5610..dc68272217 100644
--- a/include/openspace/interaction/interactionhandler.h
+++ b/include/openspace/interaction/interactionhandler.h
@@ -31,6 +31,7 @@
#include
#include
#include
+#include
#include
#include
@@ -48,8 +49,7 @@ class SceneGraphNode;
namespace interaction {
-class InteractionHandler : public properties::PropertyOwner
-{
+class InteractionHandler : public properties::PropertyOwner, public Documented {
public:
InteractionHandler();
~InteractionHandler();
@@ -121,7 +121,7 @@ public:
void saveCameraStateToFile(const std::string& filepath);
void restoreCameraStateFromFile(const std::string& filepath);
- void writeKeyboardDocumentation(const std::string& type, const std::string& file);
+// void writeKeyboardDocumentation(const std::string& type, const std::string& file);
private:
using Synchronized = ghoul::Boolean;
@@ -131,6 +131,8 @@ private:
Synchronized synchronization;
std::string documentation;
};
+
+ std::string generateJson() const override;
void setInteractionMode(std::shared_ptr interactionMode);
diff --git a/include/openspace/util/documented.h b/include/openspace/util/documented.h
new file mode 100644
index 0000000000..c6cfd16445
--- /dev/null
+++ b/include/openspace/util/documented.h
@@ -0,0 +1,57 @@
+/*****************************************************************************************
+ * *
+ * OpenSpace *
+ * *
+ * Copyright (c) 2014-2017 *
+ * *
+ * 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_CORE___DOCUMENTED___H__
+#define __OPENSPACE_CORE___DOCUMENTED___H__
+
+#include
+#include
+
+namespace openspace {
+
+class Documented {
+public:
+ struct HandlebarTemplate {
+ std::string name;
+ std::string filename;
+ };
+
+ Documented(std::string name, std::string jsonName, std::vector handlebarTemplates,
+ std::string javascriptFilename);
+
+ void writeDocumentation(const std::string& filename);
+
+protected:
+ virtual std::string generateJson() const = 0;
+
+private:
+ const std::string _name;
+ const std::string _jsonName;
+ const std::vector _handlebarTemplates;
+ const std::string _javascriptFile;
+};
+
+} // namespace openspace
+
+#endif // __OPENSPACE_CORE___DOCUMENTED___H__
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 330ff94505..d40d56c9c9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -138,6 +138,7 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/util/blockplaneintersectiongeometry.cpp
${OPENSPACE_BASE_DIR}/src/util/boxgeometry.cpp
${OPENSPACE_BASE_DIR}/src/util/camera.cpp
+ ${OPENSPACE_BASE_DIR}/src/util/documented.cpp
${OPENSPACE_BASE_DIR}/src/util/factorymanager.cpp
${OPENSPACE_BASE_DIR}/src/util/keys.cpp
${OPENSPACE_BASE_DIR}/src/util/openspacemodule.cpp
@@ -281,6 +282,7 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/util/blockplaneintersectiongeometry.h
${OPENSPACE_BASE_DIR}/include/openspace/util/boxgeometry.h
${OPENSPACE_BASE_DIR}/include/openspace/util/camera.h
+ ${OPENSPACE_BASE_DIR}/include/openspace/util/documented.h
${OPENSPACE_BASE_DIR}/include/openspace/util/factorymanager.h
${OPENSPACE_BASE_DIR}/include/openspace/util/factorymanager.inl
${OPENSPACE_BASE_DIR}/include/openspace/util/keys.h
diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp
index 33ada3f73a..d2bdea1456 100644
--- a/src/engine/openspaceengine.cpp
+++ b/src/engine/openspaceengine.cpp
@@ -604,7 +604,8 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
if (hasType && hasFile) {
file = absPath(file);
- interactionHandler().writeKeyboardDocumentation(type, file);
+ interactionHandler().writeDocumentation(file);
+// interactionHandler().writeKeyboardDocumentation(type, file);
}
}
diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp
index 81d3a029a9..e87dabb564 100644
--- a/src/interaction/interactionhandler.cpp
+++ b/src/interaction/interactionhandler.cpp
@@ -59,10 +59,10 @@ namespace {
const char* MainTemplateFilename = "${OPENSPACE_DATA}/web/keybindings/main.hbs";
const char* KeybindingTemplateFilename = "${OPENSPACE_DATA}/web/keybindings/keybinding.hbs";
- const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js";
+// const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js";
const char* JsFilename = "${OPENSPACE_DATA}/web/keybindings/script.js";
- const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css";
- const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css";
+// const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css";
+// const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css";
} // namespace
#include "interactionhandler_lua.inl"
@@ -73,6 +73,15 @@ namespace interaction {
// InteractionHandler
InteractionHandler::InteractionHandler()
: properties::PropertyOwner("Interaction")
+ , Documented(
+ "Documentation",
+ "keybindings",
+ {
+ { "keybindingTemplate", KeybindingTemplateFilename },
+ { "mainTemplate", MainTemplateFilename }
+ },
+ JsFilename
+ )
, _origin("origin", "Origin", "")
, _rotationalFriction("rotationalFriction", "Rotational Friction", true)
, _horizontalFriction("horizontalFriction", "Horizontal Friction", true)
@@ -433,133 +442,163 @@ void InteractionHandler::bindKey(Key key, KeyModifier modifier,
}
-void InteractionHandler::writeKeyboardDocumentation(const std::string& type,
- const std::string& file)
-{
- if (type == "text") {
- std::ofstream f;
- f.exceptions(~std::ofstream::goodbit);
- f.open(absPath(file));
-
- for (const auto& p : _keyLua) {
- std::string remoteScriptingInfo;
- bool remoteScripting = p.second.synchronization;
-
- if (!remoteScripting) {
- remoteScriptingInfo = " (LOCAL)";
- }
- f << std::to_string(p.first) << ": "
- << p.second.command << remoteScriptingInfo << '\n'
- << p.second.documentation << '\n';
+std::string InteractionHandler::generateJson() const {
+ std::stringstream json;
+ json << "[";
+ bool first = true;
+ for (const auto& p : _keyLua) {
+ if (!first) {
+ json << ",";
+ }
+ first = false;
+ json << "{";
+ json << "\"key\": \"" << std::to_string(p.first) << "\",";
+ json << "\"script\": \"" << p.second.command << "\",";
+ json << "\"remoteScripting\": " << (p.second.synchronization ? "true," : "false,");
+ json << "\"documentation\": \"" << p.second.documentation << "\"";
+ json << "}";
+ }
+ json << "]";
+
+ std::string jsonString = "";
+ for (const char& c : json.str()) {
+ if (c == '\'') {
+ jsonString += "\\'";
+ } else {
+ jsonString += c;
}
}
- else if (type == "html") {
- std::ofstream f;
- f.exceptions(~std::ofstream::goodbit);
- f.open(absPath(file));
- std::ifstream handlebarsInput(absPath(HandlebarsFilename));
- std::ifstream jsInput(absPath(JsFilename));
-
- std::string jsContent;
- std::back_insert_iterator jsInserter(jsContent);
-
- std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
- std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
-
- std::ifstream bootstrapInput(absPath(BootstrapFilename));
- std::ifstream cssInput(absPath(CssFilename));
-
- std::string cssContent;
- std::back_insert_iterator cssInserter(cssContent);
-
- std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
- std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
-
- std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
- std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ifstream keybindingTemplateInput(absPath(KeybindingTemplateFilename));
- std::string keybindingTemplateContent{ std::istreambuf_iterator{keybindingTemplateInput},
- std::istreambuf_iterator{} };
-
- std::stringstream json;
- json << "[";
- bool first = true;
- for (const auto& p : _keyLua) {
- if (!first) {
- json << ",";
- }
- first = false;
- json << "{";
- json << "\"key\": \"" << std::to_string(p.first) << "\",";
- json << "\"script\": \"" << p.second.command << "\",";
- json << "\"remoteScripting\": " << (p.second.synchronization ? "true," : "false,");
- json << "\"documentation\": \"" << p.second.documentation << "\"";
- json << "}";
- }
- json << "]";
-
- std::string jsonString = "";
- for (const char& c : json.str()) {
- if (c == '\'') {
- jsonString += "\\'";
- } else {
- jsonString += c;
- }
- }
-
- std::string generationTime;
- try {
- generationTime = Time::now().ISO8601();
- }
- catch (...) {}
-
- std::stringstream html;
- html << "\n"
- << "\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\n"
- << "\t\n"
- << "\t\n"
- << "\t\tDocumentation\n"
- << "\t\n"
- << "\t\n"
- << "\t\n"
- << "\n";
-
- f << html.str();
-
-
- /*
- for (const auto& p : _keyLua) {
- html << "\t\t\n"
- << "\t\t\t| " << std::to_string(p.first) << " | \n"
- << "\t\t\t" << p.second.first << " | \n"
- << "\t\t\t" << (p.second.second ? "Yes" : "No") << " | \n"
- << "\t\t
\n";
- }*/
- }
- else {
- throw ghoul::RuntimeError(
- "Unsupported keyboard documentation type '" + type + "'",
- "InteractionHandler"
- );
- }
+ return jsonString;
}
+
+//void InteractionHandler::writeKeyboardDocumentation(const std::string& type,
+// const std::string& file)
+//{
+// if (type == "text") {
+// std::ofstream f;
+// f.exceptions(~std::ofstream::goodbit);
+// f.open(absPath(file));
+//
+// for (const auto& p : _keyLua) {
+// std::string remoteScriptingInfo;
+// bool remoteScripting = p.second.synchronization;
+//
+// if (!remoteScripting) {
+// remoteScriptingInfo = " (LOCAL)";
+// }
+// f << std::to_string(p.first) << ": "
+// << p.second.command << remoteScriptingInfo << '\n'
+// << p.second.documentation << '\n';
+// }
+// }
+// else if (type == "html") {
+// std::ofstream f;
+// f.exceptions(~std::ofstream::goodbit);
+// f.open(absPath(file));
+//
+// std::ifstream handlebarsInput(absPath(HandlebarsFilename));
+// std::ifstream jsInput(absPath(JsFilename));
+//
+// std::string jsContent;
+// std::back_insert_iterator jsInserter(jsContent);
+//
+// std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
+// std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
+//
+// std::ifstream bootstrapInput(absPath(BootstrapFilename));
+// std::ifstream cssInput(absPath(CssFilename));
+//
+// std::string cssContent;
+// std::back_insert_iterator cssInserter(cssContent);
+//
+// std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
+// std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
+//
+// std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
+// std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
+// std::istreambuf_iterator{} };
+//
+// std::ifstream keybindingTemplateInput(absPath(KeybindingTemplateFilename));
+// std::string keybindingTemplateContent{ std::istreambuf_iterator{keybindingTemplateInput},
+// std::istreambuf_iterator{} };
+//
+// std::stringstream json;
+// json << "[";
+// bool first = true;
+// for (const auto& p : _keyLua) {
+// if (!first) {
+// json << ",";
+// }
+// first = false;
+// json << "{";
+// json << "\"key\": \"" << std::to_string(p.first) << "\",";
+// json << "\"script\": \"" << p.second.command << "\",";
+// json << "\"remoteScripting\": " << (p.second.synchronization ? "true," : "false,");
+// json << "\"documentation\": \"" << p.second.documentation << "\"";
+// json << "}";
+// }
+// json << "]";
+//
+// std::string jsonString = "";
+// for (const char& c : json.str()) {
+// if (c == '\'') {
+// jsonString += "\\'";
+// } else {
+// jsonString += c;
+// }
+// }
+//
+// std::string generationTime;
+// try {
+// generationTime = Time::now().ISO8601();
+// }
+// catch (...) {}
+//
+// std::stringstream html;
+// html << "\n"
+// << "\n"
+// << "\t\n"
+// << "\t\t\n"
+// << "\t\t\n"
+// << "\t\n"
+// << "\t\n"
+// << "\t\tDocumentation\n"
+// << "\t\n"
+// << "\t\n"
+// << "\t\n"
+// << "\n";
+//
+// f << html.str();
+//
+//
+// /*
+// for (const auto& p : _keyLua) {
+// html << "\t\t\n"
+// << "\t\t\t| " << std::to_string(p.first) << " | \n"
+// << "\t\t\t" << p.second.first << " | \n"
+// << "\t\t\t" << (p.second.second ? "Yes" : "No") << " | \n"
+// << "\t\t
\n";
+// }*/
+// }
+// else {
+// throw ghoul::RuntimeError(
+// "Unsupported keyboard documentation type '" + type + "'",
+// "InteractionHandler"
+// );
+// }
+//}
scripting::LuaLibrary InteractionHandler::luaLibrary() {
return{
diff --git a/src/util/documented.cpp b/src/util/documented.cpp
new file mode 100644
index 0000000000..2fd79dcd9c
--- /dev/null
+++ b/src/util/documented.cpp
@@ -0,0 +1,136 @@
+/*****************************************************************************************
+ * *
+ * OpenSpace *
+ * *
+ * Copyright (c) 2014-2017 *
+ * *
+ * 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
+
+#include
+#include
+
+#include
+#include
+
+#include
+
+namespace {
+ const char* HandlebarsFilename = "${OPENSPACE_DATA}/web/common/handlebars-v4.0.5.js";
+ const char* BootstrapFilename = "${OPENSPACE_DATA}/web/common/bootstrap.min.css";
+ const char* CssFilename = "${OPENSPACE_DATA}/web/common/style.css";
+} // namespace
+
+namespace openspace {
+
+Documented::Documented(std::string name,
+ std::string jsonName,
+ std::vector handlebarTemplates,
+ std::string javascriptFilename)
+ : _name(std::move(name))
+ , _jsonName(std::move(jsonName))
+ , _handlebarTemplates(std::move(handlebarTemplates))
+ , _javascriptFile(std::move(javascriptFilename))
+{
+ ghoul_precondition(!_name.empty(), "name must not be empty");
+ ghoul_precondition(!_jsonName.empty(), "jsonName must not be empty");
+ ghoul_precondition(
+ !_handlebarTemplates.empty(),
+ "handlebarTemplates must not be empty"
+ );
+ ghoul_precondition(!_javascriptFile.empty(), "javascriptFilename must not be empty");
+}
+
+void Documented::writeDocumentation(const std::string& filename) {
+ std::ifstream handlebarsInput(absPath(HandlebarsFilename));
+ std::ifstream jsInput(absPath(_javascriptFile));
+
+ std::string jsContent;
+ std::back_insert_iterator jsInserter(jsContent);
+
+ std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
+ std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
+
+ std::ifstream bootstrapInput(absPath(BootstrapFilename));
+ std::ifstream cssInput(absPath(CssFilename));
+
+ std::string cssContent;
+ std::back_insert_iterator cssInserter(cssContent);
+
+ std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
+ std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
+
+ std::ofstream file;
+ file.exceptions(~std::ofstream::goodbit);
+ file.open(filename);
+
+ std::string json = generateJson();
+ // We probably should escape backslashes here?
+
+ file << "" << '\n'
+ << "" << '\n'
+ << "\t" << "" << '\n';
+
+ for (const HandlebarTemplate& t : _handlebarTemplates) {
+ const char* Type = "text/x-handlebars-template";
+ file << "\t\t"
+ << "" << '\n';
+ }
+
+ const std::string Version =
+ "[" +
+ std::to_string(OPENSPACE_VERSION_MAJOR) + "," +
+ std::to_string(OPENSPACE_VERSION_MINOR) + "," +
+ std::to_string(OPENSPACE_VERSION_PATCH) +
+ "]";
+
+ std::string generationTime;
+ try {
+ generationTime = Time::now().ISO8601();
+ }
+ catch (...) {}
+
+ file
+ << "\t" << "" << '\n'
+ << "\t" << "" << '\n'
+ << "\t\t" << "" << _name << "" << '\n'
+ << "\t" << "" << '\n'
+ << "\t" << "" << '\n'
+ << "\t" << "" << '\n'
+ << "" << '\n';
+}
+
+} // namespace openspace
From 7d5a53fb5eba04ff6e49ec581d1925a4c8fa13ad Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Wed, 10 May 2017 09:18:29 -0400
Subject: [PATCH 08/23] Update SGCT
---
ext/sgct | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ext/sgct b/ext/sgct
index 9a1a7ab821..55e6eb877d 160000
--- a/ext/sgct
+++ b/ext/sgct
@@ -1 +1 @@
-Subproject commit 9a1a7ab8219a1ffc728f8f883ab0c2dfa8bbf2ab
+Subproject commit 55e6eb877d8fc02d3e3851e94fc5417a5b856217
From 1d024dfff3c9e1dfe7caab24d6f9efd462c49800 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Wed, 10 May 2017 15:39:42 -0400
Subject: [PATCH 09/23] Use correct variable for Sun transformation
---
data/scene/sun/sun.mod | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/data/scene/sun/sun.mod b/data/scene/sun/sun.mod
index 6905d9de89..11b0e1516d 100644
--- a/data/scene/sun/sun.mod
+++ b/data/scene/sun/sun.mod
@@ -30,7 +30,7 @@ return {
},
PerformShading = false,
},
- Transformation = {
+ Transform = {
Translation = {
Type = "SpiceTranslation",
Body = "SUN",
@@ -56,7 +56,7 @@ return {
Texture = "textures/sun-glare.png",
BlendMode = "Additive"
},
- Transformation = {
+ Transform = {
Translation = {
Type = "SpiceTranslation",
Body = "SUN",
From d597750398194b5e41c7bf2bb76b9e7778d4cc15 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Thu, 11 May 2017 13:56:06 -0400
Subject: [PATCH 10/23] Some more refactoring of the documentation feature
---
data/web/properties/main.hbs | 1 -
data/web/properties/script.js | 2 +-
.../documentation/documentationengine.h | 19 +-
.../interaction/interactionhandler.h | 3 +-
include/openspace/scene/scene.h | 13 +-
include/openspace/scripting/scriptengine.h | 10 +-
include/openspace/util/documented.h | 5 +-
include/openspace/util/factorymanager.h | 18 +-
modules/galaxy/rendering/galaxyraycaster.h | 2 +-
.../rendering/kameleonvolumeraycaster.h | 2 +-
.../rendering/multiresvolumeraycaster.h | 2 +-
.../toyvolume/rendering/toyvolumeraycaster.h | 2 +-
openspace.cfg | 31 +-
src/documentation/documentationengine.cpp | 259 +++++++++--------
src/engine/configurationmanager_doc.inl | 140 ++-------
src/engine/openspaceengine.cpp | 117 ++------
src/interaction/interactionhandler.cpp | 127 ---------
src/scene/scene.cpp | 223 +++++----------
src/scripting/scriptengine.cpp | 265 +++---------------
src/util/factorymanager.cpp | 169 +++--------
20 files changed, 388 insertions(+), 1022 deletions(-)
diff --git a/data/web/properties/main.hbs b/data/web/properties/main.hbs
index fc56bca0b8..6af37752cd 100644
--- a/data/web/properties/main.hbs
+++ b/data/web/properties/main.hbs
@@ -18,7 +18,6 @@
OpenSpace Scene Properties
Version: {{version.[0]}}.{{version.[1]}}.{{version.[2]}}
-
Scene name: {{sceneFilename}}
Generated: {{generationTime}}
{{#each propertyOwners}}
diff --git a/data/web/properties/script.js b/data/web/properties/script.js
index f7302a5e0b..52b8a468fa 100644
--- a/data/web/properties/script.js
+++ b/data/web/properties/script.js
@@ -53,7 +53,7 @@ window.onload = function () {
var data = {
propertyOwners: propertyOwners,
version: version,
- sceneFilename: sceneFilename,
+ // sceneFilename: sceneFilename,
generationTime: generationTime
}
diff --git a/include/openspace/documentation/documentationengine.h b/include/openspace/documentation/documentationengine.h
index 41400602fb..444d164c6a 100644
--- a/include/openspace/documentation/documentationengine.h
+++ b/include/openspace/documentation/documentationengine.h
@@ -27,6 +27,8 @@
#include
+#include
+
#include
#include
@@ -38,7 +40,9 @@ namespace documentation {
* produced in the application an write them out as a documentation file for human
* consumption.
*/
-class DocumentationEngine : public ghoul::Singleton {
+class DocumentationEngine : public ghoul::Singleton
+ , public Documented
+{
public:
/**
* This exception is thrown by the addDocumentation method if a provided Documentation
@@ -57,16 +61,7 @@ public:
Documentation documentation;
};
- /**
- * Write the collected Documentation%s to disk at the \p filename in the specified
- * \p type. A new file is created and silently overwritten in the location that
- * \p filename is pointed to.
- * \param filename The file that is to be created containing all the Documentation
- * information.
- * \param type The type of documentation that is written. Currently allowed values are
- * \c text and \c html
- */
- void writeDocumentation(const std::string& filename, const std::string& type);
+ DocumentationEngine();
/**
* Adds the \p documentation to the list of Documentation%s that are written to a
@@ -90,6 +85,8 @@ public:
static DocumentationEngine& ref();
private:
+ std::string generateJson() const override;
+
/// The list of all Documentation%s that are stored by the DocumentationEngine
std::vector _documentations;
diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h
index dc68272217..576b9cf01a 100644
--- a/include/openspace/interaction/interactionhandler.h
+++ b/include/openspace/interaction/interactionhandler.h
@@ -121,7 +121,6 @@ public:
void saveCameraStateToFile(const std::string& filepath);
void restoreCameraStateFromFile(const std::string& filepath);
-// void writeKeyboardDocumentation(const std::string& type, const std::string& file);
private:
using Synchronized = ghoul::Boolean;
@@ -132,7 +131,7 @@ private:
std::string documentation;
};
- std::string generateJson() const override;
+ std::string generateJson() const override;
void setInteractionMode(std::shared_ptr interactionMode);
diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h
index 76f87a3e41..9a1aecbd7d 100644
--- a/include/openspace/scene/scene.h
+++ b/include/openspace/scene/scene.h
@@ -31,6 +31,7 @@
#include
#include
+#include
#include
#include
#include
@@ -45,7 +46,7 @@ class SceneGraphNode;
// Notifications:
// SceneGraphFinishedLoading
-class Scene {
+class Scene : public Documented {
public:
using UpdateDependencies = ghoul::Boolean;
@@ -61,7 +62,6 @@ public:
// constructors & destructor
Scene();
- ~Scene();
/**
* Initalizes the SceneGraph
@@ -135,11 +135,6 @@ public:
*/
const std::map& nodesByName() const;
- /**
- * Output property documentation to a file.
- */
- void writePropertyDocumentation(const std::string& filename, const std::string& type, const std::string& sceneFilename);
-
/**
* Returns the Lua library that contains all Lua functions available to change the
* scene graph. The functions contained are
@@ -152,7 +147,9 @@ public:
static documentation::Documentation Documentation();
-private:
+private:
+ std::string generateJson() const override;
+
void sortTopologically();
std::unique_ptr _root;
diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h
index b28a8fb2ba..280b4fa588 100644
--- a/include/openspace/scripting/scriptengine.h
+++ b/include/openspace/scripting/scriptengine.h
@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___SCRIPTENGINE___H__
#include
+#include
#include
#include
@@ -50,9 +51,12 @@ namespace scripting {
* openspace namespac prefix in Lua. The same functions can be exposed to
* other Lua states by passing them to the #initializeLuaState method.
*/
-class ScriptEngine : public Syncable {
+class ScriptEngine : public Syncable, public Documented {
public:
using RemoteScripting = ghoul::Boolean;
+
+ ScriptEngine();
+
/**
* Initializes the internal Lua state and registers a common set of library functions
* \throw LuaRuntimeException If the creation of the new Lua state fails
@@ -73,8 +77,6 @@ public:
bool runScript(const std::string& script);
bool runScriptFile(const std::string& filename);
- void writeDocumentation(const std::string& filename, const std::string& type) const;
-
bool writeLog(const std::string& script);
virtual void presync(bool isMaster);
@@ -106,6 +108,8 @@ private:
void addBaseLibrary();
void remapPrintFunction();
+ std::string generateJson() const override;
+
ghoul::lua::LuaState _state;
std::set _registeredLibraries;
diff --git a/include/openspace/util/documented.h b/include/openspace/util/documented.h
index c6cfd16445..7f9b92a28f 100644
--- a/include/openspace/util/documented.h
+++ b/include/openspace/util/documented.h
@@ -37,8 +37,11 @@ public:
std::string filename;
};
- Documented(std::string name, std::string jsonName, std::vector handlebarTemplates,
+ Documented(std::string name, std::string jsonName,
+ std::vector handlebarTemplates,
std::string javascriptFilename);
+
+ virtual ~Documented() = default;
void writeDocumentation(const std::string& filename);
diff --git a/include/openspace/util/factorymanager.h b/include/openspace/util/factorymanager.h
index 7b815ca065..997976e461 100644
--- a/include/openspace/util/factorymanager.h
+++ b/include/openspace/util/factorymanager.h
@@ -25,6 +25,8 @@
#ifndef __OPENSPACE_CORE___FACTORYMANAGER___H__
#define __OPENSPACE_CORE___FACTORYMANAGER___H__
+#include
+
#include
#include
@@ -37,7 +39,7 @@ namespace openspace {
* them available through the #addFactory and #factory methods. Each
* ghoul::TemplateFactory can only be added once and can be accessed by its type.
*/
-class FactoryManager {
+class FactoryManager : public Documented {
public:
/// This exception is thrown if the ghoul::TemplateFactory could not be found in the
/// #factory method
@@ -55,6 +57,8 @@ public:
/// The type describing the ghoul::TemplateFactory that could not be found
std::string type;
};
+
+ FactoryManager();
/**
* Static initializer that initializes the static member. This needs to be done before
@@ -104,17 +108,9 @@ public:
template
ghoul::TemplateFactory* factory() const;
- /**
- * Writes a documentation for the FactoryMananger that contains all of the registered
- * factories and for each factory all registered class names.
- * \param file The file to which the documentation will be written
- * \param type The type of documentation that will be written
- * \pre \p file must not be empty
- * \pre \p type must not be empty
- */
- void writeDocumentation(const std::string& file, const std::string& type);
-
private:
+ std::string generateJson() const override;
+
/// Singleton member for the Factory Manager
static FactoryManager* _manager;
diff --git a/modules/galaxy/rendering/galaxyraycaster.h b/modules/galaxy/rendering/galaxyraycaster.h
index dcd34063e6..b65e08eff6 100644
--- a/modules/galaxy/rendering/galaxyraycaster.h
+++ b/modules/galaxy/rendering/galaxyraycaster.h
@@ -44,7 +44,7 @@ namespace ghoul {
namespace openspace {
-class RenderData;
+struct RenderData;
class RaycastData;
class GalaxyRaycaster : public VolumeRaycaster {
diff --git a/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h b/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h
index 95f4ecb656..d45590d2a7 100644
--- a/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h
+++ b/modules/kameleonvolume/rendering/kameleonvolumeraycaster.h
@@ -49,7 +49,7 @@ namespace ghoul {
namespace openspace {
-class RenderData;
+struct RenderData;
class RaycastData;
class KameleonVolumeRaycaster : public VolumeRaycaster {
diff --git a/modules/multiresvolume/rendering/multiresvolumeraycaster.h b/modules/multiresvolume/rendering/multiresvolumeraycaster.h
index c08a75e0c4..3c598ffd84 100644
--- a/modules/multiresvolume/rendering/multiresvolumeraycaster.h
+++ b/modules/multiresvolume/rendering/multiresvolumeraycaster.h
@@ -48,7 +48,7 @@ namespace ghoul {
namespace openspace {
-class RenderData;
+struct RenderData;
class RaycastData;
class MultiresVolumeRaycaster : public VolumeRaycaster {
diff --git a/modules/toyvolume/rendering/toyvolumeraycaster.h b/modules/toyvolume/rendering/toyvolumeraycaster.h
index 08569987bf..1577ede5ec 100644
--- a/modules/toyvolume/rendering/toyvolumeraycaster.h
+++ b/modules/toyvolume/rendering/toyvolumeraycaster.h
@@ -41,7 +41,7 @@ namespace ghoul {
namespace openspace {
-class RenderData;
+struct RenderData;
class RaycastData;
class ToyVolumeRaycaster : public VolumeRaycaster {
diff --git a/openspace.cfg b/openspace.cfg
index be9164e8aa..5bba443950 100644
--- a/openspace.cfg
+++ b/openspace.cfg
@@ -62,30 +62,13 @@ return {
},
CapabilitiesVerbosity = "Full"
},
- LuaDocumentation = {
- Type = "html",
- File = "${DOCUMENTATION}/LuaScripting.html"
- },
- PropertyDocumentation = {
- Type = "html",
- File = "${DOCUMENTATION}/Properties.html"
- },
- ScriptLog = {
- Type = "text",
- File = "${BASE_PATH}/ScriptLog.txt"
- },
- KeyboardShortcuts = {
- Type = "html",
- File = "${DOCUMENTATION}/KeyboardMapping.html"
- },
- Documentation = {
- Type = "html",
- File = "${DOCUMENTATION}/Documentation.html"
- },
- FactoryDocumentation = {
- Type = "html",
- File = "${DOCUMENTATION}/FactoryDocumentation.html"
- },
+ LuaDocumentation = "${DOCUMENTATION}/LuaScripting.html",
+ PropertyDocumentation = "${DOCUMENTATION}/Properties.html",
+ ScriptLog = "${BASE_PATH}/ScriptLog.txt",
+ KeyboardShortcuts = "${DOCUMENTATION}/KeyboardMapping.html",
+ Documentation = "${DOCUMENTATION}/Documentation.html",
+ FactoryDocumentation = "${DOCUMENTATION}/FactoryDocumentation.html",
+
ShutdownCountdown = 3,
-- OnScreenTextScaling = "framebuffer",
-- PerSceneCache = true,
diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp
index 2f48183dd1..7dc5b11c0b 100644
--- a/src/documentation/documentationengine.cpp
+++ b/src/documentation/documentationengine.cpp
@@ -61,6 +61,19 @@ DocumentationEngine::DuplicateDocumentationException::DuplicateDocumentationExce
, documentation(std::move(documentation))
{}
+DocumentationEngine::DocumentationEngine()
+ : Documented(
+ "Documentation",
+ "documentation",
+ {
+ { "mainTemplate", MainTemplateFilename },
+ { "documentationTemplate", DocumentationTemplateFilename }
+ },
+ JsFilename
+ )
+{}
+
+
DocumentationEngine& DocumentationEngine::ref() {
if (_instance == nullptr) {
_instance = new DocumentationEngine;
@@ -256,126 +269,152 @@ std::string generateHtmlDocumentation(const Documentation& d) {
return html.str();
}
-void DocumentationEngine::writeDocumentation(const std::string& f, const std::string& t) {
- if (t == "text") {
- std::ofstream file;
- file.exceptions(~std::ofstream::goodbit);
- file.open(f);
+std::string DocumentationEngine::generateJson() const {
+ std::stringstream json;
+ json << "[";
- for (const Documentation& d : _documentations) {
- int indent = 0;
- file << documentation::generateTextDocumentation(d, indent) << "\n\n";
+ for (const Documentation& d : _documentations) {
+ json << generateJsonDocumentation(d);
+ if (&d != &_documentations.back()) {
+ json << ", ";
}
}
- else if (t == "html") {
- std::ifstream handlebarsInput(absPath(HandlebarsFilename));
- std::ifstream jsInput(absPath(JsFilename));
- std::string jsContent;
- std::back_insert_iterator jsInserter(jsContent);
+ json << "]";
- std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
- std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
-
- std::ifstream bootstrapInput(absPath(BootstrapFilename));
- std::ifstream cssInput(absPath(CssFilename));
-
- std::string cssContent;
- std::back_insert_iterator cssInserter(cssContent);
-
- std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
- std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
-
- std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
- std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
- std::istreambuf_iterator{}};
-
- std::ifstream documentationTemplateInput(absPath(DocumentationTemplateFilename));
- std::string documentationTemplateContent{ std::istreambuf_iterator{documentationTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ofstream file;
- file.exceptions(~std::ofstream::goodbit);
- file.open(f);
-
- std::stringstream json;
- json << "[";
-
- for (const Documentation& d : _documentations) {
- json << generateJsonDocumentation(d);
- if (&d != &_documentations.back()) {
- json << ", ";
- }
+ std::string jsonString = "";
+ for (const char& c : json.str()) {
+ if (c == '\'') {
+ jsonString += "\\'";
}
-
- json << "]";
-
- std::string jsonString = "";
- for (const char& c : json.str()) {
- if (c == '\'') {
- jsonString += "\\'";
- } else {
- jsonString += c;
- }
+ else {
+ jsonString += c;
}
-
- std::stringstream html;
- html << "\n"
- << "\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\n"
- << "\t\n"
- << "\t\n"
- << "\t\tDocumentation\n"
- << "\t\n"
- << "\t\n"
- << "\t\n"
- << "\n";
-
- file << html.str();
-
-/*
- Use this for generating documentation in raw html:
-
- html << "\n"
- << "\tDocumentation\n\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\t| Name | \n"
- << "\t\t
\n"
- << "\t\t\n"
- << "\t\t\t| Key | \n"
- << "\t\t\tOptional | \n"
- << "\t\t\tType | \n"
- << "\t\t\tRestrictions | \n"
- << "\t\t\tDocumentation | \n"
- << "\t\t
\n"
- << "\t\n"
- << "\t\n";
-
- for (const Documentation& d : _documentations) {
- html << generateHtmlDocumentation(d);
-
- html << "\t |
\n";
- }
-
- html << "\t\n"
- << "
\n";
-*/
}
+
+ return jsonString;
}
+//void DocumentationEngine::writeDocumentation(const std::string& f, const std::string& t) {
+// if (t == "text") {
+// std::ofstream file;
+// file.exceptions(~std::ofstream::goodbit);
+// file.open(f);
+//
+// for (const Documentation& d : _documentations) {
+// int indent = 0;
+// file << documentation::generateTextDocumentation(d, indent) << "\n\n";
+// }
+// }
+// else if (t == "html") {
+// std::ifstream handlebarsInput(absPath(HandlebarsFilename));
+// std::ifstream jsInput(absPath(JsFilename));
+//
+// std::string jsContent;
+// std::back_insert_iterator jsInserter(jsContent);
+//
+// std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
+// std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
+//
+// std::ifstream bootstrapInput(absPath(BootstrapFilename));
+// std::ifstream cssInput(absPath(CssFilename));
+//
+// std::string cssContent;
+// std::back_insert_iterator cssInserter(cssContent);
+//
+// std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
+// std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
+//
+// std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
+// std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
+// std::istreambuf_iterator{}};
+//
+// std::ifstream documentationTemplateInput(absPath(DocumentationTemplateFilename));
+// std::string documentationTemplateContent{ std::istreambuf_iterator{documentationTemplateInput},
+// std::istreambuf_iterator{} };
+//
+// std::ofstream file;
+// file.exceptions(~std::ofstream::goodbit);
+// file.open(f);
+//
+// std::stringstream json;
+// json << "[";
+//
+// for (const Documentation& d : _documentations) {
+// json << generateJsonDocumentation(d);
+// if (&d != &_documentations.back()) {
+// json << ", ";
+// }
+// }
+//
+// json << "]";
+//
+// std::string jsonString = "";
+// for (const char& c : json.str()) {
+// if (c == '\'') {
+// jsonString += "\\'";
+// } else {
+// jsonString += c;
+// }
+// }
+//
+// std::stringstream html;
+// html << "\n"
+// << "\n"
+// << "\t\n"
+// << "\t\t\n"
+// << "\t\t\n"
+// << "\t\n"
+// << "\t\n"
+// << "\t\tDocumentation\n"
+// << "\t\n"
+// << "\t\n"
+// << "\t\n"
+// << "\n";
+//
+// file << html.str();
+//
+///*
+// Use this for generating documentation in raw html:
+//
+// html << "\n"
+// << "\tDocumentation\n\n"
+// << "\t\n"
+// << "\t\t\n"
+// << "\t\t\t| Name | \n"
+// << "\t\t
\n"
+// << "\t\t\n"
+// << "\t\t\t| Key | \n"
+// << "\t\t\tOptional | \n"
+// << "\t\t\tType | \n"
+// << "\t\t\tRestrictions | \n"
+// << "\t\t\tDocumentation | \n"
+// << "\t\t
\n"
+// << "\t\n"
+// << "\t\n";
+//
+// for (const Documentation& d : _documentations) {
+// html << generateHtmlDocumentation(d);
+//
+// html << "\t |
\n";
+// }
+//
+// html << "\t\n"
+// << "
\n";
+//*/
+// }
+//}
+
void DocumentationEngine::addDocumentation(Documentation doc) {
for (const DocumentationEntry& e : doc.entries) {
ghoul_assert(
diff --git a/src/engine/configurationmanager_doc.inl b/src/engine/configurationmanager_doc.inl
index a00228b045..e47a9d9c39 100644
--- a/src/engine/configurationmanager_doc.inl
+++ b/src/engine/configurationmanager_doc.inl
@@ -141,143 +141,49 @@ documentation::Documentation ConfigurationManager::Documentation() {
},
{
ConfigurationManager::KeyLuaDocumentation,
- new TableVerifier({
- {
- ConfigurationManager::PartType,
- new StringInListVerifier(
- // List from ScriptEngine::writeDocumentation
- { "text", "html" }
- ),
- "The type of documentation that will be written."
- },
- {
- ConfigurationManager::PartFile,
- new StringVerifier,
- "The filename that will be created on startup containing the "
- "documentation of available Lua functions. Any existing file "
- "will be silently overwritten."
- }
- }),
- "Descriptions of whether and where to create a documentation file that "
- "describes the available Lua functions that can be executed in scene "
- "files or per console.",
+ new StringVerifier,
+ "The filename that will be created on startup containing the documentation "
+ "of available Lua functions that can be executed in scene files or per "
+ "console. Any existing file will be silently overwritten.",
Optional::Yes
},
{
ConfigurationManager::KeyPropertyDocumentation,
- new TableVerifier({
- {
- ConfigurationManager::PartType,
- new StringInListVerifier(
- // List taken from Scene::writePropertyDocumentation
- { "text", "html" }
- ),
- "The type of property documentation file that is created."
- },
- {
- ConfigurationManager::PartFile,
- new StringVerifier,
- "The file that will be created on startup containing a list of "
- "all properties in the scene. Any existing file will be silently "
- "overwritten."
- }
- }),
- "Descriptions of whether and where to create a list of all properties "
- "that were created in the current scene.",
+ new StringVerifier,
+ "The file that will be created on startup containing a list of all "
+ "properties in the scene. Any existing file will be silently overwritten.",
Optional::Yes
},
{
ConfigurationManager::KeyScriptLog,
- new TableVerifier({
- {
- ConfigurationManager::PartType,
- new StringInListVerifier(
- // List taken from ScriptEngine::writeLog
- { "text" }
- ),
- "The type of logfile that will be created."
- },
- {
- ConfigurationManager::PartFile,
- new StringVerifier,
- "The file that will be created on startup containing the log of "
- "all Lua scripts that are executed. Any existing file (including "
- "the results from previous runs) will be silently overwritten."
- }
- }),
- "Contains a log of all Lua scripts that were executed in the last "
- "session.",
+ new StringVerifier,
+ "The file that will be created on startup containing the log of all Lua "
+ "scripts that are executed in the last session. Any existing file (including "
+ "the results from previous runs) will be silently overwritten.",
Optional::Yes
},
{
ConfigurationManager::KeyKeyboardShortcuts,
- new TableVerifier({
- {
- ConfigurationManager::PartType,
- new StringInListVerifier(
- // List from InteractionHandler::writeKeyboardDocumentation
- { "text", "html" }
- ),
- "The type of keyboard binding documentation that should be "
- "written."
- },
- {
- ConfigurationManager::PartFile,
- new StringVerifier,
- "The file that will be created on startup containing the list of "
- "all keyboard bindings with their respective Lua scripts. Any "
- "previous file in this location will be silently overritten."
- }
- }),
- "Contains the collection of all keyboard shortcuts that were collected "
- "during startup. For each key, it mentions which scripts will be "
- "executed in the current session.",
+ new StringVerifier,
+ "The file that will be created on startup containing the list of all "
+ "keyboard bindings with their respective Lua scripts. For each key, it "
+ "mentions which scripts will be executed in the current session.",
Optional::Yes
},
{
ConfigurationManager::KeyDocumentation,
- new TableVerifier({
- {
- ConfigurationManager::PartType,
- new StringInListVerifier(
- // List from DocumentationEngine::writeDocumentation
- { "text", "html" }
- ),
- "The type of documentation that should be written."
- },
- {
- ConfigurationManager::PartFile,
- new StringVerifier,
- "The file that will be created on startup containing this "
- "documentation. Any previous file in this location will be silently "
- "overritten."
- }
- }),
- "This defines the location and type of this documentation file.",
+ new StringVerifier,
+ "The file that will be created on startup containing this documentation. Any "
+ "previous file in this location will be silently overwritten.",
Optional::Yes
},
{
ConfigurationManager::KeyFactoryDocumentation,
- new TableVerifier({
- {
- ConfigurationManager::PartType,
- new StringInListVerifier(
- // List from FactoryManager::writeDocumentation
- { "text", "html" }
- ),
- "The type of documentation that should be written."
- },
- {
- ConfigurationManager::PartFile,
- new StringVerifier,
- "The file that will be created on startup containing the factory "
- "documentation. Any previous file in this location will be silently "
- "overritten."
- }
- }),
- "This defines the location and type of the factory documentation file, which "
- "shows the different types of objects that can be created in the current "
- "application configuration.",
+ new StringVerifier,
+ "The file that will be created on startup containing the factory "
+ "documentation which shows the different types of objects that can be "
+ "created in the current application configuration. Any previous file in this "
+ "location will be silently overritten.",
Optional::Yes
},
{
diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp
index d2bdea1456..9a96c49899 100644
--- a/src/engine/openspaceengine.cpp
+++ b/src/engine/openspaceengine.cpp
@@ -589,44 +589,21 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) {
}
// Write keyboard documentation.
- {
- const std::string KeyboardShortcutsType =
- ConfigurationManager::KeyKeyboardShortcuts + "." +
- ConfigurationManager::PartType;
-
- const std::string KeyboardShortcutsFile =
- ConfigurationManager::KeyKeyboardShortcuts + "." +
- ConfigurationManager::PartFile;
-
- std::string type, file;
- const bool hasType = configurationManager().getValue(KeyboardShortcutsType, type);
- const bool hasFile = configurationManager().getValue(KeyboardShortcutsFile, file);
-
- if (hasType && hasFile) {
- file = absPath(file);
- interactionHandler().writeDocumentation(file);
-// interactionHandler().writeKeyboardDocumentation(type, file);
- }
+ if (configurationManager().hasKey(ConfigurationManager::KeyKeyboardShortcuts)) {
+ interactionHandler().writeDocumentation(
+ absPath(configurationManager().value(
+ ConfigurationManager::KeyKeyboardShortcuts
+ ))
+ );
}
// If a PropertyDocumentationFile was specified, generate it now.
- {
- const std::string KeyPropertyDocumentationType =
- ConfigurationManager::KeyPropertyDocumentation + '.' +
- ConfigurationManager::PartType;
-
- const std::string KeyPropertyDocumentationFile =
- ConfigurationManager::KeyPropertyDocumentation + '.' +
- ConfigurationManager::PartFile;
-
- std::string type, file;
- const bool hasType = configurationManager().getValue(KeyPropertyDocumentationType, type);
- const bool hasFile = configurationManager().getValue(KeyPropertyDocumentationFile, file);
-
- if (hasType && hasFile) {
- file = absPath(file);
- scene->writePropertyDocumentation(file, type, scenePath);
- }
+ if (configurationManager().hasKey(ConfigurationManager::KeyPropertyDocumentation)) {
+ scene->writeDocumentation(
+ absPath(configurationManager().value(
+ ConfigurationManager::KeyPropertyDocumentation
+ ))
+ );
}
_syncEngine->addSyncables(Time::ref().getSyncables());
@@ -647,72 +624,30 @@ void OpenSpaceEngine::deinitialize() {
void OpenSpaceEngine::writeDocumentation() {
// If a LuaDocumentationFile was specified, generate it now
- const std::string LuaDocumentationType =
- ConfigurationManager::KeyLuaDocumentation + "." + ConfigurationManager::PartType;
- const std::string LuaDocumentationFile =
- ConfigurationManager::KeyLuaDocumentation + "." + ConfigurationManager::PartFile;
-
- const bool hasLuaDocType = configurationManager().hasKey(LuaDocumentationType);
- const bool hasLuaDocFile = configurationManager().hasKey(LuaDocumentationFile);
- if (hasLuaDocType && hasLuaDocFile) {
- std::string luaDocumentationType = configurationManager().value(
- LuaDocumentationType
- );
- std::string luaDocumentationFile = configurationManager().value(
- LuaDocumentationFile
- );
-
+ if (configurationManager().hasKey(ConfigurationManager::KeyLuaDocumentation)) {
_scriptEngine->writeDocumentation(
- absPath(luaDocumentationFile),
- luaDocumentationType
+ absPath(configurationManager().value(
+ ConfigurationManager::KeyLuaDocumentation
+ ))
);
}
// If a general documentation was specified, generate it now
- const std::string DocumentationType =
- ConfigurationManager::KeyDocumentation + '.' + ConfigurationManager::PartType;
- const std::string DocumentationFile =
- ConfigurationManager::KeyDocumentation + '.' + ConfigurationManager::PartFile;
-
- const bool hasDocumentationType = configurationManager().hasKey(DocumentationType);
- const bool hasDocumentationFile = configurationManager().hasKey(DocumentationFile);
- if (hasDocumentationType && hasDocumentationFile) {
- std::string documentationType = configurationManager().value(
- DocumentationType
- );
- std::string documentationFile = configurationManager().value(
- DocumentationFile
- );
-
+ if (configurationManager().hasKey(ConfigurationManager::KeyDocumentation)) {
DocEng.writeDocumentation(
- absPath(documentationFile),
- documentationType
+ absPath(configurationManager().value(
+ ConfigurationManager::KeyDocumentation
+ ))
);
}
- const std::string FactoryDocumentationType =
- ConfigurationManager::KeyFactoryDocumentation + '.' +
- ConfigurationManager::PartType;
-
- const std::string FactoryDocumentationFile =
- ConfigurationManager::KeyFactoryDocumentation + '.' +
- ConfigurationManager::PartFile;
-
- bool hasFactoryDocumentationType = configurationManager().hasKey(
- FactoryDocumentationType
- );
- bool hasFactoryDocumentationFile = configurationManager().hasKey(
- FactoryDocumentationFile
- );
- if (hasFactoryDocumentationType && hasFactoryDocumentationFile) {
- std::string type = configurationManager().value(
- FactoryDocumentationType
+ // If a factory documentation was specified, generate it now
+ if (configurationManager().hasKey(ConfigurationManager::KeyFactoryDocumentation)) {
+ FactoryManager::ref().writeDocumentation(
+ absPath(configurationManager().value(
+ ConfigurationManager::KeyFactoryDocumentation
+ ))
);
- std::string file = configurationManager().value(
- FactoryDocumentationFile
- );
-
- FactoryManager::ref().writeDocumentation(absPath(file), type);
}
}
diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp
index e87dabb564..1a55b2eca9 100644
--- a/src/interaction/interactionhandler.cpp
+++ b/src/interaction/interactionhandler.cpp
@@ -472,133 +472,6 @@ std::string InteractionHandler::generateJson() const {
return jsonString;
}
-//void InteractionHandler::writeKeyboardDocumentation(const std::string& type,
-// const std::string& file)
-//{
-// if (type == "text") {
-// std::ofstream f;
-// f.exceptions(~std::ofstream::goodbit);
-// f.open(absPath(file));
-//
-// for (const auto& p : _keyLua) {
-// std::string remoteScriptingInfo;
-// bool remoteScripting = p.second.synchronization;
-//
-// if (!remoteScripting) {
-// remoteScriptingInfo = " (LOCAL)";
-// }
-// f << std::to_string(p.first) << ": "
-// << p.second.command << remoteScriptingInfo << '\n'
-// << p.second.documentation << '\n';
-// }
-// }
-// else if (type == "html") {
-// std::ofstream f;
-// f.exceptions(~std::ofstream::goodbit);
-// f.open(absPath(file));
-//
-// std::ifstream handlebarsInput(absPath(HandlebarsFilename));
-// std::ifstream jsInput(absPath(JsFilename));
-//
-// std::string jsContent;
-// std::back_insert_iterator jsInserter(jsContent);
-//
-// std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
-// std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
-//
-// std::ifstream bootstrapInput(absPath(BootstrapFilename));
-// std::ifstream cssInput(absPath(CssFilename));
-//
-// std::string cssContent;
-// std::back_insert_iterator cssInserter(cssContent);
-//
-// std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
-// std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
-//
-// std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
-// std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
-// std::istreambuf_iterator{} };
-//
-// std::ifstream keybindingTemplateInput(absPath(KeybindingTemplateFilename));
-// std::string keybindingTemplateContent{ std::istreambuf_iterator{keybindingTemplateInput},
-// std::istreambuf_iterator{} };
-//
-// std::stringstream json;
-// json << "[";
-// bool first = true;
-// for (const auto& p : _keyLua) {
-// if (!first) {
-// json << ",";
-// }
-// first = false;
-// json << "{";
-// json << "\"key\": \"" << std::to_string(p.first) << "\",";
-// json << "\"script\": \"" << p.second.command << "\",";
-// json << "\"remoteScripting\": " << (p.second.synchronization ? "true," : "false,");
-// json << "\"documentation\": \"" << p.second.documentation << "\"";
-// json << "}";
-// }
-// json << "]";
-//
-// std::string jsonString = "";
-// for (const char& c : json.str()) {
-// if (c == '\'') {
-// jsonString += "\\'";
-// } else {
-// jsonString += c;
-// }
-// }
-//
-// std::string generationTime;
-// try {
-// generationTime = Time::now().ISO8601();
-// }
-// catch (...) {}
-//
-// std::stringstream html;
-// html << "\n"
-// << "\n"
-// << "\t\n"
-// << "\t\t\n"
-// << "\t\t\n"
-// << "\t\n"
-// << "\t\n"
-// << "\t\tDocumentation\n"
-// << "\t\n"
-// << "\t\n"
-// << "\t\n"
-// << "\n";
-//
-// f << html.str();
-//
-//
-// /*
-// for (const auto& p : _keyLua) {
-// html << "\t\t\n"
-// << "\t\t\t| " << std::to_string(p.first) << " | \n"
-// << "\t\t\t" << p.second.first << " | \n"
-// << "\t\t\t" << (p.second.second ? "Yes" : "No") << " | \n"
-// << "\t\t
\n";
-// }*/
-// }
-// else {
-// throw ghoul::RuntimeError(
-// "Unsupported keyboard documentation type '" + type + "'",
-// "InteractionHandler"
-// );
-// }
-//}
scripting::LuaLibrary InteractionHandler::luaLibrary() {
return{
diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp
index 4778aee872..6799f75717 100644
--- a/src/scene/scene.cpp
+++ b/src/scene/scene.cpp
@@ -82,9 +82,18 @@ namespace {
namespace openspace {
-Scene::Scene() {}
-
-Scene::~Scene() {}
+Scene::Scene()
+ : Documented(
+ "Documented",
+ "propertyOwners",
+ {
+ { "mainTemplate", MainTemplateFilename },
+ { "propertyOwnerTemplate", PropertyOwnerTemplateFilename },
+ { "propertyTemplate", PropertyTemplateFilename }
+ },
+ JsFilename
+ )
+{}
void Scene::setRoot(std::unique_ptr root) {
if (_root) {
@@ -266,165 +275,71 @@ const std::vector& Scene::allSceneGraphNodes() const {
return _topologicallySortedNodes;
}
-void Scene::writePropertyDocumentation(const std::string& filename, const std::string& type, const std::string& sceneFilename) {
- LDEBUG("Writing documentation for properties");
- if (type == "text") {
- std::ofstream file;
- file.exceptions(~std::ofstream::goodbit);
- file.open(filename);
-
- using properties::Property;
- for (SceneGraphNode* node : allSceneGraphNodes()) {
- std::vector properties = node->propertiesRecursive();
- if (!properties.empty()) {
- file << node->name() << std::endl;
-
- for (Property* p : properties) {
- file << p->fullyQualifiedIdentifier() << ": " <<
- p->guiName() << std::endl;
- }
-
- file << std::endl;
- }
- }
- }
- else if (type == "html") {
- std::ofstream file;
- file.exceptions(~std::ofstream::goodbit);
- file.open(filename);
-
-
- std::ifstream handlebarsInput(absPath(HandlebarsFilename));
- std::ifstream jsInput(absPath(JsFilename));
-
- std::string jsContent;
- std::back_insert_iterator jsInserter(jsContent);
-
- std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
- std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
-
- std::ifstream bootstrapInput(absPath(BootstrapFilename));
- std::ifstream cssInput(absPath(CssFilename));
-
- std::string cssContent;
- std::back_insert_iterator cssInserter(cssContent);
-
- std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
- std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
-
- std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
- std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ifstream propertyOwnerTemplateInput(absPath(PropertyOwnerTemplateFilename));
- std::string propertyOwnerTemplateContent{ std::istreambuf_iterator{propertyOwnerTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ifstream propertyTemplateInput(absPath(PropertyTemplateFilename));
- std::string propertyTemplateContent{ std::istreambuf_iterator{propertyTemplateInput},
- std::istreambuf_iterator{} };
-
- // Create JSON
- std::function createJson =
- [&createJson](properties::PropertyOwner* owner) -> std::string
- {
- std::stringstream json;
- json << "{";
- json << "\"name\": \"" << owner->name() << "\",";
-
- json << "\"properties\": [";
- auto properties = owner->properties();
- for (properties::Property* p : properties) {
- json << "{";
- json << "\"id\": \"" << p->identifier() << "\",";
- json << "\"type\": \"" << p->className() << "\",";
- json << "\"fullyQualifiedId\": \"" << p->fullyQualifiedIdentifier() << "\",";
- json << "\"guiName\": \"" << p->guiName() << "\"";
- json << "}";
- if (p != properties.back()) {
- json << ",";
- }
- }
- json << "],";
-
- json << "\"propertyOwners\": [";
- auto propertyOwners = owner->propertySubOwners();
- for (properties::PropertyOwner* o : propertyOwners) {
- json << createJson(o);
- if (o != propertyOwners.back()) {
- json << ",";
- }
- }
- json << "]";
- json << "}";
-
- return json.str();
- };
-
-
+std::string Scene::generateJson() const {
+ std::function createJson =
+ [&createJson](properties::PropertyOwner* owner) -> std::string
+ {
std::stringstream json;
- json << "[";
- std::vector nodes = allSceneGraphNodes();
- if (!nodes.empty()) {
- json << std::accumulate(
- std::next(nodes.begin()),
- nodes.end(),
- createJson(*nodes.begin()),
- [createJson](std::string a, SceneGraphNode* n) {
- return a + "," + createJson(n);
- }
- );
- }
+ json << "{";
+ json << "\"name\": \"" << owner->name() << "\",";
- json << "]";
-
- std::string jsonString = "";
- for (const char& c : json.str()) {
- if (c == '\'') {
- jsonString += "\\'";
- } else {
- jsonString += c;
+ json << "\"properties\": [";
+ auto properties = owner->properties();
+ for (properties::Property* p : properties) {
+ json << "{";
+ json << "\"id\": \"" << p->identifier() << "\",";
+ json << "\"type\": \"" << p->className() << "\",";
+ json << "\"fullyQualifiedId\": \"" << p->fullyQualifiedIdentifier() << "\",";
+ json << "\"guiName\": \"" << p->guiName() << "\"";
+ json << "}";
+ if (p != properties.back()) {
+ json << ",";
}
}
+ json << "],";
- std::string generationTime;
- try {
- generationTime = Time::now().ISO8601();
+ json << "\"propertyOwners\": [";
+ auto propertyOwners = owner->propertySubOwners();
+ for (properties::PropertyOwner* o : propertyOwners) {
+ json << createJson(o);
+ if (o != propertyOwners.back()) {
+ json << ",";
+ }
}
- catch (...) {}
+ json << "]";
+ json << "}";
- std::stringstream html;
- html << "\n"
- << "\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\n"
- << "\t\t\n"
- << "\t\n"
- << "\t\n"
- << "\t\tDocumentation\n"
- << "\t\n"
- << "\t\n"
- << "\t\n"
- << "\n";
- file << html.str();
+ return json.str();
+ };
+
+
+ std::stringstream json;
+ json << "[";
+ std::vector nodes = allSceneGraphNodes();
+ if (!nodes.empty()) {
+ json << std::accumulate(
+ std::next(nodes.begin()),
+ nodes.end(),
+ createJson(*nodes.begin()),
+ [createJson](std::string a, SceneGraphNode* n) {
+ return a + "," + createJson(n);
+ }
+ );
}
- else
- LERROR("Undefined type '" << type << "' for Property documentation");
+
+ json << "]";
+
+ std::string jsonString = "";
+ for (const char& c : json.str()) {
+ if (c == '\'') {
+ jsonString += "\\'";
+ }
+ else {
+ jsonString += c;
+ }
+ }
+
+ return jsonString;
}
scripting::LuaLibrary Scene::luaLibrary() {
diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp
index ddbd6fac4f..af37f4623c 100644
--- a/src/scripting/scriptengine.cpp
+++ b/src/scripting/scriptengine.cpp
@@ -65,6 +65,18 @@ namespace {
std::string ScriptEngine::OpenSpaceLibraryName = "openspace";
+ScriptEngine::ScriptEngine()
+ : Documented(
+ "Script Documentation",
+ "scripting",
+ {
+ { "mainTemplate", MainTemplateFilename },
+ { "scriptingTemplate", ScriptingTemplateFilename }
+ },
+ JsFilename
+ )
+{}
+
void ScriptEngine::initialize() {
LDEBUG("Adding base library");
addBaseLibrary();
@@ -496,235 +508,48 @@ std::vector ScriptEngine::allLuaFunctions() const {
return result;
}
-void ScriptEngine::writeDocumentation(const std::string& filename, const std::string& type) const {
- auto concatenate = [](std::string library, std::string function) {
- std::string total = "openspace.";
- if (!library.empty()) {
- total += std::move(library) + ".";
+std::string ScriptEngine::generateJson() const {
+ // Create JSON
+ std::stringstream json;
+ json << "[";
+
+ bool first = true;
+ for (const LuaLibrary& l : _registeredLibraries) {
+ if (!first) {
+ json << ",";
}
- total += std::move(function);
- return total;
- };
+ first = false;
- LDEBUG("Writing Lua documentation of type '" << type <<
- "' to file '" << filename << "'");
- if (type == "text") {
- // Settings
- const unsigned int lineWidth = 80;
- static const std::string whitespace = " \t";
- static const std::string padding = " ";
+ json << "{";
+ json << "\"library\": \"" << l.name << "\",";
+ json << "\"functions\": [";
- // The additional space between the longest function name and the descriptions
-
- std::ofstream file;
- file.exceptions(~std::ofstream::goodbit);
- file.open(filename);
-
- file << "Available commands:\n";
- // Now write out the functions
- for (const LuaLibrary& l : _registeredLibraries) {
- for (const LuaLibrary::Function& f : l.functions) {
- std::string name = concatenate(l.name, f.name);
- file << padding << name << "(" << f.argumentText << ")" << std::endl;
- }
- }
- file << std::endl;
-
- // Now write out the functions definitions
- for (const LuaLibrary& library : _registeredLibraries) {
- for (const LuaLibrary::Function& function : library.functions) {
- std::string name = concatenate(library.name, function.name);
- file << name << "(" << function.argumentText << "):" << std::endl;
-
- std::string remainingHelptext = function.helpText;
- while (!remainingHelptext.empty()) {
- const size_t length = remainingHelptext.length();
- const size_t paddingLength = padding.length();
-
- if ((length + paddingLength) > lineWidth) {
- size_t lastSpace = remainingHelptext.find_last_of(
- whitespace,
- lineWidth - 1 - paddingLength
- );
- if (lastSpace == remainingHelptext.npos) {
- lastSpace = lineWidth;
- }
-
- file << padding << remainingHelptext.substr(0, lastSpace) << '\n';
-
- size_t firstNotSpace = remainingHelptext.find_first_not_of(
- whitespace,
- lastSpace
- );
- if (firstNotSpace == remainingHelptext.npos) {
- firstNotSpace = lastSpace;
- }
- remainingHelptext = remainingHelptext.substr(firstNotSpace);
- }
- else {
- file << padding << remainingHelptext << std::endl;
- remainingHelptext = "";
- }
- }
- file << std::endl;
- }
- }
- }
- else if (type == "html") {
- std::ifstream handlebarsInput(absPath(HandlebarsFilename));
- std::ifstream jsInput(absPath(JsFilename));
-
- std::string jsContent;
- std::back_insert_iterator jsInserter(jsContent);
-
- std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
- std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
-
- std::ifstream bootstrapInput(absPath(BootstrapFilename));
- std::ifstream cssInput(absPath(CssFilename));
-
- std::string cssContent;
- std::back_insert_iterator cssInserter(cssContent);
-
- std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
- std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
-
- std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
- std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ifstream scriptingTemplateInput(absPath(ScriptingTemplateFilename));
- std::string scriptingTemplateContent{ std::istreambuf_iterator{scriptingTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ofstream file;
- file.exceptions(~std::ofstream::goodbit);
- file.open(filename);
-
- // Create JSON
- std::stringstream json;
- json << "[";
-
- bool first = true;
- for (const LuaLibrary& l : _registeredLibraries) {
- if (!first) {
+ for (const LuaLibrary::Function& f : l.functions) {
+ json << "{";
+ json << "\"name\": \"" << f.name << "\", ";
+ json << "\"arguments\": \"" << f.argumentText << "\", ";
+ json << "\"help\": \"" << f.helpText << "\"";
+ json << "}";
+ if (&f != &l.functions.back()) {
json << ",";
}
- first = false;
-
- json << "{";
- json << "\"library\": \"" << l.name << "\",";
- json << "\"functions\": [";
-
- for (const LuaLibrary::Function& f : l.functions) {
- json << "{";
- json << "\"name\": \"" << f.name << "\", ";
- json << "\"arguments\": \"" << f.argumentText << "\", ";
- json << "\"help\": \"" << f.helpText << "\"";
- json << "}";
- if (&f != &l.functions.back()) {
- json << ",";
- }
- }
- json << "]}";
-
}
- json << "]";
+ json << "]}";
- std::string jsonString = "";
- for (const char& c : json.str()) {
- if (c == '\'') {
- jsonString += "\\'";
- }
- else {
- jsonString += c;
- }
- }
-
- std::stringstream html;
- html << "\n"
- << "\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\n"
- << "\t\n"
- << "\t\n"
- << "\t\tDocumentation\n"
- << "\t\n"
- << "\t\n"
- << "\t\n"
- << "\n";
-
- file << html.str();
-
- /*
-
- html << "\n"
- << "\t\n"
- << "\t\tScript Log\n"
- << "\t\n"
- << "\n"
- << "\n"
- << "\tScript Log\n\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\t| Library | \n"
- << "\t\t\tFunctions | \n"
- << "\t\t
\n"
- << "\t\t\n"
- << "\t\t\t| Name | \n"
- << "\t\t\tArguments | \n"
- << "\t\t\tHelp | \n"
- << "\t\t
\n"
- << "\t\n"
- << "\t\n";
-
-
-
- for (const LuaLibrary& l : _registeredLibraries) {
- html << "\t\n";
-
- if (l.name.empty()) {
- html << "\t\t| openspace | \n";
- }
- else {
- html << "\t\topenspace." << l.name << " | \n";
- }
- html << "\t\t | | | \n"
- << "\t\
";
-
- for (const LuaLibrary::Function& f : l.functions) {
- html << "\t\n"
- << "\t\t | \n"
- << "\t\t" << f.name << " | \n"
- << "\t\t" << f.argumentText << " | \n"
- << "\t\t" << f.helpText << " | \n"
- << "\t
\n";
- }
-
- html << "\t |
\n";
- }
-
- html << "\t\n"
- << "
\n"
- << "";
-
- file << html.str();
-*/
}
- else {
- throw ghoul::RuntimeError("Undefined type '" + type + "' for Lua documentation");
+ json << "]";
+
+ std::string jsonString = "";
+ for (const char& c : json.str()) {
+ if (c == '\'') {
+ jsonString += "\\'";
+ }
+ else {
+ jsonString += c;
+ }
}
+
+ return jsonString;
}
bool ScriptEngine::writeLog(const std::string& script) {
diff --git a/src/util/factorymanager.cpp b/src/util/factorymanager.cpp
index 3c13b6fcc8..4de2e4ac8f 100644
--- a/src/util/factorymanager.cpp
+++ b/src/util/factorymanager.cpp
@@ -52,6 +52,18 @@ FactoryManager::FactoryNotFoundError::FactoryNotFoundError(std::string t)
ghoul_assert(!type.empty(), "Type must not be empty");
}
+FactoryManager::FactoryManager()
+ : Documented(
+ "Factory Documentation",
+ "factories",
+ {
+ { "mainTemplate", MainTemplateFilename },
+ { "factoryTemplate", FactoryTemplateFilename }
+ },
+ JsFilename
+ )
+{}
+
void FactoryManager::initialize() {
ghoul_assert(!_manager, "Factory Manager must not have been initialized");
_manager = new FactoryManager;
@@ -79,151 +91,34 @@ void FactoryManager::addFactory(std::unique_ptr fact
_factories.push_back({ std::move(factory), std::move(name) });
}
-void FactoryManager::writeDocumentation(const std::string& file, const std::string& type) {
- if (type == "text") {
- std::ofstream f;
- f.exceptions(~std::ofstream::goodbit);
- f.open(file);
+std::string FactoryManager::generateJson() const {
+ std::stringstream json;
- for (const FactoryInfo& factoryInfo : _factories) {
- f << factoryInfo.name << '\n';
+ json << "[";
+ for (const FactoryInfo& factoryInfo : _factories) {
+ json << "{";
+ json << "\"name\": \"" << factoryInfo.name << "\",";
+ json << "\"classes\": [";
- ghoul::TemplateFactoryBase* factory = factoryInfo.factory.get();
- for (const std::string& c : factory->registeredClasses()) {
- f << '\t' << c << '\n';
- }
- f << "\n\n";
- }
-
- }
- else if (type == "html") {
- std::ifstream handlebarsInput(absPath(HandlebarsFilename));
- std::ifstream jsInput(absPath(JsFilename));
-
- std::string jsContent;
- std::back_insert_iterator jsInserter(jsContent);
-
- std::copy(std::istreambuf_iterator{handlebarsInput}, std::istreambuf_iterator(), jsInserter);
- std::copy(std::istreambuf_iterator{jsInput}, std::istreambuf_iterator(), jsInserter);
-
- std::ifstream bootstrapInput(absPath(BootstrapFilename));
- std::ifstream cssInput(absPath(CssFilename));
-
- std::string cssContent;
- std::back_insert_iterator cssInserter(cssContent);
-
- std::copy(std::istreambuf_iterator{bootstrapInput}, std::istreambuf_iterator(), cssInserter);
- std::copy(std::istreambuf_iterator{cssInput}, std::istreambuf_iterator(), cssInserter);
-
- std::ifstream mainTemplateInput(absPath(MainTemplateFilename));
- std::string mainTemplateContent{ std::istreambuf_iterator{mainTemplateInput},
- std::istreambuf_iterator{} };
-
- std::ifstream factoryTemplateInput(absPath(FactoryTemplateFilename));
- std::string factoryTemplateContent{ std::istreambuf_iterator{factoryTemplateInput},
- std::istreambuf_iterator{} };
-
- std::stringstream json;
-
- json << "[";
- for (const FactoryInfo& factoryInfo : _factories) {
- json << "{";
- json << "\"name\": \"" << factoryInfo.name << "\",";
- json << "\"classes\": [";
-
- ghoul::TemplateFactoryBase* factory = factoryInfo.factory.get();
- const std::vector& registeredClasses = factory->registeredClasses();
- for (const std::string& c : registeredClasses) {
- json << "\"" << c << "\"";
- if (&c != ®isteredClasses.back()) {
- json << ",";
- }
- }
-
- json << "]}";
- if (&factoryInfo != &_factories.back()) {
+ ghoul::TemplateFactoryBase* factory = factoryInfo.factory.get();
+ const std::vector& registeredClasses = factory->registeredClasses();
+ for (const std::string& c : registeredClasses) {
+ json << "\"" << c << "\"";
+ if (&c != ®isteredClasses.back()) {
json << ",";
}
}
- json << "]";
-
- // I did not check the output of this for correctness ---abock
- std::string jsonText = json.str();
-
- std::ofstream f;
- f.exceptions(~std::ofstream::goodbit);
- f.open(file);
-
- std::string jsonString = "";
- for (const char& c : json.str()) {
- if (c == '\'') {
- jsonString += "\\'";
- } else {
- jsonString += c;
- }
+ json << "]}";
+ if (&factoryInfo != &_factories.back()) {
+ json << ",";
}
-
- std::stringstream html;
- html << "\n"
- << "\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\n"
- << "\t\n"
- << "\t\n"
- << "\t\tDocumentation\n"
- << "\t\n"
- << "\t\n"
- << "\t\n"
- << "\n";
-
- f << html.str();
-
- /*
- html << "\n"
- << "\t\n"
- << "\t\tFactories\n"
- << "\t\n"
- << "\n"
- << "\n"
- << "\tFactories\n\n"
- << "\t\n"
- << "\t\t\n"
- << "\t\t\t| Type | \n"
- << "\t\t\tObject | \n"
- << "\t\t
\n"
- << "\t\n"
- << "\t\n";
-
- for (const FactoryInfo& factoryInfo : _factories) {
- html << "\t\t\n"
- << "\t\t\t| " << factoryInfo.name << " | \n";
-
- ghoul::TemplateFactoryBase* factory = factoryInfo.factory.get();
- for (const std::string& c : factory->registeredClasses()) {
- html << "\t\t\t
| " << c << " |
\n";
- }
- html << "\t |
\n";
-
- }
-
- html << "\t\n"
- << "
\n"
- << ";";
- f << html.str();
- */
}
+
+ json << "]";
+
+ // I did not check the output of this for correctness ---abock
+ return json.str();
}
} // namespace openspace
From 17fe85afbad33793171fbd9688095984cf8bab88 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Thu, 11 May 2017 18:01:36 -0400
Subject: [PATCH 11/23] Add documentation
---
include/openspace/util/documented.h | 49 +++++++++++++++++++++++++++--
src/util/documented.cpp | 13 +++++---
2 files changed, 56 insertions(+), 6 deletions(-)
diff --git a/include/openspace/util/documented.h b/include/openspace/util/documented.h
index 7f9b92a28f..0f701e9a45 100644
--- a/include/openspace/util/documented.h
+++ b/include/openspace/util/documented.h
@@ -30,22 +30,67 @@
namespace openspace {
+/*
+ * This abstract class is used for instances when another class has the ability to
+ * generate a Handlebar generated documentation file that contains valuable information
+ * for the user. Instances of this are the DocumentationEngine results, the list of
+ * Property%s generated by the Scene, or the FactoryEngine results. The documentation is
+ * generated through the writeDocumentation method.
+ *
+ * The concrete subclass needs to overload the generateJson class that will return the
+ * Json that is parsed by Handlebar to generate the webpage.
+ *
+ * A list of Handlebar templates, the variable name for the result of the generateJson
+ * method, and the Javascript file that contains additional logic is passed in the
+ * constructor.
+ */
class Documented {
public:
+ /// This struct contains a single Handlebar template, with the name and the filename
struct HandlebarTemplate {
- std::string name;
- std::string filename;
+ std::string name; ///< The name of the Handlebar template defined in \m filename
+ std::string filename; ///< The filename referenced in the \m name
};
+ /**
+ * The constructor that is used to set the member variables later used in the
+ * writeDocumentation method.
+ * \param name The name of the written documentation
+ * \param jsonName The variable name of the value generated by the generateJson
+ * \param handlebarTemplates A list of Handlebar templates that is added to the
+ * documentation file
+ * \param javascriptFilename The path to a Javascript source file that is added to the
+ * documentation and that can contain additional functionality
+ * \pre name must not be empty
+ * \pre jsonName must not be empty
+ * \pre Each handlebarTemplates' \c name must not be empty and \c filename must exist
+ * \pre javascriptFilename must not be empty must exist
+ */
Documented(std::string name, std::string jsonName,
std::vector handlebarTemplates,
std::string javascriptFilename);
+ /// Default constructor
virtual ~Documented() = default;
+ /**
+ * Create the documentation into the provided filename. Any existing file will be
+ * silently overwritten. This method will call the generateJson method that can be
+ * used by concrete subclasses to provide the actual data that is provided in the
+ * documentation.
+ * \param filename The filename in which the documentation is written
+ */
void writeDocumentation(const std::string& filename);
protected:
+ /**
+ * This abstract method is used by concrete subclasses to provide the actual data that
+ * is used in the documentation written by this Documented method. The JSON string
+ * returned by this function will be stored in the variable with the \c jsonName as
+ * passed in the constructor.
+ * \return A JSON script that is parsed and stored in the variable passed in the
+ * Documented constructor
+ */
virtual std::string generateJson() const = 0;
private:
diff --git a/src/util/documented.cpp b/src/util/documented.cpp
index 2fd79dcd9c..95aae556f4 100644
--- a/src/util/documented.cpp
+++ b/src/util/documented.cpp
@@ -51,11 +51,16 @@ Documented::Documented(std::string name,
{
ghoul_precondition(!_name.empty(), "name must not be empty");
ghoul_precondition(!_jsonName.empty(), "jsonName must not be empty");
- ghoul_precondition(
- !_handlebarTemplates.empty(),
- "handlebarTemplates must not be empty"
- );
+ for (const HandlebarTemplate& t : _handlebarTemplates) {
+ ghoul_precondition(!t.name.empty(), "name must not be empty");
+ ghoul_precondition(!t.filename.empty(), "filename must not be empty");
+ ghoul_precondition(FileSys.fileExists(t.filename), "filename must exist");
+ }
ghoul_precondition(!_javascriptFile.empty(), "javascriptFilename must not be empty");
+ ghoul_precondition(
+ FileSys.fileExists(_javascriptFile),
+ "javascriptFilename must exist"
+ );
}
void Documented::writeDocumentation(const std::string& filename) {
From 5ebf2a4913c3e26d89b5e74adade9315f6e81832 Mon Sep 17 00:00:00 2001
From: Alexander Bock
Date: Thu, 11 May 2017 18:16:30 -0400
Subject: [PATCH 12/23] Rename Documented to DocumentationGenerator
---
.../documentation/documentationengine.h | 7 +++----
.../documentationgenerator.h} | 20 +++++++++----------
.../interaction/interactionhandler.h | 9 +++++----
include/openspace/scene/scene.h | 5 +++--
include/openspace/scripting/scriptengine.h | 7 ++++---
include/openspace/util/factorymanager.h | 4 ++--
src/CMakeLists.txt | 4 ++--
src/documentation/documentationengine.cpp | 2 +-
.../documentationgenerator.cpp} | 12 +++++------
src/interaction/interactionhandler.cpp | 2 +-
src/scene/scene.cpp | 2 +-
src/scripting/scriptengine.cpp | 2 +-
src/util/factorymanager.cpp | 2 +-
13 files changed, 40 insertions(+), 38 deletions(-)
rename include/openspace/{util/documented.h => documentation/documentationgenerator.h} (89%)
rename src/{util/documented.cpp => documentation/documentationgenerator.cpp} (94%)
diff --git a/include/openspace/documentation/documentationengine.h b/include/openspace/documentation/documentationengine.h
index 444d164c6a..5ab18d9f03 100644
--- a/include/openspace/documentation/documentationengine.h
+++ b/include/openspace/documentation/documentationengine.h
@@ -26,10 +26,9 @@
#define __OPENSPACE_CORE___DOCUMENTATIONENGINE___H__
#include
-
-#include
-
+#include
#include
+
#include
namespace openspace {
@@ -41,7 +40,7 @@ namespace documentation {
* consumption.
*/
class DocumentationEngine : public ghoul::Singleton
- , public Documented
+ , public DocumentationGenerator
{
public:
/**
diff --git a/include/openspace/util/documented.h b/include/openspace/documentation/documentationgenerator.h
similarity index 89%
rename from include/openspace/util/documented.h
rename to include/openspace/documentation/documentationgenerator.h
index 0f701e9a45..4b3b5f4d2d 100644
--- a/include/openspace/util/documented.h
+++ b/include/openspace/documentation/documentationgenerator.h
@@ -22,8 +22,8 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
-#ifndef __OPENSPACE_CORE___DOCUMENTED___H__
-#define __OPENSPACE_CORE___DOCUMENTED___H__
+#ifndef __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__
+#define __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__
#include
#include
@@ -44,7 +44,7 @@ namespace openspace {
* method, and the Javascript file that contains additional logic is passed in the
* constructor.
*/
-class Documented {
+class DocumentationGenerator {
public:
/// This struct contains a single Handlebar template, with the name and the filename
struct HandlebarTemplate {
@@ -66,12 +66,12 @@ public:
* \pre Each handlebarTemplates' \c name must not be empty and \c filename must exist
* \pre javascriptFilename must not be empty must exist
*/
- Documented(std::string name, std::string jsonName,
+ DocumentationGenerator(std::string name, std::string jsonName,
std::vector handlebarTemplates,
std::string javascriptFilename);
/// Default constructor
- virtual ~Documented() = default;
+ virtual ~DocumentationGenerator() = default;
/**
* Create the documentation into the provided filename. Any existing file will be
@@ -85,11 +85,11 @@ public:
protected:
/**
* This abstract method is used by concrete subclasses to provide the actual data that
- * is used in the documentation written by this Documented method. The JSON string
- * returned by this function will be stored in the variable with the \c jsonName as
- * passed in the constructor.
+ * is used in the documentation written by this DocumentationGenerator class. The JSON
+ * string returned by this function will be stored in the variable with the
+ * \c jsonName as passed in the constructor.
* \return A JSON script that is parsed and stored in the variable passed in the
- * Documented constructor
+ * DocumentationGenerator constructor
*/
virtual std::string generateJson() const = 0;
@@ -102,4 +102,4 @@ private:
} // namespace openspace
-#endif // __OPENSPACE_CORE___DOCUMENTED___H__
+#endif // __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__
diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h
index 576b9cf01a..891dfca494 100644
--- a/include/openspace/interaction/interactionhandler.h
+++ b/include/openspace/interaction/interactionhandler.h
@@ -25,13 +25,14 @@
#ifndef __OPENSPACE_CORE___INTERACTIONHANDLER___H__
#define __OPENSPACE_CORE___INTERACTIONHANDLER___H__
+#include
+#include
+
#include
#include
-#include
#include
#include
#include
-#include
#include
#include
@@ -48,8 +49,8 @@ class SceneGraphNode;
namespace interaction {
-
-class InteractionHandler : public properties::PropertyOwner, public Documented {
+class InteractionHandler : public properties::PropertyOwner, public DocumentationGenerator
+{
public:
InteractionHandler();
~InteractionHandler();
diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h
index 9a1aecbd7d..dcd77be9dc 100644
--- a/include/openspace/scene/scene.h
+++ b/include/openspace/scene/scene.h
@@ -25,13 +25,14 @@
#ifndef __OPENSPACE_CORE___SCENE___H__
#define __OPENSPACE_CORE___SCENE___H__
+#include
+
#include
#include