File indexing completed on 2024-04-06 12:11:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <cassert>
0015 #include "TEveCompound.h"
0016 #include "TEveManager.h"
0017 #include "TEveSelection.h"
0018
0019 #include "Fireworks/Core/interface/FWInteractionList.h"
0020 #include "Fireworks/Core/interface/FWEventItem.h"
0021 #include "Fireworks/Core/interface/FWModelIdFromEveSelector.h"
0022 #include "Fireworks/Core/interface/FWModelId.h"
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 FWInteractionList::FWInteractionList(const FWEventItem* item) : m_item(item) {}
0036
0037
0038
0039
0040
0041
0042 FWInteractionList::~FWInteractionList() {
0043 for (std::vector<TEveCompound*>::iterator i = m_compounds.begin(); i != m_compounds.end(); ++i) {
0044
0045
0046
0047 if ((*i)->GetUserData())
0048 delete reinterpret_cast<FWFromEveSelectorBase*>((*i)->GetUserData());
0049
0050 (*i)->RemoveElements();
0051 (*i)->DecDenyDestroy();
0052 }
0053 }
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 void FWInteractionList::added(TEveElement* el, unsigned int idx) {
0064
0065
0066 if (idx < m_compounds.size()) {
0067 m_compounds[idx]->AddElement(el);
0068 return;
0069 }
0070
0071
0072
0073 std::string name = m_item->modelName(idx);
0074 if (m_item->haveInterestingValue())
0075 name += m_item->modelInterestingValueAsString(idx);
0076
0077 TEveCompound* c = new TEveCompound(name.c_str(), name.c_str());
0078 c->EnableListElements(m_item->defaultDisplayProperties().isVisible());
0079 c->SetMainColor(m_item->defaultDisplayProperties().color());
0080 c->SetMainTransparency(m_item->defaultDisplayProperties().transparency());
0081
0082
0083 c->CSCImplySelectAllChildren();
0084 c->CSCApplyMainColorToAllChildren();
0085 c->CSCApplyMainTransparencyToAllChildren();
0086
0087
0088
0089 c->IncDenyDestroy();
0090
0091
0092
0093 c->SetUserData(new FWModelIdFromEveSelector(FWModelId(m_item, idx)));
0094
0095
0096 m_compounds.push_back(c);
0097 m_compounds.back()->AddElement(el);
0098
0099 }
0100
0101
0102
0103
0104 void FWInteractionList::modelChanges(const FWModelIds& iIds) {
0105 assert(m_compounds.size() >= m_item->size());
0106
0107 for (std::set<FWModelId>::const_iterator it = iIds.begin(); it != iIds.end(); ++it) {
0108 const FWEventItem::ModelInfo& info = m_item->modelInfo(it->index());
0109
0110 const FWDisplayProperties& p = info.displayProperties();
0111 TEveElement* comp = m_compounds[it->index()];
0112 comp->EnableListElements(p.isVisible(), p.isVisible());
0113 comp->SetMainColor(p.color());
0114 comp->SetMainTransparency(p.transparency());
0115
0116 if (info.isSelected()) {
0117 if (comp->GetSelectedLevel() != 1)
0118 gEve->GetSelection()->AddElement(comp);
0119 } else {
0120 if (comp->GetSelectedLevel() == 1)
0121 gEve->GetSelection()->RemoveElement(comp);
0122 }
0123 }
0124 }
0125
0126
0127
0128
0129
0130 void FWInteractionList::itemChanged() {
0131 for (size_t i = 0, e = m_item->size(); i < e; ++i) {
0132
0133
0134 TEveElement* comp = m_compounds[i];
0135
0136 std::string name = m_item->modelName(i);
0137 if (m_item->haveInterestingValue())
0138 name += m_item->modelInterestingValueAsString(i);
0139
0140 comp->SetElementTitle(name.c_str());
0141
0142 const FWEventItem::ModelInfo& info = m_item->modelInfo(i);
0143 const FWDisplayProperties& p = info.displayProperties();
0144
0145 if (p.isVisible() != comp->GetRnrSelf())
0146 comp->EnableListElements(p.isVisible(), p.isVisible());
0147
0148 if (p.color() != comp->GetMainColor())
0149 comp->SetMainColor(p.color());
0150
0151 if (p.transparency() != comp->GetMainTransparency())
0152 comp->SetMainTransparency(p.transparency());
0153 }
0154 }