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

use AbstractSelectionDescriptor

parent 79f102ba
No related branches found
No related tags found
1 merge request!415Unit handling in layer oriented sample editor
...@@ -103,14 +103,14 @@ SelectionDescriptor<RotationItem*> ItemWithParticles::rotationMethod() ...@@ -103,14 +103,14 @@ SelectionDescriptor<RotationItem*> ItemWithParticles::rotationMethod()
d.currentItem = [=]() -> RotationItem* { return rotationItem(); }; d.currentItem = [=]() -> RotationItem* { return rotationItem(); };
d.setCurrentIndex = [=](int current) { d.currentIndexSetter = [=](int current) {
if (auto item = getItem(T_TRANSFORMATION)) if (auto item = getItem(T_TRANSFORMATION))
model()->removeItem(item); model()->removeItem(item);
if (current > 0) if (current > 0)
createTransformationItem()->setRotationType(map[current].second); createTransformationItem()->setRotationType(map[current].second);
}; };
d.currentIndex = [=]() { d.currentIndexGetter = [=]() {
auto item = rotationItem(); auto item = rotationItem();
if (item == nullptr) if (item == nullptr)
return 0; return 0;
......
...@@ -129,7 +129,7 @@ SelectionDescriptor<InterferenceItem*> ParticleLayoutItem::interference() const ...@@ -129,7 +129,7 @@ SelectionDescriptor<InterferenceItem*> ParticleLayoutItem::interference() const
d.currentItem = [=] { return dynamic_cast<InterferenceItem*>(getItem(T_INTERFERENCE)); }; d.currentItem = [=] { return dynamic_cast<InterferenceItem*>(getItem(T_INTERFERENCE)); };
d.setCurrentIndex = [=](int current) { d.currentIndexSetter = [=](int current) {
if (auto item = getItem(T_INTERFERENCE)) if (auto item = getItem(T_INTERFERENCE))
model()->removeItem(item); model()->removeItem(item);
if (current > 0) if (current > 0)
...@@ -137,7 +137,7 @@ SelectionDescriptor<InterferenceItem*> ParticleLayoutItem::interference() const ...@@ -137,7 +137,7 @@ SelectionDescriptor<InterferenceItem*> ParticleLayoutItem::interference() const
T_INTERFERENCE); T_INTERFERENCE);
}; };
d.currentIndex = [=]() { d.currentIndexGetter = [=]() {
if (auto item = dynamic_cast<InterferenceItem*>(getItem(T_INTERFERENCE))) if (auto item = dynamic_cast<InterferenceItem*>(getItem(T_INTERFERENCE)))
for (int i = 1; i < map.size(); i++) for (int i = 1; i < map.size(); i++)
if (map[i].second == item->modelType()) if (map[i].second == item->modelType())
......
...@@ -226,6 +226,11 @@ void SampleEditorController::setInt(int newValue, UIntDescriptor d) ...@@ -226,6 +226,11 @@ void SampleEditorController::setInt(int newValue, UIntDescriptor d)
d.set(newValue); d.set(newValue);
} }
void SampleEditorController::setCurrentIndex(int index, const AbstractSelectionDescriptor& d)
{
d.setCurrentIndex(index);
}
QUndoStack* SampleEditorController::undoStack() QUndoStack* SampleEditorController::undoStack()
{ {
return &m_undoStack; return &m_undoStack;
......
...@@ -29,6 +29,7 @@ class ParticleCompositionItem; ...@@ -29,6 +29,7 @@ class ParticleCompositionItem;
class DoubleDescriptor; class DoubleDescriptor;
class UIntDescriptor; class UIntDescriptor;
class ItemWithMaterial; class ItemWithMaterial;
class AbstractSelectionDescriptor;
//! Class to modify a sample from the layer oriented sample editor. //! Class to modify a sample from the layer oriented sample editor.
//! //!
...@@ -72,11 +73,7 @@ public: ...@@ -72,11 +73,7 @@ public:
void setDoubleFromUndo(double newValue, const QString& path); void setDoubleFromUndo(double newValue, const QString& path);
void setInt(int newValue, UIntDescriptor d); void setInt(int newValue, UIntDescriptor d);
template <typename SelectionDescriptorClass> void setCurrentIndex(int index, const AbstractSelectionDescriptor& d);
void setCurrentIndex(int index, SelectionDescriptorClass d)
{
d.setCurrentIndex(index);
}
void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier); void selectMaterial(ItemWithMaterial* item, const QString& newMaterialIdentifier);
void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d); void setMaterialValue(ItemWithMaterial* item, double newValue, DoubleDescriptor d);
......
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