--User changes -Add pre/post in Toolbar

This commit is contained in:
Michel Mastriani 2020-01-22 20:24:15 -03:00
parent 207ace6c67
commit 1fdebe6f05
11 changed files with 328 additions and 222 deletions

View File

@ -234,7 +234,7 @@ Fractorium::~Fractorium()
{ {
SyncSequenceSettings(); SyncSequenceSettings();
m_VarDialog->SyncSettings(); m_VarDialog->SyncSettings();
m_Settings->ShowXforms(ui.ActionDrawXforms->isChecked()); m_Settings->ShowXforms(ui.ActionDrawPreAffines->isChecked() || ui.ActionDrawPostAffines->isChecked());
m_Settings->ShowGrid(ui.ActionDrawGrid->isChecked()); m_Settings->ShowGrid(ui.ActionDrawGrid->isChecked());
m_Settings->setValue("windowState", saveState()); m_Settings->setValue("windowState", saveState());
m_Settings->sync(); m_Settings->sync();

View File

@ -15,6 +15,11 @@
#include "DoubleSpinBoxTableItemDelegate.h" #include "DoubleSpinBoxTableItemDelegate.h"
#include "PaletteEditor/PaletteEditor.h" #include "PaletteEditor/PaletteEditor.h"
/// <summary>
/// An enum representing the type of edit being done.
/// </summary>
enum class eAffineState : int { PRE, ALL_PRE, POST, ALL_POST };
/// <summary> /// <summary>
/// Fractorium class. /// Fractorium class.
/// </summary> /// </summary>
@ -116,6 +121,8 @@ public:
void CurrentXform(uint i); void CurrentXform(uint i);
//Xforms Affine. //Xforms Affine.
bool DrawPreAffines();
bool DrawPostAffines();
bool DrawSelectedPre(); bool DrawSelectedPre();
bool DrawAllPre(); bool DrawAllPre();
bool DrawSelectedPost(); bool DrawSelectedPost();
@ -174,7 +181,8 @@ public slots:
void OnActionDP(bool checked); void OnActionDP(bool checked);
void OnActionStyle(bool checked); void OnActionStyle(bool checked);
void OnActionStartStopRenderer(bool checked); void OnActionStartStopRenderer(bool checked);
void OnActionDrawXforms(bool checked); void OnActionDrawAffines(bool checked);
void OnActionDrawAllAffines(bool checked);
void OnActionDrawImage(bool checked); void OnActionDrawImage(bool checked);
void OnActionDrawGrid(bool checked); void OnActionDrawGrid(bool checked);
@ -412,6 +420,8 @@ private:
bool HaveFinal(); bool HaveFinal();
//Toolbar. //Toolbar.
void SaveAffineState();
void SyncAffineStateToToolbar();
void SyncOptionsToToolbar(); void SyncOptionsToToolbar();
//Library. //Library.
@ -592,6 +602,7 @@ private:
QColor m_VariationTreeBgColorNonZero, m_VariationTreeBgColorZero; QColor m_VariationTreeBgColorNonZero, m_VariationTreeBgColorZero;
vector<QDockWidget*> m_Docks; vector<QDockWidget*> m_Docks;
bool m_PreviousAffineState[4];
int m_FontSize; int m_FontSize;
int m_VarSortMode; int m_VarSortMode;
int m_PaletteSortMode; int m_PaletteSortMode;

View File

@ -50,5 +50,6 @@
<file>Icons/Function-512.png</file> <file>Icons/Function-512.png</file>
<file>Icons/pic.png</file> <file>Icons/pic.png</file>
<file>Icons/grid.png</file> <file>Icons/grid.png</file>
<file>Icons/reset_scale.png</file>
</qresource> </qresource>
</RCC> </RCC>

File diff suppressed because it is too large Load Diff

View File

@ -766,17 +766,20 @@ void Fractorium::OnActionResetWorkspace(bool checked)
/// <param name="checked">Ignored</param> /// <param name="checked">Ignored</param>
void Fractorium::OnActionAlternateEditorImage(bool checked) void Fractorium::OnActionAlternateEditorImage(bool checked)
{ {
if (DrawImage()) if (DrawPreAffines() || DrawPostAffines())
{ {
ui.ActionDrawImage->setChecked(false); ui.ActionDrawPreAffines->setChecked(false);
ui.ActionDrawXforms->setChecked(true); ui.ActionDrawAllPreAffines->setChecked(false);
ui.ActionDrawGrid->setChecked(true); ui.ActionDrawPostAffines->setChecked(false);
ui.ActionDrawAllPostAffines->setChecked(false);
ui.ActionDrawGrid->setChecked(false);
ui.ActionDrawImage->setChecked(true);
} }
else else
{ {
ui.ActionDrawXforms->setChecked(false); ui.ActionDrawImage->setChecked(false);
ui.ActionDrawGrid->setChecked(false); ui.ActionDrawGrid->setChecked(true);
ui.ActionDrawImage->setChecked(true); SyncAffineStateToToolbar();
} }
ui.GLDisplay->update(); ui.GLDisplay->update();

View File

@ -15,24 +15,37 @@ void Fractorium::InitToolbarUI()
spGroup->addAction(ui.ActionDP); spGroup->addAction(ui.ActionDP);
SyncOptionsToToolbar(); SyncOptionsToToolbar();
ui.ActionDrawImage->setChecked(true); ui.ActionDrawImage->setChecked(true);
connect(ui.ActionCpu, SIGNAL(triggered(bool)), this, SLOT(OnActionCpu(bool)), Qt::QueuedConnection); m_PreviousAffineState[(int)eAffineState::PRE] = true;
connect(ui.ActionCL, SIGNAL(triggered(bool)), this, SLOT(OnActionCL(bool)), Qt::QueuedConnection); m_PreviousAffineState[(int)eAffineState::ALL_PRE] = true;
connect(ui.ActionSP, SIGNAL(triggered(bool)), this, SLOT(OnActionSP(bool)), Qt::QueuedConnection); m_PreviousAffineState[(int)eAffineState::POST] = false;
connect(ui.ActionDP, SIGNAL(triggered(bool)), this, SLOT(OnActionDP(bool)), Qt::QueuedConnection); m_PreviousAffineState[(int)eAffineState::ALL_POST] = false;
connect(ui.ActionStyle, SIGNAL(triggered(bool)), this, SLOT(OnActionStyle(bool)), Qt::QueuedConnection); connect(ui.ActionCpu, SIGNAL(triggered(bool)), this, SLOT(OnActionCpu(bool)), Qt::QueuedConnection);
connect(ui.ActionStartStopRenderer, SIGNAL(triggered(bool)), this, SLOT(OnActionStartStopRenderer(bool)), Qt::QueuedConnection); connect(ui.ActionCL, SIGNAL(triggered(bool)), this, SLOT(OnActionCL(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawXforms, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawXforms(bool)), Qt::QueuedConnection); connect(ui.ActionSP, SIGNAL(triggered(bool)), this, SLOT(OnActionSP(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawImage, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawImage(bool)), Qt::QueuedConnection); connect(ui.ActionDP, SIGNAL(triggered(bool)), this, SLOT(OnActionDP(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawGrid, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawGrid(bool)), Qt::QueuedConnection); connect(ui.ActionStyle, SIGNAL(triggered(bool)), this, SLOT(OnActionStyle(bool)), Qt::QueuedConnection);
connect(ui.ActionStartStopRenderer, SIGNAL(triggered(bool)), this, SLOT(OnActionStartStopRenderer(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawImage, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawImage(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawPreAffines, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawAffines(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawPostAffines, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawAffines(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawAllPreAffines, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawAllAffines(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawAllPostAffines, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawAllAffines(bool)), Qt::QueuedConnection);
connect(ui.ActionDrawGrid, SIGNAL(triggered(bool)), this, SLOT(OnActionDrawGrid(bool)), Qt::QueuedConnection);
} }
/// <summary> /// <summary>
/// GUI wrapper functions, getters only. /// GUI wrapper functions, getters only.
/// </summary> /// </summary>
bool Fractorium::DrawXforms() { return ui.ActionDrawXforms->isChecked(); } bool Fractorium::DrawPreAffines() { return ui.ActionDrawPreAffines->isChecked(); }
bool Fractorium::DrawImage() { return ui.ActionDrawImage->isChecked(); } bool Fractorium::DrawPostAffines() { return ui.ActionDrawPostAffines->isChecked(); }
bool Fractorium::DrawGrid() { return ui.ActionDrawGrid->isChecked(); } bool Fractorium::DrawSelectedPre() { return !ui.ActionDrawAllPreAffines->isChecked(); }
bool Fractorium::DrawAllPre() { return ui.ActionDrawAllPreAffines->isChecked(); }
bool Fractorium::DrawSelectedPost() { return !ui.ActionDrawAllPostAffines->isChecked(); }
bool Fractorium::DrawAllPost() { return ui.ActionDrawAllPostAffines->isChecked(); }
bool Fractorium::DrawXforms() { return ui.ActionDrawPreAffines->isChecked() || ui.ActionDrawPostAffines->isChecked(); }
bool Fractorium::DrawImage() { return ui.ActionDrawImage->isChecked(); }
bool Fractorium::DrawGrid() { return ui.ActionDrawGrid->isChecked(); }
/// <summary> /// <summary>
/// Called when the CPU render option on the toolbar is clicked. /// Called when the CPU render option on the toolbar is clicked.
@ -122,18 +135,30 @@ void Fractorium::OnActionStartStopRenderer(bool checked)
} }
/// <summary> /// <summary>
/// Toggle whether to show the affines. /// Called when the pre affine button is clicked.
/// Called when the editor image button is clicked.
/// </summary> /// </summary>
/// <param name="checked">Check state, show editor if true, else hide.</param> /// <param name="checked">Check state, show pre affines if true, else hide.</param>
void Fractorium::OnActionDrawXforms(bool checked) void Fractorium::OnActionDrawAffines(bool checked)
{ {
m_Settings->ShowXforms(checked); m_Settings->ShowXforms(checked);
if (!ui.ActionDrawImage->isChecked() && !ui.ActionDrawXforms->isChecked()) if (!ui.ActionDrawImage->isChecked() && !(ui.ActionDrawPreAffines->isChecked() || ui.ActionDrawPostAffines->isChecked()))
ui.ActionDrawImage->setChecked(true); ui.ActionDrawImage->setChecked(true);
ui.GLDisplay->update(); SaveAffineState();
ui.GLDisplay->update();
}
/// <summary>
/// Toggle whether to show selected/all post affines.
/// Called when the show all post affine button is clicked.
/// </summary>
/// <param name="checked">Check state, show all pre affines if true, else show selected.</param>
void Fractorium::OnActionDrawAllAffines(bool checked)
{
SaveAffineState();
ui.GLDisplay->update();
} }
/// <summary> /// <summary>
@ -143,8 +168,8 @@ void Fractorium::OnActionDrawXforms(bool checked)
/// <param name="checked">Check state, show image if true, else hide.</param> /// <param name="checked">Check state, show image if true, else hide.</param>
void Fractorium::OnActionDrawImage(bool checked) void Fractorium::OnActionDrawImage(bool checked)
{ {
if (!ui.ActionDrawImage->isChecked() && !ui.ActionDrawXforms->isChecked()) if (!ui.ActionDrawImage->isChecked())
ui.ActionDrawXforms->setChecked(true); SyncAffineStateToToolbar();
ui.GLDisplay->update(); ui.GLDisplay->update();
} }
@ -160,6 +185,32 @@ void Fractorium::OnActionDrawGrid(bool checked)
ui.GLDisplay->update(); ui.GLDisplay->update();
} }
/// <summary>
/// Keep previous state of the affines to switch between Editor and Image
/// </summary>
void Fractorium::SaveAffineState()
{
if(!ui.ActionDrawPreAffines->isChecked() && !ui.ActionDrawPostAffines->isChecked())
return;
m_PreviousAffineState[(int)eAffineState::PRE] = ui.ActionDrawPreAffines->isChecked();
m_PreviousAffineState[(int)eAffineState::ALL_PRE] = ui.ActionDrawAllPreAffines->isChecked();
m_PreviousAffineState[(int)eAffineState::POST] = ui.ActionDrawPostAffines->isChecked();
m_PreviousAffineState[(int)eAffineState::ALL_POST] = ui.ActionDrawAllPostAffines->isChecked();
}
/// <summary>
/// Sync affine state data to the check state of the toolbar buttons.
/// This does not trigger a clicked() event.
/// </summary>
void Fractorium::SyncAffineStateToToolbar()
{
ui.ActionDrawPreAffines->setChecked(m_PreviousAffineState[(int)eAffineState::PRE]);
ui.ActionDrawAllPreAffines->setChecked(m_PreviousAffineState[(int)eAffineState::ALL_PRE]);
ui.ActionDrawPostAffines->setChecked(m_PreviousAffineState[(int)eAffineState::POST]);
ui.ActionDrawAllPostAffines->setChecked(m_PreviousAffineState[(int)eAffineState::ALL_POST]);
}
/// <summary> /// <summary>
/// Sync options data to the check state of the toolbar buttons. /// Sync options data to the check state of the toolbar buttons.
/// This does not trigger a clicked() event. /// This does not trigger a clicked() event.
@ -196,5 +247,8 @@ void Fractorium::SyncOptionsToToolbar()
} }
ui.ActionDrawGrid->setChecked(m_Settings->ShowGrid()); ui.ActionDrawGrid->setChecked(m_Settings->ShowGrid());
ui.ActionDrawXforms->setChecked(m_Settings->ShowXforms()); ui.ActionDrawPreAffines->setChecked(m_Settings->ShowXforms());
} ui.ActionDrawAllPreAffines->setChecked(m_Settings->ShowXforms());
SaveAffineState();
}

View File

@ -154,8 +154,10 @@ void Fractorium::InitXformsAffineUI()
m_PostSpins[5] = m_PostO2Spin; m_PostSpins[5] = m_PostO2Spin;
ui.PreAffineGroupBox->setChecked(false);//Flip both once to force enabling/disabling the disabling of the group boxes and the corner buttons. ui.PreAffineGroupBox->setChecked(false);//Flip both once to force enabling/disabling the disabling of the group boxes and the corner buttons.
ui.PreAffineGroupBox->setChecked(true);//Pre affine enabled. ui.PreAffineGroupBox->setChecked(true);//Pre affine enabled.
ui.PostAffineGroupBox->setChecked(true); ui.PostAffineGroupBox->setChecked(false);
ui.PostAffineGroupBox->setChecked(false);//Post affine disabled. ui.PostAffineGroupBox->setChecked(true);//Post affine enabled.
ui.PreAffineShowGroupBox->setVisible(false); // michel - to delete
ui.PostAffineShowGroupBox->setVisible(false); // michel - to delete
} }
/// <summary> /// <summary>
@ -791,13 +793,9 @@ void Fractorium::SetupAffineSpinner(QTableWidget* table, const QObject* receiver
} }
/// <summary> /// <summary>
/// GUI wrapper functions, getters only. /// GUI wrapper function, getter only.
/// </summary> /// </summary>
bool Fractorium::DrawSelectedPre() { return ui.ShowPreAffineSelectedRadio->isChecked(); }
bool Fractorium::DrawAllPre() { return ui.ShowPreAffineAllRadio->isChecked(); }
bool Fractorium::DrawSelectedPost() { return ui.ShowPostAffineSelectedRadio->isChecked(); }
bool Fractorium::DrawAllPost() { return ui.ShowPostAffineAllRadio->isChecked(); }
bool Fractorium::LocalPivot() { return ui.LocalPivotRadio->isChecked(); } bool Fractorium::LocalPivot() { return ui.LocalPivotRadio->isChecked(); }
template class FractoriumEmberController<float>; template class FractoriumEmberController<float>;

View File

@ -523,8 +523,8 @@ void GLWidget::paintGL()
} }
//Affine drawing. //Affine drawing.
bool pre = m_Fractorium->ui.PreAffineGroupBox->isChecked(); bool pre = m_Fractorium->DrawPreAffines();
bool post = m_Fractorium->ui.PostAffineGroupBox->isChecked(); bool post = m_Fractorium->DrawPostAffines();
this->glEnable(GL_BLEND); this->glEnable(GL_BLEND);
this->glEnable(GL_LINE_SMOOTH); this->glEnable(GL_LINE_SMOOTH);
this->glEnable(GL_POINT_SMOOTH); this->glEnable(GL_POINT_SMOOTH);
@ -1757,8 +1757,8 @@ void GLWidget::DrawAffineHelper(int index, float circleWidth, float lineWidth, b
template <typename T> template <typename T>
int GLEmberController<T>::UpdateHover(v3T& glCoords) int GLEmberController<T>::UpdateHover(v3T& glCoords)
{ {
bool pre = m_Fractorium->ui.PreAffineGroupBox->isChecked(); bool pre = m_Fractorium->DrawPreAffines();
bool post = m_Fractorium->ui.PostAffineGroupBox->isChecked(); bool post = m_Fractorium->DrawPostAffines();
int i = 0, bestIndex = -1; int i = 0, bestIndex = -1;
T bestDist = 10; T bestDist = 10;
auto ember = m_FractoriumEmberController->CurrentEmber(); auto ember = m_FractoriumEmberController->CurrentEmber();

BIN
Source/Fractorium/Icons/grid.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
Source/Fractorium/Icons/pic.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB