50 : fSceneHandler(sceneHandler), fViewId(id), fNeedKernelVisit(true)
53 std::ostringstream ost;
134 const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& fullPath)
137 std::ostringstream oss;
139 for (
const auto& pvNodeId : fullPath) {
140 const auto& pv = pvNodeId.GetPhysicalVolume();
141 auto iterator = find(pvStore->cbegin(), pvStore->cend(), pv);
142 if (iterator == pvStore->cend()) {
144 ed <<
"Volume no longer in physical volume store.";
148 oss <<
' ' << pvNodeId.GetPhysicalVolume()->GetName() <<
' ' << pvNodeId.GetCopyNo();
155 const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& fullPath,
G4bool visibiity)
178 std::list<G4SceneTreeItem>::iterator foundIter;
180 foundIter->AccessVisAttributes().SetVisibility(visibiity);
185 ed <<
"Touchable \"" << fullPath <<
"\" not found";
191 const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& fullPath,
215 std::list<G4SceneTreeItem>::iterator foundIter;
217 foundIter->AccessVisAttributes().SetColour(colour);
222 ed <<
"Touchable \"" << fullPath <<
"\" not found";
239 auto& modelType = fpModel->
GetType();
241 FindOrInsertModel(modelType, modelID);
247 for (
const auto& dn : pvModel->GetNumberOfTouchables()) {
248 expanded += dn.second;
249 if (fMaximumExpandedDepth < dn.first) fMaximumExpandedDepth = dn.first;
250 if (expanded > fMaximumExpanded)
break;
255std::list<G4SceneTreeItem>::iterator
256G4VViewer::SceneTreeScene::FindOrInsertModel(
const G4String& modelType,
const G4String& modelID)
266 auto& rootItem = fpViewer->fSceneTree;
267 rootItem.SetDescription(fpViewer->GetName());
270 auto& modelItems = rootItem.AccessChildren();
271 auto modelIter = modelItems.begin();
272 auto pvModelIter = modelItems.end();
273 for (; modelIter != modelItems.end(); ++modelIter) {
275 pvModelIter = modelIter;
277 if (modelIter->GetModelDescription() == modelID)
break;
280 if (modelIter == modelItems.end()) {
283 modelItem.SetDescription(
"model");
284 modelItem.SetModelType(modelType);
285 modelItem.SetModelDescription(modelID);
286 if (pvModelIter != modelItems.end() &&
289 modelIter = rootItem.InsertChild(++pvModelIter, modelItem);
292 modelIter = rootItem.InsertChild(modelIter, modelItem);
297 modelIter->AccessVisAttributes().SetVisibility(
true);
304std::list<G4SceneTreeItem>::iterator G4VViewer::SceneTreeScene::FindOrInsertTouchable
309 if (pPVModel ==
nullptr) {
311 ed << fpModel->GetType() <<
": not a Physical VolumeModel";
315 auto childIter = children.begin();
316 for (; childIter != children.end(); ++childIter) {
317 if (childIter->GetPVPath() == partialPathString)
break;
319 if (childIter != children.end()) {
327 if (partialPathString == fullPathString) {
331 childIter->SetDescription(fpModel->GetCurrentTag());
332 childIter->SetModelType(fpModel->GetType());
333 childIter->SetModelDescription(modelID);
334 childIter->SetPVPath(partialPathString);
335 if (fpVisAttributes) childIter->SetVisAttributes(*fpVisAttributes);
336 if (pPVModel) childIter->SetAttDefs(pPVModel->GetAttDefs());
337 if (pPVModel) childIter->SetAttValues(pPVModel->CreateCurrentAttValues());
344 if (partialPathString == fullPathString) {
347 if (fpVisAttributes) childIter->SetVisAttributes(*fpVisAttributes);
356 if (partialPathString == fullPathString) {
361 touchable.SetExpanded(depth > fMaximumExpandedDepth?
false:
true);
362 touchable.SetDescription(fpModel->GetCurrentTag());
363 touchable.SetModelType(fpModel->GetType());
364 touchable.SetModelDescription(modelID);
365 touchable.SetPVPath(partialPathString);
366 if (fpVisAttributes) touchable.SetVisAttributes(*fpVisAttributes);
367 if (pPVModel) touchable.SetAttDefs(pPVModel->GetAttDefs());
368 if (pPVModel) touchable.SetAttValues(pPVModel->CreateCurrentAttValues());
369 childIter = mother.
InsertChild(childIter,touchable);
375 ghost.SetExpanded(depth > fMaximumExpandedDepth?
false:
true);
377 std::istringstream iss(partialPathString);
379 while (iss >> name >> copyNo);
380 std::ostringstream oss;
381 oss <<
name <<
':' << copyNo;
382 ghost.SetDescription(oss.str());
383 ghost.SetModelType(fpModel->GetType());
384 ghost.SetModelDescription(modelID);
385 ghost.SetPVPath(partialPathString);
386 ghost.AccessVisAttributes().SetVisibility(
false);
395void G4VViewer::SceneTreeScene::ProcessVolume(
const G4VSolid&)
397 auto& modelType = fpModel->GetType();
398 auto& modelID = fpModel->GetGlobalDescription();
399 auto modelIter = FindOrInsertModel(modelType, modelID);
404 std::ostringstream oss;
405 oss << pPVModel->GetFullPVPath();
409 const auto& nodeIDs = pPVModel->GetFullPVPath();
413 auto currentIter = modelIter;
415 for (
const auto& nodeID : nodeIDs) {
416 std::ostringstream oss1;
418 partialPathString +=
' ' + oss1.str();
420 FindOrInsertTouchable(modelID, *currentIter, ++depth, partialPathString, fullPathString);
428#ifdef G4MULTITHREADED
430void G4VViewer::DoneWithMasterThread()
435void G4VViewer::MovingToMasterThread()
440void G4VViewer::SwitchToVisSubThread()
445void G4VViewer::DoneWithVisSubThread()
450void G4VViewer::MovingToVisSubThread()
455void G4VViewer::SwitchToMasterThread()
464 os <<
"View " << v.
fName <<
":\n";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
static G4String GetPVNamePathString(const std::vector< G4PhysicalVolumeNodeID > &)
static G4ModelingParameters::PVNameCopyNoPath GetPVNameCopyNoPath(const std::vector< G4PhysicalVolumeNodeID > &)
static G4PhysicalVolumeStore * GetInstance()
std::list< G4SceneTreeItem > & AccessChildren()
G4bool FindTouchableFromRoot(const G4String &fullPathString, std::list< G4SceneTreeItem >::iterator &foundIter)
std::list< G4SceneTreeItem >::iterator InsertChild(std::list< G4SceneTreeItem >::iterator pos, const G4SceneTreeItem &item)
G4double GetRealElapsed() const
G4int ApplyCommand(const char *aCommand)
G4UIsession * GetG4UIWindow() const
static G4UImanager * GetUIpointer()
virtual void UpdateSceneTree(const G4SceneTreeItem &)
const G4String & GetGlobalDescription() const
const G4String & GetType() const
virtual void ProcessScene()
const G4String & GetName() const
void RemoveViewerFromList(G4VViewer *pView)
virtual void ClearStore()
void SetModel(G4VModel *pModel)
void SetTouchable(const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath)
void SetName(const G4String &)
friend std::ostream & operator<<(std::ostream &os, const G4VViewer &v)
G4VSceneHandler & fSceneHandler
G4double fKernelVisitElapsedTimeSeconds
void UpdateGUISceneTree()
G4ViewParameters fDefaultVP
void TouchableSetVisibility(const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, G4bool visibility)
virtual void FinishView()
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
void SetViewParameters(const G4ViewParameters &vp)
void TouchableSetColour(const std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > &fullPath, const G4Colour &)
G4SceneTreeItem fSceneTree
void AddVisAttributesModifier(const G4ModelingParameters::VisAttributesModifier &)
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)
const G4ViewParameters & GetDefaultViewParameters() const
static G4VisManager * GetInstance()
const char * name(G4int ptype)