158 std::map<VP1GeoFlags::SubSystemFlag,Imp::SubSystem*>::iterator it, itE =
m_d->flag2subsystems.end();
159 for (it =
m_d->flag2subsystems.begin();it!=itE;++it)
161 for (it =
m_d->flag2subsystems.begin();it!=itE;++it)
185 if (subsys->subsysflag==flag) {
193 std::cout<<
"VolumeTreeModel::addSubSystem Error: System has already been added!"<<std::endl;
200 std::cout<<
"VolumeTreeModel::addSubSystem Error: Unknown system flag! Please update the code!"<<std::endl;
222 section->name =
"Unknown Section Flag";
236 subsys->
name =
"Unknown subsystem flag";
242 section->disabledSubSystems << subsys;
243 m_d->flag2subsystems[flag]=subsys;
252 if (
m_d->flag2subsystems.find(flag)==
m_d->flag2subsystems.end()) {
253 std::cout<<
"VolumeTreeModel::enableSubSystem Error: System never added!"<<std::endl;
273 std::cout<<
"VolumeTreeModel::enableSubSystem Error: Did not find section of subsystem!."<<std::endl;
277 section->enabledSubSystems << subsys;
278 section->disabledSubSystems.removeAll(subsys);
280 if (
section->enabledSubSystems.count()==1) {
281 assert(!
m_d->activeSections.contains(
section));
286 m_d->volhandle2subsystem[volhandle] = subsys;
299 if (
m_d->flag2subsystems.find(flag)==
m_d->flag2subsystems.end())
319 std::cout<<
"VolumeTreeModel::disableSubSystem Error: Did not find section of subsystem!."<<std::endl;
324 section->disabledSubSystems << subsys;
325 section->enabledSubSystems.removeAll(subsys);
327 if (
section->enabledSubSystems.count()==0) {
328 assert(
m_d->activeSections.contains(
section));
334 Q_ASSERT(
m_d->volhandle2subsystem.find(volhandle)!=
m_d->volhandle2subsystem.end());
335 m_d->volhandle2subsystem.erase(
m_d->volhandle2subsystem.find(volhandle));
346 out.reserve(
m_d->flag2subsystems.size());
347 std::map<VP1GeoFlags::SubSystemFlag,Imp::SubSystem*>::iterator it, itE =
m_d->flag2subsystems.end();
348 for (it =
m_d->flag2subsystems.begin();it!=itE;++it)
349 out.push_back(std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr>
350 (it->second->volhandlelist.begin(),it->second->volhandlelist.end()));
358 if (!hasIndex(row, column,
parent))
359 return QModelIndex();
363 Q_ASSERT(row<m_d->activeSections.count());
364 return createIndex(row, column,
m_d->activeSections.at(row));
373 Q_ASSERT(childHandle);
374 return createIndex(row, column, childHandle);
392 if (!
index.isValid())
393 return QModelIndex();
401 return createIndex(parentHandle->
childNumber(), 0, parentHandle);
404 Q_ASSERT(
m_d->volhandle2subsystem.find(childHandle)!=
m_d->volhandle2subsystem.end());
420 return QModelIndex();
430 return m_d->activeSections.size();
450 if ((role!=Qt::DisplayRole&&role!=Qt::ForegroundRole)||!
index.isValid())
455 if (role==Qt::ForegroundRole) {
459 return QColor::fromRgbF( 0.5, 0.5, 0.5 );
463 return volumeHandle->
getName()+
" ["+QString::number(volumeHandle->
nChildren())+
"]";
465 return volumeHandle->
getName();
468 if (role==Qt::ForegroundRole)
482 if (!
index.isValid())
483 return Qt::ItemFlags();
486 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
488 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