155{
158
160
161 G4TransportationManager* transportationManager =
163
164 size_t nWorlds = transportationManager->
GetNoWorlds();
165
167 if (!world) {
170 "ERROR: G4VisCommandsTouchable::SetNewValue:"
171 "\n No world. Maybe the geometry has not yet been defined."
172 "\n Try \"/run/initialize\""
174 }
175 return;
176 }
177
178 if (command == fpCommandDump) {
179
180 G4PhysicalVolumeModel::TouchableProperties properties =
183
185 G4PhysicalVolumeModel tempPVModel
189 nullptr,
190 true,
192 const std::map<G4String,G4AttDef>* attDefs = tempPVModel.GetAttDefs();
193 std::vector<G4AttValue>* attValues = tempPVModel.CreateCurrentAttValues();
194 G4cout << G4AttCheck(attValues,attDefs);
195 delete attValues;
198 if (polyhedron) {
199 polyhedron->SetVisAttributes(lv->GetVisAttributes());
200 G4cout <<
"\nLocal polyhedron coordinates:\n" << *polyhedron;
201 const G4Transform3D& transform = tempPVModel.GetCurrentTransform();
202 polyhedron->Transform(transform);
203 G4cout <<
"\nGlobal polyhedron coordinates:\n" << *polyhedron;
204 }
205 } else {
207 }
208 return;
209
210 } else if (command == fpCommandFindPath) {
211
212 G4String pvName;
214 std::istringstream iss(newValue);
215 iss >> pvName >> copyNo;
216 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
217 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
219 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
220 G4PhysicalVolumeModel searchModel (*iterWorld);
221 G4ModelingParameters mp;
222 searchModel.SetModelingParameters (&mp);
223
224 G4PhysicalVolumesSearchScene searchScene (&searchModel, pvName, copyNo);
225 searchModel.DescribeYourselfTo (searchScene);
226 for (const auto& findings: searchScene.GetFindings()) {
227 findingsVector.push_back(findings);
228 }
229 }
230 for (const auto& findings: findingsVector) {
232 << findings.fFoundBasePVPath
233 << ' ' << findings.fpFoundPV->GetName()
234 << ' ' << findings.fFoundPVCopyNo
235 << " (mother logical volume: "
236 << findings.fpFoundPV->GetMotherLogical()->GetName()
237 << ')'
239 }
240 if (findingsVector.size()) {
242 << "Use this to set a particular touchable with \"/vis/set/touchable <path>\""
243 << "\nor to see overlaps: \"/vis/drawLogicalVolume <mother-logical-volume-name>\""
245 } else {
247 if (copyNo >= 0)
G4warn <<
':' << copyNo;
249 }
250 return;
251 }
252
253 G4VViewer* currentViewer =
fpVisManager -> GetCurrentViewer ();
254 if (!currentViewer) {
257 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
259 }
260 return;
261 }
262
263 G4Scene* currentScene =
fpVisManager->GetCurrentScene();
264 if (!currentScene) {
267 "ERROR: No current scene - \"/vis/scene/list\" to see possibilities."
269 }
270 return;
271 }
272
273 if (command == fpCommandCentreOn || command == fpCommandCentreAndZoomInOn) {
274
275
276 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
277
278 G4PhysicalVolumeModel::TouchableProperties properties =
281
283 G4PhysicalVolumeModel tempPVModel
287 nullptr,
288 true,
291
292 G4Scene tempScene("Centre Scene");
293 G4bool successful = tempScene.AddRunDurationModel(&tempPVModel,warn);
294 if (!successful) return;
298 << ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
300 }
301
302 const G4VisExtent& newExtent = tempScene.GetExtent();
305 G4ViewParameters newVP = saveVP;
306 if (command == fpCommandCentreAndZoomInOn) {
307
311 }
312
315
317
321
322 Twinkle(currentViewer,newVP,touchables);
324 }
325
328 <<
"Viewer \"" << currentViewer->
GetName()
329 << "\" centred ";
330 if (fpCommandCentreAndZoomInOn) {
331 G4cout <<
"and zoomed in";
332 }
335 }
337 } else {
339 }
340 return;
341
342 } else if (command == fpCommandDraw) {
343
344 G4PhysicalVolumeModel::TouchableProperties properties =
347
349 G4PhysicalVolumeModel* pvModel = new G4PhysicalVolumeModel
353 nullptr,
354 true,
356
361
362 if (successful) {
363 if (fpCommandDraw->GetNewBoolValue(newValue)) {
364 const auto& extent = pvModel->
GetExtent();
365 const G4double halfX = (extent.GetXmax()-extent.GetXmin())/2.;
366 const G4double halfY = (extent.GetYmax()-extent.GetYmin())/2.;
367 const G4double halfZ = (extent.GetZmax()-extent.GetZmin())/2.;
368 G4Box extentBox("extent",halfX,halfY,halfZ);
369 G4VisAttributes extentVA;
372 }
375 <<
"\", copy no. " << properties.
fCopyNo <<
" drawn";
376 if (fpCommandDraw->GetNewBoolValue(newValue)) {
377 G4cout <<
" with extent box";
378 }
380 }
381 } else {
383 }
384 } else {
386 }
387 return;
388
389 } else if (command == fpCommandExtentForField) {
390
391 G4PhysicalVolumeModel::TouchableProperties properties =
394 G4VisExtent extent
400 G4cout <<
"Extent for field set to " << extent
401 << "\nVolume for field has been cleared."
403 }
404 if (fpCommandExtentForField->GetNewBoolValue(newValue)) {
406 }
407 } else {
409 }
410 return;
411
412 } else if (command == fpCommandLocalAxes) {
413
414 G4PhysicalVolumeModel::TouchableProperties properties =
420 const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
421 G4double length = std::pow(10,intLog10LengthMax);
422 if (5.*length < lengthMax) length *= 5.;
423 else if (2.*length < lengthMax) length *= 2.;
424 G4AxesModel axesModel(0.,0.,0.,length,transform);
425 axesModel.SetGlobalTag("LocalAxesModel");
426 axesModel.DescribeYourselfTo(*
fpVisManager->GetCurrentSceneHandler());
428 } else {
430 }
431 return;
432
433 } else if (command == fpCommandShowExtent) {
434
435 G4PhysicalVolumeModel::TouchableProperties properties =
438 G4VisExtent extent
442 if (fpCommandShowExtent->GetNewBoolValue(newValue))
DrawExtent(extent);
443 } else {
445 }
446 return;
447
448 } else if (command == fpCommandTwinkle) {
449
451 G4PhysicalVolumeModel::TouchableProperties properties =
454 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
462 } else {
464 }
465 } else {
466 G4warn <<
"Twinkling not available - image construction time too long." <<
G4endl;
467 }
468 return;
469
470 } else if (command == fpCommandVolumeForField) {
471
472 G4PhysicalVolumeModel::TouchableProperties properties =
475 G4VisExtent extent
481 (G4PhysicalVolumesSearchScene::Findings(properties));
488 }
489 if (fpCommandVolumeForField->GetNewBoolValue(newValue)) {
491 }
492 } else {
494 }
495 return;
496
497 } else {
498
501 "ERROR: G4VisCommandsTouchable::SetNewValue: unrecognised command."
503 }
504 return;
505 }
506}
HepGeom::Point3D< G4double > G4Point3D
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G4VSolid * GetSolid() const
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
std::size_t GetNoWorlds() const
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
const G4VisExtent & GetExtent() const
virtual void SetCopyNo(G4int CopyNo)=0
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
virtual G4VisExtent GetExtent() const
virtual G4Polyhedron * GetPolyhedron() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
G4double GetKernelVisitElapsedTimeSeconds() const
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
void InterpolateToNewView(G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String &exportString="")
static std::vector< G4PhysicalVolumesSearchScene::Findings > fCurrrentPVFindingsForField
static G4VisManager * fpVisManager
static G4VisExtent fCurrentExtentForField
void DrawExtent(const G4VisExtent &)
void SetViewParameters(G4VViewer *viewer, const G4ViewParameters &viewParams)
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
void Twinkle(G4VViewer *currentViewer, const G4ViewParameters &baseVP, const std::vector< std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > > &paths)
void SetCurrentTargetPoint(const G4Point3D ¤tTargetPoint)
void SetZoomFactor(G4double zoomFactor)
void SetForceWireframe(G4bool=true)
G4double GetExtentRadius() const
G4VisExtent & Transform(const G4Transform3D &)
const G4Point3D & GetExtentCentre() const
G4PhysicalVolumeModel::TouchableProperties FindTouchableProperties(G4ModelingParameters::PVNameCopyNoPath path)
G4VPhysicalVolume * fpTouchablePV
std::vector< G4PhysicalVolumeNodeID > fTouchableFullPVPath
std::vector< G4PhysicalVolumeNodeID > fTouchableBaseFullPVPath
G4Transform3D fTouchableGlobalTransform