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

@ -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();