Skip to content
Snippets Groups Projects
Commit 71f23129 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

lambdas accepting DoubleDescriptor are resolved

parent 8ebf63e6
No related branches found
No related tags found
1 merge request!1162rm DoubleDescriptor from code
......@@ -144,7 +144,7 @@ int FormLayouter::addValue(DoubleProperty& d, function<void(double)> onValueChan
void FormLayouter::insertValue(int row, DoubleProperty& d)
{
auto* ec = m_ec; // to allow copy-capture in the following lambda
insertValue(row, d, [ec, d](double newValue) { ec->setDouble(newValue, d); });
insertValue(row, d, [ec, &d](double newValue) { ec->setDouble(newValue, d); });
}
void FormLayouter::insertValue(int row, DoubleProperty& d, function<void(double)> onValueChange)
......
......@@ -77,8 +77,9 @@ void InterferenceForm::createInterferenceWidgets()
// SampleEditorController::setDensityRelatedValueValue has to be called (instead of
// SampleEditorController::setDouble). For this we have the following lambda to add a value:
const auto addDensityRelatedValue = [this, &layouter, interference](DoubleProperty& d) {
layouter.addValue(
d, [=](double newValue) { m_ec->setDensityRelatedValue(interference, newValue, d); });
layouter.addValue(d, [this, interference, &d](double newValue) {
m_ec->setDensityRelatedValue(interference, newValue, d);
});
};
if (auto* itf = dynamic_cast<Interference1DLatticeItem*>(interference)) {
......
......@@ -33,7 +33,7 @@ void LatticeTypeSelectionForm::createContent()
const auto valueDescriptors = currentLatticeType->geometryValues(false);
const bool vertical = valueDescriptors.size() > 2;
const auto onValueChange = [=](double newValue, DoubleDescriptor d) {
const auto onValueChange = [this](double newValue, DoubleProperty& d) {
m_ec->setDensityRelatedValue(m_interferenceItem, newValue, d);
};
LayerEditorUtils::addMultiPropertyToGrid(m_gridLayout, 1, valueDescriptors, onValueChange,
......
......@@ -69,7 +69,7 @@ void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int fir
SampleEditorController* ec, bool vertically,
bool addSpacer)
{
const auto setNewValue = [=](double newValue, DoubleDescriptor d) {
const auto setNewValue = [ec](double newValue, DoubleProperty& d) {
ec->setDouble(newValue, d);
};
......@@ -79,21 +79,21 @@ void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int fir
void LayerEditorUtils::addMultiPropertyToGrid(QGridLayout* m_gridLayout, int firstCol,
const DoublePropertyRefs& valueDescriptors,
function<void(double, DoubleDescriptor)> setNewValue,
function<void(double, DoubleProperty&)> setNewValue,
bool vertically, bool addSpacer)
{
int col = firstCol;
for (const DoubleProperty& valueDescriptor : valueDescriptors) {
for (DoubleProperty& d : valueDescriptors) {
DoubleSpinBox* editor;
if (valueDescriptor.label() == "Angle")
editor = new DoubleSpinBox(valueDescriptor, false, 1, 1.0);
if (d.label() == "Angle")
editor = new DoubleSpinBox(d, false, 1, 1.0);
else
editor = new DoubleSpinBox(valueDescriptor);
editor = new DoubleSpinBox(d);
QObject::connect(editor, &DoubleSpinBox::baseValueChanged,
[=](double newValue) { setNewValue(newValue, valueDescriptor); });
[setNewValue, &d](double newValue) { setNewValue(newValue, d); });
QString labeltext = valueDescriptor.label();
QString labeltext = d.label();
if (!vertically && !labeltext.endsWith(":"))
labeltext += ":";
auto* label = new QLabel(labeltext, m_gridLayout->parentWidget());
......@@ -130,7 +130,7 @@ void LayerEditorUtils::addVectorToGrid(QGridLayout* m_gridLayout, int firstCol,
void LayerEditorUtils::addVectorToGrid(QGridLayout* m_gridLayout, int firstCol, VectorProperty& v,
function<void(double, DoubleDescriptor)> setNewValue,
function<void(double, DoubleProperty&)> setNewValue,
bool vertically, bool addSpacer)
{
addMultiPropertyToGrid(m_gridLayout, firstCol, {v.x(), v.y(), v.z()}, setNewValue, vertically,
......
......@@ -52,7 +52,7 @@ void addMultiPropertyToGrid(QGridLayout* m_gridLayout, int firstCol,
//! Create DoubleSpinBoxes for the DoubeDescriptors and connect them to the given setNewValue()
void addMultiPropertyToGrid(QGridLayout* m_gridLayout, int firstCol,
const DoublePropertyRefs& valueDescriptors,
std::function<void(double, DoubleDescriptor)> setNewValue,
std::function<void(double, DoubleProperty&)> setNewValue,
bool vertically, bool addSpacer);
void addMultiPropertyToGrid(QGridLayout* m_gridLayout, int firstCol,
......@@ -66,7 +66,7 @@ void addVectorToGrid(QGridLayout* m_gridLayout, int firstCol, VectorProperty& v,
//! Create DoubleSpinBoxes for the DoubeDescriptors and connect them to the given setNewValue()
void addVectorToGrid(QGridLayout* m_gridLayout, int firstCol, VectorProperty& v,
std::function<void(double, DoubleDescriptor)> setNewValue, bool vertically,
std::function<void(double, DoubleProperty&)> setNewValue, bool vertically,
bool addSpacer);
......
......@@ -104,8 +104,9 @@ void MaterialInplaceForm::createWidgets()
auto* label = new QLabel(d.label(), this);
label->setBuddy(editor);
QObject::connect(editor, &DoubleLineEdit::baseValueChanged,
[=](double newValue) { m_ec->setMaterialValue(m_item, newValue, d); });
QObject::connect(editor, &DoubleLineEdit::baseValueChanged, [this, &d](double newValue) {
m_ec->setMaterialValue(m_item, newValue, d);
});
m_layout->addWidget(label, 0, col);
m_layout->addWidget(editor, 1, col++);
......@@ -113,7 +114,7 @@ void MaterialInplaceForm::createWidgets()
// -- Create UI for magnetization vector
VectorProperty mag = material->magnetization();
const auto setNewValue = [=](double value, DoubleDescriptor d) {
const auto setNewValue = [this](double value, DoubleProperty& d) {
m_ec->setMaterialValue(m_item, value, d);
};
LayerEditorUtils::addVectorToGrid(m_layout, col, mag, setNewValue, true, false);
......
......@@ -306,9 +306,9 @@ void SampleEditorController::removeParticle(ItemWithParticles* itemToRemove)
}
}
void SampleEditorController::setDouble(double newValue, DoubleDescriptor d)
void SampleEditorController::setDouble(double newValue, DoubleProperty& d)
{
m_undoStack.push(new CommandChangeValue(d.label, this, d.get(), newValue, d.path()));
m_undoStack.push(new CommandChangeValue(d.label(), this, d.get(), newValue, d.uid()));
d.set(newValue);
emit modified();
}
......@@ -379,7 +379,7 @@ void SampleEditorController::selectMaterial(ItemWithMaterial* item,
}
void SampleEditorController::setMaterialValue(ItemWithMaterial* item, double newValue,
DoubleDescriptor d)
DoubleProperty& d)
{
setDouble(newValue, d);
......@@ -393,7 +393,7 @@ void SampleEditorController::setMaterialValue(ItemWithMaterial* item, double new
}
void SampleEditorController::setDensityRelatedValue(InterferenceItem* interferenceItem,
double newValue, DoubleDescriptor d)
double newValue, DoubleProperty& d)
{
setDouble(newValue, d);
......
......@@ -23,7 +23,7 @@ class AbstractSelectionContainerForm;
class AbstractSelectionDescriptor;
class CompoundItem;
class CoreAndShellForm;
class DoubleDescriptor;
class DoubleProperty;
class InterferenceForm;
class InterferenceItem;
class Item3D;
......@@ -90,14 +90,14 @@ public:
void selectInterference(InterferenceForm* widget, int newIndex);
void setIntegrateOverXi(LatticeTypeSelectionForm* widget, bool newValue);
void setDouble(double newValue, DoubleDescriptor d);
void setDouble(double newValue, DoubleProperty& d);
void setDoubleFromUndo(double newValue, const QString& path);
void setCurrentIndex(AbstractSelectionContainerForm* widget, int index,
const AbstractSelectionDescriptor& d);
void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier);
void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d);
void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleProperty& d);
//! Set an interference function's value which affects the total particle density of the
//! containing particle layout.
......@@ -106,7 +106,7 @@ public:
//! contains this interference function. Call this method to provide all the related updating
//! (data & UI).
void setDensityRelatedValue(InterferenceItem* interferenceItem, double newValue,
DoubleDescriptor d);
DoubleProperty& d);
void onStartingToMoveLayer();
void onStoppedToMoveLayer(QWidget* widgetToMove, QWidget* moveAboveThisWidget);
......
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