mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-02-01 18:40:12 -05:00
--Bug fixes
-Allow 7 decimal places in variations spinners. -Try to prevent infinite loop that sometimes happens when drawing grid. Unsure if this actually works since it's very hard to reproduce.
This commit is contained in:
parent
fba7f60fda
commit
4c53364f62
@ -356,7 +356,7 @@ VariationTreeDoubleSpinBox::VariationTreeDoubleSpinBox(QWidget* p, VariationTree
|
||||
m_WidgetItem = widgetItem;
|
||||
m_Param = param;
|
||||
m_Id = id;
|
||||
//setDecimals(3);
|
||||
setDecimals(7);
|
||||
//PI
|
||||
auto piAction = new QAction("PI", this);
|
||||
connect(piAction, SIGNAL(triggered(bool)), this, SLOT(PiActionTriggered(bool)), Qt::QueuedConnection);
|
||||
@ -426,7 +426,13 @@ void VariationTreeDoubleSpinBox::SqrtThreeActionTriggered(bool checked) { setVal
|
||||
|
||||
QString VariationTreeDoubleSpinBox::textFromValue(double value) const
|
||||
{
|
||||
return QWidget::locale().toString(value, 'g', 10);
|
||||
return QWidget::locale().toString(value, 'g', decimals());
|
||||
}
|
||||
|
||||
|
||||
double VariationTreeDoubleSpinBox::valueFromText(const QString& text) const
|
||||
{
|
||||
return QWidget::locale().toDouble(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -99,6 +99,7 @@ public:
|
||||
eVariationId GetVariationId() { return m_Id; }
|
||||
VariationTreeWidgetItem* WidgetItem() { return m_WidgetItem; }
|
||||
virtual QString textFromValue(double value) const override;
|
||||
virtual double valueFromText(const QString& text) const override;
|
||||
|
||||
public slots:
|
||||
void PiActionTriggered(bool checked = false);
|
||||
|
@ -213,7 +213,7 @@ Fractorium::Fractorium(QWidget* p)
|
||||
//this constructor exits, GLWidget::InitGL() will create the initial flock and start the rendering timer
|
||||
//which executes whenever the program is idle. Upon starting the timer, the renderer
|
||||
//will be initialized.
|
||||
QTimer::singleShot(500, [&]() { ui.GLDisplay->InitGL(); });
|
||||
QTimer::singleShot(1000, [&]() { ui.GLDisplay->InitGL(); });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -122,7 +122,6 @@ void FractoriumEmberController<T>::SetupVariationsTree()
|
||||
spinBox->DoubleClickZero(1);
|
||||
spinBox->DoubleClickNonZero(0);
|
||||
spinBox->SmallStep(0.001);
|
||||
//spinBox->setDecimals(4);
|
||||
tree->setItemWidget(item, 1, spinBox);
|
||||
m_Fractorium->connect(spinBox, SIGNAL(valueChanged(double)), SLOT(OnVariationSpinBoxValueChanged(double)), Qt::QueuedConnection);
|
||||
|
||||
@ -153,7 +152,6 @@ void FractoriumEmberController<T>::SetupVariationsTree()
|
||||
varSpinBox->SmallStep(1);
|
||||
}
|
||||
|
||||
varSpinBox->setDecimals(4);
|
||||
tree->setItemWidget(paramWidget, 1, varSpinBox);
|
||||
m_Fractorium->connect(varSpinBox, SIGNAL(valueChanged(double)), SLOT(OnVariationSpinBoxValueChanged(double)), Qt::QueuedConnection);
|
||||
}
|
||||
|
@ -897,13 +897,17 @@ void GLEmberController<T>::DrawGrid()
|
||||
{
|
||||
auto renderer = m_Fractorium->m_Controller->Renderer();
|
||||
double scale = m_FractoriumEmberController->AffineScaleCurrentToLocked();
|
||||
//qDebug() << renderer->UpperRightX(false) << " " << renderer->LowerLeftX(false) << " " << renderer->UpperRightY(false) << " " << renderer->LowerLeftY(false);
|
||||
float unitX = (std::abs(renderer->UpperRightX(false) - renderer->LowerLeftX(false)) / 2.0f) / scale;
|
||||
float unitY = (std::abs(renderer->UpperRightY(false) - renderer->LowerLeftY(false)) / 2.0f) / scale;
|
||||
//qDebug() << unitX << " " << unitY;
|
||||
float xLow = std::floor(-unitX);
|
||||
float xHigh = std::ceil(unitX);
|
||||
float yLow = std::floor(-unitY);
|
||||
float yHigh = std::ceil(unitY);
|
||||
float alpha = 0.25f;
|
||||
int xsteps = std::ceil(std::abs(xHigh - xLow) / GridStep);//Need these because sometimes the float value never reaches the max and it gets stuck in an infinite loop.
|
||||
int ysteps = std::ceil(std::abs(yHigh - yLow) / GridStep);
|
||||
Affine2D<T> temp;
|
||||
m4T mat = (temp * scale).ToMat4RowMajor();
|
||||
m_GL->glPushMatrix();
|
||||
@ -913,13 +917,13 @@ void GLEmberController<T>::DrawGrid()
|
||||
m_GL->glBegin(GL_LINES);
|
||||
m_GL->glColor4f(0.5f, 0.5f, 0.5f, alpha);
|
||||
|
||||
for (float fx = xLow; fx <= xHigh; fx += GridStep)
|
||||
for (float fx = xLow, i = 0; fx <= xHigh && i < xsteps; fx += GridStep, i++)
|
||||
{
|
||||
m_GL->glVertex2f(fx, yLow);
|
||||
m_GL->glVertex2f(fx, yHigh);
|
||||
}
|
||||
|
||||
for (float fy = yLow; fy < yHigh; fy += GridStep)
|
||||
for (float fy = yLow, i = 0; fy < yHigh && i < ysteps; fy += GridStep, i++)
|
||||
{
|
||||
m_GL->glVertex2f(xLow, fy);
|
||||
m_GL->glVertex2f(xHigh, fy);
|
||||
|
Loading…
Reference in New Issue
Block a user