From a82ad66374caf33f8af3969703202ac174d1a36b Mon Sep 17 00:00:00 2001 From: Kalle Bladin Date: Fri, 26 Aug 2016 20:32:08 -0400 Subject: [PATCH] Add scale as a property of every scenegraph node. --- include/openspace/scene/scale.h | 3 ++- modules/base/scale/staticscale.cpp | 10 +++++++--- modules/base/scale/staticscale.h | 6 +++--- src/scene/scenegraphnode.cpp | 3 +++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/openspace/scene/scale.h b/include/openspace/scene/scale.h index d7f0ce9703..d95cec819c 100644 --- a/include/openspace/scene/scale.h +++ b/include/openspace/scene/scale.h @@ -27,10 +27,11 @@ #include #include +#include namespace openspace { -class Scale { +class Scale : public properties::PropertyOwner { public: static Scale* createFromDictionary(const ghoul::Dictionary& dictionary); diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index ff1573e61c..99d961c50c 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -25,24 +25,28 @@ #include namespace { + const std::string _loggerCat = "StaticScale"; const std::string KeyValue = "Scale"; } namespace openspace { StaticScale::StaticScale(const ghoul::Dictionary& dictionary) - : _scaleValue(1.0) + : _scaleValue("scale", "Scale", 1.0, 1.0, 1000.0) { const bool hasValue = dictionary.hasKeyAndValue(KeyValue); if (hasValue) { - dictionary.getValue(KeyValue, _scaleValue); + float value; + dictionary.getValue(KeyValue, value); + _scaleValue.setValue(value); } + Scale::addProperty(_scaleValue); } StaticScale::~StaticScale() {} double StaticScale::scaleValue() const { - return _scaleValue; + return _scaleValue.value(); } void StaticScale::update(const UpdateData&) {} diff --git a/modules/base/scale/staticscale.h b/modules/base/scale/staticscale.h index 68f2d65c1b..196956d9ab 100644 --- a/modules/base/scale/staticscale.h +++ b/modules/base/scale/staticscale.h @@ -31,13 +31,13 @@ namespace openspace { class StaticScale: public Scale { public: - StaticScale(const ghoul::Dictionary& dictionary - = ghoul::Dictionary()); + StaticScale(const ghoul::Dictionary& dictionary = ghoul::Dictionary()); virtual ~StaticScale(); virtual double scaleValue() const; virtual void update(const UpdateData& data) override; private: - double _scaleValue; + properties::FloatProperty _scaleValue; + //double _scaleValue; }; } // namespace openspace diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 5482dbddaa..68afc19761 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -150,6 +150,9 @@ SceneGraphNode* SceneGraphNode::createFromDictionary(const ghoul::Dictionary& di //parentNode->addNode(result); + result->_scale->setName("Transform"); + result->addPropertySubOwner(result->_scale); + LDEBUG("Successfully created SceneGraphNode '" << result->name() << "'"); return result;