Skip to content
Snippets Groups Projects
Commit 78c7925c authored by Matthias Puchner's avatar Matthias Puchner
Browse files

fix total density value on creation of widget

parent 59579395
No related branches found
No related tags found
1 merge request!579Various fixes & modifications
...@@ -41,7 +41,20 @@ DoubleDescriptor ParticleLayoutItem::ownDensity() const ...@@ -41,7 +41,20 @@ DoubleDescriptor ParticleLayoutItem::ownDensity() const
return m_ownDensity; return m_ownDensity;
} }
double ParticleLayoutItem::totalDensity() const DoubleDescriptor ParticleLayoutItem::totalDensity() const
{
// create descriptor with same value as own density, then change the getter and setter
DoubleDescriptor d = ownDensity();
d.set = [=](double d) {
if (!totalDensityIsDefinedByInterference())
const_cast<DoubleProperty*>(&m_ownDensity)->set(d);
};
d.get = [=]() { return totalDensityValue(); };
d.path = [=]() { return m_ownDensity.uid() + "/totalDensity"; };
return d;
}
double ParticleLayoutItem::totalDensityValue() const
{ {
if (!totalDensityIsDefinedByInterference()) if (!totalDensityIsDefinedByInterference())
return m_ownDensity; return m_ownDensity;
...@@ -63,7 +76,6 @@ double ParticleLayoutItem::totalDensity() const ...@@ -63,7 +76,6 @@ double ParticleLayoutItem::totalDensity() const
if (const auto* hd = dynamic_cast<const InterferenceHardDiskItem*>(m_interference.get())) if (const auto* hd = dynamic_cast<const InterferenceHardDiskItem*>(m_interference.get()))
return hd->density(); return hd->density();
ASSERT(false); ASSERT(false);
} }
......
...@@ -42,8 +42,8 @@ public: ...@@ -42,8 +42,8 @@ public:
//! //!
//! Returns ownDensity() if the interference is not influencing the density. If the //! Returns ownDensity() if the interference is not influencing the density. If the
//! interference is defining the density, this is the interference-calculated density. //! interference is defining the density, this is the interference-calculated density.
double totalDensity() const; DoubleDescriptor totalDensity() const;
double totalDensityValue() const;
DoubleDescriptor weight() const; DoubleDescriptor weight() const;
//! The particles this layout contains. //! The particles this layout contains.
......
...@@ -34,7 +34,7 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la ...@@ -34,7 +34,7 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la
{ {
FormLayouter layouter(this, ec); FormLayouter layouter(this, ec);
layouter.setContentsMargins(30, 6, 0, 0); layouter.setContentsMargins(30, 6, 0, 0);
int rowOfTotalDensity = layouter.addValue(m_layoutItem->ownDensity()); int rowOfTotalDensity = layouter.addValue(m_layoutItem->totalDensity());
m_totalDensitySpinBox = m_totalDensitySpinBox =
layouter.widgetAt<DoubleSpinBox*>(rowOfTotalDensity, QFormLayout::FieldRole); layouter.widgetAt<DoubleSpinBox*>(rowOfTotalDensity, QFormLayout::FieldRole);
ASSERT(m_totalDensitySpinBox); ASSERT(m_totalDensitySpinBox);
...@@ -63,7 +63,6 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la ...@@ -63,7 +63,6 @@ ParticleLayoutForm::ParticleLayoutForm(LayerForm* parent, ParticleLayoutItem* la
m_layout = layouter.layout(); m_layout = layouter.layout();
updateDensityEnabling(); updateDensityEnabling();
updateDensityValue();
updateTitle(parent->layerItem()); updateTitle(parent->layerItem());
} }
...@@ -105,11 +104,7 @@ void ParticleLayoutForm::updateDensityEnabling() ...@@ -105,11 +104,7 @@ void ParticleLayoutForm::updateDensityEnabling()
void ParticleLayoutForm::updateDensityValue() void ParticleLayoutForm::updateDensityValue()
{ {
if (m_layoutItem->totalDensityIsDefinedByInterference()) { m_totalDensitySpinBox->updateValue();
QSignalBlocker b(m_totalDensitySpinBox);
m_totalDensitySpinBox->setBaseValue(m_layoutItem->totalDensity());
} else
m_totalDensitySpinBox->updateValue();
} }
void ParticleLayoutForm::updateTitle(const LayerItem* layerItem) void ParticleLayoutForm::updateTitle(const LayerItem* layerItem)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment