diff --git a/Source/Ember/Ember.cpp b/Source/Ember/Ember.cpp index cc7272d..f12c822 100644 --- a/Source/Ember/Ember.cpp +++ b/Source/Ember/Ember.cpp @@ -489,7 +489,7 @@ uint Timing::m_ProcessorCount; EXPORTPREPOSTREGVAR(Waves42, T) \ EXPORTPREPOSTREGVAR(Waves3, T) \ EXPORTPREPOSTREGVAR(Waves4, T) \ - EXPORTPREPOSTREGVAR(Gnarly, T) \ + EXPORTPREPOSTREGVAR(Gnarly, T) \ template EMBER_API class VariationList; \ template EMBER_API class SpatialFilter; \ template EMBER_API class GaussianFilter; \ diff --git a/Source/Ember/Variation.h b/Source/Ember/Variation.h index eebd67f..1ea0f88 100644 --- a/Source/Ember/Variation.h +++ b/Source/Ember/Variation.h @@ -212,7 +212,7 @@ enum class eVariationId : et VAR_GLYNNSIM3 , VAR_GLYNNSIM4 , VAR_GLYNNSIM5 , - VAR_GNARLY , + VAR_GNARLY, VAR_GRIDOUT , VAR_HANDKERCHIEF, VAR_HEART , @@ -313,7 +313,7 @@ enum class eVariationId : et VAR_PIE3D , VAR_PIXEL_FLOW , VAR_POINCARE , - VAR_POINCARE2 , + VAR_POINCARE2 , VAR_POINCARE3D , VAR_POINT_SYMMETRY, VAR_POLAR , @@ -627,7 +627,7 @@ enum class eVariationId : et VAR_PRE_GLYNNSIM3, VAR_PRE_GLYNNSIM4, VAR_PRE_GLYNNSIM5, - VAR_PRE_GNARLY, + VAR_PRE_GNARLY, VAR_PRE_GRIDOUT, VAR_PRE_HANDKERCHIEF, VAR_PRE_HEART, @@ -728,7 +728,7 @@ enum class eVariationId : et VAR_PRE_PIE3D, VAR_PRE_PIXEL_FLOW, VAR_PRE_POINCARE, - VAR_PRE_POINCARE2, + VAR_PRE_POINCARE2, VAR_PRE_POINCARE3D, VAR_PRE_POINT_SYMMETRY, VAR_PRE_POLAR, @@ -1041,7 +1041,7 @@ enum class eVariationId : et VAR_POST_GLYNNSIM3, VAR_POST_GLYNNSIM4, VAR_POST_GLYNNSIM5, - VAR_POST_GNARLY, + VAR_POST_GNARLY, VAR_POST_GRIDOUT, VAR_POST_HANDKERCHIEF, VAR_POST_HEART, @@ -1142,7 +1142,7 @@ enum class eVariationId : et VAR_POST_PIE3D, VAR_POST_PIXEL_FLOW, VAR_POST_POINCARE, - VAR_POST_POINCARE2, + VAR_POST_POINCARE2, VAR_POST_POINCARE3D, VAR_POST_POINT_SYMMETRY, VAR_POST_POLAR, diff --git a/Source/Ember/VariationList.cpp b/Source/Ember/VariationList.cpp index cd11bd6..1ef167a 100644 --- a/Source/Ember/VariationList.cpp +++ b/Source/Ember/VariationList.cpp @@ -172,7 +172,7 @@ VariationList::VariationList() ADDPREPOSTREGVAR(NPolar) ADDPREPOSTREGVAR(Ortho) ADDPREPOSTREGVAR(Poincare) - ADDPREPOSTREGVAR(Poincare2) + ADDPREPOSTREGVAR(Poincare2) ADDPREPOSTREGVAR(Poincare3D) ADDPREPOSTREGVAR(Polynomial) ADDPREPOSTREGVAR(PSphere) @@ -429,7 +429,7 @@ VariationList::VariationList() ADDPREPOSTREGVAR(Waves3) ADDPREPOSTREGVAR(Waves4) ADDPREPOSTREGVAR(Waves42) - ADDPREPOSTREGVAR(Gnarly) + ADDPREPOSTREGVAR(Gnarly) //ADDPREPOSTREGVAR(LinearXZ) //ADDPREPOSTREGVAR(LinearYZ) //DC are special. diff --git a/Source/Ember/Variations02.h b/Source/Ember/Variations02.h index b974b08..2ccf6cc 100644 --- a/Source/Ember/Variations02.h +++ b/Source/Ember/Variations02.h @@ -4502,89 +4502,86 @@ template class Poincare2Variation : public ParametricVariation { public: - Poincare2Variation(T weight = 1.0) : ParametricVariation("poincare2", eVariationId::VAR_POINCARE2, weight) - { - Init(); - } + Poincare2Variation(T weight = 1.0) : ParametricVariation("poincare2", eVariationId::VAR_POINCARE2, weight) + { + Init(); + } - PARVARCOPY(Poincare2Variation) + PARVARCOPY(Poincare2Variation) - virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override - { - T a = helper.In.x - m_Cx; - T b = helper.In.y - m_Cy; - T c = 1 - m_Cx * helper.In.x - m_Cy * helper.In.y; - T d = m_Cy * helper.In.x - m_Cx * helper.In.y; + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T a = helper.In.x - m_Cx; + T b = helper.In.y - m_Cy; + T c = 1 - m_Cx * helper.In.x - m_Cy * helper.In.y; + T d = m_Cy * helper.In.x - m_Cx * helper.In.y; + T num = m_Weight / Zeps(c * c + d * d); + helper.Out.x = (a * c + b * d) * num; + helper.Out.y = (b * c - a * d) * num; + helper.Out.z = DefaultZ(helper); + } - T num = m_Weight / Zeps(c * c + d * d); - - helper.Out.x = (a * c + b * d) * num; - helper.Out.y = (b * c - a * d) * num; - helper.Out.z = DefaultZ(helper); - } - - virtual string OpenCLString() const override - { - ostringstream ss, ss2; - intmax_t i = 0; - ss2 << "_" << XformIndexInEmber() << "]"; - string index = ss2.str(); - string weight = WeightDefineString(); - string cP = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cQ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string cY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - - ss << "\t{\n" - << "\t\treal_t a = vIn.x - " << cX << ";\n" - << "\t\treal_t b = vIn.y - " << cY << ";\n" - << "\t\treal_t c = 1 - " << cX << " * vIn.x - " << cY << " * vIn.y;\n" - << "\t\treal_t d = " << cY <<" * vIn.x - " << cX << " * vIn.y;\n" - << "\t\treal_t num = " << weight <<" / Zeps(c * c + d * d);\n" - << "\n" - << "\t\tvOut.x = (a * c + b * d) * num;\n" - << "\t\tvOut.y = (b * c - a * d) * num;\n" - << "\t\tvOut.z = " << DefaultZCl() - << "\t}\n"; - return ss.str(); - } + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0; + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string cP = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cQ = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cX = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string cY = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t a = vIn.x - " << cX << ";\n" + << "\t\treal_t b = vIn.y - " << cY << ";\n" + << "\t\treal_t c = 1 - " << cX << " * vIn.x - " << cY << " * vIn.y;\n" + << "\t\treal_t d = fma(" << cY << ", vIn.x, -(" << cX << " * vIn.y));\n" + << "\t\treal_t num = " << weight << " / Zeps(fma(c, c, d * d));\n" + << "\n" + << "\t\tvOut.x = fma(a, c, b * d) * num;\n" + << "\t\tvOut.y = fma(b, c, -(a * d)) * num;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } virtual vector OpenCLGlobalFuncNames() const override { return vector { "Zeps" }; } - - virtual void Precalc() override - { - T a0 = M_2PI / m_PoincareP; - T dist2 = 1 - (std::cos(a0) - 1) / (std::cos(a0) + std::cos(M_2PI / m_PoincareQ)); - T dist = (dist2 > 0) ? T(1) / std::sqrt(dist2) : T(1); - if (1 / m_PoincareP + 1 / m_PoincareQ < T(0.5)) - { - m_Cx = std::cos(a0) * dist; - m_Cy = std::sin(a0) * dist; - } - else - m_Cx = m_Cy = 0; - } + virtual void Precalc() override + { + T a0 = M_2PI / m_PoincareP; + T dist2 = 1 - (std::cos(a0) - 1) / (std::cos(a0) + std::cos(M_2PI / m_PoincareQ)); + T dist = (dist2 > 0) ? T(1) / std::sqrt(dist2) : T(1); + + if (1 / m_PoincareP + 1 / m_PoincareQ < T(0.5)) + { + m_Cx = std::cos(a0) * dist; + m_Cy = std::sin(a0) * dist; + } + else + m_Cx = m_Cy = 0; + } protected: - void Init() - { - string prefix = Prefix(); - m_Params.clear(); - m_Params.push_back(ParamWithName(&m_PoincareP, prefix + "poincare2_p", 3)); - m_Params.push_back(ParamWithName(&m_PoincareQ, prefix + "poincare2_q", 7)); - m_Params.push_back(ParamWithName(true, &m_Cx, prefix + "poincare2_cx"));//Precalc. - m_Params.push_back(ParamWithName(true, &m_Cy, prefix + "poincare2_cy")); - } + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_PoincareP, prefix + "poincare2_p", 3)); + m_Params.push_back(ParamWithName(&m_PoincareQ, prefix + "poincare2_q", 7)); + m_Params.push_back(ParamWithName(true, &m_Cx, prefix + "poincare2_cx"));//Precalc. + m_Params.push_back(ParamWithName(true, &m_Cy, prefix + "poincare2_cy")); + } private: - T m_PoincareP; - T m_PoincareQ; - T m_Cx;//Precalc. - T m_Cy; + T m_PoincareP; + T m_PoincareQ; + T m_Cx;//Precalc. + T m_Cy; }; /// diff --git a/Source/Ember/Variations07.h b/Source/Ember/Variations07.h index 4cdc7b5..75c307c 100644 --- a/Source/Ember/Variations07.h +++ b/Source/Ember/Variations07.h @@ -1108,7 +1108,7 @@ public: T temp, x = helper.In.x / m_Width; bool pos = x > 0; - if (std::cos((pos ? x - (int)x : x + (int)x) * M_PI) < rand.Frand01() * 2 - 1) + if (std::cos((pos ? x - (int)x : x + (int)x) * T(M_PI)) < rand.Frand01() * 2 - 1) temp = pos ? -m_Vwidth : m_Vwidth; else temp = 0; @@ -4280,11 +4280,11 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - v2T z1(helper.In.x, helper.In.y); - v2T z = VarFuncs::RealDivComplex(1.0, z1); - v2T result = VarFuncs::ComplexMultReal(VarFuncs::ComplexLog(VarFuncs::ComplexPlusComplex(z, VarFuncs::ComplexMultComplex(VarFuncs::ComplexSqrt(VarFuncs::ComplexPlusReal(z, 1.0)), VarFuncs::ComplexSqrt(VarFuncs::ComplexMinusReal(z, 1.0))))), m_WeightInvPi); - helper.Out.x = result.x; - helper.Out.y = result.y; + std::complex z(helper.In.x, helper.In.y); + z = T(1.0) / z; + std::complex result = m_WeightInvPi * std::log(z + std::sqrt(z + T(1.0)) * std::sqrt(z - T(1.0))); + helper.Out.x = result.real(); + helper.Out.y = result.imag(); helper.Out.z = DefaultZ(helper); } @@ -4347,19 +4347,19 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - v2T z1(helper.In.x, helper.In.y); - v2T z = VarFuncs::RealDivComplex(1.0, z1); - v2T result = VarFuncs::ComplexMultReal(VarFuncs::ComplexLog(VarFuncs::ComplexPlusComplex(z, VarFuncs::ComplexMultComplex(VarFuncs::ComplexSqrt(VarFuncs::ComplexPlusReal(z, 1.0)), VarFuncs::ComplexSqrt(VarFuncs::ComplexMinusReal(z, 1.0))))), m_WeightInvPi); + std::complex z(helper.In.x, helper.In.y); + z = T(1.0) / z; + std::complex result = m_WeightInvPi * std::log(z + std::sqrt(z + T(1.0)) * std::sqrt(z - T(1.0))); - if (result.y < 0) + if (result.imag() < 0) { - helper.Out.x = result.x; - helper.Out.y = result.y + 1; + helper.Out.x = result.real(); + helper.Out.y = result.imag() + T(1.0); } else { - helper.Out.x = -result.x; - helper.Out.y = result.y - 1; + helper.Out.x = -result.real(); + helper.Out.y = result.imag() - T(1.0); } helper.Out.z = DefaultZ(helper); @@ -4433,10 +4433,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - v2T z(helper.In.x, helper.In.y); - v2T result = VarFuncs::ComplexMultReal(VarFuncs::ComplexLog(VarFuncs::ComplexPlusComplex(z, VarFuncs::ComplexSqrt(VarFuncs::ComplexPlusReal(VarFuncs::ComplexMultComplex(z, z), 1.0)))), m_WeightInvPi); - helper.Out.x = result.x; - helper.Out.y = result.y; + std::complex z(helper.In.x, helper.In.y); + std::complex result = m_WeightInvPi * std::log(z + std::sqrt(z * z + T(1.0))); + helper.Out.x = result.real(); + helper.Out.y = result.imag(); helper.Out.z = DefaultZ(helper); } @@ -4497,11 +4497,10 @@ public: virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override { - v2T z(helper.In.x, helper.In.y); - v2T zm(-helper.In.x, -helper.In.y); - v2T result = VarFuncs::ComplexMultReal(VarFuncs::ComplexLog(VarFuncs::ComplexDivComplex(VarFuncs::ComplexPlusReal(z, 1.0), VarFuncs::ComplexPlusReal(zm, 1.0))), m_WeightInvPi); - helper.Out.x = result.x; - helper.Out.y = result.y; + std::complex z(helper.In.x, helper.In.y); + std::complex result = m_WeightInvPi * std::log((z + T(1.0)) / (-z + T(1.0))); + helper.Out.x = result.real(); + helper.Out.y = result.imag(); helper.Out.z = DefaultZ(helper); } @@ -7083,109 +7082,108 @@ template class GnarlyVariation : public ParametricVariation { public: - GnarlyVariation(T weight = 1.0) : ParametricVariation("gnarly", eVariationId::VAR_GNARLY, weight) - { - Init(); - } + GnarlyVariation(T weight = 1.0) : ParametricVariation("gnarly", eVariationId::VAR_GNARLY, weight) + { + Init(); + } - PARVARCOPY(GnarlyVariation) + PARVARCOPY(GnarlyVariation) - virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override - { - T Vx, Vy; - T Cx, Cy; - T Lx, Ly; - T r, theta, s, c; + virtual void Func(IteratorHelper& helper, Point& outPoint, QTIsaac& rand) override + { + T Vx, Vy; + T Cx, Cy; + T Lx, Ly; + T r, theta, s, c; + Vx = helper.In.x; + Vy = helper.In.y; - Vx = helper.In.x; - Vy = helper.In.y; + if (m_GnarlyCellSize != T(0)) + { + Cx = (Floor(Vx / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize; + Cy = (Floor(Vy / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize; + Lx = Vx - Cx; + Ly = Vy - Cy; - if (m_GnarlyCellSize != T(0)) - { - Cx = (Floor(Vx / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize; - Cy = (Floor(Vy / m_GnarlyCellSize) + T(0.5)) * m_GnarlyCellSize; + if ((Lx * Lx + Ly * Ly) <= m_R2) + { + r = (Lx * Lx + Ly * Ly) / m_R2; + theta = m_GnarlyTwist * std::log(r); + sincos(theta, &s, &c); + Vx = Cx + c * Lx + s * Ly; + Vy = Cy - s * Lx + c * Ly; + } + } - Lx = Vx - Cx; - Ly = Vy - Cy; + helper.Out.x = m_Weight * Vx; + helper.Out.y = m_Weight * Vy; + helper.Out.z = DefaultZ(helper); + } - if ((Lx * Lx + Ly * Ly) <= m_R2) - { - r = (Lx * Lx + Ly * Ly) / m_R2; - theta = m_GnarlyTwist * std::log(r); - sincos(theta, &s, &c); - Vx = Cx + c * Lx + s * Ly; - Vy = Cy - s * Lx + c * Ly; - } - } + virtual string OpenCLString() const override + { + ostringstream ss, ss2; + intmax_t i = 0, varIndex = IndexInXform(); + ss2 << "_" << XformIndexInEmber() << "]"; + string index = ss2.str(); + string weight = WeightDefineString(); + string cellsize = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + string r2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; + ss << "\t{\n" + << "\t\treal_t Vx, Vy, Cx, Cy, Lx, Ly, Lxy;\n" + << "\t\treal_t r, theta, s, c;\n" + << "\n" + << "\t\tVx = vIn.x;\n" + << "\t\tVy = vIn.y;\n" + << "\n" + << "\t\tif (" << cellsize << " != (real_t)(0))\n" + << "\t\t{\n" + << "\t\t\tCx = (floor(Vx / " << cellsize << ") + (real_t)(0.5)) * " << cellsize << ";\n" + << "\t\t\tCy = (floor(Vy / " << cellsize << ") + (real_t)(0.5)) * " << cellsize << ";\n" + << "\n" + << "\t\t\tLx = Vx - Cx;\n" + << "\t\t\tLy = Vy - Cy;\n" + << "\t\t\tLxy = fma(Lx, Lx, Ly * Ly);\n" + << "\n" + << "\t\t\tif (Lxy <= " << r2 << ")\n" + << "\t\t\t{\n" + << "\t\t\t\tr = Lxy / " << r2 << ";\n" + << "\t\t\t\ttheta = " << twist << " * log(r);\n" + << "\t\t\t\ts = sin(theta);\n" + << "\t\t\t\tc = cos(theta);\n" + << "\t\t\t\tVx = Cx + c * Lx + s * Ly;\n" + << "\t\t\t\tVy = Cy - s * Lx + c * Ly;\n" + << "\t\t\t}\n" + << "\t\t}\n" + << "\n" + << "\t\tvOut.x = " << weight << " * Vx;\n" + << "\t\tvOut.y = " << weight << " * Vy;\n" + << "\t\tvOut.z = " << DefaultZCl() + << "\t}\n"; + return ss.str(); + } - helper.Out.x += m_Weight * Vx; - helper.Out.y += m_Weight * Vy; - helper.Out.z = DefaultZ(helper); - } - - virtual string OpenCLString() const override - { - ostringstream ss, ss2; - intmax_t i = 0, varIndex = IndexInXform(); - ss2 << "_" << XformIndexInEmber() << "]"; - string index = ss2.str(); - string weight = WeightDefineString(); - string cellsize = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string twist = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - string r2 = "parVars[" + ToUpper(m_Params[i++].Name()) + index; - ss << "\t{\n" - << "\t\treal_t Vx, Vy, Cx, Cy, Lx, Ly;\n" - << "\t\treal_t r, theta, s, c;\n" - << "\n" - << "\t\tVx = vIn.x;\n" - << "\t\tVy = vIn.y;\n" - << "\n" - << "\t\tif (" << cellsize << " != (real_t)(0))\n" - << "\t\t{\n" - << "\t\t\tCx = (floor(Vx / " << cellsize << ") + (real_t)(0.5)) * " << cellsize << ";\n" - << "\t\t\tCy = (floor(Vy / " << cellsize << ") + (real_t)(0.5)) * " << cellsize << ";\n" - << "\n" - << "\t\t\tLx = Vx - Cx;\n" - << "\t\t\tLy = Vy - Cy;\n" - << "\n" - << "\t\t\tif ((Lx * Lx + Ly * Ly) <= " << r2 << ")\n" - << "\t\t\t{\n" - << "\t\t\t\tr = (Lx * Lx + Ly * Ly) / " << r2 << ";\n" - << "\t\t\t\ttheta = " << twist << " * log(r);\n" - << "\t\t\t\ts = sin(theta);\n" - << "\t\t\t\tc = cos(theta);\n" - << "\t\t\t\tVx = Cx + c * Lx + s * Ly;\n" - << "\t\t\t\tVy = Cy - s * Lx + c * Ly;\n" - << "\t\t\t}\n" - << "\t\t}\n" - << "\n" - << "\t\tvOut.x += " << weight << " * Vx;\n" - << "\t\tvOut.y += " << weight << " * Vy;\n" - << "\t\tvOut.z = " << DefaultZCl() - << "\t}\n"; - return ss.str(); - } - - virtual void Precalc() override - { - T radius = T(0.5) * m_GnarlyCellSize; - m_R2 = Zeps(radius * radius); - } + virtual void Precalc() override + { + T radius = T(0.5) * m_GnarlyCellSize; + m_R2 = Zeps(SQR(radius)); + } protected: - void Init() - { - string prefix = Prefix(); - m_Params.clear(); - m_Params.push_back(ParamWithName(&m_GnarlyCellSize, prefix + "gnarly_cellsize", T(1))); - m_Params.push_back(ParamWithName(&m_GnarlyTwist, prefix + "gnarly_twist", T(1))); - m_Params.push_back(ParamWithName(true, &m_R2, prefix + "gnarly_r2"));//Precalc. - } + void Init() + { + string prefix = Prefix(); + m_Params.clear(); + m_Params.push_back(ParamWithName(&m_GnarlyCellSize, prefix + "gnarly_cellsize", T(1))); + m_Params.push_back(ParamWithName(&m_GnarlyTwist, prefix + "gnarly_twist", T(1))); + m_Params.push_back(ParamWithName(true, &m_R2, prefix + "gnarly_r2"));//Precalc. + } private: - T m_GnarlyCellSize; - T m_GnarlyTwist; - T m_R2;//Precalc. + T m_GnarlyCellSize; + T m_GnarlyTwist; + T m_R2;//Precalc. }; MAKEPREPOSTPARVAR(Splits3D, splits3D, SPLITS3D) diff --git a/Source/Ember/XmlToEmber.cpp b/Source/Ember/XmlToEmber.cpp index 7c48947..cf0406c 100644 --- a/Source/Ember/XmlToEmber.cpp +++ b/Source/Ember/XmlToEmber.cpp @@ -245,7 +245,7 @@ XmlToEmber::XmlToEmber() { "mode", "unicorngaloshen_mode" }, { "d_spher_weight", "d_spherical_weight" }, { "poincare_p", "poincare2_p" }, - { "poincare_q", "poincare2_q" } + { "poincare_q", "poincare2_q" } }; m_FlattenNames = { @@ -910,7 +910,7 @@ bool XmlToEmber::ParseEmberElementFromChaos(xmlNode* emberNode, Ember& cur if (!varname.empty()) { T weight = 1; - string corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname); + string corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname); auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname; if (auto var = m_VariationList->GetVariation(corrwprefix)) @@ -961,7 +961,9 @@ bool XmlToEmber::ParseEmberElementFromChaos(xmlNode* emberNode, Ember& cur } else if (parvar) { - paramstr = prefix + paramstr; + if (!StartsWith(paramstr, prefix)) + paramstr = prefix + paramstr; + parvar->SetParamVal(paramstr.c_str(), val); //if (!parvar->SetParamVal(paramstr.c_str(), val)) // AddToReport(string(loc) + " : Failed to set parametric variation parameter " + paramstr); @@ -2482,14 +2484,14 @@ string XmlToEmber::GetCorrectedVariationName(vector template string XmlToEmber::GetCorrectedVariationName(vector, vector>>& vec, const string& varname) { - if (varname == "poincare")//for Apo flames, poincare must be the same, but chaotica poincare is implemented as poincare2 - return "poincare2"; - else if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't. - for (auto& v : vec) - if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here. - return v.first.second; + if (varname == "poincare")//for Apo flames, poincare must be the same, but chaotica poincare is implemented as poincare2 + return "poincare2"; + else if (varname != "mobius")//Chaotica actually gets this right, but Apophysis doesn't. + for (auto& v : vec) + if (!_stricmp(v.first.first.c_str(), varname.c_str()))//Do case insensitive here. + return v.first.second; - return varname; + return varname; } /// diff --git a/Source/Fractorium/CurvesGraphicsView.cpp b/Source/Fractorium/CurvesGraphicsView.cpp index 48796a6..a96ea8c 100644 --- a/Source/Fractorium/CurvesGraphicsView.cpp +++ b/Source/Fractorium/CurvesGraphicsView.cpp @@ -20,7 +20,6 @@ CurvesGraphicsView::CurvesGraphicsView(QWidget* parent) m_GPen.setWidth(2); m_BPen.setWidth(2); setScene(&m_Scene); - SetTop(CurveIndex::ALL); //qDebug() << "Original scene rect before setting anything is: " << sceneRect(); m_OriginalRect = sceneRect(); Curves curves(true); @@ -30,16 +29,19 @@ CurvesGraphicsView::CurvesGraphicsView(QWidget* parent) } /// -/// Get the position of a given point within a given curve. +/// Called when an underlying point has had its position changed, so emit a signal so that a listener can take action. /// -/// The curve whose point value will be retrieved, 0-3. -/// The point within the curve value will be retrieved, 1-2. +/// The curve whose point value was changed, 0-3. +/// The point within the curve whose point value was changed. /// The position of the point. X,Y will each be within 0-1. void CurvesGraphicsView::PointChanged(int curveIndex, int pointIndex, const QPointF& point) { - double x = point.x() / width(); - double y = (height() - point.y()) / height(); - emit PointChangedSignal(curveIndex, pointIndex, QPointF(x, y)); + if (curveIndex == m_Index) + { + double x = point.x() / width(); + double y = (height() - point.y()) / height(); + emit PointChangedSignal(curveIndex, pointIndex, QPointF(x, y)); + } } /// @@ -105,6 +107,7 @@ void CurvesGraphicsView::Set(Curves& curves) createpoints(1, m_RedP, Qt::GlobalColor::red, 1); createpoints(2, m_GrnP, Qt::GlobalColor::green, 1); createpoints(3, m_BluP, Qt::GlobalColor::blue, 1); + SetTop(CurveIndex(m_Index)); } /// @@ -135,16 +138,10 @@ void CurvesGraphicsView::SetTop(CurveIndex curveIndex) for (size_t i = 0; i < 4; i++) { - if (i == m_Index) - { - for (auto& p : m_Points[i]) - p->setZValue(2); - } - else - { - for (auto& p : m_Points[i]) - p->setZValue(1); - } + bool b = (i == m_Index); + + for (auto& p : m_Points[i]) + p->SetCurrent(b); } } @@ -237,7 +234,7 @@ void CurvesGraphicsView::mousePressEvent(QMouseEvent* e) return -1; }; - if (e->button() == Qt::RightButton)//Right button does whole image rotation and scaling. + if (e->button() == Qt::RightButton) { int i = findpoint(e->pos().x(), e->pos().y()); diff --git a/Source/Fractorium/CurvesGraphicsView.h b/Source/Fractorium/CurvesGraphicsView.h index de2cdb4..24f39c9 100644 --- a/Source/Fractorium/CurvesGraphicsView.h +++ b/Source/Fractorium/CurvesGraphicsView.h @@ -39,6 +39,7 @@ public: void Set(int curveIndex, int pointIndex, const QPointF& point); void Set(Curves& curves); void SetTop(CurveIndex curveIndex); + size_t SelectedCurveIndex() const { return m_Index; } Q_SIGNALS: void PointChangedSignal(int curveIndex, int pointIndex, const QPointF& point); @@ -87,13 +88,23 @@ public: EllipseItem(const QRectF& rect, int curveIndex, int pointIndex, CurvesGraphicsView* viewParent, QGraphicsItem* parent = nullptr) : QGraphicsEllipseItem(rect, parent) { + m_CurveIndex = curveIndex; + m_PointIndex = pointIndex; + m_ViewParent = viewParent; setFlag(QGraphicsItem::ItemSendsScenePositionChanges); setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsMovable); setPen(Qt::NoPen); - m_CurveIndex = curveIndex; - m_PointIndex = pointIndex; - m_ViewParent = viewParent; + } + + /// + /// Set whether this item is selectable, which means this curve is the current one. + /// + /// True if selected, else false. + void SetCurrent(bool b) + { + setFlag(QGraphicsItem::ItemIsMovable, b); + setZValue(b ? 2 : 1); } /// @@ -125,7 +136,7 @@ protected: /// The new position virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value) override { - if (change == ItemPositionChange && scene()) + if ((change == ItemPositionChange) && scene()) { //Value is the new position. QPointF newPos = value.toPointF(); diff --git a/Source/apoconv/Form1.cs b/Source/apoconv/Form1.cs index 5729c2b..34cd0f5 100644 --- a/Source/apoconv/Form1.cs +++ b/Source/apoconv/Form1.cs @@ -19,9 +19,11 @@ namespace apoconv { "(float)", "" }, { "double", "T" }, { "float", "T" }, + { "Complex", "std::complex" }, //{ "0.0", "0" }, { "0.5", "T(0.5)" }, { "1.0", "T(1.0)" }, + { "2.0", "T(2.0)" }, { "0.1", "T(0.1)" }, { "0.01", "T(0.01)" }, { "0.001", "T(0.001)" }, @@ -56,6 +58,7 @@ namespace apoconv { "sqrt(", "std::sqrt(" }, { "pow(", "std::pow(" }, { "fabs(", "std::abs(" }, + { "log(", "std::log(" }, { "sqr(", "Sqr(" },