--Code changes

-Fix up Miche's work on allowing a small subset of parameters to be copied from the main window to the final render dialog when doing save/render again.
This commit is contained in:
Person 2020-01-04 01:02:30 -08:00
parent aee36b52ab
commit ba1e5ed922
6 changed files with 120 additions and 74 deletions

View File

@ -219,14 +219,14 @@ void CurvesGraphicsView::mousePressEvent(QMouseEvent* e)
{ {
QGraphicsView::mousePressEvent(e); QGraphicsView::mousePressEvent(e);
auto thresh = devicePixelRatioF() * 4; auto thresh = devicePixelRatioF() * 4;
auto findpoint = [&](int x, int y, bool incThresh = false) -> int auto findpoint = [&](int x, int y, double thresh) -> int
{ {
for (int i = 0; i < m_Points[m_Index].size(); i++) for (int i = 0; i < m_Points[m_Index].size(); i++)
{ {
auto item = m_Points[m_Index][i]; auto item = m_Points[m_Index][i];
auto xdist = std::abs(item->pos().x() - x); auto xdist = std::abs(item->pos().x() - x);
auto ydist = std::abs(item->pos().y() - y); auto ydist = std::abs(item->pos().y() - y);
auto threshAgain = incThresh ? thresh * 2 : thresh; auto threshAgain = thresh;
if (xdist < threshAgain && ydist < threshAgain) if (xdist < threshAgain && ydist < threshAgain)
return i; return i;
@ -237,12 +237,12 @@ void CurvesGraphicsView::mousePressEvent(QMouseEvent* e)
if (e->button() == Qt::RightButton) if (e->button() == Qt::RightButton)
{ {
int i = findpoint(e->pos().x(), e->pos().y()); int i = findpoint(e->pos().x(), e->pos().y(), thresh);
if (i != -1) if (i != -1)
emit PointRemovedSignal(m_Index, i); emit PointRemovedSignal(m_Index, i);
} }
else if (findpoint(e->pos().x(), e->pos().y(), true) == -1) else if (findpoint(e->pos().x(), e->pos().y(), thresh * 8) == -1)
{ {
QRectF rect = scene()->sceneRect(); QRectF rect = scene()->sceneRect();
auto points = m_Points[m_Index]; auto points = m_Points[m_Index];

View File

@ -164,11 +164,11 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(QWidget* p, Qt::WindowF
m_StripsSpin->setValue(int(m_Settings->FinalStrips())); m_StripsSpin->setValue(int(m_Settings->FinalStrips()));
Scale(eScaleType(m_Settings->FinalScale())); Scale(eScaleType(m_Settings->FinalScale()));
auto bumpmenu = new QMenu(this); auto bumpmenu = new QMenu(this);
auto add10 = new QAction("Add 10% quality", this); add10->setProperty("tag", QVariant(0.10)); 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 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 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 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)); auto add200 = new QAction("Add 200% Quality", this); add200->setProperty("tag", QVariant(2.0));
bumpmenu->addAction(add10); bumpmenu->addAction(add10);
bumpmenu->addAction(add25); bumpmenu->addAction(add25);
bumpmenu->addAction(add50); bumpmenu->addAction(add50);
@ -192,7 +192,7 @@ FractoriumFinalRenderDialog::FractoriumFinalRenderDialog(QWidget* p, Qt::WindowF
saamenu->addAction(saaexr); saamenu->addAction(saaexr);
ui.FinalRenderSaveAgainAsButton->setMenu(saamenu); ui.FinalRenderSaveAgainAsButton->setMenu(saamenu);
ui.FinalRenderSaveAgainAsButton->setProperty("tag", "jpg"); ui.FinalRenderSaveAgainAsButton->setProperty("tag", "jpg");
ui.FinalRenderSaveAgainAsButton->setText("Save again as jpg"); ui.FinalRenderSaveAgainAsButton->setText("Save Again as jpg");
ui.FinalRenderSaveAgainAsButton->setEnabled(false); ui.FinalRenderSaveAgainAsButton->setEnabled(false);
connect(ui.FinalRenderSaveAgainAsButton, SIGNAL(clicked()), this, SLOT(OnSaveAgainAsClicked())); connect(ui.FinalRenderSaveAgainAsButton, SIGNAL(clicked()), this, SLOT(OnSaveAgainAsClicked()));
connect(ui.FinalRenderBumpQualityStartButton, SIGNAL(clicked()), this, SLOT(OnQualityBumpClicked())); connect(ui.FinalRenderBumpQualityStartButton, SIGNAL(clicked()), this, SLOT(OnQualityBumpClicked()));
@ -823,7 +823,7 @@ void FractoriumFinalRenderDialog::OnSaveAgainAsClicked()
} }
else if (act) else if (act)
{ {
ui.FinalRenderSaveAgainAsButton->setText("Save again as " + act->text()); ui.FinalRenderSaveAgainAsButton->setText("Save Again as " + act->text());
ui.FinalRenderSaveAgainAsButton->setProperty("tag", act->text()); ui.FinalRenderSaveAgainAsButton->setProperty("tag", act->text());
} }
} }

View File

@ -1194,6 +1194,9 @@
</item> </item>
<item> <item>
<widget class="QToolButton" name="FinalRenderSaveAgainAsButton"> <widget class="QToolButton" name="FinalRenderSaveAgainAsButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Save the rendered image again using the specified file type.&lt;/p&gt;&lt;p&gt;This will copy in the values for Brightness, Gamma, Gamma Threshold, Vibrancy, Highlight Power, K2, Spatial Filter Type/Width, MinDE, MaxDE and CurveDE from the main window, and if any have changed, it will perform the filtering and imaging steps of the rendering process again before saving.&lt;/p&gt;&lt;p&gt;The values will not be copied from the main window if Strips is greater than 1.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Save Again As</string> <string>Save Again As</string>
</property> </property>
@ -1207,6 +1210,9 @@
</item> </item>
<item> <item>
<widget class="QToolButton" name="FinalRenderBumpQualityStartButton"> <widget class="QToolButton" name="FinalRenderBumpQualityStartButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Render with the additional quality specified, picking up where the last render left off.&lt;/p&gt;&lt;p&gt;This will copy in the values for Brightness, Gamma, Gamma Threshold, Vibrancy, Highlight Power, K2, Spatial Filter Type/Width, MinDE, MaxDE and CurveDE from the main window and will apply them in the filtering and imaging steps of the rendering process.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text"> <property name="text">
<string>Add Quality</string> <string>Add Quality</string>
</property> </property>

View File

@ -118,6 +118,7 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
m_FinishedImageCount.store(0); m_FinishedImageCount.store(0);
Pause(false); Pause(false);
ResetProgress(); ResetProgress();
FirstOrDefaultRenderer()->m_ProgressParameter = reinterpret_cast<void*>(&currentStripForProgress);//When animating, only the first (primary) device has a progress parameter.
if (!isBump) if (!isBump)
{ {
@ -128,7 +129,6 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
m_XmlWriter.Save(backup.toStdString().c_str(), *m_Ember, 0, true, false, true, false, false); m_XmlWriter.Save(backup.toStdString().c_str(), *m_Ember, 0, true, false, true, false, false);
SyncGuiToRenderer(); SyncGuiToRenderer();
FirstOrDefaultRenderer()->m_ProgressParameter = reinterpret_cast<void*>(&currentStripForProgress);//When animating, only the first (primary) device has a progress parameter.
m_GuiState.m_Strips = VerifyStrips(m_Ember->m_FinalRasH, m_GuiState.m_Strips, m_GuiState.m_Strips = VerifyStrips(m_Ember->m_FinalRasH, m_GuiState.m_Strips,
[&](const string & s) { Output(QString::fromStdString(s)); }, //Greater than height. [&](const string & s) { Output(QString::fromStdString(s)); }, //Greater than height.
[&](const string & s) { Output(QString::fromStdString(s)); }, //Mod height != 0. [&](const string & s) { Output(QString::fromStdString(s)); }, //Mod height != 0.
@ -297,7 +297,7 @@ FinalRenderEmberController<T>::FinalRenderEmberController(FractoriumFinalRenderD
{ {
m_ImageCount = 1; m_ImageCount = 1;
m_Ember->m_TemporalSamples = 1; m_Ember->m_TemporalSamples = 1;
m_Fractorium->m_Controller->ParamsToEmber(*m_Ember, true); // update color and filter params 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.
m_Renderer->SetEmber(*m_Ember, isBump ? eProcessAction::KEEP_ITERATING : eProcessAction::FULL_RENDER); m_Renderer->SetEmber(*m_Ember, isBump ? eProcessAction::KEEP_ITERATING : eProcessAction::FULL_RENDER);
m_Renderer->PrepFinalAccumVector(m_FinalImage);//Must manually call this first because it could be erroneously made smaller due to strips if called inside Renderer::Run(). m_Renderer->PrepFinalAccumVector(m_FinalImage);//Must manually call this first because it could be erroneously made smaller due to strips if called inside Renderer::Run().
m_Stats.Clear(); m_Stats.Clear();
@ -750,6 +750,8 @@ EmberNs::Renderer<T, float>* FinalRenderEmberController<T>::FirstOrDefaultRender
/// <summary> /// <summary>
/// Save the output of the last rendered image using the existing image output buffer in the renderer. /// Save the output of the last rendered image using the existing image output buffer in the renderer.
/// Before rendering, this copies the image coloring/filtering values used in the last step of the rendering
/// process, and performs that part of the render, before saving.
/// </summary> /// </summary>
/// <returns>The full path and filename the image was saved to.</returns> /// <returns>The full path and filename the image was saved to.</returns>
template<typename T> template<typename T>
@ -758,12 +760,50 @@ QString FinalRenderEmberController<T>::SaveCurrentAgain()
if (!m_Ember) if (!m_Ember)
return ""; return "";
m_Fractorium->m_Controller->ParamsToEmber(*m_Ember, true); // update color and filter params 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;
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;
//This is sort of a hack outside of the normal rendering process above.
if (dofilterandaccum ||
gamma != m_Ember->m_Gamma ||
gammathresh != m_Ember->m_GammaThresh ||
vibrancy != m_Ember->m_Vibrancy ||
highlight != m_Ember->m_HighlightPower ||
sftype != m_Ember->m_SpatialFilterType ||
sfradius != m_Ember->m_SpatialFilterRadius
)
{
m_Run = true; m_Run = true;
m_FinishedImageCount.store(0);
m_Ember->m_TemporalSamples = 1; m_Ember->m_TemporalSamples = 1;
m_Renderer->SetEmber(*m_Ember, eProcessAction::FILTER_AND_ACCUM); m_Renderer->m_ProgressParameter = reinterpret_cast<void*>(&currentStripForProgress);//Need to reset this because it was set to a local variable within the render thread.
m_Renderer->SetEmber(*m_Ember, dofilterandaccum ? eProcessAction::FILTER_AND_ACCUM : eProcessAction::ACCUM_ONLY);
m_Renderer->Run(m_FinalImage, 0, m_GuiState.m_Strips, m_GuiState.m_YAxisUp); m_Renderer->Run(m_FinalImage, 0, m_GuiState.m_Strips, m_GuiState.m_YAxisUp);
m_FinishedImageCount.fetch_add(1);
HandleFinishedProgress();
m_Run = false; m_Run = false;
}
}
return SaveCurrentRender(*m_Ember); return SaveCurrentRender(*m_Ember);
} }
@ -868,7 +908,7 @@ void FinalRenderEmberController<T>::HandleFinishedProgress()
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, int((float(finishedCountCached) / 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.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() && m_GuiState.m_Strips == 1)); 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)); QMetaObject::invokeMethod(m_FinalRenderDialog->ui.FinalRenderBumpQualityStartButton, "setEnabled", Qt::QueuedConnection, Q_ARG(bool, !doAll && m_Renderer.get() && m_GuiState.m_Strips == 1));
} }

View File

@ -139,9 +139,9 @@ public:
virtual void SequenceOpenButtonClicked() { } virtual void SequenceOpenButtonClicked() { }
//Params. //Params.
virtual void ParamsToEmber(Ember<float>& ember, bool basicParams = false) { }; virtual void ParamsToEmber(Ember<float>& ember, bool imageParamsOnly = false) { };
#ifdef DO_DOUBLE #ifdef DO_DOUBLE
virtual void ParamsToEmber(Ember<double>& ember, bool basicParams = false) { }; virtual void ParamsToEmber(Ember<double>& ember, bool imageParamsOnly = false) { };
#endif #endif
virtual void SetCenter(double x, double y) { } virtual void SetCenter(double x, double y) { }
virtual void FillParamTablesAndPalette() { } virtual void FillParamTablesAndPalette() { }
@ -425,9 +425,9 @@ public:
virtual void SequenceOpenButtonClicked() override; virtual void SequenceOpenButtonClicked() override;
//Params. //Params.
virtual void ParamsToEmber(Ember<float>& ember, bool basicParams = false) override; virtual void ParamsToEmber(Ember<float>& ember, bool imageParamsOnly = false) override;
#ifdef DO_DOUBLE #ifdef DO_DOUBLE
virtual void ParamsToEmber(Ember<double>& ember, bool basicParams = false) override; virtual void ParamsToEmber(Ember<double>& ember, bool imageParamsOnly = false) override;
#endif #endif
virtual void SetCenter(double x, double y) override; virtual void SetCenter(double x, double y) override;
virtual void FillParamTablesAndPalette() override; virtual void FillParamTablesAndPalette() override;
@ -566,7 +566,7 @@ private:
template <typename U> void SetEmberPrivate(const Ember<U>& ember, bool verbatim, bool updatePointer); template <typename U> void SetEmberPrivate(const Ember<U>& ember, bool verbatim, bool updatePointer);
//Params. //Params.
template <typename U> void ParamsToEmberPrivate(Ember<U>& ember, bool basicParams); template <typename U> void ParamsToEmberPrivate(Ember<U>& ember, bool imageParamsOnly);
//Xforms. //Xforms.
void SetNormalizedWeightText(Xform<T>* xform); void SetNormalizedWeightText(Xform<T>* xform);

View File

@ -828,14 +828,14 @@ void FractoriumEmberController<T>::FillParamTablesAndPalette()
/// Copy all GUI widget values on the parameters tab to the passed in ember. /// Copy all GUI widget values on the parameters tab to the passed in ember.
/// </summary> /// </summary>
/// <param name="ember">The ember to copy values to.</param> /// <param name="ember">The ember to copy values to.</param>
/// <param name="basicParams">true to get just filter and colors.</param> /// <param name="imageParamsOnly">True to get just spatial and density filters plus coloring params.</param>
template <typename T> void FractoriumEmberController<T>::ParamsToEmber(Ember<float>& ember, bool basicParams) { ParamsToEmberPrivate<float>(ember, basicParams); } template <typename T> void FractoriumEmberController<T>::ParamsToEmber(Ember<float>& ember, bool imageParamsOnly) { ParamsToEmberPrivate<float>(ember, imageParamsOnly); }
#ifdef DO_DOUBLE #ifdef DO_DOUBLE
template <typename T> void FractoriumEmberController<T>::ParamsToEmber(Ember<double>& ember, bool basicParams) { ParamsToEmberPrivate<double>(ember, basicParams); } template <typename T> void FractoriumEmberController<T>::ParamsToEmber(Ember<double>& ember, bool imageParamsOnly) { ParamsToEmberPrivate<double>(ember, imageParamsOnly); }
#endif #endif
template <typename T> template <typename T>
template <typename U> template <typename U>
void FractoriumEmberController<T>::ParamsToEmberPrivate(Ember<U>& ember, bool basicParams) void FractoriumEmberController<T>::ParamsToEmberPrivate(Ember<U>& ember, bool imageParamsOnly)
{ {
ember.m_Brightness = m_Fractorium->m_BrightnessSpin->value();//Color. ember.m_Brightness = m_Fractorium->m_BrightnessSpin->value();//Color.
ember.m_Gamma = m_Fractorium->m_GammaSpin->value(); ember.m_Gamma = m_Fractorium->m_GammaSpin->value();
@ -845,15 +845,15 @@ void FractoriumEmberController<T>::ParamsToEmberPrivate(Ember<U>& ember, bool ba
ember.m_K2 = m_Fractorium->m_K2Spin->value(); ember.m_K2 = m_Fractorium->m_K2Spin->value();
ember.m_SpatialFilterRadius = m_Fractorium->m_SpatialFilterWidthSpin->value();//Filter. ember.m_SpatialFilterRadius = m_Fractorium->m_SpatialFilterWidthSpin->value();//Filter.
ember.m_SpatialFilterType = eSpatialFilterType(m_Fractorium->m_SpatialFilterTypeCombo->currentIndex()); ember.m_SpatialFilterType = eSpatialFilterType(m_Fractorium->m_SpatialFilterTypeCombo->currentIndex());
ember.m_TemporalFilterWidth = m_Fractorium->m_TemporalFilterWidthSpin->value();
ember.m_TemporalFilterType = eTemporalFilterType(m_Fractorium->m_TemporalFilterTypeCombo->currentIndex());
ember.m_MinRadDE = m_Fractorium->m_DEFilterMinRadiusSpin->value(); ember.m_MinRadDE = m_Fractorium->m_DEFilterMinRadiusSpin->value();
ember.m_MaxRadDE = m_Fractorium->m_DEFilterMaxRadiusSpin->value(); ember.m_MaxRadDE = m_Fractorium->m_DEFilterMaxRadiusSpin->value();
ember.m_CurveDE = m_Fractorium->m_DECurveSpin->value(); ember.m_CurveDE = m_Fractorium->m_DECurveSpin->value();
if(basicParams) if (imageParamsOnly)
return; 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(); auto color = m_Fractorium->ui.ColorTable->item(5, 1)->backgroundColor();
ember.m_Background.r = color.red() / 255.0; ember.m_Background.r = color.red() / 255.0;
ember.m_Background.g = color.green() / 255.0; ember.m_Background.g = color.green() / 255.0;