mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-02 06:16:17 -04:00
Allow for multiple palette files rather than hard coding to flam3-palettes.xml.
Make xaos display a matrix rather than a single column. This will be moved out into its own tab since it's no longer xform dependent, but that will be in a future commit. Remove xaos from/to button since it's no longer applicable. Add test function to Isaac to return just one random byte. Might be used in the future.
This commit is contained in:
@ -243,11 +243,11 @@ public slots:
|
||||
|
||||
//Xforms Xaos.
|
||||
void OnXaosChanged(double d);
|
||||
void OnXaosFromToToggled(bool checked);
|
||||
void OnClearXaosButtonClicked(bool checked);
|
||||
void OnRandomXaosButtonClicked(bool checked);
|
||||
|
||||
//Palette.
|
||||
void OnPaletteFilenameComboChanged(const QString& text);
|
||||
void OnPaletteAdjust(int d);
|
||||
void OnPaletteCellClicked(int row, int col);
|
||||
void OnPaletteCellDoubleClicked(int row, int col);
|
||||
|
@ -2953,8 +2953,8 @@ SpinBox
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>118</width>
|
||||
<height>618</height>
|
||||
<width>245</width>
|
||||
<height>747</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
@ -4561,7 +4561,10 @@ SpinBox
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
<enum>Qt::ScrollBarAsNeeded</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="autoScroll">
|
||||
<bool>false</bool>
|
||||
@ -4603,29 +4606,32 @@ SpinBox
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>2</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>110</number>
|
||||
<number>40</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>27</number>
|
||||
<number>15</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>22</number>
|
||||
</attribute>
|
||||
@ -4640,17 +4646,22 @@ SpinBox
|
||||
</attribute>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>Default Row</string>
|
||||
<string/>
|
||||
</property>
|
||||
</row>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Field</string>
|
||||
<string>F1</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>F2</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>F3</string>
|
||||
</property>
|
||||
</column>
|
||||
<item row="0" column="0">
|
||||
@ -4663,56 +4674,11 @@ SpinBox
|
||||
<string/>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="XaosFromToGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Direction</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>6</number>
|
||||
<item row="0" column="2">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="XaosToRadio">
|
||||
<property name="text">
|
||||
<string>To</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="XaosFromRadio">
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -4752,7 +4718,7 @@ SpinBox
|
||||
<attribute name="title">
|
||||
<string>Palette</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_16" rowstretch="0,0,0,0" columnstretch="0">
|
||||
<layout class="QGridLayout" name="gridLayout_16" rowstretch="0,0,0,0,0" columnstretch="0">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
@ -4771,7 +4737,7 @@ SpinBox
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="TableWidget" name="PalettePreviewTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
@ -4853,7 +4819,7 @@ SpinBox
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="TableWidget" name="PaletteAdjustTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
@ -4986,7 +4952,7 @@ SpinBox
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QTableWidget" name="PaletteListTable">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
@ -5060,7 +5026,7 @@ SpinBox
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
@ -5117,6 +5083,9 @@ SpinBox
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="PaletteFilenameCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="InfoTab">
|
||||
@ -6064,8 +6033,6 @@ SpinBox
|
||||
<tabstop>PreAffineGroupBox</tabstop>
|
||||
<tabstop>scrollArea_4</tabstop>
|
||||
<tabstop>InfoBoundsGroupBox</tabstop>
|
||||
<tabstop>XaosFromRadio</tabstop>
|
||||
<tabstop>XaosToRadio</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="Fractorium.qrc"/>
|
||||
|
@ -76,7 +76,11 @@ FractoriumEmberController<T>::FractoriumEmberController(Fractorium* fractorium)
|
||||
m_GLController = unique_ptr<GLEmberController<T>>(new GLEmberController<T>(fractorium, fractorium->ui.GLDisplay, this));
|
||||
m_PreviewRenderer = unique_ptr<EmberNs::Renderer<T, T>>(new EmberNs::Renderer<T, T>());
|
||||
SetupVariationTree();
|
||||
InitPaletteTable("flam3-palettes.xml");
|
||||
|
||||
//Initial combo change event to fill the palette table will be called automatically later.
|
||||
if (!InitPaletteList("./"))
|
||||
throw "No palettes found, exiting.";
|
||||
|
||||
BackgroundChanged(QColor(0, 0, 0));//Default to black.
|
||||
ClearUndo();
|
||||
|
||||
|
@ -177,14 +177,15 @@ public:
|
||||
virtual void VariationSpinBoxValueChanged(double d) { }
|
||||
|
||||
//Xforms Xaos.
|
||||
virtual void FillXaosWithCurrentXform() { }
|
||||
virtual void FillXaos() { }
|
||||
virtual QString MakeXaosNameString(uint i) { return ""; }
|
||||
virtual void XaosChanged(DoubleSpinBox* sender) { }
|
||||
virtual void ClearXaos() { }
|
||||
virtual void RandomXaos() { }
|
||||
|
||||
//Palette.
|
||||
virtual bool InitPaletteTable(const string& s) { return false; }
|
||||
virtual int InitPaletteList(const string& s) { return 0; }
|
||||
virtual bool FillPaletteTable(const string& s) { return false; }
|
||||
virtual void ApplyPaletteToEmber() { }
|
||||
virtual void PaletteAdjust() { }
|
||||
virtual QRgb GetQRgbFromPaletteIndex(uint i) { return QRgb(); }
|
||||
@ -235,6 +236,7 @@ protected:
|
||||
QImage m_FinalPaletteImage;
|
||||
QString m_LastSaveAll;
|
||||
QString m_LastSaveCurrent;
|
||||
string m_CurrentPaletteFilePath;
|
||||
CriticalSection m_Cs;
|
||||
std::thread m_WriteThread;
|
||||
vector<byte> m_FinalImage[2];
|
||||
@ -405,14 +407,15 @@ public:
|
||||
void FillVariationTreeWithXform(Xform<T>* xform);
|
||||
|
||||
//Xforms Xaos.
|
||||
virtual void FillXaosWithCurrentXform() override;
|
||||
virtual void FillXaos() override;
|
||||
virtual QString MakeXaosNameString(uint i) override;
|
||||
virtual void XaosChanged(DoubleSpinBox* sender) override;
|
||||
virtual void ClearXaos() override;
|
||||
virtual void RandomXaos() override;
|
||||
|
||||
//Palette.
|
||||
virtual bool InitPaletteTable(const string& s) override;
|
||||
virtual int InitPaletteList(const string& s) override;
|
||||
virtual bool FillPaletteTable(const string& s) override;
|
||||
virtual void ApplyPaletteToEmber() override;
|
||||
virtual void PaletteAdjust() override;
|
||||
virtual QRgb GetQRgbFromPaletteIndex(uint i) override { return QRgb(); }
|
||||
|
@ -98,7 +98,7 @@ void FractoriumEmberController<T>::NewEmptyFlameInCurrentFile()
|
||||
xform.m_Weight = T(0.25);
|
||||
xform.m_ColorX = m_Rand.Frand01<T>();
|
||||
ember.AddXform(xform);
|
||||
ember.m_Palette = *m_PaletteList.GetPalette(-1);
|
||||
ember.m_Palette = *m_PaletteList.GetRandomPalette();
|
||||
ember.m_Name = EmberFile<T>::DefaultEmberName(m_EmberFile.Size() + 1).toStdString();
|
||||
ember.m_Index = m_EmberFile.Size();
|
||||
m_EmberFile.m_Embers.push_back(ember);//Will invalidate the pointers contained in the EmberTreeWidgetItems, UpdateLibraryTree() will resync.
|
||||
|
@ -12,6 +12,8 @@ void Fractorium::InitPaletteUI()
|
||||
QTableWidget* paletteTable = ui.PaletteListTable;
|
||||
QTableWidget* palettePreviewTable = ui.PalettePreviewTable;
|
||||
|
||||
connect(ui.PaletteFilenameCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(OnPaletteFilenameComboChanged(const QString&)), Qt::QueuedConnection);
|
||||
|
||||
connect(paletteTable, SIGNAL(cellClicked(int, int)), this, SLOT(OnPaletteCellClicked(int, int)), Qt::QueuedConnection);
|
||||
connect(paletteTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(OnPaletteCellDoubleClicked(int, int)), Qt::QueuedConnection);
|
||||
|
||||
@ -30,52 +32,83 @@ void Fractorium::InitPaletteUI()
|
||||
|
||||
connect(ui.PaletteRandomSelect, SIGNAL(clicked(bool)), this, SLOT(OnPaletteRandomSelectButtonClicked(bool)), Qt::QueuedConnection);
|
||||
connect(ui.PaletteRandomAdjust, SIGNAL(clicked(bool)), this, SLOT(OnPaletteRandomAdjustButtonClicked(bool)), Qt::QueuedConnection);
|
||||
|
||||
//Preview table.
|
||||
palettePreviewTable->setRowCount(1);
|
||||
palettePreviewTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
||||
QTableWidgetItem* previewNameCol = new QTableWidgetItem("");
|
||||
palettePreviewTable->setItem(0, 0, previewNameCol);
|
||||
QTableWidgetItem* previewPaletteItem = new QTableWidgetItem();
|
||||
palettePreviewTable->setItem(0, 1, previewPaletteItem);
|
||||
|
||||
paletteTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
||||
paletteTable->horizontalHeader()->setSectionsClickable(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read all palette Xml files in the specified folder and populate the palette list with the contents.
|
||||
/// This will clear any previous contents.
|
||||
/// Called upon initialization, or controller type change.
|
||||
/// </summary>
|
||||
/// <param name="s">The full path to the palette files folder</param>
|
||||
/// <returns>The number of palettes successfully added</returns>
|
||||
template <typename T>
|
||||
int FractoriumEmberController<T>::InitPaletteList(const string& s)
|
||||
{
|
||||
QDirIterator it(s.c_str(), QStringList() << "*.xml", QDir::Files, QDirIterator::FollowSymlinks);
|
||||
|
||||
m_PaletteList.Clear();
|
||||
m_Fractorium->ui.PaletteFilenameCombo->clear();
|
||||
m_Fractorium->ui.PaletteFilenameCombo->setProperty("path", QString::fromStdString(s));
|
||||
|
||||
while (it.hasNext())
|
||||
{
|
||||
auto path = it.next().toStdString();
|
||||
auto qfilename = it.fileName();
|
||||
|
||||
if (m_PaletteList.Add(path))
|
||||
m_Fractorium->ui.PaletteFilenameCombo->addItem(qfilename);
|
||||
}
|
||||
|
||||
return m_PaletteList.Size();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a palette Xml file and populate the palette table with the contents.
|
||||
/// This will clear any previous contents.
|
||||
/// Called upon initialization, or controller type change.
|
||||
/// Called upon initialization, palette combo index change, and controller type change.
|
||||
/// </summary>
|
||||
/// <param name="s">The full path to the palette file</param>
|
||||
/// <param name="s">The name to the palette file without the path</param>
|
||||
/// <returns>True if successful, else false.</returns>
|
||||
template <typename T>
|
||||
bool FractoriumEmberController<T>::InitPaletteTable(const string& s)
|
||||
bool FractoriumEmberController<T>::FillPaletteTable(const string& s)
|
||||
{
|
||||
QTableWidget* paletteTable = m_Fractorium->ui.PaletteListTable;
|
||||
QTableWidget* palettePreviewTable = m_Fractorium->ui.PalettePreviewTable;
|
||||
|
||||
paletteTable->clear();
|
||||
|
||||
if (m_PaletteList.Init(s))//Default to this, but add an option later.//TODO
|
||||
m_CurrentPaletteFilePath = m_Fractorium->ui.PaletteFilenameCombo->property("path").toString().toStdString() + s;
|
||||
size_t paletteSize = m_PaletteList.Size(m_CurrentPaletteFilePath);
|
||||
|
||||
if (paletteSize)
|
||||
{
|
||||
//Preview table.
|
||||
palettePreviewTable->setRowCount(1);
|
||||
palettePreviewTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
||||
QTableWidgetItem* previewNameCol = new QTableWidgetItem("");
|
||||
palettePreviewTable->setItem(0, 0, previewNameCol);
|
||||
QTableWidgetItem* previewPaletteItem = new QTableWidgetItem();
|
||||
palettePreviewTable->setItem(0, 1, previewPaletteItem);
|
||||
|
||||
//Palette list table.
|
||||
paletteTable->setRowCount(m_PaletteList.Size());
|
||||
paletteTable->setColumnWidth(1, 260);//256 plus small margin on each side.
|
||||
paletteTable->horizontalHeader()->setSectionsClickable(false);
|
||||
|
||||
paletteTable->clear();
|
||||
paletteTable->blockSignals(true);
|
||||
paletteTable->setRowCount(paletteSize);
|
||||
|
||||
//Headers get removed when clearing, so must re-create here.
|
||||
QTableWidgetItem* nameHeader = new QTableWidgetItem("Name");
|
||||
QTableWidgetItem* paletteHeader = new QTableWidgetItem("Palette");
|
||||
|
||||
nameHeader->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
||||
paletteHeader->setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
|
||||
nameHeader->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
paletteHeader->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
|
||||
paletteTable->setHorizontalHeaderItem(0, nameHeader);
|
||||
paletteTable->setHorizontalHeaderItem(1, paletteHeader);
|
||||
|
||||
//Palette list table.
|
||||
for (size_t i = 0; i < m_PaletteList.Size(); i++)
|
||||
for (size_t i = 0; i < paletteSize; i++)
|
||||
{
|
||||
Palette<T>* p = m_PaletteList.GetPalette(i);
|
||||
Palette<T>* p = m_PaletteList.GetPalette(m_CurrentPaletteFilePath, i);
|
||||
vector<byte> v = p->MakeRgbPaletteBlock(PALETTE_CELL_HEIGHT);
|
||||
QTableWidgetItem* nameCol = new QTableWidgetItem(p->m_Name.c_str());
|
||||
|
||||
@ -89,6 +122,8 @@ bool FractoriumEmberController<T>::InitPaletteTable(const string& s)
|
||||
paletteTable->setItem(i, 1, paletteItem);
|
||||
}
|
||||
|
||||
paletteTable->blockSignals(false);
|
||||
m_Fractorium->OnPaletteRandomSelectButtonClicked(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -102,6 +137,8 @@ bool FractoriumEmberController<T>::InitPaletteTable(const string& s)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Fractorium::OnPaletteFilenameComboChanged(const QString& text) { m_Controller->FillPaletteTable(text.toStdString()); }
|
||||
|
||||
/// <summary>
|
||||
/// Apply adjustments to the current ember's palette.
|
||||
/// </summary>
|
||||
@ -188,7 +225,7 @@ void Fractorium::OnPaletteAdjust(int d) { m_Controller->PaletteAdjust(); }
|
||||
template <typename T>
|
||||
void FractoriumEmberController<T>::PaletteCellClicked(int row, int col)
|
||||
{
|
||||
Palette<T>* palette = m_PaletteList.GetPalette(row);
|
||||
Palette<T>* palette = m_PaletteList.GetPalette(m_CurrentPaletteFilePath, row);
|
||||
QTableWidgetItem* nameItem = m_Fractorium->ui.PaletteListTable->item(row, 0);
|
||||
|
||||
if (palette)
|
||||
@ -225,11 +262,11 @@ void Fractorium::OnPaletteCellDoubleClicked(int row, int col)
|
||||
|
||||
/// <summary>
|
||||
/// Set the selected palette to a randomly selected one,
|
||||
/// applying any adjustments previously specified.
|
||||
/// applying any adjustments previously specified if the checked parameter is true.
|
||||
/// Called when the Random Palette button is clicked.
|
||||
/// Resets the rendering process.
|
||||
/// </summary>
|
||||
/// <param name="row">The current row selected</param>
|
||||
/// <param name="checked">True to clear the current adjustments, else leave current adjustments.</param>
|
||||
void Fractorium::OnPaletteRandomSelectButtonClicked(bool checked)
|
||||
{
|
||||
uint i = 0;
|
||||
@ -237,7 +274,10 @@ void Fractorium::OnPaletteRandomSelectButtonClicked(bool checked)
|
||||
|
||||
while ((i = QTIsaac<ISAAC_SIZE, ISAAC_INT>::GlobalRand->Rand(rowCount)) == uint(m_PreviousPaletteRow));
|
||||
|
||||
OnPaletteCellClicked(i, 1);
|
||||
if (checked)
|
||||
OnPaletteCellDoubleClicked(i, 1);//Will clear the adjustments.
|
||||
else
|
||||
OnPaletteCellClicked(i, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -568,6 +568,9 @@ void FractoriumEmberController<T>::FillParamTablesAndPalette()
|
||||
m_TempPalette = m_Ember.m_Palette;
|
||||
UpdateAdjustedPaletteGUI(m_Ember.m_Palette);//Will clear name string since embedded palettes have no name. This will trigger a full render.
|
||||
}
|
||||
|
||||
//Xaos.
|
||||
FillXaos();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -267,11 +267,11 @@ void FractoriumEmberController<T>::XformNameChanged(int row, int col)
|
||||
|
||||
xform->m_Name = m_Fractorium->ui.XformWeightNameTable->item(row, col)->text().toStdString();
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
if (QTableWidgetItem* xformNameItem = m_Fractorium->ui.XaosTable->item(index, 0))
|
||||
xformNameItem->setText(MakeXaosNameString(index));
|
||||
}
|
||||
//if (index != -1)
|
||||
//{
|
||||
// if (QTableWidgetItem* xformNameItem = m_Fractorium->ui.XaosTable->item(index, 0))
|
||||
// xformNameItem->setText(MakeXaosNameString(index));
|
||||
//}
|
||||
}, false);
|
||||
}
|
||||
|
||||
@ -298,7 +298,6 @@ void FractoriumEmberController<T>::FillWithXform(Xform<T>* xform)
|
||||
FillColorWithXform(xform);
|
||||
FillAffineWithXform(xform, true);
|
||||
FillAffineWithXform(xform, false);
|
||||
FillXaosWithCurrentXform();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,42 +6,24 @@
|
||||
/// </summary>
|
||||
void Fractorium::InitXformsXaosUI()
|
||||
{
|
||||
connect(ui.XaosToRadio, SIGNAL(toggled(bool)), this, SLOT(OnXaosFromToToggled(bool)), Qt::QueuedConnection);
|
||||
connect(ui.ClearXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnClearXaosButtonClicked(bool)), Qt::QueuedConnection);
|
||||
connect(ui.RandomXaosButton, SIGNAL(clicked(bool)), this, SLOT(OnRandomXaosButtonClicked(bool)), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill the xaos table with the values from the current xform.
|
||||
/// Fill the xaos table with the values from the ember.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
void FractoriumEmberController<T>::FillXaosWithCurrentXform()
|
||||
void FractoriumEmberController<T>::FillXaos()
|
||||
{
|
||||
Xform<T>* currXform = CurrentXform();
|
||||
|
||||
if (!IsFinal(currXform))
|
||||
for (int i = 0, count = int(XformCount()); i < count; i++)
|
||||
{
|
||||
for (int i = 0; i < m_Ember.XformCount(); i++)
|
||||
{
|
||||
DoubleSpinBox* spinBox = dynamic_cast<DoubleSpinBox*>(m_Fractorium->ui.XaosTable->cellWidget(i, 1));
|
||||
auto* xform = m_Ember.GetXform(i);
|
||||
|
||||
//Fill in values column.
|
||||
if (m_Fractorium->ui.XaosToRadio->isChecked())//"To": Single xform, advance index.
|
||||
spinBox->SetValueStealth(currXform->Xaos(i));
|
||||
else//"From": Advance xforms, single index.
|
||||
if ((currXform = m_Ember.GetXform(i)))
|
||||
spinBox->SetValueStealth(currXform->Xaos(m_Fractorium->ui.CurrentXformCombo->currentIndex()));
|
||||
|
||||
//Fill in name column.
|
||||
Xform<T>* xform = m_Ember.GetXform(i);
|
||||
QTableWidgetItem* xformNameItem = m_Fractorium->ui.XaosTable->item(i, 0);
|
||||
|
||||
if (xform && xformNameItem)
|
||||
xformNameItem->setText(MakeXaosNameString(i));
|
||||
}
|
||||
for (int j = 0; j < count; j++)
|
||||
if (auto* spinBox = dynamic_cast<DoubleSpinBox*>(m_Fractorium->ui.XaosTable->cellWidget(i, j)))
|
||||
spinBox->SetValueStealth(xform->Xaos(j));
|
||||
}
|
||||
|
||||
m_Fractorium->ui.XaosTable->setEnabled(!IsFinal(currXform));//Disable if final, else enable.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -55,22 +37,22 @@ QString FractoriumEmberController<T>::MakeXaosNameString(uint i)
|
||||
Xform<T>* xform = m_Ember.GetXform(i);
|
||||
QString name;
|
||||
|
||||
if (xform)
|
||||
{
|
||||
int indexPlus1 = m_Ember.GetXformIndex(xform) + 1;//GUI is 1 indexed to avoid confusing the user.
|
||||
int curr = m_Fractorium->ui.CurrentXformCombo->currentIndex() + 1;
|
||||
|
||||
if (indexPlus1 != -1)
|
||||
{
|
||||
if (m_Fractorium->ui.XaosToRadio->isChecked())
|
||||
name = QString("From ") + ToString(curr) + QString(" To ") + ToString(indexPlus1);
|
||||
else
|
||||
name = QString("From ") + ToString(indexPlus1) + QString(" To ") + ToString(curr);
|
||||
|
||||
//if (xform->m_Name != "")
|
||||
// name = name + " (" + QString::fromStdString(xform->m_Name) + ")";
|
||||
}
|
||||
}
|
||||
//if (xform)
|
||||
//{
|
||||
// int indexPlus1 = m_Ember.GetXformIndex(xform) + 1;//GUI is 1 indexed to avoid confusing the user.
|
||||
// int curr = m_Fractorium->ui.CurrentXformCombo->currentIndex() + 1;
|
||||
//
|
||||
// if (indexPlus1 != -1)
|
||||
// {
|
||||
// if (m_Fractorium->ui.XaosToRadio->isChecked())
|
||||
// name = QString("From ") + ToString(curr) + QString(" To ") + ToString(indexPlus1);
|
||||
// else
|
||||
// name = QString("From ") + ToString(indexPlus1) + QString(" To ") + ToString(curr);
|
||||
//
|
||||
// //if (xform->m_Name != "")
|
||||
// // name = name + " (" + QString::fromStdString(xform->m_Name) + ")";
|
||||
// }
|
||||
//}
|
||||
|
||||
return name;
|
||||
}
|
||||
@ -78,109 +60,93 @@ QString FractoriumEmberController<T>::MakeXaosNameString(uint i)
|
||||
/// <summary>
|
||||
/// Set the xaos value.
|
||||
/// Called when any xaos spinner is changed.
|
||||
/// Different action taken based on the state of to/from radio button.
|
||||
/// Resets the rendering process.
|
||||
/// </summary>
|
||||
/// <param name="sender">The DoubleSpinBox that triggered this event</param>
|
||||
template <typename T>
|
||||
void FractoriumEmberController<T>::XaosChanged(DoubleSpinBox* sender)
|
||||
{
|
||||
UpdateCurrentXform([&] (Xform<T>* xform)
|
||||
{
|
||||
QTableWidget* xaosTable = m_Fractorium->ui.XaosTable;
|
||||
auto p = sender->property("tableindex").toPoint();
|
||||
|
||||
if (!IsFinal(xform))//This should never get called for the final xform because the table will be disabled, but check just to be safe.
|
||||
{
|
||||
for (int i = 0; i < xaosTable->rowCount(); i++)//Find the spin box that triggered the event.
|
||||
{
|
||||
DoubleSpinBox* spinBox = dynamic_cast<DoubleSpinBox*>(xaosTable->cellWidget(i, 1));
|
||||
|
||||
if (spinBox == sender)
|
||||
{
|
||||
if (m_Fractorium->ui.XaosToRadio->isChecked())//"To": Single xform, advance index.
|
||||
{
|
||||
xform->SetXaos(i, spinBox->value());
|
||||
}
|
||||
else//"From": Advance xforms, single index.
|
||||
{
|
||||
if ((xform = m_Ember.GetXform(i)))//Single = is intentional.
|
||||
xform->SetXaos(m_Fractorium->ui.CurrentXformCombo->currentIndex(), spinBox->value());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (auto* xform = m_Ember.GetXform(p.x()))
|
||||
Update([&] { xform->SetXaos(p.y(), sender->value()); });
|
||||
}
|
||||
|
||||
void Fractorium::OnXaosChanged(double d)
|
||||
{
|
||||
if (DoubleSpinBox* senderSpinBox = dynamic_cast<DoubleSpinBox*>(this->sender()))
|
||||
if (auto* senderSpinBox = dynamic_cast<DoubleSpinBox*>(this->sender()))
|
||||
m_Controller->XaosChanged(senderSpinBox);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update xaos display to use either "to" or "from" logic.
|
||||
/// Called when xaos to/from radio buttons checked.
|
||||
/// </summary>
|
||||
/// <param name="checked">Ignored</param>
|
||||
void Fractorium::OnXaosFromToToggled(bool checked)
|
||||
{
|
||||
m_Controller->FillXaosWithCurrentXform();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear xaos table, recreate all spinners based on the xaos used by the current xform in the current ember.
|
||||
/// Called every time the current xform changes.
|
||||
/// Clear xaos table, recreate all spinners based on the xaos used in the current ember.
|
||||
/// </summary>
|
||||
void Fractorium::FillXaosTable()
|
||||
{
|
||||
int spinHeight = 20;
|
||||
int count = int(m_Controller->XformCount());
|
||||
QWidget* w = nullptr;
|
||||
ui.XaosTable->setRowCount(m_Controller->XformCount());//This will grow or shrink the number of rows and call the destructor for previous DoubleSpinBoxes.
|
||||
QString lbl("lbl");
|
||||
|
||||
for (int i = 0; i < int(m_Controller->XformCount()); i++)
|
||||
ui.XaosTable->setRowCount(count);//This will grow or shrink the number of rows and call the destructor for previous DoubleSpinBoxes.
|
||||
ui.XaosTable->setColumnCount(count);
|
||||
|
||||
ui.XaosTable->verticalHeader()->setVisible(true);
|
||||
ui.XaosTable->horizontalHeader()->setVisible(true);
|
||||
ui.XaosTable->verticalHeader()->setSectionsClickable(false);
|
||||
ui.XaosTable->horizontalHeader()->setSectionsClickable(false);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DoubleSpinBox* spinBox = new DoubleSpinBox(ui.XaosTable, spinHeight, 0.1);
|
||||
QTableWidgetItem* xformNameItem = new QTableWidgetItem(m_Controller->MakeXaosNameString(i));
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
QPoint p(i, j);
|
||||
DoubleSpinBox* spinBox = new DoubleSpinBox(ui.XaosTable, spinHeight, 0.1);
|
||||
|
||||
spinBox->DoubleClick(true);
|
||||
spinBox->DoubleClickZero(1);
|
||||
spinBox->DoubleClickNonZero(0);
|
||||
ui.XaosTable->setItem(i, 0, xformNameItem);
|
||||
ui.XaosTable->setCellWidget(i, 1, spinBox);
|
||||
connect(spinBox, SIGNAL(valueChanged(double)), this, SLOT(OnXaosChanged(double)), Qt::QueuedConnection);
|
||||
spinBox->setFixedWidth(35);
|
||||
spinBox->DoubleClick(true);
|
||||
spinBox->DoubleClickZero(1);
|
||||
spinBox->DoubleClickNonZero(0);
|
||||
spinBox->setProperty("tableindex", p);
|
||||
ui.XaosTable->setCellWidget(i, j, spinBox);
|
||||
|
||||
auto wp = ui.XaosTable->item(i, j);
|
||||
|
||||
if (i > 0)
|
||||
w = SetTabOrder(this, w, spinBox);
|
||||
else
|
||||
w = spinBox;
|
||||
if (wp)
|
||||
wp->setTextAlignment(Qt::AlignCenter);
|
||||
|
||||
connect(spinBox, SIGNAL(valueChanged(double)), this, SLOT(OnXaosChanged(double)), Qt::QueuedConnection);
|
||||
|
||||
if (i == 0 && j == 0)
|
||||
w = spinBox;
|
||||
else
|
||||
w = SetTabOrder(this, w, spinBox);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
ui.XaosTable->setHorizontalHeaderItem(i, new QTableWidgetItem("F" + QString::number(i + 1)));
|
||||
ui.XaosTable->setVerticalHeaderItem(i, new QTableWidgetItem("T" + QString::number(i + 1)));
|
||||
ui.XaosTable->horizontalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
|
||||
ui.XaosTable->verticalHeader()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
|
||||
}
|
||||
|
||||
w = SetTabOrder(this, w, ui.XaosToRadio);
|
||||
w = SetTabOrder(this, w, ui.XaosFromRadio);
|
||||
ui.XaosTable->resizeRowsToContents();
|
||||
ui.XaosTable->resizeColumnsToContents();
|
||||
|
||||
w = SetTabOrder(this, w, ui.ClearXaosButton);
|
||||
w = SetTabOrder(this, w, ui.RandomXaosButton);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all xaos from the current ember.
|
||||
/// Called when xaos to/from radio buttons checked.
|
||||
/// </summary>
|
||||
/// <param name="checked">Ignored</param>
|
||||
template <typename T>
|
||||
void FractoriumEmberController<T>::ClearXaos()
|
||||
{
|
||||
UpdateCurrentXform([&] (Xform<T>* xform)
|
||||
{
|
||||
m_Ember.ClearXaos();
|
||||
});
|
||||
|
||||
//Can't just call FillXaosWithCurrentXform() because the current xform might the final.
|
||||
for (int i = 0; i < m_Ember.XformCount(); i++)
|
||||
if (DoubleSpinBox* spinBox = dynamic_cast<DoubleSpinBox*>(m_Fractorium->ui.XaosTable->cellWidget(i, 1)))
|
||||
spinBox->SetValueStealth(1.0);
|
||||
Update([&] { m_Ember.ClearXaos(); });
|
||||
FillXaos();
|
||||
}
|
||||
|
||||
void Fractorium::OnClearXaosButtonClicked(bool checked) { m_Controller->ClearXaos(); }
|
||||
@ -195,25 +161,24 @@ void Fractorium::OnClearXaosButtonClicked(bool checked) { m_Controller->ClearXao
|
||||
template <typename T>
|
||||
void FractoriumEmberController<T>::RandomXaos()
|
||||
{
|
||||
UpdateCurrentXform([&](Xform<T>* xform)
|
||||
Update([&]
|
||||
{
|
||||
for (size_t i = 0; i < m_Ember.XformCount(); i++)
|
||||
{
|
||||
if (Xform<T>* localXform = m_Ember.GetXform(i))
|
||||
if (auto* xform = m_Ember.GetXform(i))
|
||||
{
|
||||
for (size_t j = 0; j < m_Ember.XformCount(); j++)
|
||||
{
|
||||
if (m_Rand.RandBit())
|
||||
localXform->SetXaos(j, T(m_Rand.RandBit()));
|
||||
xform->SetXaos(j, T(m_Rand.RandBit()));
|
||||
else
|
||||
localXform->SetXaos(j, m_Rand.Frand<T>(0, 3));
|
||||
xform->SetXaos(j, m_Rand.Frand<T>(0, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//If current is final, it will update when they change to a non-final xform.
|
||||
FillXaosWithCurrentXform();
|
||||
|
||||
FillXaos();
|
||||
}
|
||||
|
||||
void Fractorium::OnRandomXaosButtonClicked(bool checked) { m_Controller->RandomXaos(); }
|
||||
|
Reference in New Issue
Block a user