156 std::map<VP1GeoFlags::SubSystemFlag,Imp::SubSystem*>::iterator it, itE =
m_d->flag2subsystems.end();
157 for (it =
m_d->flag2subsystems.begin();it!=itE;++it)
159 for (it =
m_d->flag2subsystems.begin();it!=itE;++it)
183 if (subsys->subsysflag==flag) {
191 std::cout<<
"VolumeTreeModel::addSubSystem Error: System has already been added!"<<std::endl;
198 std::cout<<
"VolumeTreeModel::addSubSystem Error: Unknown system flag! Please update the code!"<<std::endl;
220 section->name =
"Unknown Section Flag";
234 subsys->
name =
"Unknown subsystem flag";
240 section->disabledSubSystems << subsys;
241 m_d->flag2subsystems[flag]=subsys;
250 if (
m_d->flag2subsystems.find(flag)==
m_d->flag2subsystems.end()) {
251 std::cout<<
"VolumeTreeModel::enableSubSystem Error: System never added!"<<std::endl;
271 std::cout<<
"VolumeTreeModel::enableSubSystem Error: Did not find section of subsystem!."<<std::endl;
275 section->enabledSubSystems << subsys;
276 section->disabledSubSystems.removeAll(subsys);
278 if (
section->enabledSubSystems.count()==1) {
279 assert(!
m_d->activeSections.contains(
section));
284 m_d->volhandle2subsystem[volhandle] = subsys;
297 if (
m_d->flag2subsystems.find(flag)==
m_d->flag2subsystems.end())
317 std::cout<<
"VolumeTreeModel::disableSubSystem Error: Did not find section of subsystem!."<<std::endl;
322 section->disabledSubSystems << subsys;
323 section->enabledSubSystems.removeAll(subsys);
325 if (
section->enabledSubSystems.count()==0) {
326 assert(
m_d->activeSections.contains(
section));
332 Q_ASSERT(
m_d->volhandle2subsystem.find(volhandle)!=
m_d->volhandle2subsystem.end());
333 m_d->volhandle2subsystem.erase(
m_d->volhandle2subsystem.find(volhandle));
344 out.reserve(
m_d->flag2subsystems.size());
345 std::map<VP1GeoFlags::SubSystemFlag,Imp::SubSystem*>::iterator it, itE =
m_d->flag2subsystems.end();
346 for (it =
m_d->flag2subsystems.begin();it!=itE;++it)
347 out.push_back(std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr>
348 (it->second->volhandlelist.begin(),it->second->volhandlelist.end()));
356 if (!hasIndex(row, column,
parent))
357 return QModelIndex();
361 Q_ASSERT(row<m_d->activeSections.count());
362 return createIndex(row, column,
m_d->activeSections.at(row));
371 Q_ASSERT(childHandle);
372 return createIndex(row, column, childHandle);
390 if (!
index.isValid())
391 return QModelIndex();
399 return createIndex(parentHandle->
childNumber(), 0, parentHandle);
402 Q_ASSERT(
m_d->volhandle2subsystem.find(childHandle)!=
m_d->volhandle2subsystem.end());
418 return QModelIndex();
428 return m_d->activeSections.size();
448 if ((role!=Qt::DisplayRole&&role!=Qt::ForegroundRole)||!
index.isValid())
453 if (role==Qt::ForegroundRole) {
457 return QColor::fromRgbF( 0.5, 0.5, 0.5 );
461 return volumeHandle->
getName()+
" ["+QString::number(volumeHandle->
nChildren())+
"]";
463 return volumeHandle->
getName();
466 if (role==Qt::ForegroundRole)
480 if (!
index.isValid())
481 return Qt::ItemFlags();
484 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
486 return Qt::ItemIsEnabled;
static const Attributes_t empty
@ MuonBarrelStationMiddle
VolumeHandle(VolumeHandleSharedData *, VolumeHandle *parent, const GeoPVConstLink &, int childNumber, const MuonChamberState &mcs=NONMUONCHAMBER, const SbMatrix &accumTrans=SbMatrix())
bool childrenAreInitialised() const
void initialiseChildren()
std::vector< VolumeHandle * > VolumeHandleList
VolumeHandleList::iterator VolumeHandleListItr
VolumeHandle * child(int index) const
unsigned nChildren() const
QList< SubSystem * > enabledSubSystems
QList< SubSystem * > disabledSubSystems
SubSystem(SectionInfo *si, VP1GeoFlags::SubSystemFlag sf)
VolumeHandle::VolumeHandleList volhandlelist
VP1GeoFlags::SubSystemFlag subsysflag
static VolumeHandle * handlePointer(const QModelIndex &idx)
static void defineSubSystem(VP1GeoFlags::SubSystemFlag, QString, SECTION)
static std::map< VP1GeoFlags::SubSystemFlag, QString > subsysflag2string
std::map< VP1GeoFlags::SubSystemFlag, SubSystem * > flag2subsystems
static std::map< SECTION, QString > section2string
static std::map< VP1GeoFlags::SubSystemFlag, SECTION > subsysflag2section
static bool isRegularVolumeHandle(VolumeHandle *handle)
static SubSystem * subSystemPointer(VolumeHandle *handle)
static bool isSectionInfoPointer(VolumeHandle *handle)
static SectionInfo * sectionInfoPointer(VolumeHandle *handle)
QList< SectionInfo * > activeSections
QList< SectionInfo * > allSections
std::map< VolumeHandle *, SubSystem * > volhandle2subsystem
static bool isSubSystemPointer(VolumeHandle *handle)
QVariant data(const QModelIndex &, int) const
int rowCount(const QModelIndex &) const
void enableSubSystem(VP1GeoFlags::SubSystemFlag flag)
VolumeTreeModel(QObject *parent=0)
Qt::ItemFlags flags(const QModelIndex &index) const
QModelIndex index(int, int, const QModelIndex &) const
virtual ~VolumeTreeModel()
void disableSubSystem(VP1GeoFlags::SubSystemFlag flag)
void fetchMore(const QModelIndex &parent)
void addSubSystem(VP1GeoFlags::SubSystemFlag flag, const VolumeHandle::VolumeHandleList &roothandles)
QVariant headerData(int section, Qt::Orientation orientation, int role) const
bool canFetchMore(const QModelIndex &parent) const
QModelIndex parent(const QModelIndex &) const
void getRootHandles(std::vector< std::pair< VolumeHandle::VolumeHandleListItr, VolumeHandle::VolumeHandleListItr > > &) const
bool hasChildren(const QModelIndex &parent=QModelIndex()) const
std::string find(const std::string &s)
return a remapped string