From 3c9d48315c02e2c59da09e85fcadb6ab0dba7c65 Mon Sep 17 00:00:00 2001 From: Oskar Carlbaum Date: Fri, 22 Sep 2017 06:27:44 +0200 Subject: [PATCH] Add trigger properties. One for focus the camera on parent and one for time jump to start of sequence! --- .../renderablefieldlinessequence.cpp | 37 ++++++++++++++++++- .../rendering/renderablefieldlinessequence.h | 33 ++++++++++------- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index a7e5135302..25c98b57cb 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -25,8 +25,11 @@ #include #include +#include #include +#include #include +#include #include #include @@ -90,6 +93,12 @@ namespace { static const openspace::properties::Property::PropertyInfo FlowSpeedInfo = { "speed", "Speed", "Speed of the flow." }; + static const openspace::properties::Property::PropertyInfo OriginButtonInfo = { + "focusCameraOnParent", "Focus Camera", "Focus camera on parent." + }; + static const openspace::properties::Property::PropertyInfo TimeJumpButtonInfo = { + "timeJumpToStart", "Jump to Start Time", "Performs a time jump to the start of the sequence." + }; enum ColorMethod { UNIFORM = 0, BY_QUANTITY }; } // namespace @@ -113,7 +122,9 @@ RenderableFieldlinesSequence::RenderableFieldlinesSequence(const ghoul::Dictiona _flowParticleSize(ParticleSizeInfo, 5, 0, 500), _flowParticleSpacing(ParticleSpacingInfo, 60, 0, 500), _flowReversed(ReverseFlowInfo, false), - _flowSpeed(FlowSpeedInfo, 20, 0, 1000) { + _flowSpeed(FlowSpeedInfo, 20, 0, 1000), + _focusOnOriginBtn(OriginButtonInfo), + _jumpToStartBtn(TimeJumpButtonInfo) { // Set the default color table, just in case user defined paths are corrupt! _transferFunction = std::make_shared(absPath(_colorTablePaths[0])); @@ -174,6 +185,10 @@ void RenderableFieldlinesSequence::initialize() { addPropertySubOwner(_colorGroup); addPropertySubOwner(_flowGroup); + // Add non-grouped properties + addProperty(_focusOnOriginBtn); + addProperty(_jumpToStartBtn); + // Add Properties to the groups _colorGroup.addProperty(_colorMethod); _colorGroup.addProperty(_colorQuantity); @@ -235,6 +250,25 @@ void RenderableFieldlinesSequence::initialize() { _colorTableRanges[_colorQuantity].y = std::stof(_colorQuantityMax); }); + _focusOnOriginBtn.onChange([this] { + LDEBUG("SET FOCUS NODE TO PARENT"); + // TODO CHECK IF VALID NUMBER! + // _updateTransferFunctionMin = true; + //OsEng.navigationHandler().setFocusNode(); + SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(_name); + if (!node) { + LWARNING("Could not find a node in scenegraph called '" << _name << "'"); + return; + } + OsEng.navigationHandler().setFocusNode(node->parent()); + OsEng.navigationHandler().resetCameraDirection(); + }); + + _jumpToStartBtn.onChange([this] { + LDEBUG("Jump in time to start of sequence!"); + OsEng.timeManager().time().setTime(_startTimes[0]); + }); + // Setup shader program _shaderProgram = OsEng.renderEngine().buildRenderProgram( "FieldlinesSequence", @@ -469,6 +503,7 @@ bool RenderableFieldlinesSequence::extractInfoFromDictionary( string name; dictionary.getValue(SceneGraphNode::KeyName, name); + _name = name; name += ": "; // ------------------- EXTRACT MANDATORY VALUES FROM DICTIONARY ------------------- // diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h index a18a207bba..773022754c 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -60,6 +61,8 @@ private: INVALID }; + std::string _name; + int _activeStateIndex = -1; int _activeTriggerTimeIndex = -1; bool _isLoadingStatesAtRuntime = true; // False => loading osfls at runtime @@ -94,22 +97,24 @@ private: const GLuint _VA_COLOR = 1; // ----------------------------- Properties ----------------------------- - properties::PropertyOwner _colorGroup; // Group to hold the color properties - properties::OptionProperty _colorMethod; // Uniform/transfer function/topology? - properties::OptionProperty _colorQuantity; // Index of the extra quantity to color lines by - properties::StringProperty _colorQuantityMin; // Color table/transfer function min - properties::StringProperty _colorQuantityMax; // Color table/transfer function max - properties::StringProperty _colorTablePath; // Color table/transfer function for "By Quantity" coloring - properties::Vec4Property _colorUniform; // Uniform Field Line Color + properties::PropertyOwner _colorGroup; // Group to hold the color properties + properties::OptionProperty _colorMethod; // Uniform/transfer function/topology? + properties::OptionProperty _colorQuantity; // Index of the extra quantity to color lines by + properties::StringProperty _colorQuantityMin; // Color table/transfer function min + properties::StringProperty _colorQuantityMax; // Color table/transfer function max + properties::StringProperty _colorTablePath; // Color table/transfer function for "By Quantity" coloring + properties::Vec4Property _colorUniform; // Uniform Field Line Color - properties::Vec4Property _flowColor; // Simulated particles' color - properties::BoolProperty _flowEnabled; // Toggle flow [ON/OFF] - properties::PropertyOwner _flowGroup; // Gropu to hold the flow/particle properties - properties::IntProperty _flowParticleSize; // Size of simulated flow particles - properties::IntProperty _flowParticleSpacing; // Size of simulated flow particles - properties::BoolProperty _flowReversed; // Toggle flow direction [FORWARDS/BACKWARDS] - properties::IntProperty _flowSpeed; // Speed of simulated flow + properties::Vec4Property _flowColor; // Simulated particles' color + properties::BoolProperty _flowEnabled; // Toggle flow [ON/OFF] + properties::PropertyOwner _flowGroup; // Gropu to hold the flow/particle properties + properties::IntProperty _flowParticleSize; // Size of simulated flow particles + properties::IntProperty _flowParticleSpacing; // Size of simulated flow particles + properties::BoolProperty _flowReversed; // Toggle flow direction [FORWARDS/BACKWARDS] + properties::IntProperty _flowSpeed; // Speed of simulated flow + properties::TriggerProperty _focusOnOriginBtn; // Button which sets camera focus to parent node of the renderable + properties::TriggerProperty _jumpToStartBtn; // Button which executes a time jump to start of sequence void computeSequenceEndTime(); bool extractInfoFromDictionary(const ghoul::Dictionary& dictionary);