22.21.4.2 4/19/2021

--User changes
 -Allow users to set the Exp value when using the Exp temporal filter type.
 -Set the default temporal filter type to be Box, which does not alter the palette values at all during animation. This is done to avoid confusion when using Gaussian or Exp which can produce darkened images.

--Bug fixes
 -Sending a sequence to the final render dialog when the keyframes had non zero rotate and center Y values would produce off center animations when rendered.
 -Temporal filters were being unnecessarily recreated many times when rendering or generating sequences.
 -Exp filter was always treated like a Box filter.

--Code changes
 -Add a new member function SaveCurrentAsXml(QString filename = "") to the controllers which is only used for testing.
 -Modernize some C++ code.
This commit is contained in:
Person 2021-04-19 21:07:24 -06:00
parent 652ccc242c
commit 8086cfa731
97 changed files with 2156 additions and 2087 deletions

View File

@ -6,7 +6,7 @@
<ProductVersion>3.7</ProductVersion>
<ProjectGuid>{c8096c47-e358-438c-a520-146d46b0637d}</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>Fractorium_21.21.4.1</OutputName>
<OutputName>Fractorium_22.21.4.2</OutputName>
<OutputType>Package</OutputType>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductVersion="21.21.4.1" ?>
<?define ProductVersion="22.21.4.2" ?>
<?define ProductName="Fractorium $(var.ProductVersion) ($(var.GpuType))" ?>
<?define UpgradeCode="{4714cd15-bfba-44f6-8059-9e1466ebfa6e}"?>
<?define Manufacturer="Fractorium"?>
@ -13,7 +13,7 @@
<!--
Change this for every release.
-->
<?define ProductCode="{ADD54CBF-04FF-4E45-996B-F071FFE5D65B}"?>
<?define ProductCode="{5EB322AE-7613-4D8B-AC60-2B53C4CC7941}"?>
<Product Id="$(var.ProductCode)" Name="$(var.ProductName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
<Package

Binary file not shown.

View File

@ -49,8 +49,8 @@
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 21, 21, 4, 1
PRODUCTVERSION 21, 21, 4, 1
FILEVERSION 22, 21, 4, 2
PRODUCTVERSION 22, 21, 4, 2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -67,12 +67,12 @@
BEGIN
VALUE "CompanyName", "Open Source"
VALUE "FileDescription", "Renders fractal flames as animations with motion blur"
VALUE "FileVersion", "21, 21, 4, 1"
VALUE "FileVersion", "22, 21, 4, 2"
VALUE "InternalName", "EmberAnimate.exe"
VALUE "LegalCopyright", "Copyright (C) Matt Feemster 2021, GPL v3"
VALUE "OriginalFilename", "EmberAnimate.exe"
VALUE "ProductName", "Ember Animate"
VALUE "ProductVersion", "21, 21, 4, 1"
VALUE "ProductVersion", "22, 21, 4, 2"
END
END
BLOCK "VarFileInfo"

Binary file not shown.

View File

@ -49,8 +49,8 @@
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 21, 21, 4, 1
PRODUCTVERSION 21, 21, 4, 1
FILEVERSION 22, 21, 4, 2
PRODUCTVERSION 22, 21, 4, 2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -67,12 +67,12 @@
BEGIN
VALUE "CompanyName", "Open Source"
VALUE "FileDescription", "Manipulates fractal flame parameter files"
VALUE "FileVersion", "21, 21, 4, 1"
VALUE "FileVersion", "22, 21, 4, 2"
VALUE "InternalName", "EmberGenome.exe"
VALUE "LegalCopyright", "Copyright (C) Matt Feemster 2021, GPL v3"
VALUE "OriginalFilename", "EmberGenome.exe"
VALUE "ProductName", "Ember Genome"
VALUE "ProductVersion", "21, 21, 4, 1"
VALUE "ProductVersion", "22, 21, 4, 2"
END
END
BLOCK "VarFileInfo"

View File

@ -49,8 +49,8 @@
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 21, 21, 4, 1
PRODUCTVERSION 21, 21, 4, 1
FILEVERSION 22, 21, 4, 2
PRODUCTVERSION 22, 21, 4, 2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -67,12 +67,12 @@
BEGIN
VALUE "CompanyName", "Open Source"
VALUE "FileDescription", "Renders fractal flames as single images"
VALUE "FileVersion", "21, 21, 4, 1"
VALUE "FileVersion", "22, 21, 4, 2"
VALUE "InternalName", "EmberRender.exe"
VALUE "LegalCopyright", "Copyright (C) Matt Feemster 2021, GPL v3"
VALUE "OriginalFilename", "EmberRender.exe"
VALUE "ProductName", "Ember Render"
VALUE "ProductVersion", "21, 21, 4, 1"
VALUE "ProductVersion", "22, 21, 4, 2"
END
END
BLOCK "VarFileInfo"

Binary file not shown.

View File

@ -1,4 +1,4 @@
VERSION = 21.21.4.1
VERSION = 22.21.4.2
win32:CONFIG += skip_target_version_ext
CONFIG += c++14

View File

@ -2,7 +2,7 @@
%define buildroot %{_topdir}/BUILDROOT
Name: Fractorium
Version: 21.21.4.1
Version: 22.21.4.2
Release: 1
Summary: A fractal flame editor with GPU support

View File

@ -1,3 +1,18 @@
22.21.4.2 4/19/2021
--User changes
-Allow users to set the Exp value when using the Exp temporal filter type.
-Set the default temporal filter type to be Box, which does not alter the palette values at all during animation. This is done to avoid confusion when using Gaussian or Exp which can produce darkened images.
--Bug fixes
-Sending a sequence to the final render dialog when the keyframes had non zero rotate and center Y values would produce off center animations when rendered.
-Temporal filters were being unnecessarily recreated many times when rendering or generating sequences.
-Exp filter was always treated like a Box filter.
--Code changes
-Add a new member function SaveCurrentAsXml(QString filename = "") to the controllers which is only used for testing.
-Modernize some C++ code.
21.21.4.1 4/7/2021
--User changes

View File

@ -8,7 +8,7 @@ Homepage: http://fractorium.com/
Vcs-Git: https://bitbucket.org/mfeemster/fractorium
Vcs-Browser: https://bitbucket.org/mfeemster/fractorium
Package: Fractorium
Version: 21.21.4.1
Version: 22.21.4.2
Architecture: amd64
Description: A fractal flame editor with GPU support
Fractorium

View File

@ -223,8 +223,8 @@ void Affine2D<T>::ScaleXY(T amount)
template <typename T>
void Affine2D<T>::Rotate(T rad)
{
m4T origMat4 = ToMat4ColMajor(true);//Must center and use column major for glm to work.
m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
const m4T origMat4 = ToMat4ColMajor(true);//Must center and use column major for glm to work.
const m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
A(newMat4[0][0]);//Use direct assignments instead of constructor to skip assigning C and F.
B(newMat4[0][1]);
D(newMat4[1][0]);
@ -234,8 +234,8 @@ void Affine2D<T>::Rotate(T rad)
template <typename T>
void Affine2D<T>::RotateTrans(T rad)
{
m4T origMat4 = TransToMat4ColMajor();//Only put translation in this matrix.
m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
const m4T origMat4 = TransToMat4ColMajor();//Only put translation in this matrix.
const m4T newMat4 = glm::rotate(origMat4, rad, v3T(0, 0, 1));//Assuming only rotating around z.
C(newMat4[0][3]);//Use direct assignments instead of constructor to skip assigning A, B, D, E.
F(newMat4[1][3]);
}
@ -257,7 +257,7 @@ void Affine2D<T>::Translate(const v2T& v)
template <typename T>
void Affine2D<T>::RotateScaleXTo(const v2T& v)
{
Affine2D<T> rs = CalcRotateScale(X(), v);
const Affine2D<T> rs = CalcRotateScale(X(), v);
X(rs.TransformNormal(X()));
Y(rs.TransformNormal(Y()));
}
@ -269,7 +269,7 @@ void Affine2D<T>::RotateScaleXTo(const v2T& v)
template <typename T>
void Affine2D<T>::RotateScaleYTo(const v2T& v)
{
Affine2D<T> rs = CalcRotateScale(Y(), v);
const Affine2D<T> rs = CalcRotateScale(Y(), v);
X(rs.TransformNormal(X()));
Y(rs.TransformNormal(Y()));
}
@ -281,7 +281,7 @@ void Affine2D<T>::RotateScaleYTo(const v2T& v)
template <typename T>
Affine2D<T> Affine2D<T>::Inverse() const
{
T det = A() * E() - D() * B();
const T det = A() * E() - D() * B();
return Affine2D<T>(E() / det, -D() / det,
-B() / det, A() / det,
(F() * B() - C() * E()) / det, (C() * D() - F() * A()) / det);
@ -341,10 +341,10 @@ typename m2T Affine2D<T>::ToMat2RowMajor() const
template <typename T>
typename m4T Affine2D<T>::ToMat4ColMajor(bool center) const
{
m4T mat(A(), B(), 0, center ? 0 : C(), //Col0...
D(), E(), 0, center ? 0 : F(), //1
0, 0, 1, 0, //2
0, 0, 0, 1);//3
const m4T mat(A(), B(), 0, center ? 0 : C(), //Col0...
D(), E(), 0, center ? 0 : F(), //1
0, 0, 1, 0, //2
0, 0, 0, 1);//3
return mat;
}
@ -356,20 +356,20 @@ typename m4T Affine2D<T>::ToMat4ColMajor(bool center) const
template <typename T>
typename m4T Affine2D<T>::ToMat4RowMajor(bool center) const
{
m4T mat(A(), D(), 0, 0,
B(), E(), 0, 0,
0, 0, 1, 0,
center ? 0 : C(), center ? 0 : F(), 0, 1);
const m4T mat(A(), D(), 0, 0,
B(), E(), 0, 0,
0, 0, 1, 0,
center ? 0 : C(), center ? 0 : F(), 0, 1);
return mat;
}
template <typename T>
typename m4T Affine2D<T>::TransToMat4ColMajor() const
{
m4T mat(1, 0, 0, C(), //Col0...
0, 1, 0, F(), //1
0, 0, 1, 0, //2
0, 0, 0, 1);//3
const m4T mat(1, 0, 0, C(), //Col0...
0, 1, 0, F(), //1
0, 0, 1, 0, //2
0, 0, 0, 1);//3
return mat;
}
@ -436,7 +436,7 @@ Affine2D<T> Affine2D<T>::CalcRotateScale(const v2T& from, const v2T& to)
template <typename T>
void Affine2D<T>::CalcRSAC(const v2T& from, const v2T& to, T& a, T& c)
{
T lsq = from.x * from.x + from.y * from.y;
const T lsq = from.x * from.x + from.y * from.y;
a = (from.y * to.y + from.x * to.x) / lsq;
c = (from.x * to.y - from.y * to.x) / lsq;
}

View File

@ -185,11 +185,11 @@ public:
if (i < 4)
{
m_Points[i].resize(5);
m_Points[i][0] = v2T(0);
m_Points[i][1] = v2T(T(0.25));
m_Points[i][2] = v2T(T(0.50));
m_Points[i][3] = v2T(T(0.75));
m_Points[i][4] = v2T(1);
m_Points[i][0] = v2T{ 0 };
m_Points[i][1] = v2T{ static_cast<T>(0.25) };
m_Points[i][2] = v2T{ static_cast<T>(0.50) };
m_Points[i][3] = v2T{ static_cast<T>(0.75) };
m_Points[i][4] = v2T{ 1 };
}
}
@ -219,9 +219,9 @@ public:
}
if ((m_Points[i][0] != v2T(0)) ||
(m_Points[i][1] != v2T(T(0.25))) ||
(m_Points[i][2] != v2T(T(0.50))) ||
(m_Points[i][3] != v2T(T(0.75))) ||
(m_Points[i][1] != v2T(static_cast<T>(0.25))) ||
(m_Points[i][2] != v2T(static_cast<T>(0.50))) ||
(m_Points[i][3] != v2T(static_cast<T>(0.75))) ||
(m_Points[i][4] != v2T(1))
)
{

View File

@ -52,7 +52,7 @@ public:
//Make sure the values make sense.
if (m_Curve <= 0.0)
m_Curve = T(0.5);
m_Curve = static_cast<T>(0.5);
if (m_MaxRad < m_MinRad)
m_MaxRad = m_MinRad + 1;
@ -60,7 +60,7 @@ public:
//Ensure it's valid.
while (!Valid())
{
m_Curve += T(0.1);
m_Curve += static_cast<T>(0.1);
}
}
@ -121,7 +121,7 @@ public:
//
// num filters = (de_max_width / de_min_width)^(1 / estimator_curve)
//
decFilterCount = std::pow(finalMaxRad / finalMinRad, T(1.0) / m_Curve);
decFilterCount = std::pow(finalMaxRad / finalMinRad, static_cast<T>(1) / m_Curve);
if (decFilterCount > 1e7)//Too many filters.
return false;
@ -131,8 +131,8 @@ public:
//Condense the smaller kernels to save space.
if (intFilterCount > keepThresh)
{
maxIndex = static_cast<int>(ceil(DE_THRESH + std::pow(T(intFilterCount - DE_THRESH), m_Curve))) + 1;
m_MaxFilteredCounts = static_cast<int>(std::pow(T(maxIndex - DE_THRESH), T(1.0) / m_Curve)) + DE_THRESH;
maxIndex = static_cast<int>(ceil(DE_THRESH + std::pow(static_cast<T>(intFilterCount - DE_THRESH), m_Curve))) + 1;
m_MaxFilteredCounts = static_cast<int>(std::pow(static_cast<T>(maxIndex - DE_THRESH), static_cast<T>(1) / m_Curve)) + DE_THRESH;
}
else
{
@ -160,11 +160,11 @@ public:
//Calculate the filter width for this number of hits in a bin.
if (filterLoop < keepThresh)
{
filterHeight = (finalMaxRad / std::pow(T(filterLoop + 1), m_Curve));
filterHeight = (finalMaxRad / std::pow(static_cast<T>(filterLoop + 1), m_Curve));
}
else
{
loopAdjust = std::pow(T(filterLoop - keepThresh), (T(1.0) / m_Curve)) + keepThresh;
loopAdjust = std::pow(static_cast<T>(filterLoop - keepThresh), (static_cast<T>(1) / m_Curve)) + keepThresh;
filterHeight = (finalMaxRad / std::pow(loopAdjust + 1, m_Curve));
}
@ -182,7 +182,7 @@ public:
{
for (dek = -m_FilterWidth; dek <= m_FilterWidth; dek++)
{
filterVal = std::sqrt(T(dej * dej + dek * dek)) / filterHeight;
filterVal = std::sqrt(static_cast<T>(dej * dej + dek * dek)) / filterHeight;
//Only populate the coefs within this radius.
if (filterVal <= 1.0)
@ -197,7 +197,7 @@ public:
{
for (dek = 0; dek <= dej; dek++)
{
filterVal = std::sqrt(T(dej * dej + dek * dek)) / filterHeight;
filterVal = std::sqrt(static_cast<T>(dej * dej + dek * dek)) / filterHeight;
//Only populate the coefs within this radius.
if (filterVal > 1.0)
@ -258,7 +258,7 @@ public:
{
T finalMaxRad = m_MaxRad * m_Supersample + 1;
T finalMinRad = m_MinRad * m_Supersample + 1;
return std::pow(finalMaxRad / finalMinRad, T(1.0) / m_Curve) <= 1e7;
return std::pow(finalMaxRad / finalMinRad, static_cast<T>(1) / m_Curve) <= 1e7;
}
/// <summary>

View File

@ -596,7 +596,7 @@ public:
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++; }
for (auto& weight : normalizedWeights) { weight = (norm == static_cast<T>( 0 ) ? static_cast<T>( 0 ) : m_Xforms[i].m_Weight / norm); i++; }
}
/// <summary>
@ -1082,8 +1082,8 @@ public:
/// <param name="rand">The random context to use for generating random symmetry</param>
void AddSymmetry(intmax_t sym, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand)
{
intmax_t k;
size_t i, result = 0;
intmax_t k = 0;
size_t i = 0, result = 0;
T a;
if (sym == 0)
@ -1101,9 +1101,9 @@ public:
if (rand.RandBit())
sym = symDistrib[rand.Rand(Vlen(symDistrib))];
else if (rand.Rand() & 31)
sym = intmax_t(rand.Rand(13)) - 6;
sym = intmax_t{ rand.Rand(13) } - 6;
else
sym = intmax_t(rand.Rand(51)) - 25;
sym = intmax_t{ rand.Rand(51) } - 25;
}
if (sym == 1 || sym == 0)
@ -1132,7 +1132,7 @@ public:
sym = -sym;
}
a = T(2 * M_PI / sym);
a = static_cast<T>(2 * M_PI / sym);
for (k = 1; k < sym; k++)
{
@ -1142,7 +1142,7 @@ public:
m_Xforms[i].m_Weight = 1;
m_Xforms[i].m_ColorSpeed = 0;
m_Xforms[i].m_Animate = 0;
m_Xforms[i].m_ColorX = m_Xforms[i].m_ColorY = (sym < 3) ? 0 : (T(k - 1) / T(sym - 2));//Added Y.
m_Xforms[i].m_ColorX = m_Xforms[i].m_ColorY = (sym < 3) ? 0 : (static_cast<T>(k - 1) / static_cast<T>(sym - 2));//Added Y.
m_Xforms[i].m_Affine.A(Round6(std::cos(k * a)));
m_Xforms[i].m_Affine.D(Round6(std::sin(k * a)));
m_Xforms[i].m_Affine.B(Round6(-m_Xforms[i].m_Affine.D()));
@ -1452,7 +1452,7 @@ public:
m_AffineInterp = eAffineInterp::AFFINE_INTERP_LOG;
m_TemporalFilterType = eTemporalFilterType::BOX_TEMPORAL_FILTER;
m_TemporalFilterWidth = 1;
m_TemporalFilterExp = 0;
m_TemporalFilterExp = 1;
m_PaletteMode = ePaletteMode::PALETTE_LINEAR;
m_Interp = eInterp::EMBER_INTERP_SMOOTH;
}
@ -1559,8 +1559,8 @@ public:
<< "Spatial Filter Type: " << m_SpatialFilterType << "\n"
<< "Spatial Filter Radius: " << m_SpatialFilterRadius << "\n"
<< "Temporal Filter Type: " << m_TemporalFilterType << "\n"
<< "Temporal Filter Exp: " << m_TemporalFilterExp << "\n"
<< "Temporal Filter Width: " << m_TemporalFilterWidth << "\n"
<< "Temporal Filter Exp: " << m_TemporalFilterExp << "\n"
<< "Palette Mode: " << m_PaletteMode << "\n"
<< "Palette Interp: " << m_PaletteInterp << "\n"
<< "Palette Index: " << m_Palette.m_Index << "\n"
@ -1738,7 +1738,7 @@ public:
//Only used if temporal filter type is exp, else unused.
//Xml field: "temporal_filter_exp".
T m_TemporalFilterExp = 0;
T m_TemporalFilterExp = 1;
//The width of the temporal filter.
//Xml field: "temporal_filter_width".

View File

@ -37,7 +37,7 @@ static void sincos(float x, float* s, float* c)
namespace EmberNs
{
#define EMBER_VERSION "21.21.4.1"
#define EMBER_VERSION "22.21.4.2"
//#define FLAM3_COMPAT 1//Uncomment this if you want full compatibility with flam3 regarding some of the trig-based variations in Variations01.h
#define EPS6 T(1e-6)
#define EPS std::numeric_limits<T>::epsilon()//Apoplugin.h uses -20, but it's more mathematically correct to do it this way.
@ -46,12 +46,12 @@ namespace EmberNs
#define DE_THRESH 100
#define DEG_2_RAD (M_PI / 180)
#define RAD_2_DEG (180 / M_PI)
#define DEG_2_RAD_T (T(M_PI) / T(180))
#define RAD_2_DEG_T (T(180) / T(M_PI))
#define M_2PI (T(M_PI * 2))
#define M_3PI (T(M_PI * 3))
#define M_PI2 (T(M_PI_2))
#define M_PI4 (T(M_PI_4))
#define DEG_2_RAD_T (T{M_PI} / T{180})
#define RAD_2_DEG_T (T{180} / T{M_PI})
#define M_2PI (T{M_PI * 2})
#define M_3PI (T{M_PI * 3})
#define M_PI2 (T{M_PI_2})
#define M_PI4 (T{M_PI_4})
#define M_SQRT3 T(1.7320508075688772935274463415059)
#define M_SQRT3_2 T(0.86602540378443864676372317075294)
#define M_SQRT3_3 T(0.57735026918962576450914878050196)

View File

@ -70,7 +70,7 @@ public:
MotionParam& operator = (const MotionParam<U>& other)
{
this->first = other.first;
this->second = T(other.second);
this->second = static_cast<T>(other.second);
return *this;
}
};

View File

@ -53,7 +53,7 @@ bool EmberToXml<T>::Save(const string& filename, C<Ember<T>, Alloc>& embers, siz
if (f.is_open())
{
auto prev = embers.begin();
const auto prev = embers.begin();
//Always ensure times make sense.
for (auto& ember : embers)
@ -280,7 +280,7 @@ string EmberToXml<T>::ToString(Ember<T>& ember, const string& extraAttributes, s
os << ">\n";
os << std::uppercase;
auto rows = ember.m_Palette.Size() / 8;
const auto rows = ember.m_Palette.Size() / 8;
for (i = 0; i < rows; i++)
{
@ -289,9 +289,9 @@ string EmberToXml<T>::ToString(Ember<T>& ember, const string& extraAttributes, s
for (j = 0; j < 8; j++)
{
size_t idx = 8 * i + j;
os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][0] * 255));
os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][1] * 255));
os << hex << setw(2) << setfill('0') << int(std::rint(ember.m_Palette[idx][2] * 255));
os << hex << setw(2) << setfill('0') << static_cast<int>(std::rint(ember.m_Palette[idx][0] * 255));
os << hex << setw(2) << setfill('0') << static_cast<int>(std::rint(ember.m_Palette[idx][1] * 255));
os << hex << setw(2) << setfill('0') << static_cast<int>(std::rint(ember.m_Palette[idx][2] * 255));
}
os << "\n";
@ -304,10 +304,10 @@ string EmberToXml<T>::ToString(Ember<T>& ember, const string& extraAttributes, s
{
for (i = 0; i < ember.m_Palette.Size(); i++)
{
double r = ember.m_Palette[i][0] * 255;
double g = ember.m_Palette[i][1] * 255;
double b = ember.m_Palette[i][2] * 255;
double a = ember.m_Palette[i][3] * 255;
const double r = ember.m_Palette[i][0] * 255;
const double g = ember.m_Palette[i][1] * 255;
const double b = ember.m_Palette[i][2] * 255;
const double a = ember.m_Palette[i][3] * 255;
os << " ";
//The original used a precision of 6 which is totally unnecessary, use 2.
@ -463,7 +463,7 @@ xmlDocPtr EmberToXml<T>::CreateNewEditdoc(Ember<T>* parent0, Ember<T>* parent1,
{
os << "<comm>" << comment << "</comm>";
s = os.str();
commentDoc = xmlReadMemory(s.c_str(), int(s.length()), "comment.env", nullptr, XML_PARSE_NONET);
commentDoc = xmlReadMemory(s.c_str(), static_cast<int>(s.length()), "comment.env", nullptr, XML_PARSE_NONET);
os.str("");
//Check for errors.

View File

@ -1004,8 +1004,8 @@ public:
if (a.m_ColorSpeed < b.m_ColorSpeed) return false;
//Original did this every time, even though it's only needed if the color speeds are equal.
m2T aMat2 = a.m_Affine.ToMat2ColMajor();
m2T bMat2 = b.m_Affine.ToMat2ColMajor();
const auto aMat2 = a.m_Affine.ToMat2ColMajor();
const auto bMat2 = b.m_Affine.ToMat2ColMajor();
T ad = glm::determinant(aMat2);
T bd = glm::determinant(bMat2);

View File

@ -32,11 +32,11 @@
/// </summary>
#ifndef __ISAAC64
typedef uint ISAAC_INT;
const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b9);
typedef uint ISAAC_INT;
const ISAAC_INT GOLDEN_RATIO = ISAAC_INT{ 0x9e3779b9 };
#else
typedef size_t ISAAC_INT;
const ISAAC_INT GOLDEN_RATIO = ISAAC_INT(0x9e3779b97f4a7c13);
typedef size_t ISAAC_INT;
const ISAAC_INT GOLDEN_RATIO = ISAAC_INT{ 0x9e3779b97f4a7c13 };
#endif
namespace EmberNs
@ -251,7 +251,7 @@ public:
#ifdef ISAAC_FLAM3_DEBUG
return ((Rand() & 0xfffffff) - 0x7ffffff) / (floatType)0x7ffffff;
#else
return Frand<floatType>(floatType(-1), floatType(1));
return Frand<floatType>(floatType { -1 }, floatType { 1 });
#endif
}

View File

@ -278,12 +278,12 @@ public:
/// <param name="freq">Frequency 1 - 10</param>
void MakeAdjustedPalette(Palette<T>& palette, int rot, T hue, T sat, T bright, T cont, uint blur, uint freq)
{
T rgb[3], hsv[3];
T rgb[3] {}, hsv[3] {};
palette.m_Entries.resize(Size());
if (freq > 1)
{
size_t n = Size() / freq;
const size_t n = Size() / freq;
for (size_t j = 0; j <= freq; j++)
{

View File

@ -36,7 +36,7 @@ bool PaletteList<T>::AddPaletteFile(const string& filename, const vector<Palette
{
if (!GetPaletteListByFullPath(filename))
{
auto item = s_Palettes.insert(make_pair(filename, palettes));
const auto item = s_Palettes.insert(make_pair(filename, palettes));
Save(filename);
return true;
}
@ -55,7 +55,7 @@ bool PaletteList<T>::AddEmptyPaletteFile(const string& filename)
{
if (!GetPaletteListByFullPath(filename))
{
auto item = s_Palettes.insert(make_pair(filename, vector<Palette<T>>()));
const auto item = s_Palettes.insert(make_pair(filename, vector<Palette<T>>()));
Palette<T> p;
p.m_Index = 0;
p.m_Name = "empty-default";
@ -82,11 +82,11 @@ bool PaletteList<T>::AddEmptyPaletteFile(const string& filename)
template <typename T>
bool PaletteList<T>::AddPaletteToFile(const string& filename, const Palette<T>& palette)
{
if (auto p = GetPaletteListByFullPathOrFilename(filename))
if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
p->push_back(palette);
p->back().m_Filename = make_shared<string>(filename);//Ensure the filename matches because this could have been duplicated from another palette file.
p->back().m_Index = int(p->size()) - 1;
p->back().m_Index = static_cast<int>(p->size()) - 1;
Save(filename);
return true;
}
@ -105,13 +105,13 @@ bool PaletteList<T>::AddPaletteToFile(const string& filename, const Palette<T>&
template <typename T>
bool PaletteList<T>::Replace(const string& filename, const Palette<T>& palette)
{
if (auto p = GetPaletteListByFullPathOrFilename(filename))
if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
for (auto& pal : *p)
{
if (pal.m_Name == palette.m_Name)
{
auto index = pal.m_Index;
const auto index = pal.m_Index;
pal = palette;
pal.m_Index = index;
Save(filename);
@ -134,7 +134,7 @@ bool PaletteList<T>::Replace(const string& filename, const Palette<T>& palette)
template <typename T>
bool PaletteList<T>::Replace(const string& filename, const Palette<T>& palette, int index)
{
if (auto p = GetPaletteListByFullPathOrFilename(filename))
if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
if (index < p->size())
{
@ -160,7 +160,7 @@ bool PaletteList<T>::Delete(const string& filename, int index)
{
int i = 0;
if (auto p = GetPaletteListByFullPathOrFilename(filename))
if (const auto p = GetPaletteListByFullPathOrFilename(filename))
{
if (index < p->size())
{
@ -188,13 +188,13 @@ template <typename T>
bool PaletteList<T>::Add(const string& filename, bool force)
{
bool added = true;
bool contains = GetPaletteListByFullPathOrFilename(filename) != nullptr;
auto filenameonly = GetFilename(filename);
const auto contains = GetPaletteListByFullPathOrFilename(filename) != nullptr;
const auto filenameonly = GetFilename(filename);
if (contains && !force)//Don't allow any palettes with the same name, even if they reside in different paths.
return false;
auto palettes = s_Palettes.insert(make_pair(filename, vector<Palette<T>>()));
const auto palettes = s_Palettes.insert(make_pair(filename, vector<Palette<T>>()));
if (force || palettes.second)
{
@ -203,12 +203,12 @@ bool PaletteList<T>::Add(const string& filename, bool force)
if (ReadFile(filename.c_str(), buf))
{
auto lower = ToLower(filename);
auto pfilename = shared_ptr<string>(new string(filename));
const auto lower = ToLower(filename);
const auto pfilename = shared_ptr<string>(new string(filename));
if (EndsWith(lower, ".xml"))
{
xmlDocPtr doc = xmlReadMemory(static_cast<const char*>(buf.data()), int(buf.size()), filename.c_str(), nullptr, XML_PARSE_NONET);
const auto doc = xmlReadMemory(static_cast<const char*>(buf.data()), static_cast<int>(buf.size()), filename.c_str(), nullptr, XML_PARSE_NONET);
if (doc)
{
@ -270,7 +270,7 @@ Palette<T>* PaletteList<T>::GetRandomPalette()
while (attempts < Size() * 10)
{
auto p = s_Palettes.begin();
auto paletteFileIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(Size());
const auto paletteFileIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(Size());
size_t i = 0;
//Move p forward i elements.
@ -282,7 +282,7 @@ Palette<T>* PaletteList<T>::GetRandomPalette()
if (i < Size())
{
size_t paletteIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(p->second.size());
const size_t paletteIndex = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(p->second.size());
if (paletteIndex < p->second.size() && !p->second[paletteIndex].IsEmpty())
return &p->second[paletteIndex];
@ -303,7 +303,7 @@ Palette<T>* PaletteList<T>::GetRandomPalette()
template <typename T>
Palette<T>* PaletteList<T>::GetPaletteByFilename(const string& filename, size_t i)
{
if (auto palettes = GetPaletteListByFilename(filename))
if (const auto palettes = GetPaletteListByFilename(filename))
if (i < palettes->size())
return &(*palettes)[i];
@ -319,7 +319,7 @@ Palette<T>* PaletteList<T>::GetPaletteByFilename(const string& filename, size_t
template <typename T>
Palette<T>* PaletteList<T>::GetPaletteByFullPath(const string& filename, size_t i)
{
if (auto palettes = GetPaletteListByFullPath(filename))
if (const auto palettes = GetPaletteListByFullPath(filename))
if (i < palettes->size())
return &(*palettes)[i];
@ -335,7 +335,7 @@ Palette<T>* PaletteList<T>::GetPaletteByFullPath(const string& filename, size_t
template <typename T>
Palette<T>* PaletteList<T>::GetPaletteByName(const string& filename, const string& name)
{
if (auto palettes = GetPaletteListByFullPathOrFilename(filename))
if (const auto palettes = GetPaletteListByFullPathOrFilename(filename))
for (auto& palette : *palettes)
if (palette.m_Name == name)
return &palette;
@ -351,7 +351,7 @@ Palette<T>* PaletteList<T>::GetPaletteByName(const string& filename, const strin
template <typename T>
vector<Palette<T>>* PaletteList<T>::GetPaletteListByFilename(const string& filename)
{
auto filenameonly = GetFilename(filename);
const auto filenameonly = GetFilename(filename);
for (auto& palettes : s_Palettes)
if (GetFilename(palettes.first) == filenameonly)
@ -368,7 +368,7 @@ vector<Palette<T>>* PaletteList<T>::GetPaletteListByFilename(const string& filen
template <typename T>
vector<Palette<T>>* PaletteList<T>::GetPaletteListByFullPath(const string& filename)
{
auto palettes = s_Palettes.find(filename);
const auto palettes = s_Palettes.find(filename);
if (palettes != s_Palettes.end() && !palettes->second.empty())
return &palettes->second;
@ -401,7 +401,7 @@ vector<Palette<T>>* PaletteList<T>::GetPaletteListByFullPathOrFilename(const str
template <typename T>
string PaletteList<T>::GetFullPathFromFilename(const string& filename)
{
auto filenameonly = GetFilename(filename);
const auto filenameonly = GetFilename(filename);
for (auto& palettes : s_Palettes)
if (GetFilename(palettes.first) == filenameonly)
@ -422,7 +422,7 @@ string PaletteList<T>::GetFullPathFromFilename(const string& filename)
template <typename T>
bool PaletteList<T>::GetHueAdjustedPalette(const string& filename, size_t i, T hue, Palette<T>& palette)
{
if (auto unadjustedPal = GetPaletteByFullPath(filename, i))
if (const auto unadjustedPal = GetPaletteByFullPath(filename, i))
{
unadjustedPal->MakeHueAdjustedPalette(palette, hue);
return true;
@ -508,7 +508,7 @@ const string& PaletteList<T>::Name(size_t index)
template <typename T>
bool PaletteList<T>::IsModifiable(const string& filename)
{
if (auto palFile = GetPaletteListByFullPathOrFilename(filename))
if (const auto palFile = GetPaletteListByFullPathOrFilename(filename))
for (auto& pal : *palFile)
if (pal.m_SourceColors.empty())
return false;
@ -534,14 +534,14 @@ const map<string, vector<Palette<T>>>& PaletteList<T>::Palettes() const
template <typename T>
bool PaletteList<T>::Save(const string& filename)
{
auto fullpath = GetFullPathFromFilename(filename);
const auto fullpath = GetFullPathFromFilename(filename);
try
{
size_t index = 0;
ostringstream os;
if (auto palFile = GetPaletteListByFullPathOrFilename(filename))
if (const auto palFile = GetPaletteListByFullPathOrFilename(filename))
{
ofstream f(fullpath);
os << "<palettes>\n";
@ -568,11 +568,11 @@ bool PaletteList<T>::Save(const string& filename)
{
for (int j = 0; j < 8; j++)
{
size_t idx = 8 * i + j;
const size_t idx = 8 * i + j;
os << "00";
os << hex << setw(2) << setfill('0') << int(std::rint(pal[idx][0] * 255));
os << hex << setw(2) << setfill('0') << int(std::rint(pal[idx][1] * 255));
os << hex << setw(2) << setfill('0') << int(std::rint(pal[idx][2] * 255));
os << hex << setw(2) << setfill('0') << static_cast<int>(std::rint(pal[idx][0] * 255));
os << hex << setw(2) << setfill('0') << static_cast<int>(std::rint(pal[idx][1] * 255));
os << hex << setw(2) << setfill('0') << static_cast<int>(std::rint(pal[idx][2] * 255));
}
os << "\n";
@ -651,7 +651,7 @@ void PaletteList<T>::ParsePalettes(xmlNode* node, const shared_ptr<string>& file
ss.clear();//Reset and fill the string stream.
ss.str(tmpStr);
ss >> tmp;//Do the conversion.
palette.m_Entries[colorCount][i] = T(tmp) / T(255);//Hex palette is [0..255], convert to [0..1].
palette.m_Entries[colorCount][i] = static_cast<T>(tmp) / static_cast<T>(255);//Hex palette is [0..255], convert to [0..1].
}
colorCount++;
@ -659,12 +659,12 @@ void PaletteList<T>::ParsePalettes(xmlNode* node, const shared_ptr<string>& file
}
else if (!Compare(attr->name, "source_colors"))
{
string s(val);
auto vec1 = Split(s, ' ');
const string s(val);
const auto vec1 = Split(s, ' ');
for (auto& v : vec1)
{
auto vec2 = Split(v, ',');
const auto vec2 = Split(v, ',');
if (vec2.size() == 4)
{

View File

@ -211,7 +211,7 @@ public:
r = 0;
g = 0;
b = 0;
a = norm ? T(1) : T(255);
a = norm ? T{ 1 } : T{ 255 };
}
};
}

View File

@ -11,7 +11,7 @@ Renderer<T, bucketT>::Renderer()
{
//Use a very large number regardless of the size of the output pixels. This should be sufficient granularity, even though
//it's technically less than the number of distinct values representable by a 32-bit float.
m_Csa.resize(size_t(CURVES_LENGTH));
m_Csa.resize(static_cast<size_t>(CURVES_LENGTH));
//Ensure the renderer at least has sane values for the camera upon startup.
//This is needed because due to timing/threading disconnects, the GUI can use the camera
//values before the render has started, which will lead to corrupt values.
@ -114,7 +114,7 @@ void Renderer<T, bucketT>::ComputeBounds()
template <typename T, typename bucketT>
void Renderer<T, bucketT>::ComputeQuality()
{
m_Scale = std::pow(T(2.0), Zoom());
m_Scale = std::pow(static_cast<T>(2), Zoom());
m_ScaledQuality = Quality() * SQR(m_Scale);
}
@ -130,11 +130,11 @@ void Renderer<T, bucketT>::ComputeCamera()
m_PixelsPerUnitY = m_PixelsPerUnitX;
m_PixelsPerUnitX /= PixelAspectRatio();
T shift = 0;
T t0 = T(m_GutterWidth) / (Supersample() * m_PixelsPerUnitX);
T t1 = T(m_GutterWidth) / (Supersample() * m_PixelsPerUnitY);
T t0 = static_cast<T>(m_GutterWidth) / (Supersample() * m_PixelsPerUnitX);
T t1 = static_cast<T>(m_GutterWidth) / (Supersample() * m_PixelsPerUnitY);
//These go from ll to ur, moving from negative to positive.
m_LowerLeftX = CenterX() - FinalRasW() / m_PixelsPerUnitX / T(2.0);
m_LowerLeftY = CenterY() - FinalRasH() / m_PixelsPerUnitY / T(2.0);
m_LowerLeftX = CenterX() - FinalRasW() / m_PixelsPerUnitX / static_cast<T>(2);
m_LowerLeftY = CenterY() - FinalRasH() / m_PixelsPerUnitY / static_cast<T>(2);
m_UpperRightX = m_LowerLeftX + FinalRasW() / m_PixelsPerUnitX;
m_UpperRightY = m_LowerLeftY + FinalRasH() / m_PixelsPerUnitY;
T carLlX = m_LowerLeftX - t0;
@ -258,7 +258,8 @@ bool Renderer<T, bucketT>::CreateDEFilter(bool& newAlloc)
(m_Ember.m_CurveDE != m_DensityFilter->Curve()) ||
(m_Ember.m_Supersample != m_DensityFilter->Supersample()))
{
m_DensityFilter = make_unique<DensityFilter<bucketT>>(bucketT(m_Ember.m_MinRadDE), bucketT(m_Ember.m_MaxRadDE), bucketT(m_Ember.m_CurveDE), m_Ember.m_Supersample);
m_DensityFilter = make_unique<DensityFilter<bucketT>>(static_cast<bucketT>(m_Ember.m_MinRadDE), static_cast<bucketT>(m_Ember.m_MaxRadDE),
static_cast<bucketT>(m_Ember.m_CurveDE), m_Ember.m_Supersample);
newAlloc = true;
}
@ -297,7 +298,8 @@ bool Renderer<T, bucketT>::CreateSpatialFilter(bool& newAlloc)
(m_PixelAspectRatio != m_SpatialFilter->PixelAspectRatio()))
{
m_SpatialFilter = unique_ptr<SpatialFilter<bucketT>>(
SpatialFilterCreator<bucketT>::Create(m_Ember.m_SpatialFilterType, bucketT(m_Ember.m_SpatialFilterRadius), m_Ember.m_Supersample, bucketT(m_PixelAspectRatio)));
SpatialFilterCreator<bucketT>::Create(m_Ember.m_SpatialFilterType,
static_cast<bucketT>(m_Ember.m_SpatialFilterRadius), m_Ember.m_Supersample, static_cast<bucketT>(m_PixelAspectRatio)));
m_Ember.m_SpatialFilterRadius = m_SpatialFilter->FilterRadius();//It may have been changed internally if it was too small, so ensure they're synced.
newAlloc = true;
}
@ -315,6 +317,7 @@ template <typename T, typename bucketT>
bool Renderer<T, bucketT>::CreateTemporalFilter(bool& newAlloc)
{
newAlloc = false;
//static int i = 0;
//Use intelligent testing so it isn't created every time a new ember is passed in.
if ((!m_TemporalFilter.get()) ||
@ -326,6 +329,14 @@ bool Renderer<T, bucketT>::CreateTemporalFilter(bool& newAlloc)
m_TemporalFilter = unique_ptr<TemporalFilter<T>>(
TemporalFilterCreator<T>::Create(m_Ember.m_TemporalFilterType, m_Ember.m_TemporalSamples, m_Ember.m_TemporalFilterWidth, m_Ember.m_TemporalFilterExp));
newAlloc = true;
//auto name = TemporalFilterCreator<T>::ToString(m_TemporalFilter->FilterType());
//ostringstream os;
//os << "./" << ++i << "_" << name << "_filter.txt";
//ofstream of (os.str());
//auto str = m_TemporalFilter->ToString();
//
//if (of.is_open())
// of << str;
}
return m_TemporalFilter.get() != nullptr;
@ -421,7 +432,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<v4F>& finalImage, double time, si
}
//Make sure values are within valid range.
ClampGteRef(m_Ember.m_Supersample, size_t(1));
ClampGteRef(m_Ember.m_Supersample, static_cast<size_t>(1));
//Make sure to get most recent update since loop won't be entered to call Interp().
//Vib, gam and background are normally summed for each temporal sample. However if iteration is skipped, make sure to get the latest.
@ -442,7 +453,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<v4F>& finalImage, double time, si
//it.Tic();
//Interpolate.
if (m_EmbersP->size() > 1)
m_Interpolater.Interpolate(*m_EmbersP, T(time), 0, m_Ember);
m_Interpolater.Interpolate(*m_EmbersP, static_cast<T>(time), 0, m_Ember);
//it.Toc("Interp 1");
@ -480,7 +491,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<v4F>& finalImage, double time, si
}
}
deTime = T(time) + *m_TemporalFilter->Deltas();
deTime = static_cast<T>(time) + *m_TemporalFilter->Deltas();
//Interpolate and get an ember for DE purposes.
//Additional interpolation will be done in the temporal samples loop.
@ -506,7 +517,7 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<v4F>& finalImage, double time, si
for (; (temporalSample < TemporalSamples()) && !m_Abort;)
{
T colorScalar = m_TemporalFilter->Filter()[temporalSample];
T temporalTime = T(time) + m_TemporalFilter->Deltas()[temporalSample];
T temporalTime = static_cast<T>(time) + m_TemporalFilter->Deltas()[temporalSample];
//Interpolate again.
//it.Tic();
@ -573,9 +584,9 @@ eRenderStatus Renderer<T, bucketT>::Run(vector<v4F>& finalImage, double time, si
{
m_Vibrancy += Vibrancy();
m_Gamma += Gamma();
m_Background.r += bucketT(m_Ember.m_Background.r);
m_Background.g += bucketT(m_Ember.m_Background.g);
m_Background.b += bucketT(m_Ember.m_Background.b);
m_Background.r += static_cast<bucketT>(m_Ember.m_Background.r);
m_Background.g += static_cast<bucketT>(m_Ember.m_Background.g);
m_Background.b += static_cast<bucketT>(m_Ember.m_Background.b);
m_VibGamCount++;
m_LastIter = 0;
temporalSample++;
@ -617,14 +628,14 @@ FilterAndAccum:
//to be very dark. Correct it by pretending the number of iters done is the exact quality desired and then scale according to that.
if (forceOutput)
{
T quality = (T(m_Stats.m_Iters) / T(FinalDimensions())) * (m_Scale * m_Scale);
m_K2 = bucketT((Supersample() * Supersample()) / (area * quality * m_TemporalFilter->SumFilt()));
T quality = (static_cast<T>(m_Stats.m_Iters) / static_cast<T>(FinalDimensions())) * (m_Scale * m_Scale);
m_K2 = static_cast<bucketT>((Supersample() * Supersample()) / (area * quality * m_TemporalFilter->SumFilt()));
}
else
m_K2 = bucketT((Supersample() * Supersample()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt()));
m_K2 = static_cast<bucketT>((Supersample() * Supersample()) / (area * m_ScaledQuality * m_TemporalFilter->SumFilt()));
}
else
m_K2 = bucketT(m_Ember.m_K2);
m_K2 = static_cast<bucketT>(m_Ember.m_K2);
if (!ResetBuckets(false, true))//Only the histogram was reset above, now reset the density filtering buffer.
{
@ -692,7 +703,7 @@ AccumOnly:
//Make sure a filter has been created.
CreateSpatialFilter(newFilterAlloc);
m_DensityFilterOffset = m_GutterWidth - size_t(Clamp<T>((T(m_SpatialFilter->FinalFilterWidth()) - T(Supersample())) / 2, 0, T(m_GutterWidth)));
m_DensityFilterOffset = m_GutterWidth - static_cast<size_t>(Clamp<T>((static_cast<T>(m_SpatialFilter->FinalFilterWidth()) - static_cast<T>(Supersample())) / 2, 0, static_cast<T>(m_GutterWidth)));
m_CurvesSet = m_Ember.m_Curves.CurvesSet();
ComputeCurves();//Color curves must be re-calculated as well.
@ -747,7 +758,7 @@ EmberImageComments Renderer<T, bucketT>::ImageComments(const EmberStats& stats,
EmberImageComments comments;
ss.imbue(std::locale(""));
comments.m_Genome = m_EmberToXml.ToString(m_Ember, "", printEditDepth, false, hexPalette);
ss << (double(stats.m_Badvals) / double(stats.m_Iters));//Percentage of bad values to iters.
ss << (static_cast<double>(stats.m_Badvals) / static_cast<double>(stats.m_Iters));//Percentage of bad values to iters.
comments.m_Badvals = ss.str(); ss.str("");
ss << stats.m_Iters;
comments.m_NumIters = ss.str(); ss.str("");//Total iters.
@ -767,7 +778,7 @@ EmberImageComments Renderer<T, bucketT>::ImageComments(const EmberStats& stats,
template <typename T, typename bucketT>
void Renderer<T, bucketT>::MakeDmap(T colorScalar)
{
m_Ember.m_Palette.template MakeDmap<bucketT>(m_Dmap, bucketT(colorScalar));
m_Ember.m_Palette.template MakeDmap<bucketT>(m_Dmap, static_cast<bucketT>(colorScalar));
}
/// <summary>
@ -778,8 +789,8 @@ void Renderer<T, bucketT>::MakeDmap(T colorScalar)
template <typename T, typename bucketT>
bool Renderer<T, bucketT>::Alloc(bool histOnly)
{
bool b = true;
bool lock =
auto b = true;
const auto lock =
(m_SuperSize != m_HistBuckets.size()) ||
(m_SuperSize != m_AccumulatorBuckets.size()) ||
(m_ThreadsToUse != m_Samples.size()) ||
@ -888,14 +899,14 @@ bool Renderer<T, bucketT>::ResetBuckets(bool resetHist, bool resetAccum)
template <typename T, typename bucketT>
void Renderer<T, bucketT>::VectorizedLogScale(size_t row, size_t rowEnd)
{
float k1 = float(m_K1);//All types must be float.
float k2 = float(m_K2);
const auto k1 = static_cast<float>(m_K1);//All types must be float.
const auto k2 = static_cast<float>(m_K2);
auto* __restrict hist = m_HistBuckets.data();//Vectorizer can't tell these point to different locations.
auto* __restrict acc = m_AccumulatorBuckets.data();
for (size_t i = row; i < rowEnd; i++)
{
float logScale = (k1 * std::log(1.0f + hist[i].a * k2)) / (hist[i].a + std::numeric_limits<float>::epsilon());
const float logScale = (k1 * std::log(1.0f + hist[i].a * k2)) / (hist[i].a + std::numeric_limits<float>::epsilon());
acc[i].r = hist[i].r * logScale;//Must break these out individually. Vectorizer can't reason about vec4's overloaded * operator.
acc[i].g = hist[i].g * logScale;
acc[i].b = hist[i].b * logScale;
@ -919,7 +930,7 @@ eRenderStatus Renderer<T, bucketT>::LogScaleDensityFilter(bool forceOutput)
//Timing t(4);
//Original didn't parallelize this, doing so gives a 50-75% speedup.
//The value can be directly assigned, which is quicker than summing.
parallel_for(startRow, endRow, size_t(1), [&](size_t j)
parallel_for(startRow, endRow, static_cast<size_t>(1), [&](size_t j)
{
size_t row = j * m_SuperRasW;
size_t rowEnd = row + endCol;
@ -931,7 +942,7 @@ eRenderStatus Renderer<T, bucketT>::LogScaleDensityFilter(bool forceOutput)
//Check for visibility first before doing anything else to avoid all possible unnecessary calculations.
if (m_HistBuckets[i].a != 0)
{
bucketT logScale = (m_K1 * std::log(1 + m_HistBuckets[i].a * m_K2)) / m_HistBuckets[i].a;
const bucketT logScale = (m_K1 * std::log(1 + m_HistBuckets[i].a * m_K2)) / m_HistBuckets[i].a;
//Original did a temporary assignment, then *= logScale, then passed the result to bump_no_overflow().
//Combine here into one operation for a slight speedup.
//Vectorized version:
@ -969,30 +980,30 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
{
Timing totalTime, localTime;
bool scf = !(Supersample() & 1);
intmax_t ss = Floor<T>(Supersample() / T(2));
T scfact = std::pow(Supersample() / (Supersample() + T(1)), T(2));
intmax_t ss = Floor<T>(Supersample() / static_cast<T>(2));
T scfact = std::pow(Supersample() / (Supersample() + static_cast<T>(1)), static_cast<T>(2));
size_t threads = m_ThreadsToUse;
size_t startRow = Supersample() - 1;
size_t endRow = m_SuperRasH - (Supersample() - 1);//Original did + which is most likely wrong.
intmax_t startCol = Supersample() - 1;
intmax_t endCol = m_SuperRasW - (Supersample() - 1);
size_t chunkSize = size_t(ceil(double(endRow - startRow) / double(threads)));
size_t chunkSize = static_cast<size_t>(std::ceil(static_cast<double>(endRow - startRow) / static_cast<double>(threads)));
//parallel_for scales very well, dividing the work almost perfectly among all processors.
parallel_for(size_t(0), threads, size_t(1), [&] (size_t threadIndex)
parallel_for(static_cast<size_t>(0), threads, static_cast<size_t>(1), [&] (size_t threadIndex)
{
size_t pixelNumber = 0;
int localStartRow = int(std::min<size_t>(startRow + (threadIndex * chunkSize), endRow - 1));
int localEndRow = int(std::min<size_t>(localStartRow + chunkSize, endRow));
size_t pixelsThisThread = size_t(localEndRow - localStartRow) * m_SuperRasW;
const auto localStartRow = static_cast<intmax_t>(std::min<size_t>(startRow + (threadIndex * chunkSize), endRow - 1));
const auto localEndRow = static_cast<intmax_t>(std::min<size_t>(localStartRow + chunkSize, endRow));
const size_t pixelsThisThread = static_cast<size_t>(localEndRow - localStartRow) * m_SuperRasW;
double lastPercent = 0;
tvec4<bucketT, glm::defaultp> logScaleBucket;
for (intmax_t j = localStartRow; (j < localEndRow) && !m_Abort; j++)
{
auto buckets = m_HistBuckets.data();
auto bucketRowStart = buckets + (j * m_SuperRasW);//Pull out of inner loop for optimization.
auto filterCoefs = m_DensityFilter->Coefs();
auto filterWidths = m_DensityFilter->Widths();
const auto buckets = m_HistBuckets.data();
const auto bucketRowStart = buckets + (j * m_SuperRasW);//Pull out of inner loop for optimization.
const auto filterCoefs = m_DensityFilter->Coefs();
const auto filterWidths = m_DensityFilter->Widths();
for (intmax_t i = startCol; i < endCol; i++)
{
@ -1005,7 +1016,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
if (bucket->a == 0)
continue;
bucketT cacheLog = (m_K1 * std::log(1 + bucket->a * m_K2)) / bucket->a;//Caching this calculation gives a 30% speedup.
const bucketT cacheLog = (m_K1 * std::log(1 + bucket->a * m_K2)) / bucket->a;//Caching this calculation gives a 30% speedup.
if (ss == 0)
{
@ -1016,10 +1027,10 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
//The original contained a glaring flaw as it would run past the boundaries of the buffers
//when calculating the density for a box centered on the last row or column.
//Clamp here to not run over the edge.
intmax_t densityBoxLeftX = (i - std::min(i, ss));
intmax_t densityBoxRightX = (i + std::min(ss, intmax_t(m_SuperRasW) - i - 1));
intmax_t densityBoxTopY = (j - std::min(j, ss));
intmax_t densityBoxBottomY = (j + std::min(ss, intmax_t(m_SuperRasH) - j - 1));
const intmax_t densityBoxLeftX = (i - std::min(i, ss));
const intmax_t densityBoxRightX = (i + std::min(ss, static_cast<intmax_t>(m_SuperRasW) - i - 1));
const intmax_t densityBoxTopY = (j - std::min(j, ss));
const intmax_t densityBoxBottomY = (j + std::min(ss, static_cast<intmax_t>(m_SuperRasH) - j - 1));
//Count density in ssxss area.
//Original went one col at a time, which is cache inefficient. Go one row at at time here for a slight speedup.
@ -1035,9 +1046,9 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
if (filterSelect > m_DensityFilter->MaxFilteredCounts())
filterSelectInt = m_DensityFilter->MaxFilterIndex();
else if (filterSelect <= DE_THRESH)
filterSelectInt = size_t(ceil(filterSelect)) - 1;
filterSelectInt = static_cast<size_t>(std::ceil(filterSelect)) - 1;
else
filterSelectInt = DE_THRESH + size_t(Floor<T>(std::pow(filterSelect - DE_THRESH, m_DensityFilter->Curve())));
filterSelectInt = DE_THRESH + static_cast<size_t>(Floor<T>(std::pow(filterSelect - DE_THRESH, m_DensityFilter->Curve())));
//If the filter selected below the min specified clamp it to the min.
if (filterSelectInt > m_DensityFilter->MaxFilterIndex())
@ -1045,7 +1056,7 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
//Only have to calculate the values for ~1/8 of the square.
filterCoefIndex = filterSelectInt * m_DensityFilter->KernelSize();
arrFilterWidth = intmax_t(ceil(filterWidths[filterSelectInt])) - 1;
arrFilterWidth = static_cast<intmax_t>(std::ceil(filterWidths[filterSelectInt])) - 1;
for (jj = 0; jj <= arrFilterWidth; jj++)
{
@ -1096,13 +1107,13 @@ eRenderStatus Renderer<T, bucketT>::GaussianDensityFilter()
if (m_Callback && threadIndex == 0)
{
pixelNumber += m_SuperRasW;
double percent = (double(pixelNumber) / double(pixelsThisThread)) * 100.0;
double percentDiff = percent - lastPercent;
double toc = localTime.Toc();
const auto percent = (static_cast<double>(pixelNumber) / static_cast<double>(pixelsThisThread)) * 100.0;
const auto percentDiff = percent - lastPercent;
const auto toc = localTime.Toc();
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))
{
double etaMs = ((100.0 - percent) / percent) * totalTime.Toc();
const auto etaMs = ((100.0 - percent) / percent) * totalTime.Toc();
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 1, etaMs))
Abort();
@ -1144,7 +1155,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(vector<v4F>& pixels,
}
//Timing t(4);
size_t filterWidth = m_SpatialFilter->FinalFilterWidth();
const size_t filterWidth = m_SpatialFilter->FinalFilterWidth();
bucketT g, linRange, vibrancy;
Color<bucketT> background;
auto p = pixels.data();
@ -1155,10 +1166,10 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(vector<v4F>& pixels,
//The original does it this way as well and it's roughly 11 times faster to do it this way than inline below with each pixel.
if (EarlyClip())
{
parallel_for(size_t(0), m_SuperRasH, size_t(1), [&](size_t j)
parallel_for(static_cast<size_t>(0), m_SuperRasH, static_cast<size_t>(1), [&](size_t j)
{
auto rowStart = m_AccumulatorBuckets.data() + (j * m_SuperRasW);//Pull out of inner loop for optimization.
auto rowEnd = rowStart + m_SuperRasW;
const auto rowEnd = rowStart + m_SuperRasW;
while (rowStart < rowEnd && !m_Abort)//Use the pointer itself as the offset to save an extra addition per iter.
{
@ -1182,7 +1193,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(vector<v4F>& pixels,
//otherwise artifacts that resemble page tearing will occur in an interactive run. It's
//critical to never exit this loop prematurely.
//for (size_t j = 0; j < FinalRasH(); j++)//Keep around for debugging.
parallel_for(size_t(0), FinalRasH(), size_t(1), [&](size_t j)
parallel_for(static_cast<size_t>(0), FinalRasH(), static_cast<size_t>(1), [&](size_t j)
{
Color<bucketT> newBucket;
size_t pixelsRowStart = (m_YAxisUp ? ((FinalRasH() - j) - 1) : j) * FinalRasW();//Pull out of inner loop for optimization.
@ -1193,8 +1204,8 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(vector<v4F>& pixels,
for (size_t i = 0; i < FinalRasW(); i++, pv4T++)
{
size_t ii, jj;
size_t x = m_DensityFilterOffset + (i * Supersample());//Start at the beginning column of each super sample block.
size_t clampedFilterW = std::min(filterWidth, m_SuperRasW - x);//Make sure the filter doesn't go past the right of the gutter.
const size_t x = m_DensityFilterOffset + (i * Supersample());//Start at the beginning column of each super sample block.
const size_t clampedFilterW = std::min(filterWidth, m_SuperRasW - x);//Make sure the filter doesn't go past the right of the gutter.
newBucket.Clear();
//Original was iterating column-wise, which is slow.
@ -1233,7 +1244,7 @@ eRenderStatus Renderer<T, bucketT>::AccumulatorToFinalImage(vector<v4F>& pixels,
{
for (i = 0; i < FinalRasW(); i++)
{
auto pp = p + (i + j * FinalRasW());
const auto pp = p + (i + j * FinalRasW());
pp->r = m_TempEmber.m_Palette[i * 256 / FinalRasW()][0];
pp->g = m_TempEmber.m_Palette[i * 256 / FinalRasW()][1];
pp->b = m_TempEmber.m_Palette[i * 256 / FinalRasW()][2];
@ -1266,7 +1277,7 @@ EmberStats Renderer<T, bucketT>::Iterate(size_t iterCount, size_t temporalSample
{
//Timing t2(4);
m_IterTimer.Tic();
size_t totalItersPerThread = size_t(ceil(double(iterCount) / double(m_ThreadsToUse)));
const size_t totalItersPerThread = static_cast<size_t>(std::ceil(static_cast<double>(iterCount) / static_cast<double>(m_ThreadsToUse)));
EmberStats stats;
//vector<double> accumTimes(4);
@ -1277,16 +1288,16 @@ EmberStats Renderer<T, bucketT>::Iterate(size_t iterCount, size_t temporalSample
m_ThreadEmbers.insert(m_ThreadEmbers.begin(), m_ThreadsToUse, m_Ember);
}
parallel_for(size_t(0), m_ThreadsToUse, size_t(1), [&] (size_t threadIndex)
parallel_for(static_cast<size_t>(0), m_ThreadsToUse, static_cast<size_t>(1), [&] (size_t threadIndex)
{
#if defined(_WIN32)
SetThreadPriority(GetCurrentThread(), int(m_Priority));
SetThreadPriority(GetCurrentThread(), static_cast<int>(m_Priority));
#elif defined(__APPLE__)
sched_param sp = {0};
sp.sched_priority = int(m_Priority);
sp.sched_priority = static_cast<int>(m_Priority);
pthread_setschedparam(pthread_self(), SCHED_RR, &sp);
#else
pthread_setschedprio(pthread_self(), int(m_Priority));
pthread_setschedprio(pthread_self(), static_cast<int>(m_Priority));
#endif
//Timing t;
IterParams<T> params;
@ -1334,27 +1345,27 @@ EmberStats Renderer<T, bucketT>::Iterate(size_t iterCount, size_t temporalSample
if (m_Callback && threadIndex == 0)
{
auto percent = 100.0 *
double
static_cast<double>
(
double
static_cast<double>
(
double
static_cast<double>
(
//Takes progress of current thread and multiplies by thread count.
//This assumes the threads progress at roughly the same speed.
//Adding m_LastIter is done so that an incremental render still gives an accurate percentage.
double(m_LastIter + (m_SubBatch[threadIndex] * m_ThreadsToUse)) / double(ItersPerTemporalSample())
static_cast<double>(m_LastIter + (m_SubBatch[threadIndex] * m_ThreadsToUse)) / static_cast<double>(ItersPerTemporalSample())
) + temporalSample
) / double(TemporalSamples())
) / static_cast<double>(TemporalSamples())
);
double percentDiff = percent - m_LastIterPercent;
double toc = m_ProgressTimer.Toc();
const auto percentDiff = percent - m_LastIterPercent;
const auto toc = m_ProgressTimer.Toc();
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))//Call callback function if either 10% has passed, or one second (and 1%).
{
auto startingpercent = 100.0 * (m_LastIter / double(ItersPerTemporalSample()));//This is done to support incremental renders, starting from the percentage it left off on.
auto currentpercent = percent - startingpercent;//Current percent in terms of starting percentage. So starting at 50% and progressing 5% will give a value of 5%, not 55%.
auto etaMs = currentpercent == 0 ? 0 : (((100.0 - startingpercent) - currentpercent) / currentpercent) * m_RenderTimer.Toc();//Subtract startingpercent from 100% so that it's properly scaled, meaning rendering from 50% - 100% will be treated as 0% - 100%.
const auto startingpercent = 100.0 * (m_LastIter / static_cast<double>(ItersPerTemporalSample()));//This is done to support incremental renders, starting from the percentage it left off on.
const auto currentpercent = percent - startingpercent;//Current percent in terms of starting percentage. So starting at 50% and progressing 5% will give a value of 5%, not 55%.
const auto etaMs = currentpercent == 0 ? 0 : (((100.0 - startingpercent) - currentpercent) / currentpercent) * m_RenderTimer.Toc();//Subtract startingpercent from 100% so that it's properly scaled, meaning rendering from 50% - 100% will be treated as 0% - 100%.
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 0, etaMs))
Abort();
@ -1418,11 +1429,11 @@ template <typename T, typename bucketT> TemporalFilter<T>* Renderer<T, buck
/// Virtual renderer properties overridden from RendererBase, getters only.
/// </summary>
template <typename T, typename bucketT> double Renderer<T, bucketT>::ScaledQuality() const { return double(m_ScaledQuality); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::LowerLeftX(bool gutter) const { return double(gutter ? m_CarToRas.CarLlX() : m_LowerLeftX); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::LowerLeftY(bool gutter) const { return double(gutter ? m_CarToRas.CarLlY() : m_LowerLeftY); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::UpperRightX(bool gutter) const { return double(gutter ? m_CarToRas.CarUrX() : m_UpperRightX); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::UpperRightY(bool gutter) const { return double(gutter ? m_CarToRas.CarUrY() : m_UpperRightY); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::ScaledQuality() const { return static_cast<double>(m_ScaledQuality); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::LowerLeftX(bool gutter) const { return static_cast<double>(gutter ? m_CarToRas.CarLlX() : m_LowerLeftX); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::LowerLeftY(bool gutter) const { return static_cast<double>(gutter ? m_CarToRas.CarLlY() : m_LowerLeftY); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::UpperRightX(bool gutter) const { return static_cast<double>(gutter ? m_CarToRas.CarUrX() : m_UpperRightX); }
template <typename T, typename bucketT> double Renderer<T, bucketT>::UpperRightY(bool gutter) const { return static_cast<double>(gutter ? m_CarToRas.CarUrY() : m_UpperRightY); }
template <typename T, typename bucketT> DensityFilterBase* Renderer<T, bucketT>::GetDensityFilter() { return m_DensityFilter.get(); }
/// <summary>
@ -1440,11 +1451,11 @@ template <typename T, typename bucketT> T Renderer<T, bucket
template <typename T, typename bucketT> T Renderer<T, bucketT>::CenterX() const { return m_Ember.m_CenterX; }
template <typename T, typename bucketT> T Renderer<T, bucketT>::CenterY() const { return m_Ember.m_CenterY; }
template <typename T, typename bucketT> T Renderer<T, bucketT>::Rotate() const { return m_Ember.m_Rotate; }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::Brightness() const { return bucketT(m_Ember.m_Brightness); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::Gamma() const { return bucketT(m_Ember.m_Gamma); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::Vibrancy() const { return bucketT(m_Ember.m_Vibrancy); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::GammaThresh() const { return bucketT(m_Ember.m_GammaThresh); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::HighlightPower() const { return bucketT(m_Ember.m_HighlightPower); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::Brightness() const { return static_cast<bucketT>(m_Ember.m_Brightness); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::Gamma() const { return static_cast<bucketT>(m_Ember.m_Gamma); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::Vibrancy() const { return static_cast<bucketT>(m_Ember.m_Vibrancy); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::GammaThresh() const { return static_cast<bucketT>(m_Ember.m_GammaThresh); }
template <typename T, typename bucketT> bucketT Renderer<T, bucketT>::HighlightPower() const { return static_cast<bucketT>(m_Ember.m_HighlightPower); }
template <typename T, typename bucketT> Color<T> Renderer<T, bucketT>::Background() const { return m_Ember.m_Background; }
template <typename T, typename bucketT> const Xform<T>* Renderer<T, bucketT>::Xforms() const { return m_Ember.Xforms(); }
template <typename T, typename bucketT> Xform<T>* Renderer<T, bucketT>::NonConstXforms() { return m_Ember.NonConstXforms(); }
@ -1491,13 +1502,13 @@ void Renderer<T, bucketT>::PrepFinalAccumVals(Color<bucketT>& background, bucket
//sample, which means the values will be zero.
vibrancy = m_Vibrancy == 0 ? Vibrancy() : m_Vibrancy;
size_t vibGamCount = m_VibGamCount == 0 ? 1 : m_VibGamCount;
bucketT gamma = m_Gamma == 0 ? Gamma() : m_Gamma;
g = 1 / ClampGte<bucketT>(gamma / vibGamCount, bucketT(0.01));//Ensure a divide by zero doesn't occur.
const bucketT gamma = m_Gamma == 0 ? Gamma() : m_Gamma;
g = 1 / ClampGte<bucketT>(gamma / vibGamCount, static_cast<bucketT>(0.01));//Ensure a divide by zero doesn't occur.
linRange = GammaThresh();
vibrancy /= vibGamCount;
background.x = (IsNearZero(m_Background.r) ? bucketT(m_Ember.m_Background.r) : m_Background.r) / vibGamCount;
background.y = (IsNearZero(m_Background.g) ? bucketT(m_Ember.m_Background.g) : m_Background.g) / vibGamCount;
background.z = (IsNearZero(m_Background.b) ? bucketT(m_Ember.m_Background.b) : m_Background.b) / vibGamCount;
background.x = (IsNearZero(m_Background.r) ? static_cast<bucketT>(m_Ember.m_Background.r) : m_Background.r) / vibGamCount;
background.y = (IsNearZero(m_Background.g) ? static_cast<bucketT>(m_Ember.m_Background.g) : m_Background.g) / vibGamCount;
background.z = (IsNearZero(m_Background.b) ? static_cast<bucketT>(m_Ember.m_Background.b) : m_Background.b) / vibGamCount;
}
/// <summary>
@ -1516,7 +1527,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
{
size_t histIndex, intColorIndex, histSize = m_HistBuckets.size();
bucketT colorIndex, colorIndexFrac;
auto psm1 = m_Ember.m_Palette.Size() - 1;
const auto psm1 = m_Ember.m_Palette.Size() - 1;
//Linear is a linear scale for when the color index is not a whole number, which is most of the time.
//It uses a portion of the value of the index, and the remainder of the next index.
@ -1526,7 +1537,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
//Use overloaded addition and multiplication operators in vec4 to perform the accumulation.
if (PaletteMode() == ePaletteMode::PALETTE_LINEAR)
{
auto psm2 = psm1 - 1;
const auto psm2 = psm1 - 1;
//It's critical to understand what's going on here as it's one of the most important parts of the algorithm.
//A color value gets retrieved from the palette and
@ -1564,8 +1575,8 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
//This will result in a few points at the very edges getting discarded, but prevents a crash and doesn't seem to make a speed difference.
if (histIndex < histSize)
{
colorIndex = bucketT(p.m_ColorX) * psm1;
intColorIndex = size_t(colorIndex);
colorIndex = static_cast<bucketT>(p.m_ColorX) * psm1;
intColorIndex = static_cast<size_t>(colorIndex);
if (intColorIndex < 0)
{
@ -1579,13 +1590,13 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
}
else
{
colorIndexFrac = colorIndex - bucketT(intColorIndex);//Interpolate between intColorIndex and intColorIndex + 1.
colorIndexFrac = colorIndex - static_cast<bucketT>(intColorIndex);//Interpolate between intColorIndex and intColorIndex + 1.
}
bucketT* __restrict hist = glm::value_ptr(m_HistBuckets[histIndex]);//Vectorizer can't tell these point to different locations.
const bucketT* __restrict pal = glm::value_ptr(palette->m_Entries[intColorIndex]);
const bucketT* __restrict pal2 = glm::value_ptr(palette->m_Entries[intColorIndex + 1]);
auto cifm1 = bucketT(1) - colorIndexFrac;
const auto cifm1 = static_cast<bucketT>(1) - colorIndexFrac;
//Loops are unrolled to allow auto vectorization.
if (p.m_Opacity == 1)
@ -1597,7 +1608,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
}
else
{
auto va = bucketT(p.m_Opacity);
const auto va = static_cast<bucketT>(p.m_Opacity);
hist[0] += ((pal[0] * cifm1) + (pal2[0] * colorIndexFrac)) * va;
hist[1] += ((pal[1] * cifm1) + (pal2[1] * colorIndexFrac)) * va;
hist[2] += ((pal[2] * cifm1) + (pal2[2] * colorIndexFrac)) * va;
@ -1618,8 +1629,8 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
{
if (Rotate() != 0)
{
T p00 = p.m_X - m_Ember.m_CenterX;
T p11 = p.m_Y - m_Ember.m_RotCenterY;
const T p00 = p.m_X - m_Ember.m_CenterX;
const T p11 = p.m_Y - m_Ember.m_RotCenterY;
p.m_X = (p00 * m_RotMat.A()) + (p11 * m_RotMat.B()) + m_Ember.m_CenterX;
p.m_Y = (p00 * m_RotMat.D()) + (p11 * m_RotMat.E()) + m_Ember.m_RotCenterY;
}
@ -1630,7 +1641,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
if (histIndex < histSize)
{
intColorIndex = Clamp<size_t>(size_t(p.m_ColorX * psm1), 0, psm1);
intColorIndex = Clamp<size_t>(static_cast<size_t>(p.m_ColorX * psm1), 0, psm1);
bucketT* __restrict hist = glm::value_ptr(m_HistBuckets[histIndex]);//Vectorizer can't tell these point to different locations.
const bucketT* __restrict pal = glm::value_ptr(palette->m_Entries[intColorIndex]);
@ -1643,7 +1654,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
}
else
{
auto va = bucketT(p.m_Opacity);
auto va = static_cast<bucketT>(p.m_Opacity);
hist[0] += pal[0] * va;
hist[1] += pal[1] * va;
hist[2] += pal[2] * va;
@ -1667,7 +1678,7 @@ void Renderer<T, bucketT>::Accumulate(QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand, Poin
template <typename T, typename bucketT>
void Renderer<T, bucketT>::AddToAccum(const tvec4<bucketT, glm::defaultp>& bucket, intmax_t i, intmax_t ii, intmax_t j, intmax_t jj)
{
if (j + jj >= 0 && j + jj < intmax_t(m_SuperRasH) && i + ii >= 0 && i + ii < intmax_t(m_SuperRasW))
if (j + jj >= 0 && j + jj < static_cast<intmax_t>(m_SuperRasH) && i + ii >= 0 && i + ii < static_cast<intmax_t>(m_SuperRasW))
{
auto* __restrict accum = m_AccumulatorBuckets.data() + ((i + ii) + ((j + jj) * m_SuperRasW));//For vectorizer, results in a 33% speedup.
accum->r += bucket.r;
@ -1695,7 +1706,7 @@ template <typename T, typename bucketT>
template <typename accumT>
void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket, Color<bucketT>& background, bucketT g, bucketT linRange, bucketT vibrancy, bool scale, accumT* correctedChannels)
{
auto bt1 = bucketT(1);
auto bt1 = static_cast<bucketT>(1);
if (scale && EarlyClip())
{
@ -1706,10 +1717,10 @@ void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket
CurveAdjust(bucket.b, 3);
}
correctedChannels[0] = accumT(Clamp<bucketT>(bucket.r, 0, bt1));
correctedChannels[1] = accumT(Clamp<bucketT>(bucket.g, 0, bt1));
correctedChannels[2] = accumT(Clamp<bucketT>(bucket.b, 0, bt1));
correctedChannels[3] = accumT(Clamp<bucketT>(bucket.a, 0, bt1));
correctedChannels[0] = static_cast<accumT>(Clamp<bucketT>(bucket.r, 0, bt1));
correctedChannels[1] = static_cast<accumT>(Clamp<bucketT>(bucket.g, 0, bt1));
correctedChannels[2] = static_cast<accumT>(Clamp<bucketT>(bucket.b, 0, bt1));
correctedChannels[3] = static_cast<accumT>(Clamp<bucketT>(bucket.a, 0, bt1));
}
else
{
@ -1737,10 +1748,10 @@ void Renderer<T, bucketT>::GammaCorrection(tvec4<bucketT, glm::defaultp>& bucket
if (scale && m_CurvesSet)
CurveAdjust(a, rgbi + 1);
correctedChannels[rgbi] = accumT(Clamp<bucketT>(a, 0, bt1));//Early clip, just assign directly.
correctedChannels[rgbi] = static_cast<accumT>(Clamp<bucketT>(a, 0, bt1));//Early clip, just assign directly.
}
correctedChannels[3] = accumT(alpha);
correctedChannels[3] = static_cast<accumT>(alpha);
}
}
@ -1775,8 +1786,8 @@ void Renderer<T, bucketT>::ComputeCurves()
template <typename T, typename bucketT>
void Renderer<T, bucketT>::CurveAdjust(bucketT& a, const glm::length_t& index)
{
size_t tempIndex = size_t(Clamp<bucketT>(a * CURVES_LENGTH_M1, 0, CURVES_LENGTH_M1));
size_t tempIndex2 = size_t(Clamp<bucketT>(m_Csa[tempIndex].x * CURVES_LENGTH_M1, 0, CURVES_LENGTH_M1));
size_t tempIndex = static_cast<size_t>(Clamp<bucketT>(a * CURVES_LENGTH_M1, 0, CURVES_LENGTH_M1));
size_t tempIndex2 = static_cast<size_t>(Clamp<bucketT>(m_Csa[tempIndex].x * CURVES_LENGTH_M1, 0, CURVES_LENGTH_M1));
a = m_Csa[tempIndex2][index];
}

View File

@ -55,21 +55,21 @@ public:
bool AssignIterator();
//Virtual processing functions overriden from RendererBase.
virtual void Prepare() override;
virtual void ComputeBounds() override;
virtual void ComputeQuality() override;
virtual void ComputeCamera() override;
virtual void SetEmber(const Ember<T>& ember, eProcessAction action = eProcessAction::FULL_RENDER, bool prep = false) override;
void Prepare() override;
void ComputeBounds() override;
void ComputeQuality() override;
void ComputeCamera() override;
void SetEmber(const Ember<T>& ember, eProcessAction action = eProcessAction::FULL_RENDER, bool prep = false) override;
template <typename C>
void SetEmber(const C& embers);
void MoveEmbers(vector<Ember<T>>& embers);
void SetExternalEmbersPointer(vector<Ember<T>>* embers);
virtual bool CreateDEFilter(bool& newAlloc) override;
virtual bool CreateSpatialFilter(bool& newAlloc) override;
virtual bool CreateTemporalFilter(bool& newAlloc) override;
virtual size_t HistBucketSize() const override { return sizeof(tvec4<bucketT, glm::defaultp>); }
virtual eRenderStatus Run(vector<v4F>& finalImage, double time = 0, size_t subBatchCountOverride = 0, bool forceOutput = false, size_t finalOffset = 0) override;
virtual EmberImageComments ImageComments(const EmberStats& stats, size_t printEditDepth = 0, bool hexPalette = true) override;
bool CreateDEFilter(bool& newAlloc) override;
bool CreateSpatialFilter(bool& newAlloc) override;
bool CreateTemporalFilter(bool& newAlloc) override;
size_t HistBucketSize() const override { return sizeof(tvec4<bucketT, glm::defaultp>); }
eRenderStatus Run(vector<v4F>& finalImage, double time = 0, size_t subBatchCountOverride = 0, bool forceOutput = false, size_t finalOffset = 0) override;
EmberImageComments ImageComments(const EmberStats& stats, size_t printEditDepth = 0, bool hexPalette = true) override;
protected:
//New virtual functions to be overridden in derived renderers that use the GPU, but not accessed outside.
@ -100,12 +100,12 @@ public:
inline TemporalFilter<T>* GetTemporalFilter();
//Virtual renderer properties overridden from RendererBase, getters only.
virtual double ScaledQuality() const override;
virtual double LowerLeftX(bool gutter = true) const override;
virtual double LowerLeftY(bool gutter = true) const override;
virtual double UpperRightX(bool gutter = true) const override;
virtual double UpperRightY(bool gutter = true) const override;
virtual DensityFilterBase* GetDensityFilter() override;
double ScaledQuality() const override;
double LowerLeftX(bool gutter = true) const override;
double LowerLeftY(bool gutter = true) const override;
double UpperRightX(bool gutter = true) const override;
double UpperRightY(bool gutter = true) const override;
DensityFilterBase* GetDensityFilter() override;
//Non-virtual ember wrappers, getters only.
inline bool XaosPresent() const;
@ -135,11 +135,11 @@ public:
inline ePaletteMode PaletteMode() const;
//Virtual ember wrappers overridden from RendererBase, getters only.
virtual size_t TemporalSamples() const override;
virtual size_t FinalRasW() const override;
virtual size_t FinalRasH() const override;
virtual size_t SubBatchSize() const override;
virtual size_t FuseCount() const override;
size_t TemporalSamples() const override;
size_t FinalRasW() const override;
size_t FinalRasH() const override;
size_t SubBatchSize() const override;
size_t FuseCount() const override;
//Non-virtual iterator wrappers.
const byte* XformDistributions() const;

View File

@ -174,7 +174,7 @@ bool RendererBase::RandVec(vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>>& randVec)
bool RendererBase::PrepFinalAccumVector(vector<v4F>& pixels)
{
EnterResize();
size_t size = FinalDimensions();
const auto size = FinalDimensions();
if (m_ReclaimOnResize)
{
@ -264,8 +264,8 @@ size_t RendererBase::FinalBufferSize() const { return FinalRowSize() *
size_t RendererBase::PixelSize() const { return NumChannels() * BytesPerChannel(); }
size_t RendererBase::GutterWidth() const { return m_GutterWidth; }
size_t RendererBase::DensityFilterOffset() const { return m_DensityFilterOffset; }
size_t RendererBase::TotalIterCount(size_t strips) const { return size_t(size_t(Round(ScaledQuality())) * FinalRasW() * FinalRasH() * strips); }//Use Round() because there can be some roundoff error when interpolating.
size_t RendererBase::ItersPerTemporalSample() const { return size_t(ceil(double(TotalIterCount(1)) / double(TemporalSamples()))); }//Temporal samples is used with animation, which doesn't support strips, so pass 1.
size_t RendererBase::TotalIterCount(size_t strips) const { return static_cast<size_t>(static_cast<size_t>(Round(ScaledQuality())) * FinalRasW() * FinalRasH() * strips); }//Use Round() because there can be some roundoff error when interpolating.
size_t RendererBase::ItersPerTemporalSample() const { return static_cast<size_t>(std::ceil(static_cast<double>(TotalIterCount(1)) / static_cast<double>(TemporalSamples()))); }//Temporal samples is used with animation, which doesn't support strips, so pass 1.
eProcessState RendererBase::ProcessState() const { return m_ProcessState; }
eProcessAction RendererBase::ProcessAction() const { return m_ProcessAction; }
EmberStats RendererBase::Stats() const { return m_Stats; }

View File

@ -114,7 +114,7 @@ public:
//First clear out any xforms that are not the final, and have a density of less than 0.001.
while (auto xform = ember.GetXform(i))
while (const auto xform = ember.GetXform(i))
{
if (xform->m_Weight < T(0.001))
{
@ -130,18 +130,17 @@ public:
//Now consider all xforms, including final.
i = 0;
while (auto xform = ember.GetTotalXform(i))
while (const auto xform = ember.GetTotalXform(i))
{
do
{
Variation<T>* var = nullptr;
Variation<T>* smallestVar = nullptr;
numVars = 0;
smallest = -1;
for (j = 0; j < xform->TotalVariationCount(); j++)
{
var = xform->GetVariation(j);
const auto var = xform->GetVariation(j);
if (var && var->m_Weight != 0.0)
{
@ -224,15 +223,15 @@ public:
for (size_t i = 0; i < ember.TotalXformCount(); i++)
{
auto xform1 = ember.GetTotalXform(i);
auto xform2 = mutation.GetTotalXform(i);
const auto xform1 = ember.GetTotalXform(i);
const auto xform2 = mutation.GetTotalXform(i);
if (xform1 && xform2)
{
for (size_t j = 0; j < xform1->TotalVariationCount(); j++)
{
Variation<T>* var1 = xform1->GetVariation(j);
Variation<T>* var2 = xform2->GetVariationById(var1->VariationId());
const auto var1 = xform1->GetVariation(j);
const auto var2 = xform2->GetVariationById(var1->VariationId());
if ((var1 == nullptr) ^ (var2 == nullptr))//If any of them are different, clear the first and copy all of the second and exit the while loop.
{
@ -255,8 +254,8 @@ public:
Random(mutation, useVars, sym, 2, maxVars);
//Which xform to mutate?
modXform = m_Rand.Rand(ember.TotalXformCount());
auto xform1 = ember.GetTotalXform(modXform);
auto xform2 = mutation.GetTotalXform(0);
const auto xform1 = ember.GetTotalXform(modXform);
const auto xform2 = mutation.GetTotalXform(0);
os << "mutate xform " << modXform << " coefs";
//If less than 3 xforms, then change only the translation part.
@ -279,14 +278,14 @@ public:
}
else if (mode == eMutateMode::MUTATE_POST_XFORMS)
{
bool same = (m_Rand.Rand() & 3) > 0;//25% chance of using the same post for all of them.
const auto same = (m_Rand.Rand() & 3) > 0;//25% chance of using the same post for all of them.
size_t b = 1 + m_Rand.Rand(6);
os << "mutate post xforms " << b << (same ? " same" : "");
for (size_t i = 0; i < ember.TotalXformCount(); i++)
{
bool copy = (i > 0) && same;
auto xform = ember.GetTotalXform(i);
const auto copy = (i > 0) && same;
const auto xform = ember.GetTotalXform(i);
if (copy)//Copy the post from the first xform to the rest of them.
{
@ -297,7 +296,7 @@ public:
//50% chance.
if (b & 1)
{
T f = T(M_PI) * m_Rand.Frand11<T>();
auto f = static_cast<T>(M_PI) * m_Rand.Frand11<T>();
T ra, rb, rd, re;
ra = (xform->m_Affine.A() * std::cos(f) + xform->m_Affine.B() * -std::sin(f));
rd = (xform->m_Affine.A() * std::sin(f) + xform->m_Affine.D() * std::cos(f));
@ -321,8 +320,8 @@ public:
//33% chance.
if (b & 2)
{
T f = T(0.2) + m_Rand.Frand01<T>();
T g = T(0.2) + m_Rand.Frand01<T>();
auto f = static_cast<T>(0.2) + m_Rand.Frand01<T>();
auto g = static_cast<T>(0.2) + m_Rand.Frand01<T>();
if (m_Rand.RandBit())
f = 1 / f;
@ -344,8 +343,8 @@ public:
if (b & 4)//16% chance.
{
T f = m_Rand.Frand11<T>();
T g = m_Rand.Frand11<T>();
const auto f = m_Rand.Frand11<T>();
const auto g = m_Rand.Frand11<T>();
xform->m_Affine.C(xform->m_Affine.C() - f);
xform->m_Affine.F(xform->m_Affine.F() - g);
xform->m_Post.C(xform->m_Post.C() + f);
@ -356,7 +355,7 @@ public:
}
else if (mode == eMutateMode::MUTATE_COLOR_PALETTE)
{
T s = m_Rand.Frand01<T>();
const auto s = m_Rand.Frand01<T>();
if (s < T(0.4))//Randomize xform color coords.
{
@ -401,8 +400,8 @@ public:
//Change all the coefs by a fraction of the random.
for (size_t x = 0; x < ember.TotalXformCount(); x++)
{
auto xform1 = ember.GetTotalXform(x);
auto xform2 = mutation.GetTotalXform(x);
const auto xform1 = ember.GetTotalXform(x);
const auto xform2 = mutation.GetTotalXform(x);
for (glm::length_t i = 0; i < 2; i++)
for (glm::length_t j = 0; j < 3; j++)
@ -432,7 +431,7 @@ public:
if (crossMode == eCrossMode::CROSS_NOT_SPECIFIED)
{
T s = m_Rand.Frand01<T>();
const auto s = m_Rand.Frand01<T>();
if (s < 0.1)
crossMode = eCrossMode::CROSS_UNION;
@ -558,7 +557,7 @@ public:
{
//Select the starting parent.
size_t ci;
uint startParent = m_Rand.RandBit();
auto startParent = m_Rand.RandBit();
os << " cmap_cross " << startParent << ":";
//Loop over the entries, switching to the other parent 1% of the time.
@ -651,7 +650,7 @@ public:
//Loop over xforms.
for (i = 0; i < ember.TotalXformCount(); i++)
{
auto xform = ember.GetTotalXform(i);
const auto xform = ember.GetTotalXform(i);
xform->m_Weight = T(1) / ember.TotalXformCount();
xform->m_ColorX = m_Rand.Frand01<T>();//Original pingponged between 0 and 1, which gives bad coloring. Ember does random instead.
xform->m_ColorY = m_Rand.Frand01<T>();//Will need to update this if 2D coordinates are ever supported.
@ -722,7 +721,7 @@ public:
if (var != -2)
{
//Pick a random variation and use a random weight from 0-1.
Variation<T>* v = m_VariationList->GetVariationCopy(static_cast<size_t>(m_Rand.Rand(varCount)), m_Rand.Frand<T>(T(0.001), 1));
auto v = m_VariationList->GetVariationCopy(static_cast<size_t>(m_Rand.Rand(varCount)), m_Rand.Frand<T>(static_cast<T>(0.001), 1));
if (v && !xform->AddVariation(v))
delete v;//It already existed and therefore was not added.
@ -730,7 +729,7 @@ public:
else
{
//Pick a random variation from the suppled IDs and use a random weight from 0-1.
Variation<T>* v = m_VariationList->GetVariationCopy(useVars[m_Rand.Rand(useVars.size())], m_Rand.Frand<T>(T(0.001), 1));
auto v = m_VariationList->GetVariationCopy(useVars[m_Rand.Rand(useVars.size())], m_Rand.Frand<T>(static_cast<T>(0.001), 1));
if (v && !xform->AddVariation(v))
delete v;
@ -760,12 +759,12 @@ public:
if (var != -2)
{
//Pick a random variation and use a random weight from 0-1.
xform->AddVariation(m_VariationList->GetVariationCopy(static_cast<size_t>(m_Rand.Rand(varCount)), m_Rand.Frand<T>(T(0.001), 1)));
xform->AddVariation(m_VariationList->GetVariationCopy(static_cast<size_t>(m_Rand.Rand(varCount)), m_Rand.Frand<T>(static_cast<T>(0.001), 1)));
}
else
{
//Pick a random variation from the suppled IDs and use a random weight from 0-1.
xform->AddVariation(m_VariationList->GetVariationCopy(useVars[m_Rand.Rand(useVars.size())], m_Rand.Frand<T>(T(0.001), 1)));
xform->AddVariation(m_VariationList->GetVariationCopy(useVars[m_Rand.Rand(useVars.size())], m_Rand.Frand<T>(static_cast<T>(0.001), 1)));
}
}
}
@ -865,16 +864,16 @@ public:
for (i = 0; i < m_FinalImage.size(); i++)
{
auto& p = m_FinalImage[i];
m_Hist[size_t((p.r * res) +
(p.g * res) * res +
(p.b * res) * res * res)]++;//A specific histogram index representing the sum of R,G,B values.
m_Hist[static_cast<size_t>((p.r * res) +
(p.g * res) * res +
(p.b * res) * res * res)]++;//A specific histogram index representing the sum of R,G,B values.
}
for (i = 0; i < res3; i++)
if (m_Hist[i])//The greater range of RGB values used...
hits++;
return T(hits / res3);//...the higher this returned ratio will be.
return static_cast<T>(hits / res3);//...the higher this returned ratio will be.
}
/// <summary>
@ -903,8 +902,8 @@ public:
ember.GetTotalXform(i)->m_ColorY = m_Rand.Frand01<T>();
}
auto xform0 = RandomXform(ember, -1);
auto xform1 = RandomXform(ember, ember.GetXformIndex(xform0));
const auto xform0 = RandomXform(ember, -1);
const auto xform1 = RandomXform(ember, ember.GetXformIndex(xform0));
if (xform0 && (m_Rand.RandBit()))
{
@ -936,10 +935,9 @@ public:
if (i != excluded)
{
auto xform = ember.GetTotalXform(i);
if (xform->m_Weight > 0)
return xform;
if (const auto xform = ember.GetTotalXform(i))
if (xform->m_Weight > 0)
return xform;
}
}
@ -963,10 +961,10 @@ public:
//the result xforms before rotate is called.
for (size_t i = 0; i < ember.TotalXformCount(); i++)
{
auto xform1 = ember.GetTotalXform(i);
auto xform2 = rotated.GetTotalXform(i);
const auto xform1 = ember.GetTotalXform(i);
const auto xform2 = rotated.GetTotalXform(i);
if (!xform1->m_Motion.empty())
if (xform1 && xform2 && !xform1->m_Motion.empty())
xform2->ApplyMotion(*xform1, blend);
}
@ -998,10 +996,10 @@ public:
for (i = 0; i < m_EdgePrealign[si].TotalXformCount(); i++)
{
auto xform = embers[si].GetTotalXform(i);
auto prealignxform = m_EdgePrealign[si].GetTotalXform(i);
const auto xform = embers[si].GetTotalXform(i);
const auto prealignxform = m_EdgePrealign[si].GetTotalXform(i);
if (!xform->m_Motion.empty())
if (xform && prealignxform && !xform->m_Motion.empty())
prealignxform->ApplyMotion(*xform, blend);//Apply motion parameters to result.xform[i] using blend parameter.
}
}
@ -1024,7 +1022,7 @@ public:
//Rotate the aligned xforms.
if (rotations)
{
auto cwblend = cw ? blend : -blend;
const auto cwblend = cw ? blend : -blend;
m_EdgeSpun[0].RotateAffines(cwblend * (360 * rotations));
m_EdgeSpun[1].RotateAffines(cwblend * (360 * rotations));
}
@ -1050,8 +1048,8 @@ public:
/// <param name="cw">True to rotate clockwise, else rotate counter clockwise. Ignored if rotations is 0.</param>
void Spin(Ember<T>& parent, Ember<T>* templ, Ember<T>& result, size_t frame, T blend, bool cw)
{
auto cwblend = cw ? blend : -blend;
string temp = "rotate " + std::to_string(cwblend * 360.0);
const auto cwblend = cw ? blend : -blend;
const string temp = "rotate " + std::to_string(cwblend * 360.0);
//Spin the parent blend degrees.
Loop(parent, result, blend, cw);
@ -1068,6 +1066,8 @@ public:
result.m_Edits = m_EmberToXml.CreateNewEditdoc(&parent, nullptr, temp, m_Nick, m_Url, m_Id, m_Comment, m_SheepGen, m_SheepId);
//Subpixel jitter.
Offset(result, m_OffsetX, m_OffsetY);
//Need to set these to be equal so rendering works correctly for off center embers.
result.m_RotCenterY = result.m_CenterY;
//Make the name of the flame the time.
result.m_Name = std::to_string(result.m_Time);
}
@ -1088,8 +1088,8 @@ public:
/// <param name="cw">True to rotate clockwise, else rotate counter clockwise. Ignored if rotations is 0.</param>
void SpinInter(Ember<T>* parents, Ember<T>* templ, Ember<T>& result, size_t frame, bool seqFlag, T blend, size_t rotations, bool cw)
{
auto cwblend = cw ? blend : -blend;
string temp = "interpolate " + std::to_string(cwblend * 360.0);
const auto cwblend = cw ? blend : -blend;
const string temp = "interpolate " + std::to_string(cwblend * 360.0);
//Interpolate between spun parents.
Edge(parents, result, blend, rotations, cw, seqFlag);
@ -1106,6 +1106,8 @@ public:
result.m_Edits = m_EmberToXml.CreateNewEditdoc(&parents[0], &parents[1], temp, m_Nick, m_Url, m_Id, m_Comment, m_SheepGen, m_SheepId);
//Subpixel jitter.
Offset(result, m_OffsetX, m_OffsetY);
//Need to set these to be equal so rendering works correctly for off center embers.
result.m_RotCenterY = result.m_CenterY;
//Make the name of the flame the time.
result.m_Name = std::to_string(result.m_Time);
}
@ -1216,9 +1218,9 @@ public:
void RotateOldCenterBy(T& newCenterX, T& newCenterY, T oldCenterX, T oldCenterY, T by)
{
T r[2];
T th = by * 2 * T(M_PI) / 360;
T c = std::cos(th);
T s = -std::sin(th);
const T th = by * 2 * static_cast<T>(M_PI) / 360;
const T c = std::cos(th);
const T s = -std::sin(th);
newCenterX -= oldCenterX;
newCenterY -= oldCenterY;
r[0] = c * newCenterX - s * newCenterY;
@ -1258,11 +1260,11 @@ public:
//params.m_OneRowDiv2 = m_Renderer->CoordMap().OneRow() / 2;
size_t bv = m_Iterator->Iterate(ember, params, ctr, m_Samples.data(), m_Rand);//Use a special fuse of 20, all other calls to this will use 15, or 100.
if (bv / T(samples) > eps)
if (bv / static_cast<T>(samples) > eps)
eps = 3 * bv / T(samples);
if (eps > T(0.3))
eps = T(0.3);
if (eps > static_cast<T>(0.3))
eps = static_cast<T>(0.3);
lowTarget = static_cast<size_t>(samples * eps);
highTarget = samples - lowTarget;

View File

@ -51,7 +51,7 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
SpatialFilter(eSpatialFilterType filterType, T support, T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
SpatialFilter(eSpatialFilterType filterType, T support, T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
{
m_FilterType = filterType;
m_Support = support;
@ -115,9 +115,9 @@ public:
return;
}
T fw = T(2.0) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
T fw = static_cast<T>(2) * m_Support * m_Supersample * m_FilterRadius / m_PixelAspectRatio;
T adjust, ii, jj;
int fwidth = int(fw) + 1;
int fwidth = static_cast<int>(fw) + 1;
int i, j;
//Make sure the filter kernel has same parity as oversample.
@ -128,7 +128,7 @@ public:
if (fw > 0.0)
adjust = m_Support * fwidth / fw;
else
adjust = T(1.0);
adjust = static_cast<T>(1);
m_Filter.resize(fwidth * fwidth);
@ -138,8 +138,8 @@ public:
for (j = 0; j < fwidth; j++)
{
//Calculate the function inputs for the kernel function.
ii = ((T(2.0) * i + T(1.0)) / T(fwidth) - T(1.0)) * adjust;
jj = ((T(2.0) * j + T(1.0)) / T(fwidth) - T(1.0)) * adjust;
ii = ((static_cast<T>(2) * i + static_cast<T>(1)) / static_cast<T>(fwidth) - static_cast<T>(1)) * adjust;
jj = ((static_cast<T>(2) * j + static_cast<T>(1)) / static_cast<T>(fwidth) - static_cast<T>(1)) * adjust;
//Adjust for aspect ratio.
jj /= m_PixelAspectRatio;
m_Filter[i + j * fwidth] = Filter(ii) * Filter(jj);//Call virtual Filter(), implemented in specific derived filter classes.
@ -153,7 +153,7 @@ public:
break;
}
m_FilterRadius += T(0.01);//Values were too small.
m_FilterRadius += static_cast<T>(0.01);//Values were too small.
}
while (1);
}
@ -208,7 +208,7 @@ protected:
/// <returns>The calculated value</returns>
static T Sinc(T x)
{
x *= T(M_PI);
x *= static_cast<T>(M_PI);
if (x != 0)
return std::sin(x) / x;
@ -224,7 +224,7 @@ private:
bool Normalize()
{
size_t i;
T t = T(0.0);
T t = 0;
for (i = 0; i < m_Filter.size(); i++)
t += m_Filter[i];
@ -232,7 +232,7 @@ private:
if (t == 0.0 || std::isinf(t) || std::isnan(t) || !std::isnormal(t))
return false;
t = T(1.0 / t);
t = static_cast<T>(1 / t);
for (i = 0; i < m_Filter.size(); i++)
{
@ -268,8 +268,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
GaussianFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::GAUSSIAN_SPATIAL_FILTER, T(1.5), filterRadius, superSample, pixelAspectRatio) { }
GaussianFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::GAUSSIAN_SPATIAL_FILTER, static_cast<T>(1.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Gaussian filter to t parameter and return.
@ -278,7 +278,7 @@ public:
/// <returns>The filtered value</returns>
virtual T Filter(T t) const override
{
return T(std::exp(-2 * t * t) * std::sqrt(2 / M_PI));
return static_cast<T>(std::exp(-2 * t * t) * std::sqrt(2 / M_PI));
}
};
@ -296,8 +296,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
HermiteFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::HERMITE_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
HermiteFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::HERMITE_SPATIAL_FILTER, static_cast<T>(1), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Hermite filter to t parameter and return.
@ -311,7 +311,7 @@ public:
t = -t;
if (t < 1)
return T((2.0 * t - 3.0) * t * t + 1.0);
return static_cast<T>((2 * t - 3) * t * t + 1);
return 0;
}
@ -331,8 +331,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BoxFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::BOX_SPATIAL_FILTER, T(0.5), filterRadius, superSample, pixelAspectRatio) { }
BoxFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::BOX_SPATIAL_FILTER, static_cast<T>(0.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Box filter to t parameter and return.
@ -341,7 +341,7 @@ public:
/// <returns>The filtered value</returns>
virtual T Filter(T t) const override
{
if ((t > T(-0.5)) && (t <= T(0.5)))
if ((t > static_cast<T>(-0.5)) && (t <= static_cast<T>(0.5)))
return 1;
return 0;
@ -362,8 +362,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
TriangleFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::TRIANGLE_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
TriangleFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::TRIANGLE_SPATIAL_FILTER, static_cast<T>(1), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Triangle filter to t parameter and return.
@ -396,8 +396,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BellFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::BELL_SPATIAL_FILTER, T(1.5), filterRadius, superSample, pixelAspectRatio) { }
BellFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::BELL_SPATIAL_FILTER, static_cast<T>(1.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Bell filter to t parameter and return.
@ -410,13 +410,13 @@ public:
if (t < 0)
t = -t;
if (t < T(0.5))
return T(0.75 - (t * t));
if (t < static_cast<T>(0.5))
return static_cast<T>(0.75 - (t * t));
if (t < T(1.5))
if (t < static_cast<T>(1.5))
{
t = T(t - 1.5);
return T(0.5 * (t * t));
t = static_cast<T>(t - 1.5);
return static_cast<T>(0.5 * (t * t));
}
return 0;
@ -437,8 +437,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BsplineFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::BSPLINE_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
BsplineFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::BSPLINE_SPATIAL_FILTER, static_cast<T>(2), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply B Spline filter to t parameter and return.
@ -456,12 +456,12 @@ public:
if (t < 1)
{
tt = t * t;
return T((0.5 * tt * t) - tt + (2.0 / 3.0));
return static_cast<T>((0.5 * tt * t) - tt + (2.0 / 3.0));
}
else if (t < 2)
{
t = 2 - t;
return T((1.0 / 6.0) * (t * t * t));
return static_cast<T>((1.0 / 6.0) * (t * t * t));
}
return 0;
@ -482,8 +482,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
Lanczos3Filter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::LANCZOS3_SPATIAL_FILTER, T(3.0), filterRadius, superSample, pixelAspectRatio) { }
Lanczos3Filter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::LANCZOS3_SPATIAL_FILTER, static_cast<T>(3), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Lanczos 3 filter to t parameter and return.
@ -516,8 +516,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
Lanczos2Filter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::LANCZOS2_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
Lanczos2Filter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::LANCZOS2_SPATIAL_FILTER, static_cast<T>(2), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Lanczos 2 filter to t parameter and return.
@ -550,8 +550,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
MitchellFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::MITCHELL_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
MitchellFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::MITCHELL_SPATIAL_FILTER, static_cast<T>(2), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Mitchell filter to t parameter and return.
@ -561,25 +561,25 @@ public:
virtual T Filter(T t) const override
{
T tt = t * t;
const T b = T(1.0 / 3.0);
const T c = T(1.0 / 3.0);
const T b = static_cast<T>(1.0 / 3.0);
const T c = static_cast<T>(1.0 / 3.0);
if (t < 0)
t = -t;
if (t < 1)
{
t = T(((12.0 - 9.0 * b - 6.0 * c) * (t * tt))
+ ((-18.0 + 12.0 * b + 6.0 * c) * tt)
+ (6.0 - 2 * b));
t = static_cast<T>(((12.0 - 9.0 * b - 6.0 * c) * (t * tt))
+ ((-18.0 + 12.0 * b + 6.0 * c) * tt)
+ (6.0 - 2 * b));
return t / 6;
}
else if (t < 2)
{
t = T(((-1.0 * b - 6.0 * c) * (t * tt))
+ ((6.0 * b + 30.0 * c) * tt)
+ ((-12.0 * b - 48.0 * c) * t)
+ (8.0 * b + 24 * c));
t = static_cast<T>(((-1.0 * b - 6.0 * c) * (t * tt))
+ ((6.0 * b + 30.0 * c) * tt)
+ ((-12.0 * b - 48.0 * c) * t)
+ (8.0 * b + 24 * c));
return t / 6;
}
@ -601,8 +601,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
BlackmanFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::BLACKMAN_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
BlackmanFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::BLACKMAN_SPATIAL_FILTER, static_cast<T>(1), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Blackman filter to t parameter and return.
@ -611,7 +611,7 @@ public:
/// <returns>The filtered value</returns>
virtual T Filter(T t) const override
{
return T(0.42 + 0.5 * std::cos(M_PI * t) + 0.08 * std::cos(2 * M_PI * t));
return static_cast<T>(0.42 + 0.5 * std::cos(M_PI * t) + 0.08 * std::cos(2 * M_PI * t));
}
};
@ -629,8 +629,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
CatromFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::CATROM_SPATIAL_FILTER, T(2.0), filterRadius, superSample, pixelAspectRatio) { }
CatromFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::CATROM_SPATIAL_FILTER, static_cast<T>(2), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Catmull-Rom filter to t parameter and return.
@ -643,16 +643,16 @@ public:
return 0;
if (t < -1)
return T(0.5 * (4 + t * (8 + t * (5 + t))));
return static_cast<T>(0.5 * (4 + t * (8 + t * (5 + t))));
if (t < 0)
return T(0.5 * (2 + t * t * (-5 - 3 * t)));
return static_cast<T>(0.5 * (2 + t * t * (-5 - 3 * t)));
if (t < 1)
return T(0.5 * (2 + t * t * (-5 + 3 * t)));
return static_cast<T>(0.5 * (2 + t * t * (-5 + 3 * t)));
if (t < 2)
return T(0.5 * (4 + t * (-8 + t * (5 - t))));
return static_cast<T>(0.5 * (4 + t * (-8 + t * (5 - t))));
return 0;
}
@ -672,8 +672,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
HammingFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::HAMMING_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
HammingFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::HAMMING_SPATIAL_FILTER, static_cast<T>(1), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Hamming filter to t parameter and return.
@ -682,7 +682,7 @@ public:
/// <returns>The filtered value</returns>
virtual T Filter(T t) const override
{
return T(0.54 + 0.46 * std::cos(M_PI * t));
return static_cast<T>(0.54 + 0.46 * std::cos(M_PI * t));
}
};
@ -700,8 +700,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
HanningFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::HANNING_SPATIAL_FILTER, T(1.0), filterRadius, superSample, pixelAspectRatio) { }
HanningFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::HANNING_SPATIAL_FILTER, static_cast<T>(1), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Hanning filter to t parameter and return.
@ -710,7 +710,7 @@ public:
/// <returns>The filtered value</returns>
virtual T Filter(T t) const override
{
return T(0.5 + 0.5 * std::cos(M_PI * t));
return static_cast<T>(0.5 + 0.5 * std::cos(M_PI * t));
}
};
@ -728,8 +728,8 @@ public:
/// <param name="filterRadius">The filter radius</param>
/// <param name="superSample">The supersample of the ember being rendered</param>
/// <param name="pixelAspectRatio">The pixel aspect ratio being used to render. Default: 1.</param>
QuadraticFilter(T filterRadius, size_t superSample, T pixelAspectRatio = T(1.0))
: SpatialFilter<T>(eSpatialFilterType::QUADRATIC_SPATIAL_FILTER, T(1.5), filterRadius, superSample, pixelAspectRatio) { }
QuadraticFilter(T filterRadius, size_t superSample, T pixelAspectRatio = static_cast<T>(1))
: SpatialFilter<T>(eSpatialFilterType::QUADRATIC_SPATIAL_FILTER, static_cast<T>(1.5), filterRadius, superSample, pixelAspectRatio) { }
/// <summary>
/// Apply Quadratic filter to t parameter and return.
@ -742,13 +742,13 @@ public:
return 0.0;
if (t < -0.5)
return T(0.5 * (t + 1.5) * (t + 1.5));
return static_cast<T>(0.5 * (t + 1.5) * (t + 1.5));
if (t < 0.5)
return T(0.75 - (t * t));
return static_cast<T>(0.75 - (t * t));
if (t < 1.5)
return T(0.5 * (t - 1.5) * (t - 1.5));
return static_cast<T>(0.5 * (t - 1.5) * (t - 1.5));
return 0;
}

View File

@ -115,11 +115,11 @@ T Spline<T>::Interpolate(T newX)
while (j < n && newX > vals[j + 1].x)
j++;
auto xmxj = newX - vals[j].x;
auto output = a[j] * (xmxj * xmxj * xmxj) +
b[j] * (xmxj * xmxj) +
c[j] * xmxj +
d[j];
const auto xmxj = newX - vals[j].x;
const auto output = a[j] * (xmxj * xmxj * xmxj) +
b[j] * (xmxj * xmxj) +
c[j] * xmxj +
d[j];
return output;
}

View File

@ -46,7 +46,8 @@ public:
/// <param name="filterType">Type of the filter.</param>
/// <param name="temporalSamples">The number of temporal samples in the ember being rendered</param>
/// <param name="filterWidth">The width of the filter.</param>
TemporalFilter(eTemporalFilterType filterType, size_t temporalSamples, T filterWidth)
/// <param name="filterExp">The filter exponent. Unused except with ExpTemporalFilter, but needed to prevent equality tests from failing.</param>
TemporalFilter(eTemporalFilterType filterType, size_t temporalSamples, T filterWidth, T filterExp)
{
size_t i, steps = temporalSamples;
m_TemporalSamples = temporalSamples;
@ -54,7 +55,7 @@ public:
m_Deltas.resize(steps);
m_Filter.resize(steps);
m_FilterType = filterType;
m_FilterExp = 1;
m_FilterExp = filterExp;//Always assign this to prevent excessive recreates in Renderer::CreateTemporalFilter().
if (steps == 1)
{
@ -66,7 +67,7 @@ public:
{
//Define the temporal deltas.
for (i = 0; i < steps; i++)
m_Deltas[i] = (T(i) / T(steps - 1) - T(0.5)) * filterWidth;
m_Deltas[i] = (static_cast<T>(i) / static_cast<T>(steps - 1) - static_cast<T>(0.5)) * filterWidth;
}
}
@ -131,6 +132,7 @@ public:
for (i = 0; i < m_Filter.size(); i++)
{
ss << "Filter[" << i << "]: " << m_Filter[i] << "\n";
//ss << m_Filter[i] << "\n";
}
return ss.str();
@ -166,7 +168,7 @@ protected:
m_SumFilt /= Size();
}
T m_SumFilt;//The sum of all filter values.
T m_SumFilt = 1;//The sum of all filter values.
T m_FilterWidth;
T m_FilterExp;
size_t m_TemporalSamples;
@ -188,9 +190,9 @@ public:
/// </summary>
/// <param name="temporalSamples">The number of temporal samples in the ember being rendered</param>
/// <param name="filterWidth">The width of the filter.</param>
/// <param name="filterExp">The filter exp.</param>
ExpTemporalFilter(size_t temporalSamples, T filterWidth, T filterExp)
: TemporalFilter<T>(eTemporalFilterType::BOX_TEMPORAL_FILTER, temporalSamples, filterWidth)
/// <param name="filterExp">The filter exponent.</param>
ExpTemporalFilter(size_t temporalSamples, T filterWidth, T filterExp = 1)
: TemporalFilter<T>(eTemporalFilterType::EXP_TEMPORAL_FILTER, temporalSamples, filterWidth, filterExp)
{
if (Size() > 1)
{
@ -199,9 +201,9 @@ public:
for (size_t i = 0; i < Size(); i++)
{
if (filterExp >= 0)
slpx = (T(i) + 1) / Size();
slpx = (static_cast<T>(i) + 1) / Size();
else
slpx = T(Size() - i) / Size();
slpx = static_cast<T>(Size() - i) / Size();
//Scale the color based on these values.
m_Filter[i] = std::pow(slpx, fabs(filterExp));
@ -211,7 +213,6 @@ public:
maxFilt = m_Filter[i];
}
m_FilterExp = filterExp;
FinishFilter(maxFilt);
}
}
@ -230,12 +231,13 @@ public:
/// </summary>
/// <param name="temporalSamples">The number of temporal samples in the ember being rendered</param>
/// <param name="filterWidth">The width of the filter.</param>
GaussianTemporalFilter(size_t temporalSamples, T filterWidth)
: TemporalFilter<T>(eTemporalFilterType::GAUSSIAN_TEMPORAL_FILTER, temporalSamples, filterWidth)
/// <param name="filterExp">Unused, but needed to prevent equality tests from failing.</param>
GaussianTemporalFilter(size_t temporalSamples, T filterWidth, T filterExp)
: TemporalFilter<T>(eTemporalFilterType::GAUSSIAN_TEMPORAL_FILTER, temporalSamples, filterWidth, filterExp)
{
if (Size() > 1)
{
T maxFilt = 0, halfSteps = T(Size()) / T(2);
T maxFilt = 0, halfSteps = static_cast<T>(Size()) / static_cast<T>(2);
GaussianFilter<T> gaussian(1, 1);//Just pass dummy values, they are unused in this case.
for (size_t i = 0; i < Size(); i++)
@ -265,8 +267,9 @@ public:
/// </summary>
/// <param name="temporalSamples">The number of temporal samples in the ember being rendered</param>
/// <param name="filterWidth">The width of the filter.</param>
BoxTemporalFilter(size_t temporalSamples, T filterWidth)
: TemporalFilter<T>(eTemporalFilterType::BOX_TEMPORAL_FILTER, temporalSamples, filterWidth)
/// <param name="filterExp">Unused, but needed to prevent equality tests from failing.</param>
BoxTemporalFilter(size_t temporalSamples, T filterWidth, T filterExp)
: TemporalFilter<T>(eTemporalFilterType::BOX_TEMPORAL_FILTER, temporalSamples, filterWidth, filterExp)
{
if (Size() > 1)
{
@ -291,20 +294,20 @@ public:
/// <param name="filterType">Type of the filter</param>
/// <param name="temporalSamples">The number of temporal samples in the ember being rendered</param>
/// <param name="filterWidth">The width of the filter</param>
/// <param name="filterExp">The filter exp, only used with Exp filter, otherwise ignored.</param>
/// <param name="filterExp">The filter exp, only used with Exp filter, otherwise unused but needed to prevent equality tests from failing.</param>
/// <returns>A pointer to the newly created filter object</returns>
static TemporalFilter<T>* Create(eTemporalFilterType filterType, size_t temporalSamples, T filterWidth, T filterExp = 1)
static TemporalFilter<T>* Create(eTemporalFilterType filterType, size_t temporalSamples, T filterWidth, T filterExp)
{
TemporalFilter<T>* filter = nullptr;
switch (filterType)
{
case EmberNs::eTemporalFilterType::BOX_TEMPORAL_FILTER:
filter = new BoxTemporalFilter<T>(temporalSamples, filterWidth);
filter = new BoxTemporalFilter<T>(temporalSamples, filterWidth, filterExp);
break;
case EmberNs::eTemporalFilterType::GAUSSIAN_TEMPORAL_FILTER:
filter = new GaussianTemporalFilter<T>(temporalSamples, filterWidth);
filter = new GaussianTemporalFilter<T>(temporalSamples, filterWidth, filterExp);
break;
case EmberNs::eTemporalFilterType::EXP_TEMPORAL_FILTER:
@ -312,7 +315,7 @@ public:
break;
default:
filter = new BoxTemporalFilter<T>(temporalSamples, filterWidth);//Default to box if bad enum passed in.
filter = new BoxTemporalFilter<T>(temporalSamples, filterWidth, filterExp);//Default to box if bad enum passed in.
break;
}

View File

@ -48,7 +48,7 @@ public:
double Toc(const char* str = nullptr, bool fullString = false)
{
m_EndTime = NowMsD();
double ms = ElapsedTime();
const auto ms = ElapsedTime();
if (str)
{
@ -91,13 +91,13 @@ public:
{
stringstream ss;
double x = ms / 1000;
double secs = fmod(x, 60);
const auto secs = fmod(x, 60);
x /= 60;
double mins = fmod(x, 60);
const auto mins = fmod(x, 60);
x /= 60;
double hours = fmod(x, 24);
const auto hours = fmod(x, 24);
x /= 24;
double days = x;
const auto days = x;
if (days >= 1)
ss << static_cast<int>(days) << "d ";

View File

@ -954,20 +954,20 @@ static string Trim(const string& str, char ch = ' ')
/// <returns>The vector containing the split tokens</returns>
static vector<std::string> Split(const string& str, const string& del, bool removeEmpty = false)
{
int current = 0;
int next = -1;
size_t current = 0;
size_t next = std::numeric_limits<size_t>::max();
vector<string> vec;
do
{
current = next + 1;
next = int(str.find_first_of(del, current));
next = str.find_first_of(del, current);
string ent(Trim(str.substr(current, next - current)));
if (!removeEmpty || ent.length() > 0)
vec.push_back(ent);
}
while (next != int(string::npos));
while (next != string::npos);
return vec;
}

View File

@ -2283,10 +2283,8 @@ public:
vec.reserve(m_Params.size());
for (auto& param : m_Params)
{
if ((includePrecalcs && param.IsPrecalc()) || !param.IsPrecalc())
vec.push_back(param.Name());
}
return vec;
}
@ -2305,12 +2303,8 @@ public:
string index = os2.str();
for (auto& param : m_Params)
{
if (param.IsState())
{
os << "\n\treal_t " << param.Name() << index;
}
}
return os.str();
}
@ -2324,12 +2318,8 @@ public:
size_t count = 0;
for (auto& param : m_Params)
{
if (param.IsState())
{
count++;
}
}
return count;
}
@ -2344,12 +2334,8 @@ public:
virtual void InitStateVars(T* t, size_t& index) override
{
for (auto& param : m_Params)
{
if (param.IsState())
{
t[index++] = param.ParamVal();
}
}
}
/// <summary>

View File

@ -661,7 +661,7 @@ int VariationList<T>::GetVariationIndex(const string& name) const
{
for (size_t i = 0; i < m_Variations.size() && m_Variations[i]; i++)
if (!_stricmp(name.c_str(), m_Variations[i]->Name().c_str()))
return int(i);
return static_cast<int>(i);
return -1;
}

View File

@ -487,7 +487,7 @@ bool XmlToEmber<T>::Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& e
xmlFreeDoc(doc);
emberSize = embers.size();
auto first = embers.begin();
const auto first = embers.begin();
//t.Toc("ScanForEmberNodes");
@ -519,7 +519,7 @@ bool XmlToEmber<T>::Parse(byte* buf, const char* filename, C<Ember<T>, Alloc>& e
if (emberSize > 1)
{
auto prev = embers.begin();
auto second = Advance(embers.begin(), 1);
const auto second = Advance(embers.begin(), 1);
for (auto it = second; it != embers.end(); ++it)
{
@ -633,7 +633,7 @@ void XmlToEmber<T>::ScanForEmberNodes(xmlNode* curNode, const char* parentFile,
if (currentEmber.PaletteIndex() != -1)
{
if (auto pal = m_PaletteList->GetPaletteByFilename(m_PaletteList->m_DefaultFilename, currentEmber.PaletteIndex()))
if (const auto pal = m_PaletteList->GetPaletteByFilename(m_PaletteList->m_DefaultFilename, currentEmber.PaletteIndex()))
currentEmber.m_Palette = *pal;
else
AddToReport(string(loc) + " : Error assigning palette with index " + std::to_string(currentEmber.PaletteIndex()));
@ -667,11 +667,11 @@ void XmlToEmber<T>::ScanForEmberNodes(xmlNode* curNode, const char* parentFile,
/// <returns>The name value if they matched, else nullptr.</returns>
static const char* CheckNameVal(xmlNode* node, const char* name)
{
if (auto att = node->properties)
if (const auto att = node->properties)
{
if (!Compare(att->name, "name"))
{
if (auto attStr = XC(xmlGetProp(node, att->name)))
if (const auto attStr = XC(xmlGetProp(node, att->name)))
{
if (!Compare(attStr, name))
{
@ -707,16 +707,10 @@ static xmlNode* CheckNodeName(xmlNode* node, const char* name)
/// <returns>The value of the name field if found, else nullptr.</returns>
static const char* GetNameVal(xmlNode* node, const char* name = "name")
{
if (auto att = node->properties)
{
if (const auto att = node->properties)
if (!Compare(att->name, name ? name : "name"))
{
if (auto attStr = XC(xmlGetProp(node, att->name)))
{
if (const auto attStr = XC(xmlGetProp(node, att->name)))
return CCX(attStr);
}
}
}
return nullptr;
};
@ -730,15 +724,9 @@ static const char* GetNameVal(xmlNode* node, const char* name = "name")
static xmlNode* GetChildNode(xmlNode* node, const char* name)
{
for (auto childNode = node->children; childNode; childNode = childNode->next)
{
if (childNode->type == XML_ELEMENT_NODE)
{
if (CheckNameVal(childNode, name))
{
return childNode;
}
}
}
return nullptr;
};
@ -752,15 +740,9 @@ static xmlNode* GetChildNode(xmlNode* node, const char* name)
static xmlNode* GetChildNodeByNodeName(xmlNode* node, const char* name)
{
for (auto childNode = node->children; childNode; childNode = childNode->next)
{
if (childNode->type == XML_ELEMENT_NODE)
{
if (auto node = CheckNodeName(childNode, name))
{
if (const auto node = CheckNodeName(childNode, name))
return node;
}
}
}
return nullptr;
};
@ -779,15 +761,15 @@ bool XmlToEmber<T>::ParseAndAssignContent(xmlNode* node, const char* fieldname,
{
bool ret = false;
if (auto att = node->properties)
if (const auto att = node->properties)
{
if (!Compare(att->name, fieldname))
{
if (auto attStr = XC(xmlGetProp(node, att->name)))
if (const auto attStr = XC(xmlGetProp(node, att->name)))
{
if (!fieldnameval || !Compare(attStr, fieldnameval))
{
if (auto cont = xmlNodeGetContent(node))
if (const auto cont = xmlNodeGetContent(node))
{
istringstream istr(CCX(cont));
istr >> val;
@ -814,15 +796,15 @@ bool XmlToEmber<T>::ParseAndAssignContent(xmlNode* node, const char* fieldname,
{
bool ret = false;
if (auto att = node->properties)
if (const auto att = node->properties)
{
if (!Compare(att->name, fieldname))
{
if (auto attStr = XC(xmlGetProp(node, att->name)))
if (const auto attStr = XC(xmlGetProp(node, att->name)))
{
if (!fieldnameval || !Compare(attStr, fieldnameval))
{
if (auto cont = xmlNodeGetContent(node))
if (const auto cont = xmlNodeGetContent(node))
{
val = CX(cont);
return true;
@ -863,10 +845,10 @@ void XmlToEmber<T>::ScanForChaosNodes(xmlNode* curNode, const char* parentFile,
if (!useDefaults)
currentEmber.Clear(false);
if (auto embername = GetNameVal(thisNode, "name"))
if (const auto embername = GetNameVal(thisNode, "name"))
currentEmber.m_Name = embername;
auto childNode = thisNode;
const auto childNode = thisNode;
bool ret = true;
parseEmberSuccess = ParseEmberElementFromChaos(childNode, currentEmber);
@ -916,7 +898,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
att = emberNode->properties;//The top level element is a ember element, read the attributes of it and store them.
auto variationsfunc = [&](const string & prefix, const char* nodename, xmlNode * node, Xform<T>& xf, std::vector<std::string>& alliterweights)
{
if (auto transformsChildNode = GetChildNode(node, nodename))
if (const auto transformsChildNode = GetChildNode(node, nodename))
{
for (auto variationNode = transformsChildNode->children; variationNode; variationNode = variationNode->next)
{
@ -936,9 +918,9 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (!varname.empty())
{
T weight = 1;
string corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname);
auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname;
const T weight = 1;
const auto corrvarname = GetCorrectedVariationName(m_BadVariationNames, varname);
const auto corrwprefix = !StartsWith(corrvarname, prefix) ? prefix + corrvarname : corrvarname;
if (auto var = m_VariationList->GetVariation(corrwprefix))
{
@ -952,21 +934,21 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (auto paramsNode = GetChildNodeByNodeName(variationNode, "params"))
{
auto parvar = dynamic_cast<ParametricVariation<T>*>(varCopy);
const auto parvar = dynamic_cast<ParametricVariation<T>*>(varCopy);
for (auto paramsChildNode = paramsNode->children; paramsChildNode; paramsChildNode = paramsChildNode->next)
{
if (paramsChildNode->type == XML_ELEMENT_NODE)
{
if (auto paramname = GetNameVal(paramsChildNode))
if (const auto paramname = GetNameVal(paramsChildNode))
{
T val = 1;
if (auto paramCurveChildNode = GetChildNodeByNodeName(paramsChildNode, "curve"))
if (const auto paramCurveChildNode = GetChildNodeByNodeName(paramsChildNode, "curve"))
{
if (auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
if (const auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
{
if (auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
if (const auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
{
if (paramCurveValuesContentChildNode->children)
{
@ -1031,20 +1013,20 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (auto transformChildNode = GetChildNodeByNodeName(node, "flam3_transform"))
{
found = true;
auto itername = GetNameVal(node, "name");
const auto itername = GetNameVal(node, "name");
xf.m_Name = itername;
if (auto affineChildNode = GetChildNode(transformChildNode, "Pre affine"))
if (const auto affineChildNode = GetChildNode(transformChildNode, "Pre affine"))
{
std::string offsetstr;
double xangle = 0, xlength = 1, yangle = 90, ylength = 1, xoffset = 0, yoffset = 0;
if (auto xangleChildNode = GetChildNode(affineChildNode, "x_axis_angle"))
if (auto paramCurveChildNode = GetChildNodeByNodeName(xangleChildNode, "curve"))
if (const auto xangleChildNode = GetChildNode(affineChildNode, "x_axis_angle"))
if (const auto paramCurveChildNode = GetChildNodeByNodeName(xangleChildNode, "curve"))
{
if (auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
if (const auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
{
if (auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
if (const auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
{
if (paramCurveValuesContentChildNode->children)
{
@ -1058,15 +1040,15 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
else
ParseAndAssignContent(xangleChildNode, "name", "x_axis_angle", xangle);
if (auto xlengthChildNode = GetChildNode(affineChildNode, "x_axis_length"))
if (const auto xlengthChildNode = GetChildNode(affineChildNode, "x_axis_length"))
if (ParseAndAssignContent(xlengthChildNode, "name", "x_axis_length", xlength)) {}
if (auto yangleChildNode = GetChildNode(affineChildNode, "y_axis_angle"))
if (auto paramCurveChildNode = GetChildNodeByNodeName(yangleChildNode, "curve"))
if (const auto yangleChildNode = GetChildNode(affineChildNode, "y_axis_angle"))
if (const auto paramCurveChildNode = GetChildNodeByNodeName(yangleChildNode, "curve"))
{
if (auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
if (const auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
{
if (auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
if (const auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
{
if (paramCurveValuesContentChildNode->children)
{
@ -1080,10 +1062,10 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
else
ParseAndAssignContent(yangleChildNode, "name", "y_axis_angle", yangle);
if (auto ylengthChildNode = GetChildNode(affineChildNode, "y_axis_length"))
if (const auto ylengthChildNode = GetChildNode(affineChildNode, "y_axis_length"))
if (ParseAndAssignContent(ylengthChildNode, "name", "y_axis_length", ylength)) {}
if (auto offsetChildNode = GetChildNode(affineChildNode, "offset"))
if (const auto offsetChildNode = GetChildNode(affineChildNode, "offset"))
if (ParseAndAssignContent(offsetChildNode, "name", "offset", offsetstr))
{
istringstream istr(offsetstr);
@ -1104,18 +1086,18 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
xf.m_Affine.F(o2);
}
if (auto affineChildNode = GetChildNode(transformChildNode, "Post affine"))
if (const auto affineChildNode = GetChildNode(transformChildNode, "Post affine"))
{
std::string offsetstr;
double xangle = 0, xlength = 1, yangle = 90, ylength = 1, xoffset = 0, yoffset = 0;
if (auto xangleChildNode = GetChildNode(affineChildNode, "x_axis_angle"))
if (const auto xangleChildNode = GetChildNode(affineChildNode, "x_axis_angle"))
if (!ParseAndAssignContent(xangleChildNode, "name", "x_axis_angle", xangle))
if (auto paramCurveChildNode = GetChildNodeByNodeName(affineChildNode, "curve"))
if (const auto paramCurveChildNode = GetChildNodeByNodeName(affineChildNode, "curve"))
{
if (auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
if (const auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
{
if (auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
if (const auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
{
if (paramCurveValuesContentChildNode->children)
{
@ -1127,15 +1109,15 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
}
}
if (auto xlengthChildNode = GetChildNode(affineChildNode, "x_axis_length"))
if (const auto xlengthChildNode = GetChildNode(affineChildNode, "x_axis_length"))
if (ParseAndAssignContent(xlengthChildNode, "name", "x_axis_length", xlength)) {}
if (auto yangleChildNode = GetChildNode(affineChildNode, "y_axis_angle"))
if (auto paramCurveChildNode = GetChildNodeByNodeName(yangleChildNode, "curve"))
if (const auto yangleChildNode = GetChildNode(affineChildNode, "y_axis_angle"))
if (const auto paramCurveChildNode = GetChildNodeByNodeName(yangleChildNode, "curve"))
{
if (auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
if (const auto paramCurveValuesChildNode = GetChildNode(paramCurveChildNode, "values"))
{
if (auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
if (const auto paramCurveValuesContentChildNode = GetChildNodeByNodeName(paramCurveValuesChildNode, "values"))
{
if (paramCurveValuesContentChildNode->children)
{
@ -1149,22 +1131,22 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
else
ParseAndAssignContent(yangleChildNode, "name", "y_axis_angle", yangle);
if (auto ylengthChildNode = GetChildNode(affineChildNode, "y_axis_length"))
if (const auto ylengthChildNode = GetChildNode(affineChildNode, "y_axis_length"))
if (ParseAndAssignContent(ylengthChildNode, "name", "y_axis_length", ylength)) {}
if (auto offsetChildNode = GetChildNode(affineChildNode, "offset"))
if (const auto offsetChildNode = GetChildNode(affineChildNode, "offset"))
if (ParseAndAssignContent(offsetChildNode, "name", "offset", offsetstr))
{
istringstream istr(offsetstr);
istr >> xoffset >> yoffset;
}
T x1 = T(xlength * std::cos(xangle * DEG_2_RAD));
T y1 = T(xlength * std::sin(xangle * DEG_2_RAD));
T x2 = T(ylength * std::cos(yangle * DEG_2_RAD));
T y2 = T(ylength * std::sin(yangle * DEG_2_RAD));
T o1 = T(xoffset);
T o2 = T(yoffset);
T x1 = static_cast<T>(xlength * std::cos(xangle * DEG_2_RAD));
T y1 = static_cast<T>(xlength * std::sin(xangle * DEG_2_RAD));
T x2 = static_cast<T>(ylength * std::cos(yangle * DEG_2_RAD));
T y2 = static_cast<T>(ylength * std::sin(yangle * DEG_2_RAD));
T o1 = static_cast<T>(xoffset);
T o2 = static_cast<T>(yoffset);
xf.m_Post.A(x1);
xf.m_Post.B(x2);
xf.m_Post.C(o1);
@ -1181,38 +1163,38 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
variationsfunc(prefix, "post_transforms", transformChildNode, xf, alliterweights);
}
if (auto shaderChildNode = GetChildNodeByNodeName(node, "flam3_shader"))
if (const auto shaderChildNode = GetChildNodeByNodeName(node, "flam3_shader"))
{
T paletteIndex = 0, colorSpeed = 0.5, opacity = 1;
if (auto paletteIndexChildNode = GetChildNode(shaderChildNode, "palette_index"))
if (const auto paletteIndexChildNode = GetChildNode(shaderChildNode, "palette_index"))
if (ParseAndAssignContent(paletteIndexChildNode, "name", "palette_index", paletteIndex)) { xf.m_ColorX = xf.m_ColorY = paletteIndex; }
if (auto colrSpeedChildNode = GetChildNode(shaderChildNode, "blend_speed"))
if (const auto colrSpeedChildNode = GetChildNode(shaderChildNode, "blend_speed"))
if (ParseAndAssignContent(colrSpeedChildNode, "name", "blend_speed", colorSpeed)) { xf.m_ColorSpeed = colorSpeed; }
if (auto opacityChildNode = GetChildNode(shaderChildNode, "opacity"))
if (const auto opacityChildNode = GetChildNode(shaderChildNode, "opacity"))
if (ParseAndAssignContent(opacityChildNode, "name", "opacity", opacity)) { xf.m_Opacity = opacity; }
}
if (auto weightsChildNode = GetChildNodeByNodeName(node, "weights_selector"))
if (const auto weightsChildNode = GetChildNodeByNodeName(node, "weights_selector"))
{
T weight = 0;
std::string periterweights;
if (auto baseWeightChildNode = GetChildNode(weightsChildNode, "base_weight"))
if (const auto baseWeightChildNode = GetChildNode(weightsChildNode, "base_weight"))
{
if (ParseAndAssignContent(baseWeightChildNode, "name", "base_weight", weight))
xf.m_Weight = weight;
}
else if (auto baseWeightChildNode = GetChildNode(weightsChildNode, "Base weight"))
else if (const auto baseWeightChildNode = GetChildNode(weightsChildNode, "Base weight"))
{
if (ParseAndAssignContent(baseWeightChildNode, "name", "Base weight", weight))
xf.m_Weight = weight;
}
if (auto periterweightsChildNode = GetChildNode(weightsChildNode, "per_iterator_weights"))
if (const auto periterweightsChildNode = GetChildNode(weightsChildNode, "per_iterator_weights"))
{
for (auto iterweightChildNode = periterweightsChildNode->children; iterweightChildNode; iterweightChildNode = iterweightChildNode->next)
{
@ -1280,7 +1262,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
if (!bVal && !istr.bad() && !istr.fail())
currentEmber.m_HighlightPower = T(-1);
if (auto curvesnode = GetChildNodeByNodeName(childNode, "curves"))
if (const auto curvesnode = GetChildNodeByNodeName(childNode, "curves"))
{
T val = 0;
auto curvenodesfunc = [&](xmlNode * node, int index)
@ -1289,16 +1271,16 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
string knots, values;
vector<v2F> vals;
if (auto knotsnode = GetChildNode(node, "knots"))
if (const auto knotsnode = GetChildNode(node, "knots"))
{
if (auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (const auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (knotvalsnode->children)
knots = CCX(knotvalsnode->children->content);
}
if (auto valuesnode = GetChildNode(node, "values"))
if (const auto valuesnode = GetChildNode(node, "values"))
{
if (auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (const auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (valvalsnode->children)
values = CCX(valvalsnode->children->content);
}
@ -1311,11 +1293,11 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
{
if (childNode->type == XML_ELEMENT_NODE)
{
if (auto node = CheckNodeName(childNode, "table"))
if (const auto node = CheckNodeName(childNode, "table"))
{
if (!haveknots)
{
if (auto knotvalsnode = GetChildNodeByNodeName(node, "values"))
if (const auto knotvalsnode = GetChildNodeByNodeName(node, "values"))
{
if (knotvalsnode->children)
{
@ -1328,7 +1310,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
}
else if (!havevals)
{
if (auto valvalsnode = GetChildNodeByNodeName(node, "values"))
if (const auto valvalsnode = GetChildNodeByNodeName(node, "values"))
{
if (valvalsnode->children)
{
@ -1363,16 +1345,16 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
}
};
if (auto overallnode = GetChildNode(curvesnode, "overall"))
if (const auto overallnode = GetChildNode(curvesnode, "overall"))
curvenodesfunc(overallnode, 0);
if (auto rednode = GetChildNode(curvesnode, "0"))
if (const auto rednode = GetChildNode(curvesnode, "0"))
curvenodesfunc(rednode, 1);
if (auto greennode = GetChildNode(curvesnode, "5"))
if (const auto greennode = GetChildNode(curvesnode, "5"))
curvenodesfunc(greennode, 2);
if (auto bluenode = GetChildNode(curvesnode, "10"))
if (const auto bluenode = GetChildNode(curvesnode, "10"))
curvenodesfunc(bluenode, 3);
}
}
@ -1412,9 +1394,9 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
}
else if (!Compare(childNode->name, "colouring"))
{
if (auto palettenode = GetChildNode(childNode, "flam3_palette"))
if (const auto palettenode = GetChildNode(childNode, "flam3_palette"))
{
if (auto palettevalsnode = GetChildNodeByNodeName(palettenode, "values"))
if (const auto palettevalsnode = GetChildNodeByNodeName(palettenode, "values"))
{
float r = 0, g = 0, b = 0;
auto colors = CCX(palettevalsnode->children->content);
@ -1434,41 +1416,41 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
{
std::string huek, huev, satk, satv, valk, valv;
if (auto huenode = GetChildNode(childNode, "hue"))
if (const auto huenode = GetChildNode(childNode, "hue"))
{
if (auto knotsnode = GetChildNode(huenode, "knots"))
if (auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (const auto knotsnode = GetChildNode(huenode, "knots"))
if (const auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (knotvalsnode->children)
huek = CCX(knotvalsnode->children->content);
if (auto valuesnode = GetChildNode(huenode, "values"))
if (auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (const auto valuesnode = GetChildNode(huenode, "values"))
if (const auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (valvalsnode->children)
huev = CCX(valvalsnode->children->content);
}
if (auto satnode = GetChildNode(childNode, "saturation"))
if (const auto satnode = GetChildNode(childNode, "saturation"))
{
if (auto knotsnode = GetChildNode(satnode, "knots"))
if (auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (const auto knotsnode = GetChildNode(satnode, "knots"))
if (const auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (knotvalsnode->children)
satk = CCX(knotvalsnode->children->content);
if (auto valuesnode = GetChildNode(satnode, "values"))
if (auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (const auto valuesnode = GetChildNode(satnode, "values"))
if (const auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (valvalsnode->children)
satv = CCX(valvalsnode->children->content);
}
if (auto valnode = GetChildNode(childNode, "value"))
if (const auto valnode = GetChildNode(childNode, "value"))
{
if (auto knotsnode = GetChildNode(valnode, "knots"))
if (auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (const auto knotsnode = GetChildNode(valnode, "knots"))
if (const auto knotvalsnode = GetChildNodeByNodeName(knotsnode, "values"))
if (knotvalsnode->children)
valk = CCX(knotvalsnode->children->content);
if (auto valuesnode = GetChildNode(valnode, "values"))
if (auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (const auto valuesnode = GetChildNode(valnode, "values"))
if (const auto valvalsnode = GetChildNodeByNodeName(valuesnode, "values"))
if (valvalsnode->children)
valv = CCX(valvalsnode->children->content);
}
@ -1499,16 +1481,16 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
Spline<float> sspline(svec);
Spline<float> vspline(vvec);
currentEmber.m_Palette.m_Entries.resize(COLORMAP_LENGTH);
auto stepsize = (1.0f / (currentEmber.m_Palette.Size() - 1));
const auto stepsize = (1.0f / (currentEmber.m_Palette.Size() - 1));
for (auto palindex = 0; palindex < currentEmber.m_Palette.Size(); palindex++)
{
float t = palindex * stepsize;
auto h = hspline.Interpolate(t);
auto s = sspline.Interpolate(t);
auto v = vspline.Interpolate(t);
const float t = palindex * stepsize;
const auto h = hspline.Interpolate(t);
const auto s = sspline.Interpolate(t);
const auto v = vspline.Interpolate(t);
float r, g, b;
Palette<float>::HsvToRgb(float(h * 2 * M_PI), s, v, r, g, b);
Palette<float>::HsvToRgb(static_cast<float>(h * 2 * M_PI), s, v, r, g, b);
currentEmber.m_Palette.m_Entries[palindex][0] = r;
currentEmber.m_Palette.m_Entries[palindex][1] = g;
currentEmber.m_Palette.m_Entries[palindex][2] = b;
@ -1519,7 +1501,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
}
else if (!Compare(childNode->name, "node"))
{
if (auto nodename = CheckNameVal(childNode, "iterators"))
if (const auto nodename = CheckNameVal(childNode, "iterators"))
{
std::vector<std::string> alliterweights;
@ -1537,7 +1519,7 @@ bool XmlToEmber<T>::ParseEmberElementFromChaos(xmlNode* emberNode, Ember<T>& cur
{
size_t i = 0;
while (auto xform = currentEmber.GetXform(i))
while (const auto xform = currentEmber.GetXform(i))
{
if (i < alliterweights.size() && !alliterweights[i].empty())
{
@ -1742,7 +1724,7 @@ bool XmlToEmber<T>::ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber
else if (!Compare(curAtt->name, "overall_curve"))
{
//cout << "found overall curves\n";
auto splits = Split(attStr, ' ');
const auto splits = Split(attStr, ' ');
istringstream is(attStr);
vector<v2F> vals;
T x = 0, y = 0;
@ -1765,7 +1747,7 @@ bool XmlToEmber<T>::ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber
else if (!Compare(curAtt->name, "red_curve"))
{
//cout << "found red curves\n";
auto splits = Split(attStr, ' ');
const auto splits = Split(attStr, ' ');
istringstream is(attStr);
vector<v2F> vals;
T x = 0, y = 0;
@ -1788,7 +1770,7 @@ bool XmlToEmber<T>::ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber
else if (!Compare(curAtt->name, "green_curve"))
{
//cout << "found green curves\n";
auto splits = Split(attStr, ' ');
const auto splits = Split(attStr, ' ');
istringstream is(attStr);
vector<v2F> vals;
T x = 0, y = 0;
@ -1811,7 +1793,7 @@ bool XmlToEmber<T>::ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber
else if (!Compare(curAtt->name, "blue_curve"))
{
//cout << "found blue curves\n";
auto splits = Split(attStr, ' ');
const auto splits = Split(attStr, ' ');
istringstream is(attStr);
vector<v2F> vals;
T x = 0, y = 0;
@ -1957,11 +1939,11 @@ bool XmlToEmber<T>::ParseEmberElement(xmlNode* emberNode, Ember<T>& currentEmber
else if (!Compare(curAtt->name, "source_colors"))
{
string s(attStr);
auto vec1 = Split(s, ' ');
const auto vec1 = Split(s, ' ');
for (auto& v : vec1)
{
auto vec2 = Split(v, ',');
const auto vec2 = Split(v, ',');
if (vec2.size() == 4)
{
@ -2308,7 +2290,7 @@ bool XmlToEmber<T>::ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion,
else if (!Compare(curAtt->name, "color"))
{
istringstream is(attStr);
xform.m_ColorX = xform.m_ColorY = T(0.5);
xform.m_ColorX = xform.m_ColorY = static_cast<T>(0.5);
is >> xform.m_ColorX;
is >> xform.m_ColorY;//Very unlikely to be present, but leave for future use.
}
@ -2361,7 +2343,7 @@ bool XmlToEmber<T>::ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion,
//Only correct names if it came from an outside source. Names originating from this library are always considered correct.
string s = fromEmber ? string(CCX(curAtt->name)) : GetCorrectedVariationName(m_BadVariationNames, curAtt);
if (auto var = m_VariationList->GetVariation(s))
if (const auto var = m_VariationList->GetVariation(s))
{
T weight = 0;
Aton(attStr, weight);
@ -2442,7 +2424,7 @@ bool XmlToEmber<T>::ParseXform(xmlNode* childNode, Xform<T>& xform, bool motion,
//Now that all xforms have been parsed, go through and try to find params for the parametric variations.
for (size_t i = 0; i < xform.TotalVariationCount(); i++)
{
if (ParametricVariation<T>* parVar = dynamic_cast<ParametricVariation<T>*>(xform.GetVariation(i)))
if (const auto parVar = dynamic_cast<ParametricVariation<T>*>(xform.GetVariation(i)))
{
for (curAtt = attPtr; curAtt; curAtt = curAtt->next)
{
@ -2600,10 +2582,10 @@ bool XmlToEmber<T>::ParseHexColors(const char* colstr, Ember<T>& ember, size_t n
while (colorCount >= ember.m_Palette.Size())
ember.m_Palette.m_Entries.push_back(v4F());
ember.m_Palette.m_Entries[colorCount][i] = float(tmp) / 255.0f;//Hex palette is [0..255], convert to [0..1].
ember.m_Palette.m_Entries[colorCount][i] = static_cast<float>(tmp) / 255.0f;//Hex palette is [0..255], convert to [0..1].
}
ember.m_Palette.m_Entries[colorCount][3] = float(1);
ember.m_Palette.m_Entries[colorCount][3] = static_cast<float>(1);
colorCount++;
}

View File

@ -258,15 +258,15 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
else if (ToLower(opt.ScaleType()) != "none")
cout << "Scale type must be width height or none. Setting to none.\n";
auto w = std::max<size_t>(size_t(ember.m_OrigFinalRasW * opt.WidthScale()), 10);
auto h = std::max<size_t>(size_t(ember.m_OrigFinalRasH * opt.HeightScale()), 10);
const auto w = std::max<size_t>(size_t(ember.m_OrigFinalRasW * opt.WidthScale()), 10);
const auto h = std::max<size_t>(size_t(ember.m_OrigFinalRasH * opt.HeightScale()), 10);
ember.SetSizeAndAdjustScale(w, h, false, scaleType);
}
//Cast to double in case the value exceeds 2^32.
double imageMem = 4 * double(ember.m_FinalRasW)
* double(ember.m_FinalRasH) * double(renderers[0]->BytesPerChannel());
double maxMem = pow(2.0, double((sizeof(void*) * 8) - 1));
const auto imageMem = 4 * static_cast<double>(ember.m_FinalRasW)
* static_cast<double>(ember.m_FinalRasH) * static_cast<double>(renderers[0]->BytesPerChannel());
const auto maxMem = pow(2.0, static_cast<double>((sizeof(void*) * 8) - 1));
if (imageMem > maxMem)//Ensure the max amount of memory for a process isn't exceeded.
{
@ -328,16 +328,16 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
size_t h,
size_t chan)
{
auto finalImagep = finalImage.data();
auto size = w * h;
bool doBmp = Find(opt.Format(), "bmp");
bool doJpg = Find(opt.Format(), "jpg");
bool doExr16 = Find(opt.Format(), "exr");
bool doExr32 = Find(opt.Format(), "exr32");
bool doPng8 = Find(opt.Format(), "png");
bool doPng16 = Find(opt.Format(), "png16");
bool doOnlyPng8 = doPng8 && !doPng16;
bool doOnlyExr16 = doExr16 && !doExr32;
const auto finalImagep = finalImage.data();
const auto size = w * h;
const auto doBmp = Find(opt.Format(), "bmp");
const auto doJpg = Find(opt.Format(), "jpg");
const auto doExr16 = Find(opt.Format(), "exr");
const auto doExr32 = Find(opt.Format(), "exr32");
const auto doPng8 = Find(opt.Format(), "png");
const auto doPng16 = Find(opt.Format(), "png16");
const auto doOnlyPng8 = doPng8 && !doPng16;
const auto doOnlyExr16 = doExr16 && !doExr32;
vector<byte> rgb8Image;
vector<std::thread> writeFileThreads;
writeFileThreads.reserve(6);
@ -351,9 +351,9 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto fn = baseFilename + ".bmp";
const auto fn = baseFilename + ".bmp";
VerbosePrint("Writing " + fn);
auto writeSuccess = WriteBmp(fn.c_str(), rgb8Image.data(), w, h);
const auto writeSuccess = WriteBmp(fn.c_str(), rgb8Image.data(), w, h);
if (!writeSuccess)
cout << "Error writing " << fn << "\n";
@ -364,9 +364,9 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto fn = baseFilename + ".jpg";
const auto fn = baseFilename + ".jpg";
VerbosePrint("Writing " + fn);
auto writeSuccess = WriteJpeg(fn.c_str(), rgb8Image.data(), w, h, int(opt.JpegQuality()), opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WriteJpeg(fn.c_str(), rgb8Image.data(), w, h, int(opt.JpegQuality()), opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << fn << "\n";
@ -382,11 +382,11 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto fn = baseFilename + ".png";
const auto fn = baseFilename + ".png";
VerbosePrint("Writing " + fn);
vector<byte> rgba8Image(size * 4);
Rgba32ToRgba8(finalImagep, rgba8Image.data(), w, h, opt.Transparency());
auto writeSuccess = WritePng(fn.c_str(), rgba8Image.data(), w, h, 1, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WritePng(fn.c_str(), rgba8Image.data(), w, h, 1, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << fn << "\n";
@ -397,7 +397,7 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto suffix = opt.Suffix();
const auto suffix = opt.Suffix();
auto fn = baseFilename;
if (doBothPng)//Add suffix if they specified both PNG.
@ -410,7 +410,7 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
VerbosePrint("Writing " + fn);
vector<glm::uint16> rgba16Image(size * 4);
Rgba32ToRgba16(finalImagep, rgba16Image.data(), w, h, opt.Transparency());
auto writeSuccess = WritePng(fn.c_str(), (byte*)rgba16Image.data(), w, h, 2, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WritePng(fn.c_str(), (byte*)rgba16Image.data(), w, h, 2, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << fn << "\n";
@ -426,11 +426,11 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto fn = baseFilename + ".exr";
const auto fn = baseFilename + ".exr";
VerbosePrint("Writing " + fn);
vector<Rgba> rgba32Image(size);
Rgba32ToRgbaExr(finalImagep, rgba32Image.data(), w, h, opt.Transparency());
auto writeSuccess = WriteExr16(fn.c_str(), rgba32Image.data(), w, h, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WriteExr16(fn.c_str(), rgba32Image.data(), w, h, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << fn << "\n";
@ -441,7 +441,7 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto suffix = opt.Suffix();
const auto suffix = opt.Suffix();
auto fn = baseFilename;
if (doBothExr)//Add suffix if they specified both EXR.
@ -457,12 +457,12 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
vector<float> b(size);
vector<float> a(size);
Rgba32ToRgba32Exr(finalImagep, r.data(), g.data(), b.data(), a.data(), w, h, opt.Transparency());
auto writeSuccess = WriteExr32(fn.c_str(),
r.data(),
g.data(),
b.data(),
a.data(),
w, h, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WriteExr32(fn.c_str(),
r.data(),
g.data(),
b.data(),
a.data(),
w, h, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << fn << "\n";
@ -498,7 +498,7 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
// that it was first incremented before comparing.
while ((ftime = (atomfTime.fetch_add(opt.Dtime()) + opt.Dtime())) <= opt.LastFrame())
{
T localTime = T(ftime) - opt.Dtime();
const auto localTime = static_cast<T>(ftime) - opt.Dtime();
if (opt.Verbose() && ((opt.LastFrame() - opt.FirstFrame()) / opt.Dtime() >= 1))
{
@ -518,7 +518,7 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
if (opt.WriteGenome())
{
auto flameName = MakeAnimFilename(inputPath, opt.Prefix(), opt.Suffix(), ".flame", padding, size_t(localTime));
const auto flameName = MakeAnimFilename(inputPath, opt.Prefix(), opt.Suffix(), ".flame", padding, size_t(localTime));
if (opt.Verbose())
{
@ -534,8 +534,8 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
stats = renderer->Stats();
comments = renderer->ImageComments(stats, opt.PrintEditDepth(), true);
os.str("");
size_t iterCount = renderer->TotalIterCount(1);
os << comments.m_NumIters << " / " << iterCount << " (" << std::fixed << std::setprecision(2) << ((double(stats.m_Iters) / double(iterCount)) * 100) << "%)";
const auto iterCount = renderer->TotalIterCount(1);
os << comments.m_NumIters << " / " << iterCount << " (" << std::fixed << std::setprecision(2) << ((static_cast<double>(stats.m_Iters) / static_cast<double>(iterCount)) * 100) << "%)";
if (opt.Verbose())
{
@ -552,8 +552,8 @@ bool EmberAnimate(int argc, _TCHAR* argv[], EmberOptions& opt)
//Run image writing in a thread. Although doing it this way duplicates the final output memory, it saves a lot of time
//when running with OpenCL. Call join() to ensure the previous thread call has completed.
Join(writeThread);
auto threadVecIndex = finalImageIndex;//Cache before launching thread.
auto baseFilename = MakeAnimFilename(inputPath, opt.Prefix(), opt.Suffix(), "", padding, size_t(localTime));
const auto threadVecIndex = finalImageIndex;//Cache before launching thread.
const auto baseFilename = MakeAnimFilename(inputPath, opt.Prefix(), opt.Suffix(), "", padding, size_t(localTime));
if (opt.ThreadedWrite())//Copies of all but the first parameter are passed to saveFunc(), to avoid conflicting with those values changing when starting the render for the next image.
{
@ -603,7 +603,7 @@ int _tmain(int argc, _TCHAR* argv[])
if (!opt.Populate(argc, argv, eOptionUse::OPT_USE_ANIMATE))
{
auto palf = PaletteList<float>::Instance();
const auto palf = PaletteList<float>::Instance();
#ifdef DO_DOUBLE
if (!opt.Sp())

View File

@ -131,7 +131,7 @@ uint DEOpenCLKernelCreator::MaxDEFilterSize() { return 9; }//The true max would
/// <returns>The maximum filter radius allowed</returns>
double DEOpenCLKernelCreator::SolveMaxDERad(double desiredFilterSize, double ss)
{
uint finalFilterSize = uint((ceil(desiredFilterSize) * ss) + (ss - 1.0));
auto finalFilterSize = static_cast<uint>((ceil(desiredFilterSize) * ss) + (ss - 1.0));
//Return the desired size if the final size of it will fit.
if (finalFilterSize <= MaxDEFilterSize())
@ -149,7 +149,7 @@ double DEOpenCLKernelCreator::SolveMaxDERad(double desiredFilterSize, double ss)
/// <returns>The maximum filter box size allowed</returns>
uint DEOpenCLKernelCreator::SolveMaxBoxSize(uint localMem)
{
return uint(std::floor(std::sqrt(Floor(localMem / 16.0))));//Divide by 16 because each element is float4.
return static_cast<uint>(std::floor(std::sqrt(Floor(localMem / 16.0))));//Divide by 16 because each element is float4.
}
/// <summary>

View File

@ -813,7 +813,7 @@ string IterOpenCLKernelCreator<T>::GlobalFunctionsString(const Ember<T>& ember)
ostringstream os;
static string zeps = "Zeps";
while (auto xform = ember.GetTotalXform(i++))
while (const auto xform = ember.GetTotalXform(i++))
{
size_t varCount = xform->TotalVariationCount();
@ -823,9 +823,9 @@ string IterOpenCLKernelCreator<T>::GlobalFunctionsString(const Ember<T>& ember)
for (j = 0; j < varCount; j++)
{
if (auto var = xform->GetVariation(j))
if (const auto var = xform->GetVariation(j))
{
auto names = var->OpenCLGlobalFuncNames();
const auto names = var->OpenCLGlobalFuncNames();
if (var->NeedPrecalcAngles())
if (!Contains(funcNames, zeps))
@ -843,7 +843,7 @@ string IterOpenCLKernelCreator<T>::GlobalFunctionsString(const Ember<T>& ember)
funcNames.push_back(zeps);
for (auto& funcName : funcNames)
if (auto text = m_FunctionMapper.GetGlobalFunc(funcName))
if (const auto text = m_FunctionMapper.GetGlobalFunc(funcName))
os << *text << "\n";
return os.str();
@ -897,11 +897,11 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(const Ember<T>& ember, pair<
if (doVals)
params.second.clear();
while (auto xform = ember.GetTotalXform(i))
while (const auto xform = ember.GetTotalXform(i))
{
size_t j = 0;
while (auto var = xform->GetVariation(j))
while (const auto var = xform->GetVariation(j))
{
if (doString)
os << "#define WEIGHT_" << i << "_" << j << " " << size++ << "\n";//Uniquely identify the weight of this variation in this xform.
@ -909,7 +909,7 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(const Ember<T>& ember, pair<
if (doVals)
params.second.push_back(var->m_Weight);
if (auto parVar = dynamic_cast<ParametricVariation<T>*>(var))
if (const auto parVar = dynamic_cast<ParametricVariation<T>*>(var))
{
for (size_t k = 0; k < parVar->ParamCount(); k++)
{
@ -918,7 +918,7 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(const Ember<T>& ember, pair<
if (doString)
os << "#define " << ToUpper(parVar->Params()[k].Name()) << "_" << i << " " << size << "\n";//Uniquely identify this param in this variation in this xform.
auto elements = parVar->Params()[k].Size() / sizeof(T);
const auto elements = parVar->Params()[k].Size() / sizeof(T);
if (doVals)
{
@ -959,20 +959,20 @@ void IterOpenCLKernelCreator<T>::SharedDataIndexDefines(const Ember<T>& ember, p
string s;
vector<string> dataNames;//Can't use a set here because they sort and we must preserve the insertion order due to nested function calls.
ostringstream os;
auto varFuncs = VarFuncs<T>::Instance();
const auto varFuncs = VarFuncs<T>::Instance();
if (doVals)
params.second.clear();
while (auto xform = ember.GetTotalXform(i++))
while (const auto xform = ember.GetTotalXform(i++))
{
size_t varCount = xform->TotalVariationCount();
for (j = 0; j < varCount; j++)
{
if (auto var = xform->GetVariation(j))
if (const auto var = xform->GetVariation(j))
{
auto names = var->OpenCLGlobalDataNames();
const auto names = var->OpenCLGlobalDataNames();
for (auto& name : names)
{
@ -980,7 +980,7 @@ void IterOpenCLKernelCreator<T>::SharedDataIndexDefines(const Ember<T>& ember, p
{
s = ToUpper(name);
if (auto dataInfo = varFuncs->GetSharedData(s))///Will contain a name, pointer to data, and size of the data in units of sizeof(T).
if (const auto dataInfo = varFuncs->GetSharedData(s))///Will contain a name, pointer to data, and size of the data in units of sizeof(T).
{
if (doString)
os << "#define " << ToUpper(name) << " " << offset << '\n';
@ -1017,9 +1017,9 @@ string IterOpenCLKernelCreator<T>::VariationStateString(const Ember<T>& ember)
ostringstream os;
os << "typedef struct __attribute__ " ALIGN_CL " _VariationState\n{";
while (auto xform = ember.GetTotalXform(i++))
while (const auto xform = ember.GetTotalXform(i++))
for (size_t j = 0; j < xform->TotalVariationCount(); j++)
if (auto var = xform->GetVariation(j))
if (const auto var = xform->GetVariation(j))
os << var->StateOpenCLString();
os << "\n} VariationState;\n\n";
@ -1039,9 +1039,9 @@ string IterOpenCLKernelCreator<T>::VariationStateInitString(const Ember<T>& embe
size_t i = 0;
ostringstream os;
while (auto xform = ember.GetTotalXform(i++))
while (const auto xform = ember.GetTotalXform(i++))
for (size_t j = 0; j < xform->TotalVariationCount(); j++)
if (auto var = xform->GetVariation(j))
if (const auto var = xform->GetVariation(j))
os << var->StateInitOpenCLString();
return os.str();
@ -1057,7 +1057,7 @@ bool IterOpenCLKernelCreator<T>::AnyZeroOpacity(const Ember<T>& ember)
{
size_t i = 0;
while (auto xform = ember.GetXform(i++))
while (const auto xform = ember.GetXform(i++))
if (xform->m_Opacity == 0)
return true;
@ -1118,9 +1118,9 @@ bool IterOpenCLKernelCreator<T>::IsBuildRequired(const Ember<T>& ember1, const E
for (i = 0; i < xformCount; i++)
{
auto xform1 = ember1.GetTotalXform(i);
auto xform2 = ember2.GetTotalXform(i);
auto varCount = xform1->TotalVariationCount();
const auto xform1 = ember1.GetTotalXform(i);
const auto xform2 = ember2.GetTotalXform(i);
const auto varCount = xform1->TotalVariationCount();
if (optAffine && (xform1->m_Affine.IsID() != xform2->m_Affine.IsID()))
return true;

View File

@ -265,7 +265,7 @@ bool OpenCLWrapper::WriteBuffer(size_t bufferIndex, void* data, size_t size)
if (m_Init && (bufferIndex < m_Buffers.size()) && (GetBufferSize(bufferIndex) == size))
{
cl::Event e;
cl_int err = m_Queue.enqueueWriteBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, nullptr, &e);
const auto err = m_Queue.enqueueWriteBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, nullptr, &e);
e.wait();
m_Queue.finish();
@ -301,7 +301,7 @@ bool OpenCLWrapper::ReadBuffer(size_t bufferIndex, void* data, size_t size)
if (m_Init && (bufferIndex < m_Buffers.size()) && (GetBufferSize(bufferIndex) == size))
{
cl::Event e;
cl_int err = m_Queue.enqueueReadBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, nullptr, &e);
const auto err = m_Queue.enqueueReadBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, nullptr, &e);
e.wait();
m_Queue.finish();
@ -752,7 +752,7 @@ bool OpenCLWrapper::EnqueueAcquireGLObjects(cl::ImageGL& image)
{
vector<cl::Memory> images;
images.push_back(image);
cl_int err = m_Queue.enqueueAcquireGLObjects(&images);
const auto err = m_Queue.enqueueAcquireGLObjects(&images);
m_Queue.finish();
return m_Info->CheckCL(err, "cl::CommandQueue::enqueueAcquireGLObjects()");
}
@ -786,7 +786,7 @@ bool OpenCLWrapper::EnqueueReleaseGLObjects(cl::ImageGL& image)
{
vector<cl::Memory> images;
images.push_back(image);
cl_int err = m_Queue.enqueueReleaseGLObjects(&images);
const auto err = m_Queue.enqueueReleaseGLObjects(&images);
m_Queue.finish();
return m_Info->CheckCL(err, "cl::CommandQueue::enqueueReleaseGLObjects()");
}
@ -803,7 +803,7 @@ bool OpenCLWrapper::EnqueueAcquireGLObjects(const VECTOR_CLASS<cl::Memory>* memO
{
if (m_Init && m_Shared)
{
cl_int err = m_Queue.enqueueAcquireGLObjects(memObjects);
const auto err = m_Queue.enqueueAcquireGLObjects(memObjects);
m_Queue.finish();
return m_Info->CheckCL(err, "cl::CommandQueue::enqueueAcquireGLObjects()");
}
@ -820,7 +820,7 @@ bool OpenCLWrapper::EnqueueReleaseGLObjects(const VECTOR_CLASS<cl::Memory>* memO
{
if (m_Init && m_Shared)
{
cl_int err = m_Queue.enqueueReleaseGLObjects(memObjects);
const auto err = m_Queue.enqueueReleaseGLObjects(memObjects);
m_Queue.finish();
return m_Info->CheckCL(err, "cl::CommandQueue::enqueueReleaseGLObjects()");
}
@ -958,12 +958,12 @@ bool OpenCLWrapper::RunKernel(size_t kernelIndex, size_t totalGridWidth, size_t
if (m_Init && kernelIndex < m_Programs.size())
{
cl::Event e;
cl_int err = m_Queue.enqueueNDRangeKernel(m_Programs[kernelIndex].m_Kernel,
cl::NullRange,
cl::NDRange(totalGridWidth, totalGridHeight, totalGridDepth),
cl::NDRange(blockWidth, blockHeight, blockDepth),
nullptr,
&e);
const auto err = m_Queue.enqueueNDRangeKernel(m_Programs[kernelIndex].m_Kernel,
cl::NullRange,
cl::NDRange(totalGridWidth, totalGridHeight, totalGridDepth),
cl::NDRange(blockWidth, blockHeight, blockDepth),
nullptr,
&e);
e.wait();
m_Queue.finish();
return m_Info->CheckCL(err, "cl::CommandQueue::enqueueNDRangeKernel()");

View File

@ -339,15 +339,15 @@ void RendererCL<T, bucketT>::InitStateVec()
{
size_t count = 0, i = 0, j = 0, k = 0;
while (auto xform = m_Ember.GetTotalXform(i++))
while (const auto xform = m_Ember.GetTotalXform(i++))
for (j = 0; j < xform->TotalVariationCount(); j++)
if (auto var = xform->GetVariation(j))
if (const auto var = xform->GetVariation(j))
count += var->StateParamCount() * sizeof(T);
//Round to 16 and resize the buffer to be copied to OpenCL buffer here.
auto igkc = IterGridKernelCount();
const auto igkc = IterGridKernelCount();
size_t index = 0, count16 = ((count / 16) * 16) + (count % 16 > 0 ? 16 : 0);
auto elcount = count16 / sizeof(T);
const auto elcount = count16 / sizeof(T);
m_VarStates.resize(igkc * elcount);
if (count16)
@ -357,9 +357,9 @@ void RendererCL<T, bucketT>::InitStateVec()
i = 0;
index = k * elcount;
while (auto xform = m_Ember.GetTotalXform(i++))
while (const auto xform = m_Ember.GetTotalXform(i++))
for (j = 0; j < xform->TotalVariationCount(); j++)
if (auto var = xform->GetVariation(j))
if (const auto var = xform->GetVariation(j))
var->InitStateVars(m_VarStates.data(), index);
}
}
@ -447,7 +447,7 @@ bool RendererCL<T, bucketT>::ClearFinal()
if (!m_Devices.empty())
{
auto& wrapper = m_Devices[0]->m_Wrapper;
uint index = wrapper.FindImageIndex(m_FinalImageName, wrapper.Shared());
const auto index = wrapper.FindImageIndex(m_FinalImageName, wrapper.Shared());
if (this->PrepFinalAccumVector(v))
{
@ -626,7 +626,7 @@ vector<string> RendererCL<T, bucketT>::ErrorReport()
for (auto& device : m_Devices)
{
auto s = device->ErrorReport();
const auto s = device->ErrorReport();
ours.insert(ours.end(), s.begin(), s.end());
}
@ -1148,25 +1148,25 @@ bool RendererCL<T, bucketT>::RunIter(size_t iterCount, size_t temporalSample, si
if (m_Callback && !dev)//Will only do callback on the first device, however it will report the progress of all devices.
{
double percent = 100.0 *
double
(
double
const auto percent = 100.0 *
static_cast<double>
(
double
static_cast<double>
(
double(m_LastIter + atomItersRan.load()) / double(ItersPerTemporalSample())
) + temporalSample
) / double(TemporalSamples())
);
double percentDiff = percent - m_LastIterPercent;
double toc = m_ProgressTimer.Toc();
static_cast<double>
(
static_cast<double>(m_LastIter + atomItersRan.load()) / static_cast<double>(ItersPerTemporalSample())
) + temporalSample
) / static_cast<double>(TemporalSamples())
);
const auto percentDiff = percent - m_LastIterPercent;
const auto toc = m_ProgressTimer.Toc();
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))//Call callback function if either 10% has passed, or one second (and 1%).
{
auto startingpercent = 100.0 * (m_LastIter / double(ItersPerTemporalSample()));//This is done to support incremental renders, starting from the percentage it left off on.
auto currentpercent = percent - startingpercent;//Current percent in terms of starting percentage. So starting at 50% and progressing 5% will give a value of 5%, not 55%.
auto etaMs = currentpercent == 0 ? 0 : (((100.0 - startingpercent) - currentpercent) / currentpercent) * m_RenderTimer.Toc();//Subtract startingpercent from 100% so that it's properly scaled, meaning rendering from 50% - 100% will be treated as 0% - 100%.
const auto startingpercent = 100.0 * (m_LastIter / static_cast<double>(ItersPerTemporalSample()));//This is done to support incremental renders, starting from the percentage it left off on.
const auto currentpercent = percent - startingpercent;//Current percent in terms of starting percentage. So starting at 50% and progressing 5% will give a value of 5%, not 55%.
const auto etaMs = currentpercent == 0 ? 0 : (((100.0 - startingpercent) - currentpercent) / currentpercent) * m_RenderTimer.Toc();//Subtract startingpercent from 100% so that it's properly scaled, meaning rendering from 50% - 100% will be treated as 0% - 100%.
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 0, etaMs))
Abort();
@ -1229,7 +1229,7 @@ eRenderStatus RendererCL<T, bucketT>::RunLogScaleFilter()
if (b)
{
auto& wrapper = m_Devices[0]->m_Wrapper;
int kernelIndex = wrapper.FindKernelIndex(m_DEOpenCLKernelCreator.LogScaleAssignDEEntryPoint());
const auto kernelIndex = wrapper.FindKernelIndex(m_DEOpenCLKernelCreator.LogScaleAssignDEEntryPoint());
if (kernelIndex != -1)
{
@ -1305,10 +1305,10 @@ eRenderStatus RendererCL<T, bucketT>::RunDensityFilter()
//that are far enough apart such that their filters do not overlap.
//Do the latter.
//Gap is in terms of blocks and specifies how many blocks must separate two blocks running at the same time.
uint gapW = uint(ceil(fw2 / blockSizeW));
uint chunkSizeW = gapW + 1;//Chunk size is also in terms of blocks and is one block (the one running) plus the gap to the right of it.
uint gapH = uint(ceil(fw2 / blockSizeH));
uint chunkSizeH = gapH + 1;//Chunk size is also in terms of blocks and is one block (the one running) plus the gap below it.
const auto gapW = static_cast<uint>(ceil(fw2 / blockSizeW));
const auto chunkSizeW = gapW + 1;//Chunk size is also in terms of blocks and is one block (the one running) plus the gap to the right of it.
const auto gapH = static_cast<uint>(ceil(fw2 / blockSizeH));
const auto chunkSizeH = gapH + 1;//Chunk size is also in terms of blocks and is one block (the one running) plus the gap below it.
double totalChunks = chunkSizeW * chunkSizeH;
if (b && !(b = wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, reinterpret_cast<void*>(&m_DensityFilterCL), sizeof(m_DensityFilterCL)))) { ErrorStr(loc, "Writing DE filter parameters buffer failed", m_Devices[0].get()); }
@ -1364,8 +1364,8 @@ eRenderStatus RendererCL<T, bucketT>::RunDensityFilter()
if (b && m_Callback)
{
double percent = (double((rowChunkPass * chunkSizeW) + (colChunkPass + 1)) / totalChunks) * 100.0;
double etaMs = ((100.0 - percent) / percent) * t.Toc();
const auto percent = (static_cast<double>((rowChunkPass * chunkSizeW) + (colChunkPass + 1)) / totalChunks) * 100.0;
const auto etaMs = ((100.0 - percent) / percent) * t.Toc();
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 1, etaMs))
Abort();
@ -1502,7 +1502,7 @@ bool RendererCL<T, bucketT>::ClearBuffer(size_t device, const string& bufferName
if (device < m_Devices.size())
{
auto& wrapper = m_Devices[device]->m_Wrapper;
int kernelIndex = wrapper.FindKernelIndex(m_IterOpenCLKernelCreator.ZeroizeEntryPoint());
const auto kernelIndex = wrapper.FindKernelIndex(m_IterOpenCLKernelCreator.ZeroizeEntryPoint());
cl_uint argIndex = 0;
static std::string loc = __FUNCTION__;
@ -1604,7 +1604,7 @@ int RendererCL<T, bucketT>::MakeAndGetDensityFilterProgram(size_t ss, uint filte
if (!m_Devices.empty())
{
auto& wrapper = m_Devices[0]->m_Wrapper;
auto& deEntryPoint = m_DEOpenCLKernelCreator.GaussianDEEntryPoint(ss, filterWidth);
const auto& deEntryPoint = m_DEOpenCLKernelCreator.GaussianDEEntryPoint(ss, filterWidth);
const char* loc = __FUNCTION__;
if ((kernelIndex = wrapper.FindKernelIndex(deEntryPoint)) == -1)//Has not been built yet.
@ -1633,7 +1633,7 @@ int RendererCL<T, bucketT>::MakeAndGetFinalAccumProgram()
if (!m_Devices.empty())
{
auto& wrapper = m_Devices[0]->m_Wrapper;
auto& finalAccumEntryPoint = m_FinalAccumOpenCLKernelCreator.FinalAccumEntryPoint(EarlyClip());
const auto& finalAccumEntryPoint = m_FinalAccumOpenCLKernelCreator.FinalAccumEntryPoint(EarlyClip());
const char* loc = __FUNCTION__;
if ((kernelIndex = wrapper.FindKernelIndex(finalAccumEntryPoint)) == -1)//Has not been built yet.
@ -1660,13 +1660,13 @@ int RendererCL<T, bucketT>::MakeAndGetGammaCorrectionProgram()
if (!m_Devices.empty())
{
auto& wrapper = m_Devices[0]->m_Wrapper;
auto& gammaEntryPoint = m_FinalAccumOpenCLKernelCreator.GammaCorrectionEntryPoint();
int kernelIndex = wrapper.FindKernelIndex(gammaEntryPoint);
const auto& gammaEntryPoint = m_FinalAccumOpenCLKernelCreator.GammaCorrectionEntryPoint();
auto kernelIndex = wrapper.FindKernelIndex(gammaEntryPoint);
static std::string loc = __FUNCTION__;
if (kernelIndex == -1)//Has not been built yet.
{
auto& kernel = m_FinalAccumOpenCLKernelCreator.GammaCorrectionKernel();
const auto& kernel = m_FinalAccumOpenCLKernelCreator.GammaCorrectionKernel();
bool b = wrapper.AddProgram(gammaEntryPoint, kernel, gammaEntryPoint, m_DoublePrecision);
if (b)
@ -1689,8 +1689,8 @@ int RendererCL<T, bucketT>::MakeAndGetGammaCorrectionProgram()
template <typename T, typename bucketT>
bool RendererCL<T, bucketT>::CreateHostBuffer()
{
bool b = true;
size_t size = SuperSize() * sizeof(v4bT);//Size of histogram and density filter buffer.
auto b = true;
const auto size = SuperSize() * sizeof(v4bT);//Size of histogram and density filter buffer.
static std::string loc = __FUNCTION__;
if (b = Renderer<T, bucketT>::Alloc(true))//Allocate the histogram memory to point this HOST_PTR buffer to, other buffers not needed.
@ -1717,15 +1717,15 @@ bool RendererCL<T, bucketT>::SumDeviceHist()
if (m_Devices.size() > 1)
{
//Timing t;
bool b = true;
auto b = true;
auto& wrapper = m_Devices[0]->m_Wrapper;
static std::string loc = __FUNCTION__;
size_t blockW = m_Devices[0]->Nvidia() ? 32 : 16;//Max work group size is 256 on AMD, which means 16x16.
size_t blockH = m_Devices[0]->Nvidia() ? 32 : 16;
const size_t blockW = m_Devices[0]->Nvidia() ? 32 : 16;//Max work group size is 256 on AMD, which means 16x16.
const size_t blockH = m_Devices[0]->Nvidia() ? 32 : 16;
size_t gridW = SuperRasW();
size_t gridH = SuperRasH();
OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH);
int kernelIndex = wrapper.FindKernelIndex(m_IterOpenCLKernelCreator.SumHistEntryPoint());
const auto kernelIndex = wrapper.FindKernelIndex(m_IterOpenCLKernelCreator.SumHistEntryPoint());
if ((b = (kernelIndex != -1)))
{
@ -1915,9 +1915,9 @@ void RendererCL<T, bucketT>::FillSeeds()
{
if (!m_Devices.empty())
{
double start, delta = std::floor(double(std::numeric_limits<uint>::max()) / (IterGridKernelCount() * 2 * m_Devices.size()));
const auto delta = std::floor(double(std::numeric_limits<uint>::max()) / (IterGridKernelCount() * 2 * m_Devices.size()));
auto start = delta;
m_Seeds.resize(m_Devices.size());
start = delta;
for (size_t device = 0; device < m_Devices.size(); device++)
{
@ -1944,11 +1944,11 @@ void RendererCL<T, bucketT>::FillSeeds()
template <typename T, typename bucketT>
std::string RendererCL<T, bucketT>::ErrorStr(const std::string& loc, const std::string& error, RendererClDevice* dev)
{
std::string str = loc + "()"s + (dev ?
"\n"s +
dev->m_Wrapper.DeviceName() + "\nPlatform: " +
std::to_string(dev->PlatformIndex()) + ", device: " + std::to_string(dev->DeviceIndex()) : "") + ", error:\n" +
error + "\n";
const std::string str = loc + "()"s + (dev ?
"\n"s +
dev->m_Wrapper.DeviceName() + "\nPlatform: " +
std::to_string(dev->PlatformIndex()) + ", device: " + std::to_string(dev->DeviceIndex()) : "") + ", error:\n" +
error + "\n";
AddToReport(str);
return str;
}

View File

@ -156,30 +156,30 @@ public:
virtual bool ClearFinal();
//Public virtual functions overridden from Renderer or RendererBase.
virtual size_t MemoryAvailable() override;
virtual bool Ok() const override;
virtual size_t SubBatchSize() const override;
virtual size_t ThreadCount() const override;
virtual bool CreateDEFilter(bool& newAlloc) override;
virtual bool CreateSpatialFilter(bool& newAlloc) override;
virtual eRendererType RendererType() const override;
virtual bool Shared() const override;
virtual void ClearErrorReport() override;
virtual string ErrorReportString() override;
virtual vector<string> ErrorReport() override;
virtual bool RandVec(vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>>& randVec) override;
virtual bool AnyNvidia() const override;
size_t MemoryAvailable() override;
bool Ok() const override;
size_t SubBatchSize() const override;
size_t ThreadCount() const override;
bool CreateDEFilter(bool& newAlloc) override;
bool CreateSpatialFilter(bool& newAlloc) override;
eRendererType RendererType() const override;
bool Shared() const override;
void ClearErrorReport() override;
string ErrorReportString() override;
vector<string> ErrorReport() override;
bool RandVec(vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>>& randVec) override;
bool AnyNvidia() const override;
#ifndef TEST_CL
protected:
#endif
//Protected virtual functions overridden from Renderer.
virtual bool Alloc(bool histOnly = false) override;
virtual bool ResetBuckets(bool resetHist = true, bool resetAccum = true) override;
virtual eRenderStatus LogScaleDensityFilter(bool forceOutput = false) override;
virtual eRenderStatus GaussianDensityFilter() override;
virtual eRenderStatus AccumulatorToFinalImage(vector<v4F>& pixels, size_t finalOffset) override;
virtual EmberStats Iterate(size_t iterCount, size_t temporalSample) override;
bool Alloc(bool histOnly = false) override;
bool ResetBuckets(bool resetHist = true, bool resetAccum = true) override;
eRenderStatus LogScaleDensityFilter(bool forceOutput = false) override;
eRenderStatus GaussianDensityFilter() override;
eRenderStatus AccumulatorToFinalImage(vector<v4F>& pixels, size_t finalOffset) override;
EmberStats Iterate(size_t iterCount, size_t temporalSample) override;
#ifndef TEST_CL
private:

View File

@ -74,7 +74,7 @@ void RendererClDevice::ClearErrorReport()
/// <returns>The concatenated error report string</returns>
string RendererClDevice::ErrorReportString()
{
auto s = EmberReport::ErrorReportString();
const auto s = EmberReport::ErrorReportString();
return s + m_Wrapper.ErrorReportString();
}
@ -86,7 +86,7 @@ string RendererClDevice::ErrorReportString()
vector<string> RendererClDevice::ErrorReport()
{
auto ours = EmberReport::ErrorReport();
auto s = m_Wrapper.ErrorReport();
const auto s = m_Wrapper.ErrorReport();
ours.insert(ours.end(), s.begin(), s.end());
return ours;
}

View File

@ -28,9 +28,9 @@ public:
size_t DeviceIndex() const;
//Public virtual functions overridden from base classes.
virtual void ClearErrorReport() override;
virtual string ErrorReportString() override;
virtual vector<string> ErrorReport() override;
void ClearErrorReport() override;
string ErrorReportString() override;
vector<string> ErrorReport() override;
size_t m_Calls;
OpenCLWrapper m_Wrapper;

View File

@ -218,9 +218,9 @@ static void Rgba32ToRgb8(v4F* rgba, byte* rgb, size_t width, size_t height)
{
for (size_t i = 0, j = 0; i < (width * height); i++)
{
rgb[j++] = byte(Clamp<float>(rgba[i].r * 255.0f, 0.0f, 255.0f));
rgb[j++] = byte(Clamp<float>(rgba[i].g * 255.0f, 0.0f, 255.0f));
rgb[j++] = byte(Clamp<float>(rgba[i].b * 255.0f, 0.0f, 255.0f));
rgb[j++] = static_cast<byte>(Clamp<float>(rgba[i].r * 255.0f, 0.0f, 255.0f));
rgb[j++] = static_cast<byte>(Clamp<float>(rgba[i].g * 255.0f, 0.0f, 255.0f));
rgb[j++] = static_cast<byte>(Clamp<float>(rgba[i].b * 255.0f, 0.0f, 255.0f));
}
}
@ -237,10 +237,10 @@ static void Rgba32ToRgba8(v4F* rgba, byte* rgb, size_t width, size_t height, boo
{
for (size_t i = 0, j = 0; i < (width * height); i++)
{
rgb[j++] = byte(Clamp<float>(rgba[i].r * 255.0f, 0.0f, 255.0f));
rgb[j++] = byte(Clamp<float>(rgba[i].g * 255.0f, 0.0f, 255.0f));
rgb[j++] = byte(Clamp<float>(rgba[i].b * 255.0f, 0.0f, 255.0f));
rgb[j++] = doAlpha ? byte(Clamp<float>(rgba[i].a * 255.0f, 0.0f, 255.0f)) : 255;
rgb[j++] = static_cast<byte>(Clamp<float>(rgba[i].r * 255.0f, 0.0f, 255.0f));
rgb[j++] = static_cast<byte>(Clamp<float>(rgba[i].g * 255.0f, 0.0f, 255.0f));
rgb[j++] = static_cast<byte>(Clamp<float>(rgba[i].b * 255.0f, 0.0f, 255.0f));
rgb[j++] = doAlpha ? static_cast<byte>(Clamp<float>(rgba[i].a * 255.0f, 0.0f, 255.0f)) : 255;
}
}
@ -257,10 +257,10 @@ static void Rgba32ToRgba16(v4F* rgba, glm::uint16* rgb, size_t width, size_t hei
{
for (size_t i = 0, j = 0; i < (width * height); i++)
{
rgb[j++] = glm::uint16(Clamp<float>(rgba[i].r * 65535.0f, 0.0f, 65535.0f));
rgb[j++] = glm::uint16(Clamp<float>(rgba[i].g * 65535.0f, 0.0f, 65535.0f));
rgb[j++] = glm::uint16(Clamp<float>(rgba[i].b * 65535.0f, 0.0f, 65535.0f));
rgb[j++] = doAlpha ? glm::uint16(Clamp<float>(rgba[i].a * 65535.0f, 0.0f, 65535.0f)) : glm::uint16(65535);
rgb[j++] = static_cast<glm::uint16>(Clamp<float>(rgba[i].r * 65535.0f, 0.0f, 65535.0f));
rgb[j++] = static_cast<glm::uint16>(Clamp<float>(rgba[i].g * 65535.0f, 0.0f, 65535.0f));
rgb[j++] = static_cast<glm::uint16>(Clamp<float>(rgba[i].b * 65535.0f, 0.0f, 65535.0f));
rgb[j++] = doAlpha ? static_cast<glm::uint16>(Clamp<float>(rgba[i].a * 65535.0f, 0.0f, 65535.0f)) : glm::uint16{ 65535 };
}
}
@ -385,8 +385,6 @@ static string MakeAnimFilename(const string& path, const string& prefix, const s
/// <returns>The number of strips to use</returns>
static uint CalcStrips(double memRequired, double memAvailable, double useMem)
{
uint strips;
if (useMem > 0)
memAvailable = useMem;
else
@ -395,8 +393,7 @@ static uint CalcStrips(double memRequired, double memAvailable, double useMem)
if (memAvailable >= memRequired)
return 1;
strips = uint(ceil(memRequired / memAvailable));
return strips;
return static_cast<uint>(ceil(memRequired / memAvailable));
}
/// <summary>

View File

@ -178,7 +178,7 @@ public:
EmberOptionEntry(eOptionUse optUsage, eOptionIDs optId, const CharT* arg, T defaultVal, ESOArgType argType, const string& docString)
{
m_OptionUse = optUsage;
m_Option.nId = int(optId);
m_Option.nId = static_cast<int>(optId);
m_Option.pszArg = arg;
m_Option.nArgType = argType;
m_DocString = docString;
@ -478,11 +478,11 @@ public:
//Process args.
while (args.Next())
{
ESOError errorCode = args.LastError();
const auto errorCode = args.LastError();
if (errorCode == SO_SUCCESS)
{
eOptionIDs e = eOptionIDs(args.OptionId());
const auto e = eOptionIDs(args.OptionId());
switch (e)
{
@ -656,15 +656,15 @@ public:
CSimpleOpt::SOption endOption = SO_END_OF_OPTIONS;
entries.reserve(75);
for (auto entry : m_BoolArgs) if (et(entry->m_OptionUse) & et(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_BoolArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_IntArgs) if (et(entry->m_OptionUse) & et(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_IntArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_UintArgs) if (et(entry->m_OptionUse) & et(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_UintArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_DoubleArgs) if (et(entry->m_OptionUse) & et(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_DoubleArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_StringArgs) if (et(entry->m_OptionUse) & et(optUsage)) entries.push_back(entry->m_Option);
for (auto entry : m_StringArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) entries.push_back(entry->m_Option);
entries.push_back(endOption);
return entries;
@ -679,15 +679,15 @@ public:
{
ostringstream os;
for (auto entry : m_BoolArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_BoolArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_IntArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_IntArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_UintArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_UintArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_DoubleArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_DoubleArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_StringArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_DocString << "\n";
for (auto entry : m_StringArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_DocString << "\n";
return os.str();
}
@ -702,15 +702,15 @@ public:
ostringstream os;
os << std::boolalpha;
for (auto entry : m_BoolArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_BoolArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_IntArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_IntArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_UintArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_UintArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_DoubleArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_DoubleArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_StringArgs) if (et(entry->m_OptionUse) & et(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
for (auto entry : m_StringArgs) if (static_cast<et>(entry->m_OptionUse) & static_cast<et>(optUsage)) os << entry->m_NameWithoutDashes << ": " << (*entry)() << "\n";
return os.str();
}

View File

@ -56,8 +56,8 @@ static bool WriteJpeg(const char* filename, byte* image, size_t width, size_t he
jpeg_stdio_dest(&info, file);
info.in_color_space = JCS_RGB;
info.input_components = 3;
info.image_width = JDIMENSION(width);
info.image_height = JDIMENSION(height);
info.image_width = static_cast<JDIMENSION>(width);
info.image_height = static_cast<JDIMENSION>(height);
jpeg_set_defaults(&info);
#if defined(_WIN32) || defined(__APPLE__)
jpeg_set_quality(&info, quality, static_cast<boolean>(TRUE));
@ -73,14 +73,14 @@ static bool WriteJpeg(const char* filename, byte* image, size_t width, size_t he
if (enableComments)
{
string s;
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(verString.c_str()), uint(verString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(verString.c_str()), static_cast<uint>(verString.size()));
if (nick != "")
{
os.str("");
os << "nickname: " << nick;
s = os.str();
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(s.c_str()), uint(s.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(s.c_str()), static_cast<uint>(s.size()));
}
if (url != "")
@ -88,7 +88,7 @@ static bool WriteJpeg(const char* filename, byte* image, size_t width, size_t he
os.str("");
os << "url: " << url;
s = os.str();
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(s.c_str()), uint(s.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(s.c_str()), static_cast<uint>(s.size()));
}
if (id != "")
@ -96,13 +96,13 @@ static bool WriteJpeg(const char* filename, byte* image, size_t width, size_t he
os.str("");
os << "id: " << id;
s = os.str();
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(s.c_str()), uint(s.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(s.c_str()), static_cast<uint>(s.size()));
}
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(bvString.c_str()), uint(bvString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(niString.c_str()), uint(niString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(rtString.c_str()), uint(rtString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(genomeString.c_str()), uint(genomeString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(bvString.c_str()), static_cast<uint>(bvString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(niString.c_str()), static_cast<uint>(niString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(rtString.c_str()), static_cast<uint>(rtString.size()));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<const byte*>(genomeString.c_str()), static_cast<uint>(genomeString.size()));
}
for (i = 0; i < height; i++)
@ -200,7 +200,7 @@ static bool WritePng(const char* filename, byte* image, size_t width, size_t hei
}
png_init_io(png_ptr, file);
png_set_IHDR(png_ptr, info_ptr, png_uint_32(width), png_uint_32(height), 8 * png_uint_32(bytesPerChannel),
png_set_IHDR(png_ptr, info_ptr, static_cast<png_uint_32>(width), static_cast<png_uint_32>(height), 8 * static_cast<png_uint_32>(bytesPerChannel),
PNG_COLOR_TYPE_RGBA,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE,
@ -241,12 +241,12 @@ static vector<byte> ConvertRGBToBMPBuffer(byte* buffer, size_t width, size_t hei
return vector<byte>();
size_t padding = 0;
size_t scanlinebytes = width * 3;
const auto scanlinebytes = width * 3;
while ((scanlinebytes + padding ) % 4 != 0)
padding++;
size_t psw = scanlinebytes + padding;
const auto psw = scanlinebytes + padding;
newSize = height * psw;
vector<byte> newBuf(newSize);
size_t bufpos = 0;
@ -292,11 +292,11 @@ static bool SaveBmp(const char* filename, const byte* image, size_t width, size_
bmfh.bfType = 0x4d42; // 0x4d42 = 'BM'
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (DWORD)paddedSize;
bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + static_cast<DWORD>(paddedSize);
bmfh.bfOffBits = 0x36;
info.biSize = sizeof(BITMAPINFOHEADER);
info.biWidth = (LONG)width;
info.biHeight = (LONG)height;
info.biWidth = static_cast<LONG>(width);
info.biHeight = static_cast<LONG>(height);
info.biPlanes = 1;
info.biBitCount = 24;
info.biCompression = BI_RGB;
@ -335,7 +335,7 @@ static bool SaveBmp(const char* filename, const byte* image, size_t width, size_
return false;
}
if (WriteFile(file, image, (DWORD)paddedSize, &bwritten, NULL) == false)
if (WriteFile(file, image, static_cast<DWORD>(paddedSize), &bwritten, NULL) == false)
{
CloseHandle(file);
return false;
@ -382,8 +382,8 @@ static bool WriteExr16(const char* filename, Rgba* image, size_t width, size_t h
{
try
{
int iw = int(width);
int ih = int(height);
const auto iw = static_cast<int>(width);
const auto ih = static_cast<int>(height);
std::unique_ptr<RgbaOutputFile> file;
try
@ -442,8 +442,8 @@ static bool WriteExr32(const char* filename, float* r, float* g, float* b, float
{
try
{
int iw = int(width);
int ih = int(height);
const auto iw = static_cast<int>(width);
const auto ih = static_cast<int>(height);
std::unique_ptr<OutputFile> file;
try

View File

@ -306,12 +306,12 @@ bool EmberGenome(int argc, _TCHAR* argv[], EmberOptions& opt)
}
}
bool doMutate = opt.Mutate() != "";
bool doInter = opt.Inter() != "";
bool doRotate = opt.Rotate() != "";
bool doClone = opt.Clone() != "";
bool doCross0 = opt.Cross0() != "";
bool doCross1 = opt.Cross1() != "";
const auto doMutate = opt.Mutate() != "";
const auto doInter = opt.Inter() != "";
const auto doRotate = opt.Rotate() != "";
const auto doClone = opt.Clone() != "";
const auto doCross0 = opt.Cross0() != "";
const auto doCross1 = opt.Cross1() != "";
count += (doMutate ? 1 : 0);
count += (doInter ? 1 : 0);
count += (doRotate ? 1 : 0);
@ -483,14 +483,14 @@ bool EmberGenome(int argc, _TCHAR* argv[], EmberOptions& opt)
frameCount = 0;
os.str("");
os << setfill('0') << setprecision(0) << fixed;
auto padding = opt.Padding() ? streamsize(opt.Padding()) : (streamsize(std::log10(opt.StartCount() + (((opt.LoopFrames() * opt.Loops()) + opt.InterpFrames()) * embers.size()))) + 1);
const auto padding = opt.Padding() ? streamsize(opt.Padding()) : (streamsize(std::log10(opt.StartCount() + (((opt.LoopFrames() * opt.Loops()) + opt.InterpFrames()) * embers.size()))) + 1);
t.Tic();
for (i = 0; i < embers.size(); i++)
{
if (opt.Loops() > 0)
{
size_t roundFrames = size_t(std::round(opt.LoopFrames() * opt.Loops()));
const auto roundFrames = static_cast<size_t>(std::round(opt.LoopFrames() * opt.Loops()));
for (frame = 0; frame < roundFrames; frame++)
{
@ -504,7 +504,7 @@ bool EmberGenome(int argc, _TCHAR* argv[], EmberOptions& opt)
//Rotate the next step and save in result, but do not print.
//result will be the starting point for the interp phase below.
frame = roundFrames;
blend = T(frame) / T(opt.LoopFrames());
blend = static_cast<T>(frame) / static_cast<T>(opt.LoopFrames());
tools.Spin(embers[i], pTemplate, result, opt.StartCount() + frameCount, blend, opt.CwLoops());//Do not increment frameCount here.
FormatName(result, os, padding);
}
@ -517,7 +517,7 @@ bool EmberGenome(int argc, _TCHAR* argv[], EmberOptions& opt)
for (frame = 0; frame < opt.InterpFrames(); frame++)
{
seqFlag = frame == 0 || (frame == opt.InterpFrames() - 1);
blend = frame / T(opt.InterpFrames());
blend = frame / static_cast<T>(opt.InterpFrames());
result.Clear();
tools.SpinInter(&embers[i], pTemplate, result, opt.StartCount() + frameCount++, seqFlag, blend, opt.InterpLoops(), opt.CwInterpLoops());
FormatName(result, os, padding);
@ -548,8 +548,8 @@ bool EmberGenome(int argc, _TCHAR* argv[], EmberOptions& opt)
}
frame = opt.Frame();
blend = frame / T(opt.InterpFrames());//Percentage between first and second flame to treat as the center flame.
spread = 1 / T(opt.InterpFrames());//Amount to move backward and forward from the center flame.
blend = frame / static_cast<T>(opt.InterpFrames());//Percentage between first and second flame to treat as the center flame.
spread = 1 / static_cast<T>(opt.InterpFrames());//Amount to move backward and forward from the center flame.
if (opt.Enclosed())
cout << "<pick version=\"EMBER-" << EmberVersion() << "\">\n";

View File

@ -147,7 +147,7 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
//Final setup steps before running.
os.imbue(std::locale(""));
padding = uint(std::log10(double(embers.size()))) + 1;
padding = uint(std::log10(static_cast<double>(embers.size()))) + 1;
renderer->EarlyClip(opt.EarlyClip());
renderer->YAxisUp(opt.YAxisUp());
renderer->LockAccum(opt.LockAccum());
@ -210,9 +210,9 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
}
//Cast to double in case the value exceeds 2^32.
double imageMem = double(renderer->NumChannels()) * double(ember.m_FinalRasW)
* double(ember.m_FinalRasH) * double(renderer->BytesPerChannel());
double maxMem = pow(2.0, double((sizeof(void*) * 8) - 1));
const auto imageMem = static_cast<double>(renderer->NumChannels()) * static_cast<double>(ember.m_FinalRasW)
* static_cast<double>(ember.m_FinalRasH) * static_cast<double>(renderer->BytesPerChannel());
const auto maxMem = pow(2.0, static_cast<double>((sizeof(void*) * 8) - 1));
if (imageMem > maxMem)//Ensure the max amount of memory for a process is not exceeded.
{
@ -232,7 +232,7 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
else
{
p = renderer->MemoryRequired(1, true, false);//No threaded write for render, only for animate.
strips = CalcStrips(double(p.second), double(renderer->MemoryAvailable()), opt.UseMem());
strips = CalcStrips(static_cast<double>(p.second), static_cast<double>(renderer->MemoryAvailable()), opt.UseMem());
if (strips > 1)
VerbosePrint("Setting strips to " << strips << " with specified memory usage of " << opt.UseMem());
@ -281,7 +281,7 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
iterCount = renderer->TotalIterCount(1);
comments = renderer->ImageComments(stats, opt.PrintEditDepth(), true);
os.str("");
os << comments.m_NumIters << " / " << iterCount << " (" << std::fixed << std::setprecision(2) << ((double(stats.m_Iters) / double(iterCount)) * 100) << "%)";
os << comments.m_NumIters << " / " << iterCount << " (" << std::fixed << std::setprecision(2) << ((static_cast<double>(stats.m_Iters) / static_cast<double>(iterCount)) * 100) << "%)";
VerbosePrint("\nIters ran/requested: " + os.str());
if (!opt.EmberCL())
@ -290,17 +290,17 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
VerbosePrint("Render time: " + t.Format(stats.m_RenderMs));
VerbosePrint("Pure iter time: " + t.Format(stats.m_IterMs));
VerbosePrint("Iters/sec: " << size_t(stats.m_Iters / (stats.m_IterMs / 1000.0)) << "\n");
bool useName = opt.NameEnable() && !finalEmber.m_Name.empty();
auto finalImagep = finalImage.data();
auto size = finalEmber.m_FinalRasW * finalEmber.m_FinalRasH;
bool doBmp = Find(opt.Format(), "bmp");
bool doJpg = Find(opt.Format(), "jpg");
bool doExr16 = Find(opt.Format(), "exr");
bool doExr32 = Find(opt.Format(), "exr32");
bool doPng8 = Find(opt.Format(), "png");
bool doPng16 = Find(opt.Format(), "png16");
bool doOnlyPng8 = doPng8 && !doPng16;
bool doOnlyExr16 = doExr16 && !doExr32;
const auto useName = opt.NameEnable() && !finalEmber.m_Name.empty();
const auto finalImagep = finalImage.data();
const auto size = finalEmber.m_FinalRasW * finalEmber.m_FinalRasH;
const auto doBmp = Find(opt.Format(), "bmp");
const auto doJpg = Find(opt.Format(), "jpg");
const auto doExr16 = Find(opt.Format(), "exr");
const auto doExr32 = Find(opt.Format(), "exr32");
const auto doPng8 = Find(opt.Format(), "png");
const auto doPng16 = Find(opt.Format(), "png16");
const auto doOnlyPng8 = doPng8 && !doPng16;
const auto doOnlyExr16 = doExr16 && !doExr32;
vector<byte> rgb8Image;
vector<std::thread> writeFileThreads;
writeFileThreads.reserve(6);
@ -314,9 +314,9 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "bmp", padding, i, useName);
const auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "bmp", padding, i, useName);
VerbosePrint("Writing " + filename);
auto writeSuccess = WriteBmp(filename.c_str(), rgb8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH);
const auto writeSuccess = WriteBmp(filename.c_str(), rgb8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH);
if (!writeSuccess)
cout << "Error writing " << filename << "\n";
@ -327,9 +327,9 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "jpg", padding, i, useName);
const auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "jpg", padding, i, useName);
VerbosePrint("Writing " + filename);
auto writeSuccess = WriteJpeg(filename.c_str(), rgb8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, int(opt.JpegQuality()), opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WriteJpeg(filename.c_str(), rgb8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, int(opt.JpegQuality()), opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << filename << "\n";
@ -345,11 +345,11 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
{
writeFileThreads.push_back(std::thread([&]()
{
auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "png", padding, i, useName);
const auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "png", padding, i, useName);
VerbosePrint("Writing " + filename);
vector<byte> rgba8Image(size * 4);
Rgba32ToRgba8(finalImagep, rgba8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.Transparency());
auto writeSuccess = WritePng(filename.c_str(), rgba8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, 1, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WritePng(filename.c_str(), rgba8Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, 1, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << filename << "\n";
@ -368,11 +368,11 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
suffix += "_p16";
}
auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), suffix, "png", padding, i, useName);
const auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), suffix, "png", padding, i, useName);
VerbosePrint("Writing " + filename);
vector<glm::uint16> rgba16Image(size * 4);
Rgba32ToRgba16(finalImagep, rgba16Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.Transparency());
auto writeSuccess = WritePng(filename.c_str(), (byte*)rgba16Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, 2, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WritePng(filename.c_str(), (byte*)rgba16Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, 2, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << filename << "\n";
@ -382,19 +382,19 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
if (doExr16)
{
bool doBothExr = doExr32 && (opt.Format().find("exr") != opt.Format().rfind("exr"));
const auto doBothExr = doExr32 && (opt.Format().find("exr") != opt.Format().rfind("exr"));
if (doBothExr || doOnlyExr16)//16-bit EXR.
{
writeFileThreads.push_back(std::thread([&]()
{
auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "exr", padding, i, useName);
const auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), opt.Suffix(), "exr", padding, i, useName);
VerbosePrint("Writing " + filename);
vector<Rgba> rgba32Image(size);
Rgba32ToRgbaExr(finalImagep, rgba32Image.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.Transparency());
auto writeSuccess = WriteExr16(filename.c_str(),
rgba32Image.data(),
finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WriteExr16(filename.c_str(),
rgba32Image.data(),
finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << filename << "\n";
@ -413,19 +413,19 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
suffix += "_exr32";
}
auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), suffix, "exr", padding, i, useName);
const auto filename = MakeSingleFilename(inputPath, opt.Out(), finalEmber.m_Name, opt.Prefix(), suffix, "exr", padding, i, useName);
VerbosePrint("Writing " + filename);
vector<float> r(size);
vector<float> g(size);
vector<float> b(size);
vector<float> a(size);
Rgba32ToRgba32Exr(finalImagep, r.data(), g.data(), b.data(), a.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.Transparency());
auto writeSuccess = WriteExr32(filename.c_str(),
r.data(),
g.data(),
b.data(),
a.data(),
finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
const auto writeSuccess = WriteExr32(filename.c_str(),
r.data(),
g.data(),
b.data(),
a.data(),
finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, opt.EnableComments(), comments, opt.Id(), opt.Url(), opt.Nick());
if (!writeSuccess)
cout << "Error writing " << filename << "\n";
@ -438,7 +438,7 @@ bool EmberRender(int argc, _TCHAR* argv[], EmberOptions& opt)
if (opt.EmberCL() && opt.DumpKernel())
{
if (auto rendererCL = dynamic_cast<RendererCL<T, float>*>(renderer.get()))
if (const auto rendererCL = dynamic_cast<RendererCL<T, float>*>(renderer.get()))
{
cout << "Iteration kernel:\n" <<
rendererCL->IterKernel() << "\n\n" <<

View File

@ -61,7 +61,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Fractorium 21.21.4.1&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;A Qt-based fractal flame editor which uses a C++ re-write of the flam3 algorithm named Ember and a GPU capable version named EmberCL which implements a portion of the cuburn algorithm in OpenCL.&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;http://fractorium.com&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;fractorium.com&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;Fractorium 22.21.4.2&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;A Qt-based fractal flame editor which uses a C++ re-write of the flam3 algorithm named Ember and a GPU capable version named EmberCL which implements a portion of the cuburn algorithm in OpenCL.&lt;/span&gt;&lt;/p&gt;&lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;http://fractorium.com&quot;&gt;&lt;span style=&quot; font-size:10pt; text-decoration: underline; color:#0000ff;&quot;&gt;fractorium.com&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>

View File

@ -120,7 +120,7 @@ protected:
/// <param name="painter">Unused and just passed to QGraphicsEllipseItem::paint()</param>
/// <param name="option">Drawing options used which will have the QStyle::State_Selected flag unset</param>
/// <param name="widget">Unused and just passed to QGraphicsEllipseItem::paint()</param>
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override
{
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
@ -134,13 +134,13 @@ protected:
/// <param name="change">Action is only taken if this value equals ItemPositionChange</param>
/// <param name="value">The new position. This will be clamped to the scene rect.</param>
/// <returns>The new position</returns>
virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value) override
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override
{
if ((change == ItemPositionChange) && scene())
{
//Value is the new position.
QPointF newPos = value.toPointF();
QRectF rect = scene()->sceneRect();
auto newPos = value.toPointF();
const auto rect = scene()->sceneRect();
if (!rect.contains(newPos))
{

View File

@ -12,6 +12,7 @@ QTimer DoubleSpinBox::s_Timer;
/// <param name="p">The parent widget. Default: nullptr.</param>
/// <param name="height">The height of the spin box. Default: 16.</param>
/// <param name="step">The step used to increment/decrement the spin box when using the mouse wheel. Default: 0.05.</param>
/// <param name="clearSel">True to clear the selection inside the spin box when changing values, else leave the text selected. Default: true.</param>
DoubleSpinBox::DoubleSpinBox(QWidget* p, int h, double step, bool clearSel)
: QDoubleSpinBox(p)
{

View File

@ -22,10 +22,10 @@ public:
/// <param name="parent">The parent widget. Default: nullptr.</param>
explicit DoubleSpinBoxTableItemDelegate(DoubleSpinBox* spinBox, QObject* parent = nullptr)
: QItemDelegate(parent),
m_SpinBox(spinBox)
m_SpinBox(spinBox)
{
}
/// <summary>
/// Re-parent and return the DoubleSpinBox to display when the user clicks on a cell and it enters edit mode.
/// The re-parenting is done so that the DoubleSpinBox appears directly on top of the cell.
@ -34,10 +34,9 @@ public:
/// <param name="option">Ignored</param>
/// <param name="index">Ignored</param>
/// <returns>The DoubleSpinBox member</returns>
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
m_SpinBox->setParent(parent);
return m_SpinBox;
}
@ -46,7 +45,7 @@ public:
/// </summary>
/// <param name="editor">Ignored</param>
/// <param name="index">Ignored</param>
virtual void destroyEditor(QWidget* editor, const QModelIndex& index) const override
void destroyEditor(QWidget* editor, const QModelIndex& index) const override
{
}
@ -55,11 +54,10 @@ public:
/// </summary>
/// <param name="editor">Ignored</param>
/// <param name="index">Ignored</param>
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override
void setEditorData(QWidget* editor, const QModelIndex& index) const override
{
QPoint p(index.row(), index.column());
auto value = index.model()->data(index, Qt::EditRole).toDouble();
const QPoint p(index.row(), index.column());
const auto value = index.model()->data(index, Qt::EditRole).toDouble();
m_SpinBox->setProperty("tableindex", p);
m_SpinBox->setValue(value);
}
@ -70,7 +68,7 @@ public:
/// <param name="editor">Ignored</param>
/// <param name="model">The model whose value will be set</param>
/// <param name="index">The cell index of the model</param>
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override
{
model->setData(index, m_SpinBox->value(), Qt::EditRole);
}
@ -81,7 +79,7 @@ public:
/// <param name="editor">The DoubleSpinBox member</param>
/// <param name="option">Contains the rectangle to be used for the geometry of the DoubleSpinBox</param>
/// <param name="index">Ignored</param>
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override
void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
editor->setGeometry(option.rect);
}

View File

@ -178,7 +178,7 @@ public:
size_t num = 0;
QString endSection;
QString ret = str;
int lastUnderscore = str.lastIndexOf('_');
const auto lastUnderscore = str.lastIndexOf('_');
if (lastUnderscore != -1)
{
@ -205,9 +205,9 @@ public:
QString newPath;
QFileInfo original(filename);
QString path = original.absolutePath() + '/';
QString base = original.completeBaseName();
QString extension = original.suffix();
const QString path = original.absolutePath() + '/';
const QString extension = original.suffix();
do
{

View File

@ -47,7 +47,7 @@ public:
/// <param name="height">The height of the image in pixels</param>
void SetImage(vector<byte>& v, uint width, uint height)
{
int size = 64;
const auto size = 64;
m_Image = QImage(width, height, QImage::Format_RGBA8888);
memcpy(m_Image.scanLine(0), v.data(), SizeOf(v));//Memcpy the data in.
m_Pixmap = QPixmap::fromImage(m_Image).scaled(QSize(size, size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);//Create a QPixmap out of the QImage, scaled to size.

View File

@ -18,8 +18,9 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(QWidget* p, Qt::WindowF
: QDialog(p, f)
{
ui.setupUi(this);
int row = 0, spinHeight = 20;
double dmax = numeric_limits<double>::max();
int row = 0;
const auto spinHeight = 20;
const auto dmax = numeric_limits<double>::max();
QTableWidget* table = ui.FinalRenderParamsTable;
m_Info = OpenCLInfo::Instance();
m_Fractorium = qobject_cast<Fractorium*>(p);
@ -169,12 +170,12 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(QWidget* p, Qt::WindowF
m_SupersampleSpin->setValue(m_Settings->FinalSupersample());
m_StripsSpin->setValue(int(m_Settings->FinalStrips()));
Scale(eScaleType(m_Settings->FinalScale()));
auto bumpmenu = new QMenu(this);
auto add10 = new QAction("Add 10% Quality", this); add10->setProperty("tag", QVariant(0.10));
auto add25 = new QAction("Add 25% Quality", this); add25->setProperty("tag", QVariant(0.25));
auto add50 = new QAction("Add 50% Quality", this); add50->setProperty("tag", QVariant(0.50));
auto add100 = new QAction("Add 100% Quality", this); add100->setProperty("tag", QVariant(1.0));
auto add200 = new QAction("Add 200% Quality", this); add200->setProperty("tag", QVariant(2.0));
const auto bumpmenu = new QMenu(this);
const auto add10 = new QAction("Add 10% Quality", this); add10->setProperty("tag", QVariant(0.10));
const auto add25 = new QAction("Add 25% Quality", this); add25->setProperty("tag", QVariant(0.25));
const auto add50 = new QAction("Add 50% Quality", this); add50->setProperty("tag", QVariant(0.50));
const auto add100 = new QAction("Add 100% Quality", this); add100->setProperty("tag", QVariant(1.0));
const auto add200 = new QAction("Add 200% Quality", this); add200->setProperty("tag", QVariant(2.0));
bumpmenu->addAction(add10);
bumpmenu->addAction(add25);
bumpmenu->addAction(add50);
@ -184,15 +185,15 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(QWidget* p, Qt::WindowF
ui.FinalRenderBumpQualityStartButton->setProperty("tag", add25->property("tag"));
ui.FinalRenderBumpQualityStartButton->setText(add25->text());
ui.FinalRenderBumpQualityStartButton->setEnabled(false);
auto saamenu = new QMenu(this);
const auto saamenu = new QMenu(this);
#ifdef _WIN32
auto saabmp = new QAction("bmp", this);
const auto saabmp = new QAction("bmp", this);
saamenu->addAction(saabmp);
connect(saabmp, SIGNAL(triggered()), this, SLOT(OnSaveAgainAsClicked()));
#endif
auto saajpg = new QAction("jpg", this);
auto saapng = new QAction("png", this);
auto saaexr = new QAction("exr", this);
const auto saajpg = new QAction("jpg", this);
const auto saapng = new QAction("png", this);
const auto saaexr = new QAction("exr", this);
saamenu->addAction(saajpg);
saamenu->addAction(saapng);
saamenu->addAction(saaexr);
@ -237,11 +238,11 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(QWidget* p, Qt::WindowF
OnDoAllCheckBoxStateChanged(ui.FinalRenderDoAllCheckBox->isChecked());
OnDoSequenceCheckBoxStateChanged(ui.FinalRenderDoSequenceCheckBox->isChecked());
QSize s = size();
int desktopHeight = qApp->desktop()->availableGeometry().height();
const auto desktopHeight = qApp->desktop()->availableGeometry().height();
s.setHeight(std::min(s.height(), int(double(desktopHeight * 0.90))));
setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, s, qApp->desktop()->availableGeometry()));
//Update these with new controls.
QWidget* w = SetTabOrder(this, ui.FinalRenderEarlyClipCheckBox, ui.FinalRenderYAxisUpCheckBox);
auto w = SetTabOrder(this, ui.FinalRenderEarlyClipCheckBox, ui.FinalRenderYAxisUpCheckBox);
w = SetTabOrder(this, w, ui.FinalRenderTransparencyCheckBox);
w = SetTabOrder(this, w, ui.FinalRenderOpenCLCheckBox);
w = SetTabOrder(this, w, ui.FinalRenderPng16BitCheckBox);
@ -459,7 +460,7 @@ void FractoriumFinalRenderDialog::OnTransparencyCheckBoxStateChanged(int state)
/// <param name="state">Use OpenCL if state == Qt::Checked, else don't.</param>
void FractoriumFinalRenderDialog::OnOpenCLCheckBoxStateChanged(int state)
{
bool checked = state == Qt::Checked;
const auto checked = state == Qt::Checked;
ui.FinalRenderDeviceTable->setEnabled(checked);
ui.FinalRenderOpenCLSubBatchPctSpin->setEnabled(checked);
ui.FinalRenderThreadCountSpin->setEnabled(!checked);
@ -502,7 +503,7 @@ void FractoriumFinalRenderDialog::OnDoAllCheckBoxStateChanged(int state)
/// <param name="state">The state of the checkbox</param>
void FractoriumFinalRenderDialog::OnDoSequenceCheckBoxStateChanged(int state)
{
bool checked = ui.FinalRenderDoSequenceCheckBox->isChecked();
const auto checked = ui.FinalRenderDoSequenceCheckBox->isChecked();
m_TemporalSamplesSpin->setEnabled(checked);
if (checked)
@ -654,7 +655,7 @@ void FractoriumFinalRenderDialog::OnScaleRadioButtonChanged(bool checked)//This
/// <param name="col">The column of the cell</param>
void FractoriumFinalRenderDialog::OnDeviceTableCellChanged(int row, int col)
{
if (auto item = ui.FinalRenderDeviceTable->item(row, col))
if (const auto item = ui.FinalRenderDeviceTable->item(row, col))
{
HandleDeviceTableCheckChanged(ui.FinalRenderDeviceTable, row, col);
SetMemory();
@ -670,8 +671,8 @@ void FractoriumFinalRenderDialog::OnDeviceTableCellChanged(int row, int col)
void FractoriumFinalRenderDialog::OnDeviceTableRadioToggled(bool checked)
{
int row;
auto s = sender();
auto table = ui.FinalRenderDeviceTable;
const auto s = sender();
const auto table = ui.FinalRenderDeviceTable;
QRadioButton* radio = nullptr;
if (s)
@ -732,7 +733,7 @@ void FractoriumFinalRenderDialog::OnStripsChanged(int d)
/// <param name="checked">Ignored</param>
void FractoriumFinalRenderDialog::OnFileButtonClicked(bool checked)
{
QString s = m_Fractorium->SetupSaveFolderDialog();
const auto s = m_Fractorium->SetupSaveFolderDialog();
if (Exists(s))
{
@ -748,7 +749,7 @@ void FractoriumFinalRenderDialog::OnFileButtonClicked(bool checked)
/// <param name="checked">Ignored</param>
void FractoriumFinalRenderDialog::OnShowFolderButtonClicked(bool checked)
{
QString s = m_Settings->SaveFolder();
const auto s = m_Settings->SaveFolder();
if (Exists(s))
QDesktopServices::openUrl(QUrl::fromLocalFile(s));
@ -791,8 +792,8 @@ void FractoriumFinalRenderDialog::OnSuffixChanged(const QString& s)
/// </summary>
void FractoriumFinalRenderDialog::OnQualityBumpClicked()
{
auto act = qobject_cast<QAction*>(sender());
auto tbtn = qobject_cast<QToolButton*>(sender());
const auto act = qobject_cast<QAction*>(sender());
const auto tbtn = qobject_cast<QToolButton*>(sender());
if (tbtn)
{
@ -818,18 +819,18 @@ void FractoriumFinalRenderDialog::OnQualityBumpClicked()
/// </summary>
void FractoriumFinalRenderDialog::OnSaveAgainAsClicked()
{
auto act = qobject_cast<QAction*>(sender());
auto tbtn = qobject_cast<QToolButton*>(sender());
const auto act = qobject_cast<QAction*>(sender());
const auto tbtn = qobject_cast<QToolButton*>(sender());
if (tbtn)
{
if (m_Controller.get())
{
auto s = tbtn->property("tag").toString();
const auto s = tbtn->property("tag").toString();
m_Tbcw->m_Combo->blockSignals(true);
m_Tbcw->m_Combo->setCurrentText(s);
m_Tbcw->m_Combo->blockSignals(false);
auto filename = m_Controller->SaveCurrentAgain();
const auto filename = m_Controller->SaveCurrentAgain();
ui.FinalRenderTextOutput->append("\nSaved again as " + filename);
}
}
@ -913,7 +914,7 @@ void FractoriumFinalRenderDialog::showEvent(QShowEvent* e)
if (CreateControllerFromGUI(true))//Create controller if it does not exist, or if it does and the renderer is not running.
{
int index = int(m_Fractorium->m_Controller->Index()) + 1;
const auto index = static_cast<int>(m_Fractorium->m_Controller->Index()) + 1;
#ifdef DO_DOUBLE
Ember<double> ed;
EmberFile<double> efi;
@ -938,7 +939,7 @@ void FractoriumFinalRenderDialog::showEvent(QShowEvent* e)
firstfile = efi.m_Filename;
#endif
m_Controller->SetEmberFile(efi, true);//Move the temp file into the final render controller.
ui.FinalRenderCurrentSpin->setMaximum(int(efi.Size()));
ui.FinalRenderCurrentSpin->setMaximum(static_cast<int>(efi.Size()));
ui.FinalRenderCurrentSpin->blockSignals(true);
ui.FinalRenderCurrentSpin->setValue(index);//Set the currently selected ember to the one that was being edited.
ui.FinalRenderCurrentSpin->blockSignals(false);
@ -986,7 +987,7 @@ void FractoriumFinalRenderDialog::reject()
/// <returns>True if successful, else false.</returns>
bool FractoriumFinalRenderDialog::CreateControllerFromGUI(bool createRenderer)
{
int index = Current() - 1;
const auto index = Current() - 1;
#ifdef DO_DOUBLE
size_t elementSize = Double() ? sizeof(double) : sizeof(float);
#else
@ -1054,8 +1055,7 @@ bool FractoriumFinalRenderDialog::SetMemory()
{
if (isVisible() && CreateControllerFromGUI(true))
{
QString s;
auto p = m_Controller->SyncAndComputeMemory();
const auto p = m_Controller->SyncAndComputeMemory();
ui.FinalRenderParamsTable->item(m_MemoryCellIndex, 1)->setText(ToString<qulonglong>(get<1>(p)));
ui.FinalRenderParamsTable->item(m_ItersCellIndex, 1)->setText(ToString<qulonglong>(get<2>(p)));

View File

@ -76,8 +76,8 @@ void FinalRenderEmberController<T>::CancelRender()
/// <returns>True if a valid renderer is created or if no action is taken, else false.</returns>
bool FinalRenderEmberControllerBase::CreateRendererFromGUI()
{
bool useOpenCL = m_Info->Ok() && m_FinalRenderDialog->OpenCL();
auto v = Devices(m_FinalRenderDialog->Devices());
const auto useOpenCL = m_Info->Ok() && m_FinalRenderDialog->OpenCL();
const auto v = Devices(m_FinalRenderDialog->Devices());
return CreateRenderer((useOpenCL && !v.empty()) ? eRendererType::OPENCL_RENDERER : eRendererType::CPU_RENDERER,
v, false, false); //Not shared.
}
@ -110,11 +110,11 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
m_TotalTimer.Tic();//Begin timing for progress of all operations.
m_GuiState = m_FinalRenderDialog->State();//Cache render settings from the GUI before running.
size_t i = 0;
bool doAll = m_GuiState.m_DoAll && m_EmberFile.Size() > 1;
bool isBump = !doAll && m_IsQualityBump && m_GuiState.m_Strips == 1;//Should never get called with m_IsQualityBump otherwise, but check one last time to be safe.
const auto doAll = m_GuiState.m_DoAll && m_EmberFile.Size() > 1;
const auto isBump = !doAll && m_IsQualityBump && m_GuiState.m_Strips == 1;//Should never get called with m_IsQualityBump otherwise, but check one last time to be safe.
size_t currentStripForProgress = 0;//Sort of a hack to get the strip value to the progress function.
QString path = doAll ? ComposePath(QString::fromStdString(m_EmberFile.m_Embers.begin()->m_Name)) : ComposePath(Name());
QString backup = path + "_backup.flame";
const auto path = doAll ? ComposePath(QString::fromStdString(m_EmberFile.m_Embers.begin()->m_Name)) : ComposePath(Name());
const auto backup = path + "_backup.flame";
m_FinishedImageCount.store(0);
Pause(false);
ResetProgress();
@ -147,7 +147,7 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
vector<Ember<T>> embers;
vector<std::thread> threadVec;
std::atomic<size_t> atomfTime;
auto firstEmber = m_EmberFile.m_Embers.begin();
const auto firstEmber = m_EmberFile.m_Embers.begin();
//Need to loop through and set all w, h, q, ts, ss and t vals.
for (auto& it : m_EmberFile.m_Embers)
@ -186,7 +186,7 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
EmberStats stats;
EmberImageComments comments;
Timing renderTimer;
auto renderer = m_Renderers[index].get();
const auto renderer = m_Renderers[index].get();
renderer->SetExternalEmbersPointer(&embers);//All will share a pointer to the original vector to conserve memory with large files. Ok because the vec doesn't get modified.
//Render each image, cancelling if m_Run ever gets set to false.
@ -324,7 +324,7 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
Output("No renderer present, aborting.");
}
QString totalTimeString = "All renders completed in: " + QString::fromStdString(m_TotalTimer.Format(m_TotalTimer.Toc())) + ".";
const QString totalTimeString = "All renders completed in: " + QString::fromStdString(m_TotalTimer.Format(m_TotalTimer.Toc())) + ".";
Output(totalTimeString);
QFile::remove(backup);
QMetaObject::invokeMethod(m_FinalRenderDialog, "Pause", Qt::QueuedConnection, Q_ARG(bool, false));
@ -386,6 +386,21 @@ void FinalRenderEmberController<T>::SetEmber(size_t index, bool verbatim)
}
}
/// <summary>
/// Save current ember as Xml using the filename specified.
/// </summary>
/// <param name="filename">The filename to save the ember to.</param>
template <typename T>
void FinalRenderEmberController<T>::SaveCurrentAsXml(QString filename)
{
const auto ember = m_Ember;
EmberToXml<T> writer;
const QFileInfo fileInfo(filename);
if (!writer.Save(filename.toStdString().c_str(), *ember, 0, true, true, false, true, true))
m_Fractorium->ShowCritical("Save Failed", "Could not save file, try saving to a different folder.");
}
/// <summary>
/// Start the final rendering process.
/// Create the needed renderer from the GUI if it has not been created yet.
@ -394,7 +409,7 @@ void FinalRenderEmberController<T>::SetEmber(size_t index, bool verbatim)
template<typename T>
bool FinalRenderEmberController<T>::Render()
{
QString filename = m_FinalRenderDialog->Path();
const auto filename = m_FinalRenderDialog->Path();
if (filename == "")
{
@ -442,7 +457,7 @@ bool FinalRenderEmberController<T>::BumpQualityRender(double d)
}
m_IsQualityBump = true;
auto iterCount = m_Renderer->TotalIterCount(1);
const auto iterCount = m_Renderer->TotalIterCount(1);
m_FinalRenderDialog->ui.FinalRenderParamsTable->item(m_FinalRenderDialog->m_ItersCellIndex, 1)->setText(ToString<qulonglong>(iterCount));
m_FinalRenderDialog->ui.FinalRenderTextOutput->setText("Preparing all parameters.\n");
m_Result = QtConcurrent::run(m_FinalRenderFunc);
@ -462,8 +477,8 @@ template <typename T>
bool FinalRenderEmberController<T>::CreateRenderer(eRendererType renderType, const vector<pair<size_t, size_t>>& devices, bool updatePreviews, bool shared)
{
bool ok = true;
bool renderTypeMismatch = (m_Renderer.get() && (m_Renderer->RendererType() != renderType)) ||
(!m_Renderers.empty() && (m_Renderers[0]->RendererType() != renderType));
const auto renderTypeMismatch = (m_Renderer.get() && (m_Renderer->RendererType() != renderType)) ||
(!m_Renderers.empty() && (m_Renderers[0]->RendererType() != renderType));
CancelRender();
if ((!m_FinalRenderDialog->DoSequence() && (!m_Renderer.get() || !m_Renderer->Ok())) ||
@ -482,7 +497,7 @@ bool FinalRenderEmberController<T>::CreateRenderer(eRendererType renderType, con
m_Renderers = ::CreateRenderers<T>(renderType, m_Devices, shared, m_OutputTexID, emberReport);
for (auto& renderer : m_Renderers)
if (auto rendererCL = dynamic_cast<RendererCLBase*>(renderer.get()))
if (const auto rendererCL = dynamic_cast<RendererCLBase*>(renderer.get()))
rendererCL->OptAffine(true);//Optimize empty affines for final renderers, this is normally false for the interactive renderer.
}
else
@ -490,7 +505,7 @@ bool FinalRenderEmberController<T>::CreateRenderer(eRendererType renderType, con
m_Renderers.clear();
m_Renderer = unique_ptr<EmberNs::RendererBase>(::CreateRenderer<T>(renderType, m_Devices, shared, m_OutputTexID, emberReport));
if (auto rendererCL = dynamic_cast<RendererCLBase*>(m_Renderer.get()))
if (const auto rendererCL = dynamic_cast<RendererCLBase*>(m_Renderer.get()))
rendererCL->OptAffine(true);//Optimize empty affines for final renderers, this is normally false for the interactive renderer.
}
@ -522,10 +537,10 @@ template <typename T>
int FinalRenderEmberController<T>::ProgressFunc(Ember<T>& ember, void* foo, double fraction, int stage, double etaMs)
{
static int count = 0;
size_t strip = *(reinterpret_cast<size_t*>(FirstOrDefaultRenderer()->m_ProgressParameter));
double fracPerStrip = std::ceil(100.0 / m_GuiState.m_Strips);
double stripsfrac = std::ceil(fracPerStrip * strip) + std::ceil(fraction / m_GuiState.m_Strips);
int intFract = int(stripsfrac);
const size_t strip = *(reinterpret_cast<size_t*>(FirstOrDefaultRenderer()->m_ProgressParameter));
const double fracPerStrip = std::ceil(100.0 / m_GuiState.m_Strips);
const double stripsfrac = std::ceil(fracPerStrip * strip) + std::ceil(fraction / m_GuiState.m_Strips);
const int intFract = static_cast<int>(stripsfrac);
if (stage == 0)
QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderIterationProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, intFract));
@ -595,7 +610,7 @@ bool FinalRenderEmberController<T>::SyncGuiToRenderer()
m_Renderer->ThreadCount(m_FinalRenderDialog->ThreadCount());
m_Renderer->Priority((eThreadPriority)m_FinalRenderDialog->ThreadPriority());
if (auto rendererCL = dynamic_cast<RendererCL<T, float>*>(m_Renderer.get()))
if (const auto rendererCL = dynamic_cast<RendererCL<T, float>*>(m_Renderer.get()))
rendererCL->SubBatchPercentPerThread(m_FinalRenderDialog->OpenCLSubBatchPct());
}
else if (!m_Renderers.empty())
@ -608,7 +623,7 @@ bool FinalRenderEmberController<T>::SyncGuiToRenderer()
m_Renderers[i]->ThreadCount(m_FinalRenderDialog->ThreadCount());
m_Renderers[i]->Priority((eThreadPriority)m_FinalRenderDialog->ThreadPriority());
if (auto rendererCL = dynamic_cast<RendererCL<T, float>*>(m_Renderers[i].get()))
if (const auto rendererCL = dynamic_cast<RendererCL<T, float>*>(m_Renderers[i].get()))
rendererCL->SubBatchPercentPerThread(m_FinalRenderDialog->OpenCLSubBatchPct());
}
}
@ -635,10 +650,10 @@ void FinalRenderEmberController<T>::SyncCurrentToSizeSpinners(bool scale, bool s
if (scale)
{
if (doWidth)
m_FinalRenderDialog->m_WidthScaleSpin->SetValueStealth(double(m_Ember->m_FinalRasW) / m_Ember->m_OrigFinalRasW);//Work backward to determine the scale.
m_FinalRenderDialog->m_WidthScaleSpin->SetValueStealth(static_cast<double>(m_Ember->m_FinalRasW) / m_Ember->m_OrigFinalRasW);//Work backward to determine the scale.
if (doHeight)
m_FinalRenderDialog->m_HeightScaleSpin->SetValueStealth(double(m_Ember->m_FinalRasH) / m_Ember->m_OrigFinalRasH);
m_FinalRenderDialog->m_HeightScaleSpin->SetValueStealth(static_cast<double>(m_Ember->m_FinalRasH) / m_Ember->m_OrigFinalRasH);
}
if (size)
@ -681,7 +696,7 @@ tuple<size_t, size_t, size_t> FinalRenderEmberController<T>::SyncAndComputeMemor
size_t iterCount = 0;
pair<size_t, size_t> p(0, 0);
size_t strips;
uint channels = m_FinalRenderDialog->Ext() == "png" ? 4 : 3;//4 channels for Png, else 3.
const uint channels = m_FinalRenderDialog->Ext() == "png" ? 4 : 3;//4 channels for Png, else 3.
SyncGuiToEmbers();
if (m_Renderer.get())
@ -720,8 +735,8 @@ tuple<size_t, size_t, size_t> FinalRenderEmberController<T>::SyncAndComputeMemor
template <typename T>
QString FinalRenderEmberController<T>::ComposePath(const QString& name)
{
QString path = MakeEnd(m_Settings->SaveFolder(), '/');//Base path.
QString full = path + m_FinalRenderDialog->Prefix() + name + m_FinalRenderDialog->Suffix() + "." + m_FinalRenderDialog->Ext();
const auto path = MakeEnd(m_Settings->SaveFolder(), '/');//Base path.
const auto full = path + m_FinalRenderDialog->Prefix() + name + m_FinalRenderDialog->Suffix() + "." + m_FinalRenderDialog->Ext();
return EmberFile<T>::UniqueFilename(full);
}
@ -763,24 +778,24 @@ QString FinalRenderEmberController<T>::SaveCurrentAgain()
if (m_GuiState.m_Strips == 1)
{
size_t currentStripForProgress = 0;
auto brightness = m_Ember->m_Brightness;
auto gamma = m_Ember->m_Gamma;
auto gammathresh = m_Ember->m_GammaThresh;
auto vibrancy = m_Ember->m_Vibrancy;
auto highlight = m_Ember->m_HighlightPower;
auto k2 = m_Ember->m_K2;
auto sftype = m_Ember->m_SpatialFilterType;
auto sfradius = m_Ember->m_SpatialFilterRadius;
auto minde = m_Ember->m_MinRadDE;
auto maxde = m_Ember->m_MaxRadDE;
auto curvede = m_Ember->m_CurveDE;
const auto brightness = m_Ember->m_Brightness;
const auto gamma = m_Ember->m_Gamma;
const auto gammathresh = m_Ember->m_GammaThresh;
const auto vibrancy = m_Ember->m_Vibrancy;
const auto highlight = m_Ember->m_HighlightPower;
const auto k2 = m_Ember->m_K2;
const auto sftype = m_Ember->m_SpatialFilterType;
const auto sfradius = m_Ember->m_SpatialFilterRadius;
const auto minde = m_Ember->m_MinRadDE;
const auto maxde = m_Ember->m_MaxRadDE;
const auto curvede = m_Ember->m_CurveDE;
m_Fractorium->m_Controller->ParamsToEmber(*m_Ember, true);//Update color and filter params from the main window controls, which only affect the filter and/or final accumulation stage.
auto dofilterandaccum = m_GuiState.m_EarlyClip ||
brightness != m_Ember->m_Brightness ||
k2 != m_Ember->m_K2 ||
minde != m_Ember->m_MinRadDE ||
maxde != m_Ember->m_MaxRadDE ||
curvede != m_Ember->m_CurveDE;
const auto dofilterandaccum = m_GuiState.m_EarlyClip ||
brightness != m_Ember->m_Brightness ||
k2 != m_Ember->m_K2 ||
minde != m_Ember->m_MinRadDE ||
maxde != m_Ember->m_MaxRadDE ||
curvede != m_Ember->m_CurveDE;
//This is sort of a hack outside of the normal rendering process above.
if (dofilterandaccum ||
@ -833,7 +848,7 @@ QString FinalRenderEmberController<T>::SaveCurrentRender(Ember<T>& ember)
template<typename T>
QString FinalRenderEmberController<T>::SaveCurrentRender(Ember<T>& ember, const EmberImageComments& comments, vector<v4F>& pixels, size_t width, size_t height, bool png16Bit, bool transparency)
{
QString filename = ComposePath(QString::fromStdString(ember.m_Name));
const auto filename = ComposePath(QString::fromStdString(ember.m_Name));
FractoriumEmberControllerBase::SaveCurrentRender(filename, comments, pixels, width, height, png16Bit, transparency);
return filename;
}
@ -847,7 +862,7 @@ QString FinalRenderEmberController<T>::SaveCurrentRender(Ember<T>& ember, const
template<typename T>
void FinalRenderEmberController<T>::RenderComplete(Ember<T>& ember)
{
if (auto renderer = dynamic_cast<EmberNs::Renderer<T, float>*>(m_Renderer.get()))
if (const auto renderer = dynamic_cast<EmberNs::Renderer<T, float>*>(m_Renderer.get()))
RenderComplete(ember, m_Stats, m_RenderTimer);
}
@ -898,15 +913,15 @@ bool FinalRenderEmberController<T>::Paused()
template<typename T>
void FinalRenderEmberController<T>::HandleFinishedProgress()
{
auto finishedCountCached = m_FinishedImageCount.load();//Make sure to use the same value throughout this function even if the atomic is changing.
bool doAll = m_GuiState.m_DoAll && m_EmberFile.Size() > 1;
const auto finishedCountCached = m_FinishedImageCount.load();//Make sure to use the same value throughout this function even if the atomic is changing.
const bool doAll = m_GuiState.m_DoAll && m_EmberFile.Size() > 1;
if (m_FinishedImageCount.load() != m_ImageCount)
ResetProgress(false);
else
SetProgressComplete(100);//Just to be safe.
QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderTotalProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, int((float(finishedCountCached) / float(m_ImageCount)) * 100)));
QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderTotalProgress, "setValue", Qt::QueuedConnection, Q_ARG(int, static_cast<int>((float(finishedCountCached) / static_cast<float>(m_ImageCount)) * 100)));
QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderImageCountLabel, "setText", Qt::QueuedConnection, Q_ARG(const QString&, ToString<qulonglong>(finishedCountCached) + " / " + ToString<qulonglong>(m_ImageCount)));
QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderSaveAgainAsButton, "setEnabled", Qt::QueuedConnection, Q_ARG(bool, !doAll && m_Renderer.get()));//Can do save again with variable number of strips.
QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderBumpQualityStartButton, "setEnabled", Qt::QueuedConnection, Q_ARG(bool, !doAll && m_Renderer.get() && m_GuiState.m_Strips == 1));
@ -922,16 +937,17 @@ template<typename T>
void FinalRenderEmberController<T>::RenderComplete(Ember<T>& ember, const EmberStats& stats, Timing& renderTimer)
{
rlg l(m_ProgressCs);
string renderTimeString = renderTimer.Format(renderTimer.Toc());
QString status, filename = ComposePath(QString::fromStdString(ember.m_Name));
QString itersString = ToString<qulonglong>(stats.m_Iters);
QString itersPerSecString = ToString<qulonglong>(size_t(stats.m_Iters / (stats.m_IterMs / 1000.0)));
const auto renderTimeString = renderTimer.Format(renderTimer.Toc());
QString status;
const auto filename = ComposePath(QString::fromStdString(ember.m_Name));
const auto itersString = ToString<qulonglong>(stats.m_Iters);
const auto itersPerSecString = ToString<qulonglong>(static_cast<size_t>(stats.m_Iters / (stats.m_IterMs / 1000.0)));
if (m_GuiState.m_SaveXml)
{
QFileInfo xmlFileInfo(filename);//Create another one in case it was modified for batch rendering.
QString newPath = xmlFileInfo.absolutePath() + '/' + xmlFileInfo.completeBaseName() + ".flame";
xmlDocPtr tempEdit = ember.m_Edits;
const QFileInfo xmlFileInfo(filename);//Create another one in case it was modified for batch rendering.
const QString newPath = xmlFileInfo.absolutePath() + '/' + xmlFileInfo.completeBaseName() + ".flame";
const xmlDocPtr tempEdit = ember.m_Edits;
ember.m_Edits = m_XmlWriter.CreateNewEditdoc(&ember, nullptr, "edit", m_Settings->Nick().toStdString(), m_Settings->Url().toStdString(), m_Settings->Id().toStdString(), "", 0, 0);
m_XmlWriter.Save(newPath.toStdString().c_str(), ember, 0, true, false, true);//Note that the ember passed is used, rather than m_Ember because it's what was actually rendered.
@ -993,8 +1009,8 @@ void FinalRenderEmberController<T>::SyncGuiToEmber(Ember<T>& ember, size_t width
}
else
{
double wScale = m_FinalRenderDialog->m_WidthScaleSpin->value();
double hScale = m_FinalRenderDialog->m_HeightScaleSpin->value();
const auto wScale = m_FinalRenderDialog->m_WidthScaleSpin->value();
const auto hScale = m_FinalRenderDialog->m_HeightScaleSpin->value();
w = ember.m_OrigFinalRasW * wScale;
h = ember.m_OrigFinalRasH * hScale;
}
@ -1031,8 +1047,8 @@ QString FinalRenderEmberController<T>::CheckMemory(const tuple<size_t, size_t, s
{
bool error = false;
QString s;
size_t histSize = get<0>(p);
size_t totalSize = get<1>(p);
const auto histSize = get<0>(p);
const auto totalSize = get<1>(p);
auto selectedDevices = m_FinalRenderDialog->Devices();
static vector<RendererCL<T, float>*> clRenderers;
clRenderers.clear();
@ -1053,19 +1069,19 @@ QString FinalRenderEmberController<T>::CheckMemory(const tuple<size_t, size_t, s
//Iterate through each renderer and examine each device it's using.
for (auto r : clRenderers)
{
auto& devices = r->Devices();
const auto& devices = r->Devices();
for (auto& d : devices)
{
auto& wrapper = d->m_Wrapper;
auto index = wrapper.TotalDeviceIndex();
const auto& wrapper = d->m_Wrapper;
const auto index = wrapper.TotalDeviceIndex();
if (selectedDevices.contains(int(index)))
{
bool err = false;
QString temp;
size_t maxAlloc = wrapper.MaxAllocSize();
size_t totalAvail = wrapper.GlobalMemSize();
const auto maxAlloc = wrapper.MaxAllocSize();
const auto totalAvail = wrapper.GlobalMemSize();
if (histSize > maxAlloc)
{
@ -1109,23 +1125,23 @@ template <typename T>
void FinalRenderPreviewRenderer<T>::PreviewRenderFunc(uint start, uint end)
{
T scalePercentage;
size_t maxDim = 100;
auto d = m_Controller->m_FinalRenderDialog;
const size_t maxDim = 100;
const auto d = m_Controller->m_FinalRenderDialog;
QLabel* widget = d->ui.FinalRenderPreviewLabel;
//Determine how to scale the scaled ember to fit in the label with a max of 100x100.
auto e = m_Controller->m_Ember;
auto settings = FractoriumSettings::Instance();
const auto e = m_Controller->m_Ember;
const auto settings = FractoriumSettings::Instance();
if (e->m_FinalRasW >= e->m_FinalRasH)
scalePercentage = T(maxDim) / e->m_FinalRasW;
scalePercentage = static_cast<T>(maxDim) / e->m_FinalRasW;
else
scalePercentage = T(maxDim) / e->m_FinalRasH;
scalePercentage = static_cast<T>(maxDim) / e->m_FinalRasH;
m_PreviewEmber = *e;
m_PreviewEmber.m_Quality = 100;
m_PreviewEmber.m_TemporalSamples = 1;
m_PreviewEmber.m_FinalRasW = std::max<size_t>(1, std::min<size_t>(maxDim, size_t(scalePercentage * e->m_FinalRasW)));//Ensure neither is zero.
m_PreviewEmber.m_FinalRasH = std::max<size_t>(1, std::min<size_t>(maxDim, size_t(scalePercentage * e->m_FinalRasH)));
m_PreviewEmber.m_FinalRasW = std::max<size_t>(1, std::min<size_t>(maxDim, static_cast<size_t>(scalePercentage * e->m_FinalRasW)));//Ensure neither is zero.
m_PreviewEmber.m_FinalRasH = std::max<size_t>(1, std::min<size_t>(maxDim, static_cast<size_t>(scalePercentage * e->m_FinalRasH)));
m_PreviewEmber.m_PixelsPerUnit = scalePercentage * e->m_PixelsPerUnit;
m_PreviewRenderer.EarlyClip(d->EarlyClip());
m_PreviewRenderer.YAxisUp(d->YAxisUp());
@ -1142,7 +1158,7 @@ void FinalRenderPreviewRenderer<T>::PreviewRenderFunc(uint start, uint end)
{
m_PreviewVec.resize(finalEmber.m_FinalRasW * finalEmber.m_FinalRasH * 4);
Rgba32ToRgba8(m_PreviewFinalImage.data(), m_PreviewVec.data(), finalEmber.m_FinalRasW, finalEmber.m_FinalRasH, d->Transparency());
QImage image(int(finalEmber.m_FinalRasW), int(finalEmber.m_FinalRasH), QImage::Format_RGBA8888);//The label wants RGBA.
QImage image(static_cast<int>(finalEmber.m_FinalRasW), static_cast<int>(finalEmber.m_FinalRasH), QImage::Format_RGBA8888);//The label wants RGBA.
memcpy(image.scanLine(0), m_PreviewVec.data(), SizeOf(m_PreviewVec));//Memcpy the data in.
QPixmap pixmap(QPixmap::fromImage(image));
QMetaObject::invokeMethod(widget, "setPixmap", Qt::QueuedConnection, Q_ARG(QPixmap, pixmap));

View File

@ -109,39 +109,40 @@ public:
virtual ~FinalRenderEmberController() { }
//Virtual functions overridden from FractoriumEmberControllerBase.
virtual void SetEmberFile(const EmberFile<float>& emberFile, bool move) override;
virtual void CopyEmberFile(EmberFile<float>& emberFile, bool sequence, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
void SetEmberFile(const EmberFile<float>& emberFile, bool move) override;
void CopyEmberFile(EmberFile<float>& emberFile, bool sequence, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
#ifdef DO_DOUBLE
virtual void SetEmberFile(const EmberFile<double>& emberFile, bool move) override;
virtual void CopyEmberFile(EmberFile<double>& emberFile, bool sequence, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
void SetEmberFile(const EmberFile<double>& emberFile, bool move) override;
void CopyEmberFile(EmberFile<double>& emberFile, bool sequence, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
#endif
virtual void SetEmber(size_t index, bool verbatim) override;
virtual bool Render() override;
virtual bool BumpQualityRender(double d) override;
virtual bool CreateRenderer(eRendererType renderType, const vector<pair<size_t, size_t>>& devices, bool updatePreviews, bool shared = true) override;
virtual int ProgressFunc(Ember<T>& ember, void* foo, double fraction, int stage, double etaMs) override;
virtual size_t Index() const override { return m_Ember->m_Index; }
virtual uint SizeOfT() const override { return sizeof(T); }
void SetEmber(size_t index, bool verbatim) override;
void SaveCurrentAsXml(QString filename = "") override;
bool Render() override;
bool BumpQualityRender(double d) override;
bool CreateRenderer(eRendererType renderType, const vector<pair<size_t, size_t>>& devices, bool updatePreviews, bool shared = true) override;
int ProgressFunc(Ember<T>& ember, void* foo, double fraction, int stage, double etaMs) override;
size_t Index() const override { return m_Ember->m_Index; }
uint SizeOfT() const override { return sizeof(T); }
//Virtual functions overridden from FinalRenderEmberControllerBase.
virtual void SyncCurrentToGui() override;
virtual void SyncGuiToEmbers(size_t widthOverride = 0, size_t heightOverride = 0, bool dowidth = true, bool doheight = true) override;
virtual void SyncCurrentToSizeSpinners(bool scale, bool size, bool doWidth = true, bool doHeight = true) override;
virtual void ResetProgress(bool total = true) override;
virtual tuple<size_t, size_t, size_t> SyncAndComputeMemory() override;
virtual double OriginalAspect() override { return double(m_Ember->m_OrigFinalRasW) / m_Ember->m_OrigFinalRasH; }
virtual QString Name() const override { return QString::fromStdString(m_Ember->m_Name); }
virtual QString ComposePath(const QString& name) override;
virtual QString SaveCurrentAgain() override;
virtual void CancelRender() override;
virtual QString CheckMemory(const tuple<size_t, size_t, size_t>& p) override;
void SyncCurrentToGui() override;
void SyncGuiToEmbers(size_t widthOverride = 0, size_t heightOverride = 0, bool dowidth = true, bool doheight = true) override;
void SyncCurrentToSizeSpinners(bool scale, bool size, bool doWidth = true, bool doHeight = true) override;
void ResetProgress(bool total = true) override;
tuple<size_t, size_t, size_t> SyncAndComputeMemory() override;
double OriginalAspect() override { return double(m_Ember->m_OrigFinalRasW) / m_Ember->m_OrigFinalRasH; }
QString Name() const override { return QString::fromStdString(m_Ember->m_Name); }
QString ComposePath(const QString& name) override;
QString SaveCurrentAgain() override;
void CancelRender() override;
QString CheckMemory(const tuple<size_t, size_t, size_t>& p) override;
//Non Virtual functions.
EmberNs::Renderer<T, float>* FirstOrDefaultRenderer();
protected:
virtual void Pause(bool pause) override;
virtual bool Paused() override;
void Pause(bool pause) override;
bool Paused() override;
void HandleFinishedProgress();
QString SaveCurrentRender(Ember<T>& ember);
QString SaveCurrentRender(Ember<T>& ember, const EmberImageComments& comments, vector<v4F>& pixels, size_t width, size_t height, bool png16Bit, bool transparency);
@ -177,7 +178,7 @@ public:
{
}
virtual void PreviewRenderFunc(uint start, uint end) override;
void PreviewRenderFunc(uint start, uint end) override;
private:
FinalRenderEmberController<T>* m_Controller;

View File

@ -17,7 +17,7 @@
Fractorium::Fractorium(QWidget* p)
: QMainWindow(p)
{
int iconSize_ = 9;
const auto iconSize_ = 9;
size_t i = 0;
string s;
Timing t;
@ -126,7 +126,7 @@ Fractorium::Fractorium(QWidget* p)
if (m_Info->Ok() && m_Settings->OpenCL() && m_QualitySpin->value() < (m_Settings->OpenClQuality() * m_Settings->Devices().size()))
m_QualitySpin->setValue(m_Settings->OpenClQuality() * m_Settings->Devices().size());
int statusBarHeight = 20;// *devicePixelRatio();
const auto statusBarHeight = 20;// *devicePixelRatio();
ui.StatusBar->setMinimumHeight(statusBarHeight);
ui.StatusBar->setMaximumHeight(statusBarHeight);
m_RenderStatusLabel = new QLabel(this);
@ -138,8 +138,8 @@ Fractorium::Fractorium(QWidget* p)
m_CoordinateStatusLabel->setMaximumWidth(300);
m_CoordinateStatusLabel->setAlignment(Qt::AlignLeft);
ui.StatusBar->addWidget(m_CoordinateStatusLabel);
int progressBarHeight = 15;
int progressBarWidth = 300;
const auto progressBarHeight = 15;
const auto progressBarWidth = 300;
m_ProgressBar = new QProgressBar(this);
m_ProgressBar->setRange(0, 100);
m_ProgressBar->setValue(0);
@ -271,10 +271,14 @@ void Fractorium::SetCoordinateStatus(int rasX, int rasY, float worldX, float wor
/// </summary>
void Fractorium::CenterScrollbars()
{
QScrollBar* w = ui.GLParentScrollArea->horizontalScrollBar();
QScrollBar* h = ui.GLParentScrollArea->verticalScrollBar();
w->setValue(w->maximum() / 2);
h->setValue(h->maximum() / 2);
const auto w = ui.GLParentScrollArea->horizontalScrollBar();
const auto h = ui.GLParentScrollArea->verticalScrollBar();
if (w && h)
{
w->setValue(w->maximum() / 2);
h->setValue(h->maximum() / 2);
}
}
/// <summary>
@ -297,7 +301,7 @@ void FractoriumEmberController<T>::ApplyXmlSavingTemplate(Ember<T>& ember)
/// <returns>True if the current ember contains a final xform, else false.</returns>
bool Fractorium::HaveFinal()
{
auto combo = ui.CurrentXformCombo;
const auto combo = ui.CurrentXformCombo;
return (combo->count() > 0 && combo->itemText(combo->count() - 1) == "Final");
}
@ -380,12 +384,11 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e)
m_WidthSpin->DoubleClickNonZero(ui.GLParentScrollArea->width() * ui.GLDisplay->devicePixelRatioF());
m_HeightSpin->DoubleClickNonZero(ui.GLParentScrollArea->height() * ui.GLDisplay->devicePixelRatioF());
}
else if (auto ke = dynamic_cast<QKeyEvent*>(e))
else if (const auto ke = dynamic_cast<QKeyEvent*>(e))
{
auto combo = ui.CurrentXformCombo;
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
const int times = 3;
const int ftimes = 2;
const auto times = 3;
const auto ftimes = 2;
if (ke->key() >= Qt::Key_F1 && ke->key() <= Qt::Key_F32)
{
@ -393,7 +396,7 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e)
if (fcount >= ftimes)
{
const int val = ke->key() - (int)Qt::Key_F1;
const auto val = ke->key() - (int)Qt::Key_F1;
if (shift)
{
@ -435,7 +438,7 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e)
!focusedctrlCombo &&
!QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier))//Must exclude these because otherwise, typing a minus key in any of the spinners will switch the xform. Also exclude alt.
{
size_t index;
size_t index = 0;
double vdist = 0.01;
double hdist = 0.01;
double zoom = 1;
@ -821,8 +824,8 @@ void Fractorium::dragMoveEvent(QDragMoveEvent* e)
void Fractorium::dropEvent(QDropEvent* e)
{
QStringList filenames;
Qt::KeyboardModifiers mod = e->keyboardModifiers();
bool append = mod.testFlag(Qt::ControlModifier) ? false : true;
const auto mod = e->keyboardModifiers();
const auto append = mod.testFlag(Qt::ControlModifier) ? false : true;
if (e->mimeData()->hasUrls())
{
@ -912,12 +915,12 @@ QStringList Fractorium::SetupOpenXmlDialog(bool openExamples)
#ifndef __APPLE__
//Lazy instantiate since it takes a long time.
if (!m_OpenFileDialog)
if (!m_OpenFileDialog.get())
{
m_OpenFileDialog = new QFileDialog(this);
m_OpenFileDialog = std::make_unique<QFileDialog>(this);
m_OpenFileDialog->setViewMode(QFileDialog::List);
m_OpenFileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
connect(m_OpenFileDialog, &QFileDialog::filterSelected, [&](const QString & filter) { m_Settings->OpenXmlExt(filter); });
connect(m_OpenFileDialog.get(), &QFileDialog::filterSelected, [&](const QString & filter) { m_Settings->OpenXmlExt(filter); });
m_OpenFileDialog->setFileMode(QFileDialog::ExistingFiles);
m_OpenFileDialog->setAcceptMode(QFileDialog::AcceptOpen);
m_OpenFileDialog->setNameFilter("flam3 (*.flam3);;flame (*.flame);;xml (*.xml);;chaos (*.chaos)");
@ -993,16 +996,16 @@ QString Fractorium::SetupSaveXmlDialog(const QString& defaultFilename)
//Lazy instantiate since it takes a long time.
//QS
if (!m_SaveFileDialog)
if (!m_SaveFileDialog.get())
{
m_SaveFileDialog = new QFileDialog(this);
m_SaveFileDialog = std::make_unique<QFileDialog>(this);
m_SaveFileDialog->setViewMode(QFileDialog::List);
m_SaveFileDialog->setFileMode(QFileDialog::FileMode::AnyFile);
m_SaveFileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
//This must be done once here because clears various internal states which allow the file text to be properly set.
//This is most likely a bug in QFileDialog.
m_SaveFileDialog->setAcceptMode(QFileDialog::AcceptSave);
connect(m_SaveFileDialog, &QFileDialog::filterSelected, [&](const QString & filter)
connect(m_SaveFileDialog.get(), &QFileDialog::filterSelected, [&](const QString & filter)
{
m_Settings->SaveXmlExt(filter);
m_SaveFileDialog->setDefaultSuffix(filter);
@ -1045,16 +1048,16 @@ QString Fractorium::SetupSaveImageDialog(const QString& defaultFilename)
#ifndef __APPLE__
//Lazy instantiate since it takes a long time.
if (!m_SaveImageDialog)
if (!m_SaveImageDialog.get())
{
m_SaveImageDialog = new QFileDialog(this);
m_SaveImageDialog = std::make_unique<QFileDialog>(this);
m_SaveImageDialog->setViewMode(QFileDialog::List);
m_SaveImageDialog->setFileMode(QFileDialog::FileMode::AnyFile);
m_SaveImageDialog->setOption(QFileDialog::DontUseNativeDialog, true);
//This must be done once here because clears various internal states which allow the file text to be properly set.
//This is most likely a bug in QFileDialog.
m_SaveImageDialog->setAcceptMode(QFileDialog::AcceptSave);
connect(m_SaveImageDialog, &QFileDialog::filterSelected, [&](const QString & filter)
connect(m_SaveImageDialog.get(), &QFileDialog::filterSelected, [&](const QString & filter)
{
m_Settings->SaveImageExt(filter);
m_SaveImageDialog->setDefaultSuffix(filter);
@ -1095,9 +1098,9 @@ QString Fractorium::SetupSaveFolderDialog()
#ifndef __APPLE__
//Lazy instantiate since it takes a long time.
if (!m_FolderDialog)
if (!m_FolderDialog.get())
{
m_FolderDialog = new QFileDialog(this);
m_FolderDialog = std::make_unique<QFileDialog>(this);
m_FolderDialog->setViewMode(QFileDialog::List);
m_FolderDialog->setOption(QFileDialog::DontUseNativeDialog, true);
//This must come first because it clears various internal states which allow the file text to be properly set.
@ -1139,15 +1142,9 @@ QString Fractorium::SetupSaveFolderDialog()
/// <returns>True if created successfully, else false</returns>
bool Fractorium::SetupFinalRenderDialog()
{
if (m_FinalRenderDialog)
if (m_FinalRenderDialog = std::make_unique<FractoriumFinalRenderDialog>(this))
{
delete m_FinalRenderDialog;
m_FinalRenderDialog = nullptr;
}
if (m_FinalRenderDialog = new FractoriumFinalRenderDialog(this))
{
connect(m_FinalRenderDialog, SIGNAL(finished(int)), this, SLOT(OnFinalRenderClose(int)), Qt::QueuedConnection);
connect(m_FinalRenderDialog.get(), SIGNAL(finished(int)), this, SLOT(OnFinalRenderClose(int)), Qt::QueuedConnection);
return true;
}
@ -1210,6 +1207,7 @@ void Fractorium::SetTabOrders()
w = SetTabOrder(this, w, m_AffineInterpTypeCombo);
w = SetTabOrder(this, w, m_TemporalFilterWidthSpin);
w = SetTabOrder(this, w, m_TemporalFilterTypeCombo);
w = SetTabOrder(this, w, m_TemporalFilterExpSpin);
w = SetTabOrder(this, ui.LibraryTree, ui.SequenceStartCountSpinBox);//Library.
w = SetTabOrder(this, w, ui.SequenceStartPreviewsButton);
w = SetTabOrder(this, w, ui.SequenceStopPreviewsButton);
@ -1358,12 +1356,12 @@ void Fractorium::SetTabOrders()
/// <param name="logicalIndex">The index of the row that was double clicked</param>
void Fractorium::ToggleTableRow(QTableView* table, int logicalIndex)
{
bool allZero = true;
auto model = table->model();
int cols = model->columnCount();
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
auto tableWidget = qobject_cast<QTableWidget*>(table);
auto allZero = true;
const auto model = table->model();
const auto cols = model->columnCount();
const auto shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
const auto ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
const auto tableWidget = qobject_cast<QTableWidget*>(table);
if (tableWidget)
{
@ -1382,12 +1380,12 @@ void Fractorium::ToggleTableRow(QTableView* table, int logicalIndex)
if (shift)
allZero = !allZero;
double val = allZero ? 1.0 : 0.0;
const auto val = allZero ? 1.0 : 0.0;
for (int i = 0; i < cols; i++)
if (auto spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(logicalIndex, i)))
if (ctrl)
spinBox->setValue(double(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRandBit()));
spinBox->setValue(static_cast<double>(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRandBit()));
else
spinBox->setValue(val);
}
@ -1405,7 +1403,7 @@ void Fractorium::ToggleTableRow(QTableView* table, int logicalIndex)
if (shift)
allZero = !allZero;
double val = allZero ? 1.0 : 0.0;
const auto val = allZero ? 1.0 : 0.0;
for (int i = 0; i < cols; i++)
if (ctrl)
@ -1427,12 +1425,12 @@ void Fractorium::ToggleTableRow(QTableView* table, int logicalIndex)
/// <param name="logicalIndex">The index of the column that was double clicked</param>
void Fractorium::ToggleTableCol(QTableView* table, int logicalIndex)
{
bool allZero = true;
auto model = table->model();
int rows = model->rowCount();
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
auto tableWidget = qobject_cast<QTableWidget*>(table);
auto allZero = true;
const auto model = table->model();
const auto rows = model->rowCount();
const auto shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
const auto ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
const auto tableWidget = qobject_cast<QTableWidget*>(table);
if (tableWidget)
{
@ -1451,12 +1449,12 @@ void Fractorium::ToggleTableCol(QTableView* table, int logicalIndex)
if (shift)
allZero = !allZero;
double val = allZero ? 1.0 : 0.0;
const auto val = allZero ? 1.0 : 0.0;
for (int i = 0; i < rows; i++)
if (auto spinBox = qobject_cast<DoubleSpinBox*>(tableWidget->cellWidget(i, logicalIndex)))
if (ctrl)
spinBox->setValue(double(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRandBit()));
spinBox->setValue(static_cast<double>(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRandBit()));
else
spinBox->setValue(val);
}
@ -1474,7 +1472,7 @@ void Fractorium::ToggleTableCol(QTableView* table, int logicalIndex)
if (shift)
allZero = !allZero;
double val = allZero ? 1.0 : 0.0;
const auto val = allZero ? 1.0 : 0.0;
for (int i = 0; i < rows; i++)
if (ctrl)

View File

@ -263,6 +263,7 @@ public slots:
void OnSupersampleChanged(int d);
void OnAffineInterpTypeComboCurrentIndexChanged(int index);
void OnInterpTypeComboCurrentIndexChanged(int index);
void OnExpChanged(double d);
//Xforms.
void OnCurrentXformComboChanged(int index);
@ -400,13 +401,13 @@ public:
static void SetFixedTableHeader(QHeaderView* header, QHeaderView::ResizeMode mode = QHeaderView::Fixed);
protected:
virtual bool eventFilter(QObject* o, QEvent* e) override;
virtual void resizeEvent(QResizeEvent* e) override;
virtual void closeEvent(QCloseEvent* e) override;
virtual void dragEnterEvent(QDragEnterEvent* e) override;
virtual void dragMoveEvent(QDragMoveEvent* e) override;
virtual void dropEvent(QDropEvent* e) override;
virtual void showEvent(QShowEvent* e) override;
bool eventFilter(QObject* o, QEvent* e) override;
void resizeEvent(QResizeEvent* e) override;
void closeEvent(QCloseEvent* e) override;
void dragEnterEvent(QDragEnterEvent* e) override;
void dragMoveEvent(QDragMoveEvent* e) override;
void dropEvent(QDropEvent* e) override;
void showEvent(QShowEvent* e) override;
private:
void InitMenusUI();
@ -481,11 +482,11 @@ private:
QString SetupSaveFolderDialog();
bool SetupFinalRenderDialog();
QColorDialog* m_ColorDialog = nullptr;
FractoriumFinalRenderDialog* m_FinalRenderDialog = nullptr;
std::unique_ptr<FractoriumFinalRenderDialog> m_FinalRenderDialog;
FractoriumOptionsDialog* m_OptionsDialog = nullptr;
FractoriumVariationsDialog* m_VarDialog = nullptr;
FractoriumAboutDialog* m_AboutDialog = nullptr;
PaletteEditor* m_PaletteEditor = nullptr;
std::unique_ptr<PaletteEditor> m_PaletteEditor;
//Params.
DoubleSpinBox* m_BrightnessSpin;//Color.
@ -523,6 +524,7 @@ private:
SpinBox* m_SupersampleSpin;
StealthComboBox* m_AffineInterpTypeCombo;
StealthComboBox* m_InterpTypeCombo;
DoubleSpinBox* m_TemporalFilterExpSpin;
//Xforms.
DoubleSpinBox* m_XformWeightSpin;
@ -588,10 +590,10 @@ private:
//Files.
QList<QUrl> m_Urls;
#ifndef __APPLE__
QFileDialog* m_SaveFileDialog = nullptr;
QFileDialog* m_SaveImageDialog = nullptr;
QFileDialog* m_OpenFileDialog = nullptr;
QFileDialog* m_FolderDialog = nullptr;
std::unique_ptr<QFileDialog> m_SaveFileDialog;
std::unique_ptr<QFileDialog> m_SaveImageDialog;
std::unique_ptr<QFileDialog> m_OpenFileDialog;
std::unique_ptr<QFileDialog> m_FolderDialog;
#endif
QssDialog* m_QssDialog = nullptr;
QString m_LastSaveAll;

View File

@ -1360,13 +1360,13 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>90</height>
<height>112</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>90</height>
<height>112</height>
</size>
</property>
<property name="focusPolicy">
@ -1452,6 +1452,11 @@
<string>Temporal Filter Type</string>
</property>
</row>
<row>
<property name="text">
<string>Temporal Exp Value</string>
</property>
</row>
<column>
<property name="text">
<string>Field</string>
@ -1487,7 +1492,20 @@
<string>Temporal Filter Type</string>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The type of the temporal filter used during animation.&lt;/p&gt;&lt;p&gt;This is similar to the spatial filter in that the type can be chosen to produce different effects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The type of the temporal filter used during animation.&lt;/p&gt;&lt;p&gt;The filter is an array of values equal in length to the temporal samples used during animation.&lt;/p&gt;&lt;p&gt;For each temporal step used to create motion blur between sequence frames, the palette will be multiplied by the value in the filter array at that same step position.&lt;/p&gt;&lt;p&gt;Box: All filter elements are 1, which means the palette is unchanged from its original values.&lt;/p&gt;&lt;p&gt;Gaussian: The filter values follow the shape of a Gaussian distribution: starting close to zero, increasing up to 1 at the halfway point, then falling back down to zero. This can cause the output to be darker than the original keyframes since almost every filter value is less than 1, which might not be desirable.&lt;/p&gt;&lt;p&gt;Exp: Use an exponent to shape the filter values. A value of 0 sets all filter values to 1, making it the equivalent of Box. For Exp values other than 1, the output will usually be darker than the original keyframes since almost every filter value is less than 1, which might not be desirable.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</item>
<item row="4" column="0">
<property name="text">
<string>Temporal Exp Value</string>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The exponent value when using the Exp temporal filter type.&lt;/p&gt;&lt;p&gt;0: The value for every temporal sample is 1, which makes this equivalent to the Box filter.&lt;/p&gt;&lt;p&gt;0.5: Convex curve from 0 to 1.&lt;/p&gt;&lt;p&gt;1: Straight line from 0 to 1.&lt;/p&gt;&lt;p&gt;&amp;gt; 1: Concave curve from 0 to 1, with a more gradual onset the larger the value is.&lt;/p&gt;&lt;p&gt;Otherwise unused.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</item>
<item row="4" column="1">
<property name="text">
<string/>
</property>
</item>
</widget>

View File

@ -33,7 +33,7 @@
template<typename spinType, typename valType>
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)
{
auto settings = FractoriumSettings::DefInstance();
const auto settings = FractoriumSettings::DefInstance();
spinBox = new spinType(table, height, step);
spinBox->setRange(min, max);
spinBox->setValue(val);
@ -47,8 +47,8 @@ static void SetupSpinner(QTableWidget* table, const QObject* receiver, int& row,
if (doubleClickNonZero != -999 && doubleClickZero != -999)
{
spinBox->DoubleClick(true);
spinBox->DoubleClickZero(valType(doubleClickZero));
spinBox->DoubleClickNonZero(valType(doubleClickNonZero));
spinBox->DoubleClickZero(static_cast<valType>(doubleClickZero));
spinBox->DoubleClickNonZero(static_cast<valType>(doubleClickNonZero));
}
if (incRow)
@ -78,7 +78,7 @@ static QWidget* SetTabOrder(QWidget* p, QWidget* w1, QWidget* w2)
/// <returns>The truncated value</returns>
static double TruncPrecision(double val, uint digits)
{
double mult = std::pow(10, digits);
const auto mult = std::pow(10, digits);
return std::round(mult * val) / mult;
}
@ -136,12 +136,11 @@ static bool Exists(const QString& s)
/// <returns>The converted color</returns>
static QColor VisibleColor(const QColor& color)
{
int threshold = 105;
int delta = (color.red() * 0.299) + //Magic numbers gotten from a Stack Overflow post.
(color.green() * 0.587) +
(color.blue() * 0.114);
QColor textColor = (255 - delta < threshold) ? QColor(0, 0, 0) : QColor(255, 255, 255);
return textColor;
const auto threshold = 105;
const auto delta = (color.red() * 0.299) + //Magic numbers gotten from a Stack Overflow post.
(color.green() * 0.587) +
(color.blue() * 0.114);
return (255 - delta < threshold) ? QColor(0, 0, 0) : QColor(255, 255, 255);
}
/// <summary>
@ -154,8 +153,8 @@ static QColor VisibleColor(const QColor& color)
template <typename T>
static intmax_t IsXformLinked(Ember<T>& ember, Xform<T>* xform)
{
auto count = ember.XformCount();
auto index = ember.GetXformIndex(xform);
const auto count = ember.XformCount();
const auto index = ember.GetXformIndex(xform);
intmax_t linked = -1;
size_t toOneCount = 0;
size_t toZeroCount = 0;
@ -217,7 +216,7 @@ static vector<pair<size_t, size_t>> Devices(const QList<QVariant>& selectedDevic
for (int i = 0; i < selectedDevices.size(); i++)
{
auto index = selectedDevices[i].toUInt();
const auto index = selectedDevices[i].toUInt();
if (index < devices.size())
vec.push_back(devices[index]);
@ -239,13 +238,13 @@ static void SetupDeviceTable(QTableWidget* table, const QList<QVariant>& setting
bool primary = false;
auto& deviceNames = OpenCLInfo::Instance()->AllDeviceNames();
table->clearContents();
table->setRowCount(int(deviceNames.size()));
table->setRowCount(static_cast<int>(deviceNames.size()));
for (int i = 0; i < deviceNames.size(); i++)
{
auto checkItem = new QTableWidgetItem();
auto radio = new QRadioButton();
auto deviceItem = new QTableWidgetItem(QString::fromStdString(deviceNames[i]));
const auto checkItem = new QTableWidgetItem();
const auto radio = new QRadioButton();
const auto deviceItem = new QTableWidgetItem(QString::fromStdString(deviceNames[i]));
table->setItem(i, 0, checkItem);
table->setCellWidget(i, 1, radio);
table->setItem(i, 2, deviceItem);
@ -277,29 +276,29 @@ static void SetupDeviceTable(QTableWidget* table, const QList<QVariant>& setting
/// </summary>
/// <param name="table">The QTableWidget to copy values to</param>
/// <param name="settingsDevices">The absolute indices of the devices to use, with the first being the primary.</param>
static void SettingsToDeviceTable(QTableWidget* table, QList<QVariant>& settingsDevices)
static void SettingsToDeviceTable(QTableWidget* table, const QList<QVariant>& settingsDevices)
{
if (settingsDevices.empty() && table->rowCount() > 0)
{
table->item(0, 0)->setCheckState(Qt::Checked);
qobject_cast<QRadioButton*>(table->cellWidget(0, 1))->setChecked(true);
for (int row = 1; row < table->rowCount(); row++)
for (auto row = 1; row < table->rowCount(); row++)
if (auto item = table->item(row, 0))
item->setCheckState(Qt::Unchecked);
}
else
{
for (int row = 0; row < table->rowCount(); row++)
for (auto row = 0; row < table->rowCount(); row++)
{
if (auto item = table->item(row, 0))
if (const auto item = table->item(row, 0))
{
if (settingsDevices.contains(row))
{
item->setCheckState(Qt::Checked);
if (!settingsDevices.indexOf(QVariant::fromValue(row)))
if (auto radio = qobject_cast<QRadioButton*>(table->cellWidget(row, 1)))
if (const auto radio = qobject_cast<QRadioButton*>(table->cellWidget(row, 1)))
radio->setChecked(true);
}
else
@ -320,12 +319,12 @@ static void SettingsToDeviceTable(QTableWidget* table, QList<QVariant>& settings
static QList<QVariant> DeviceTableToSettings(QTableWidget* table)
{
QList<QVariant> devices;
auto rows = table->rowCount();
const auto rows = table->rowCount();
for (int row = 0; row < rows; row++)
{
auto checkItem = table->item(row, 0);
auto radio = qobject_cast<QRadioButton*>(table->cellWidget(row, 1));
const auto checkItem = table->item(row, 0);
const auto radio = qobject_cast<QRadioButton*>(table->cellWidget(row, 1));
if (checkItem->checkState() == Qt::Checked)
{
@ -347,12 +346,12 @@ static QList<QVariant> DeviceTableToSettings(QTableWidget* table)
/// <param name="col">The column of the cell</param>
static void HandleDeviceTableCheckChanged(QTableWidget* table, int row, int col)
{
int primaryRow = -1;
auto primaryRow = -1;
QRadioButton* primaryRadio = nullptr;
for (int i = 0; i < table->rowCount(); i++)
for (auto i = 0; i < table->rowCount(); i++)
{
if (auto radio = qobject_cast<QRadioButton*>(table->cellWidget(i, 1)))
if (const auto radio = qobject_cast<QRadioButton*>(table->cellWidget(i, 1)))
{
if (radio->isChecked())
{
@ -365,7 +364,7 @@ static void HandleDeviceTableCheckChanged(QTableWidget* table, int row, int col)
if (primaryRow == -1) primaryRow = 0;
if (auto primaryItem = table->item(primaryRow, 0))
if (const auto primaryItem = table->item(primaryRow, 0))
if (primaryItem->checkState() == Qt::Unchecked)
primaryItem->setCheckState(Qt::Checked);
}
@ -380,17 +379,17 @@ static void HandleDeviceTableCheckChanged(QTableWidget* table, int row, int col)
/// <param name="row">The row to write the palette to</param>
static void AddPaletteToTable(QTableWidget* paletteTable, Palette<float>* palette, int row)
{
auto v = palette->MakeRgbPaletteBlock(PALETTE_CELL_HEIGHT);
auto nameCol = new QTableWidgetItem(palette->m_Name.c_str());
const auto v = palette->MakeRgbPaletteBlock(PALETTE_CELL_HEIGHT);
auto nameCol = std::make_unique<QTableWidgetItem>(palette->m_Name.c_str());
nameCol->setToolTip(palette->m_Name.c_str());
nameCol->setFlags(palette->m_SourceColors.empty() ? (Qt::ItemIsEnabled | Qt::ItemIsSelectable)
: (Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable));
paletteTable->setItem(row, 0, nameCol);
QImage image(v.data(), int(palette->Size()), PALETTE_CELL_HEIGHT, QImage::Format_RGB888);
auto paletteItem = new PaletteTableWidgetItem(palette);
paletteTable->setItem(row, 0, nameCol.release());
const QImage image(v.data(), static_cast<int>(palette->Size()), PALETTE_CELL_HEIGHT, QImage::Format_RGB888);
auto paletteItem = std::make_unique<PaletteTableWidgetItem>(palette);
paletteItem->setData(Qt::DecorationRole, QPixmap::fromImage(image));
paletteItem->setFlags(paletteItem->flags() & ~Qt::ItemIsEditable);
paletteTable->setItem(row, 1, paletteItem);
paletteTable->setItem(row, 1, paletteItem.release());
}
/// <summary>
@ -406,22 +405,22 @@ static bool FillPaletteTable(const string& s, QTableWidget* paletteTable, shared
{
if (!s.empty())//This occasionally seems to get called with an empty string for reasons unknown.
{
if (auto palettes = paletteList->GetPaletteListByFilename(s))
if (const auto palettes = paletteList->GetPaletteListByFilename(s))
{
paletteTable->clear();
paletteTable->blockSignals(true);
paletteTable->setRowCount(int(palettes->size()));
paletteTable->setRowCount(static_cast<int>(palettes->size()));
//Headers get removed when clearing, so must re-create here.
auto nameHeader = new QTableWidgetItem("Name");
auto paletteHeader = new QTableWidgetItem("Palette");
auto nameHeader = std::make_unique<QTableWidgetItem>("Name");
auto paletteHeader = std::make_unique<QTableWidgetItem>("Palette");
nameHeader->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
paletteHeader->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
paletteTable->setHorizontalHeaderItem(0, nameHeader);
paletteTable->setHorizontalHeaderItem(1, paletteHeader);
paletteTable->setHorizontalHeaderItem(0, nameHeader.release());
paletteTable->setHorizontalHeaderItem(1, paletteHeader.release());
//Palette list table.
for (auto i = 0; i < palettes->size(); i++)
if (auto palette = &(*palettes)[i])
if (const auto palette = &(*palettes)[i])
AddPaletteToTable(paletteTable, palette, i);
paletteTable->blockSignals(false);
@ -471,11 +470,11 @@ static QString GetDefaultUserPath()
/// <returns>The full path and filename if found, else empty string.</returns>
static QString FindFirstDefaultPalette()
{
auto paths = GetDefaultPaths();
const auto paths = GetDefaultPaths();
for (auto& path : paths)
{
auto full = path + "/flam3-palettes.xml";
const auto full = path + "/flam3-palettes.xml";
if (QFile::exists(full))
return full;
@ -573,9 +572,9 @@ static QList<T> GetAllParents(QWidget* widget)
{
QList<T> parents;
while (auto parent = qobject_cast<QWidget*>(widget->parent()))
while (const auto parent = qobject_cast<QWidget*>(widget->parent()))
{
if (auto parentT = qobject_cast<T>(parent))
if (const auto parentT = qobject_cast<T>(parent))
parents.push_back(parentT);
widget = parent;

View File

@ -69,7 +69,7 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
m_Fractorium->ui.PaletteFilenameCombo->clear();
//Initial combo change event to fill the palette table will be called automatically later.
//Look hard for a palette.
auto paths = GetDefaultPaths();
const auto paths = GetDefaultPaths();
for (auto& path : paths)
b |= InitPaletteList(path);
@ -227,11 +227,11 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*, siz
{
int i = 0;
size_t selIndex = 0;
auto current = CurrentXform();
auto currentIndex = m_Fractorium->ui.CurrentXformCombo->currentIndex();
bool forceFinal = m_Fractorium->HaveFinal();
bool isCurrentFinal = m_Ember.IsFinalXform(current);
bool doFinal = updateType != eXformUpdate::UPDATE_SELECTED_EXCEPT_FINAL && updateType != eXformUpdate::UPDATE_ALL_EXCEPT_FINAL;
const auto current = CurrentXform();
const auto currentIndex = m_Fractorium->ui.CurrentXformCombo->currentIndex();
const bool forceFinal = m_Fractorium->HaveFinal();
const bool isCurrentFinal = m_Ember.IsFinalXform(current);
const bool doFinal = updateType != eXformUpdate::UPDATE_SELECTED_EXCEPT_FINAL && updateType != eXformUpdate::UPDATE_ALL_EXCEPT_FINAL;
switch (updateType)
{
@ -253,7 +253,7 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*, siz
{
bool currentDone = false;
while (auto xform = m_Ember.GetTotalXform(i, forceFinal))
while (const auto xform = m_Ember.GetTotalXform(i, forceFinal))
{
if (m_Fractorium->IsXformSelected(i))
{
@ -276,7 +276,7 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*, siz
{
bool anyUpdated = false;
while (auto xform = (doFinal ? m_Ember.GetTotalXform(i, forceFinal) : m_Ember.GetXform(i)))
while (const auto xform = (doFinal ? m_Ember.GetTotalXform(i, forceFinal) : m_Ember.GetXform(i)))
{
if (m_Fractorium->IsXformSelected(i))
{
@ -296,7 +296,7 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*, siz
case eXformUpdate::UPDATE_ALL:
{
while (auto xform = m_Ember.GetTotalXform(i, forceFinal))
while (const auto xform = m_Ember.GetTotalXform(i, forceFinal))
func(xform, i++, selIndex++);
}
break;
@ -304,7 +304,7 @@ void FractoriumEmberController<T>::UpdateXform(std::function<void(Xform<T>*, siz
case eXformUpdate::UPDATE_ALL_EXCEPT_FINAL:
default:
{
while (auto xform = m_Ember.GetXform(i))
while (const auto xform = m_Ember.GetXform(i))
func(xform, i++, selIndex++);
}
break;
@ -330,8 +330,8 @@ void FractoriumEmberController<T>::SetEmberPrivate(const Ember<U>& ember, bool v
if (ember.m_Name != m_Ember.m_Name)
m_LastSaveCurrent = "";
size_t w = m_Ember.m_FinalRasW;//Cache values for use below.
size_t h = m_Ember.m_FinalRasH;
const auto w = m_Ember.m_FinalRasW;//Cache values for use below.
const auto h = m_Ember.m_FinalRasH;
m_Ember = ember;
if (updatePointer && (typeid(T) == typeid(U)))
@ -345,13 +345,13 @@ void FractoriumEmberController<T>::SetEmberPrivate(const Ember<U>& ember, bool v
}
static EmberToXml<T> writer;//Save parameters of last full render just in case there is a crash.
auto path = GetDefaultUserPath();
QDir dir(path);
const auto path = GetDefaultUserPath();
const QDir dir(path);
if (!dir.exists())
dir.mkpath(".");
string filename = path.toStdString() + "/last.flame";
const auto filename = path.toStdString() + "/last.flame";
writer.Save(filename, m_Ember, 0, true, true, false, true, true);
m_GLController->ResetMouseState();
FillXforms();//Must do this first because the palette setup in FillParamTablesAndPalette() uses the xforms combo.
@ -374,12 +374,12 @@ void FractoriumEmberController<T>::SetEmberPrivate(const Ember<U>& ember, bool v
template <typename T>
void TreePreviewRenderer<T>::PreviewRenderFunc(uint start, uint end)
{
auto f = m_Controller->m_Fractorium;
const auto f = m_Controller->m_Fractorium;
m_PreviewRenderer.EarlyClip(f->m_Settings->EarlyClip());
m_PreviewRenderer.YAxisUp(f->m_Settings->YAxisUp());
m_PreviewRenderer.ThreadCount(std::max(1u, Timing::ProcessorCount() - 1));//Leave one processor free so the GUI can breathe.
if (auto top = m_Tree->topLevelItem(0))
if (const auto top = m_Tree->topLevelItem(0))
{
size_t i = start;
@ -395,7 +395,7 @@ void TreePreviewRenderer<T>::PreviewRenderFunc(uint start, uint end)
if (m_PreviewRenderer.Run(m_PreviewFinalImage) == eRenderStatus::RENDER_OK)
{
if (auto treeItem = dynamic_cast<EmberTreeWidgetItemBase*>(top->child(int(i))))
if (const auto treeItem = dynamic_cast<EmberTreeWidgetItemBase*>(top->child(int(i))))
{
//It is critical that Qt::BlockingQueuedConnection is passed because this is running on a different thread than the UI.
//This ensures the events are processed in order as each preview is updated, and that control does not return here

View File

@ -98,7 +98,7 @@ public:
virtual void CopyFlameInCurrentFile() { }
virtual void CreateReferenceFile() { }
virtual void OpenAndPrepFiles(const QStringList& filenames, bool append) { }
virtual void SaveCurrentAsXml() { }
virtual void SaveCurrentAsXml(QString filename = "") { }
virtual void SaveEntireFileAsXml() { }
virtual uint SaveCurrentToOpenedFile(bool render = true) { return 0; }
virtual void SaveCurrentFileOnShutdown() { }
@ -186,6 +186,7 @@ public:
virtual void ColorCurveChanged(int curveIndex, int pointInxed, const QPointF& point) { }
virtual void ColorCurvesPointAdded(size_t curveIndex, const QPointF& point) { }
virtual void ColorCurvesPointRemoved(size_t curveIndex, int pointIndex) { }
virtual void ExpChanged(double d) { }
//Xforms.
virtual void CurrentXformComboChanged(int index) { }
@ -345,200 +346,201 @@ public:
virtual ~FractoriumEmberController();
//Embers.
virtual void SetEmber(const Ember<float>& ember, bool verbatim, bool updatePointer) override;
virtual void CopyEmber(Ember<float>& ember, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
virtual void SetEmberFile(const EmberFile<float>& emberFile, bool move) override;
virtual void CopyEmberFile(EmberFile<float>& emberFile, bool sequence, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
virtual void SetTempPalette(const Palette<float>& palette) override;
virtual void CopyTempPalette(Palette<float>& palette) override;
void SetEmber(const Ember<float>& ember, bool verbatim, bool updatePointer) override;
void CopyEmber(Ember<float>& ember, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
void SetEmberFile(const EmberFile<float>& emberFile, bool move) override;
void CopyEmberFile(EmberFile<float>& emberFile, bool sequence, std::function<void(Ember<float>& ember)> perEmberOperation/* = [&](Ember<float>& ember) { }*/) override;
void SetTempPalette(const Palette<float>& palette) override;
void CopyTempPalette(Palette<float>& palette) override;
#ifdef DO_DOUBLE
virtual void SetEmber(const Ember<double>& ember, bool verbatim, bool updatePointer) override;
virtual void CopyEmber(Ember<double>& ember, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
virtual void SetEmberFile(const EmberFile<double>& emberFile, bool move) override;
virtual void CopyEmberFile(EmberFile<double>& emberFile, bool sequence, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
virtual void SetTempPalette(const Palette<double>& palette) override;
virtual void CopyTempPalette(Palette<double>& palette) override;
void SetEmber(const Ember<double>& ember, bool verbatim, bool updatePointer) override;
void CopyEmber(Ember<double>& ember, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
void SetEmberFile(const EmberFile<double>& emberFile, bool move) override;
void CopyEmberFile(EmberFile<double>& emberFile, bool sequence, std::function<void(Ember<double>& ember)> perEmberOperation/* = [&](Ember<double>& ember) { }*/) override;
void SetTempPalette(const Palette<double>& palette) override;
void CopyTempPalette(Palette<double>& palette) override;
#endif
virtual void SetEmber(size_t index, bool verbatim) override;
virtual void AddXform() override;
virtual void AddLinkedXform() override;
virtual void DuplicateXform() override;
virtual void ClearXform() override;
virtual void DeleteXforms() override;
virtual void AddFinalXform() override;
virtual bool UseFinalXform() override { return m_Ember.UseFinalXform(); }
virtual size_t XformCount() const override { return m_Ember.XformCount(); }
virtual size_t TotalXformCount() const override { return m_Ember.TotalXformCount(); }
virtual QString Name() const override { return QString::fromStdString(m_Ember.m_Name); }
virtual void Name(const string& s) override { m_Ember.m_Name = s; }
virtual size_t FinalRasW() const override { return m_Ember.m_FinalRasW; }
virtual void FinalRasW(size_t w) override { m_Ember.m_FinalRasW = w; }
virtual size_t FinalRasH() const override { return m_Ember.m_FinalRasH; }
virtual void FinalRasH(size_t h) override { m_Ember.m_FinalRasH = h; }
virtual size_t Index() const override { return m_Ember.m_Index; }
virtual void AddSymmetry(int sym, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override { m_Ember.AddSymmetry(sym, rand); }
virtual void CalcNormalizedWeights() override { m_Ember.CalcNormalizedWeights(m_NormalizedWeights); }
void SetEmber(size_t index, bool verbatim) override;
void AddXform() override;
void AddLinkedXform() override;
void DuplicateXform() override;
void ClearXform() override;
void DeleteXforms() override;
void AddFinalXform() override;
bool UseFinalXform() override { return m_Ember.UseFinalXform(); }
size_t XformCount() const override { return m_Ember.XformCount(); }
size_t TotalXformCount() const override { return m_Ember.TotalXformCount(); }
QString Name() const override { return QString::fromStdString(m_Ember.m_Name); }
void Name(const string& s) override { m_Ember.m_Name = s; }
size_t FinalRasW() const override { return m_Ember.m_FinalRasW; }
void FinalRasW(size_t w) override { m_Ember.m_FinalRasW = w; }
size_t FinalRasH() const override { return m_Ember.m_FinalRasH; }
void FinalRasH(size_t h) override { m_Ember.m_FinalRasH = h; }
size_t Index() const override { return m_Ember.m_Index; }
void AddSymmetry(int sym, QTIsaac<ISAAC_SIZE, ISAAC_INT>& rand) override { m_Ember.AddSymmetry(sym, rand); }
void CalcNormalizedWeights() override { m_Ember.CalcNormalizedWeights(m_NormalizedWeights); }
void ConstrainDimensions(Ember<T>& ember);
Ember<T>* CurrentEmber();
//Menu.
virtual void NewFlock(size_t count) override;
virtual void NewEmptyFlameInCurrentFile() override;
virtual void NewRandomFlameInCurrentFile() override;
virtual void CopyFlameInCurrentFile() override;
virtual void CreateReferenceFile() override;
virtual void OpenAndPrepFiles(const QStringList& filenames, bool append) override;
virtual void SaveCurrentAsXml() override;
virtual void SaveEntireFileAsXml() override;
virtual uint SaveCurrentToOpenedFile(bool render = true) override;
virtual void SaveCurrentFileOnShutdown() override;
virtual void Undo() override;
virtual void Redo() override;
virtual void CopyXml() override;
virtual void CopyAllXml() override;
virtual void PasteXmlAppend() override;
virtual void PasteXmlOver() override;
virtual void CopySelectedXforms() override;
virtual void PasteSelectedXforms() override;
virtual void CopyKernel() override;
virtual void AddReflectiveSymmetry() override;
virtual void AddRotationalSymmetry() override;
virtual void AddBothSymmetry() override;
virtual void Flatten() override;
virtual void Unflatten() override;
virtual void ClearFlame() override;
void NewFlock(size_t count) override;
void NewEmptyFlameInCurrentFile() override;
void NewRandomFlameInCurrentFile() override;
void CopyFlameInCurrentFile() override;
void CreateReferenceFile() override;
void OpenAndPrepFiles(const QStringList& filenames, bool append) override;
void SaveCurrentAsXml(QString filename = "") override;
void SaveEntireFileAsXml() override;
uint SaveCurrentToOpenedFile(bool render = true) override;
void SaveCurrentFileOnShutdown() override;
void Undo() override;
void Redo() override;
void CopyXml() override;
void CopyAllXml() override;
void PasteXmlAppend() override;
void PasteXmlOver() override;
void CopySelectedXforms() override;
void PasteSelectedXforms() override;
void CopyKernel() override;
void AddReflectiveSymmetry() override;
void AddRotationalSymmetry() override;
void AddBothSymmetry() override;
void Flatten() override;
void Unflatten() override;
void ClearFlame() override;
//Toolbar.
//Library.
virtual void SyncLibrary(eLibraryUpdate update) override;
virtual void FillLibraryTree(int selectIndex = -1) override;
virtual void UpdateLibraryTree() override;
virtual void MoveLibraryItems(const QModelIndexList& items, int destRow) override;
virtual void Delete(const vector<pair<size_t, QTreeWidgetItem*>>& v) override;
virtual void EmberTreeItemChanged(QTreeWidgetItem* item, int col) override;
virtual void EmberTreeItemDoubleClicked(QTreeWidgetItem* item, int col) override;
void SyncLibrary(eLibraryUpdate update) override;
void FillLibraryTree(int selectIndex = -1) override;
void UpdateLibraryTree() override;
void MoveLibraryItems(const QModelIndexList& items, int destRow) override;
void Delete(const vector<pair<size_t, QTreeWidgetItem*>>& v) override;
void EmberTreeItemChanged(QTreeWidgetItem* item, int col) override;
void EmberTreeItemDoubleClicked(QTreeWidgetItem* item, int col) override;
void RenderPreviews(QTreeWidget* tree, TreePreviewRenderer<T>* renderer, EmberFile<T>& file, uint start = UINT_MAX, uint end = UINT_MAX);
virtual void RenderLibraryPreviews(uint start = UINT_MAX, uint end = UINT_MAX) override;
virtual void RenderSequencePreviews(uint start = UINT_MAX, uint end = UINT_MAX) override;
virtual void SequenceTreeItemChanged(QTreeWidgetItem* item, int col) override;
virtual void StopLibraryPreviewRender() override;
virtual void StopSequencePreviewRender() override;
virtual void StopAllPreviewRenderers() override;
virtual void FillSequenceTree() override;
virtual void SequenceGenerateButtonClicked() override;
virtual void SequenceSaveButtonClicked() override;
virtual void SequenceOpenButtonClicked() override;
void RenderLibraryPreviews(uint start = UINT_MAX, uint end = UINT_MAX) override;
void RenderSequencePreviews(uint start = UINT_MAX, uint end = UINT_MAX) override;
void SequenceTreeItemChanged(QTreeWidgetItem* item, int col) override;
void StopLibraryPreviewRender() override;
void StopSequencePreviewRender() override;
void StopAllPreviewRenderers() override;
void FillSequenceTree() override;
void SequenceGenerateButtonClicked() override;
void SequenceSaveButtonClicked() override;
void SequenceOpenButtonClicked() override;
//Params.
virtual void ParamsToEmber(Ember<float>& ember, bool imageParamsOnly = false) override;
void ParamsToEmber(Ember<float>& ember, bool imageParamsOnly = false) override;
#ifdef DO_DOUBLE
virtual void ParamsToEmber(Ember<double>& ember, bool imageParamsOnly = false) override;
void ParamsToEmber(Ember<double>& ember, bool imageParamsOnly = false) override;
#endif
virtual void SetCenter(double x, double y) override;
virtual void FillParamTablesAndPalette() override;
virtual void BrightnessChanged(double d) override;
virtual void GammaChanged(double d) override;
virtual void GammaThresholdChanged(double d) override;
virtual void VibrancyChanged(double d) override;
virtual void HighlightPowerChanged(double d) override;
virtual void K2Changed(double d) override;
virtual void PaletteModeChanged(uint i) override;
virtual void WidthChanged(uint i) override;
virtual void HeightChanged(uint i) override;
virtual void ResizeAndScale(int width, int height, eScaleType scaleType) override;
virtual void CenterXChanged(double d) override;
virtual void CenterYChanged(double d) override;
virtual void ScaleChanged(double d) override;
virtual void ZoomChanged(double d) override;
virtual void RotateChanged(double d) override;
virtual void ZPosChanged(double d) override;
virtual void PerspectiveChanged(double d) override;
virtual void PitchChanged(double d) override;
virtual void YawChanged(double d) override;
virtual void DepthBlurChanged(double d) override;
virtual void BlurCurveChanged(double d) override;
virtual void SpatialFilterWidthChanged(double d) override;
virtual void SpatialFilterTypeChanged(const QString& text) override;
virtual void TemporalFilterWidthChanged(double d) override;
virtual void TemporalFilterTypeChanged(const QString& text) override;
virtual void DEFilterMinRadiusWidthChanged(double d) override;
virtual void DEFilterMaxRadiusWidthChanged(double d) override;
virtual void DEFilterCurveWidthChanged(double d) override;
virtual void SbsChanged(int d) override;
virtual void FuseChanged(int d) override;
virtual void RandRangeChanged(double d) override;
virtual void QualityChanged(double d) override;
virtual void SupersampleChanged(int d) override;
virtual void AffineInterpTypeChanged(int index) override;
virtual void InterpTypeChanged(int index) override;
virtual void BackgroundChanged(const QColor& col) override;
virtual void ClearColorCurves(int i) override;
virtual void ColorCurveChanged(int curveIndex, int pointInxed, const QPointF& point) override;
virtual void ColorCurvesPointAdded(size_t curveIndex, const QPointF& point) override;
virtual void ColorCurvesPointRemoved(size_t curveIndex, int pointIndex) override;
void SetCenter(double x, double y) override;
void FillParamTablesAndPalette() override;
void BrightnessChanged(double d) override;
void GammaChanged(double d) override;
void GammaThresholdChanged(double d) override;
void VibrancyChanged(double d) override;
void HighlightPowerChanged(double d) override;
void K2Changed(double d) override;
void PaletteModeChanged(uint i) override;
void WidthChanged(uint i) override;
void HeightChanged(uint i) override;
void ResizeAndScale(int width, int height, eScaleType scaleType) override;
void CenterXChanged(double d) override;
void CenterYChanged(double d) override;
void ScaleChanged(double d) override;
void ZoomChanged(double d) override;
void RotateChanged(double d) override;
void ZPosChanged(double d) override;
void PerspectiveChanged(double d) override;
void PitchChanged(double d) override;
void YawChanged(double d) override;
void DepthBlurChanged(double d) override;
void BlurCurveChanged(double d) override;
void SpatialFilterWidthChanged(double d) override;
void SpatialFilterTypeChanged(const QString& text) override;
void TemporalFilterWidthChanged(double d) override;
void TemporalFilterTypeChanged(const QString& text) override;
void DEFilterMinRadiusWidthChanged(double d) override;
void DEFilterMaxRadiusWidthChanged(double d) override;
void DEFilterCurveWidthChanged(double d) override;
void SbsChanged(int d) override;
void FuseChanged(int d) override;
void RandRangeChanged(double d) override;
void QualityChanged(double d) override;
void SupersampleChanged(int d) override;
void AffineInterpTypeChanged(int index) override;
void InterpTypeChanged(int index) override;
void BackgroundChanged(const QColor& col) override;
void ClearColorCurves(int i) override;
void ColorCurveChanged(int curveIndex, int pointInxed, const QPointF& point) override;
void ColorCurvesPointAdded(size_t curveIndex, const QPointF& point) override;
void ColorCurvesPointRemoved(size_t curveIndex, int pointIndex) override;
void ExpChanged(double d) override;
//Xforms.
virtual void CurrentXformComboChanged(int index) override;
virtual void XformWeightChanged(double d) override;
virtual void EqualizeWeights() override;
virtual void XformNameChanged(const QString& s) override;
virtual void XformAnimateChanged(int state) override;
virtual void FillXforms(int index = 0) override;
virtual void UpdateXformName(int index) override;
void CurrentXformComboChanged(int index) override;
void XformWeightChanged(double d) override;
void EqualizeWeights() override;
void XformNameChanged(const QString& s) override;
void XformAnimateChanged(int state) override;
void FillXforms(int index = 0) override;
void UpdateXformName(int index) override;
void FillWithXform(Xform<T>* xform);
Xform<T>* CurrentXform();
void UpdateXform(std::function<void(Xform<T>*, size_t, size_t)> func, eXformUpdate updateType = eXformUpdate::UPDATE_CURRENT, bool updateRender = true, eProcessAction action = eProcessAction::FULL_RENDER, size_t index = 0);
static void AddXformsWithXaos(Ember<T>& ember, std::vector<std::pair<Xform<T>, size_t>>& xforms, eXaosPasteStyle pastestyle);
//Xforms Affine.
virtual void AffineSetHelper(double d, int index, bool pre) override;
virtual void FlipXforms(bool horizontal, bool vertical, bool pre) override;
virtual void RotateXformsByAngle(double angle, bool pre) override;
virtual void MoveXforms(double x, double y, bool pre) override;
virtual void ScaleXforms(double scale, bool pre) override;
virtual void ResetXformsAffine(bool pre) override;
virtual void CopyXformsAffine(bool pre) override;
virtual void PasteXformsAffine(bool pre) override;
virtual void RandomXformsAffine(bool pre) override;
virtual void FillBothAffines() override;
virtual void SwapAffines() override;
virtual void InitLockedScale() override;
virtual double AffineScaleCurrentToLocked() override;
virtual double AffineScaleLockedToCurrent() override;
void AffineSetHelper(double d, int index, bool pre) override;
void FlipXforms(bool horizontal, bool vertical, bool pre) override;
void RotateXformsByAngle(double angle, bool pre) override;
void MoveXforms(double x, double y, bool pre) override;
void ScaleXforms(double scale, bool pre) override;
void ResetXformsAffine(bool pre) override;
void CopyXformsAffine(bool pre) override;
void PasteXformsAffine(bool pre) override;
void RandomXformsAffine(bool pre) override;
void FillBothAffines() override;
void SwapAffines() override;
void InitLockedScale() override;
double AffineScaleCurrentToLocked() override;
double AffineScaleLockedToCurrent() override;
void FillAffineWithXform(Xform<T>* xform, bool pre);
void ChangeLockedScale(T value);
//Xforms Color.
virtual void XformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0) override;
virtual void RandomColorIndicesButtonClicked() override;
virtual void ToggleColorIndicesButtonClicked() override;
virtual void RandomColorSpeedButtonClicked() override;
virtual void ToggleColorSpeedsButtonClicked() override;
virtual void XformColorSpeedChanged(double d) override;
virtual void XformOpacityChanged(double d) override;
virtual void XformDirectColorChanged(double d) override;
virtual void SoloXformCheckBoxStateChanged(int state, int index) override;
virtual QColor ColorIndexToQColor(double d) override;
void XformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update = eXformUpdate::UPDATE_SELECTED, size_t index = 0) override;
void RandomColorIndicesButtonClicked() override;
void ToggleColorIndicesButtonClicked() override;
void RandomColorSpeedButtonClicked() override;
void ToggleColorSpeedsButtonClicked() override;
void XformColorSpeedChanged(double d) override;
void XformOpacityChanged(double d) override;
void XformDirectColorChanged(double d) override;
void SoloXformCheckBoxStateChanged(int state, int index) override;
QColor ColorIndexToQColor(double d) override;
void FillColorWithXform(Xform<T>* xform);
//Xforms Variations.
virtual void Filter(const QString& text) override;
virtual void SetupVariationsTree() override;
virtual void ClearVariationsTree() override;
virtual void VariationSpinBoxValueChanged(double d) override;
virtual void FilteredVariations() override;
virtual void FillVariationTreeWithCurrentXform() override;
void Filter(const QString& text) override;
void SetupVariationsTree() override;
void ClearVariationsTree() override;
void VariationSpinBoxValueChanged(double d) override;
void FilteredVariations() override;
void FillVariationTreeWithCurrentXform() override;
void FillVariationTreeWithXform(Xform<T>* xform);
//Xforms Xaos.
virtual void FillXaos() override;
virtual void FillAppliedXaos() override;
virtual void XaosChanged(int x, int y, double val) override;
virtual void ClearXaos() override;
virtual void RandomXaos() override;
virtual void AddLayer(int xforms) override;
virtual void TransposeXaos() override;
void FillXaos() override;
void FillAppliedXaos() override;
void XaosChanged(int x, int y, double val) override;
void ClearXaos() override;
void RandomXaos() override;
void AddLayer(int xforms) override;
void TransposeXaos() override;
//Xforms Selection.
virtual QString MakeXformCaption(size_t i) override;
@ -546,28 +548,28 @@ public:
bool XformCheckboxAt(Xform<T>* xform, std::function<void(QCheckBox*)> func);
//Palette.
virtual size_t InitPaletteList(const QString& s) override;
virtual bool FillPaletteTable(const string& s) override;
virtual void ApplyPaletteToEmber() override;
virtual void PaletteAdjust() override;
virtual void PaletteCellClicked(int row, int col) override;
virtual void SetBasePaletteAndAdjust(const Palette<float>& palette) override;
virtual void PaletteEditorButtonClicked() override;
virtual void PaletteEditorColorChanged() override;
virtual void SyncPalette(bool accepted) override;
size_t InitPaletteList(const QString& s) override;
bool FillPaletteTable(const string& s) override;
void ApplyPaletteToEmber() override;
void PaletteAdjust() override;
void PaletteCellClicked(int row, int col) override;
void SetBasePaletteAndAdjust(const Palette<float>& palette) override;
void PaletteEditorButtonClicked() override;
void PaletteEditorColorChanged() override;
void SyncPalette(bool accepted) override;
//Info.
virtual void FillSummary() override;
virtual void ReorderVariations(QTreeWidgetItem* item) override;
void FillSummary() override;
void ReorderVariations(QTreeWidgetItem* item) override;
//Rendering/progress.
virtual bool Render() override;
virtual bool CreateRenderer(eRendererType renderType, const vector<pair<size_t, size_t>>& devices, bool updatePreviews, bool shared = true) override;
virtual uint SizeOfT() const override { return sizeof(T); }
virtual int ProgressFunc(Ember<T>& ember, void* foo, double fraction, int stage, double etaMs) override;
virtual void ClearUndo() override;
virtual GLEmberControllerBase* GLController() override { return m_GLController.get(); }
virtual void DeleteRenderer() override;
bool Render() override;
bool CreateRenderer(eRendererType renderType, const vector<pair<size_t, size_t>>& devices, bool updatePreviews, bool shared = true) override;
uint SizeOfT() const override { return sizeof(T); }
int ProgressFunc(Ember<T>& ember, void* foo, double fraction, int stage, double etaMs) override;
void ClearUndo() override;
GLEmberControllerBase* GLController() override { return m_GLController.get(); }
void DeleteRenderer() override;
private:
//Embers.
@ -704,7 +706,7 @@ public:
m_PreviewRenderer.YAxisUp(f->m_Settings->YAxisUp());
}
virtual void PreviewRenderFunc(uint start, uint end) override;
void PreviewRenderFunc(uint start, uint end) override;
protected:
FractoriumEmberController<T>* m_Controller;

View File

@ -6,8 +6,8 @@
/// </summary>
void Fractorium::InitInfoUI()
{
auto treeHeader = ui.SummaryTree->header();
auto tableHeader = ui.SummaryTable->horizontalHeader();
const auto treeHeader = ui.SummaryTree->header();
const auto tableHeader = ui.SummaryTable->horizontalHeader();
treeHeader->setVisible(true);
treeHeader->setSectionsClickable(true);
treeHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
@ -44,12 +44,13 @@ void Fractorium::OnSummaryTableHeaderResized(int logicalIndex, int oldSize, int
/// <param name="logicalIndex">The column which was clicked</param>
void Fractorium::OnSummaryTreeHeaderSectionClicked(int logicalIndex)
{
auto tree = ui.SummaryTree;
if (logicalIndex)
tree->expandAll();
else
tree->collapseAll();
if (const auto tree = ui.SummaryTree)
{
if (logicalIndex)
tree->expandAll();
else
tree->collapseAll();
}
}
/// <summary>
@ -66,18 +67,19 @@ void Fractorium::OnSummaryTreeHeaderSectionClicked(int logicalIndex)
template <typename T>
void FractoriumEmberController<T>::FillSummary()
{
int p = 3;
int vp = 4;
int vlen = 7;
char pc = 'f';
bool forceFinal = m_Fractorium->HaveFinal();
size_t x = 0, total = m_Ember.TotalXformCount(forceFinal);
const auto p = 3;
const auto vp = 4;
const auto vlen = 7;
const auto pc = 'f';
const auto forceFinal = m_Fractorium->HaveFinal();
const auto total = m_Ember.TotalXformCount(forceFinal);
const auto table = m_Fractorium->ui.SummaryTable;
const auto nondraggable = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
const auto draggable = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
size_t x = 0;
Xform<T>* xform = nullptr;
QColor color;
auto table = m_Fractorium->ui.SummaryTable;
auto tree = m_Fractorium->ui.SummaryTree;
auto nondraggable = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
auto draggable = Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled;
tree->blockSignals(true);
tree->clear();
m_Fractorium->m_InfoNameItem->setText(m_Ember.m_Name.c_str());
@ -162,7 +164,7 @@ void FractoriumEmberController<T>::FillSummary()
vitem->setText(1, QLocale::system().toString(var->m_Weight, pc, vp).rightJustified(vlen, ' '));
vitem->setFlags(draggable);
if (auto parVar = dynamic_cast<ParametricVariation<T>*>(var))
if (const auto parVar = dynamic_cast<ParametricVariation<T>*>(var))
{
auto params = parVar->Params();
@ -179,7 +181,7 @@ void FractoriumEmberController<T>::FillSummary()
}
}
auto item2 = new QTreeWidgetItem(tree);//Empty item in between xforms.
const auto item2 = new QTreeWidgetItem(tree);//Empty item in between xforms.
}
tree->expandAll();
@ -203,8 +205,8 @@ void Fractorium::FillSummary()
template <typename T>
void FractoriumEmberController<T>::ReorderVariations(QTreeWidgetItem* item)
{
auto tree = m_Fractorium->ui.SummaryTree;
auto xfindex = tree->indexOfTopLevelItem(item) / 2;//Blank lines each count as one.
const auto tree = m_Fractorium->ui.SummaryTree;
const auto xfindex = tree->indexOfTopLevelItem(item) / 2;//Blank lines each count as one.
if (auto xform = m_Ember.GetTotalXform(xfindex))
{
@ -214,7 +216,7 @@ void FractoriumEmberController<T>::ReorderVariations(QTreeWidgetItem* item)
{
int i = 0;
while (auto ch = item->child(i))
while (const auto ch = item->child(i))
{
if (ch->text(0) == tree->LastNonVarField())
{
@ -258,7 +260,7 @@ void Fractorium::UpdateHistogramBounds()
lr.sprintf("LR: %3.3f, %3.3f", r->UpperRightX(), r->LowerLeftY());
ll.sprintf("LL: %3.3f, %3.3f", r->LowerLeftX(), r->LowerLeftY());
wh.sprintf("W x H: %4u x %4u", r->SuperRasW(), r->SuperRasH());
g.sprintf("%u", (uint)r->GutterWidth());
g.sprintf("%u", static_cast<uint>(r->GutterWidth()));
ui.InfoBoundsLabelUL->setText(ul);
ui.InfoBoundsLabelUR->setText(ur);
ui.InfoBoundsLabelLR->setText(lr);
@ -268,7 +270,7 @@ void Fractorium::UpdateHistogramBounds()
if (r->GetDensityFilter())
{
auto deWidth = (r->GetDensityFilter()->FilterWidth() * 2) + 1;
const auto deWidth = (r->GetDensityFilter()->FilterWidth() * 2) + 1;
de.sprintf("%d x %d", deWidth, deWidth);
ui.InfoBoundsTable->item(1, 1)->setText(de);
}

View File

@ -205,7 +205,7 @@ void FractoriumEmberController<T>::FillLibraryTree(int selectIndex)
m_Fractorium->SelectLibraryItem(selectIndex);
m_Fractorium->SyncFileCountToSequenceCount();
RenderLibraryPreviews(0, uint(m_EmberFile.Size()));
RenderLibraryPreviews(0, static_cast<uint>(m_EmberFile.Size()));
tree->expandAll();
}
@ -241,7 +241,7 @@ void FractoriumEmberController<T>::UpdateLibraryTree()
//When adding elements, ensure all indices are sequential.
SyncLibrary(eLibraryUpdate::INDEX);
m_Fractorium->SyncFileCountToSequenceCount();
RenderLibraryPreviews(origChildCount, uint(m_EmberFile.Size()));
RenderLibraryPreviews(origChildCount, static_cast<uint>(m_EmberFile.Size()));
}
}
@ -289,9 +289,9 @@ void FractoriumEmberController<T>::EmberTreeItemChanged(QTreeWidgetItem* item, i
m_LastSaveCurrent = "";//Reset will force the dialog to show on the next save current since the user probably wants a different name.
}
}
else if (auto parentItem = dynamic_cast<QTreeWidgetItem*>(item))
else if (const auto parentItem = dynamic_cast<QTreeWidgetItem*>(item))
{
auto text = parentItem->text(0);
const auto text = parentItem->text(0);
if (text != "")
{
@ -719,7 +719,7 @@ void FractoriumEmberController<T>::SequenceGenerateButtonClicked()
if (rotations > 0)//Store the last result as the flame to interpolate from. This applies for whole or fractional values of opt.Loops().
embers[0] = result;
auto it2 = it;//Need a quick temporary to avoid modifying it which is used in the loop.
auto it2 = it;//Need a quick temporary to avoid modifying it, which is used in the loop.
embers[1] = *(++it2);//Get the next ember to be used with blending below.
const auto blendFrames = randBlend ? m_Rand.Frand<double>(framesBlend, framesBlendMax) : framesBlend;
const auto d = randBlendRot ? m_Rand.Frand<double>(rotsPerBlend, rotsPerBlendMax) : double(rotsPerBlend);

View File

@ -384,26 +384,29 @@ void Fractorium::OnActionOpenExamples(bool checked) { m_Controller->OpenAndPrepF
/// This will first save the current ember back to the opened file in memory before
/// saving it to disk.
/// </summary>
/// <param name="filename">The filename to save the ember to. If empty, use internal variables to determine the filename.</param>
template <typename T>
void FractoriumEmberController<T>::SaveCurrentAsXml()
void FractoriumEmberController<T>::SaveCurrentAsXml(QString filename)
{
QString filename;
auto s = m_Fractorium->m_Settings;
if (s->SaveAutoUnique() && m_LastSaveCurrent != "")
if (filename == "")
{
filename = EmberFile<T>::UniqueFilename(m_LastSaveCurrent);
}
else if (QFile::exists(m_LastSaveCurrent))
{
filename = m_LastSaveCurrent;
}
else
{
if (m_EmberFile.Size() == 1)
filename = m_Fractorium->SetupSaveXmlDialog(m_EmberFile.m_Filename);//If only one ember present, just use parent filename.
if (s->SaveAutoUnique() && m_LastSaveCurrent != "")
{
filename = EmberFile<T>::UniqueFilename(m_LastSaveCurrent);
}
else if (QFile::exists(m_LastSaveCurrent))
{
filename = m_LastSaveCurrent;
}
else
filename = m_Fractorium->SetupSaveXmlDialog(QString::fromStdString(m_Ember.m_Name));//More than one ember present, use individual ember name.
{
if (m_EmberFile.Size() == 1)
filename = m_Fractorium->SetupSaveXmlDialog(m_EmberFile.m_Filename);//If only one ember present, just use parent filename.
else
filename = m_Fractorium->SetupSaveXmlDialog(QString::fromStdString(m_Ember.m_Name));//More than one ember present, use individual ember name.
}
}
if (filename != "")
@ -1053,7 +1056,7 @@ void Fractorium::OnActionFinalRender(bool checked)
m_RenderStatusLabel->setText("Renderer stopped.");
SetupFinalRenderDialog();
if (m_FinalRenderDialog)
if (m_FinalRenderDialog.get())
m_FinalRenderDialog->Show(false);
}
@ -1067,8 +1070,7 @@ void Fractorium::OnFinalRenderClose(int result)
StartRenderTimer(false);//Re-create the renderer and start rendering again.
ui.ActionStartStopRenderer->setChecked(false);//Re-enable any controls that might have been disabled.
OnActionStartStopRenderer(false);
delete m_FinalRenderDialog;
m_FinalRenderDialog = nullptr;
m_FinalRenderDialog.reset();
}
/// <summary>

View File

@ -85,7 +85,7 @@ size_t FractoriumEmberController<T>::InitPaletteList(const QString& s)
}
}
m_Fractorium->ui.PaletteFilenameCombo->model()->sort(0);
m_Fractorium->ui.PaletteFilenameCombo->model()->sort(0);
return m_PaletteList->Size();
}
@ -140,12 +140,12 @@ void Fractorium::OnPaletteFilenameComboChanged(const QString& text)
template <typename T>
void FractoriumEmberController<T>::ApplyPaletteToEmber()
{
uint blur = m_Fractorium->m_PaletteBlurSpin->value();
uint freq = m_Fractorium->m_PaletteFrequencySpin->value();
double sat = double(m_Fractorium->m_PaletteSaturationSpin->value() / 100.0);
double brightness = double(m_Fractorium->m_PaletteBrightnessSpin->value() / 255.0);
double contrast = double(m_Fractorium->m_PaletteContrastSpin->value() > 0 ? (m_Fractorium->m_PaletteContrastSpin->value() * 2) : m_Fractorium->m_PaletteContrastSpin->value()) / 100.0;
double hue = double(m_Fractorium->m_PaletteHueSpin->value()) / 360.0;
const uint blur = m_Fractorium->m_PaletteBlurSpin->value();
const uint freq = m_Fractorium->m_PaletteFrequencySpin->value();
const auto sat = m_Fractorium->m_PaletteSaturationSpin->value() / 100.0;
const auto brightness = m_Fractorium->m_PaletteBrightnessSpin->value() / 255.0;
const auto contrast = m_Fractorium->m_PaletteContrastSpin->value() > 0 ? m_Fractorium->m_PaletteContrastSpin->value() * 2.0 : m_Fractorium->m_PaletteContrastSpin->value() / 100.0;
const auto hue = m_Fractorium->m_PaletteHueSpin->value() / 360.0;
//Use the temp palette as the base and apply the adjustments gotten from the GUI and save the result in the ember palette.
m_TempPalette.MakeAdjustedPalette(m_Ember.m_Palette, m_Fractorium->m_PreviewPaletteRotation, hue, sat, brightness, contrast, blur, freq);
}
@ -159,10 +159,10 @@ void FractoriumEmberController<T>::ApplyPaletteToEmber()
template <typename T>
void FractoriumEmberController<T>::UpdateAdjustedPaletteGUI(Palette<float>& palette)
{
auto xform = CurrentXform();
auto palettePreviewTable = m_Fractorium->ui.PalettePreviewTable;
const auto xform = CurrentXform();
const auto palettePreviewTable = m_Fractorium->ui.PalettePreviewTable;
const auto paletteName = QString::fromStdString(m_Ember.m_Palette.m_Name);
auto previewPaletteItem = palettePreviewTable->item(0, 1);
auto paletteName = QString::fromStdString(m_Ember.m_Palette.m_Name);
if (previewPaletteItem)//This can be null if the palette file was moved or corrupted.
{
@ -173,9 +173,12 @@ void FractoriumEmberController<T>::UpdateAdjustedPaletteGUI(Palette<float>& pale
QPixmap pixmap(QPixmap::fromImage(m_FinalPaletteImage));//Create a QPixmap out of the QImage.
previewPaletteItem->setData(Qt::DecorationRole, pixmap.scaled(QSize(pixmap.width(), palettePreviewTable->rowHeight(0) + 2), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));//Set the pixmap on the palette tab.
m_Fractorium->SetPaletteTableItem(&pixmap, m_Fractorium->ui.XformPaletteRefTable, m_Fractorium->m_PaletteRefItem, 0, 0);//Set the palette ref table on the xforms | color tab.
auto previewNameItem = palettePreviewTable->item(0, 0);
previewNameItem->setText(paletteName);//Finally, set the name of the palette to be both the text and the tooltip.
previewNameItem->setToolTip(paletteName);
if (auto previewNameItem = palettePreviewTable->item(0, 0))
{
previewNameItem->setText(paletteName);//Finally, set the name of the palette to be both the text and the tooltip.
previewNameItem->setToolTip(paletteName);
}
}
//Update the current xform's color and reset the rendering process.
@ -232,7 +235,7 @@ void FractoriumEmberController<T>::SetBasePaletteAndAdjust(const Palette<float>&
template <typename T>
void FractoriumEmberController<T>::PaletteCellClicked(int row, int col)
{
if (auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
if (const auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
SetBasePaletteAndAdjust(*palette);
}
@ -246,9 +249,9 @@ void FractoriumEmberController<T>::PaletteCellClicked(int row, int col)
/// <param name="col">The table column clicked, ignored</param>
void Fractorium::OnPaletteCellClicked(int row, int col)
{
if (auto item = dynamic_cast<PaletteTableWidgetItem*>(ui.PaletteListTable->item(row, 1)))
if (const auto item = dynamic_cast<PaletteTableWidgetItem*>(ui.PaletteListTable->item(row, 1)))
{
auto index = int(item->Index());
const auto index = int(item->Index());
if (m_PreviousPaletteRow != index)
{
@ -338,10 +341,10 @@ void Fractorium::OnPaletteCellDoubleClicked(int row, int col)
void Fractorium::OnPaletteRandomSelectButtonClicked(bool checked)
{
uint i = 0;
int rowCount = ui.PaletteListTable->rowCount();
const auto rowCount = ui.PaletteListTable->rowCount();
if (rowCount > 1)//If only one palette in the current palette file, just use it.
while (((i = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(rowCount)) == uint(m_PreviousPaletteRow)) || i >= uint(rowCount));
while (((i = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(rowCount)) == uint(m_PreviousPaletteRow)) || i >= static_cast<uint>(rowCount));
if (checked)
OnPaletteCellDoubleClicked(i, 1);//Will clear the adjustments.
@ -384,9 +387,9 @@ template <typename T>
void FractoriumEmberController<T>::PaletteEditorButtonClicked()
{
size_t i = 0;
auto ed = m_Fractorium->m_PaletteEditor;
const auto ed = m_Fractorium->m_PaletteEditor.get();
map<size_t, float> colorIndices;
bool forceFinal = m_Fractorium->HaveFinal();
const auto forceFinal = m_Fractorium->HaveFinal();
m_PreviousTempPalette = m_TempPalette; // it's necessary because m_TempPalette is changed when the user make changes in palette editor
ed->SetPalette(m_TempPalette);
@ -419,14 +422,14 @@ bool Fractorium::PaletteChanged()
/// <param name="checked">Ignored</param>
void Fractorium::OnPaletteEditorButtonClicked(bool checked)
{
if (!m_PaletteEditor)
if (!m_PaletteEditor.get())
{
m_PaletteEditor = new PaletteEditor(this);
connect(m_PaletteEditor, SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection);
connect(m_PaletteEditor, SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection);
connect(m_PaletteEditor, SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection);
m_PaletteEditor = std::make_unique<PaletteEditor>(this);
connect(m_PaletteEditor.get(), SIGNAL(PaletteChanged()), this, SLOT(OnPaletteEditorColorChanged()), Qt::QueuedConnection);
connect(m_PaletteEditor.get(), SIGNAL(PaletteFileChanged()), this, SLOT(OnPaletteEditorFileChanged()), Qt::QueuedConnection);
connect(m_PaletteEditor.get(), SIGNAL(ColorIndexChanged(size_t, float)), this, SLOT(OnPaletteEditorColorIndexChanged(size_t, float)), Qt::QueuedConnection);
#ifdef __linux__
connect(m_PaletteEditor, SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection);
connect(m_PaletteEditor.get(), SIGNAL(finished(int)), this, SLOT(OnPaletteEditorFinished(int)), Qt::QueuedConnection);
#endif
}
@ -441,12 +444,11 @@ void Fractorium::OnPaletteEditorButtonClicked(bool checked)
template <typename T>
void FractoriumEmberController<T>::SyncPalette(bool accepted)
{
size_t i = 0;
auto ed = m_Fractorium->m_PaletteEditor;
const auto ed = m_Fractorium->m_PaletteEditor.get();
Palette<float> edPal;
Palette<float> prevPal = m_PreviousTempPalette;
map<size_t, float> colorIndices;
bool forceFinal = m_Fractorium->HaveFinal();
const auto forceFinal = m_Fractorium->HaveFinal();
if (accepted)
{
@ -457,7 +459,7 @@ void FractoriumEmberController<T>::SyncPalette(bool accepted)
if (auto xform = m_Ember.GetTotalXform(index.first, forceFinal))
xform->m_ColorX = index.second;
edPal = ed->GetPalette(int(prevPal.Size()));
edPal = ed->GetPalette(static_cast<int>(prevPal.Size()));
SetBasePaletteAndAdjust(edPal);//This will take care of updating the color index controls.
if (edPal.m_Filename.get() && !edPal.m_Filename->empty())
@ -485,7 +487,7 @@ void FractoriumEmberController<T>::SyncPalette(bool accepted)
template <typename T>
void FractoriumEmberController<T>::PaletteEditorColorChanged()
{
SetBasePaletteAndAdjust(m_Fractorium->m_PaletteEditor->GetPalette(int(m_TempPalette.Size())));
SetBasePaletteAndAdjust(m_Fractorium->m_PaletteEditor->GetPalette(static_cast<int>(m_TempPalette.Size())));
}
void Fractorium::OnPaletteEditorColorChanged()

View File

@ -47,7 +47,7 @@ void Fractorium::InitParamsUI()
comboVals.push_back("Step");
comboVals.push_back("Linear");
SetupCombo(table, this, row, 1, m_PaletteModeCombo, comboVals, SIGNAL(currentIndexChanged(int)), SLOT(OnPaletteModeComboCurrentIndexChanged(int)));
m_PaletteModeCombo->SetCurrentIndexStealth(int(ePaletteMode::PALETTE_LINEAR));
m_PaletteModeCombo->SetCurrentIndexStealth(static_cast<int>(ePaletteMode::PALETTE_LINEAR));
table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
//Geometry.
row = 0;
@ -114,17 +114,18 @@ void Fractorium::InitParamsUI()
comboVals.push_back("Linear");
comboVals.push_back("Smooth");
SetupCombo(table, this, row, 1, m_InterpTypeCombo, comboVals, SIGNAL(currentIndexChanged(int)), SLOT(OnInterpTypeComboCurrentIndexChanged(int)));
m_InterpTypeCombo->SetCurrentIndexStealth(int(eInterp::EMBER_INTERP_SMOOTH));
m_InterpTypeCombo->SetCurrentIndexStealth(static_cast<int>(eInterp::EMBER_INTERP_SMOOTH));
comboVals.clear();
comboVals.push_back("Linear");
comboVals.push_back("Log");
SetupCombo( table, this, row, 1, m_AffineInterpTypeCombo, comboVals, SIGNAL(currentIndexChanged(int)), SLOT(OnAffineInterpTypeComboCurrentIndexChanged(int)));
m_AffineInterpTypeCombo->SetCurrentIndexStealth(int(eAffineInterp::AFFINE_INTERP_LOG));
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_TemporalFilterWidthSpin, spinHeight, 1, 10, 1, SIGNAL(valueChanged(double)), SLOT(OnTemporalFilterWidthChanged(double)), true, 1);
m_AffineInterpTypeCombo->SetCurrentIndexStealth(static_cast<int>(eAffineInterp::AFFINE_INTERP_LOG));
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_TemporalFilterWidthSpin, spinHeight, 1, 10, 1, SIGNAL(valueChanged(double)), SLOT(OnTemporalFilterWidthChanged(double)), true, 1, 1, 1);
comboVals = TemporalFilterCreator<float>::FilterTypes();
SetupCombo( table, this, row, 1, m_TemporalFilterTypeCombo, comboVals, SIGNAL(currentIndexChanged(const QString&)), SLOT(OnTemporalFilterTypeComboCurrentIndexChanged(const QString&)));
m_TemporalFilterTypeCombo->SetCurrentIndexStealth(int(eTemporalFilterType::GAUSSIAN_TEMPORAL_FILTER));
m_TemporalFilterTypeCombo->SetCurrentIndexStealth(static_cast<int>(eTemporalFilterType::BOX_TEMPORAL_FILTER));
table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
SetupSpinner<DoubleSpinBox, double>(table, this, row, 1, m_TemporalFilterExpSpin, spinHeight, 0, 5, 0.1, SIGNAL(valueChanged(double)), SLOT(OnExpChanged(double)), true, 1, 1, 0);
}
/// <summary>
@ -254,12 +255,12 @@ void Fractorium::OnBackgroundColorButtonClicked(bool checked)
template <typename T>
void FractoriumEmberController<T>::BackgroundChanged(const QColor& color)
{
auto itemRow = m_Fractorium->m_BgRow;
auto colorTable = m_Fractorium->ui.ColorTable;
const auto itemRow = m_Fractorium->m_BgRow;
const auto colorTable = m_Fractorium->ui.ColorTable;
const auto r = ToString(color.red());
const auto g = ToString(color.green());
const auto b = ToString(color.blue());
colorTable->item(itemRow, 1)->setBackgroundColor(color);
auto r = ToString(color.red());
auto g = ToString(color.green());
auto b = ToString(color.blue());
colorTable->item(itemRow, 1)->setTextColor(VisibleColor(color));
colorTable->item(itemRow, 1)->setText("rgb(" + r + ", " + g + ", " + b + ")");
UpdateAll([&](Ember<T>& ember, bool isMain)
@ -742,7 +743,7 @@ void FractoriumEmberController<T>::TemporalFilterWidthChanged(double d)
if (!m_Fractorium->ApplyAll())
if (m_EmberFilePointer)
m_EmberFilePointer->m_TemporalFilterWidth = d;
}, false, eProcessAction::NOTHING, m_Fractorium->ApplyAll());//Don't do anything until animation is implemented.
}, false, eProcessAction::NOTHING, m_Fractorium->ApplyAll());
}
void Fractorium::OnTemporalFilterWidthChanged(double d) { m_Controller->TemporalFilterWidthChanged(d); }
@ -763,10 +764,31 @@ void FractoriumEmberController<T>::TemporalFilterTypeChanged(const QString& text
if (!m_Fractorium->ApplyAll())
if (m_EmberFilePointer)
m_EmberFilePointer->m_TemporalFilterType = filter;
}, false, eProcessAction::NOTHING, m_Fractorium->ApplyAll());//Don't do anything until animation is implemented.
}, false, eProcessAction::NOTHING, m_Fractorium->ApplyAll());
}
void Fractorium::OnTemporalFilterTypeComboCurrentIndexChanged(const QString& text) { m_Controller->TemporalFilterTypeChanged(text); }
/// <summary>
/// Set the exponent value for the Exp temporal filter type to be used with animation.
/// Called when the exp value combo box index is changed.
/// Does not reset anything because this is only used for animation.
/// </summary>
/// <param name="text">The name of the temporal filter</param>
template <typename T>
void FractoriumEmberController<T>::ExpChanged(double d)
{
UpdateAll([&](Ember<T>& ember, bool isMain)
{
ember.m_TemporalFilterExp = d;
if (!m_Fractorium->ApplyAll())
if (m_EmberFilePointer)
m_EmberFilePointer->m_TemporalFilterExp = d;
}, false, eProcessAction::NOTHING, m_Fractorium->ApplyAll());
}
void Fractorium::OnExpChanged(double d) { m_Controller->ExpChanged(d); }
/// <summary>
/// Set the center.
/// This updates the spinners as well as the current ember center.
@ -802,7 +824,7 @@ void FractoriumEmberController<T>::FillParamTablesAndPalette()
m_Fractorium->m_ColorDialog->setCurrentColor(QColor(m_Ember.m_Background.r * 255, m_Ember.m_Background.g * 255, m_Ember.m_Background.b * 255));
m_Fractorium->ui.ColorTable->item(m_Fractorium->m_BgRow, 1)->setBackgroundColor(m_Fractorium->m_ColorDialog->currentColor());
BackgroundChanged(m_Fractorium->m_ColorDialog->currentColor());
m_Fractorium->m_PaletteModeCombo->SetCurrentIndexStealth(int(m_Ember.m_PaletteMode));
m_Fractorium->m_PaletteModeCombo->SetCurrentIndexStealth(int{ m_Ember.m_PaletteMode });
m_Fractorium->m_WidthSpin->SetValueStealth(m_Ember.m_FinalRasW);//Geometry.
m_Fractorium->m_HeightSpin->SetValueStealth(m_Ember.m_FinalRasH);
m_Fractorium->m_CenterXSpin->SetValueStealth(m_Ember.m_CenterX);
@ -812,14 +834,15 @@ void FractoriumEmberController<T>::FillParamTablesAndPalette()
m_Fractorium->m_RotateSpin->SetValueStealth(m_Ember.m_Rotate);
m_Fractorium->m_ZPosSpin->SetValueStealth(m_Ember.m_CamZPos);
m_Fractorium->m_PerspectiveSpin->SetValueStealth(m_Ember.m_CamPerspective);
m_Fractorium->m_PitchSpin->SetValueStealth(m_Ember.m_CamPitch * RAD_2_DEG_T);
m_Fractorium->m_YawSpin->SetValueStealth(m_Ember.m_CamYaw * RAD_2_DEG_T);
m_Fractorium->m_PitchSpin->SetValueStealth(double{ m_Ember.m_CamPitch } * RAD_2_DEG_T);
m_Fractorium->m_YawSpin->SetValueStealth(double {m_Ember.m_CamYaw} * RAD_2_DEG_T);
m_Fractorium->m_DepthBlurSpin->SetValueStealth(m_Ember.m_CamDepthBlur);
m_Fractorium->m_BlurCurveSpin->SetValueStealth(m_Ember.m_BlurCurve);
m_Fractorium->m_SpatialFilterWidthSpin->SetValueStealth(m_Ember.m_SpatialFilterRadius);//Filter.
m_Fractorium->m_SpatialFilterTypeCombo->SetCurrentIndexStealth(int(m_Ember.m_SpatialFilterType));
m_Fractorium->m_SpatialFilterTypeCombo->SetCurrentIndexStealth(int{ m_Ember.m_SpatialFilterType });
m_Fractorium->m_TemporalFilterWidthSpin->SetValueStealth(m_Ember.m_TemporalFilterWidth);
m_Fractorium->m_TemporalFilterTypeCombo->SetCurrentIndexStealth(int(m_Ember.m_TemporalFilterType));
m_Fractorium->m_TemporalFilterTypeCombo->SetCurrentIndexStealth(int{ m_Ember.m_TemporalFilterType });
m_Fractorium->m_TemporalFilterExpSpin->SetValueStealth(m_Ember.m_TemporalFilterExp);
m_Fractorium->m_DEFilterMinRadiusSpin->SetValueStealth(m_Ember.m_MinRadDE);
m_Fractorium->m_DEFilterMaxRadiusSpin->SetValueStealth(m_Ember.m_MaxRadDE);
m_Fractorium->m_DECurveSpin->SetValueStealth(m_Ember.m_CurveDE);
@ -828,8 +851,8 @@ void FractoriumEmberController<T>::FillParamTablesAndPalette()
m_Fractorium->m_RandRangeSpin->SetValueStealth(m_Ember.m_RandPointRange);
m_Fractorium->m_QualitySpin->SetValueStealth(m_Ember.m_Quality);
m_Fractorium->m_SupersampleSpin->SetValueStealth(m_Ember.m_Supersample);
m_Fractorium->m_AffineInterpTypeCombo->SetCurrentIndexStealth(int(m_Ember.m_AffineInterp));
m_Fractorium->m_InterpTypeCombo->SetCurrentIndexStealth(int(m_Ember.m_Interp));
m_Fractorium->m_AffineInterpTypeCombo->SetCurrentIndexStealth(int{ m_Ember.m_AffineInterp });
m_Fractorium->m_InterpTypeCombo->SetCurrentIndexStealth(int{ m_Ember.m_Interp });
auto temp = m_Ember.m_Palette.m_Filename;
if (temp.get())
@ -863,7 +886,7 @@ void FractoriumEmberController<T>::ParamsToEmberPrivate(Ember<U>& ember, bool im
ember.m_HighlightPower = m_Fractorium->m_HighlightSpin->value();
ember.m_K2 = m_Fractorium->m_K2Spin->value();
ember.m_SpatialFilterRadius = m_Fractorium->m_SpatialFilterWidthSpin->value();//Filter.
ember.m_SpatialFilterType = eSpatialFilterType(m_Fractorium->m_SpatialFilterTypeCombo->currentIndex());
ember.m_SpatialFilterType = static_cast<eSpatialFilterType>(m_Fractorium->m_SpatialFilterTypeCombo->currentIndex());
ember.m_MinRadDE = m_Fractorium->m_DEFilterMinRadiusSpin->value();
ember.m_MaxRadDE = m_Fractorium->m_DEFilterMaxRadiusSpin->value();
ember.m_CurveDE = m_Fractorium->m_DECurveSpin->value();
@ -872,12 +895,13 @@ void FractoriumEmberController<T>::ParamsToEmberPrivate(Ember<U>& ember, bool im
return;
ember.m_TemporalFilterWidth = m_Fractorium->m_TemporalFilterWidthSpin->value();
ember.m_TemporalFilterType = eTemporalFilterType(m_Fractorium->m_TemporalFilterTypeCombo->currentIndex());
auto color = m_Fractorium->ui.ColorTable->item(5, 1)->backgroundColor();
ember.m_TemporalFilterType = static_cast<eTemporalFilterType>(m_Fractorium->m_TemporalFilterTypeCombo->currentIndex());
ember.m_TemporalFilterExp = m_Fractorium->m_TemporalFilterExpSpin->value();
auto const color = m_Fractorium->ui.ColorTable->item(5, 1)->backgroundColor();
ember.m_Background.r = color.red() / 255.0;
ember.m_Background.g = color.green() / 255.0;
ember.m_Background.b = color.blue() / 255.0;
ember.m_PaletteMode = ePaletteMode(m_Fractorium->m_PaletteModeCombo->currentIndex());
ember.m_PaletteMode = static_cast<ePaletteMode>(m_Fractorium->m_PaletteModeCombo->currentIndex());
ember.m_FinalRasW = m_Fractorium->m_WidthSpin->value();//Geometry.
ember.m_FinalRasH = m_Fractorium->m_HeightSpin->value();
ember.m_CenterX = m_Fractorium->m_CenterXSpin->value();
@ -896,8 +920,8 @@ void FractoriumEmberController<T>::ParamsToEmberPrivate(Ember<U>& ember, bool im
ember.m_RandPointRange = m_Fractorium->m_RandRangeSpin->value();
ember.m_Quality = m_Fractorium->m_QualitySpin->value();
ember.m_Supersample = m_Fractorium->m_SupersampleSpin->value();
ember.m_AffineInterp = eAffineInterp(m_Fractorium->m_AffineInterpTypeCombo->currentIndex());
ember.m_Interp = eInterp(m_Fractorium->m_InterpTypeCombo->currentIndex());
ember.m_AffineInterp = static_cast<eAffineInterp>(m_Fractorium->m_AffineInterpTypeCombo->currentIndex());
ember.m_Interp = static_cast<eInterp>(m_Fractorium->m_InterpTypeCombo->currentIndex());
ember.SyncSize();
}

View File

@ -52,7 +52,7 @@ void FractoriumSettings::EnsureDefaults()
if (FinalThreadCount() == 0 || FinalThreadCount() > Timing::ProcessorCount())
FinalThreadCount(Timing::ProcessorCount());
FinalThreadPriority(Clamp<int>(FinalThreadPriority(), (int)eThreadPriority::LOWEST, (int)eThreadPriority::HIGHEST));
FinalThreadPriority(Clamp<int>(FinalThreadPriority(), static_cast<int>(eThreadPriority::LOWEST), static_cast<int>(eThreadPriority::HIGHEST)));
CpuSubBatch(std::max(1u, CpuSubBatch()));
OpenCLSubBatch(std::max(1u, OpenCLSubBatch()));
@ -73,7 +73,7 @@ void FractoriumSettings::EnsureDefaults()
if (OpenClQuality() == 0)
OpenClQuality(30);
if (FinalScale() > int(eScaleType::SCALE_HEIGHT))
if (FinalScale() > static_cast<int>(eScaleType::SCALE_HEIGHT))
FinalScale(0);
if (OpenXmlExt() == "")
@ -332,7 +332,7 @@ uint FractoriumSettings::FinalSupersample() { return value(FINALSUPERSAM
void FractoriumSettings::FinalSupersample(uint i) { setValue(FINALSUPERSAMPLE, i); }
size_t FractoriumSettings::FinalStrips() { return value(FINALSTRIPS).toULongLong(); }
void FractoriumSettings::FinalStrips(size_t i) { setValue(FINALSTRIPS, uint(i)); }
void FractoriumSettings::FinalStrips(size_t i) { setValue(FINALSTRIPS, static_cast<uint>(i)); }
/// <summary>
/// Xml file saving settings.

View File

@ -37,9 +37,9 @@ void Fractorium::InitXaosUI()
template <typename T>
void FractoriumEmberController<T>::FillXaos()
{
for (int i = 0, count = int(XformCount()); i < count; i++)//Column.
for (int i = 0, count = static_cast<int>(XformCount()); i < count; i++)//Column.
{
if (auto xform = m_Ember.GetXform(i))
if (const auto xform = m_Ember.GetXform(i))
{
for (int j = 0; j < count; j++)//Row.
{
@ -63,7 +63,7 @@ void FractoriumEmberController<T>::FillAppliedXaos()
for (int i = 0, count = int(XformCount()); i < count; i++)//Column.
{
if (auto xform = m_Ember.GetXform(i))
if (const auto xform = m_Ember.GetXform(i))
{
T norm = 0;
double start = 0, offset = 0;
@ -78,11 +78,11 @@ void FractoriumEmberController<T>::FillAppliedXaos()
QPixmap pixmap(m_Fractorium->ui.XaosAppliedTableView->columnWidth(i) - 8, m_Fractorium->ui.XaosTableView->rowHeight(0) * count);
QPainter painter(&pixmap);
auto twi = new QTableWidgetItem();
auto twi = std::make_unique<QTableWidgetItem>();
for (auto& w : tempweights) norm += w;
for (auto& w : tempweights) w = norm == T(0) ? T(0) : w / norm;
for (auto& w : tempweights) w = norm == static_cast<T>(0) ? static_cast<T>(0) : w / norm;
if (norm)
{
@ -99,7 +99,7 @@ void FractoriumEmberController<T>::FillAppliedXaos()
}
twi->setData(Qt::DecorationRole, pixmap);
m_Fractorium->ui.XaosDistVizTableWidget->setItem(0, i, twi);
m_Fractorium->ui.XaosDistVizTableWidget->setItem(0, i, twi.release());
}
}
@ -153,7 +153,7 @@ void Fractorium::OnXaosTableModelDataChanged(const QModelIndex& indexA, const QM
/// </summary>
void Fractorium::FillXaosTable()
{
int count = int(m_Controller->XformCount());
int count = static_cast<int>(m_Controller->XformCount());
QStringList hl, vl, blanks;
auto oldModel = std::make_unique<QStandardItemModel>(m_XaosTableModel);
hl.reserve(count);
@ -235,9 +235,9 @@ void FractoriumEmberController<T>::RandomXaos()
for (size_t j = 0; j < m_Ember.XformCount(); j++)
{
if (!ctrl)
xform->SetXaos(j, T(m_Rand.RandBit()));
xform->SetXaos(j, static_cast<T>(m_Rand.RandBit()));
else if (m_Rand.RandBit())
xform->SetXaos(j, T(m_Rand.RandBit()));
xform->SetXaos(j, static_cast<T>(m_Rand.RandBit()));
else
xform->SetXaos(j, TruncPrecision(m_Rand.Frand<T>(0, 3), 3));
}
@ -287,7 +287,7 @@ void FractoriumEmberController<T>::TransposeXaos()
vector<vector<double>> tempxaos;
tempxaos.reserve(m_Ember.XformCount());
while (auto xform = m_Ember.GetXform(i++))
while (const auto xform = m_Ember.GetXform(i++))
{
vector<double> tempvec;
tempvec.reserve(m_Ember.XformCount());
@ -301,7 +301,7 @@ void FractoriumEmberController<T>::TransposeXaos()
for (j = 0; j < tempxaos.size(); j++)
for (i = 0; i < tempxaos[j].size(); i++)
if (auto xform = m_Ember.GetXform(i))
xform->SetXaos(j, T(tempxaos[j][i]));
xform->SetXaos(j, static_cast<T>(tempxaos[j][i]));
});
FillXaos();
FillAppliedXaos();
@ -317,7 +317,7 @@ void Fractorium::OnTransposeXaosButtonClicked(bool checked) { m_Controller->Tran
/// <param name="logicalIndex">The index of the row that was double clicked</param>
void Fractorium::OnXaosRowDoubleClicked(int logicalIndex)
{
auto btn = QApplication::mouseButtons();
const auto btn = QApplication::mouseButtons();
if (!btn.testFlag(Qt::RightButton))
ToggleTableRow(ui.XaosTableView, logicalIndex);
@ -335,7 +335,7 @@ void Fractorium::OnXaosRowDoubleClicked(int logicalIndex)
/// <param name="logicalIndex">The index of the column that was double clicked</param>
void Fractorium::OnXaosColDoubleClicked(int logicalIndex)
{
auto btn = QApplication::mouseButtons();
const auto btn = QApplication::mouseButtons();
if (!btn.testFlag(Qt::RightButton))
ToggleTableCol(ui.XaosTableView, logicalIndex);

View File

@ -6,7 +6,8 @@
/// </summary>
void Fractorium::InitXformsUI()
{
int spinHeight = 20, row = 0;
const int spinHeight = 20;
auto row = 0;
connect(ui.AddXformButton, SIGNAL(clicked(bool)), this, SLOT(OnAddXformButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.AddLinkedXformButton, SIGNAL(clicked(bool)), this, SLOT(OnAddLinkedXformButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.DuplicateXformButton, SIGNAL(clicked(bool)), this, SLOT(OnDuplicateXformButtonClicked(bool)), Qt::QueuedConnection);
@ -55,8 +56,7 @@ void Fractorium::InitXformsUI()
template <typename T>
Xform<T>* FractoriumEmberController<T>::CurrentXform()
{
bool hasFinal = m_Fractorium->HaveFinal();
return m_Ember.GetTotalXform(m_Fractorium->ui.CurrentXformCombo->currentIndex(), hasFinal);//Need to force final for the special case they created a final, then cleared it, but did not delete it.
return m_Ember.GetTotalXform(m_Fractorium->ui.CurrentXformCombo->currentIndex(), m_Fractorium->HaveFinal());//Need to force final for the special case they created a final, then cleared it, but did not delete it.
}
/// <summary>
@ -65,7 +65,7 @@ Xform<T>* FractoriumEmberController<T>::CurrentXform()
/// <param name="i">The index to set the current xform to</param>
void Fractorium::CurrentXform(uint i)
{
if (i < uint(ui.CurrentXformCombo->count()))
if (i < static_cast<uint>(ui.CurrentXformCombo->count()))
ui.CurrentXformCombo->setCurrentIndex(i);
}
/// <summary>
@ -82,11 +82,10 @@ void FractoriumEmberController<T>::CurrentXformComboChanged(int index)
{
FillWithXform(xform);
m_GLController->SetSelectedXform(xform);
int solo = m_Ember.m_Solo;
m_Fractorium->ui.SoloXformCheckBox->blockSignals(true);
m_Fractorium->ui.SoloXformCheckBox->setChecked(solo == index);
m_Fractorium->ui.SoloXformCheckBox->setChecked(m_Ember.m_Solo == index);
m_Fractorium->ui.SoloXformCheckBox->blockSignals(false);
bool enable = !IsFinal(CurrentXform());
const bool enable = !IsFinal(CurrentXform());
m_Fractorium->ui.DuplicateXformButton->setEnabled(enable);
m_Fractorium->m_XformWeightSpin->setEnabled(enable);
m_Fractorium->ui.SoloXformCheckBox->setEnabled(enable);
@ -114,7 +113,7 @@ void FractoriumEmberController<T>::AddXform()
newXform.m_ColorX = m_Rand.Frand01<T>();
newXform.AddVariation(m_VariationList->GetVariationCopy(eVariationId::VAR_LINEAR));
m_Ember.AddXform(newXform);
int index = int(m_Ember.TotalXformCount(forceFinal) - (forceFinal ? 2 : 1));//Set index to the last item before final.
const int index = static_cast<int>(m_Ember.TotalXformCount(forceFinal) - (forceFinal ? 2 : 1));//Set index to the last item before final.
FillXforms(index);
});
}
@ -138,7 +137,7 @@ template <typename T>
void FractoriumEmberController<T>::AddLinkedXform()
{
bool hasAdded = false;
bool forceFinal = m_Fractorium->HaveFinal();
const auto forceFinal = m_Fractorium->HaveFinal();
auto selCount = m_Fractorium->SelectedXformCount(false);
if (!selCount)//If none explicitly selected, use current.
@ -199,7 +198,7 @@ void FractoriumEmberController<T>::AddLinkedXform()
}
}, eXformUpdate::UPDATE_SELECTED_EXCEPT_FINAL);
//Now update the GUI.
int index = int(m_Ember.TotalXformCount(forceFinal) - (forceFinal ? 2 : 1));//Set index to the last item before final.
const auto index = static_cast<int>(m_Ember.TotalXformCount(forceFinal) - (forceFinal ? 2 : 1));//Set index to the last item before final.
FillXforms(index);
FillXaos();
}
@ -215,12 +214,12 @@ void Fractorium::OnAddLinkedXformButtonClicked(bool checked) { m_Controller->Add
template <typename T>
void FractoriumEmberController<T>::AddXformsWithXaos(Ember<T>& ember, std::vector<std::pair<Xform<T>, size_t>>& xforms, eXaosPasteStyle pastestyle)
{
auto oldxfcount = ember.XformCount();
const auto oldxfcount = ember.XformCount();
for (auto& it : xforms)
{
ember.AddXform(it.first);
auto newxfcount = ember.XformCount() - 1;
const auto newxfcount = ember.XformCount() - 1;
auto* newxform = ember.GetXform(newxfcount);
for (size_t i = 0; i < oldxfcount; i++)
@ -299,7 +298,7 @@ template <typename T>
void FractoriumEmberController<T>::DuplicateXform()
{
bool forceFinal = m_Fractorium->HaveFinal();
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
const bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
vector<std::pair<Xform<T>, size_t>> vec;
vec.reserve(m_Ember.XformCount());
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
@ -347,8 +346,8 @@ void FractoriumEmberController<T>::DeleteXforms()
{
bool removed = false;
bool anyChecked = false;
bool haveFinal = m_Fractorium->HaveFinal();
auto combo = m_Fractorium->ui.CurrentXformCombo;
const bool haveFinal = m_Fractorium->HaveFinal();
const auto combo = m_Fractorium->ui.CurrentXformCombo;
Xform<T>* finalXform = nullptr;
vector<Xform<T>> xformsToKeep;
xformsToKeep.reserve(m_Ember.TotalXformCount());
@ -363,16 +362,16 @@ void FractoriumEmberController<T>::DeleteXforms()
{
if (isFinal)
finalXform = m_Ember.NonConstFinalXform();
else if (auto xform = m_Ember.GetXform(i))
else if (const auto xform = m_Ember.GetXform(i))
xformsToKeep.push_back(*xform);
}
else
anyChecked = true;//At least one was selected for removal.
});
//They might not have selected any checkboxes, in which case just delete the current.
auto current = combo->currentIndex();
auto totalCount = m_Ember.TotalXformCount();
bool keepFinal = finalXform && haveFinal;
const auto current = combo->currentIndex();
const auto totalCount = m_Ember.TotalXformCount();
const auto keepFinal = finalXform && haveFinal;
//Nothing was selected, so just delete current.
if (!anyChecked)
@ -413,7 +412,7 @@ void FractoriumEmberController<T>::DeleteXforms()
if (removed)
{
int index = int(m_Ember.TotalXformCount() - (m_Ember.UseFinalXform() ? 2 : 1));//Set index to the last item before final. Note final is requeried one last time.
const auto index = static_cast<int>(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();
m_Fractorium->ui.GLDisplay->repaint();//Force update because for some reason it doesn't always happen.
@ -444,7 +443,7 @@ void FractoriumEmberController<T>::AddFinalXform()
final.AddVariation(m_VariationList->GetVariationCopy(eVariationId::VAR_LINEAR));//Just a placeholder so other parts of the code don't see it as being empty.
m_Ember.SetFinalXform(final);
int index = int(m_Ember.TotalXformCount() - 1);//Set index to the last item.
const auto index = static_cast<int>(m_Ember.TotalXformCount() - 1);//Set index to the last item.
FillXforms(index);
});
}
@ -494,11 +493,11 @@ void Fractorium::OnEqualWeightButtonClicked(bool checked) { m_Controller->Equali
template <typename T>
void FractoriumEmberController<T>::XformNameChanged(const QString& s)
{
bool forceFinal = m_Fractorium->HaveFinal();
const auto forceFinal = m_Fractorium->HaveFinal();
UpdateXform([&] (Xform<T>* xform, size_t xfindex, size_t selIndex)
{
xform->m_Name = s.toStdString();
XformCheckboxAt(int(xfindex), [&](QCheckBox * checkbox) { checkbox->setText(MakeXformCaption(xfindex)); });
XformCheckboxAt(static_cast<int>(xfindex), [&](QCheckBox * checkbox) { checkbox->setText(MakeXformCaption(xfindex)); });
}, eXformUpdate::UPDATE_CURRENT, false);
FillSummary();//Manually update because this does not trigger a render, which is where this would normally be called.
m_Fractorium->FillXaosTable();
@ -567,7 +566,7 @@ void FractoriumEmberController<T>::FillWithXform(Xform<T>* xform)
m_Fractorium->ui.AnimateXformCheckBox->setChecked(xform->m_Animate > 0 ? true : false);
m_Fractorium->ui.AnimateXformCheckBox->blockSignals(false);
if (auto item = m_Fractorium->ui.XformWeightNameTable->item(0, 1))
if (const auto item = m_Fractorium->ui.XformWeightNameTable->item(0, 1))
{
m_Fractorium->m_XformNameEdit->blockSignals(true);
m_Fractorium->m_XformNameEdit->setText(QString::fromStdString(xform->m_Name));
@ -588,11 +587,11 @@ void FractoriumEmberController<T>::SetNormalizedWeightText(Xform<T>* xform)
{
if (xform)
{
int index = m_Ember.GetXformIndex(xform);
const auto index = m_Ember.GetXformIndex(xform);
m_Ember.CalcNormalizedWeights(m_NormalizedWeights);
if (index != -1 && index < m_NormalizedWeights.size())
m_Fractorium->m_XformWeightSpinnerButtonWidget->m_Label->setText(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")");
if (index != -1 && index < static_cast<intmax_t>(m_NormalizedWeights.size()))
m_Fractorium->m_XformWeightSpinnerButtonWidget->m_Label->setText(QString(" (") + QLocale::system().toString(static_cast<double>(m_NormalizedWeights[index]), 'g', 3) + ")");
}
}
/// <summary>
@ -603,7 +602,7 @@ void FractoriumEmberController<T>::SetNormalizedWeightText(Xform<T>* xform)
template <typename T>
bool FractoriumEmberController<T>::IsFinal(Xform<T>* xform)
{
return (m_Fractorium->HaveFinal() && (xform == m_Ember.FinalXform()));
return m_Fractorium->HaveFinal() && (xform == m_Ember.FinalXform());
}
/// <summary>
/// Fill the xforms combo box with the xforms in the current ember.
@ -615,7 +614,8 @@ bool FractoriumEmberController<T>::IsFinal(Xform<T>* xform)
template <typename T>
void FractoriumEmberController<T>::FillXforms(int index)
{
int i = 0, count = int(XformCount());
int i = 0;
const auto count = static_cast<int>(XformCount());
auto combo = m_Fractorium->ui.CurrentXformCombo;
combo->blockSignals(true);
combo->clear();
@ -637,8 +637,8 @@ void FractoriumEmberController<T>::FillXforms(int index)
{
if (i < count - 1)
{
auto cb1 = new QCheckBox(MakeXformCaption(i), m_Fractorium);
auto cb2 = new QCheckBox(MakeXformCaption(i + 1), m_Fractorium);
const auto cb1 = new QCheckBox(MakeXformCaption(i), m_Fractorium);
const auto cb2 = new QCheckBox(MakeXformCaption(i + 1), m_Fractorium);
QObject::connect(cb1, &QCheckBox::stateChanged, [&](int state) { m_Fractorium->ui.GLDisplay->update(); });//Ensure circles are drawn immediately after toggle.
QObject::connect(cb2, &QCheckBox::stateChanged, [&](int state) { m_Fractorium->ui.GLDisplay->update(); });
m_Fractorium->m_XformSelections.push_back(cb1);
@ -648,7 +648,7 @@ void FractoriumEmberController<T>::FillXforms(int index)
}
else if (i < count)
{
auto cb = new QCheckBox(MakeXformCaption(i), m_Fractorium);
const auto cb = new QCheckBox(MakeXformCaption(i), m_Fractorium);
QObject::connect(cb, &QCheckBox::stateChanged, [&](int state) { m_Fractorium->ui.GLDisplay->update(); });
m_Fractorium->m_XformSelections.push_back(cb);
m_Fractorium->m_XformsSelectionLayout->addRow(cb, new QWidget(m_Fractorium));
@ -659,7 +659,7 @@ void FractoriumEmberController<T>::FillXforms(int index)
//Special case for final xform.
if (UseFinalXform())
{
auto cb = new QCheckBox(MakeXformCaption(i), m_Fractorium);
const auto cb = new QCheckBox(MakeXformCaption(i), m_Fractorium);
QObject::connect(cb, &QCheckBox::stateChanged, [&](int state) { m_Fractorium->ui.GLDisplay->update(); });
m_Fractorium->m_XformSelections.push_back(cb);
m_Fractorium->m_XformsSelectionLayout->addRow(cb, new QWidget(m_Fractorium));
@ -694,20 +694,20 @@ void FractoriumEmberController<T>::FillXforms(int index)
template<typename T>
void FractoriumEmberController<T>::UpdateXformName(int index)
{
bool forceFinal = m_Fractorium->HaveFinal();
bool isFinal = m_Ember.FinalXform() == m_Ember.GetTotalXform(index, forceFinal);
const auto forceFinal = m_Fractorium->HaveFinal();
const auto isFinal = m_Ember.FinalXform() == m_Ember.GetTotalXform(index, forceFinal);
QString name = isFinal ? "Final" : QString::number(index + 1);
if (auto xform = m_Ember.GetTotalXform(index, forceFinal))
if (const auto xform = m_Ember.GetTotalXform(index, forceFinal))
{
if (!xform->m_Name.empty())
name += " " + QString::fromStdString(xform->m_Name);
m_Fractorium->ui.CurrentXformCombo->setItemText(index, name);
auto view = m_Fractorium->ui.CurrentXformCombo->view();
auto fontMetrics1 = view->fontMetrics();
const auto view = m_Fractorium->ui.CurrentXformCombo->view();
const auto fontMetrics1 = view->fontMetrics();
const auto ww = fontMetrics1.width("WW") * 3;
auto textWidth = m_Fractorium->ui.CurrentXformCombo->width();
auto ww = fontMetrics1.width("WW") * 3;
for (int i = 0; i < m_Fractorium->ui.CurrentXformCombo->count(); ++i)
textWidth = std::max(fontMetrics1.width(m_Fractorium->ui.CurrentXformCombo->itemText(i)) + ww, textWidth);

View File

@ -6,8 +6,11 @@
/// </summary>
void Fractorium::InitXformsAffineUI()
{
int affinePrec = 6, spinHeight = 20;
double affineStep = 0.01, affineMin = std::numeric_limits<double>::lowest(), affineMax = std::numeric_limits<double>::max();
const auto affinePrec = 6;
const auto spinHeight = 20;
const auto affineStep = 0.01;
const auto affineMin = std::numeric_limits<double>::lowest();
const auto affineMax = std::numeric_limits<double>::max();
auto table = ui.PreAffineTable;
table->verticalHeader()->setVisible(true);//The designer continually clobbers these values, so must manually set them here.
table->horizontalHeader()->setVisible(true);
@ -394,9 +397,9 @@ void Fractorium::OnRotate90CcButtonClicked(bool checked) { m_Controller->RotateX
void Fractorium::OnRotateCButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreRotateCButton;
auto combo = pre ? ui.PreRotateCombo : ui.PostRotateCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreRotateCButton;
const auto combo = pre ? ui.PreRotateCombo : ui.PostRotateCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->RotateXformsByAngle(d, pre);
@ -411,9 +414,9 @@ void Fractorium::OnRotateCButtonClicked(bool checked)
void Fractorium::OnRotateCcButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreRotateCcButton;
auto combo = pre ? ui.PreRotateCombo : ui.PostRotateCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreRotateCcButton;
const auto combo = pre ? ui.PreRotateCombo : ui.PostRotateCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->RotateXformsByAngle(-d, pre);
@ -447,9 +450,9 @@ void FractoriumEmberController<T>::MoveXforms(double x, double y, bool pre)
void Fractorium::OnMoveUpButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreMoveUpButton;
auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreMoveUpButton;
const auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->MoveXforms(0, m_Settings->YAxisUp() ? d : -d, pre);
@ -464,9 +467,9 @@ void Fractorium::OnMoveUpButtonClicked(bool checked)
void Fractorium::OnMoveDownButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreMoveDownButton;
auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreMoveDownButton;
const auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->MoveXforms(0, m_Settings->YAxisUp() ? -d : d, pre);
@ -481,9 +484,9 @@ void Fractorium::OnMoveDownButtonClicked(bool checked)
void Fractorium::OnMoveLeftButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreMoveLeftButton;
auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreMoveLeftButton;
const auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->MoveXforms(-d, 0, pre);
@ -498,9 +501,9 @@ void Fractorium::OnMoveLeftButtonClicked(bool checked)
void Fractorium::OnMoveRightButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreMoveRightButton;
auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreMoveRightButton;
const auto combo = pre ? ui.PreMoveCombo : ui.PostMoveCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->MoveXforms(d, 0, pre);
@ -535,9 +538,9 @@ void FractoriumEmberController<T>::ScaleXforms(double scale, bool pre)
void Fractorium::OnScaleDownButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreScaleDownButton;
auto combo = pre ? ui.PreScaleCombo : ui.PostScaleCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreScaleDownButton;
const auto combo = pre ? ui.PreScaleCombo : ui.PostScaleCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->ScaleXforms(1.0 / (d / 100.0), pre);
@ -552,9 +555,9 @@ void Fractorium::OnScaleDownButtonClicked(bool checked)
void Fractorium::OnScaleUpButtonClicked(bool checked)
{
bool ok;
bool pre = sender() == ui.PreScaleUpButton;
auto combo = pre ? ui.PreScaleCombo : ui.PostScaleCombo;
double d = ToDouble(combo->currentText(), &ok);
const auto pre = sender() == ui.PreScaleUpButton;
const auto combo = pre ? ui.PreScaleCombo : ui.PostScaleCombo;
const auto d = ToDouble(combo->currentText(), &ok);
if (ok)
m_Controller->ScaleXforms(d / 100.0, pre);
@ -586,7 +589,7 @@ void Fractorium::OnResetAffineButtonClicked(bool checked) { m_Controller->ResetX
template <typename T>
void FractoriumEmberController<T>::CopyXformsAffine(bool pre)
{
if (auto xform = CurrentXform())
if (const auto xform = CurrentXform())
m_CopiedAffine = pre ? xform->m_Affine : xform->m_Post;
}
@ -707,8 +710,8 @@ void FractoriumEmberController<T>::SwapAffines()
{
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto pre = xform->m_Affine;
auto post = xform->m_Post;
const auto pre = xform->m_Affine;
const auto post = xform->m_Post;
xform->m_Affine = post;
xform->m_Post = pre;
}, eXformUpdate::UPDATE_SELECTED);
@ -739,10 +742,10 @@ void Fractorium::OnAffineDrawAllCurrentRadioButtonToggled(bool checked)
/// <param name="state">The state of the checkbox</param>
void Fractorium::OnPolarAffineCheckBoxStateChanged(int state)
{
double mult = state ? 100 : 0.01;
double step = m_PreX1Spin->Step() * mult;
double small = m_PreX1Spin->SmallStep() * mult;
double click = state ? 90 : 1;
const auto mult = state ? 100 : 0.01;
const auto step = m_PreX1Spin->Step() * mult;
const auto small = m_PreX1Spin->SmallStep() * mult;
const auto click = state ? 90 : 1;
for (int i = 0; i < 3; i++)
{

View File

@ -6,7 +6,8 @@
/// </summary>
void Fractorium::InitXformsColorUI()
{
int spinHeight = 20, row = 0;
const auto spinHeight = 20;
auto row = 0;
m_XformColorValueItem = new QTableWidgetItem();
//Can't set this in the designer, so do it here.
m_XformColorValueItem->setToolTip("The index in the palette the current xform uses.\r\n\r\n"
@ -47,7 +48,7 @@ void Fractorium::InitXformsColorUI()
template <typename T>
void FractoriumEmberController<T>::XformColorIndexChanged(double d, bool updateRender, bool updateSpinner, bool updateScroll, eXformUpdate update, size_t index)
{
bool updateGUI = update != eXformUpdate::UPDATE_SPECIFIC || index == m_Fractorium->ui.CurrentXformCombo->currentIndex();
const auto updateGUI = update != eXformUpdate::UPDATE_SPECIFIC || index == m_Fractorium->ui.CurrentXformCombo->currentIndex();
if (updateRender)//False when just updating GUI in response to a change elsewhere, true when in response to a GUI change so update values and reset renderer.
{
@ -65,8 +66,8 @@ void FractoriumEmberController<T>::XformColorIndexChanged(double d, bool updateR
if (updateScroll && updateGUI)
{
auto scroll = m_Fractorium->ui.XformColorScroll;
int scrollVal = d * scroll->maximum();
const auto scroll = m_Fractorium->ui.XformColorScroll;
const auto scrollVal = d * scroll->maximum();
scroll->blockSignals(true);
scroll->setValue(scrollVal);
scroll->blockSignals(false);
@ -88,7 +89,7 @@ void Fractorium::OnXformColorIndexChanged(double d, bool updateRender, bool upda
/// <param name="d">The color index, 0-1.</param>
void Fractorium::OnXformScrollColorIndexChanged(int d)
{
OnXformColorIndexChanged(d / double(ui.XformColorScroll->maximum()), true, true, false);//Update spinner, but not scrollbar. Trigger render update.
OnXformColorIndexChanged(d / static_cast<double>(ui.XformColorScroll->maximum()), true, true, false);//Update spinner, but not scrollbar. Trigger render update.
}
/// <summary>
@ -113,7 +114,7 @@ template <typename T>
void FractoriumEmberController<T>::ToggleColorIndicesButtonClicked()
{
char ch = 1;
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex) { xform->m_ColorX = T(ch ^= 1); }, eXformUpdate::UPDATE_ALL, false);//Don't update renderer here...
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex) { xform->m_ColorX = static_cast<T>(ch ^= 1); }, eXformUpdate::UPDATE_ALL, false);//Don't update renderer here...
m_Fractorium->m_XformColorIndexSpin->setValue(CurrentXform()->m_ColorX);//...do it via GUI. This will set scrollbar value as well.
}
void Fractorium::OnToggleColorIndicesButtonClicked(bool b) { m_Controller->ToggleColorIndicesButtonClicked(); }
@ -140,7 +141,7 @@ template <typename T>
void FractoriumEmberController<T>::ToggleColorSpeedsButtonClicked()
{
char ch = 1;
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex) { xform->m_ColorSpeed = (T(ch ^= 1) ? 0.5 : 0.0); }, eXformUpdate::UPDATE_ALL);
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex) { xform->m_ColorSpeed = static_cast<T>((ch ^= 1) ? 0.5 : 0.0); }, eXformUpdate::UPDATE_ALL);
m_Fractorium->m_XformColorSpeedSpin->SetValueStealth(CurrentXform()->m_ColorSpeed);
}
void Fractorium::OnToggleColorSpeedsButtonClicked(bool b) { m_Controller->ToggleColorSpeedsButtonClicked(); }
@ -233,7 +234,7 @@ QColor FractoriumEmberController<T>::ColorIndexToQColor(double d)
entry.r *= 255;
entry.g *= 255;
entry.b *= 255;
QRgb rgb = uint(entry.r) << 16 | uint(entry.g) << 8 | uint(entry.b);
QRgb rgb = static_cast<uint>(entry.r) << 16 | static_cast<uint>(entry.g) << 8 | static_cast<uint>(entry.b);
return QColor::fromRgb(rgb);
}
@ -264,7 +265,7 @@ void Fractorium::SetPaletteTableItem(QPixmap* pixmap, QTableWidget* table, QTabl
{
if (pixmap && !pixmap->isNull())
{
QSize size(table->columnWidth(col), table->rowHeight(row) + 1);
const QSize size(table->columnWidth(col), table->rowHeight(row) + 1);
item->setData(Qt::DecorationRole, pixmap->scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
}
}

View File

@ -6,7 +6,7 @@
/// </summary>
void Fractorium::InitXformsSelectUI()
{
m_XformsSelectionLayout = (QFormLayout*)ui.XformsSelectGroupBoxScrollAreaWidget->layout();
m_XformsSelectionLayout = dynamic_cast<QFormLayout*>(ui.XformsSelectGroupBoxScrollAreaWidget->layout());
connect(ui.XformsSelectAllButton, SIGNAL(clicked(bool)), this, SLOT(OnXformsSelectAllButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.XformsSelectNoneButton, SIGNAL(clicked(bool)), this, SLOT(OnXformsSelectNoneButtonClicked(bool)), Qt::QueuedConnection);
ClearXformsSelections();
@ -32,7 +32,7 @@ void Fractorium::OnXformsSelectNoneButtonClicked(bool checked) { ForEachXformChe
bool Fractorium::IsXformSelected(size_t i)
{
if (i < m_XformSelections.size())
if (auto w = m_XformSelections[i])
if (const auto w = m_XformSelections[i])
return w->isChecked();
return false;
@ -45,7 +45,7 @@ bool Fractorium::IsXformSelected(size_t i)
/// <returns>The caption string</returns>
int Fractorium::SelectedXformCount(bool includeFinal)
{
int selCount = 0;
auto selCount = 0;
ForEachXformCheckbox([&](int index, QCheckBox * cb, bool isFinal)
{
if (cb->isChecked())
@ -86,11 +86,11 @@ void Fractorium::ClearXformsSelections()
template <typename T>
QString FractoriumEmberController<T>::MakeXformCaption(size_t i)
{
bool forceFinal = m_Fractorium->HaveFinal();
bool isFinal = m_Ember.FinalXform() == m_Ember.GetTotalXform(i, forceFinal);
const auto forceFinal = m_Fractorium->HaveFinal();
const auto isFinal = m_Ember.FinalXform() == m_Ember.GetTotalXform(i, forceFinal);
QString caption = isFinal ? "Final" : QString::number(i + 1);
if (auto xform = m_Ember.GetTotalXform(i, forceFinal))
if (const auto xform = m_Ember.GetTotalXform(i, forceFinal))
if (!xform->m_Name.empty())
caption += " (" + QString::fromStdString(xform->m_Name) + ")";
@ -104,7 +104,7 @@ QString FractoriumEmberController<T>::MakeXformCaption(size_t i)
void Fractorium::ForEachXformCheckbox(std::function<void(int, QCheckBox*, bool)> func)
{
int i = 0;
bool haveFinal = HaveFinal();
const auto haveFinal = HaveFinal();
for (auto& cb : m_XformSelections)
func(i++, cb, haveFinal && cb == m_XformSelections.back());
@ -121,7 +121,7 @@ bool FractoriumEmberController<T>::XformCheckboxAt(int i, std::function<void(QCh
{
if (i < m_Fractorium->m_XformSelections.size())
{
if (auto w = m_Fractorium->m_XformSelections[i])
if (const auto w = m_Fractorium->m_XformSelections[i])
{
func(w);
return true;
@ -141,7 +141,7 @@ bool FractoriumEmberController<T>::XformCheckboxAt(int i, std::function<void(QCh
template <typename T>
bool FractoriumEmberController<T>::XformCheckboxAt(Xform<T>* xform, std::function<void(QCheckBox*)> func)
{
bool forceFinal = m_Fractorium->HaveFinal();
const auto forceFinal = m_Fractorium->HaveFinal();
return XformCheckboxAt(m_Ember.GetTotalXformIndex(xform, forceFinal), func);
}

View File

@ -6,7 +6,7 @@
/// </summary>
void Fractorium::InitXformsVariationsUI()
{
auto tree = ui.VariationsTree;
const auto tree = ui.VariationsTree;
tree->clear();
tree->header()->setSectionsClickable(true);
connect(tree->header(), SIGNAL(sectionClicked(int)), this, SLOT(OnTreeHeaderSectionClicked(int)));
@ -48,9 +48,9 @@ void Fractorium::OnActionVariationsDialog(bool checked)
template <typename T>
void FractoriumEmberController<T>::Filter(const QString& text)
{
auto& ids = m_Fractorium->m_VarDialog->Map();
auto tree = m_Fractorium->ui.VariationsTree;
auto xform = CurrentXform();
const auto& ids = m_Fractorium->m_VarDialog->Map();
const auto tree = m_Fractorium->ui.VariationsTree;
const auto xform = CurrentXform();
tree->setUpdatesEnabled(false);
for (int i = 0; i < tree->topLevelItemCount(); i++)
@ -86,12 +86,12 @@ void Fractorium::Filter()
template <typename T>
void FractoriumEmberController<T>::FilteredVariations()
{
auto& map = m_Fractorium->m_VarDialog->Map();
const auto& map = m_Fractorium->m_VarDialog->Map();
m_FilteredVariations.clear();
m_FilteredVariations.reserve(map.size());
for (auto i = 0; i < m_VariationList->Size(); i++)
if (auto var = m_VariationList->GetVariation(i))
if (const auto var = m_VariationList->GetVariation(i))
if (map.contains(var->Name().c_str()) && map[var->Name().c_str()].toBool())
m_FilteredVariations.push_back(var->VariationId());
}
@ -107,9 +107,9 @@ void FractoriumEmberController<T>::SetupVariationsTree()
{
T fMin = TLOW;
T fMax = TMAX;
QSize hint0(170, 16);
QSize hint1(80, 16);
QSize hint2(20, 16);
const QSize hint0(170, 16);
const QSize hint1(80, 16);
const QSize hint2(20, 16);
static vector<string> dc{ "m_ColorX" };
static vector<string> assign{ "outPoint->m_X =", "outPoint->m_Y =", "outPoint->m_Z =",
"outPoint->m_X=", "outPoint->m_Y=", "outPoint->m_Z=" };
@ -208,18 +208,21 @@ void FractoriumEmberController<T>::SetupVariationsTree()
template <typename T>
void FractoriumEmberController<T>::ClearVariationsTree()
{
auto tree = m_Fractorium->ui.VariationsTree;
const auto tree = m_Fractorium->ui.VariationsTree;
for (int i = 0; i < tree->topLevelItemCount(); i++)
{
auto item = tree->topLevelItem(i);
auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item, 1));
spinBox->SetValueStealth(0);
const auto item = tree->topLevelItem(i);
for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params.
if (auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item, 1)))
{
if ((spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item->child(j), 1))))//Cast the child widget to the VariationTreeDoubleSpinBox type.
spinBox->SetValueStealth(0);
spinBox->SetValueStealth(0);
for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params.
{
if (const auto varSpinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item->child(j), 1)))//Cast the child widget to the VariationTreeDoubleSpinBox type.
varSpinBox->SetValueStealth(0);
}
}
}
}
@ -235,24 +238,24 @@ template <typename T>
void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would be awesome to make this work for all.//TODO
{
bool update = false;
auto objSender = m_Fractorium->sender();
auto tree = m_Fractorium->ui.VariationsTree;
auto sender = dynamic_cast<VariationTreeDoubleSpinBox*>(objSender);
const auto objSender = m_Fractorium->sender();
const auto tree = m_Fractorium->ui.VariationsTree;
const auto sender = dynamic_cast<VariationTreeDoubleSpinBox*>(objSender);
if (sender)
{
UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto var = m_VariationList->GetVariation(sender->GetVariationId());//The variation attached to the sender, for reference only.
auto parVar = dynamic_cast<const ParametricVariation<T>*>(var);//The parametric cast of that variation.
auto xformVar = xform->GetVariationById(var->VariationId());//The corresponding variation in the currently selected xform.
auto widgetItem = sender->WidgetItem();
bool isParam = parVar && sender->IsParam();
const auto var = m_VariationList->GetVariation(sender->GetVariationId());//The variation attached to the sender, for reference only.
const auto parVar = dynamic_cast<const ParametricVariation<T>*>(var);//The parametric cast of that variation.
const auto xformVar = xform->GetVariationById(var->VariationId());//The corresponding variation in the currently selected xform.
const auto widgetItem = sender->WidgetItem();
const auto isParam = parVar && sender->IsParam();
if (isParam)
{
//Do not take action if the xform doesn't contain the variation which this param is part of.
if (auto xformParVar = dynamic_cast<ParametricVariation<T>*>(xformVar))//The parametric cast of the xform's variation.
if (const auto xformParVar = dynamic_cast<ParametricVariation<T>*>(xformVar))//The parametric cast of the xform's variation.
if (xformParVar->SetParamVal(sender->ParamName().c_str(), d))
update = true;
}
@ -278,7 +281,7 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would
{
//If the item wasn't a param and the xform did not contain this variation,
//it means they went from zero to a non-zero weight, so add a new copy of this xform.
auto newVar = var->Copy();//Create a new one with default values.
const auto newVar = var->Copy();//Create a new one with default values.
newVar->m_Weight = d;
xform->AddVariation(newVar);
widgetItem->setTextColor(0, m_Fractorium->m_VariationTreeColorNonZero);
@ -288,14 +291,14 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would
//for the child parameters and assign them to the newly added variation.
if (parVar)
{
auto newParVar = dynamic_cast<ParametricVariation<T>*>(newVar);
const auto newParVar = dynamic_cast<ParametricVariation<T>*>(newVar);
for (int i = 0; i < widgetItem->childCount(); i++)//Iterate through all of the children, which will be the params.
{
auto childItem = widgetItem->child(i);//Get the child.
auto itemWidget = tree->itemWidget(childItem, 1);//Get the widget for the child.
const auto childItem = widgetItem->child(i);//Get the child.
const auto itemWidget = tree->itemWidget(childItem, 1);//Get the widget for the child.
if (auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget))//Cast the widget to the VariationTreeDoubleSpinBox type.
if (const auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget))//Cast the widget to the VariationTreeDoubleSpinBox type.
{
string s = childItem->text(0).toStdString();//Use the name of the child, and the value of the spinner widget to assign the param.
newParVar->SetParamVal(s.c_str(), spinBox->value());
@ -333,18 +336,18 @@ void FractoriumEmberController<T>::FillVariationTreeWithCurrentXform()
template <typename T>
void FractoriumEmberController<T>::FillVariationTreeWithXform(Xform<T>* xform)
{
auto tree = m_Fractorium->ui.VariationsTree;
const auto tree = m_Fractorium->ui.VariationsTree;
tree->blockSignals(true);
m_Fractorium->Filter();
for (int i = 0; i < tree->topLevelItemCount(); i++)
{
auto item = dynamic_cast<VariationTreeWidgetItem*>(tree->topLevelItem(i));
auto var = xform->GetVariationById(item->Id());//See if this variation in the tree was contained in the xform.
auto parVar = dynamic_cast<ParametricVariation<T>*>(var);//Attempt cast to parametric variation for later.
auto origParVar = dynamic_cast<const ParametricVariation<T>*>(m_VariationList->GetVariation(item->Id()));
const auto item = dynamic_cast<VariationTreeWidgetItem*>(tree->topLevelItem(i));
const auto var = xform->GetVariationById(item->Id());//See if this variation in the tree was contained in the xform.
const auto parVar = dynamic_cast<ParametricVariation<T>*>(var);//Attempt cast to parametric variation for later.
const auto origParVar = dynamic_cast<const ParametricVariation<T>*>(m_VariationList->GetVariation(item->Id()));
if (auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item, 1)))//Get the widget for the item, and cast the widget to the VariationTreeDoubleSpinBox type.
if (const auto spinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(tree->itemWidget(item, 1)))//Get the widget for the item, and cast the widget to the VariationTreeDoubleSpinBox type.
{
if (var)//Ensure it's visible, even if it's supposed to be filtered.
item->setHidden(false);
@ -356,10 +359,10 @@ void FractoriumEmberController<T>::FillVariationTreeWithXform(Xform<T>* xform)
for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params if it was a parametric variation.
{
T* param = nullptr;
auto childItem = item->child(j);//Get the child.
auto childItemWidget = tree->itemWidget(childItem, 1);//Get the widget for the child.
const auto childItem = item->child(j);//Get the child.
const auto childItemWidget = tree->itemWidget(childItem, 1);//Get the widget for the child.
if (auto childSpinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(childItemWidget))//Cast the widget to the VariationTreeDoubleSpinBox type.
if (const auto childSpinBox = dynamic_cast<VariationTreeDoubleSpinBox*>(childItemWidget))//Cast the widget to the VariationTreeDoubleSpinBox type.
{
string s = childItem->text(0).toStdString();//Get the name of the child.

View File

@ -35,7 +35,7 @@ template <typename T>
GLEmberController<T>::GLEmberController(Fractorium* fractorium, GLWidget* glWidget, FractoriumEmberController<T>* controller)
: GLEmberControllerBase(fractorium, glWidget)
{
GridStep = T(1.0 / 4.0); // michel, needs to insert on GUI to be flexible//TODO
GridStep = static_cast<T>(1.0 / 4.0); // michel, needs to insert on GUI to be flexible//TODO
m_FractoriumEmberController = controller;
m_HoverXform = nullptr;
m_SelectedXform = nullptr;
@ -58,7 +58,7 @@ GLEmberController<T>::~GLEmberController() { }
template <typename T>
bool GLEmberController<T>::CheckForSizeMismatch(int w, int h)
{
return (m_FractoriumEmberController->FinalRasW() != w || m_FractoriumEmberController->FinalRasH() != h);
return m_FractoriumEmberController->FinalRasW() != w || m_FractoriumEmberController->FinalRasH() != h;
}
/// <summary>
@ -82,11 +82,11 @@ T GLEmberController<T>::CalcScale()
{
//Can't operate using world coords here because every time scale changes, the world bounds change.
//So must instead calculate distance traveled based on window coords, which do not change outside of resize events.
auto windowCenter = ScrolledCenter(false);
v2T windowMousePosDistanceFromCenter(m_MousePos.x - windowCenter.x, m_MousePos.y - windowCenter.y);
v2T windowMouseDownDistanceFromCenter(m_MouseDownPos.x - windowCenter.x, m_MouseDownPos.y - windowCenter.y);
T lengthMousePosFromCenterInPixels = glm::length(windowMousePosDistanceFromCenter);
T lengthMouseDownFromCenterInPixels = glm::length(windowMouseDownDistanceFromCenter);
const auto windowCenter = ScrolledCenter(false);
const v2T windowMousePosDistanceFromCenter(m_MousePos.x - windowCenter.x, m_MousePos.y - windowCenter.y);
const v2T windowMouseDownDistanceFromCenter(m_MouseDownPos.x - windowCenter.x, m_MouseDownPos.y - windowCenter.y);
const T lengthMousePosFromCenterInPixels = glm::length(windowMousePosDistanceFromCenter);
const T lengthMouseDownFromCenterInPixels = glm::length(windowMouseDownDistanceFromCenter);
return lengthMousePosFromCenterInPixels - lengthMouseDownFromCenterInPixels;
}
@ -98,9 +98,9 @@ T GLEmberController<T>::CalcScale()
template <typename T>
T GLEmberController<T>::CalcRotation()
{
auto scrolledWorldCenter = ScrolledCenter(true);
T rotStart = NormalizeDeg180<T>((std::atan2(m_MouseDownWorldPos.y - scrolledWorldCenter.y, m_MouseDownWorldPos.x - scrolledWorldCenter.x) * RAD_2_DEG_T));
T rot = NormalizeDeg180<T>((std::atan2(m_MouseWorldPos.y - scrolledWorldCenter.y, m_MouseWorldPos.x - scrolledWorldCenter.x) * RAD_2_DEG_T));
const auto scrolledWorldCenter = ScrolledCenter(true);
const T rotStart = NormalizeDeg180<T>((std::atan2(m_MouseDownWorldPos.y - scrolledWorldCenter.y, m_MouseDownWorldPos.x - scrolledWorldCenter.x) * RAD_2_DEG_T));
const T rot = NormalizeDeg180<T>((std::atan2(m_MouseWorldPos.y - scrolledWorldCenter.y, m_MouseWorldPos.x - scrolledWorldCenter.x) * RAD_2_DEG_T));
return rotStart - rot;
}
@ -113,11 +113,11 @@ T GLEmberController<T>::CalcRotation()
template <typename T>
v3T GLEmberController<T>::ScrolledCenter(bool toWorld)
{
auto dprf = m_GL->devicePixelRatioF();
auto wpsa = m_Fractorium->ui.GLParentScrollArea->width();
auto hpsa = m_Fractorium->ui.GLParentScrollArea->height();
auto hpos = m_Fractorium->ui.GLParentScrollArea->horizontalScrollBar()->value();
auto vpos = m_Fractorium->ui.GLParentScrollArea->verticalScrollBar()->value();
const auto dprf = m_GL->devicePixelRatioF();
const auto wpsa = m_Fractorium->ui.GLParentScrollArea->width();
const auto hpsa = m_Fractorium->ui.GLParentScrollArea->height();
const auto hpos = m_Fractorium->ui.GLParentScrollArea->horizontalScrollBar()->value();
const auto vpos = m_Fractorium->ui.GLParentScrollArea->verticalScrollBar()->value();
v3T v;
if (!m_Fractorium->ui.GLParentScrollArea->horizontalScrollBar()->isVisible() && !m_Fractorium->ui.GLParentScrollArea->verticalScrollBar()->isVisible())
@ -141,12 +141,9 @@ v3T GLEmberController<T>::ScrolledCenter(bool toWorld)
/// <param name="vec">The world cartesian coordinate to be snapped</param>
/// <returns>The snapped world cartesian coordinate</returns>
template <typename T>
typename v2T GLEmberController<T>::SnapToGrid(v2T& vec)
typename v2T GLEmberController<T>::SnapToGrid(const v2T& vec) const
{
v2T ret;
ret.x = glm::round(vec.x / GridStep) * GridStep;
ret.y = glm::round(vec.y / GridStep) * GridStep;
return ret;
return v2T(glm::round(vec.x / GridStep) * GridStep, glm::round(vec.y / GridStep) * GridStep);
}
/// <summary>
@ -155,13 +152,11 @@ typename v2T GLEmberController<T>::SnapToGrid(v2T& vec)
/// <param name="vec">The world cartesian coordinate to be snapped</param>
/// <returns>The snapped world cartesian coordinate</returns>
template <typename T>
typename v3T GLEmberController<T>::SnapToGrid(v3T& vec)
typename v3T GLEmberController<T>::SnapToGrid(const v3T& vec) const
{
v3T ret;
ret.x = glm::round(vec.x / GridStep) * GridStep;
ret.y = glm::round(vec.y / GridStep) * GridStep;
ret.z = vec.z;
return ret;
return v3T(glm::round(vec.x / GridStep) * GridStep,
glm::round(vec.y / GridStep) * GridStep,
vec.z);
}
/// <summary>
@ -171,9 +166,8 @@ typename v3T GLEmberController<T>::SnapToGrid(v3T& vec)
/// <param name="divisions">The divisions of a circle to use for snapping</param>
/// <returns>The snapped world cartesian coordinate</returns>
template <typename T>
typename v3T GLEmberController<T>::SnapToNormalizedAngle(v3T& vec, uint divisions)
typename v3T GLEmberController<T>::SnapToNormalizedAngle(const v3T& vec, uint divisions) const
{
T rsq, theta;
T bestRsq = numeric_limits<T>::max();
v3T c(0, 0, 0), best;
best.x = 1;
@ -181,10 +175,10 @@ typename v3T GLEmberController<T>::SnapToNormalizedAngle(v3T& vec, uint division
for (uint i = 0; i < divisions; i++)
{
theta = 2.0 * M_PI * T(i) / T(divisions);
const auto theta = 2.0 * M_PI * static_cast<T>(i) / static_cast<T>(divisions);
c.x = std::cos(theta);
c.y = std::sin(theta);
rsq = glm::distance(vec, c);
const auto rsq = glm::distance(vec, c);
if (rsq < bestRsq)
{
@ -203,9 +197,9 @@ typename v3T GLEmberController<T>::SnapToNormalizedAngle(v3T& vec, uint division
/// <param name="flip">True to flip vertically, else don't.</param>
/// <returns>The converted world cartesian coordinates</returns>
template <typename T>
typename v3T GLEmberController<T>::WindowToWorld(v3T& v, bool flip)
typename v3T GLEmberController<T>::WindowToWorld(const v3T& v, bool flip) const
{
v3T mouse(v.x, flip ? m_Viewport[3] - v.y : v.y, 0);//Must flip y because in OpenGL, 0,0 is bottom left, but in windows, it's top left.
const v3T mouse(v.x, flip ? m_Viewport[3] - v.y : v.y, 0);//Must flip y because in OpenGL, 0,0 is bottom left, but in windows, it's top left.
v3T newCoords = glm::unProject(mouse, m_Modelview, m_Projection, m_Viewport);//Perform the calculation.
newCoords.z = 0;//For some reason, unProject() always comes back with the z coordinate as something other than 0. It should be 0 at all times.
return newCoords;
@ -287,9 +281,7 @@ void GLEmberController<double>::MultMatrix(tmat4x4<double, glm::defaultp>& mat)
template <typename T>
void GLEmberController<T>::QueryMatrices(bool print)
{
auto renderer = m_FractoriumEmberController->Renderer();
if (renderer)
if (const auto renderer = m_FractoriumEmberController->Renderer())
{
QueryVMP();

View File

@ -99,17 +99,17 @@ class GLEmberController : public GLEmberControllerBase
public:
GLEmberController(Fractorium* fractorium, GLWidget* glWidget, FractoriumEmberController<T>* controller);
virtual ~GLEmberController();
virtual void DrawImage() override;
virtual void DrawAffines(bool pre, bool post) override;
virtual void ClearWindow() override;
virtual void MousePress(QMouseEvent* e) override;
virtual void MouseRelease(QMouseEvent* e) override;
virtual void MouseMove(QMouseEvent* e) override;
virtual void Wheel(QWheelEvent* e) override;
virtual void QueryMatrices(bool print) override;
virtual bool SizesMatch() override;
virtual bool CheckForSizeMismatch(int w, int h) override;
virtual void ResetMouseState() override;
void DrawImage() override;
void DrawAffines(bool pre, bool post) override;
void ClearWindow() override;
void MousePress(QMouseEvent* e) override;
void MouseRelease(QMouseEvent* e) override;
void MouseMove(QMouseEvent* e) override;
void Wheel(QWheelEvent* e) override;
void QueryMatrices(bool print) override;
bool SizesMatch() override;
bool CheckForSizeMismatch(int w, int h) override;
void ResetMouseState() override;
T CalcScale();
T CalcRotation();
@ -124,10 +124,10 @@ public:
bool CheckXformHover(const Xform<T>* xform, const v3T& glCoords, T& bestDist, bool pre, bool post);
private:
v2T SnapToGrid(v2T& vec);
v3T SnapToGrid(v3T& vec);
v3T SnapToNormalizedAngle(v3T& vec, uint divisions);
v3T WindowToWorld(v3T& v, bool flip);
v2T SnapToGrid(const v2T& vec) const;
v3T SnapToGrid(const v3T& vec) const;
v3T SnapToNormalizedAngle(const v3T& vec, uint divisions) const;
v3T WindowToWorld(const v3T& v, bool flip) const;
void QueryVMP();
#ifndef USE_GLSL
void MultMatrix(m4T& mat);

View File

@ -114,8 +114,8 @@ void GLWidget::InitGL()
//qDebug() << "Depth buffer size: " << qsf.depthBufferSize();
//qDebug() << "Swap behavior: " << qsf.swapBehavior();
//qDebug() << "Swap interval: " << qsf.swapInterval();
int w = std::ceil(m_Fractorium->ui.GLParentScrollArea->width() * devicePixelRatioF());
int h = std::ceil(m_Fractorium->ui.GLParentScrollArea->height() * devicePixelRatioF());
const auto w = std::ceil(m_Fractorium->ui.GLParentScrollArea->width() * devicePixelRatioF());
const auto h = std::ceil(m_Fractorium->ui.GLParentScrollArea->height() * devicePixelRatioF());
SetDimensions(w, h);
//Start with either a flock of random embers, or the last flame from the previous run.
//Can't do this until now because the window wasn't maximized yet, so the sizes would have been off.
@ -124,8 +124,8 @@ void GLWidget::InitGL()
if (b)
{
auto path = GetDefaultUserPath();
QDir dir(path);
QString filename = path + "/lastonshutdown.flame";
const QDir dir(path);
const QString filename = path + "/lastonshutdown.flame";
if (dir.exists(filename))
{
@ -265,14 +265,14 @@ void GLWidget::DrawQuad()
#else
this->glEnable(GL_TEXTURE_2D);
this->glActiveTexture(GL_TEXTURE0);
auto renderer = m_Fractorium->m_Controller->Renderer();
const auto renderer = m_Fractorium->m_Controller->Renderer();
//Ensure all allocation has taken place first.
if (m_OutputTexID != 0)
{
glBindTexture(GL_TEXTURE_2D, m_OutputTexID);//The texture to draw to.
auto scaledW = std::ceil(width() * devicePixelRatioF());
auto scaledH = std::ceil(height() * devicePixelRatioF());
const auto scaledW = std::ceil(width() * devicePixelRatioF());
const auto scaledH = std::ceil(height() * devicePixelRatioF());
//Only draw if the dimensions match exactly.
if (m_TexWidth == m_Fractorium->m_Controller->FinalRasW() && m_TexHeight == m_Fractorium->m_Controller->FinalRasH())
@ -280,7 +280,7 @@ void GLWidget::DrawQuad()
//Copy data from CPU to OpenGL if using a CPU renderer. This is not needed when using OpenCL.
if (renderer->RendererType() == eRendererType::CPU_RENDERER || !renderer->Shared())
{
auto finalImage = m_Fractorium->m_Controller->FinalImage();
const auto finalImage = m_Fractorium->m_Controller->FinalImage();
if (finalImage &&//Make absolutely sure all image dimensions match when copying host side buffer to GL texture.
!finalImage->empty() &&
@ -321,15 +321,15 @@ bool GLEmberControllerBase::Allocate(bool force) { return m_GL->Allocate(force);
/// Helpers to set/get/clear which keys are pressed while dragging.
/// </summary>
/// <returns>bool</returns>
bool GLEmberControllerBase::GetAlt() { return (m_DragModifier & et(eDragModifier::DragModAlt)) == et(eDragModifier::DragModAlt); }
bool GLEmberControllerBase::GetShift() { return (m_DragModifier & et(eDragModifier::DragModShift)) == et(eDragModifier::DragModShift); }
bool GLEmberControllerBase::GetControl() { return (m_DragModifier & et(eDragModifier::DragModControl)) == et(eDragModifier::DragModControl); }
void GLEmberControllerBase::SetAlt() { m_DragModifier |= et(eDragModifier::DragModAlt); }
void GLEmberControllerBase::SetShift() { m_DragModifier |= et(eDragModifier::DragModShift); }
void GLEmberControllerBase::SetControl() { m_DragModifier |= et(eDragModifier::DragModControl); }
void GLEmberControllerBase::ClearAlt() { m_DragModifier &= ~et(eDragModifier::DragModAlt); }
void GLEmberControllerBase::ClearShift() { m_DragModifier &= ~et(eDragModifier::DragModShift); }
void GLEmberControllerBase::ClearControl() { m_DragModifier &= ~et(eDragModifier::DragModControl); }
bool GLEmberControllerBase::GetAlt() { return (m_DragModifier & static_cast<et>(eDragModifier::DragModAlt)) == static_cast<et>(eDragModifier::DragModAlt); }
bool GLEmberControllerBase::GetShift() { return (m_DragModifier & static_cast<et>(eDragModifier::DragModShift)) == static_cast<et>(eDragModifier::DragModShift); }
bool GLEmberControllerBase::GetControl() { return (m_DragModifier & static_cast<et>(eDragModifier::DragModControl)) == static_cast<et>(eDragModifier::DragModControl); }
void GLEmberControllerBase::SetAlt() { m_DragModifier |= static_cast<et>(eDragModifier::DragModAlt); }
void GLEmberControllerBase::SetShift() { m_DragModifier |= static_cast<et>(eDragModifier::DragModShift); }
void GLEmberControllerBase::SetControl() { m_DragModifier |= static_cast<et>(eDragModifier::DragModControl); }
void GLEmberControllerBase::ClearAlt() { m_DragModifier &= ~static_cast<et>(eDragModifier::DragModAlt); }
void GLEmberControllerBase::ClearShift() { m_DragModifier &= ~static_cast<et>(eDragModifier::DragModShift); }
void GLEmberControllerBase::ClearControl() { m_DragModifier &= ~static_cast<et>(eDragModifier::DragModControl); }
/// <summary>
/// Clear the OpenGL output window to be the background color of the current ember.
@ -338,7 +338,7 @@ void GLEmberControllerBase::ClearControl() { m_DragModifier &= ~et(eDragModifier
template <typename T>
void GLEmberController<T>::ClearWindow()
{
auto ember = m_FractoriumEmberController->CurrentEmber();
const auto ember = m_FractoriumEmberController->CurrentEmber();
m_GL->makeCurrent();
m_GL->glClearColor(ember->m_Background.r, ember->m_Background.g, ember->m_Background.b, 1.0);
m_GL->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -495,14 +495,14 @@ void GLWidget::paintGL()
qDebug() << "Swap behavior: " << qsf.swapBehavior();
qDebug() << "Swap interval: " << qsf.swapInterval();
*/
auto controller = m_Fractorium->m_Controller.get();
const auto controller = m_Fractorium->m_Controller.get();
//Ensure there is a renderer and that it's supposed to be drawing, signified by the running timer.
if (controller && controller->Renderer()/* && controller->ProcessState() != eProcessState::NONE*/)//Need a way to determine if at leat one successful render has happened.
{
auto renderer = controller->Renderer();
float unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f;
float unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f;
const auto renderer = controller->Renderer();
const auto unitX = std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f;
const auto unitY = std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f;
if (unitX > 100000 || unitY > 100000)//Need a better way to do this.//TODO
{
@ -523,8 +523,8 @@ void GLWidget::paintGL()
}
//Affine drawing.
bool pre = m_Fractorium->DrawPreAffines();
bool post = m_Fractorium->DrawPostAffines();
const auto pre = m_Fractorium->DrawPreAffines();
const auto post = m_Fractorium->DrawPostAffines();
this->glEnable(GL_BLEND);
this->glEnable(GL_LINE_SMOOTH);
this->glEnable(GL_POINT_SMOOTH);
@ -568,8 +568,8 @@ void GLWidget::paintGL()
template <typename T>
void GLEmberController<T>::DrawImage()
{
auto renderer = m_FractoriumEmberController->Renderer();
auto ember = m_FractoriumEmberController->CurrentEmber();
const auto renderer = m_FractoriumEmberController->Renderer();
const auto ember = m_FractoriumEmberController->CurrentEmber();
m_GL->glClearColor(ember->m_Background.r, ember->m_Background.g, ember->m_Background.b, 1.0);
m_GL->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderer->EnterFinalAccum();//Lock, may not be necessary, but just in case.
@ -597,21 +597,21 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
if (!m_Fractorium->DrawXforms())
return;
auto ember = m_FractoriumEmberController->CurrentEmber();
bool dragging = m_DragState == eDragState::DragDragging;
bool forceFinal = m_Fractorium->HaveFinal();
const auto ember = m_FractoriumEmberController->CurrentEmber();
const auto dragging = m_DragState == eDragState::DragDragging;
const auto forceFinal = m_Fractorium->HaveFinal();
if (m_DragState == eDragState::DragRotateScale)
{
auto dprf = m_GL->devicePixelRatioF();
auto world = ScrolledCenter(true);
const auto dprf = m_GL->devicePixelRatioF();
const auto world = ScrolledCenter(true);
m_GL->glLineWidth(1.0f * dprf);
GLfloat vertices[] =
const GLfloat vertices[] =
{
GLfloat(m_MouseWorldPos.x), GLfloat(m_MouseWorldPos.y),//Mouse position while dragging with right button down...
GLfloat(world.x), GLfloat(world.y)//...to center.
static_cast<GLfloat>(m_MouseWorldPos.x), static_cast<GLfloat>(m_MouseWorldPos.y),//Mouse position while dragging with right button down...
static_cast<GLfloat>(world.x), static_cast<GLfloat>(world.y)//...to center.
};
QVector4D col(0.0f, 1.0f, 1.0f, 1.0f);
const QVector4D col(0.0f, 1.0f, 1.0f, 1.0f);
m_GL->DrawPointOrLine(col, vertices, 2, GL_LINES);
}
@ -641,7 +641,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
i = 0;
while (auto xform = ember->GetTotalXform(i, forceFinal))
while (const auto xform = ember->GetTotalXform(i, forceFinal))
{
bool selected = m_Fractorium->IsXformSelected(i++) || (!any && m_SelectedXform == xform);
DrawAffine(xform, true, selected, !dragging && (m_HoverXform == xform));
@ -652,7 +652,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
size_t i = 0;
bool any = false;
while (auto xform = ember->GetTotalXform(i, forceFinal))
while (const auto xform = ember->GetTotalXform(i, forceFinal))
{
if (m_Fractorium->IsXformSelected(i++))
{
@ -670,7 +670,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
size_t i = 0;
bool any = false;
while (auto xform = ember->GetTotalXform(i, forceFinal))
while (const auto xform = ember->GetTotalXform(i, forceFinal))
if (m_Fractorium->IsXformSelected(i++))
{
any = true;
@ -679,7 +679,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
i = 0;
while (auto xform = ember->GetTotalXform(i, forceFinal))
while (const auto xform = ember->GetTotalXform(i, forceFinal))
{
bool selected = m_Fractorium->IsXformSelected(i++) || (!any && m_SelectedXform == xform);
DrawAffine(xform, false, selected, !dragging && (m_HoverXform == xform));
@ -690,7 +690,7 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
size_t i = 0;
bool any = false;
while (auto xform = ember->GetTotalXform(i, forceFinal))
while (const auto xform = ember->GetTotalXform(i, forceFinal))
{
if (m_Fractorium->IsXformSelected(i++))
{
@ -712,11 +712,11 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
m_GL->glVertex2f(m_DragHandlePos.x, m_DragHandlePos.y);
m_GL->glEnd();
#else
GLfloat vertices[] =//Should these be of type T?//TODO
const GLfloat vertices[] =//Should these be of type T?//TODO
{
GLfloat(m_DragHandlePos.x), GLfloat(m_DragHandlePos.y)
static_cast<GLfloat>(m_DragHandlePos.x), static_cast<GLfloat>(m_DragHandlePos.y)
};
QVector4D col(1.0f, 1.0f, 0.5f, 1.0f);
const QVector4D col(1.0f, 1.0f, 0.5f, 1.0f);
m_GL->DrawPointOrLine(col, vertices, 1, GL_POINTS, false, 6.0f);
#endif
}
@ -736,18 +736,18 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
m_GL->glVertex2f(m_MouseWorldPos.x, m_MouseWorldPos.y);
m_GL->glEnd();
#else
GLfloat vertices[] =//Should these be of type T?//TODO
const GLfloat vertices[] =//Should these be of type T?//TODO
{
GLfloat(m_MouseDownWorldPos.x), GLfloat(m_MouseDownWorldPos.y),//UL->UR
GLfloat(m_MouseWorldPos.x ), GLfloat(m_MouseDownWorldPos.y),
GLfloat(m_MouseDownWorldPos.x), GLfloat(m_MouseWorldPos.y),//LL->LR
GLfloat(m_MouseWorldPos.x ), GLfloat(m_MouseWorldPos.y),
GLfloat(m_MouseDownWorldPos.x), GLfloat(m_MouseDownWorldPos.y),//UL->LL
GLfloat(m_MouseDownWorldPos.x), GLfloat(m_MouseWorldPos.y),
GLfloat(m_MouseWorldPos.x ), GLfloat(m_MouseDownWorldPos.y),//UR->LR
GLfloat(m_MouseWorldPos.x ), GLfloat(m_MouseWorldPos.y)
static_cast<GLfloat>(m_MouseDownWorldPos.x), static_cast<GLfloat>(m_MouseDownWorldPos.y),//UL->UR
static_cast<GLfloat>(m_MouseWorldPos.x ), static_cast<GLfloat>(m_MouseDownWorldPos.y),
static_cast<GLfloat>(m_MouseDownWorldPos.x), static_cast<GLfloat>(m_MouseWorldPos.y),//LL->LR
static_cast<GLfloat>(m_MouseWorldPos.x ), static_cast<GLfloat>(m_MouseWorldPos.y),
static_cast<GLfloat>(m_MouseDownWorldPos.x), static_cast<GLfloat>(m_MouseDownWorldPos.y),//UL->LL
static_cast<GLfloat>(m_MouseDownWorldPos.x), static_cast<GLfloat>(m_MouseWorldPos.y),
static_cast<GLfloat>(m_MouseWorldPos.x ), static_cast<GLfloat>(m_MouseDownWorldPos.y),//UR->LR
static_cast<GLfloat>(m_MouseWorldPos.x ), static_cast<GLfloat>(m_MouseWorldPos.y)
};
QVector4D col(0.0f, 0.0f, 1.0f, 1.0f);
const QVector4D col(0.0f, 0.0f, 1.0f, 1.0f);
m_GL->DrawPointOrLine(col, vertices, 8, GL_LINES);
#endif
m_GL->glLineWidth(1.0f * m_GL->devicePixelRatioF());
@ -760,11 +760,11 @@ void GLEmberController<T>::DrawAffines(bool pre, bool post)
m_GL->glVertex2f(m_HoverHandlePos.x, m_HoverHandlePos.y);
m_GL->glEnd();
#else
GLfloat vertices[] =//Should these be of type T?//TODO
const GLfloat vertices[] =//Should these be of type T?//TODO
{
GLfloat(m_HoverHandlePos.x), GLfloat(m_HoverHandlePos.y)
static_cast<GLfloat>(m_HoverHandlePos.x), static_cast<GLfloat>(m_HoverHandlePos.y)
};
QVector4D col(0.5f, 1.0f, 1.0f, 1.0f);
const QVector4D col(0.5f, 1.0f, 1.0f, 1.0f);
m_GL->DrawPointOrLine(col, vertices, 1, GL_POINTS, false, 6.0f);
#endif
}
@ -835,8 +835,8 @@ template <typename T>
void GLEmberController<T>::MousePress(QMouseEvent* e)
{
v3T mouseFlipped(e->x() * m_GL->devicePixelRatioF(), m_Viewport[3] - e->y() * m_GL->devicePixelRatioF(), 0);//Must flip y because in OpenGL, 0,0 is bottom left, but in windows, it's top left.
auto ember = m_FractoriumEmberController->CurrentEmber();
auto renderer = m_FractoriumEmberController->Renderer();
const auto ember = m_FractoriumEmberController->CurrentEmber();
const auto renderer = m_FractoriumEmberController->Renderer();
//Ensure everything has been initialized.
if (!renderer)
@ -848,7 +848,7 @@ void GLEmberController<T>::MousePress(QMouseEvent* e)
m_BoundsDown.x = renderer->LowerLeftY(false);
m_BoundsDown.y = renderer->UpperRightX(false);
m_BoundsDown.z = renderer->UpperRightY(false);
auto mod = e->modifiers();
const auto mod = e->modifiers();
if (mod.testFlag(Qt::ShiftModifier))
SetShift();
@ -862,7 +862,7 @@ void GLEmberController<T>::MousePress(QMouseEvent* e)
if (e->button() & Qt::LeftButton)
{
int xformIndex = UpdateHover(mouseFlipped);//Determine if an affine circle was clicked.
const auto xformIndex = UpdateHover(mouseFlipped);//Determine if an affine circle was clicked.
if (m_HoverXform && xformIndex != -1)
{
@ -929,7 +929,7 @@ void GLWidget::mousePressEvent(QMouseEvent* e)
{
setFocus();//Must do this so that this window gets keyboard events.
if (auto controller = GLController())
if (const auto controller = GLController())
controller->MousePress(e);
QOpenGLWidget::mousePressEvent(e);
@ -965,7 +965,7 @@ void GLWidget::mouseReleaseEvent(QMouseEvent* e)
{
setFocus();//Must do this so that this window gets keyboard events.
if (auto controller = GLController())
if (const auto controller = GLController())
controller->MouseRelease(e);
QOpenGLWidget::mouseReleaseEvent(e);
@ -980,9 +980,9 @@ template <typename T>
void GLEmberController<T>::MouseMove(QMouseEvent* e)
{
bool draw = true;
glm::ivec2 mouse(e->x() * m_GL->devicePixelRatioF(), e->y() * m_GL->devicePixelRatioF());
v3T mouseFlipped(e->x() * m_GL->devicePixelRatioF(), m_Viewport[3] - e->y() * m_GL->devicePixelRatioF(), 0);//Must flip y because in OpenGL, 0,0 is bottom left, but in windows, it's top left.
auto ember = m_FractoriumEmberController->CurrentEmber();
const glm::ivec2 mouse(e->x() * m_GL->devicePixelRatioF(), e->y() * m_GL->devicePixelRatioF());
const v3T mouseFlipped(e->x() * m_GL->devicePixelRatioF(), m_Viewport[3] - e->y() * m_GL->devicePixelRatioF(), 0);//Must flip y because in OpenGL, 0,0 is bottom left, but in windows, it's top left.
const auto ember = m_FractoriumEmberController->CurrentEmber();
//First check to see if the mouse actually moved.
if (mouse == m_MousePos)
@ -997,7 +997,7 @@ void GLEmberController<T>::MouseMove(QMouseEvent* e)
if (m_SelectedXform && m_DragState == eDragState::DragDragging)//Dragging and affine.
{
bool pre = m_AffineType == eAffineType::AffinePre;
const bool pre = m_AffineType == eAffineType::AffinePre;
if (m_HoverType == eHoverType::HoverTranslation)
CalcDragTranslation();
@ -1013,18 +1013,18 @@ void GLEmberController<T>::MouseMove(QMouseEvent* e)
{
m_DragState = eDragState::DragSelect;//Only set drag state once the user starts moving the mouse with the left button down.
//Iterate over each xform, seeing if it's in the bounding box.
QPointF tl(m_MouseDownWorldPos.x, m_MouseDownWorldPos.y);
QPointF br(m_MouseWorldPos.x, m_MouseWorldPos.y);
QRectF qrf(tl, br);
T scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
const QPointF tl(m_MouseDownWorldPos.x, m_MouseDownWorldPos.y);
const QPointF br(m_MouseWorldPos.x, m_MouseWorldPos.y);
const QRectF qrf(tl, br);
const T scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
int i = 0;
m_FractoriumEmberController->UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
if (m_Fractorium->DrawAllPre() || xform == m_SelectedXform)//Draw all pre affine if specified.
{
QPointF cd(xform->m_Affine.C() * scale, xform->m_Affine.F() * scale);
const QPointF cd(xform->m_Affine.C() * scale, xform->m_Affine.F() * scale);
bool b = qrf.contains(cd);
m_FractoriumEmberController->XformCheckboxAt(int(xfindex), [&](QCheckBox * cb)
m_FractoriumEmberController->XformCheckboxAt(static_cast<int>(xfindex), [&](QCheckBox * cb)
{
cb->setChecked(b);
});
@ -1032,9 +1032,9 @@ void GLEmberController<T>::MouseMove(QMouseEvent* e)
if (m_Fractorium->DrawAllPost() || xform == m_SelectedXform)
{
QPointF cd(xform->m_Post.C() * scale, xform->m_Post.F() * scale);
const QPointF cd(xform->m_Post.C() * scale, xform->m_Post.F() * scale);
bool b = qrf.contains(cd);
m_FractoriumEmberController->XformCheckboxAt(int(xfindex), [&](QCheckBox * cb)
m_FractoriumEmberController->XformCheckboxAt(static_cast<int>(xfindex), [&](QCheckBox * cb)
{
if (!cb->isChecked() && b)
cb->setChecked(b);
@ -1044,25 +1044,25 @@ void GLEmberController<T>::MouseMove(QMouseEvent* e)
}
else if (m_DragState == eDragState::DragPanning)//Translating the whole image.
{
T x = -(m_MouseWorldPos.x - m_MouseDownWorldPos.x);
T y = (m_MouseWorldPos.y - m_MouseDownWorldPos.y);
const auto x = -(m_MouseWorldPos.x - m_MouseDownWorldPos.x);
const auto y = (m_MouseWorldPos.y - m_MouseDownWorldPos.y);
Affine2D<T> rotMat;
rotMat.C(m_CenterDownX);
rotMat.F(m_CenterDownY);
rotMat.Rotate(ember->m_Rotate * DEG_2_RAD_T);
v2T v1(x, y);
v2T v2 = rotMat.TransformVector(v1);
const v2T v1(x, y);
const v2T v2 = rotMat.TransformVector(v1);
ember->m_CenterX = v2.x;
ember->m_CenterY = ember->m_RotCenterY = v2.y;
m_FractoriumEmberController->SetCenter(ember->m_CenterX, ember->m_CenterY);//Will restart the rendering process.
}
else if (m_DragState == eDragState::DragRotateScale)//Rotating and scaling the whole image.
{
T rot = CalcRotation();
T scale = CalcScale();
const T rot = CalcRotation();
const T scale = CalcScale();
ember->m_Rotate = NormalizeDeg180<T>(m_RotationDown + rot);
m_Fractorium->SetRotation(ember->m_Rotate, true);
m_Fractorium->SetScale(std::max(T(10), m_ScaleDown + scale));//Will restart the rendering process.
m_Fractorium->SetScale(std::max(static_cast<T>(10), m_ScaleDown + scale));//Will restart the rendering process.
}
else if (m_DragState == eDragState::DragPitchYaw)//Pitching and yawing the whole image.
{
@ -1113,7 +1113,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* e)
{
setFocus();//Must do this so that this window gets keyboard events.
if (auto controller = GLController())
if (const auto controller = GLController())
controller->MouseMove(e);
QOpenGLWidget::mouseMoveEvent(e);
@ -1219,8 +1219,8 @@ void GLWidget::DrawPointOrLine(const QVector4D& col, const GLfloat* vertices, in
/// <param name="h">Height in pixels</param>
void GLWidget::SetDimensions(int w, int h)
{
auto downscaledW = std::ceil(w / devicePixelRatioF());
auto downscaledH = std::ceil(h / devicePixelRatioF());
const auto downscaledW = std::ceil(w / devicePixelRatioF());
const auto downscaledH = std::ceil(h / devicePixelRatioF());
setFixedSize(downscaledW, downscaledH);
}
@ -1356,7 +1356,7 @@ bool GLEmberController<T>::SizesMatch()
{
//auto scaledW = std::ceil(m_GL->width() * m_GL->devicePixelRatioF());
//auto scaledH = std::ceil(m_GL->height() * m_GL->devicePixelRatioF());
auto ember = m_FractoriumEmberController->CurrentEmber();
const auto ember = m_FractoriumEmberController->CurrentEmber();
return (ember &&
ember->m_FinalRasW == m_GL->m_TexWidth &&
ember->m_FinalRasH == m_GL->m_TexHeight &&
@ -1402,19 +1402,19 @@ void GLWidget::DrawUnitSquare()
};
QVector4D col(1.0f, 1.0f, 1.0f, 0.25f);
DrawPointOrLine(col, vertices, 8, GL_LINES);
GLfloat vertices2[] =//Should these be of type T?//TODO
const GLfloat vertices2[] =//Should these be of type T?//TODO
{
-1, 0,
1, 0
};
QVector4D col2(1.0f, 0.0f, 0.0f, 0.5f);
DrawPointOrLine(col2, vertices2, 2, GL_LINES);
GLfloat vertices3[] =//Should these be of type T?//TODO
const GLfloat vertices3[] =//Should these be of type T?//TODO
{
0, -1,
0, 1
};
QVector4D col3(0.0f, 1.0f, 0.0f, 0.5f);
const QVector4D col3(0.0f, 1.0f, 0.0f, 0.5f);
DrawPointOrLine(col3, vertices3, 2, GL_LINES);
#endif
}
@ -1427,11 +1427,11 @@ void GLWidget::DrawUnitSquare()
template <typename T>
void GLEmberController<T>::DrawGrid()
{
auto renderer = m_Fractorium->m_Controller->Renderer();
double scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
const auto renderer = m_Fractorium->m_Controller->Renderer();
const auto scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
//qDebug() << renderer->UpperRightX(false) << " " << renderer->LowerLeftX(false) << " " << renderer->UpperRightY(false) << " " << renderer->LowerLeftY(false);
float unitX = (std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f) / scale;
float unitY = (std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f) / scale;
const float unitX = (std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f) / scale;
const float unitY = (std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f) / scale;
if (unitX > 100000 || unitY > 100000)//Need a better way to do this.//TODO
{
@ -1439,13 +1439,13 @@ void GLEmberController<T>::DrawGrid()
//return;
}
float xLow = std::floor(-unitX);
float xHigh = std::ceil(unitX);
float yLow = std::floor(-unitY);
float yHigh = std::ceil(unitY);
float alpha = 0.25f;
int xsteps = std::ceil(std::abs(xHigh - xLow) / GridStep);//Need these because sometimes the float value never reaches the max and it gets stuck in an infinite loop.
int ysteps = std::ceil(std::abs(yHigh - yLow) / GridStep);
const float xLow = std::floor(-unitX);
const float xHigh = std::ceil(unitX);
const float yLow = std::floor(-unitY);
const float yHigh = std::ceil(unitY);
const float alpha = 0.25f;
const int xsteps = std::ceil(std::abs(xHigh - xLow) / GridStep);//Need these because sometimes the float value never reaches the max and it gets stuck in an infinite loop.
const int ysteps = std::ceil(std::abs(yHigh - yLow) / GridStep);
Affine2D<T> temp;
m_GL->glLineWidth(1.0f * m_GL->devicePixelRatioF());
#ifndef USE_GLSL
@ -1484,7 +1484,7 @@ void GLEmberController<T>::DrawGrid()
m_GL->glEnd();
m_GL->glPopMatrix();
#else
m4T mat = (temp * scale).ToMat4ColMajor();
const m4T mat = (temp * scale).ToMat4ColMajor();
glm::tmat4x4<float, glm::defaultp> tempmat4 = mat;
m_GL->m_ModelViewMatrix = QMatrix4x4(glm::value_ptr(tempmat4));
m_GL->glLineWidth(1.0f * m_GL->devicePixelRatioF());
@ -1551,12 +1551,12 @@ void GLEmberController<T>::DrawGrid()
template <typename T>
void GLEmberController<T>::DrawAffine(const Xform<T>* xform, bool pre, bool selected, bool hovered)
{
auto ember = m_FractoriumEmberController->CurrentEmber();
auto final = ember->IsFinalXform(xform);
auto index = ember->GetXformIndex(xform);
auto size = ember->m_Palette.m_Entries.size();
auto color = ember->m_Palette.m_Entries[Clamp<T>(xform->m_ColorX * size, 0, size - 1)];
auto& affine = pre ? xform->m_Affine : xform->m_Post;
const auto ember = m_FractoriumEmberController->CurrentEmber();
const auto final = ember->IsFinalXform(xform);
const auto index = ember->GetXformIndex(xform);
const auto size = ember->m_Palette.m_Entries.size();
const auto color = ember->m_Palette.m_Entries[Clamp<T>(xform->m_ColorX * size, 0, size - 1)];
const auto& affine = pre ? xform->m_Affine : xform->m_Post;
#ifndef USE_GLSL
//For some incredibly strange reason, even though glm and OpenGL use matrices with a column-major
//data layout, nothing will work here unless they are flipped to row major order. This is how it was
@ -1593,7 +1593,7 @@ void GLEmberController<T>::DrawAffine(const Xform<T>* xform, bool pre, bool sele
m_GL->glEnd();
m_GL->glPopMatrix();
#else
m4T mat = (affine * m_FractoriumEmberController->AffineScaleCurrentToLocked()).ToMat4ColMajor();
const m4T mat = (affine * m_FractoriumEmberController->AffineScaleCurrentToLocked()).ToMat4ColMajor();
glm::tmat4x4<float, glm::defaultp> tempmat4 = mat;
m_GL->m_ModelViewMatrix = QMatrix4x4(glm::value_ptr(tempmat4));
m_GL->DrawAffineHelper(index, 1.0, 3.0, selected, hovered, pre, final, true);//Circle line width is thinner than the line width for the axes, just to distinguish it.
@ -1662,7 +1662,7 @@ void GLWidget::DrawAffineHelper(int index, float circleWidth, float lineWidth, b
{
float px = 1.0f;
float py = 0.0f;
auto col = final ? m_Fractorium->m_FinalXformComboColor : m_Fractorium->m_XformComboColors[index % XFORM_COLOR_COUNT];
const auto col = final ? m_Fractorium->m_FinalXformComboColor : m_Fractorium->m_XformComboColors[index % XFORM_COLOR_COUNT];
#ifndef USE_GLSL
glBegin(GL_LINES);
@ -1733,9 +1733,9 @@ void GLWidget::DrawAffineHelper(int index, float circleWidth, float lineWidth, b
{
for (size_t i = 1; i <= 64; i++)//The circle.
{
float theta = float(M_PI) * 2.0f * float(i % 64) / 64.0f;
float fx = std::cos(theta);
float fy = std::sin(theta);
const float theta = static_cast<float>(M_PI) * 2.0f * static_cast<float>(i % 64) / 64.0f;
const float fx = std::cos(theta);
const float fy = std::sin(theta);
m_Verts.push_back(fx);
m_Verts.push_back(fy);
}
@ -1787,16 +1787,16 @@ void GLWidget::DrawAffineHelper(int index, float circleWidth, float lineWidth, b
template <typename T>
int GLEmberController<T>::UpdateHover(const v3T& glCoords)
{
bool pre = m_Fractorium->DrawPreAffines();
bool post = m_Fractorium->DrawPostAffines();
const bool pre = m_Fractorium->DrawPreAffines();
const bool post = m_Fractorium->DrawPostAffines();
int i = 0, bestIndex = -1;
T bestDist = 10;
auto ember = m_FractoriumEmberController->CurrentEmber();
const auto ember = m_FractoriumEmberController->CurrentEmber();
m_HoverType = eHoverType::HoverNone;
if (m_Fractorium->DrawXforms())//Don't bother checking anything if the user wants to see no xforms.
{
bool forceFinal = m_Fractorium->HaveFinal();
const bool forceFinal = m_Fractorium->HaveFinal();
//If there's a selected/current xform, check it first so it gets precedence over the others.
if (m_SelectedXform)
@ -1804,25 +1804,25 @@ int GLEmberController<T>::UpdateHover(const v3T& glCoords)
//These checks prevent highlighting the pre/post selected xform circle, when one is set to show all, and the other
//is set to show current, and the user hovers over another xform, but doesn't select it, then moves the mouse
//back over the hidden circle for the pre/post that was set to only show current.
bool isSel = m_Fractorium->IsXformSelected(ember->GetTotalXformIndex(m_SelectedXform));
bool checkPre = pre && (m_Fractorium->DrawAllPre() || (m_Fractorium->DrawSelectedPre() && isSel));
bool checkPost = post && (m_Fractorium->DrawAllPost() || (m_Fractorium->DrawSelectedPost() && isSel));
const bool isSel = m_Fractorium->IsXformSelected(ember->GetTotalXformIndex(m_SelectedXform));
const bool checkPre = pre && (m_Fractorium->DrawAllPre() || (m_Fractorium->DrawSelectedPre() && isSel));
const bool checkPost = post && (m_Fractorium->DrawAllPost() || (m_Fractorium->DrawSelectedPost() && isSel));
if (CheckXformHover(m_SelectedXform, glCoords, bestDist, checkPre, checkPost))
{
m_HoverXform = m_SelectedXform;
bestIndex = int(ember->GetTotalXformIndex(m_SelectedXform, forceFinal));
bestIndex = static_cast<int>(ember->GetTotalXformIndex(m_SelectedXform, forceFinal));
}
}
//Check all xforms.
while (auto xform = ember->GetTotalXform(i, forceFinal))
while (const auto xform = ember->GetTotalXform(i, forceFinal))
{
bool isSel = m_Fractorium->IsXformSelected(i);
const bool isSel = m_Fractorium->IsXformSelected(i);
if (pre)
{
bool checkPre = m_Fractorium->DrawAllPre() || (m_Fractorium->DrawSelectedPre() && isSel) || (m_SelectedXform == xform);
const bool checkPre = m_Fractorium->DrawAllPre() || (m_Fractorium->DrawSelectedPre() && isSel) || (m_SelectedXform == xform);
if (checkPre)//Only check pre affine if they are shown.
{
@ -1836,7 +1836,7 @@ int GLEmberController<T>::UpdateHover(const v3T& glCoords)
if (post)
{
bool checkPost = m_Fractorium->DrawAllPost() || (m_Fractorium->DrawSelectedPost() && isSel) || (m_SelectedXform == xform);
const bool checkPost = m_Fractorium->DrawAllPost() || (m_Fractorium->DrawSelectedPost() && isSel) || (m_SelectedXform == xform);
if (checkPost)
{
@ -1871,18 +1871,19 @@ template <typename T>
bool GLEmberController<T>::CheckXformHover(const Xform<T>* xform, const v3T& glCoords, T& bestDist, bool pre, bool post)
{
bool preFound = false, postFound = false;
T dist = 0, scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
T dist = 0;
const auto scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
v3T pos;
if (pre)
{
auto affineScaled = xform->m_Affine * scale;
v3T translation(affineScaled.C(), affineScaled.F(), 0);
v3T transScreen = glm::project(translation, m_Modelview, m_Projection, m_Viewport);
v3T xAxis(affineScaled.A(), affineScaled.D(), 0);
v3T xAxisScreen = glm::project(translation + xAxis, m_Modelview, m_Projection, m_Viewport);
v3T yAxis(affineScaled.B(), affineScaled.E(), 0);
v3T yAxisScreen = glm::project(translation + yAxis, m_Modelview, m_Projection, m_Viewport);
const auto affineScaled = xform->m_Affine * scale;
const v3T translation(affineScaled.C(), affineScaled.F(), 0);
const v3T transScreen = glm::project(translation, m_Modelview, m_Projection, m_Viewport);
const v3T xAxis(affineScaled.A(), affineScaled.D(), 0);
const v3T xAxisScreen = glm::project(translation + xAxis, m_Modelview, m_Projection, m_Viewport);
const v3T yAxis(affineScaled.B(), affineScaled.E(), 0);
const v3T yAxisScreen = glm::project(translation + yAxis, m_Modelview, m_Projection, m_Viewport);
pos = translation;
dist = glm::distance(glCoords, transScreen);
@ -1922,13 +1923,13 @@ bool GLEmberController<T>::CheckXformHover(const Xform<T>* xform, const v3T& glC
if (post)
{
auto affineScaled = xform->m_Post * scale;
v3T translation(affineScaled.C(), affineScaled.F(), 0);
v3T transScreen = glm::project(translation, m_Modelview, m_Projection, m_Viewport);
v3T xAxis(affineScaled.A(), affineScaled.D(), 0);
v3T xAxisScreen = glm::project(translation + xAxis, m_Modelview, m_Projection, m_Viewport);
v3T yAxis(affineScaled.B(), affineScaled.E(), 0);
v3T yAxisScreen = glm::project(translation + yAxis, m_Modelview, m_Projection, m_Viewport);
const auto affineScaled = xform->m_Post * scale;
const v3T translation(affineScaled.C(), affineScaled.F(), 0);
const v3T transScreen = glm::project(translation, m_Modelview, m_Projection, m_Viewport);
const v3T xAxis(affineScaled.A(), affineScaled.D(), 0);
const v3T xAxisScreen = glm::project(translation + xAxis, m_Modelview, m_Projection, m_Viewport);
const v3T yAxis(affineScaled.B(), affineScaled.E(), 0);
const v3T yAxisScreen = glm::project(translation + yAxis, m_Modelview, m_Projection, m_Viewport);
pos = translation;
dist = glm::distance(glCoords, transScreen);
@ -1990,12 +1991,12 @@ bool GLEmberController<T>::CheckXformHover(const Xform<T>* xform, const v3T& glC
template <typename T>
void GLEmberController<T>::CalcDragXAxis()
{
T affineToWorldScale = T(m_FractoriumEmberController->AffineScaleLockedToCurrent());
T worldToAffineScale = T(m_FractoriumEmberController->AffineScaleCurrentToLocked());
bool pre = m_AffineType == eAffineType::AffinePre;
bool worldPivotShiftAlt = !m_Fractorium->LocalPivot() && GetShift() && GetAlt();
auto worldRelAxisStartScaled = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O();//World axis start position, relative, scaled by the zoom.
T startAngle = std::atan2(worldRelAxisStartScaled.y, worldRelAxisStartScaled.x);
const T affineToWorldScale = static_cast<T>(m_FractoriumEmberController->AffineScaleLockedToCurrent());
const T worldToAffineScale = static_cast<T>(m_FractoriumEmberController->AffineScaleCurrentToLocked());
const bool pre = m_AffineType == eAffineType::AffinePre;
const bool worldPivotShiftAlt = !m_Fractorium->LocalPivot() && GetShift() && GetAlt();
const auto worldRelAxisStartScaled = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O();//World axis start position, relative, scaled by the zoom.
const T startAngle = std::atan2(worldRelAxisStartScaled.y, worldRelAxisStartScaled.x);
v3T relScaled = (m_MouseWorldPos * affineToWorldScale) - v3T(m_DragSrcTransform.O(), 0);
if (!GetShift())
@ -2005,8 +2006,8 @@ void GLEmberController<T>::CalcDragXAxis()
relScaled = SnapToNormalizedAngle(relScaled, 24u);//relScaled is using the relative scaled position of the axis.
}
T endAngle = std::atan2(relScaled.y, relScaled.x);
T angle = startAngle - endAngle;
const T endAngle = std::atan2(relScaled.y, relScaled.x);
const T angle = startAngle - endAngle;
m_FractoriumEmberController->UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto it = m_DragSrcPreTransforms.find(xfindex);
@ -2047,7 +2048,7 @@ void GLEmberController<T>::CalcDragXAxis()
}
}
auto& affine = pre ? xform->m_Affine : xform->m_Post;
const auto& affine = pre ? xform->m_Affine : xform->m_Post;
if (xform == m_FractoriumEmberController->CurrentXform())
m_DragHandlePos = v3T((affine.O() + affine.X()) * worldToAffineScale, 0);
@ -2062,10 +2063,10 @@ void GLEmberController<T>::CalcDragXAxis()
relScaled = SnapToGrid(relScaled);
}
auto newmag = glm::length(relScaled);
auto newprc = newmag / origmag;
T endAngle = std::atan2(relScaled.y, relScaled.x);
T angle = startAngle - endAngle;
const auto newmag = glm::length(relScaled);
const auto newprc = newmag / origmag;
const T endAngle = std::atan2(relScaled.y, relScaled.x);
const T angle = startAngle - endAngle;
m_FractoriumEmberController->UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto it = m_DragSrcPreTransforms.find(xfindex);
@ -2126,7 +2127,7 @@ void GLEmberController<T>::CalcDragXAxis()
}
}
auto& affine = pre ? xform->m_Affine : xform->m_Post;
const auto& affine = pre ? xform->m_Affine : xform->m_Post;
if (xform == m_FractoriumEmberController->CurrentXform())
m_DragHandlePos = v3T((affine.O() + affine.X()) * worldToAffineScale, 0);
@ -2155,12 +2156,12 @@ void GLEmberController<T>::CalcDragXAxis()
template <typename T>
void GLEmberController<T>::CalcDragYAxis()
{
T affineToWorldScale = T(m_FractoriumEmberController->AffineScaleLockedToCurrent());
T worldToAffineScale = T(m_FractoriumEmberController->AffineScaleCurrentToLocked());
bool pre = m_AffineType == eAffineType::AffinePre;
bool worldPivotShiftAlt = !m_Fractorium->LocalPivot() && GetShift() && GetAlt();
auto worldRelAxisStartScaled = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O();//World axis start position, relative, scaled by the zoom.
T startAngle = std::atan2(worldRelAxisStartScaled.y, worldRelAxisStartScaled.x);
const T affineToWorldScale = static_cast<T>(m_FractoriumEmberController->AffineScaleLockedToCurrent());
const T worldToAffineScale = static_cast<T>(m_FractoriumEmberController->AffineScaleCurrentToLocked());
const bool pre = m_AffineType == eAffineType::AffinePre;
const bool worldPivotShiftAlt = !m_Fractorium->LocalPivot() && GetShift() && GetAlt();
const auto worldRelAxisStartScaled = (v2T(m_HoverHandlePos) * affineToWorldScale) - m_DragSrcTransform.O();//World axis start position, relative, scaled by the zoom.
const T startAngle = std::atan2(worldRelAxisStartScaled.y, worldRelAxisStartScaled.x);
v3T relScaled = (m_MouseWorldPos * affineToWorldScale) - v3T(m_DragSrcTransform.O(), 0);
if (!GetShift())
@ -2170,8 +2171,8 @@ void GLEmberController<T>::CalcDragYAxis()
relScaled = SnapToNormalizedAngle(relScaled, 24u);//relScaled is using the relative scaled position of the axis.
}
T endAngle = std::atan2(relScaled.y, relScaled.x);
T angle = startAngle - endAngle;
const T endAngle = std::atan2(relScaled.y, relScaled.x);
const T angle = startAngle - endAngle;
m_FractoriumEmberController->UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto it = m_DragSrcPreTransforms.find(xfindex);
@ -2212,7 +2213,7 @@ void GLEmberController<T>::CalcDragYAxis()
}
}
auto& affine = pre ? xform->m_Affine : xform->m_Post;
const auto& affine = pre ? xform->m_Affine : xform->m_Post;
if (xform == m_FractoriumEmberController->CurrentXform())
m_DragHandlePos = v3T((affine.O() + affine.Y()) * worldToAffineScale, 0);
@ -2220,17 +2221,17 @@ void GLEmberController<T>::CalcDragYAxis()
}
else
{
auto origmag = Zeps(glm::length(m_DragSrcTransform.Y()));//Magnitude of original dragged axis before it was dragged.
const auto origmag = Zeps(glm::length(m_DragSrcTransform.Y()));//Magnitude of original dragged axis before it was dragged.
if (GetControl())
{
relScaled = SnapToGrid(relScaled);
}
auto newmag = glm::length(relScaled);
auto newprc = newmag / origmag;
T endAngle = std::atan2(relScaled.y, relScaled.x);
T angle = startAngle - endAngle;
const auto newmag = glm::length(relScaled);
const auto newprc = newmag / origmag;
const T endAngle = std::atan2(relScaled.y, relScaled.x);
const T angle = startAngle - endAngle;
m_FractoriumEmberController->UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto it = m_DragSrcPreTransforms.find(xfindex);
@ -2291,7 +2292,7 @@ void GLEmberController<T>::CalcDragYAxis()
}
}
auto& affine = pre ? xform->m_Affine : xform->m_Post;
const auto& affine = pre ? xform->m_Affine : xform->m_Post;
if (xform == m_FractoriumEmberController->CurrentXform())
m_DragHandlePos = v3T((affine.O() + affine.Y()) * worldToAffineScale, 0);
@ -2315,17 +2316,17 @@ void GLEmberController<T>::CalcDragYAxis()
template <typename T>
void GLEmberController<T>::CalcDragTranslation()
{
T affineToWorldScale = T(m_FractoriumEmberController->AffineScaleLockedToCurrent());
T worldToAffineScale = T(m_FractoriumEmberController->AffineScaleCurrentToLocked());
bool worldPivotShift = !m_Fractorium->LocalPivot() && GetShift();
bool pre = m_AffineType == eAffineType::AffinePre;
const T affineToWorldScale = static_cast<T>(m_FractoriumEmberController->AffineScaleLockedToCurrent());
const T worldToAffineScale = static_cast<T>(m_FractoriumEmberController->AffineScaleCurrentToLocked());
const bool worldPivotShift = !m_Fractorium->LocalPivot() && GetShift();
const bool pre = m_AffineType == eAffineType::AffinePre;
if (GetShift())
{
v3T snapped = GetControl() ? SnapToNormalizedAngle(m_MouseWorldPos, 24) : m_MouseWorldPos;
T startAngle = std::atan2(m_DragSrcTransform.O().y, m_DragSrcTransform.O().x);
T endAngle = std::atan2(snapped.y, snapped.x);
T angle = startAngle - endAngle;
const v3T snapped = GetControl() ? SnapToNormalizedAngle(m_MouseWorldPos, 24) : m_MouseWorldPos;
const T startAngle = std::atan2(m_DragSrcTransform.O().y, m_DragSrcTransform.O().x);
const T endAngle = std::atan2(snapped.y, snapped.x);
const T angle = startAngle - endAngle;
m_FractoriumEmberController->UpdateXform([&](Xform<T>* xform, size_t xfindex, size_t selIndex)
{
auto it = m_DragSrcPreTransforms.find(xfindex);
@ -2364,7 +2365,7 @@ void GLEmberController<T>::CalcDragTranslation()
affine.O(src.O());
}
auto& affine = pre ? xform->m_Affine : xform->m_Post;
const auto& affine = pre ? xform->m_Affine : xform->m_Post;
if (xform == m_FractoriumEmberController->CurrentXform())
m_DragHandlePos = v3T(affine.O(), 0) * worldToAffineScale;
@ -2372,7 +2373,7 @@ void GLEmberController<T>::CalcDragTranslation()
}
else
{
auto diff = m_MouseWorldPos - m_MouseDownWorldPos;
const auto diff = m_MouseWorldPos - m_MouseDownWorldPos;
if (GetControl())
{
@ -2382,10 +2383,10 @@ void GLEmberController<T>::CalcDragTranslation()
if (it != m_DragSrcPreTransforms.end())
{
auto& src = it->second;
const auto& src = it->second;
auto& affine = xform->m_Affine;
auto offset = src.O() + (affineToWorldScale * v2T(diff));
auto snapped = SnapToGrid(offset);
const auto offset = src.O() + (affineToWorldScale * v2T(diff));
const auto snapped = SnapToGrid(offset);
affine.O(v2T(snapped.x, snapped.y));
}

View File

@ -17,8 +17,8 @@ void LibraryTreeWidget::SetMainWindow(Fractorium* f)
/// <param name="de">Pointer to the QDropEvent object</param>
void LibraryTreeWidget::dropEvent(QDropEvent* de)
{
QModelIndex droppedIndex = indexAt(de->pos());
auto items = selectionModel()->selectedRows();
const auto droppedIndex = indexAt(de->pos());
const auto items = selectionModel()->selectedRows();
if (!droppedIndex.isValid())//Don't process drop because it's outside of the droppable area.
{
@ -35,7 +35,7 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
if (dp == QAbstractItemView::BelowItem)
row++;
auto itemat = this->itemFromIndex(droppedIndex);
const auto itemat = this->itemFromIndex(droppedIndex);
QTreeWidget::dropEvent(de);//This internally changes the order of the items.
//Qt has a long standing major bug that rearranges the order of disjoint selections when
@ -43,15 +43,15 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
//This is an attempt to correct for that bug by removing the dropped items, then re-inserting them
//in the order they were selected.
//This bug remains present as of Qt 5.8: https://bugreports.qt.io/browse/QTBUG-45320
if (auto top = topLevelItem(0))
if (const auto top = topLevelItem(0))
{
if (itemat)
{
auto offsetitem = this->indexFromItem(itemat);
const auto offsetitem = this->indexFromItem(itemat);
if (dp == QAbstractItemView::BelowItem)
{
auto itemrow = offsetitem.row() + 1;
const auto itemrow = offsetitem.row() + 1;
for (i = 0; i < dragItems.size(); i++)
{
@ -61,7 +61,7 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
for (i = 0; i < dragItems.size(); i++)
{
auto offset = i + itemrow;
const auto offset = i + itemrow;
if (offset <= top->childCount())
top->insertChild(offset, dragItems[i]);
@ -69,7 +69,7 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
}
else
{
auto itemrow = offsetitem.row();//Will be at least 1 if dropped above it.
const auto itemrow = offsetitem.row();//Will be at least 1 if dropped above it.
auto offset = itemrow;
for (i = 0; i < dragItems.size() && offset > 0; i++)

View File

@ -11,11 +11,12 @@
FractoriumOptionsDialog::FractoriumOptionsDialog(QWidget* p, Qt::WindowFlags f)
: QDialog(p, f)
{
int i, row = 0, spinHeight = 20;
int row = 0;
const auto spinHeight = 20;
ui.setupUi(this);
m_Settings = FractoriumSettings::DefInstance();
m_Info = OpenCLInfo::Instance();
QTableWidget* table = ui.OptionsXmlSavingTable;
auto table = ui.OptionsXmlSavingTable;
ui.ThreadCountSpin->setRange(1, Timing::ProcessorCount());
connect(ui.OpenCLCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnOpenCLCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.DeviceTable, SIGNAL(cellChanged(int, int)), this, SLOT(OnDeviceTableCellChanged(int, int)), Qt::QueuedConnection);
@ -38,7 +39,7 @@ FractoriumOptionsDialog::FractoriumOptionsDialog(QWidget* p, Qt::WindowFlags f)
{
SetupDeviceTable(table, m_Settings->Devices());
for (i = 0; i < table->rowCount(); i++)
for (auto i = 0; i < table->rowCount(); i++)
if (auto radio = qobject_cast<QRadioButton*>(table->cellWidget(i, 1)))
connect(radio, SIGNAL(toggled(bool)), this, SLOT(OnDeviceTableRadioToggled(bool)), Qt::QueuedConnection);
}
@ -106,8 +107,8 @@ void FractoriumOptionsDialog::OnDeviceTableCellChanged(int row, int col)
void FractoriumOptionsDialog::OnDeviceTableRadioToggled(bool checked)
{
int row;
auto s = sender();
auto table = ui.DeviceTable;
const auto s = sender();
const auto table = ui.DeviceTable;
QRadioButton* radio = nullptr;
if (s)
@ -129,7 +130,7 @@ void FractoriumOptionsDialog::OnDeviceTableRadioToggled(bool checked)
/// <param name="state">The state of the checkbox</param>
void FractoriumOptionsDialog::OnOpenCLCheckBoxStateChanged(int state)
{
bool checked = state == Qt::Checked;
const auto checked = state == Qt::Checked;
ui.DeviceTable->setEnabled(checked);
ui.ThreadCountSpin->setEnabled(!checked);
ui.CpuSubBatchSpin->setEnabled(!checked);
@ -223,7 +224,7 @@ void FractoriumOptionsDialog::GuiToData()
void FractoriumOptionsDialog::DataToGui()
{
//Interactive rendering.
auto devices = m_Settings->Devices();
const auto devices = m_Settings->Devices();
ui.EarlyClipCheckBox->setChecked(m_Settings->EarlyClip());
ui.YAxisUpCheckBox->setChecked(m_Settings->YAxisUp());
ui.TransparencyCheckBox->setChecked(m_Settings->Transparency());

View File

@ -50,11 +50,11 @@ public slots:
void OnOpenCLCheckBoxStateChanged(int state);
void OnDeviceTableCellChanged(int row, int col);
void OnDeviceTableRadioToggled(bool checked);
virtual void accept() override;
virtual void reject() override;
void accept() override;
void reject() override;
protected:
virtual void showEvent(QShowEvent* e) override;
void showEvent(QShowEvent* e) override;
private:
Ui::OptionsDialog ui;

View File

@ -39,7 +39,7 @@ public:
QColor Color() const;
protected:
virtual void paintEvent(QPaintEvent* event) override;
void paintEvent(QPaintEvent* event) override;
private:
QPen m_Pen;

View File

@ -78,7 +78,7 @@ void ColorPickerWidget::resizeEvent(QResizeEvent* event)
void ColorPickerWidget::OnColorViewerClicked()
{
m_ColorDialog->setCurrentColor(m_ColorPanel->Color());
auto newColor = m_ColorDialog->getColor(m_ColorPanel->Color(), this);
const auto newColor = m_ColorDialog->getColor(m_ColorPanel->Color(), this);
SetColorPanelColor(newColor);
}

View File

@ -105,10 +105,10 @@ ColorTriangle::ColorTriangle(QWidget* parent)
void ColorTriangle::Polish()
{
outerRadius = CalcOuterRadius();//Matt
penWidth = (int)Floor(outerRadius / 50.0);
ellipseSize = (int) Floor(outerRadius / 12.5);
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
penWidth = static_cast<int>(Floor(outerRadius / 50.0));
ellipseSize = static_cast<int>(Floor(outerRadius / 12.5));
const auto cx = static_cast<double>(contentsRect().center().x());
const auto cy = static_cast<double>(contentsRect().center().y());
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
@ -147,7 +147,7 @@ int ColorTriangle::heightForWidth(int w) const
void ColorTriangle::GenBackground()
{
// Find the inner radius of the hue donut.
double innerRadius = outerRadius - outerRadius / 5;
const auto innerRadius = outerRadius - outerRadius / 5.0;
// Create an image of the same size as the contents rect.
bg = QImage(contentsRect().size(), QImage::Format_RGB32);
QPainter p(&bg);
@ -162,15 +162,15 @@ void ColorTriangle::GenBackground()
#if QT_VERSION < 0x040100
color.setHsv(int(i * 360.0), 255, 255);
#else
color.setHsv(int(360.0 - (i * 360.0)), 255, 255);
color.setHsv(static_cast<int>(360.0 - (i * 360.0)), 255, 255);
#endif
gradient.setColorAt(i, color);
}
QRectF innerRadiusRect(bg.rect().center().x() - innerRadius, bg.rect().center().y() - innerRadius,
innerRadius * 2 + 1, innerRadius * 2 + 1);
QRectF outerRadiusRect(bg.rect().center().x() - outerRadius, bg.rect().center().y() - outerRadius,
outerRadius * 2 + 1, outerRadius * 2 + 1);
const QRectF innerRadiusRect(bg.rect().center().x() - innerRadius, bg.rect().center().y() - innerRadius,
innerRadius * 2 + 1, innerRadius * 2 + 1);
const QRectF outerRadiusRect(bg.rect().center().x() - outerRadius, bg.rect().center().y() - outerRadius,
outerRadius * 2 + 1, outerRadius * 2 + 1);
QPainterPath path;
path.addEllipse(innerRadiusRect);
path.addEllipse(outerRadiusRect);
@ -178,15 +178,15 @@ void ColorTriangle::GenBackground()
p.setClipPath(path);
p.fillRect(bg.rect(), gradient);
p.restore();
double penThickness = bg.width() / 400.0;
const auto penThickness = bg.width() / 400.0;
for (int f = 0; f <= 5760; f += 20)
{
int value = int((0.5 + std::cos(((f - 1800) / 5760.0) * TWOPI) / 2) * 255.0);
color.setHsv(int((f / 5760.0) * 360.0), 128 + (255 - value) / 2, 255 - (255 - value) / 4);
int value = static_cast<int>((0.5 + std::cos(((f - 1800) / 5760.0) * TWOPI) / 2) * 255.0);
color.setHsv(static_cast<int>((f / 5760.0) * 360.0), 128 + (255 - value) / 2, 255 - (255 - value) / 4);
p.setPen(QPen(color, penThickness));
p.drawArc(innerRadiusRect, 1440 - f, 20);
color.setHsv(int((f / 5760.0) * 360.0), 128 + value / 2, 255 - value / 4);
color.setHsv(static_cast<int>((f / 5760.0) * 360.0), 128 + value / 2, 255 - value / 4);
p.setPen(QPen(color, penThickness));
p.drawArc(outerRadiusRect, 2880 - 1440 - f, 20);
}
@ -205,7 +205,7 @@ void ColorTriangle::mouseMoveEvent(QMouseEvent* e)
if ((e->buttons() & Qt::LeftButton) == 0)
return;
QPointF depos((double) e->pos().x(), (double) e->pos().y());
const QPointF depos(static_cast<double>(e->pos().x()), static_cast<double>(e->pos().y()));
bool newColor = false;
if (selMode == SelectingHue)
@ -225,7 +225,7 @@ void ColorTriangle::mouseMoveEvent(QMouseEvent* e)
if (am < 0) am += TWOPI;
curHue = 360 - (int) (((am) * 360.0) / TWOPI);
curHue = 360 - static_cast<int>(((am) * 360.0) / TWOPI);
int h, s, v;
curColor.getHsv(&h, &s, &v);
@ -235,8 +235,8 @@ void ColorTriangle::mouseMoveEvent(QMouseEvent* e)
curColor.setHsv(curHue, s, v);
}
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
const auto cx = static_cast<double>(contentsRect().center().x());
const auto cy = static_cast<double>(contentsRect().center().y());
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
@ -263,7 +263,7 @@ void ColorTriangle::mouseMoveEvent(QMouseEvent* e)
if (p2->point.y() > p3->point.y()) swap(&p2, &p3);
selectorPos = MovePointToTriangle(depos.x(), depos.y(), aa, bb, cc);
QColor col = ColorFromPoint(selectorPos);
const auto col = ColorFromPoint(selectorPos);
if (col != curColor)
{
@ -297,8 +297,8 @@ void ColorTriangle::mousePressEvent(QMouseEvent* e)
return;
//QMessageBox::information(NULL, "Gradient", "press");
QPointF depos((double) e->pos().x(), (double) e->pos().y());
double rad = RadiusAt(depos, contentsRect());
const QPointF depos(static_cast<double>(e->pos().x()), static_cast<double>(e->pos().y()));
const auto rad = RadiusAt(depos, contentsRect());
bool newColor = false;
// As in mouseMoveEvent, either find the a,b,c angles or the
@ -319,7 +319,7 @@ void ColorTriangle::mousePressEvent(QMouseEvent* e)
if (am < 0) am += TWOPI;
curHue = 360 - (int) ((am * 360.0) / TWOPI);
curHue = 360 - static_cast<int>((am * 360.0) / TWOPI);
int h, s, v;
curColor.getHsv(&h, &s, &v);
@ -329,8 +329,8 @@ void ColorTriangle::mousePressEvent(QMouseEvent* e)
curColor.setHsv(curHue, s, v);
}
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
const auto cx = static_cast<double>(contentsRect().center().x());
const auto cy = static_cast<double>(contentsRect().center().y());
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
@ -360,7 +360,7 @@ void ColorTriangle::mousePressEvent(QMouseEvent* e)
if (p2->point.y() > p3->point.y()) swap(&p2, &p3);
selectorPos = MovePointToTriangle(depos.x(), depos.y(), aa, bb, cc);
QColor col = ColorFromPoint(selectorPos);
const auto col = ColorFromPoint(selectorPos);
if (col != curColor)
{
@ -477,10 +477,10 @@ void ColorTriangle::keyPressEvent(QKeyEvent* e)
void ColorTriangle::resizeEvent(QResizeEvent*)
{
outerRadius = CalcOuterRadius();//Matt
penWidth = (int)Floor(outerRadius / 50.0);
ellipseSize = (int)Floor(outerRadius / 12.5);
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
penWidth = static_cast<int>(Floor(outerRadius / 50.0));
ellipseSize = static_cast<int>(Floor(outerRadius / 12.5));
const auto cx = static_cast<double>(contentsRect().center().x());
const auto cy = static_cast<double>(contentsRect().center().y());
pa = QPointF(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
pb = QPointF(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
@ -530,7 +530,7 @@ void ColorTriangle::paintEvent(QPaintEvent* e)
QPainter painter(&pix);
painter.setRenderHint(QPainter::Antialiasing);
// Draw an outline of the triangle
QColor halfAlpha(0, 0, 0, 128);
const QColor halfAlpha(0, 0, 0, 128);
painter.setPen(QPen(halfAlpha, 0));
painter.drawLine(pa, pb);
painter.drawLine(pb, pc);
@ -543,8 +543,8 @@ void ColorTriangle::paintEvent(QPaintEvent* e)
else
painter.setPen(QPen(Qt::white, penWidth));
painter.drawEllipse((int) (pd.x() - ellipseSize / 2.0),
(int) (pd.y() - ellipseSize / 2.0),
painter.drawEllipse(static_cast<int>(pd.x() - ellipseSize / 2.0),
static_cast<int>(pd.y() - ellipseSize / 2.0),
ellipseSize, ellipseSize);
curColor.getRgb(&ri, &gi, &bi);
@ -597,15 +597,15 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
if (p2->point.y() > p3->point.y()) swap(&p2, &p3);
// All the three y deltas are >= 0
double p1p2ydist = p2->point.y() - p1->point.y();
double p1p3ydist = p3->point.y() - p1->point.y();
double p2p3ydist = p3->point.y() - p2->point.y();
double p1p2xdist = p2->point.x() - p1->point.x();
double p1p3xdist = p3->point.x() - p1->point.x();
double p2p3xdist = p3->point.x() - p2->point.x();
const auto p1p2ydist = p2->point.y() - p1->point.y();
const auto p1p3ydist = p3->point.y() - p1->point.y();
const auto p2p3ydist = p3->point.y() - p2->point.y();
const auto p1p2xdist = p2->point.x() - p1->point.x();
const auto p1p3xdist = p3->point.x() - p1->point.x();
const auto p2p3xdist = p3->point.x() - p2->point.x();
// The first x delta decides wether we have a lefty or a righty
// trigon.
bool lefty = p1p2xdist < 0;
const auto lefty = p1p2xdist < 0;
// Left and right colors and X values. The key in this map is the
// y values. Our goal is to fill these structures with all the
// information needed to do a single pass top-to-bottom,
@ -614,10 +614,10 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
QVarLengthArray<DoubleColor, 2000> rightColors;
QVarLengthArray<double, 2000> leftX;
QVarLengthArray<double, 2000> rightX;
leftColors.resize(int(Floor(p3->point.y() + 1)));
rightColors.resize(int(Floor(p3->point.y() + 1)));
leftX.resize(int(Floor(p3->point.y() + 1)));
rightX.resize(int(Floor(p3->point.y() + 1)));
leftColors.resize(static_cast<int>(Floor(p3->point.y() + 1)));
rightColors.resize(static_cast<int>(Floor(p3->point.y() + 1)));
leftX.resize(static_cast<int>(Floor(p3->point.y() + 1)));
rightX.resize(static_cast<int>(Floor(p3->point.y() + 1)));
// Scan longy - find all left and right colors and X-values for
// the tallest edge (p1-p3).
DoubleColor source;
@ -634,8 +634,8 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
r = source.r;
g = source.g;
b = source.b;
y1 = (int)Floor(p1->point.y());
y2 = (int)Floor(p3->point.y());
y1 = static_cast<int>(Floor(p1->point.y()));
y2 = static_cast<int>(Floor(p3->point.y()));
// Find slopes (notice that if the y dists are 0, we don't care
// about the slopes)
xdelta = p1p3ydist == 0.0 ? 0.0 : p1p3xdist / p1p3ydist;
@ -672,8 +672,8 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
r = source.r;
g = source.g;
b = source.b;
y1 = (int)Floor(p1->point.y());
y2 = (int)Floor(p2->point.y());
y1 = static_cast<int>(Floor(p1->point.y()));
y2 = static_cast<int>(Floor(p2->point.y()));
// Find slopes (notice that if the y dists are 0, we don't care
// about the slopes)
xdelta = p1p2ydist == 0.0 ? 0.0 : p1p2xdist / p1p2ydist;
@ -709,8 +709,8 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
r = source.r;
g = source.g;
b = source.b;
y1 = (int)Floor(p2->point.y());
y2 = (int)Floor(p3->point.y());
y1 = static_cast<int>(Floor(p2->point.y()));
y2 = static_cast<int>(Floor(p3->point.y()));
// Find slopes (notice that if the y dists are 0, we don't care
// about the slopes)
xdelta = p2p3ydist == 0.0 ? 0.0 : p2p3xdist / p2p3ydist;
@ -740,34 +740,34 @@ void ColorTriangle::DrawTrigon(QImage* buf, const QPointF& pa,
// Inner loop. For each y in the left map of x-values, draw one
// line from left to right.
const int p3yfloor = int(Floor(p3->point.y()));
const auto p3yfloor = static_cast<int>(Floor(p3->point.y()));
for (int y = int(Floor(p1->point.y())); y < p3yfloor; ++y)
for (auto y = static_cast<int>(Floor(p1->point.y())); y < p3yfloor; ++y)
{
double lx = leftX[y];
double rx = rightX[y];
int lxi = (int)Floor(lx);
int rxi = (int)Floor(rx);
DoubleColor rc = rightColors[y];
DoubleColor lc = leftColors[y];
const auto lx = leftX[y];
const auto rx = rightX[y];
const auto lxi = static_cast<int>(Floor(lx));
const auto rxi = static_cast<int>(Floor(rx));
const auto rc = rightColors[y];
const auto lc = leftColors[y];
// if the xdist is 0, don't draw anything.
double xdist = rx - lx;
const auto xdist = rx - lx;
if (xdist != 0.0)
{
double r = lc.r;
double g = lc.g;
double b = lc.b;
double rdelta = (rc.r - r) / xdist;
double gdelta = (rc.g - g) / xdist;
double bdelta = (rc.b - b) / xdist;
QRgb* scanline = reinterpret_cast<QRgb*>(buf->scanLine(y));
auto r = lc.r;
auto g = lc.g;
auto b = lc.b;
const auto rdelta = (rc.r - r) / xdist;
const auto gdelta = (rc.g - g) / xdist;
const auto bdelta = (rc.b - b) / xdist;
auto scanline = reinterpret_cast<QRgb*>(buf->scanLine(y));
scanline += lxi;
// Inner loop 2. Draws the line from left to right.
for (int i = lxi; i < rxi; ++i)
for (auto i = lxi; i < rxi; ++i)
{
*scanline++ = qRgb((int) r, (int) g, (int) b);
*scanline++ = qRgb(static_cast<int>(r), static_cast<int>(g), static_cast<int>(b));
r += rdelta;
g += gdelta;
b += bdelta;
@ -805,10 +805,10 @@ void ColorTriangle::Color(const QColor& col)
if (c > TWOPI) c -= TWOPI;
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
double innerRadius = outerRadius - (outerRadius / 5.0);
double pointerRadius = outerRadius - (outerRadius / 10.0);
const auto cx = static_cast<double>(contentsRect().center().x());
const auto cy = static_cast<double>(contentsRect().center().y());
const auto innerRadius = outerRadius - (outerRadius / 5.0);
const auto pointerRadius = outerRadius - (outerRadius / 10.0);
pa = QPointF(cx + (std::cos(a) * innerRadius), cy - (std::sin(a) * innerRadius));
pb = QPointF(cx + (std::cos(b) * innerRadius), cy - (std::sin(b) * innerRadius));
pc = QPointF(cx + (std::cos(c) * innerRadius), cy - (std::sin(c) * innerRadius));
@ -829,7 +829,7 @@ QColor ColorTriangle::Color() const
double ColorTriangle::CalcOuterRadius() const
{
double rad = (std::min(contentsRect().width(), contentsRect().height()) - 1) / 2;
auto rad = (std::min(contentsRect().width(), contentsRect().height()) - 1) / 2;
rad -= 2;//Matt - a little extra because the top gets cut off without doing this.
return rad;
}
@ -841,8 +841,8 @@ double ColorTriangle::CalcOuterRadius() const
*/
double ColorTriangle::RadiusAt(const QPointF& pos, const QRect& rect) const
{
double mousexdist = pos.x() - (double) rect.center().x();
double mouseydist = pos.y() - (double) rect.center().y();
const auto mousexdist = pos.x() - static_cast<double>(rect.center().x());
const auto mouseydist = pos.y() - static_cast<double>(rect.center().y());
return std::sqrt(mousexdist * mousexdist + mouseydist * mouseydist);
}
@ -855,14 +855,14 @@ double ColorTriangle::RadiusAt(const QPointF& pos, const QRect& rect) const
*/
double ColorTriangle::AngleAt(const QPointF& pos, const QRect& rect) const
{
double mousexdist = pos.x() - (double) rect.center().x();
double mouseydist = pos.y() - (double) rect.center().y();
double mouserad = std::sqrt(mousexdist * mousexdist + mouseydist * mouseydist);
const auto mousexdist = pos.x() - static_cast<double>(rect.center().x());
const auto mouseydist = pos.y() - static_cast<double>(rect.center().y());
const auto mouserad = std::sqrt(mousexdist * mousexdist + mouseydist * mouseydist);
if (mouserad == 0.0)
return 0.0;
double angle = std::acos(mousexdist / mouserad);
auto angle = std::acos(mousexdist / mouserad);
if (mouseydist >= 0)
angle = TWOPI - angle;
@ -1122,38 +1122,38 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
// Let v1A be the vector from (x,y) to a.
// Let v2A be the vector from a to b.
// Find the angle alphaA between v1A and v2A.
double v1xA = x - a.point.x();
double v1yA = y - a.point.y();
double v2xA = b.point.x() - a.point.x();
double v2yA = b.point.y() - a.point.y();
double vpA = vprod(v1xA, v1yA, v2xA, v2yA);
double cosA = vpA / (vlen(v1xA, v1yA) * vlen(v2xA, v2yA));
double alphaA = std::acos(cosA);
const auto v1xA = x - a.point.x();
const auto v1yA = y - a.point.y();
const auto v2xA = b.point.x() - a.point.x();
const auto v2yA = b.point.y() - a.point.y();
const auto vpA = vprod(v1xA, v1yA, v2xA, v2yA);
const auto cosA = vpA / (vlen(v1xA, v1yA) * vlen(v2xA, v2yA));
const auto alphaA = std::acos(cosA);
// Let v1B be the vector from x to b.
// Let v2B be the vector from b to c.
double v1xB = x - b.point.x();
double v1yB = y - b.point.y();
double v2xB = c.point.x() - b.point.x();
double v2yB = c.point.y() - b.point.y();
double vpB = vprod(v1xB, v1yB, v2xB, v2yB);
double cosB = vpB / (vlen(v1xB, v1yB) * vlen(v2xB, v2yB));
double alphaB = std::acos(cosB);
const auto v1xB = x - b.point.x();
const auto v1yB = y - b.point.y();
const auto v2xB = c.point.x() - b.point.x();
const auto v2yB = c.point.y() - b.point.y();
const auto vpB = vprod(v1xB, v1yB, v2xB, v2yB);
const auto cosB = vpB / (vlen(v1xB, v1yB) * vlen(v2xB, v2yB));
const auto alphaB = std::acos(cosB);
// Let v1C be the vector from x to c.
// Let v2C be the vector from c back to a.
double v1xC = x - c.point.x();
double v1yC = y - c.point.y();
double v2xC = a.point.x() - c.point.x();
double v2yC = a.point.y() - c.point.y();
double vpC = vprod(v1xC, v1yC, v2xC, v2yC);
double cosC = vpC / (vlen(v1xC, v1yC) * vlen(v2xC, v2yC));
double alphaC = std::acos(cosC);
const auto v1xC = x - c.point.x();
const auto v1yC = y - c.point.y();
const auto v2xC = a.point.x() - c.point.x();
const auto v2yC = a.point.y() - c.point.y();
const auto vpC = vprod(v1xC, v1yC, v2xC, v2yC);
const auto cosC = vpC / (vlen(v1xC, v1yC) * vlen(v2xC, v2yC));
const auto alphaC = std::acos(cosC);
// Find the radian angles between the (1,0) vector and the points
// A, B, C and (x,y). Use this information to determine which of
// the edges we should project (x,y) onto.
double angleA = AngleAt(a.point, contentsRect());
double angleB = AngleAt(b.point, contentsRect());
double angleC = AngleAt(c.point, contentsRect());
double angleP = AngleAt(QPointF(x, y), contentsRect());
const auto angleA = AngleAt(a.point, contentsRect());
const auto angleB = AngleAt(b.point, contentsRect());
const auto angleC = AngleAt(c.point, contentsRect());
const auto angleP = AngleAt(QPointF(x, y), contentsRect());
// If (x,y) is in the a-b area, project onto the a-b vector.
if (angleBetweenAngles(angleP, angleA, angleB))
@ -1162,10 +1162,10 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
// the a-b vector with this distance and the angle between a-b
// and a-(x,y) to determine the point of intersection of the
// perpendicular projection from (x,y) onto a-b.
double pdist = std::sqrt(qsqr(x - a.point.x()) + qsqr(y - a.point.y()));
const auto pdist = std::sqrt(qsqr(x - a.point.x()) + qsqr(y - a.point.y()));
// the length of all edges is always > 0
double p0x = a.point.x() + ((b.point.x() - a.point.x()) / vlen(v2xB, v2yB)) * std::cos(alphaA) * pdist;
double p0y = a.point.y() + ((b.point.y() - a.point.y()) / vlen(v2xB, v2yB)) * std::cos(alphaA) * pdist;
const auto p0x = a.point.x() + ((b.point.x() - a.point.x()) / vlen(v2xB, v2yB)) * std::cos(alphaA) * pdist;
const auto p0y = a.point.y() + ((b.point.y() - a.point.y()) / vlen(v2xB, v2yB)) * std::cos(alphaA) * pdist;
// If (x,y) is above the a-b line, which basically means it's
// outside the triangle, then return its projection onto a-b.
@ -1186,10 +1186,10 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
else if (angleBetweenAngles(angleP, angleB, angleC))
{
// If (x,y) is in the b-c area, project onto the b-c vector.
double pdist = std::sqrt(qsqr(x - b.point.x()) + qsqr(y - b.point.y()));
const auto pdist = std::sqrt(qsqr(x - b.point.x()) + qsqr(y - b.point.y()));
// the length of all edges is always > 0
double p0x = b.point.x() + ((c.point.x() - b.point.x()) / vlen(v2xC, v2yC)) * std::cos(alphaB) * pdist;
double p0y = b.point.y() + ((c.point.y() - b.point.y()) / vlen(v2xC, v2yC)) * std::cos(alphaB) * pdist;
const auto p0x = b.point.x() + ((c.point.x() - b.point.x()) / vlen(v2xC, v2yC)) * std::cos(alphaB) * pdist;
const auto p0y = b.point.y() + ((c.point.y() - b.point.y()) / vlen(v2xC, v2yC)) * std::cos(alphaB) * pdist;
if (pointAbovePoint(x, y, p0x, p0y, b.point.x(), b.point.y(), c.point.x(), c.point.y()))
{
@ -1206,14 +1206,14 @@ QPointF ColorTriangle::MovePointToTriangle(double x, double y, const Vertex& a,
else if (angleBetweenAngles(angleP, angleC, angleA))
{
// If (x,y) is in the c-a area, project onto the c-a vector.
double pdist = std::sqrt(qsqr(x - c.point.x()) + qsqr(y - c.point.y()));
const auto pdist = std::sqrt(qsqr(x - c.point.x()) + qsqr(y - c.point.y()));
// the length of all edges is always > 0
double p0x = c.point.x() + ((a.point.x() - c.point.x()) / vlen(v2xA, v2yA)) * std::cos(alphaC) * pdist;
double p0y = c.point.y() + ((a.point.y() - c.point.y()) / vlen(v2xA, v2yA)) * std::cos(alphaC) * pdist;
const auto p0x = c.point.x() + ((a.point.x() - c.point.x()) / vlen(v2xA, v2yA)) * std::cos(alphaC) * pdist;
const auto p0y = c.point.y() + ((a.point.y() - c.point.y()) / vlen(v2xA, v2yA)) * std::cos(alphaC) * pdist;
if (pointAbovePoint(x, y, p0x, p0y, c.point.x(), c.point.y(), a.point.x(), a.point.y()))
{
int n = pointInLine(p0x, p0y, c.point.x(), c.point.y(), a.point.x(), a.point.y());
const auto n = pointInLine(p0x, p0y, c.point.x(), c.point.y(), a.point.x(), a.point.y());
if (n < 0)
return c.point;
@ -1251,37 +1251,37 @@ QPointF ColorTriangle::PointFromColor(const QColor& col) const
return pc;
// Find the x and y slopes
double ab_deltax = pb.x() - pa.x();
double ab_deltay = pb.y() - pa.y();
double bc_deltax = pc.x() - pb.x();
double bc_deltay = pc.y() - pb.y();
double ac_deltax = pc.x() - pa.x();
double ac_deltay = pc.y() - pa.y();
const auto ab_deltax = pb.x() - pa.x();
const auto ab_deltay = pb.y() - pa.y();
const auto bc_deltax = pc.x() - pb.x();
const auto bc_deltay = pc.y() - pb.y();
const auto ac_deltax = pc.x() - pa.x();
const auto ac_deltay = pc.y() - pa.y();
// Extract the h,s,v values of col.
int hue, sat, val;
col.getHsv(&hue, &sat, &val);
// Find the line that passes through the triangle where the value
// is equal to our color's value.
double p1 = pa.x() + (ab_deltax * (double) (255 - val)) / 255.0;
double q1 = pa.y() + (ab_deltay * (double) (255 - val)) / 255.0;
double p2 = pb.x() + (bc_deltax * (double) val) / 255.0;
double q2 = pb.y() + (bc_deltay * (double) val) / 255.0;
const auto p1 = pa.x() + (ab_deltax * static_cast<double>(255 - val)) / 255.0;
const auto q1 = pa.y() + (ab_deltay * static_cast<double>(255 - val)) / 255.0;
const auto p2 = pb.x() + (bc_deltax * static_cast<double>(val)) / 255.0;
const auto q2 = pb.y() + (bc_deltay * static_cast<double>(val)) / 255.0;
// Find the line that passes through the triangle where the
// saturation is equal to our color's value.
double p3 = pa.x() + (ac_deltax * (double) (255 - sat)) / 255.0;
double q3 = pa.y() + (ac_deltay * (double) (255 - sat)) / 255.0;
double p4 = pb.x();
double q4 = pb.y();
const auto p3 = pa.x() + (ac_deltax * static_cast<double>(255 - sat)) / 255.0;
const auto q3 = pa.y() + (ac_deltay * static_cast<double>(255 - sat)) / 255.0;
const auto p4 = pb.x();
const auto q4 = pb.y();
// Find the intersection between these lines.
double x = 0;
double y = 0;
auto x = 0;
auto y = 0;
if (p1 != p2)
{
double a = (q2 - q1) / (p2 - p1);
double c = (q4 - q3) / (p4 - p3);
double b = q1 - a * p1;
double d = q3 - c * p3;
const auto a = (q2 - q1) / (p2 - p1);
const auto c = (q4 - q3) / (p4 - p3);
const auto b = q1 - a * p1;
const auto d = q3 - c * p3;
x = (d - b) / (a - c);
y = a * x + b;
}
@ -1304,28 +1304,28 @@ QPointF ColorTriangle::PointFromColor(const QColor& col) const
QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
{
// Find the outer radius of the hue gradient.
int outerRadius = CalcOuterRadius();//Matt//why is this local?
const auto outerRadius = CalcOuterRadius();//Matt//why is this local?
// Find the center coordinates
double cx = (double) contentsRect().center().x();
double cy = (double) contentsRect().center().y();
const auto cx = static_cast<double>(contentsRect().center().x());
const auto cy = static_cast<double>(contentsRect().center().y());
// Find the a, b and c from their angles, the center of the rect
// and the radius of the hue gradient donut.
QPointF pa(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
QPointF pb(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
QPointF pc(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
const QPointF pa(cx + (std::cos(a) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(a) * (outerRadius - (outerRadius / 5.0))));
const QPointF pb(cx + (std::cos(b) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(b) * (outerRadius - (outerRadius / 5.0))));
const QPointF pc(cx + (std::cos(c) * (outerRadius - (outerRadius / 5.0))),
cy - (std::sin(c) * (outerRadius - (outerRadius / 5.0))));
// Find the hue value from the angle of the 'a' point.
double angle = a - M_PI / 2.0;
auto angle = a - M_PI / 2.0;
if (angle < 0) angle += TWOPI;
double hue = (360.0 * angle) / TWOPI;
const auto hue = (360.0 * angle) / TWOPI;
// Create the color of the 'a' corner point. We know that b is
// black and c is white.
QColor color;
color.setHsv(360 - (int)Floor(hue), 255, 255);
color.setHsv(360 - static_cast<int>(Floor(hue)), 255, 255);
// See also drawTrigon(), which basically does exactly the same to
// determine all colors in the trigon.
Vertex aa(color, pa);
@ -1344,22 +1344,22 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
// Find the slopes of all edges in the trigon. All the three y
// deltas here are positive because of the above sorting.
double p1p2ydist = p2->point.y() - p1->point.y();
double p1p3ydist = p3->point.y() - p1->point.y();
double p2p3ydist = p3->point.y() - p2->point.y();
double p1p2xdist = p2->point.x() - p1->point.x();
double p1p3xdist = p3->point.x() - p1->point.x();
double p2p3xdist = p3->point.x() - p2->point.x();
const auto p1p2ydist = p2->point.y() - p1->point.y();
const auto p1p3ydist = p3->point.y() - p1->point.y();
const auto p2p3ydist = p3->point.y() - p2->point.y();
const auto p1p2xdist = p2->point.x() - p1->point.x();
const auto p1p3xdist = p3->point.x() - p1->point.x();
const auto p2p3xdist = p3->point.x() - p2->point.x();
// The first x delta decides wether we have a lefty or a righty
// trigon. A lefty trigon has its tallest edge on the right hand
// side of the trigon. The righty trigon has it on its left side.
// This property determines wether the left or the right set of x
// coordinates will be continuous.
bool lefty = p1p2xdist < 0;
const auto lefty = p1p2xdist < 0;
// Find whether the selector's y is in the first or second shorty,
// counting from the top and downwards. This is used to find the
// color at the selector point.
bool firstshorty = (p.y() >= p1->point.y() && p.y() < p2->point.y());
const auto firstshorty = (p.y() >= p1->point.y() && p.y() < p2->point.y());
// From the y value of the selector's position, find the left and
// right x values.
double leftx;
@ -1554,9 +1554,9 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
// find the distances from the selector to each of these (saxdist
// and saxdist2). These distances are used to find the color at
// the selector.
double xdist = rightx - leftx;
double saxdist = p.x() - leftx;
double saxdist2 = xdist - saxdist;
const auto xdist = rightx - leftx;
const auto saxdist = p.x() - leftx;
const auto saxdist2 = xdist - saxdist;
// Now determine the r,g,b values of the selector using a linear
// approximation.
double r, g, b;
@ -1582,9 +1582,9 @@ QColor ColorTriangle::ColorFromPoint(const QPointF& p) const
// Now floor the color components and fit them into proper
// boundaries. This again is to compensate for the error caused by
// loss of precision.
int ri = (int)Floor(r);
int gi = (int)Floor(g);
int bi = (int)Floor(b);
auto ri = static_cast<int>(Floor(r));
auto gi = static_cast<int>(Floor(g));
auto bi = static_cast<int>(Floor(b));
if (ri < 0) ri = 0;
else if (ri > 255) ri = 255;

View File

@ -73,8 +73,8 @@ struct Vertex
Vertex(const DoubleColor& c, const QPointF& p) : color(c), point(p) {}
Vertex(const QColor& c, const QPointF& p)
: color(DoubleColor((double)c.red(), (double)c.green(),
(double)c.blue())), point(p) {}
: color(DoubleColor(static_cast<double>(c.red()), static_cast<double>(c.green()),
static_cast<double>(c.blue()))), point(p) {}
};
/// <summary>
@ -94,19 +94,19 @@ public:
QColor Color() const;
void Color(const QColor& col);
virtual int heightForWidth(int w) const override;
virtual QSize sizeHint() const override;
int heightForWidth(int w) const override;
QSize sizeHint() const override;
Q_SIGNALS:
void ColorChanged(const QColor& col);
protected:
virtual void paintEvent(QPaintEvent*) override;
virtual void mouseMoveEvent(QMouseEvent*) override;
virtual void mousePressEvent(QMouseEvent*) override;
virtual void mouseReleaseEvent(QMouseEvent*) override;
virtual void keyPressEvent(QKeyEvent* e) override;
virtual void resizeEvent(QResizeEvent*) override;
void paintEvent(QPaintEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void keyPressEvent(QKeyEvent* e) override;
void resizeEvent(QResizeEvent*) override;
private:
void GenBackground();

View File

@ -102,10 +102,10 @@ public:
TopArrow(int width, size_t index)
{
QPolygon area;
int center = 10;
int mid = width / 2;
int left = center - mid;
int right = center + mid;
const auto center = 10;
const auto mid = width / 2;
const auto left = center - mid;
const auto right = center + mid;
area << QPoint(left, 0) << QPoint(right, 0) << QPoint(right, 10) << QPoint(center, 15) << QPoint(left, 10) << QPoint(left, 0);
Area(area);
m_Index = index;

View File

@ -138,8 +138,8 @@ void GradientColorsView::AddArrow(const QColor& color)
}
else if (m_Arrows.size() == 2)
{
auto b = m_Arrows.begin();
auto rb = m_Arrows.rbegin();
const auto b = m_Arrows.begin();
const auto rb = m_Arrows.rbegin();
position = std::abs((rb->first + b->first) / 2.0);
if (position == b->first)
@ -151,7 +151,7 @@ void GradientColorsView::AddArrow(const QColor& color)
{
bool set = false;
auto it = m_Arrows.begin();
auto oneBeforeLast = Advance(m_Arrows.begin(), m_Arrows.size() - 1);
const auto oneBeforeLast = Advance(m_Arrows.begin(), m_Arrows.size() - 1);
for (; it != oneBeforeLast; ++it)
{
@ -226,7 +226,7 @@ void GradientColorsView::InvertColors()
for (auto& it : m_Arrows)
{
auto& arrow = it.second;
auto col = arrow.Color();
const auto col = arrow.Color();
arrow.Color(QColor(255 - col.red(), 255 - col.green(), 255 - col.blue()));
if (arrow.Focus())
@ -256,9 +256,9 @@ void GradientColorsView::RandomColors()
for (auto& it : m_Arrows)
it.second.Color(
{
int(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(256)),
int(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(256)),
int(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(256))
static_cast<int>(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(256)),
static_cast<int>(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(256)),
static_cast<int>(QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(256))
});
update();
}
@ -271,7 +271,8 @@ void GradientColorsView::DistributeColors()
if (!m_Arrows.empty())
{
map<float, GradientArrow> arrows;
float index = 0, inc = 1.0f / std::max<size_t>(size_t(1), m_Arrows.size() - 1);
float index = 0;
const auto inc = 1.0f / std::max<size_t>(size_t(1), m_Arrows.size() - 1);
for (auto it : m_Arrows)
{
@ -392,7 +393,7 @@ Palette<float>& GradientColorsView::GetPalette(int size)
{
if (!m_Arrows.empty())
{
QSize imageSize(size, 1);
const QSize imageSize(size, 1);
QImage image(imageSize, QImage::Format_ARGB32_Premultiplied);
m_Palette.m_SourceColors.clear();
QPainter painter(&image);
@ -522,15 +523,15 @@ void GradientColorsView::paintEvent(QPaintEvent*)
if (!m_Arrows.empty())
{
QPoint gradStart = QPoint(m_ViewRect.topLeft().x(), m_ViewRect.bottomLeft().y() / 2);
QPoint gradStop = QPoint(m_ViewRect.topRight().x(), m_ViewRect.bottomRight().y() / 2);
const QPoint gradStart = QPoint(m_ViewRect.topLeft().x(), m_ViewRect.bottomLeft().y() / 2);
const QPoint gradStop = QPoint(m_ViewRect.topRight().x(), m_ViewRect.bottomRight().y() / 2);
QLinearGradient grad(gradStart, gradStop);
float start = m_ViewRect.x();
for (auto& it : m_Arrows)
{
GradientArrow& arrow = it.second;
auto offset = std::ceil(it.first * RectWidth());
const auto offset = std::ceil(it.first * RectWidth());
if (Blend())
{
@ -543,8 +544,8 @@ void GradientColorsView::paintEvent(QPaintEvent*)
}
QPolygon arrowPolygon = arrow.Area();
int iPosX = offset,
iPosY = m_ViewRect.height() + m_ViewRect.top() + 3;
const auto iPosX = offset;
const auto iPosY = m_ViewRect.height() + m_ViewRect.top() + 3;
arrowPolygon.translate(iPosX, iPosY);
QPainterPath paintPath;
paintPath.addPolygon(arrowPolygon);
@ -575,7 +576,7 @@ void GradientColorsView::paintEvent(QPaintEvent*)
auto& topArrow = it.second.second;
auto topArrowPolygon = topArrow.Area();
topArrowPolygon.translate(it.second.first * RectWidth(), 0);
auto topArrowRect = topArrowPolygon.boundingRect();
const auto topArrowRect = topArrowPolygon.boundingRect();
topArrowPaintPath.addPolygon(topArrowPolygon);
painter.drawPath(topArrowPaintPath);//When using a separate painter, the sides aren't as thick.
//Draw text inside of the arrow.
@ -655,7 +656,7 @@ void GradientColorsView::mouseMoveEvent(QMouseEvent* e)
if (!m_ArrowMoving && !m_ColorIndexArrowMoving) return;
size_t index = 0;
qreal maxMove = 11.5 / RectWidth();
const qreal maxMove = 11.5 / RectWidth();
if (m_ArrowMoving)
{
@ -665,18 +666,18 @@ void GradientColorsView::mouseMoveEvent(QMouseEvent* e)
if (arrow.Focus())
{
qreal lastPos = it->first;
qreal start = m_DragStart.x();
qreal end = RectWidth();
qreal dPos = ((qreal)e->pos().x() - start) / end;
qreal newPos = lastPos + dPos;
const qreal lastPos = it->first;
const qreal start = m_DragStart.x();
const qreal end = RectWidth();
const qreal dPos = ((qreal)e->pos().x() - start) / end;
const qreal newPos = lastPos + dPos;
if ((lastPos + dPos > 1) || (lastPos + dPos < 0))
return;
if (dPos < 0 && index > 0)
{
qreal posBefore = std::prev(it)->first;
const qreal posBefore = std::prev(it)->first;
if ((lastPos - maxMove + dPos) <= posBefore)
return;
@ -684,7 +685,7 @@ void GradientColorsView::mouseMoveEvent(QMouseEvent* e)
if ((dPos > 0) && (index < (m_Arrows.size() - 1)))
{
qreal posAfter = std::next(it)->first;
const qreal posAfter = std::next(it)->first;
if ((lastPos + maxMove + dPos) >= posAfter)
return;
@ -708,11 +709,11 @@ void GradientColorsView::mouseMoveEvent(QMouseEvent* e)
if (arrow.Focus())
{
qreal lastPos = it.second.first;
qreal start = m_DragStart.x();
qreal end = RectWidth();
qreal dPos = ((qreal)e->pos().x() - start) / end;
qreal newPos = lastPos + dPos;
const qreal lastPos = it.second.first;
const qreal start = m_DragStart.x();
const qreal end = RectWidth();
const qreal dPos = ((qreal)e->pos().x() - start) / end;
const qreal newPos = lastPos + dPos;
if ((lastPos + dPos > 1) || (lastPos + dPos < 0))
return;

View File

@ -64,12 +64,12 @@ Q_SIGNALS:
void ColorIndexMove(size_t index, float value);
protected:
virtual void paintEvent(QPaintEvent* e) override;
virtual void mousePressEvent(QMouseEvent* e) override;
virtual void mouseDoubleClickEvent(QMouseEvent* e) override;
virtual void mouseMoveEvent(QMouseEvent* e) override;
virtual void mouseReleaseEvent(QMouseEvent* e) override;
virtual void resizeEvent(QResizeEvent*) override;
void paintEvent(QPaintEvent* e) override;
void mousePressEvent(QMouseEvent* e) override;
void mouseDoubleClickEvent(QMouseEvent* e) override;
void mouseMoveEvent(QMouseEvent* e) override;
void mouseReleaseEvent(QMouseEvent* e) override;
void resizeEvent(QResizeEvent*) override;
private:
int RectWidth();

View File

@ -58,7 +58,7 @@ PaletteEditor::PaletteEditor(QWidget* p) :
ui->PaletteFilenameCombo->addItem(info.fileName());
}
ui->PaletteFilenameCombo->model()->sort(0);
ui->PaletteFilenameCombo->model()->sort(0);
if (ui->PaletteFilenameCombo->count() > 0)
m_CurrentPaletteFilePath = ui->PaletteFilenameCombo->itemText(0).toStdString();
@ -91,7 +91,7 @@ Palette<float>& PaletteEditor::GetPalette(int size)
/// <param name="palette">The palette to assign</param>
void PaletteEditor::SetPalette(const Palette<float>& palette)
{
auto combo = ui->PaletteFilenameCombo;
const auto combo = ui->PaletteFilenameCombo;
m_PaletteIndex = std::numeric_limits<int>::max();
m_GradientColorView->SetPalette(palette);
auto& arrows = m_GradientColorView->GetArrows();
@ -241,7 +241,7 @@ void PaletteEditor::OnResetToDefaultButtonClicked()
/// </summary>
void PaletteEditor::OnCreatePaletteFromImageButtonClicked()
{
auto filenames = SetupOpenImagesDialog();
const auto filenames = SetupOpenImagesDialog();
if (!filenames.empty())
{
@ -317,7 +317,7 @@ void PaletteEditor::OnSyncCheckBoxStateChanged(int state)
/// <param name="state">Ignored</param>
void PaletteEditor::OnBlendCheckBoxStateChanged(int state)
{
m_GradientColorView->Blend((bool)state);
m_GradientColorView->Blend(static_cast<bool>(state));
m_GradientColorView->update();
EmitPaletteChanged();
}
@ -331,10 +331,10 @@ void PaletteEditor::OnPaletteFilenameComboChanged(const QString& text)
{
if (!text.isEmpty())//This occasionally seems to get called with an empty string for reasons unknown.
{
auto paletteTable = ui->PaletteListTable;
const auto paletteTable = ui->PaletteListTable;
m_CurrentPaletteFilePath = text.toStdString();
::FillPaletteTable(text.toStdString(), paletteTable, m_PaletteList);
auto fullname = m_PaletteList->GetFullPathFromFilename(m_CurrentPaletteFilePath);
const auto fullname = m_PaletteList->GetFullPathFromFilename(m_CurrentPaletteFilePath);
ui->PaletteFilenameCombo->setToolTip(QString::fromStdString(fullname));
EnablePaletteFileControls();
}
@ -350,7 +350,7 @@ void PaletteEditor::OnPaletteCellClicked(int row, int col)
{
if (col == 1)
{
if (auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
if (const auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
{
SetPalette(*palette);
m_PaletteIndex = row;
@ -368,7 +368,7 @@ void PaletteEditor::OnPaletteCellChanged(int row, int col)
{
if (col == 0)
{
if (auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
if (const auto palette = m_PaletteList->GetPaletteByFilename(m_CurrentPaletteFilePath, row))
{
if (!palette->m_SourceColors.empty())
{
@ -386,7 +386,7 @@ void PaletteEditor::OnPaletteCellChanged(int row, int col)
/// </summary>
void PaletteEditor::OnNewPaletteFileButtonClicked()
{
auto filename = EmberFile<float>::UniqueFilename(GetDefaultUserPath() + "/user-palettes.xml");
const auto filename = EmberFile<float>::UniqueFilename(GetDefaultUserPath() + "/user-palettes.xml");
if (m_PaletteList->AddEmptyPaletteFile(filename.toStdString()))
{
@ -404,18 +404,18 @@ void PaletteEditor::OnNewPaletteFileButtonClicked()
void PaletteEditor::OnCopyPaletteFileButtonClicked()
{
auto& paletteFiles = m_PaletteList->Palettes();
auto qscurr = QString::fromStdString(m_CurrentPaletteFilePath);
auto qfilename = EmberFile<float>::UniqueFilename(GetDefaultUserPath() + "/" + qscurr);
auto filename = qfilename.toStdString();
const auto qscurr = QString::fromStdString(m_CurrentPaletteFilePath);
const auto qfilename = EmberFile<float>::UniqueFilename(GetDefaultUserPath() + "/" + qscurr);
const auto filename = qfilename.toStdString();
if (m_PaletteList->GetPaletteListByFullPath(filename) == nullptr)//Ensure the new filename does not exist in the map.
{
//Get the list of palettes for the current filename, this will be added as a copy below.
if (auto currentPaletteFile = m_PaletteList->GetPaletteListByFilename(m_CurrentPaletteFilePath))//Ensure the list of palettes was properly retrieved.
if (const auto currentPaletteFile = m_PaletteList->GetPaletteListByFilename(m_CurrentPaletteFilePath))//Ensure the list of palettes was properly retrieved.
{
if (m_PaletteList->AddPaletteFile(filename, *currentPaletteFile))//Add the current vector of palettes to an entry with the new filename.
{
QFileInfo info(qfilename);
const QFileInfo info(qfilename);
ui->PaletteFilenameCombo->addItem(info.fileName());
ui->PaletteFilenameCombo->setCurrentIndex(ui->PaletteFilenameCombo->count() - 1);
}
@ -435,7 +435,7 @@ void PaletteEditor::OnCopyPaletteFileButtonClicked()
/// </summary>
void PaletteEditor::OnAppendPaletteButtonClicked()
{
auto& pal = GetPalette(256);
const auto& pal = GetPalette(256);
m_PaletteList->AddPaletteToFile(m_CurrentPaletteFilePath, pal);
::FillPaletteTable(m_CurrentPaletteFilePath, ui->PaletteListTable, m_PaletteList);
m_PaletteIndex = ui->PaletteListTable->rowCount() - 1;
@ -448,7 +448,7 @@ void PaletteEditor::OnAppendPaletteButtonClicked()
/// </summary>
void PaletteEditor::OnOverwritePaletteButtonClicked()
{
auto& pal = GetPalette(256);
const auto& pal = GetPalette(256);
m_PaletteList->Replace(m_CurrentPaletteFilePath, pal, m_PaletteIndex);
::FillPaletteTable(m_CurrentPaletteFilePath, ui->PaletteListTable, m_PaletteList);
emit PaletteFileChanged();
@ -461,7 +461,7 @@ void PaletteEditor::OnOverwritePaletteButtonClicked()
/// </summary>
void PaletteEditor::OnDeletePaletteButtonClicked()
{
auto table = ui->PaletteListTable;
const auto table = ui->PaletteListTable;
if (table->rowCount() > 1)
{
@ -520,7 +520,7 @@ void PaletteEditor::EmitColorIndexChanged(size_t index, float value)
QStringList PaletteEditor::SetupOpenImagesDialog()
{
QStringList filenames;
auto settings = FractoriumSettings::Instance();
const auto settings = FractoriumSettings::Instance();
#ifndef __APPLE__
if (!m_FileDialog)
@ -547,19 +547,19 @@ QStringList PaletteEditor::SetupOpenImagesDialog()
if (!filenames.empty())
{
auto path = QFileInfo(filenames[0]).canonicalPath();
const auto path = QFileInfo(filenames[0]).canonicalPath();
m_FileDialog->setDirectory(path);
settings->OpenPaletteImageFolder(path);
}
}
#else
auto filename = QFileDialog::getOpenFileName(this, tr("Open Image"), settings->OpenPaletteImageFolder(), tr("Image Files (*.jpg *.png)"));
const auto filename = QFileDialog::getOpenFileName(this, tr("Open Image"), settings->OpenPaletteImageFolder(), tr("Image Files (*.jpg *.png)"));
if (filename.size() > 0)
{
filenames.append(filename);
auto path = QFileInfo(filenames[0]).canonicalPath();
const auto path = QFileInfo(filenames[0]).canonicalPath();
settings->OpenPaletteImageFolder(path);
}
@ -574,9 +574,9 @@ QStringList PaletteEditor::SetupOpenImagesDialog()
/// <param name="color">The color to assign to the new arrow</param>
void PaletteEditor::AddArrow(const QColor& color)
{
auto count = std::min<int>(std::abs(256 - m_GradientColorView->ArrowCount()), ui->ArrowsSpinBox->value());
const auto count = std::min<int>(std::abs(256 - m_GradientColorView->ArrowCount()), ui->ArrowsSpinBox->value());
for (int i = 0; i < count; i++)
for (auto i = 0; i < count; i++)
{
m_GradientColorView->AddArrow(color);
@ -594,18 +594,18 @@ void PaletteEditor::AddArrow(const QColor& color)
map<float, GradientArrow> PaletteEditor::GetRandomColorsFromImage(QString filename, int numPoints)
{
map<float, GradientArrow> colors;
QTime time = QTime::currentTime();
const auto time = QTime::currentTime();
qsrand((uint)time.msec());
QImage image(filename);
const QImage image(filename);
const qreal gSize = 512;
float off = 0.0f, inc = 1.0f / std::max(1, numPoints - 1);
QLinearGradient grad(QPoint(0, 0), QPoint(gSize, 1));
for (int i = 0; i < numPoints; i++)
for (auto i = 0; i < numPoints; i++)
{
int x = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(image.width());
int y = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(image.height());
QRgb rgb = image.pixel(x, y);
const auto x = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(image.width());
const auto y = QTIsaac<ISAAC_SIZE, ISAAC_INT>::LockedRand(image.height());
const auto rgb = image.pixel(x, y);
GradientArrow arrow;
arrow.Color(QColor::fromRgb(rgb));
arrow.Focus(i == 0);
@ -621,7 +621,7 @@ map<float, GradientArrow> PaletteEditor::GetRandomColorsFromImage(QString filena
/// </summary>
void PaletteEditor::EnablePaletteFileControls()
{
bool b = IsCurrentPaletteAndFileEditable();//Both the file and the current palette must be editable.
const auto b = IsCurrentPaletteAndFileEditable();//Both the file and the current palette must be editable.
ui->DeletePaletteButton->setEnabled(b);
ui->CopyPaletteFileButton->setEnabled(b);
ui->AppendPaletteButton->setEnabled(b);
@ -633,8 +633,8 @@ void PaletteEditor::EnablePaletteFileControls()
/// </summary>
void PaletteEditor::EnablePaletteControls()
{
bool b = IsCurrentPaletteAndFileEditable();//Both the file and the current palette must be editable.
auto& pal = GetPalette(256);
const auto b = IsCurrentPaletteAndFileEditable();//Both the file and the current palette must be editable.
const auto& pal = GetPalette(256);
ui->DeletePaletteButton->setEnabled(b);
ui->CopyPaletteFileButton->setEnabled(b);
ui->AppendPaletteButton->setEnabled(b);

View File

@ -46,7 +46,7 @@ void SpinBox::SetValueStealth(int d)
blockSignals(false);
}
void SpinBox::SetValueStealth(size_t d) { SetValueStealth(int(d)); }
void SpinBox::SetValueStealth(size_t d) { SetValueStealth(static_cast<int>(d)); }
/// <summary>
/// Set whether to respond to double click events.
@ -166,7 +166,7 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
if (!isEnabled())
return QSpinBox::eventFilter(o, e);
auto me = dynamic_cast<QMouseEvent*>(e);
const auto me = dynamic_cast<QMouseEvent*>(e);
if (me)
{
@ -221,8 +221,8 @@ bool SpinBox::eventFilter(QObject* o, QEvent* e)
{
if (QWheelEvent* we = dynamic_cast<QWheelEvent*>(e))
{
bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
const auto shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
const auto ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
if (we->angleDelta().ry() > 0)
{

View File

@ -38,12 +38,12 @@ public slots:
void OnTimeout();
protected:
virtual bool eventFilter(QObject* o, QEvent* e) override;
virtual void keyPressEvent(QKeyEvent* event) override;
virtual void focusInEvent(QFocusEvent* e) override;
virtual void focusOutEvent(QFocusEvent* e) override;
virtual void enterEvent(QEvent* e) override;
virtual void leaveEvent(QEvent* e) override;
bool eventFilter(QObject* o, QEvent* e) override;
void keyPressEvent(QKeyEvent* event) override;
void focusInEvent(QFocusEvent* e) override;
void focusOutEvent(QFocusEvent* e) override;
void enterEvent(QEvent* e) override;
void leaveEvent(QEvent* e) override;
private:
void StartTimer();

View File

@ -39,11 +39,11 @@ protected:
/// <param name="obj">The object sending the event</param>
/// <param name="e">The event</param>
/// <returns>The result of calling the base fucntion.</returns>
bool eventFilter(QObject* obj, QEvent* e)
bool eventFilter(QObject* obj, QEvent* e) override
{
if (e->type() == QEvent::MouseMove)
{
if (auto me = dynamic_cast<QMouseEvent*>(e))
if (const auto me = dynamic_cast<QMouseEvent*>(e))
{
emit MouseDragged(me->localPos(), me->globalPos());
}

View File

@ -52,7 +52,7 @@ private:
/// <returns>True if this is less than other, else false.</returns>
bool operator < (const QTreeWidgetItem& other) const
{
int column = treeWidget()->sortColumn();
const auto column = treeWidget()->sortColumn();
auto itemWidget1 = treeWidget()->itemWidget(const_cast<VariationTreeWidgetItem*>(this), 1);//Get the widget for the second column.
if (auto spinBox1 = dynamic_cast<VariationTreeDoubleSpinBox*>(itemWidget1))//Cast the widget to the VariationTreeDoubleSpinBox type.
@ -64,10 +64,10 @@ private:
if (spinBox1->IsParam() || spinBox2->IsParam())//Do not sort params, their order will always remain the same.
return false;
auto weight1 = spinBox1->value();
auto weight2 = spinBox2->value();
auto index1 = spinBox1->GetVariationId();
auto index2 = spinBox2->GetVariationId();
const auto weight1 = spinBox1->value();
const auto weight2 = spinBox2->value();
const auto index1 = spinBox1->GetVariationId();
const auto index2 = spinBox2->GetVariationId();
if (column == 0)//First column clicked, sort by variation index.
{

View File

@ -13,7 +13,7 @@ FractoriumVariationsDialog::FractoriumVariationsDialog(QWidget* p, Qt::WindowFla
m_VariationList(VariationList<float>::Instance())
{
ui.setupUi(this);
auto table = ui.VariationsTable;
const auto table = ui.VariationsTable;
m_Settings = FractoriumSettings::DefInstance();
m_Vars = m_Settings->Variations();
Populate();
@ -26,22 +26,22 @@ FractoriumVariationsDialog::FractoriumVariationsDialog(QWidget* p, Qt::WindowFla
m_CheckBoxes.push_back(ui.StateCheckBox);
m_CheckBoxes.push_back(ui.ParamCheckBox);
m_CheckBoxes.push_back(ui.NonParamCheckBox);
ui.SumCheckBox->setCheckState (Qt::CheckState(m_Settings->VarFilterSum ()));
ui.AssignCheckBox->setCheckState (Qt::CheckState(m_Settings->VarFilterAssign ()));
ui.PpSumCheckBox->setCheckState (Qt::CheckState(m_Settings->VarFilterPpsum ()));
ui.PpAssignCheckBox->setCheckState(Qt::CheckState(m_Settings->VarFilterPpassign()));
ui.DcCheckBox->setCheckState (Qt::CheckState(m_Settings->VarFilterSdc ()));
ui.StateCheckBox->setCheckState (Qt::CheckState(m_Settings->VarFilterState ()));
ui.ParamCheckBox->setCheckState (Qt::CheckState(m_Settings->VarFilterParam ()));
ui.NonParamCheckBox->setCheckState(Qt::CheckState(m_Settings->VarFilterNonparam()));
ui.SumCheckBox->setCheckState (static_cast<Qt::CheckState>(m_Settings->VarFilterSum ()));
ui.AssignCheckBox->setCheckState (static_cast<Qt::CheckState>(m_Settings->VarFilterAssign ()));
ui.PpSumCheckBox->setCheckState (static_cast<Qt::CheckState>(m_Settings->VarFilterPpsum ()));
ui.PpAssignCheckBox->setCheckState(static_cast<Qt::CheckState>(m_Settings->VarFilterPpassign()));
ui.DcCheckBox->setCheckState (static_cast<Qt::CheckState>(m_Settings->VarFilterSdc ()));
ui.StateCheckBox->setCheckState (static_cast<Qt::CheckState>(m_Settings->VarFilterState ()));
ui.ParamCheckBox->setCheckState (static_cast<Qt::CheckState>(m_Settings->VarFilterParam ()));
ui.NonParamCheckBox->setCheckState(static_cast<Qt::CheckState>(m_Settings->VarFilterNonparam()));
for (auto& cb : m_CheckBoxes)
{
if (cb->checkState() == Qt::CheckState::PartiallyChecked)
{
auto f = cb->font();
f.setStrikeOut(true);
cb->setFont(f);
auto font = cb->font();
font.setStrikeOut(true);
cb->setFont(font);
}
}
@ -52,13 +52,13 @@ FractoriumVariationsDialog::FractoriumVariationsDialog(QWidget* p, Qt::WindowFla
connect(ui.SelectAllButton, SIGNAL(clicked(bool)), this, SLOT(OnSelectAllButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.InvertSelectionButton, SIGNAL(clicked(bool)), this, SLOT(OnInvertSelectionButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.SelectNoneButton, SIGNAL(clicked(bool)), this, SLOT(OnSelectNoneButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.SumCheckBox , SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.AssignCheckBox , SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.PpSumCheckBox , SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.SumCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.AssignCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.PpSumCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.PpAssignCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.DcCheckBox , SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.StateCheckBox , SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.ParamCheckBox , SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.DcCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.StateCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.ParamCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
connect(ui.NonParamCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSelectionCheckBoxStateChanged(int)), Qt::QueuedConnection);
}
@ -68,14 +68,14 @@ FractoriumVariationsDialog::FractoriumVariationsDialog(QWidget* p, Qt::WindowFla
/// <param name="func">Function to call on each object</param>
void FractoriumVariationsDialog::ForEachCell(std::function<void(QTableWidgetItem* cb)> func)
{
auto table = ui.VariationsTable;
auto rows = table->rowCount();
auto cols = table->columnCount();
const auto table = ui.VariationsTable;
const auto rows = table->rowCount();
const auto cols = table->columnCount();
table->model()->blockSignals(true);
for (auto row = 0; row < rows; row++)
for (auto col = 0; col < cols; col++)
if (auto cb = table->item(row, col))
if (const auto cb = table->item(row, col))
func(cb);
table->model()->blockSignals(false);
@ -88,8 +88,8 @@ void FractoriumVariationsDialog::ForEachCell(std::function<void(QTableWidgetItem
/// <param name="func">Function to call on each object</param>
void FractoriumVariationsDialog::ForEachSelectedCell(std::function<void(QTableWidgetItem* cb)> func)
{
auto table = ui.VariationsTable;
QList<QTableWidgetItem*> selectedItems = table->selectedItems();
const auto table = ui.VariationsTable;
const auto selectedItems = table->selectedItems();
table->model()->blockSignals(true);
for (auto item : selectedItems)
@ -112,14 +112,14 @@ void FractoriumVariationsDialog::SyncSettings()
m[cb->text()] = cb->checkState() == Qt::CheckState::Checked;
});
m_Settings->Variations(m);
m_Settings->VarFilterSum (int(ui.SumCheckBox->checkState()));
m_Settings->VarFilterAssign (int(ui.AssignCheckBox->checkState()));
m_Settings->VarFilterPpsum (int(ui.PpSumCheckBox->checkState()));
m_Settings->VarFilterPpassign(int(ui.PpAssignCheckBox->checkState()));
m_Settings->VarFilterSdc (int(ui.DcCheckBox->checkState()));
m_Settings->VarFilterState (int(ui.StateCheckBox->checkState()));
m_Settings->VarFilterParam (int(ui.ParamCheckBox->checkState()));
m_Settings->VarFilterNonparam(int(ui.NonParamCheckBox->checkState()));
m_Settings->VarFilterSum (static_cast<int>(ui.SumCheckBox->checkState()));
m_Settings->VarFilterAssign (static_cast<int>(ui.AssignCheckBox->checkState()));
m_Settings->VarFilterPpsum (static_cast<int>(ui.PpSumCheckBox->checkState()));
m_Settings->VarFilterPpassign(static_cast<int>(ui.PpAssignCheckBox->checkState()));
m_Settings->VarFilterSdc (static_cast<int>(ui.DcCheckBox->checkState()));
m_Settings->VarFilterState (static_cast<int>(ui.StateCheckBox->checkState()));
m_Settings->VarFilterParam (static_cast<int>(ui.ParamCheckBox->checkState()));
m_Settings->VarFilterNonparam(static_cast<int>(ui.NonParamCheckBox->checkState()));
}
/// <summary>
@ -197,7 +197,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
static std::set<eVariationId> excluded;
excluded.clear();
if (auto s = dynamic_cast<QCheckBox*>(sender()))
if (const auto s = dynamic_cast<QCheckBox*>(sender()))
{
auto f = s->font();
f.setStrikeOut(s->checkState() == Qt::CheckState::PartiallyChecked);
@ -207,7 +207,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
ForEachCell([&](QTableWidgetItem * cb) { cb->setCheckState(Qt::CheckState::Unchecked); });
ForEachCell([&](QTableWidgetItem * cb)
{
if (auto var = m_VariationList->GetVariation(cb->text().toStdString()))
if (const auto var = m_VariationList->GetVariation(cb->text().toStdString()))
{
if (ui.StateCheckBox->checkState() != Qt::CheckState::Unchecked)
{
@ -282,7 +282,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
if (ui.PpSumCheckBox->isChecked() != Qt::CheckState::Unchecked)
{
if (auto pre = m_VariationList->GetPreVariation(cb->text().toStdString()))
if (const auto pre = m_VariationList->GetPreVariation(cb->text().toStdString()))
{
if (pre->AssignType() == eVariationAssignType::ASSIGNTYPE_SUM)
{
@ -296,7 +296,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
}
}
if (auto post = m_VariationList->GetPostVariation(cb->text().toStdString()))
if (const auto post = m_VariationList->GetPostVariation(cb->text().toStdString()))
{
if (post->AssignType() == eVariationAssignType::ASSIGNTYPE_SUM)
{
@ -313,7 +313,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
if (ui.PpAssignCheckBox->isChecked() != Qt::CheckState::Unchecked)
{
if (auto pre = m_VariationList->GetPreVariation(cb->text().toStdString()))
if (const auto pre = m_VariationList->GetPreVariation(cb->text().toStdString()))
{
if (pre->AssignType() == eVariationAssignType::ASSIGNTYPE_SET)
{
@ -327,7 +327,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
}
}
if (auto post = m_VariationList->GetPostVariation(cb->text().toStdString()))
if (const auto post = m_VariationList->GetPostVariation(cb->text().toStdString()))
{
if (post->AssignType() == eVariationAssignType::ASSIGNTYPE_SET)
{
@ -344,7 +344,7 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
if (ui.ParamCheckBox->isChecked() != Qt::CheckState::Unchecked)
{
if (auto parVar = m_VariationList->GetParametricVariation(cb->text().toStdString()))
if (const auto parVar = m_VariationList->GetParametricVariation(cb->text().toStdString()))
{
if (ui.ParamCheckBox->checkState() == Qt::CheckState::PartiallyChecked)
{
@ -363,29 +363,29 @@ void FractoriumVariationsDialog::OnSelectionCheckBoxStateChanged(int i)
/// </summary>
void FractoriumVariationsDialog::Populate()
{
auto table = ui.VariationsTable;
int size = int(std::max<size_t>(std::max<size_t>(m_VariationList->RegSize(), m_VariationList->PreSize()), m_VariationList->PostSize()));
const auto table = ui.VariationsTable;
const auto size = static_cast<int>(std::max<size_t>(std::max<size_t>(m_VariationList->RegSize(), m_VariationList->PreSize()), m_VariationList->PostSize()));
table->setRowCount(size);
for (auto i = 0; i < size; i++)
{
if (auto pre = m_VariationList->GetVariation(i, eVariationType::VARTYPE_PRE))
if (const auto pre = m_VariationList->GetVariation(i, eVariationType::VARTYPE_PRE))
{
auto cb = new QTableWidgetItem(pre->Name().c_str());
const auto cb = new QTableWidgetItem(pre->Name().c_str());
table->setItem(i, 0, cb);
SetCheckFromMap(cb, pre);
}
if (auto reg = m_VariationList->GetVariation(i, eVariationType::VARTYPE_REG))
if (const auto reg = m_VariationList->GetVariation(i, eVariationType::VARTYPE_REG))
{
auto cb = new QTableWidgetItem(reg->Name().c_str());
const auto cb = new QTableWidgetItem(reg->Name().c_str());
table->setItem(i, 1, cb);
SetCheckFromMap(cb, reg);
}
if (auto post = m_VariationList->GetVariation(i, eVariationType::VARTYPE_POST))
if (const auto post = m_VariationList->GetVariation(i, eVariationType::VARTYPE_POST))
{
auto cb = new QTableWidgetItem(post->Name().c_str());
const auto cb = new QTableWidgetItem(post->Name().c_str());
table->setItem(i, 2, cb);
SetCheckFromMap(cb, post);
}
@ -401,7 +401,7 @@ void FractoriumVariationsDialog::Populate()
/// <param name="item"></param>
void FractoriumVariationsDialog::OnVariationsTableItemChanged(QTableWidgetItem* item)
{
bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
const auto ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier);
if (ctrl)
ForEachSelectedCell([&](QTableWidgetItem * cb) { cb->setCheckState(item->checkState()); });
@ -445,7 +445,7 @@ void FractoriumVariationsDialog::DataToGui()
{
ForEachCell([&](QTableWidgetItem * cb)
{
if (auto var = m_VariationList->GetVariation(cb->text().toStdString()))
if (const auto var = m_VariationList->GetVariation(cb->text().toStdString()))
SetCheckFromMap(cb, var);
});
}
@ -457,7 +457,7 @@ void FractoriumVariationsDialog::GuiToData()
{
ForEachCell([&](QTableWidgetItem * cb)
{
if (auto var = m_VariationList->GetVariation(cb->text().toStdString()))
if (const auto var = m_VariationList->GetVariation(cb->text().toStdString()))
m_Vars[cb->text()] = (cb->checkState() == Qt::Checked);
});
}
@ -476,7 +476,7 @@ void FractoriumVariationsDialog::SetCheckFromMap(QTableWidgetItem* cb, const Var
}
else
{
bool chk = m_Vars[var->Name().c_str()].toBool();
const auto chk = m_Vars[var->Name().c_str()].toBool();
cb->setCheckState(chk ? Qt::Checked : Qt::Unchecked);
}
}

View File

@ -31,11 +31,11 @@ public slots:
void OnSelectNoneButtonClicked(bool checked);
void OnSelectionCheckBoxStateChanged(int i);
void OnVariationsTableItemChanged(QTableWidgetItem* item);
virtual void accept() override;
virtual void reject() override;
void accept() override;
void reject() override;
protected:
virtual void showEvent(QShowEvent* e) override;
void showEvent(QShowEvent* e) override;
private:
void ClearTypesStealth();

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
fractorium (22.21.4.2-0ubuntu1) bionic; urgency=low
* release 22.21.4.2
-- Matt Feemster <matt.feemster@gmail.com> Mon, 19 Apr 2021 10:42:17 -0700
fractorium (21.21.4.1-0ubuntu1) bionic; urgency=low
* release 21.21.4.1