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

Method UpdateSceneTree

source/interfaces/implementation/src/G4UIQt.cc:1707–1758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1705}
1706
1707void G4UIQt::UpdateSceneTree(const G4SceneTreeItem& root)
1708{
1709 // G4debug << "\nG4UIQt::UpdateSceneTree: scene tree summary\n";
1710 // root.DumpTree(G4debug); // Verbosity = 0 (one line per item)
1711 // G4debug << "\nG4UIQt::UpdateSceneTree: scene tree dump\n";
1712 // root.DumpTree(G4debug,1); // Verbosity = 1 (higher levels available)
1713
1714 // Clear the existing GUI-side tree
1715 fNewSceneTreeItemTreeWidget->clear();
1716 // (I think this deletes everything - the top level items and their children.)
1717 fMaxPVDepth = 0;
1718
1719 // Build a new GUI-side tree
1720 fNewSceneTreeItemTreeWidget->setHeaderLabel (root.GetDescription().c_str());
1721 for (const auto& model : root.GetChildren()) {
1722
1723 auto item = new QTreeWidgetItem(fNewSceneTreeItemTreeWidget);
1724
1725 // Add this GUI-side representation of the model as a child of the top widget
1726 fNewSceneTreeItemTreeWidget->insertTopLevelItem(0,item);
1727
1728 // Add text that appears in the scene tree
1729 item->setText(0, model.GetModelType().c_str());
1730
1731 // Load with info from model
1732 // There may be a way to add data as a QVariant, or a list of QVariants,
1733 // but let's try adding a G4SceneTreeItem pointer as a hex string. (There
1734 // does not seem to be a way of adding a pointer directly.)
1735 std::ostringstream oss; oss << std::hex << &model;
1736 auto data = QVariant(oss.str().c_str());
1737 item->setData(0, Qt::UserRole, data);
1738
1739 // Load a tooltip
1740 G4String toolTipMessage = model.GetModelDescription();
1741 if (!model.GetFurtherInfo().empty()) {
1742 toolTipMessage += "\n " + model.GetFurtherInfo();
1743 }
1744 item->setToolTip(0, toolTipMessage.c_str());
1745
1746 // Set the check state
1747 item->setCheckState
1748 (0, model.GetVisAttributes().IsVisible()? Qt::Checked: Qt::Unchecked);
1749
1750 // Set the expand state
1751 item->setExpanded(model.IsExpanded());
1752
1753 if (model.GetType() == G4SceneTreeItem::pvmodel) {
1754 thisSceneTreePVDepth = -1; // First item is the model - touchables hang from it
1755 BuildPVQTree(model,item);
1756 }
1757 }
1758}
1759
1760
1761void G4UIQt::UpdateDrawingStyle(G4int style) {

Callers 1

UpdateGUISceneTreeMethod · 0.45

Calls 9

c_strMethod · 0.80
GetChildrenMethod · 0.80
GetModelTypeMethod · 0.80
setDataMethod · 0.80
IsVisibleMethod · 0.80
IsExpandedMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected