MCPcopy Create free account
hub / github.com/Geant4/geant4 / BuildPVQTree

Method BuildPVQTree

source/interfaces/implementation/src/G4UIQt.cc:1816–1872  ·  view source on GitHub ↗

Build Physical Volume tree of touchables

Source from the content-addressed store, hash-verified

1814
1815// Build Physical Volume tree of touchables
1816void G4UIQt::BuildPVQTree(const G4SceneTreeItem& g4stItem, QTreeWidgetItem* qtwItem)
1817{
1818 if (fMaxPVDepth < thisSceneTreePVDepth) fMaxPVDepth = thisSceneTreePVDepth;
1819 thisSceneTreePVDepth++;
1820 const auto& g4stChildren = g4stItem.GetChildren();
1821 for (const auto& g4stChild: g4stChildren) {
1822 QStringList qStringList;
1823 qStringList.append(g4stChild.GetDescription().c_str());
1824 auto newQTWItem = new QTreeWidgetItem(qStringList);
1825
1826 // Add a GUI-side representation of the touchable as a child
1827 qtwItem->addChild(newQTWItem);
1828
1829 // Load with info from g4stChild
1830 // There may be a way to add data as a QVariant, or a list of QVariants,
1831 // but let's try adding a G4SceneTreeItem pointer as a hex string. (There
1832 // does not seem to be a way of adding a pointer directly.)
1833 std::ostringstream oss; oss << std::hex << &g4stChild;
1834 auto data = QVariant(oss.str().c_str());
1835 newQTWItem->setData(0, Qt::UserRole, data);
1836
1837 // Load a tooltip
1838 if (g4stChild.GetType() == G4SceneTreeItem::ghost) {
1839 auto& nameCopyNo = g4stChild.GetDescription();
1840 auto name = nameCopyNo.substr(0,nameCopyNo.find(':'));
1841 oss.str(""); oss << nameCopyNo <<
1842 ": Click to make visible and get more information."
1843 "\n This may not work if the volume is in the \"base path\". (Hover on"
1844 "\n G4PhysicalVolumeModel to see base path.) If this is the case,"
1845 "\n \"/vis/scene/add/volume " << name << "\" to bring into the displayed tree.)";
1846 newQTWItem->setToolTip(0, oss.str().c_str());
1847 } else { // A fully defined touchable
1848 oss.str(""); oss << g4stChild.GetPVPath() <<
1849 "\nTo see properties, right-click/dump.";
1850 newQTWItem->setToolTip(0, oss.str().c_str());
1851 }
1852
1853 // Set the check state
1854 newQTWItem->setCheckState
1855 (0, g4stChild.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1856
1857 // Set the expand state
1858 newQTWItem->setExpanded(g4stChild.IsExpanded());
1859
1860 // Set colour icon
1861 QPixmap pixmap = QPixmap(QSize(16, 16));
1862 pixmap.fill(ConvertG4ColourToQColor(g4stChild.GetVisAttributes().GetColour()));
1863 QPainter painter(&pixmap);
1864 painter.setPen(Qt::black);
1865 painter.drawRect(0,0,15,15); // Draw contour
1866 newQTWItem->setIcon(0,pixmap);
1867
1868 // Continue recursively
1869 BuildPVQTree(g4stChild,newQTWItem);
1870 }
1871 thisSceneTreePVDepth--;
1872}
1873

Callers

nothing calls this directly

Calls 13

QPixmapClass · 0.85
ConvertG4ColourToQColorFunction · 0.85
GetChildrenMethod · 0.80
c_strMethod · 0.80
setDataMethod · 0.80
substrMethod · 0.80
IsVisibleMethod · 0.80
IsExpandedMethod · 0.80
appendMethod · 0.45
GetTypeMethod · 0.45
findMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected