diff --git a/Source/Ember/Ember.h b/Source/Ember/Ember.h index 0a373ea..7b2bf71 100644 --- a/Source/Ember/Ember.h +++ b/Source/Ember/Ember.h @@ -543,7 +543,7 @@ public: { bool b = false; - ForEach(m_Xforms, [&](const Xform& xform) { b |= xform.XaosPresent(); });//If at least one entry is not equal to 1, then xaos is present. + for (auto& xform : m_Xforms) b |= xform.XaosPresent();//If at least one entry is not equal to 1, then xaos is present. return b; } @@ -553,7 +553,7 @@ public: /// void ClearXaos() { - ForEach(m_Xforms, [&](Xform& xform) { xform.ClearXaos(); }); + for (auto& xform : m_Xforms) xform.ClearXaos(); } /// @@ -605,7 +605,7 @@ public: { T weight = T(1) / m_Xforms.size(); - ForEach(m_Xforms, [&](Xform& xform) { xform.m_Weight = weight; }); + for (auto& xform : m_Xforms) xform.m_Weight = weight; } /// @@ -620,8 +620,8 @@ public: if (normalizedWeights.size() != m_Xforms.size()) normalizedWeights.resize(m_Xforms.size()); - ForEach(m_Xforms, [&](Xform& xform) { norm += xform.m_Weight; }); - ForEach(normalizedWeights, [&](T& weight) { weight = (norm == T(0) ? T(0) : m_Xforms[i].m_Weight / norm); i++; }); + for (auto& xform : m_Xforms) norm += xform.m_Weight; + for (auto& weight : normalizedWeights) { weight = (norm == T(0) ? T(0) : m_Xforms[i].m_Weight / norm); i++; } } /// @@ -635,7 +635,8 @@ public: size_t i = 0, xformIndex = 0, totalVarCount = m_FinalXform.TotalVariationCount(); variations.clear(); - ForEach(m_Xforms, [&](const Xform& xform) { totalVarCount += xform.TotalVariationCount(); }); + for (auto& xform : m_Xforms) totalVarCount += xform.TotalVariationCount(); + variations.reserve(totalVarCount); while (Xform* xform = GetTotalXform(xformIndex++)) @@ -672,7 +673,7 @@ public: { bool flattened = false; - ForEach(m_Xforms, [&](Xform& xform) { flattened |= xform.Flatten(names); }); + for (auto& xform : m_Xforms) flattened |= xform.Flatten(names); return flattened; } @@ -685,12 +686,12 @@ public: { bool unflattened = false; - ForEach(m_Xforms, [&](Xform& xform) + for (auto& xform : m_Xforms) { unflattened |= xform.DeleteVariationById(VAR_PRE_FLATTEN); unflattened |= xform.DeleteVariationById(VAR_FLATTEN); unflattened |= xform.DeleteVariationById(VAR_POST_FLATTEN); - }); + } return unflattened; } diff --git a/Source/Ember/EmberToXml.h b/Source/Ember/EmberToXml.h index 5f3e402..b184e7f 100644 --- a/Source/Ember/EmberToXml.h +++ b/Source/Ember/EmberToXml.h @@ -83,9 +83,9 @@ public: f.write(temp.c_str(), temp.size()); } - for (size_t i = 0; i < embers.size(); i++) + for (auto& ember : embers) { - string s = ToString(embers[i], "", printEditDepth, doEdits, intPalette, hexPalette); + string s = ToString(ember, "", printEditDepth, doEdits, intPalette, hexPalette); f.write(s.c_str(), s.size()); } @@ -202,7 +202,7 @@ public: ember.GetPresentVariations(variations, false); if (!variations.empty()) - ForEach(variations, [&] (Variation* var) { os << var->Name() << (var != variations.back() ? " " : "\""); }); + for (auto var : variations) os << var->Name() << (var != variations.back() ? " " : "\""); else os << "\""; diff --git a/Source/Ember/Interpolate.h b/Source/Ember/Interpolate.h index 032c733..ca728e0 100644 --- a/Source/Ember/Interpolate.h +++ b/Source/Ember/Interpolate.h @@ -472,8 +472,8 @@ public: { Xform xform; - for (size_t xf = 0; xf < xforms.size(); xf++) - MergeXformVariations1Way(xforms[xf], &xform, false, clearWeights); + for (auto xf : xforms) + MergeXformVariations1Way(xf, &xform, false, clearWeights); return xform; } diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp index f063260..938202b 100644 --- a/Source/Ember/Renderer.cpp +++ b/Source/Ember/Renderer.cpp @@ -88,8 +88,8 @@ void Renderer::ComputeBounds() //Check the size of the density estimation filter. //If the radius of the density estimation filter is greater than the //gutter width, have to pad with more. Otherwise, use the same value. - for (size_t i = 0; i < m_Embers.size(); i++) - maxDEFilterWidth = std::max(size_t(ceil(m_Embers[i].m_MaxRadDE) * m_Ember.m_Supersample), maxDEFilterWidth); + for (auto& ember : m_Embers) + maxDEFilterWidth = std::max(size_t(ceil(ember.m_MaxRadDE) * m_Ember.m_Supersample), maxDEFilterWidth); //Need an extra ss = (int)floor(m_Supersample / 2.0) of pixels so that a local iteration count for DE can be determined.//SMOULDER if (maxDEFilterWidth > 0) @@ -748,16 +748,16 @@ bool Renderer::Alloc() b &= (m_Samples.size() == m_ThreadsToUse); } - for (size_t i = 0; i < m_Samples.size(); i++) + for (auto& sample : m_Samples) { - if (m_Samples[i].size() != SubBatchSize()) + if (sample.size() != SubBatchSize()) { - m_Samples[i].resize(SubBatchSize()); + sample.resize(SubBatchSize()); if (m_ReclaimOnResize) - m_Samples[i].shrink_to_fit(); + sample.shrink_to_fit(); - b &= (m_Samples[i].size() == SubBatchSize()); + b &= (sample.size() == SubBatchSize()); } } @@ -1214,6 +1214,9 @@ EmberStats Renderer::Iterate(size_t iterCount, size_t temporalSample #else parallel_for(size_t(0), m_ThreadsToUse, [&] (size_t threadIndex) { +#endif +#ifdef WIN32 + //SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); #endif //Timing t; IterParams params; @@ -1441,7 +1444,7 @@ void Renderer::Accumulate(QTIsaac& rand, Poin { size_t histIndex, intColorIndex, histSize = m_HistBuckets.size(); bucketT colorIndex, colorIndexFrac; - const tvec4* dmap = &(palette->m_Entries[0]); + auto dmap = palette->m_Entries.data(); //T oneColDiv2 = m_CarToRas.OneCol() / 2; //T oneRowDiv2 = m_CarToRas.OneRow() / 2; diff --git a/Source/Ember/Utils.h b/Source/Ember/Utils.h index d192cdf..a57104b 100644 --- a/Source/Ember/Utils.h +++ b/Source/Ember/Utils.h @@ -21,18 +21,6 @@ static inline bool FindIf(c& container, pr pred) return std::find_if(container.begin(), container.end(), pred) != container.end(); } -/// -/// Thin wrapper around std::for_each() to relieve the caller of having to -/// pass the implicitly obvious .begin() and .end(). -/// -/// The container to call for_each() on -/// The lambda to call on each element -template -static inline void ForEach(c& container, fn func) -{ - std::for_each(container.begin(), container.end(), func); -} - /// /// Thin wrapper around computing the total size of a vector. /// @@ -149,7 +137,7 @@ public: { stringstream ss; - ForEach(errorReport, [&](const string& s) { ss << s << endl; }); + for (auto& s : errorReport) ss << s << endl; return ss.str(); } diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index 95b2f46..d146e89 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -1678,11 +1678,14 @@ public: { bool b = false; - ForEach(m_Params, [&](ParamWithName& param) + for (auto& param : m_Params) { if (!_stricmp(param.Name().c_str(), name)) + { b = true; - }); + break; + } + } return b; } @@ -1694,9 +1697,9 @@ public: /// A pointer to the parameter value if the name matched, else false. T* GetParam(const char* name) { - for (size_t i = 0; i < m_Params.size(); i++) - if (!_stricmp(m_Params[i].Name().c_str(), name)) - return m_Params[i].Param(); + for (auto& param : m_Params) + if (!_stricmp(param.Name().c_str(), name)) + return param.Param(); return nullptr; } @@ -1708,9 +1711,9 @@ public: /// A parameter value if the name matched, else 0. T GetParamVal(const char* name) const { - for (size_t i = 0; i < m_Params.size(); i++) - if (!_stricmp(m_Params[i].Name().c_str(), name)) - return m_Params[i].ParamVal(); + for (auto& param : m_Params) + if (!_stricmp(param.Name().c_str(), name)) + return param.ParamVal(); return 0; } @@ -1725,14 +1728,15 @@ public: { bool b = false; - ForEach(m_Params, [&](ParamWithName& param) + for (auto& param : m_Params) { if (!_stricmp(param.Name().c_str(), name)) { param.Set(val); b = true; + break; } - }); + } if (b) this->Precalc(); @@ -1772,7 +1776,7 @@ public: virtual void Random(QTIsaac& rand) override { Variation::Random(rand); - ForEach(m_Params, [&](ParamWithName& param) { param.Set(rand.Frand11()); }); + for (auto& param : m_Params) param.Set(rand.Frand11()); this->Precalc(); } @@ -1781,7 +1785,7 @@ public: /// void Clear() { - ForEach(m_Params, [&](ParamWithName& param) { *(param.Param()) = 0; }); + for (auto& param : m_Params) *(param.Param()) = 0; this->Precalc(); } @@ -1795,11 +1799,11 @@ public: vector vec; vec.reserve(m_Params.size()); - ForEach(m_Params, [&](const ParamWithName& param) + for (auto& param : m_Params) { if ((includePrecalcs && param.IsPrecalc()) || !param.IsPrecalc()) vec.push_back(param.Name()); - }); + } return vec; } @@ -1813,7 +1817,7 @@ public: ostringstream ss; ss << Variation::ToString() << endl; - ForEach(m_Params, [&](const ParamWithName& param) { ss << param.ToString() << endl; }); + for (auto& param : m_Params) ss << param.ToString() << endl; return ss.str(); } diff --git a/Source/Ember/VariationList.h b/Source/Ember/VariationList.h index 85aa6e3..31c4a34 100644 --- a/Source/Ember/VariationList.h +++ b/Source/Ember/VariationList.h @@ -342,16 +342,16 @@ public: ADDPREPOSTREGVAR(DCTriangle) ADDPREPOSTREGVAR(DCZTransl) - ForEach(m_Variations, [&](Variation* var) { var->Precalc(); }); + for (auto var : m_Variations) var->Precalc(); std::sort(m_Variations.begin(), m_Variations.end(), [&](const Variation* var1, const Variation* var2) { return var1->VariationId() < var2->VariationId(); }); m_RegVariations.reserve(m_Variations.size() / 3); m_PreVariations.reserve(m_Variations.size() / 3); m_PostVariations.reserve(m_Variations.size() / 3); - ForEach(m_Variations, [&](Variation* var) { if (var->VarType() == VARTYPE_REG) m_RegVariations.push_back(var); }); - ForEach(m_Variations, [&](Variation* var) { if (var->VarType() == VARTYPE_PRE) m_PreVariations.push_back(var); }); - ForEach(m_Variations, [&](Variation* var) { if (var->VarType() == VARTYPE_POST) m_PostVariations.push_back(var); }); + for (auto var : m_Variations) if (var->VarType() == VARTYPE_REG) m_RegVariations.push_back(var); + for (auto var : m_Variations) if (var->VarType() == VARTYPE_PRE) m_PreVariations.push_back(var); + for (auto var : m_Variations) if (var->VarType() == VARTYPE_POST) m_PostVariations.push_back(var); //Keep a list of which variations derive from ParametricVariation. //Note that these are not new copies, rather just pointers to the original instances in m_Variations. diff --git a/Source/Ember/Xform.h b/Source/Ember/Xform.h index af0b971..e676a34 100644 --- a/Source/Ember/Xform.h +++ b/Source/Ember/Xform.h @@ -365,11 +365,11 @@ public: const_cast*>(this)->AllVarsFunc([&] (vector*>& variations, bool& keepGoing) { - for (size_t i = 0; i < variations.size(); i++) + for (auto v : variations) { - if (variations[i] != nullptr && variations[i]->VariationId() == id) + if (v != nullptr && v->VariationId() == id) { - var = variations[i]; + var = v; keepGoing = false; break; } @@ -390,11 +390,11 @@ public: const_cast*>(this)->AllVarsFunc([&] (vector*>& variations, bool& keepGoing) { - for (size_t i = 0; i < variations.size(); i++) + for (auto v : variations) { - if (variations[i] != nullptr && variations[i]->Name() == name) + if (v != nullptr && v->Name() == name) { - var = variations[i]; + var = v; keepGoing = false; break; } @@ -593,8 +593,8 @@ public: { T norm = 0; - ForEach(variations, [&](Variation* var) { norm += var->m_Weight; }); - ForEach(variations, [&](Variation* var) { var->m_Weight /= norm; }); + for (auto var : variations) norm += var->m_Weight; + for (auto var : variations) var->m_Weight /= norm; }); } @@ -839,45 +839,30 @@ public: m_HasPreOrRegularVars = PreVariationCount() > 0 || VariationCount() > 0; //Only set precalcs for regular variations, they work differently for pre and post. - for (size_t i = 0; i < m_Variations.size(); i++) + for (auto var : m_Variations) { - if (m_Variations[i]->NeedPrecalcSumSquares()) + if (var->NeedPrecalcSumSquares()) m_NeedPrecalcSumSquares = true; - if (m_Variations[i]->NeedPrecalcSqrtSumSquares()) + if (var->NeedPrecalcSqrtSumSquares()) m_NeedPrecalcSqrtSumSquares = true; - if (m_Variations[i]->NeedPrecalcAngles()) + if (var->NeedPrecalcAngles()) m_NeedPrecalcAngles = true; - if (m_Variations[i]->NeedPrecalcAtanXY()) + if (var->NeedPrecalcAtanXY()) m_NeedPrecalcAtanXY = true; - if (m_Variations[i]->NeedPrecalcAtanYX()) + if (var->NeedPrecalcAtanYX()) m_NeedPrecalcAtanYX = true; } AllVarsFunc([&] (vector*>& variations, bool& keepGoing) { - for (size_t i = 0; i < variations.size(); i++) + for (auto var : variations) { - /*if (variations[i]->NeedPrecalcSumSquares()) - m_NeedPrecalcSumSquares = true; - - if (variations[i]->NeedPrecalcSqrtSumSquares()) - m_NeedPrecalcSqrtSumSquares = true; - - if (variations[i]->NeedPrecalcAngles()) - m_NeedPrecalcAngles = true; - - if (variations[i]->NeedPrecalcAtanXY()) - m_NeedPrecalcAtanXY = true; - - if (variations[i]->NeedPrecalcAtanYX()) - m_NeedPrecalcAtanYX = true;*/ - - variations[i]->ParentXform(this); - variations[i]->Precalc(); + var->ParentXform(this); + var->Precalc(); } }); } @@ -925,10 +910,9 @@ public: { AllVarsFunc([&] (vector*>& variations, bool& keepGoing) { - for (size_t i = 0; i < variations.size(); i++) + for (auto var : variations) + //for (size_t i = 0; i < variations.size(); i++) { - Variation* var = variations[i]; - if (var->m_Weight != 0)//This should never happen, but just to be safe. { if (FindIf(names, [&] (const string& s) -> bool { return !_stricmp(s.c_str(), var->Name().c_str()); }))//If any variation is present, don't flatten. @@ -942,14 +926,15 @@ public: //Now traverse the parameters for this variation. if (ParametricVariation* parVar = dynamic_cast*>(var))//If any parametric variation parameter is present and non-zero, don't flatten. { - ForEach(names, [&] (const string& s) + for (auto& s : names) { if (parVar->GetParamVal(s.c_str()) != 0) { shouldFlatten = false; keepGoing = false; + break; } - }); + } } } }); @@ -1175,16 +1160,16 @@ public: const_cast*>(this)->AllVarsFunc([&] (vector*>& variations, bool& keepGoing) { - for (size_t i = 0; i < variations.size(); i++) - ss << variations[i]->ToString() << endl; + for (auto var : variations) + ss << var->ToString() << endl; ss << endl; }); if (XaosPresent()) { - for (size_t i = 0; i < m_Xaos.size(); i++) - ss << m_Xaos[i] << " "; + for (auto xaos : m_Xaos) + ss << xaos << " "; ss << endl; } diff --git a/Source/Ember/XmlToEmber.h b/Source/Ember/XmlToEmber.h index 5008088..d8c44fc 100644 --- a/Source/Ember/XmlToEmber.h +++ b/Source/Ember/XmlToEmber.h @@ -1261,11 +1261,9 @@ private: /// The corrected name if one was found, else the passed in name. static string GetCorrectedParamName(vector>& vec, const char* name) { - for (size_t i = 0; i < vec.size(); i++) - { - if (!_stricmp(vec[i].first.c_str(), name)) - return vec[i].second; - } + for (auto& v : vec) + if (!_stricmp(v.first.c_str(), name)) + return v.second; return name; } @@ -1281,21 +1279,21 @@ private: /// The corrected name if one was found, else the passed in name. static string GetCorrectedVariationName(vector, vector>>& vec, xmlAttrPtr att) { - for (size_t i = 0; i < vec.size(); i++) + for (auto& v : vec) { - if (!_stricmp(vec[i].first.first.c_str(), CCX(att->name)))//Do case insensitive here. + if (!_stricmp(v.first.first.c_str(), CCX(att->name)))//Do case insensitive here. { - if (!vec[i].second.empty()) + if (!v.second.empty()) { - for (size_t j = 0; j < vec[i].second.size(); j++) + for (size_t j = 0; j < v.second.size(); j++) { - if (XmlContainsTag(att, vec[i].second[j].c_str())) - return vec[i].first.second; + if (XmlContainsTag(att, v.second[j].c_str())) + return v.first.second; } } else { - return vec[i].first.second; + return v.first.second; } } } diff --git a/Source/EmberCL/IterOpenCLKernelCreator.cpp b/Source/EmberCL/IterOpenCLKernelCreator.cpp index ba74658..fd3773d 100644 --- a/Source/EmberCL/IterOpenCLKernelCreator.cpp +++ b/Source/EmberCL/IterOpenCLKernelCreator.cpp @@ -55,7 +55,7 @@ string IterOpenCLKernelCreator::CreateIterKernelString(Ember& ember, strin xformFuncs << "\n" << parVarDefines << endl; ember.GetPresentVariations(variations); - ForEach(variations, [&](Variation* var) { if (var) xformFuncs << var->OpenCLFuncsString(); }); + for (auto var : variations) if (var) xformFuncs << var->OpenCLFuncsString(); for (i = 0; i < totalXformCount; i++) { diff --git a/Source/EmberCL/OpenCLWrapper.cpp b/Source/EmberCL/OpenCLWrapper.cpp index 4135bc6..a73d96d 100644 --- a/Source/EmberCL/OpenCLWrapper.cpp +++ b/Source/EmberCL/OpenCLWrapper.cpp @@ -96,11 +96,11 @@ bool OpenCLWrapper::AddProgram(const string& name, const string& program, const if (CreateSPK(name, program, entryPoint, spk, doublePrecision)) { - for (size_t i = 0; i < m_Programs.size(); i++) + for (auto& program : m_Programs) { - if (name == m_Programs[i].m_Name) + if (name == program.m_Name) { - m_Programs[i] = spk; + program = spk; return true; } } diff --git a/Source/EmberCL/RendererCL.cpp b/Source/EmberCL/RendererCL.cpp index a6da5a4..4aa0e2a 100644 --- a/Source/EmberCL/RendererCL.cpp +++ b/Source/EmberCL/RendererCL.cpp @@ -1483,10 +1483,10 @@ void RendererCL::FillSeeds() { m_Seeds.resize(IterGridKernelCount()); - for (size_t i = 0; i < m_Seeds.size(); i++) + for (auto& seed : m_Seeds) { - m_Seeds[i].x = m_Rand[0].Rand(); - m_Seeds[i].y = m_Rand[0].Rand(); + seed.x = m_Rand[0].Rand(); + seed.y = m_Rand[0].Rand(); } } diff --git a/Source/EmberCommon/EmberOptions.h b/Source/EmberCommon/EmberOptions.h index a63c742..39e2b49 100644 --- a/Source/EmberCommon/EmberOptions.h +++ b/Source/EmberCommon/EmberOptions.h @@ -550,11 +550,11 @@ public: CSimpleOpt::SOption endOption = SO_END_OF_OPTIONS; entries.reserve(75); - ForEach(m_BoolArgs, [&](Eob* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); }); - ForEach(m_IntArgs, [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); }); - ForEach(m_UintArgs, [&](Eou* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); }); - ForEach(m_DoubleArgs, [&](Eod* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); }); - ForEach(m_StringArgs, [&](Eos* entry) { if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); }); + for (auto entry : m_BoolArgs) if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); + for (auto entry : m_IntArgs) if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); + for (auto entry : m_UintArgs) if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); + for (auto entry : m_DoubleArgs) if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); + for (auto entry : m_StringArgs) if (entry->m_OptionUse & optUsage) entries.push_back(entry->m_Option); entries.push_back(endOption); return entries; @@ -569,11 +569,11 @@ public: { ostringstream os; - ForEach(m_BoolArgs, [&](Eob* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; }); - ForEach(m_IntArgs, [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; }); - ForEach(m_UintArgs, [&](Eou* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; }); - ForEach(m_DoubleArgs, [&](Eod* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; }); - ForEach(m_StringArgs, [&](Eos* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; }); + for (auto entry : m_BoolArgs) if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; + for (auto entry : m_IntArgs) if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; + for (auto entry : m_UintArgs) if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; + for (auto entry : m_DoubleArgs) if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; + for (auto entry : m_StringArgs) if (entry->m_OptionUse & optUsage) os << entry->m_DocString << endl; return os.str(); } @@ -588,11 +588,11 @@ public: ostringstream os; os << std::boolalpha; - ForEach(m_BoolArgs, [&](Eob* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; }); - ForEach(m_IntArgs, [&](Eoi* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; }); - ForEach(m_UintArgs, [&](Eou* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; }); - ForEach(m_DoubleArgs, [&](Eod* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; }); - ForEach(m_StringArgs, [&](Eos* entry) { if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; }); + for (auto entry : m_BoolArgs) if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; + for (auto entry : m_IntArgs) if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; + for (auto entry : m_UintArgs) if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; + for (auto entry : m_DoubleArgs) if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; + for (auto entry : m_StringArgs) if (entry->m_OptionUse & optUsage) os << entry->m_NameWithoutDashes << ": " << (*entry)() << endl; return os.str(); } diff --git a/Source/EmberTester/EmberTester.cpp b/Source/EmberTester/EmberTester.cpp index 66b1ddc..f386f0f 100644 --- a/Source/EmberTester/EmberTester.cpp +++ b/Source/EmberTester/EmberTester.cpp @@ -1317,7 +1317,7 @@ void TestVarTime() } std::sort(times.begin(), times.end(), &SortPairByTime); - //ForEach(times, [&](pair& p) { cout << p.first << "\t" << p.second << "" << endl; }); + //forr (auto& p : times) cout << p.first << "\t" << p.second << "" << endl; } void TestCasting() diff --git a/Source/Fractorium/FinalRenderDialog.cpp b/Source/Fractorium/FinalRenderDialog.cpp index c526ed1..7c20b60 100644 --- a/Source/Fractorium/FinalRenderDialog.cpp +++ b/Source/Fractorium/FinalRenderDialog.cpp @@ -385,8 +385,8 @@ void FractoriumFinalRenderDialog::OnPlatformComboCurrentIndexChanged(int index) ui.FinalRenderDeviceCombo->clear(); - for (size_t i = 0; i < devices.size(); i++) - ui.FinalRenderDeviceCombo->addItem(QString::fromStdString(devices[i])); + for (auto& device : devices) + ui.FinalRenderDeviceCombo->addItem(QString::fromStdString(device)); } /// diff --git a/Source/Fractorium/FinalRenderEmberController.cpp b/Source/Fractorium/FinalRenderEmberController.cpp index 91bdd9f..f94fcc3 100644 --- a/Source/Fractorium/FinalRenderEmberController.cpp +++ b/Source/Fractorium/FinalRenderEmberController.cpp @@ -522,8 +522,8 @@ void FinalRenderEmberController::SyncGuiToEmbers(size_t widthOverride, size_t { if (m_FinalRenderDialog->ApplyToAll()) { - for (size_t i = 0; i < m_EmberFile.Size(); i++) - SyncGuiToEmber(m_EmberFile.m_Embers[i], widthOverride, heightOverride); + for (auto& ember : m_EmberFile.m_Embers) + SyncGuiToEmber(ember, widthOverride, heightOverride); } else { diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index 734728a..96bc709 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -139,7 +139,7 @@ Fractorium::Fractorium(QWidget* p) ui.GeometryTable->setStyleSheet("QTableWidget::item { padding: 1px; }"); ui.FilterTable->setStyleSheet("QTableWidget::item { padding: 1px; }"); ui.IterationTable->setStyleSheet("QTableWidget::item { padding: 1px; }"); - ui.AffineTab->setStyleSheet("QTableWidget::item { padding: 1px; }"); + ui.XformAffineTab->setStyleSheet("QTableWidget::item { padding: 1px; }"); ui.XformWeightNameTable->setStyleSheet("QTableWidget::item { padding: 0px; }"); ui.XformColorIndexTable->setStyleSheet("QTableWidget::item { padding: 1px; }"); ui.XformColorValuesTable->setStyleSheet("QTableWidget::item { padding: 1px; }"); @@ -153,8 +153,6 @@ Fractorium::Fractorium(QWidget* p) SetCoordinateStatus(0, 0, 0, 0); SetTabOrders(); - ui.GLParentScrollArea->installEventFilter(this); - //At this point, everything has been setup except the renderer. Shortly after //this constructor exits, GLWidget::InitGL() will create the initial flock and start the rendering timer //which executes whenever the program is idle. Upon starting the timer, the renderer @@ -278,11 +276,17 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) { m_WidthSpin->DoubleClickNonZero(ui.GLParentScrollArea->width()); m_HeightSpin->DoubleClickNonZero(ui.GLParentScrollArea->height()); - //qDebug() << "scroll area resized"; } - else if (o == ui.LibraryTree) + else if (QKeyEvent* ke = dynamic_cast(e)) { - if (QKeyEvent* ke = dynamic_cast(e)) + if (ke->key() >= Qt::Key_F1 && ke->key() <= Qt::Key_F32) + { + int val = ke->key() - (int)Qt::Key_F1; + + if (val < ui.CurrentXformCombo->count()) + ui.CurrentXformCombo->setCurrentIndex(val); + } + else if (o == ui.LibraryTree) { if (ke->key() == Qt::Key_Delete && e->type() == QEvent::KeyRelease) { @@ -401,10 +405,10 @@ void Fractorium::dropEvent(QDropEvent* e) /// The signal the combo box emits /// The slot to receive the signal /// Type of the connection. Default: Qt::QueuedConnection. -void Fractorium::SetupCombo(QTableWidget* table, const QObject* receiver, int& row, int col, StealthComboBox*& comboBox, vector& vals, const char* signal, const char* slot, Qt::ConnectionType connectionType) +void Fractorium::SetupCombo(QTableWidget* table, const QObject* receiver, int& row, int col, StealthComboBox*& comboBox, const vector& vals, const char* signal, const char* slot, Qt::ConnectionType connectionType) { comboBox = new StealthComboBox(table); - ForEach(vals, [&](const string& s) { comboBox->addItem(s.c_str()); }); + for (auto& s : vals) comboBox->addItem(s.c_str()); table->setCellWidget(row, col, comboBox); connect(comboBox, signal, receiver, slot, connectionType); row++; diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index b68c798..992b0c6 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -249,6 +249,8 @@ public slots: void OnXaosChanged(double d); void OnClearXaosButtonClicked(bool checked); void OnRandomXaosButtonClicked(bool checked); + void OnXaosRowDoubleClicked(int logicalIndex); + void OnXaosColDoubleClicked(int logicalIndex); //Palette. void OnPaletteFilenameComboChanged(const QString& text); @@ -271,7 +273,7 @@ public: //template//See below. //static void SetupSpinner(QTableWidget* table, const QObject* receiver, int& row, int col, spinType*& spinBox, int height, valType min, valType max, valType step, const char* signal, const char* slot, bool incRow = true, valType val = 0, valType doubleClickZero = -999, valType doubleClickNonZero = -999); static void SetupAffineSpinner(QTableWidget* table, const QObject* receiver, int row, int col, DoubleSpinBox*& spinBox, int height, double min, double max, double step, double prec, const char* signal, const char* slot); - static void SetupCombo(QTableWidget* table, const QObject* receiver, int& row, int col, StealthComboBox*& comboBox, vector& vals, const char* signal, const char* slot, Qt::ConnectionType connectionType = Qt::QueuedConnection); + static void SetupCombo(QTableWidget* table, const QObject* receiver, int& row, int col, StealthComboBox*& comboBox, const vector& vals, const char* signal, const char* slot, Qt::ConnectionType connectionType = Qt::QueuedConnection); static void SetFixedTableHeader(QHeaderView* header, QHeaderView::ResizeMode mode = QHeaderView::Fixed); static int FlipDet(Affine2D& affine); diff --git a/Source/Fractorium/Fractorium.ui b/Source/Fractorium/Fractorium.ui index f279ce6..fece377 100644 --- a/Source/Fractorium/Fractorium.ui +++ b/Source/Fractorium/Fractorium.ui @@ -239,7 +239,7 @@ 6 - + 4 @@ -379,7 +379,7 @@ 4 - + QFrame::NoFrame @@ -392,7 +392,7 @@ true - + 0 @@ -489,7 +489,7 @@ 4 - + QFrame::NoFrame @@ -499,7 +499,7 @@ true - + 0 @@ -1509,7 +1509,7 @@ - + Qt::Vertical @@ -1525,7 +1525,7 @@ - + Qt::Vertical @@ -1831,7 +1831,7 @@ - + Qt::Vertical @@ -1847,7 +1847,7 @@ - + Qt::Vertical @@ -1954,7 +1954,7 @@ SpinBox 2 - + 0 @@ -2509,7 +2509,7 @@ SpinBox - + Curve @@ -2575,7 +2575,7 @@ SpinBox - + 0 @@ -2608,7 +2608,7 @@ SpinBox 5 - + true @@ -2621,7 +2621,7 @@ SpinBox true - + 0 @@ -3921,7 +3921,7 @@ SpinBox - + Qt::Vertical @@ -3942,7 +3942,7 @@ SpinBox - + Full list of available variations and their weights for the currently selected xform. @@ -3963,7 +3963,7 @@ SpinBox 6 - + 5 @@ -4015,7 +4015,7 @@ SpinBox - Qt::StrongFocus + Qt::WheelFocus Qt::DefaultContextMenu @@ -4173,10 +4173,13 @@ SpinBox - + Select multiple xforms to apply operations to. + + true + Select @@ -4218,6 +4221,9 @@ SpinBox 0 + + true + Select Xforms @@ -4248,6 +4254,9 @@ SpinBox 0 + + true + QFrame::NoFrame @@ -4320,7 +4329,7 @@ SpinBox - + 2 @@ -4845,7 +4854,7 @@ SpinBox - + @@ -5186,7 +5195,7 @@ SpinBox - + 4 @@ -5280,7 +5289,7 @@ SpinBox 4 - + 0 @@ -5302,7 +5311,7 @@ SpinBox true - + 0 @@ -6127,7 +6136,7 @@ SpinBox SaveCurrentToOpenedFileButton ParamsTabWidget LibraryTree - scrollArea + FlameTabScrollArea CurrentXformCombo AddXformButton DuplicateXformButton @@ -6140,7 +6149,7 @@ SpinBox XformColorScroll XformColorValuesTable SoloXformCheckBox - scrollArea_3 + AffineTabScrollArea PreAffineTable PreFlipVerticalButton PreResetButton @@ -6186,13 +6195,13 @@ SpinBox VariationsTree PaletteAdjustTable PaletteListTable - scrollArea_5 + InfoTabScrollArea InfoFileOpeningGroupBox InfoFileOpeningTextEdit InfoRenderingGroupBox InfoRenderingTextEdit PreAffineGroupBox - scrollArea_4 + LibraryTabScrollArea InfoBoundsGroupBox diff --git a/Source/Fractorium/FractoriumEmberController.h b/Source/Fractorium/FractoriumEmberController.h index db9dd5a..32653b6 100644 --- a/Source/Fractorium/FractoriumEmberController.h +++ b/Source/Fractorium/FractoriumEmberController.h @@ -158,7 +158,7 @@ public: virtual void XformWeightChanged(double d) { } virtual void EqualizeWeights() { } virtual void XformNameChanged(int row, int col) { } - virtual void FillXforms() { } + virtual void FillXforms(int index = 0) { } //Xforms Affine. virtual void AffineSetHelper(double d, int index, bool pre) { } @@ -387,7 +387,7 @@ public: virtual void XformWeightChanged(double d) override; virtual void EqualizeWeights() override; virtual void XformNameChanged(int row, int col) override; - virtual void FillXforms() override; + virtual void FillXforms(int index = 0) override; void FillWithXform(Xform* xform); Xform* CurrentXform(); @@ -421,7 +421,7 @@ public: virtual void XaosChanged(DoubleSpinBox* sender) override; virtual void ClearXaos() override; virtual void RandomXaos() override; - + //Palette. virtual int InitPaletteList(const string& s) override; virtual bool FillPaletteTable(const string& s) override; diff --git a/Source/Fractorium/FractoriumInfo.cpp b/Source/Fractorium/FractoriumInfo.cpp index 085c3f2..c0d014a 100644 --- a/Source/Fractorium/FractoriumInfo.cpp +++ b/Source/Fractorium/FractoriumInfo.cpp @@ -51,6 +51,6 @@ void Fractorium::ErrorReportToQTextEdit(const vector& errors, QTextEdit* if (clear) QMetaObject::invokeMethod(textEdit, "clear", Qt::QueuedConnection); - for (size_t i = 0; i < errors.size(); i++) - QMetaObject::invokeMethod(textEdit, "append", Qt::QueuedConnection, Q_ARG(const QString&, QString::fromStdString(errors[i]) + "\n")); + for (auto& error : errors) + QMetaObject::invokeMethod(textEdit, "append", Qt::QueuedConnection, Q_ARG(const QString&, QString::fromStdString(error) + "\n")); } diff --git a/Source/Fractorium/FractoriumLibrary.cpp b/Source/Fractorium/FractoriumLibrary.cpp index c759630..d63e40b 100644 --- a/Source/Fractorium/FractoriumLibrary.cpp +++ b/Source/Fractorium/FractoriumLibrary.cpp @@ -9,7 +9,6 @@ void Fractorium::InitLibraryUI() connect(ui.LibraryTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(OnEmberTreeItemChanged(QTreeWidgetItem*, int)), Qt::QueuedConnection); connect(ui.LibraryTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(OnEmberTreeItemDoubleClicked(QTreeWidgetItem*, int)), Qt::QueuedConnection); connect(ui.LibraryTree, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(OnEmberTreeItemDoubleClicked(QTreeWidgetItem*, int)), Qt::QueuedConnection); - ui.LibraryTree->installEventFilter(this);//Needed for keypress events other than enter. } diff --git a/Source/Fractorium/FractoriumMenus.cpp b/Source/Fractorium/FractoriumMenus.cpp index 8ae234a..bb86d20 100644 --- a/Source/Fractorium/FractoriumMenus.cpp +++ b/Source/Fractorium/FractoriumMenus.cpp @@ -323,8 +323,8 @@ void FractoriumEmberController::SaveEntireFileAsXml() SaveCurrentToOpenedFile();//Save the current ember back to the opened file before writing to disk. emberFile = m_EmberFile; - for (size_t i = 0; i < emberFile.Size(); i++) - ApplyXmlSavingTemplate(emberFile.m_Embers[i]); + for (auto& ember : emberFile.m_Embers) + ApplyXmlSavingTemplate(ember); if (writer.Save(filename.toStdString().c_str(), emberFile.m_Embers, 0, true, false, true)) { @@ -479,9 +479,9 @@ void FractoriumEmberController::CopyAllXml() os << "\n"; - for (size_t i = 0; i < m_EmberFile.Size(); i++) + for (auto& e : m_EmberFile.m_Embers) { - Ember ember = m_EmberFile.m_Embers[i]; + Ember ember = e; ApplyXmlSavingTemplate(ember); os << emberToXml.ToString(ember, "", 0, false, false, true); @@ -621,8 +621,8 @@ void FractoriumEmberController::AddReflectiveSymmetry() Update([&]() { m_Ember.AddSymmetry(-1, m_Rand); - FillXforms(); - combo->setCurrentIndex(combo->count() - (m_Fractorium->HaveFinal() ? 2 : 1));//Set index to the last item before final. + int index = m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1);//Set index to the last item before final. + FillXforms(index); }); } @@ -640,8 +640,8 @@ void FractoriumEmberController::AddRotationalSymmetry() Update([&]() { m_Ember.AddSymmetry(2, m_Rand); - FillXforms(); - combo->setCurrentIndex(combo->count() - (m_Fractorium->HaveFinal() ? 2 : 1));//Set index to the last item before final. + int index = m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1);//Set index to the last item before final. + FillXforms(index); }); } @@ -659,8 +659,8 @@ void FractoriumEmberController::AddBothSymmetry() Update([&]() { m_Ember.AddSymmetry(-2, m_Rand); - FillXforms(); - combo->setCurrentIndex(combo->count() - (m_Fractorium->HaveFinal() ? 2 : 1));//Set index to the last item before final. + int index = m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1);//Set index to the last item before final. + FillXforms(index); }); } @@ -705,7 +705,6 @@ void FractoriumEmberController::ClearFlame() } FillXforms(); - m_Fractorium->ui.CurrentXformCombo->setCurrentIndex(0); }); } diff --git a/Source/Fractorium/FractoriumRender.cpp b/Source/Fractorium/FractoriumRender.cpp index 1d428e6..ea2cba6 100644 --- a/Source/Fractorium/FractoriumRender.cpp +++ b/Source/Fractorium/FractoriumRender.cpp @@ -212,9 +212,9 @@ eProcessAction FractoriumEmberControllerBase::CondenseAndClearProcessActions() m_Cs.Enter(); eProcessAction action = NOTHING; - for (size_t i = 0; i < m_ProcessActions.size(); i++) - if (m_ProcessActions[i] > action) - action = m_ProcessActions[i]; + for (auto a : m_ProcessActions) + if (a > action) + action = a; m_ProcessActions.clear(); m_Cs.Leave(); @@ -492,6 +492,7 @@ bool FractoriumEmberController::Render() //Upon finishing, or having nothing to do, rest. if (ProcessState() == ACCUM_DONE) QThread::msleep(1); + //QApplication::processEvents(); m_Rendering = false; return success; diff --git a/Source/Fractorium/FractoriumXaos.cpp b/Source/Fractorium/FractoriumXaos.cpp index d72f278..6fceac7 100644 --- a/Source/Fractorium/FractoriumXaos.cpp +++ b/Source/Fractorium/FractoriumXaos.cpp @@ -6,8 +6,15 @@ /// void Fractorium::InitXaosUI() { + ui.XaosTable->verticalHeader()->setVisible(true); + ui.XaosTable->horizontalHeader()->setVisible(true); + ui.XaosTable->verticalHeader()->setSectionsClickable(true); + ui.XaosTable->horizontalHeader()->setSectionsClickable(true); + connect(ui.ClearXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnClearXaosButtonClicked(bool)), Qt::QueuedConnection); connect(ui.RandomXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomXaosButtonClicked(bool)), Qt::QueuedConnection); + connect(ui.XaosTable->verticalHeader(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(OnXaosRowDoubleClicked(int)), Qt::QueuedConnection); + connect(ui.XaosTable->horizontalHeader(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(OnXaosColDoubleClicked(int)), Qt::QueuedConnection); } /// @@ -92,11 +99,6 @@ void Fractorium::FillXaosTable() ui.XaosTable->setRowCount(count);//This will grow or shrink the number of rows and call the destructor for previous DoubleSpinBoxes. ui.XaosTable->setColumnCount(count); - ui.XaosTable->verticalHeader()->setVisible(true); - ui.XaosTable->horizontalHeader()->setVisible(true); - ui.XaosTable->verticalHeader()->setSectionsClickable(false); - ui.XaosTable->horizontalHeader()->setSectionsClickable(false); - for (int i = 0; i < count; i++) { for (int j = 0; j < count; j++) @@ -159,7 +161,6 @@ void Fractorium::OnClearXaosButtonClicked(bool checked) { m_Controller->ClearXao /// 50% that they're 0-3. /// Resets the rendering process. /// -/// Ignored template void FractoriumEmberController::RandomXaos() { @@ -185,6 +186,78 @@ void FractoriumEmberController::RandomXaos() void Fractorium::OnRandomXaosButtonClicked(bool checked) { m_Controller->RandomXaos(); } +/// +/// Toggle all xaos values in one row. +/// The logic is: +/// If any cell in the row is non zero, set all cells to zero, else 1. +/// If shift is held down, reverse the logic. +/// Resets the rendering process. +/// +/// The index of the row that was double clicked +void Fractorium::OnXaosRowDoubleClicked(int logicalIndex) +{ + bool allZero = true; + int cols = ui.XaosTable->columnCount(); + bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier); + + for (int i = 0; i < cols; i++) + { + if (auto* spinBox = dynamic_cast(ui.XaosTable->cellWidget(logicalIndex, i))) + { + if (!IsNearZero(spinBox->value())) + { + allZero = false; + break; + } + } + } + + if (shift) + allZero = !allZero; + + double val = allZero ? 1.0 : 0.0; + + for (int i = 0; i < cols; i++) + if (auto* spinBox = dynamic_cast(ui.XaosTable->cellWidget(logicalIndex, i))) + spinBox->setValue(val); +} + +/// +/// Toggle all xaos values in one column. +/// The logic is: +/// If any cell in the column is non zero, set all cells to zero, else 1. +/// If shift is held down, reverse the logic. +/// Resets the rendering process. +/// +/// The index of the column that was double clicked +void Fractorium::OnXaosColDoubleClicked(int logicalIndex) +{ + bool allZero = true; + int rows = ui.XaosTable->rowCount(); + bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier); + + for (int i = 0; i < rows; i++) + { + if (auto* spinBox = dynamic_cast(ui.XaosTable->cellWidget(i, logicalIndex))) + { + if (!IsNearZero(spinBox->value())) + { + allZero = false; + break; + } + } + } + + if (shift) + allZero = !allZero; + + double val = allZero ? 1.0 : 0.0; + + for (int i = 0; i < rows; i++) + if (auto* spinBox = dynamic_cast(ui.XaosTable->cellWidget(i, logicalIndex))) + spinBox->setValue(val); +} + template class FractoriumEmberController; #ifdef DO_DOUBLE diff --git a/Source/Fractorium/FractoriumXforms.cpp b/Source/Fractorium/FractoriumXforms.cpp index 4b3e1e8..b2105aa 100644 --- a/Source/Fractorium/FractoriumXforms.cpp +++ b/Source/Fractorium/FractoriumXforms.cpp @@ -109,8 +109,8 @@ void FractoriumEmberController::AddXform() newXform.m_Weight = 0.25; newXform.m_ColorX = m_Rand.Frand01(); m_Ember.AddXform(newXform); - FillXforms(); - combo->setCurrentIndex(combo->count() - (m_Fractorium->HaveFinal() ? 2 : 1));//Set index to the last item before final. + int index = m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1);//Set index to the last item before final. + FillXforms(index); }); } @@ -141,8 +141,8 @@ void FractoriumEmberController::DuplicateXform() for (auto& it : vec) m_Ember.AddXform(it); - FillXforms();//Handles xaos. - combo->setCurrentIndex(combo->count() - (m_Fractorium->HaveFinal() ? 2 : 1));//Set index to the last item before final. + int index = m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1);//Set index to the last item before final. + FillXforms(index);//Handles xaos. }); } @@ -224,8 +224,8 @@ void FractoriumEmberController::DeleteXforms() if (offset) { - FillXforms(); - combo->setCurrentIndex(combo->count() - (m_Ember.UseFinalXform() ? 2 : 1));//Set index to the last item before final. Note final is requeried one last time. + int index = m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1);//Set index to the last item before final. Note final is requeried one last time. + FillXforms(index); UpdateRender(); } } @@ -252,8 +252,8 @@ void FractoriumEmberController::AddFinalXform() final.AddVariation(new LinearVariation());//Just a placeholder so other parts of the code don't see it as being empty. m_Ember.SetFinalXform(final); - FillXforms(); - combo->setCurrentIndex(combo->count() - 1);//Set index to the last item. + int index = m_Ember.TotalXformCount() - 1;//Set index to the last item. + FillXforms(index); }); } } @@ -374,12 +374,13 @@ bool FractoriumEmberController::IsFinal(Xform* xform) /// /// Fill the xforms combo box with the xforms in the current ember. -/// Select the first one and fill all widgets with its values. +/// Select the index passed in and fill all widgets with its values. /// Also dynamically generate a checkbox for each xform which will allow the user /// to select which xforms to apply operations to. /// +/// The index to select after populating, default 0. template -void FractoriumEmberController::FillXforms() +void FractoriumEmberController::FillXforms(int index) { int i = 0, count = int(XformCount()); auto combo = m_Fractorium->ui.CurrentXformCombo; @@ -435,11 +436,13 @@ void FractoriumEmberController::FillXforms() m_Fractorium->m_XformsSelectionLayout->blockSignals(false); combo->blockSignals(false); - combo->setCurrentIndex(0); + + if (index < combo->count()) + combo->setCurrentIndex(index); m_Fractorium->FillXaosTable(); m_Fractorium->OnSoloXformCheckBoxStateChanged(Qt::Unchecked); - m_Fractorium->OnCurrentXformComboChanged(0);//Make sure the event gets called, because it won't if the zero index is already selected. + m_Fractorium->OnCurrentXformComboChanged(index);//Make sure the event gets called, because it won't if the zero index is already selected. } template class FractoriumEmberController; diff --git a/Source/Fractorium/FractoriumXformsVariations.cpp b/Source/Fractorium/FractoriumXformsVariations.cpp index e934aae..cae22a7 100644 --- a/Source/Fractorium/FractoriumXformsVariations.cpp +++ b/Source/Fractorium/FractoriumXformsVariations.cpp @@ -64,7 +64,7 @@ void FractoriumEmberController::SetupVariationTree() { ParamWithName* params = parVar->Params(); - for (size_t j = 0; j< parVar->ParamCount(); j++) + for (size_t j = 0; j < parVar->ParamCount(); j++) { if (!params[j].IsPrecalc()) { diff --git a/Source/Fractorium/Main.cpp b/Source/Fractorium/Main.cpp index 31709dc..1b7c566 100644 --- a/Source/Fractorium/Main.cpp +++ b/Source/Fractorium/Main.cpp @@ -46,6 +46,7 @@ int main(int argc, char *argv[]) Fractorium w; w.show(); + a.installEventFilter(&w); return a.exec(); } diff --git a/Source/Fractorium/OptionsDialog.cpp b/Source/Fractorium/OptionsDialog.cpp index ecb68b4..90f8953 100644 --- a/Source/Fractorium/OptionsDialog.cpp +++ b/Source/Fractorium/OptionsDialog.cpp @@ -134,8 +134,8 @@ void FractoriumOptionsDialog::OnPlatformComboCurrentIndexChanged(int index) ui.DeviceCombo->clear(); - for (size_t i = 0; i < devices.size(); i++) - ui.DeviceCombo->addItem(QString::fromStdString(devices[i])); + for (auto& device : devices) + ui.DeviceCombo->addItem(QString::fromStdString(device)); if (ui.PlatformCombo->currentIndex() == m_Settings->PlatformIndex()) ui.DeviceCombo->setCurrentIndex(m_Settings->DeviceIndex());