Skip to content
Snippets Groups Projects
Commit 31fb1ac8 authored by Van Herck, Walter's avatar Van Herck, Walter
Browse files

Based ParticleCollectionItem on ParticleLayoutItem

parent c4bb20c7
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,6 @@ ...@@ -17,10 +17,6 @@
#include "ParticleItem.h" #include "ParticleItem.h"
#include "ComboProperty.h" #include "ComboProperty.h"
const QString ParticleCollectionItem::P_DISTRIBUTED_PARAMETER =
"Distributed parameter";
const QString ParticleCollectionItem::NO_SELECTION = "No selection";
ParticleCollectionItem::ParticleCollectionItem(ParameterizedItem *parent) ParticleCollectionItem::ParticleCollectionItem(ParameterizedItem *parent)
: ParameterizedGraphicsItem(Constants::ParticleDistributionType, parent) : ParameterizedGraphicsItem(Constants::ParticleDistributionType, parent)
{ {
...@@ -29,45 +25,9 @@ ParticleCollectionItem::ParticleCollectionItem(ParameterizedItem *parent) ...@@ -29,45 +25,9 @@ ParticleCollectionItem::ParticleCollectionItem(ParameterizedItem *parent)
addToValidChildren(Constants::ParticleType, PortInfo::PORT_0); addToValidChildren(Constants::ParticleType, PortInfo::PORT_0);
addToValidChildren(Constants::ParticleCoreShellType, PortInfo::PORT_0); addToValidChildren(Constants::ParticleCoreShellType, PortInfo::PORT_0);
ComboProperty par_prop;
registerProperty(P_DISTRIBUTED_PARAMETER, par_prop.getVariant());
updateParameterList();
} }
ParticleCollectionItem::~ParticleCollectionItem() ParticleCollectionItem::~ParticleCollectionItem()
{ {
} }
void ParticleCollectionItem::onPropertyChange(const QString &name)
{
ParameterizedItem::onPropertyChange(name);
if (name == P_DISTRIBUTED_PARAMETER
&& isRegisteredProperty(P_DISTRIBUTED_PARAMETER) ) {
QVariant par_var = getRegisteredProperty(P_DISTRIBUTED_PARAMETER);
ComboProperty par_prop = par_var.value<ComboProperty>();
}
}
void ParticleCollectionItem::onChildPropertyChange()
{
updateParameterList();
ParameterizedItem::onChildPropertyChange();
}
void ParticleCollectionItem::updateParameterList()
{
if (!isRegisteredProperty(P_DISTRIBUTED_PARAMETER)) return;
QVariant par_prop = getRegisteredProperty(P_DISTRIBUTED_PARAMETER);
QString selected_par = par_prop.value<ComboProperty>().getValue();
ComboProperty updated_prop;
if (childItems().size()>0) {
QStringList par_names = childItems()[0]->getParameterTreeList();
par_names.prepend(NO_SELECTION);
par_names.removeAll(ParticleItem::P_ABUNDANCE);
updated_prop = ComboProperty(par_names);
} else {
updated_prop << NO_SELECTION;
}
setRegisteredProperty(P_DISTRIBUTED_PARAMETER, updated_prop.getVariant());
}
...@@ -24,17 +24,8 @@ class BA_CORE_API_ ParticleCollectionItem : public ParameterizedGraphicsItem ...@@ -24,17 +24,8 @@ class BA_CORE_API_ ParticleCollectionItem : public ParameterizedGraphicsItem
{ {
Q_OBJECT Q_OBJECT
public: public:
static const QString P_DISTRIBUTED_PARAMETER;
explicit ParticleCollectionItem(ParameterizedItem *parent=0); explicit ParticleCollectionItem(ParameterizedItem *parent=0);
~ParticleCollectionItem(); ~ParticleCollectionItem();
void onPropertyChange(const QString &name);
void onChildPropertyChange();
public slots:
void updateParameterList();
private:
static const QString NO_SELECTION;
}; };
#endif // PARTICLECOLLECTIONITEM_H #endif // PARTICLECOLLECTIONITEM_H
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment