Merged in luyuju151/fractorium/out-master (pull request #5)

Small improvements on fractorium UI
This commit is contained in:
Yuju Lu 2018-07-13 22:54:37 +00:00 committed by Matt Feemster
commit 0deabd45b8
7 changed files with 118 additions and 25 deletions

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h"
#include "FractoriumPch.h"
#include "FractoriumEmberController.h"
#include "FinalRenderEmberController.h"
#include "FinalRenderDialog.h"

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h"
#include "FractoriumPch.h"
#include "Fractorium.h"
#include "QssDialog.h"
@ -89,6 +89,10 @@ Fractorium::Fractorium(QWidget* p)
pixmap.fill(m_XformComboColors[i]);
m_XformComboIcons[i] = QIcon(pixmap);
}
//Set Default VariationTreeBgColor
m_VariationTreeBgColorNoneZero=QColor(200,200,200);
m_VariationTreeBgColorZero=QColor(255,255,255);
QPixmap pixmap(iconSize_, iconSize_);
pixmap.fill(m_FinalXformComboColor);

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "ui_Fractorium.h"
#include "FractoriumCommon.h"
@ -63,7 +63,9 @@ template <typename T> class FinalRenderEmberController;
class Fractorium : public QMainWindow
{
Q_OBJECT
Q_PROPERTY(QColor VariationTreeBgColorNoneZero MEMBER m_VariationTreeBgColorNoneZero)
Q_PROPERTY(QColor VariationTreeBgColorZero MEMBER m_VariationTreeBgColorZero)
friend GLWidget;
friend QssDialog;
friend LibraryTreeWidget;
@ -482,7 +484,7 @@ private:
//Xforms.
DoubleSpinBox* m_XformWeightSpin;
SpinnerButtonWidget* m_XformWeightSpinnerButtonWidget;
SpinnerLabelButtonWidget* m_XformWeightSpinnerButtonWidget;
QFormLayout* m_XformsSelectionLayout;
vector<QCheckBox*> m_XformSelections;
@ -559,6 +561,7 @@ private:
char m_CoordinateString[128];
QColor m_XformComboColors[XFORM_COLOR_COUNT], m_FinalXformComboColor;
QIcon m_XformComboIcons[XFORM_COLOR_COUNT], m_FinalXformComboIcon;
QColor m_VariationTreeBgColorNoneZero, m_VariationTreeBgColorZero;
vector<QDockWidget*> m_Docks;
int m_FontSize;
@ -569,4 +572,7 @@ private:
shared_ptr<OpenCLInfo> m_Info;
unique_ptr<FractoriumEmberControllerBase> m_Controller;
Ui::FractoriumClass ui;
};

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "EmberFile.h"
#include "DoubleSpinBox.h"
@ -184,6 +184,7 @@ public:
virtual void XformNameChanged(int row, int col) { }
virtual void XformAnimateChanged(int state) { }
virtual void FillXforms(int index = 0) { }
virtual void UpdateXformName(int index) { }
//Xforms Affine.
virtual void AffineSetHelper(double d, int index, bool pre) { }
@ -450,6 +451,7 @@ public:
virtual void XformNameChanged(int row, int col) override;
virtual void XformAnimateChanged(int state) override;
virtual void FillXforms(int index = 0) override;
virtual 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);

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h"
#include "FractoriumPch.h"
#include "Fractorium.h"
/// <summary>
@ -15,14 +15,20 @@ void Fractorium::InitXformsUI()
connect(ui.AddFinalXformButton, SIGNAL(clicked(bool)), this, SLOT(OnAddFinalXformButtonClicked(bool)), Qt::QueuedConnection);
connect(ui.CurrentXformCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(OnCurrentXformComboChanged(int)), Qt::QueuedConnection);
connect(ui.AnimateXformCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnXformAnimateCheckBoxStateChanged(int)), Qt::QueuedConnection);
SetFixedTableHeader(ui.XformWeightNameTable->horizontalHeader());
SetFixedTableHeader(ui.XformWeightNameTable->horizontalHeader(),QHeaderView::ResizeToContents);
//Use SetupSpinner() just to create the spinner, but use col of -1 to prevent it from being added to the table.
SetupSpinner<DoubleSpinBox, double>(ui.XformWeightNameTable, this, row, -1, m_XformWeightSpin, spinHeight, 0, 1000, 0.05, SIGNAL(valueChanged(double)), SLOT(OnXformWeightChanged(double)), false, 0, 1, 0);
m_XformWeightSpin->setDecimals(3);
m_XformWeightSpin->SmallStep(0.001);
m_XformWeightSpinnerButtonWidget = new SpinnerButtonWidget(m_XformWeightSpin, "=", 20, 19, ui.XformWeightNameTable);
m_XformWeightSpinnerButtonWidget->m_Button->setToolTip("Equalize weights");
m_XformWeightSpin->setMinimumWidth(40);
m_XformWeightSpinnerButtonWidget = new SpinnerLabelButtonWidget(m_XformWeightSpin, "=", 20, 19, ui.XformWeightNameTable);
m_XformWeightSpinnerButtonWidget->m_SpinBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
m_XformWeightSpinnerButtonWidget->m_Label->setStyleSheet("border: 0px;");
m_XformWeightSpinnerButtonWidget->m_Label->setAlignment(Qt::AlignRight| Qt::AlignVCenter);
m_XformWeightSpinnerButtonWidget->m_Label->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
m_XformWeightSpinnerButtonWidget->m_Button->setToolTip("Equalize weights");
m_XformWeightSpinnerButtonWidget->m_Button->setStyleSheet("text-align: center center");
m_XformWeightSpinnerButtonWidget->setMaximumWidth(130);
connect(m_XformWeightSpinnerButtonWidget->m_Button, SIGNAL(clicked(bool)), this, SLOT(OnEqualWeightButtonClicked(bool)), Qt::QueuedConnection);
ui.XformWeightNameTable->setCellWidget(0, 0, m_XformWeightSpinnerButtonWidget);
ui.XformWeightNameTable->setItem(0, 1, new QTableWidgetItem());
@ -57,9 +63,8 @@ Xform<T>* FractoriumEmberController<T>::CurrentXform()
void Fractorium::CurrentXform(uint i)
{
if (i < uint(ui.CurrentXformCombo->count()))
ui.CurrentXformCombo->setCurrentIndex(i);
ui.CurrentXformCombo->setCurrentIndex(i);
}
/// <summary>
/// Set the current xform and populate all GUI widgets.
/// Called when the current xform combo box index changes.
@ -388,7 +393,11 @@ void FractoriumEmberController<T>::XformNameChanged(int row, int col)
}, eXformUpdate::UPDATE_CURRENT, false);
FillSummary();//Manually update because this does not trigger a render, which is where this would normally be called.
}
void Fractorium::OnXformNameChanged(int row, int col) { m_Controller->XformNameChanged(row, col); }
void Fractorium::OnXformNameChanged(int row, int col)
{
m_Controller->XformNameChanged(row, col);
m_Controller->UpdateXformName(ui.CurrentXformCombo->currentIndex());
}
/// <summary>
/// Set the animate field of the selected xforms, this allows excluding current if it's not checked, but applies only to it if none are checked.
/// This has no effect on interactive rendering, it only sets a value
@ -471,8 +480,9 @@ void FractoriumEmberController<T>::SetNormalizedWeightText(Xform<T>* xform)
m_Ember.CalcNormalizedWeights(m_NormalizedWeights);
if (index != -1 && index < m_NormalizedWeights.size())
m_Fractorium->m_XformWeightSpin->setSuffix(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")");
}
//m_Fractorium->m_XformWeightSpin->setSuffix(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")");
m_Fractorium->m_XformWeightSpinnerButtonWidget->m_Label->setText(QString(" (") + QLocale::system().toString(double(m_NormalizedWeights[index]), 'g', 3) + ")");
}
}
/// <summary>
/// Determine whether the specified xform is the final xform in the ember.
@ -507,6 +517,7 @@ void FractoriumEmberController<T>::FillXforms(int index)
{
combo->addItem(ToString(i + 1));
combo->setItemIcon(i, m_Fractorium->m_XformComboIcons[i % XFORM_COLOR_COUNT]);
UpdateXformName(i);
}
i = 0;
@ -542,6 +553,7 @@ void FractoriumEmberController<T>::FillXforms(int index)
m_Fractorium->m_XformsSelectionLayout->addRow(cb, new QWidget(m_Fractorium));
combo->addItem("Final");
combo->setItemIcon(i, m_Fractorium->m_FinalXformComboIcon);
UpdateXformName(i);
}
m_Fractorium->m_XformsSelectionLayout->blockSignals(false);
@ -552,7 +564,28 @@ void FractoriumEmberController<T>::FillXforms(int index)
m_Fractorium->FillXaosTable();
m_Fractorium->OnSoloXformCheckBoxStateChanged(Qt::Unchecked);
m_Fractorium->OnCurrentXformComboChanged(index);//Make sure the event gets called, because it won't if the zero index is already selected.
m_Fractorium->OnCurrentXformComboChanged(index);//Make sure the event gets called, because it won't if the zero index is already selected.
}
/// <summary>
/// Update the text in xforms combo box to show the name of Xform.
/// </summary>
/// <param name="index">The index of the Xform to update.</param>
///
template<typename T>
void FractoriumEmberController<T>::UpdateXformName(int index)
{
bool forceFinal = m_Fractorium->HaveFinal();
bool 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 (!xform->m_Name.empty())
{
name += " " + QString::fromStdString(xform->m_Name);
}
m_Fractorium->ui.CurrentXformCombo->setItemText(index,name);
}
}
template class FractoriumEmberController<float>;
#ifdef DO_DOUBLE

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h"
#include "FractoriumPch.h"
#include "Fractorium.h"
/// <summary>
@ -226,8 +226,8 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would
if (xformVar)
xform->DeleteVariationById(var->VariationId());
widgetItem->setBackgroundColor(0, QColor(255, 255, 255));//Ensure background is always white if weight goes to zero.
}
// widgetItem->setBackgroundColor(0, QColor(255, 255, 255));//Ensure background is always white if weight goes to zero.
widgetItem->setBackgroundColor(0, m_Fractorium->m_VariationTreeBgColorZero); }
else
{
if (xformVar)//The xform already contained this variation, which means they just went from a non-zero weight to another non-zero weight (the simple case).
@ -241,8 +241,8 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would
auto newVar = var->Copy();//Create a new one with default values.
newVar->m_Weight = d;
xform->AddVariation(newVar);
widgetItem->setBackgroundColor(0, QColor(200, 200, 200));//Set background to gray when a variation has non-zero weight in this xform.
// widgetItem->setBackgroundColor(0, QColor(200, 200, 200));//Set background to gray when a variation has non-zero weight in this xform.
widgetItem->setBackgroundColor(0, m_Fractorium->m_VariationTreeBgColorNoneZero);
//If they've added a new parametric variation, then grab the values currently in the spinners
//for the child parameters and assign them to the newly added variation.
if (parVar)
@ -300,9 +300,9 @@ void FractoriumEmberController<T>::FillVariationTreeWithXform(Xform<T>* xform)
item->setHidden(false);
spinBox->SetValueStealth(var ? var->m_Weight : 0);//If the variation was present, set the spin box to its weight, else zero.
//item->setBackgroundColor(0, var ? Qt::darkGray : Qt::lightGray);//Ensure background is always white if the value goes to zero, else gray if var present.
item->setBackgroundColor(0, var ? QColor(200, 200, 200) : QColor(255, 255, 255));//Ensure background is always white if the value goes to zero, else gray if var present.
// item->setBackgroundColor(0, var ? Qt::darkGray : Qt::lightGray);//Ensure background is always white if the value goes to zero, else gray if var present.
// item->setBackgroundColor(0, var ? QColor(200, 200, 200) : QColor(255, 255, 255));//Ensure background is always white if the value goes to zero, else gray if var present.
item->setBackgroundColor(0, var ? m_Fractorium->m_VariationTreeBgColorNoneZero : m_Fractorium->m_VariationTreeBgColorZero);
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;

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include "FractoriumPch.h"
#include "DoubleSpinBox.h"
@ -118,3 +118,51 @@ public:
DoubleSpinBox* m_SpinBox;
QPushButton* m_Button;
};
class SpinnerLabelButtonWidget : public QWidget
{
Q_OBJECT
public:
/// <summary>
/// Constructor that passes the parent to the base, then creates a QLabel,
/// then creates a QPushButton and sets up its caption and dimensions, then
/// assigns the DoubleSpinBox.
/// </summary>
/// <param name="spinBox">The pre-created DoubleSpinBox</param>
/// <param name="buttonCaption">The caption of the button</param>
/// <param name="w">The width of the button</param>
/// <param name="h">The height of the button</param>
/// <param name="p">The parent widget</param>
SpinnerLabelButtonWidget(DoubleSpinBox* spinBox, QString buttonCaption, int w, int h, QWidget* p)
: QWidget(p)
{
QHBoxLayout* l = new QHBoxLayout(this);
m_Button = new QPushButton(buttonCaption, p);
m_SpinBox = spinBox;
m_Label = new QLabel(p);
m_Label->setMinimumHeight(h);
m_Label->setMaximumHeight(h);
if (w != -1)
{
m_Button->setMinimumWidth(w);
m_Button->setMaximumWidth(w);
}
m_Button->setMinimumHeight(h);
m_Button->setMaximumHeight(h);
l->addWidget(spinBox);
l->addWidget(m_Label);
l->addWidget(m_Button);
l->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
l->setMargin(0);
l->setSpacing(0);
setLayout(l);
}
DoubleSpinBox* m_SpinBox;
QPushButton* m_Button;
QLabel* m_Label;
};