From cffeceec9919503b3ba94e6b4dd527edde8c3faf Mon Sep 17 00:00:00 2001 From: mfeemster Date: Wed, 18 May 2016 16:48:40 -0700 Subject: [PATCH] --User changes -Add a new option --statevars to EmberGenome to list the variations which change state. -Allow for filtering in the Variations Dialog based on the same types listed in the EmberGenome options. --Code changes -More correctly populate VariationList::m_ParametricVariations and VariationList::m_NonParametricVariations to account for variations which have params only used for precalc. -Consolidate some of the code in VariationList which searches by name. --- Source/Ember/VariationList.cpp | 83 ++++-- Source/Ember/VariationList.h | 4 + Source/EmberCommon/EmberOptions.h | 4 + Source/EmberGenome/EmberGenome.cpp | 29 ++- .../Fractorium/FinalRenderEmberController.cpp | 3 +- Source/Fractorium/FractoriumSettings.h | 9 + Source/Fractorium/VariationsDialog.cpp | 238 ++++++++++++++++++ Source/Fractorium/VariationsDialog.h | 3 + Source/Fractorium/VariationsDialog.ui | 119 +++++++++ 9 files changed, 462 insertions(+), 30 deletions(-) diff --git a/Source/Ember/VariationList.cpp b/Source/Ember/VariationList.cpp index 7068cc4..1f2341a 100644 --- a/Source/Ember/VariationList.cpp +++ b/Source/Ember/VariationList.cpp @@ -379,7 +379,25 @@ VariationList::VariationList() m_PostVariations.push_back(var); if (auto parVar = dynamic_cast*>(var)) - m_ParametricVariations.push_back(parVar); + { + bool b = false; + auto& params = parVar->ParamsVec(); + + //Some non-parametric variations are actually stored as ParametricVariation just to hold some precalcs. + //So to populate parametric, check to see at least one parameter was not a precalc, if so, treat this as parametric. + for (auto& param : params) + { + if (!param.IsPrecalc()) + { + m_ParametricVariations.push_back(parVar); + b = true; + break; + } + } + + if (!b) + m_NonParametricVariations.push_back(var);//Only get here if all parameters were non-precalc, so treat this as non-parametric. + } else m_NonParametricVariations.push_back(var); } @@ -432,7 +450,7 @@ const Variation* VariationList::GetVariation(size_t index, eVariationType } /// -/// Gets a pointer to a copy of the variation at the specified index. +/// Get a pointer to a copy of the variation at the specified index. /// Optionally specify a weight to assign the new copy. /// /// The index in the list to make a copy of @@ -459,7 +477,7 @@ const Variation* VariationList::GetVariation(eVariationId id) const } /// -/// Gets a pointer to a copy of the variation with the specified ID. +/// Get a pointer to a copy of the variation with the specified ID. /// Optionally specify a weight to assign the new copy. /// /// The id of the variation in the list to make a copy of @@ -474,17 +492,10 @@ Variation* VariationList::GetVariationCopy(eVariationId id, T weight) cons /// The name to search for /// A pointer to the variation if found, else nullptr. template -const Variation* VariationList::GetVariation(const string& name) const -{ - for (auto var : m_Variations) - if (var && !_stricmp(name.c_str(), var->Name().c_str())) - return var; - - return nullptr; -} +const Variation* VariationList::GetVariation(const string& name) const { return SearchVarName(m_Variations, name); } /// -/// Gets a pointer to a copy of the variation with the specified name. +/// Get a pointer to a copy of the variation with the specified name. /// Optionally specify a weight to assign the new copy. /// /// The name of the variation in the list to make a copy of @@ -510,19 +521,38 @@ const ParametricVariation* VariationList::GetParametricVariation(size_t in template const ParametricVariation* VariationList::GetParametricVariation(const string& name) const { - for (auto var : m_ParametricVariations) - if (var && !_stricmp(name.c_str(), var->Name().c_str())) - return var; - - return nullptr; + return SearchVarName(m_ParametricVariations, name); } +/// +/// Get a pointer to a copy of the parametric variation at the specified index. +/// Optionally specify a weight to assign the new copy. +/// +/// The index in the list to make a copy of +/// The weight to assign the new copy. Default: 1 +/// A pointer to the parametric variation at the index if in range, else nullptr. template ParametricVariation* VariationList::GetParametricVariationCopy(eVariationId id, T weight) const { return dynamic_cast*>(MakeCopyWithWeight(GetVariation(id), weight)); } +/// +/// Get a pointer to the pre variation with the specified name. +/// +/// The name to search for +/// A pointer to the pre variation if found, else nullptr. +template +const Variation* VariationList::GetPreVariation(const string& name) const { return SearchVarName(m_PreVariations, name); } + +/// +/// Get a pointer to the post variation with the specified name. +/// +/// The name to search for +/// A pointer to the post variation if found, else nullptr. +template +const Variation* VariationList::GetPostVariation(const string& name) const { return SearchVarName(m_PostVariations, name); } + /// /// Get the index of the variation with the specified name. /// @@ -574,6 +604,25 @@ Variation* VariationList::MakeCopyWithWeight(const Variation* var, T we return nullptr; } +/// +/// Search the passed in container of variations for a name which matches the passed in name. +/// Note that since the elements of vars is a nested template, they can be Variation* +/// or anything which derives from that. +/// +/// The vector of variations to search +/// The name to search for +/// True if found, else false. +template +template