--User changes

-Add backward compatibility option for the following variations: cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan, tanh.
 -Add the ability to re-order variations by dragging them in the Info tab.
This commit is contained in:
Person
2020-03-04 22:30:08 -08:00
parent c50568a98b
commit ea649bbda6
22 changed files with 1034 additions and 310 deletions

View File

@ -129,6 +129,9 @@ public:
bool DrawAllPost();
bool LocalPivot();
//Info.
void ReorderVariations(QTreeWidgetItem* item);
public slots:
//Dock.
void OnDockTopLevelChanged(bool topLevel);

View File

@ -6540,7 +6540,7 @@
</widget>
</item>
<item>
<widget class="QTreeWidget" name="SummaryTree">
<widget class="InfoTreeWidget" name="SummaryTree">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@ -6562,6 +6562,12 @@
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
@ -8714,6 +8720,11 @@
<extends>QTreeWidget</extends>
<header>LibraryTreeWidget.h</header>
</customwidget>
<customwidget>
<class>InfoTreeWidget</class>
<extends>QTreeWidget</extends>
<header>LibraryTreeWidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>LibraryDockWidget</tabstop>

View File

@ -262,6 +262,7 @@ public:
//Info.
virtual void FillSummary() { }
virtual void ReorderVariations(QTreeWidgetItem* item) { }
//Rendering/progress.
virtual bool Render() { return false; }
@ -556,6 +557,7 @@ public:
//Info.
virtual void FillSummary() override;
virtual void ReorderVariations(QTreeWidgetItem* item) override;
//Rendering/progress.
virtual bool Render() override;

View File

@ -21,6 +21,7 @@ void Fractorium::InitInfoUI()
ui.SummaryTable->setItem(4, 0, m_InfoXformCountItem = new QTableWidgetItem(""));
ui.SummaryTable->setItem(5, 0, m_InfoFinalXformItem = new QTableWidgetItem(""));
ui.InfoTabWidget->setCurrentIndex(0);//Make summary tab focused by default.
ui.SummaryTree->SetMainWindow(this);
}
/// <summary>
@ -75,6 +76,8 @@ void FractoriumEmberController<T>::FillSummary()
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());
@ -109,8 +112,10 @@ void FractoriumEmberController<T>::FillSummary()
item1->setText(0, "Final xform");
item1->setText(1, xform->m_Name.c_str());
item1->setFlags(nondraggable);
auto affineItem = new QTreeWidgetItem(item1);
affineItem->setText(0, "Affine");
affineItem->setFlags(nondraggable);
if (xform->m_Affine.IsZero())
as += " Empty";
@ -129,6 +134,7 @@ void FractoriumEmberController<T>::FillSummary()
auto colorIndexItem = new QTreeWidgetItem(item1);
colorIndexItem->setText(0, "Color index");
colorIndexItem->setText(1, QLocale::system().toString(xform->m_ColorX, pc, p));
colorIndexItem->setFlags(nondraggable | Qt::ItemNeverHasChildren);
color = ColorIndexToQColor(xform->m_ColorX);
color.setAlphaF(xform->m_Opacity);
colorIndexItem->setBackgroundColor(1, color);
@ -136,18 +142,25 @@ void FractoriumEmberController<T>::FillSummary()
auto colorSpeedItem = new QTreeWidgetItem(item1);
colorSpeedItem->setText(0, "Color speed");
colorSpeedItem->setText(1, QLocale::system().toString(xform->m_ColorSpeed, pc, p));
colorSpeedItem->setFlags(nondraggable | Qt::ItemNeverHasChildren);
auto opacityItem = new QTreeWidgetItem(item1);
opacityItem->setText(0, "Opacity");
opacityItem->setText(1, QLocale::system().toString(xform->m_Opacity, pc, p));
opacityItem->setFlags(nondraggable | Qt::ItemNeverHasChildren);
auto dcItem = new QTreeWidgetItem(item1);
dcItem->setText(0, "Direct color");
dcItem->setText(1, QLocale::system().toString(xform->m_DirectColor, pc, p));
dcItem->setFlags(nondraggable | Qt::ItemNeverHasChildren);
if (dcItem->text(0) != tree->LastNonVarField())
throw "Last info tree non-variation index did not match expected value";
while (auto var = xform->GetVariation(i++))
{
auto vitem = new QTreeWidgetItem(item1);
auto vitem = new VariationTreeWidgetItem(var->VariationId(), item1);
vitem->setText(0, QString::fromStdString(var->Name()));
vitem->setText(1, QLocale::system().toString(var->m_Weight, pc, vp).rightJustified(vlen, ' '));
vitem->setFlags(draggable);
if (auto parVar = dynamic_cast<ParametricVariation<T>*>(var))
{
@ -160,6 +173,7 @@ void FractoriumEmberController<T>::FillSummary()
auto pitem = new QTreeWidgetItem(vitem);
pitem->setText(0, params[j].Name().c_str());
pitem->setText(1, QLocale::system().toString(params[j].ParamVal(), pc, vp).rightJustified(vlen, ' '));
pitem->setFlags(nondraggable);
}
}
}
@ -177,6 +191,57 @@ void Fractorium::FillSummary()
m_Controller->FillSummary();
}
/// <summary>
/// Reorder the variations of the xform for the passed in tree widget item.
/// Read the newly reordered variation items in order, removing each from the xform
/// corresponding to the passed in item, and storing them in a vector. Then re-add those variation
/// pointers back to the xform in the same order they were removed.
/// This will be called after the user performs a drag and drop operation on the variations in the
/// info tree. So the variations will be in the newly desired order.
/// </summary>
/// <param name="dme">Pointer to the parent (xform level) tree widget item which contains the variation item being dragged</param>
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.
if (auto xform = m_Ember.GetTotalXform(xfindex))
{
vector<Variation<T>*> vars;
vars.reserve(xform->TotalVariationCount());
Update([&]
{
int i = 0;
while (auto ch = item->child(i))
{
if (ch->text(0) == tree->LastNonVarField())
{
i++;
while (auto varch = dynamic_cast<VariationTreeWidgetItem*>(item->child(i++)))
if (auto var = xform->RemoveVariationById(varch->Id()))
vars.push_back(var);
for (auto& var : vars)
xform->AddVariation(var);
break;
}
i++;
}
}, true, eProcessAction::FULL_RENDER);
}
}
void Fractorium::ReorderVariations(QTreeWidgetItem* item)
{
m_Controller->ReorderVariations(item);
}
/// <summary>
/// Update the histogram bounds display labels.
/// This shows the user the actual bounds of what's

View File

@ -1069,12 +1069,15 @@ void Fractorium::OnActionOptions(bool checked)
bool ec = m_Settings->EarlyClip();
bool yup = m_Settings->YAxisUp();
bool trans = m_Settings->Transparency();
bool compat = m_Settings->Flam3Compat();
if (m_OptionsDialog->exec())
{
bool updatePreviews = ec != m_Settings->EarlyClip() ||
yup != m_Settings->YAxisUp() ||
trans != m_Settings->Transparency();
trans != m_Settings->Transparency() ||
compat != m_Settings->Flam3Compat();
Compat::m_Compat = m_Settings->Flam3Compat();
SyncOptionsToToolbar();//This won't trigger a recreate, the call below handles it.
ShutdownAndRecreateFromOptions(updatePreviews);//This will recreate the controller and/or the renderer from the options if necessary, then start the render timer.
}

View File

@ -122,6 +122,8 @@ void FractoriumSettings::EnsureDefaults()
if (value(SHAREDTEXTURE).toString() == "")//Set this to true if the setting is missing because it only needs to be false for the rare system that has problems with shared textures.
SharedTexture(true);
Compat::m_Compat = Flam3Compat();
}
/// <summary>
@ -200,6 +202,9 @@ void FractoriumSettings::LoadLast(bool b) { setValue(LOAD
bool FractoriumSettings::RotateAndScale() { return value(ROTSCALE).toBool(); }
void FractoriumSettings::RotateAndScale(bool b) { setValue(ROTSCALE, b); }
bool FractoriumSettings::Flam3Compat() { return value(FLAM3COMPAT).toBool(); }
void FractoriumSettings::Flam3Compat(bool b) { setValue(FLAM3COMPAT, b); }
/// <summary>
/// Sequence generation settings.
/// </summary>

View File

@ -30,6 +30,7 @@
#define OPENCLQUALITY "render/openclquality"
#define LOADLAST "render/loadlastonstart"
#define ROTSCALE "render/rotateandscale"
#define FLAM3COMPAT "render/flam3compat"
#define STAGGER "sequence/stagger"
#define STAGGERMAX "sequence/staggermax"
@ -180,6 +181,9 @@ public:
bool RotateAndScale();
void RotateAndScale(bool b);
bool Flam3Compat();
void Flam3Compat(bool b);
double Stagger();
void Stagger(double i);

View File

@ -93,4 +93,112 @@ void LibraryTreeWidget::dropEvent(QDropEvent* de)
m_Fractorium->m_Controller->MoveLibraryItems(items, row);
}
}
}
/// <summary>
/// Set a pointer to the main window.
/// </summary>
/// <param name="f">Pointer to the main Fractorium object</param>
void InfoTreeWidget::SetMainWindow(Fractorium* f)
{
m_Fractorium = f;
}
/// <summary>
/// Called on each mouse movement while dragging, validate whether the area
/// being dragged over can be dropped on.
/// Can only drop on like (pre/reg/post) variation section of the same xform
/// of the variation being dragged.
/// </summary>
/// <param name="dme">Pointer to the drag move event</param>
void InfoTreeWidget::dragMoveEvent(QDragMoveEvent* dme)
{
QModelIndex index = indexAt(dme->pos());
if (!index.isValid())//Don't process drop because it's outside of the droppable area.
{
dme->ignore();
return;
}
QList<QTreeWidgetItem*> dragItems = selectedItems();
if (dragItems.size())
{
auto drag0 = dragItems[0];
if (auto itemat = itemFromIndex(index))
{
auto dragpre = drag0->text(0).startsWith("pre_", Qt::CaseInsensitive);
auto droppre = itemat->text(0).startsWith("pre_", Qt::CaseInsensitive);
auto dragpost = drag0->text(0).startsWith("post_", Qt::CaseInsensitive);
auto droppost = itemat->text(0).startsWith("post_", Qt::CaseInsensitive);
if (auto par = itemat->parent())
{
if (drag0->parent() == par &&
(par->text(0).startsWith("xform ", Qt::CaseInsensitive) ||
par->text(0).startsWith("final", Qt::CaseInsensitive)))
{
if (auto vitemat = dynamic_cast<VariationTreeWidgetItem*>(itemat))
{
bool dopre = dragpre && droppre;
bool dopost = dragpost && droppost;
bool doreg = !dragpre && !droppre && !dragpost && !droppost;
if (dopre || doreg || doreg)
{
QTreeWidget::dragMoveEvent(dme);
return;
}
}
}
}
}
}
dme->ignore();
}
/// <summary>
/// Process the drop event to allow for moving items around inside of the tree.
/// This will only allow variations to be moved around within the variation section of the tree
/// and nowhere else.
/// </summary>
/// <param name="de">Pointer to the QDropEvent object</param>
void InfoTreeWidget::dropEvent(QDropEvent* de)
{
QModelIndex droppedIndex = indexAt(de->pos());
auto items = selectionModel()->selectedRows();
if (!droppedIndex.isValid())//Don't process drop because it's outside of the droppable area.
{
de->ignore();
return;
}
else if (!items.empty())//Actually do the drop and move the item to a new location.
{
QList<QTreeWidgetItem*> dragItems = selectedItems();
if (dragItems.size())
{
auto drag0 = dragItems[0];
auto itemat = itemFromIndex(droppedIndex);
if (auto par = itemat->parent())
{
if (auto vdropitem = dynamic_cast<VariationTreeWidgetItem*>(itemat))
{
if (auto vdragitem = dynamic_cast<VariationTreeWidgetItem*>(drag0))
{
QTreeWidget::dropEvent(de);//This internally changes the order of the items.
m_Fractorium->ReorderVariations(par);
return;
}
}
}
}
de->ignore();
}
}

View File

@ -26,4 +26,29 @@ protected:
virtual void dropEvent(QDropEvent* de) override;
Fractorium* m_Fractorium = nullptr;
};
};
class InfoTreeWidget : public QTreeWidget
{
Q_OBJECT
public:
/// <summary>
/// Constructor that passes p to the parent.
/// </summary>
/// <param name="p">The parent widget</param>
explicit InfoTreeWidget(QWidget* p = nullptr)
: QTreeWidget(p)
{
}
void SetMainWindow(Fractorium* f);
const QString& LastNonVarField() const { return m_LastNonVarField; }
protected:
virtual void dropEvent(QDropEvent* de) override;
virtual void dragMoveEvent(QDragMoveEvent* dme) override;
Fractorium* m_Fractorium = nullptr;
QString m_LastNonVarField = "Direct color";//It is critical to update this if any more fields are ever added before the variations start.
};

View File

@ -78,6 +78,7 @@ bool FractoriumOptionsDialog::Png16Bit() { return ui.Png16BitCheckBox->isChecked
bool FractoriumOptionsDialog::AutoUnique() { return ui.AutoUniqueCheckBox->isChecked(); }
bool FractoriumOptionsDialog::LoadLast() { return ui.LoadLastOnStartCheckBox->isChecked(); }
bool FractoriumOptionsDialog::RotateAndScale() { return ui.RotateAndScaleCheckBox->isChecked(); }
bool FractoriumOptionsDialog::Flam3Compat() { return ui.Flam3CompatCheckBox->isChecked(); }
uint FractoriumOptionsDialog::ThreadCount() { return ui.ThreadCountSpin->value(); }
uint FractoriumOptionsDialog::RandomCount() { return ui.RandomCountSpin->value(); }
uint FractoriumOptionsDialog::CpuQuality() { return ui.CpuQualitySpin->value(); }
@ -196,6 +197,7 @@ void FractoriumOptionsDialog::GuiToData()
m_Settings->RandomCount(RandomCount());
m_Settings->LoadLast(LoadLast());
m_Settings->RotateAndScale(RotateAndScale());
m_Settings->Flam3Compat(Flam3Compat());
m_Settings->CpuQuality(CpuQuality());
m_Settings->OpenClQuality(OpenClQuality());
m_Settings->CpuSubBatch(ui.CpuSubBatchSpin->value());
@ -236,6 +238,7 @@ void FractoriumOptionsDialog::DataToGui()
ui.RandomCountSpin->setValue(m_Settings->RandomCount());
ui.LoadLastOnStartCheckBox->setChecked(m_Settings->LoadLast());
ui.RotateAndScaleCheckBox->setChecked(m_Settings->RotateAndScale());
ui.Flam3CompatCheckBox->setChecked(m_Settings->Flam3Compat());
ui.CpuQualitySpin->setValue(m_Settings->CpuQuality());
ui.OpenCLQualitySpin->setValue(m_Settings->OpenClQuality());
ui.CpuSubBatchSpin->setValue(m_Settings->CpuSubBatch());

View File

@ -38,6 +38,7 @@ public:
bool AutoUnique();
bool LoadLast();
bool RotateAndScale();
bool Flam3Compat();
uint ThreadCount();
uint RandomCount();
uint CpuQuality();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>546</width>
<height>490</height>
<height>512</height>
</rect>
</property>
<property name="sizePolicy">
@ -538,6 +538,16 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="Flam3CompatCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The behavior of the cos, cosh, cot, coth, csc, csch, sec, sech, sin, sinh, tan and tanh variations are different in flam3/Apophysis versus Chaotica.&lt;/p&gt;&lt;p&gt;Checked: use the Apophysis behavior.&lt;/p&gt;&lt;p&gt;Unchecked: use the Chaotica behavior.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Flam3 Compatibility</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="OptionsXmlSavingTab">