188 {
189
192
193 G4VViewer* currentViewer =
fpVisManager -> GetCurrentViewer ();
194 if (!currentViewer) {
197 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
199 }
200 return;
201 }
202
203 G4String pvName;
205 std::istringstream is (newValue);
206 is >> pvName >> copyNo;
207
208
209 G4TransportationManager* transportationManager =
211 std::size_t nWorlds = transportationManager->
GetNoWorlds();
212 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
213 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
215 for (std::size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
216 G4PhysicalVolumeModel searchModel (*iterWorld);
217 G4ModelingParameters mp;
218 searchModel.SetModelingParameters (&mp);
219
220 G4PhysicalVolumesSearchScene searchScene (&searchModel, pvName, copyNo);
221 searchModel.DescribeYourselfTo (searchScene);
222 for (const auto& findings: searchScene.GetFindings()) {
223 findingsVector.push_back(findings);
224 }
225 }
226
227 if (findingsVector.empty()) {
230 << "WARNING: Volume \"" << pvName << "\" ";
231 if (copyNo > 0) {
232 G4warn <<
"copy number " << copyNo;
233 }
235 }
236 return;
237 }
238
239
240 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> foundPaths;
241
242
243 G4Scene tempScene("Centre Scene");
244 G4bool successfullyAdded =
true;
245 for (const auto& findings: findingsVector) {
246
247 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
248
249
250
251 G4PhysicalVolumeModel* tempPVModel = new G4PhysicalVolumeModel
252 (findings.fpFoundPV,
253 0,
254 findings.fFoundObjectTransformation,
255 0,
256 true,
257 findings.fFoundBasePVPath);
258
259 auto successful = tempScene.AddRunDurationModel(tempPVModel,warn);
260 if (!successful) {
261 successfullyAdded = false;
262 continue;
263 }
265 G4cout <<
"\"" << findings.fpFoundPV->GetName()
266 << "\", copy no. " << findings.fFoundPVCopyNo
267 << ",\n found in searched volume \""
268 << findings.fpSearchPV->GetName()
269 << "\" at depth " << findings.fFoundDepth
270 << ",\n base path: \"" << findings.fFoundBasePVPath
271 << ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
273 }
274 foundPaths.push_back(findings.fFoundFullPVPath);
275 }
276
277 for (const auto& sceneModel: tempScene.GetRunDurationModelList()) {
278 delete sceneModel.fpModel;
279 }
280 if (!successfullyAdded) return;
281
282
283 const G4VisExtent& newExtent = tempScene.GetExtent();
285
288 G4ViewParameters newVP = saveVP;
289 if (command == fpCommandCentreAndZoomInOn) {
290
294 }
295
298
299
301
305
306 Twinkle(currentViewer,newVP,foundPaths);
308 }
309
312 <<
"Viewer \"" << currentViewer->
GetName()
313 << "\" centred ";
314 if (fpCommandCentreAndZoomInOn) {
315 G4cout <<
"and zoomed in";
316 }
317 G4cout <<
" on physical volume(s) \"" << pvName <<
'\"'
319 }
320
322}
HepGeom::Point3D< G4double > G4Point3D
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const
G4Scene * GetScene() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
G4double GetKernelVisitElapsedTimeSeconds() const
G4VSceneHandler * GetSceneHandler() const
void InterpolateToNewView(G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String &exportString="")
static G4VisManager * fpVisManager
void SetViewParameters(G4VViewer *viewer, const G4ViewParameters &viewParams)
void Twinkle(G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
void SetZoomFactor(G4double zoomFactor)
G4double GetExtentRadius() const
const G4Point3D & GetExtentCentre() const