| 1925 | } |
| 1926 | |
| 1927 | void G4UIQt::SceneTreeItemDoubleClicked(QTreeWidgetItem* item) |
| 1928 | { |
| 1929 | if (item == nullptr) return; |
| 1930 | auto sceneTreeItem = ConvertToG4SceneTreeItem(item); |
| 1931 | if (sceneTreeItem == nullptr) return; |
| 1932 | if (sceneTreeItem->GetType() != G4SceneTreeItem::touchable) return; |
| 1933 | |
| 1934 | auto oldQColor = ConvertG4ColourToQColor(sceneTreeItem->GetVisAttributes().GetColour()); |
| 1935 | auto newQColor = QColorDialog::getColor |
| 1936 | (oldQColor, fNewSceneTreeItemTreeWidget, "", QColorDialog::ShowAlphaChannel); |
| 1937 | if (!newQColor.isValid()) return; |
| 1938 | if (newQColor == oldQColor) return; |
| 1939 | |
| 1940 | auto newColour = ConvertQColorToG4Colour(newQColor); |
| 1941 | std::ostringstream oss; oss << std::setprecision(2) |
| 1942 | << newColour.GetRed() << ' ' << newColour.GetGreen() |
| 1943 | << ' ' << newColour.GetBlue() << ' ' << newColour.GetAlpha(); |
| 1944 | auto uiMan = G4UImanager::GetUIpointer(); |
| 1945 | uiMan->ApplyCommand("/vis/set/touchable" + sceneTreeItem->GetPVPath()); |
| 1946 | uiMan->ApplyCommand("/vis/touchable/set/colour " + oss.str()); |
| 1947 | |
| 1948 | // Normally the sceneTreeItem will be updated when the scene is processed after the above |
| 1949 | // commands, but if the user sets the opacity to zero, G4PhysicalVolumeModel does not |
| 1950 | // transmit it (this is because some users set the opacity to zero to make a volume |
| 1951 | // invisible - perhaps they should use the visibility flag, but hey-ho). |
| 1952 | // By design, the sceneTreeItem remains, so it can still be interacted with, but |
| 1953 | // the colour will not be updated, so we do it here. |
| 1954 | if (newColour.GetAlpha() == 0.) { |
| 1955 | sceneTreeItem->AccessVisAttributes().SetColour(newColour); |
| 1956 | } |
| 1957 | } |
| 1958 | |
| 1959 | void G4UIQt::SceneTreeItemExpanded(QTreeWidgetItem* item) |
| 1960 | { |
nothing calls this directly
no test coverage detected