150{
153
155
158
159 size_t nWorlds = transportationManager->
GetNoWorlds();
160
162 if (!world) {
165 "ERROR: G4VisCommandsTouchable::SetNewValue:"
166 "\n No world. Maybe the geometry has not yet been defined."
167 "\n Try \"/run/initialize\""
169 }
170 return;
171 }
172
174 if (!currentViewer) {
177 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
179 }
180 return;
181 }
182
184 if (!currentScene) {
187 "ERROR: No current scene - \"/vis/scene/list\" to see possibilities."
189 }
190 return;
191 }
192
193 if (command == fpCommandCentreOn || command == fpCommandCentreAndZoomInOn) {
194
195
196 std::vector<std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>> touchables;
197
201
207 nullptr,
208 true,
211
212 G4Scene tempScene(
"Centre Scene");
213 G4bool successful = tempScene.AddRunDurationModel(&tempPVModel,warn);
214 if (!successful) return;
218 << ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
220 }
221
222 const G4VisExtent& newExtent = tempScene.GetExtent();
226 if (command == fpCommandCentreAndZoomInOn) {
227
231 }
232
235
236
240
241 Twinkle(currentViewer,newVP,touchables);
243
246 <<
"Viewer \"" << currentViewer->
GetName()
247 << "\" centred ";
248 if (fpCommandCentreAndZoomInOn) {
249 G4cout <<
"and zoomed in";
250 }
253 }
255 } else {
257 }
258
259 return;
260
261 } else if (command == fpCommandDraw) {
262
266
272 nullptr,
273 true,
275
280
281 if (successful) {
283 const auto& extent = pvModel->
GetExtent();
284 const G4double halfX = (extent.GetXmax()-extent.GetXmin())/2.;
285 const G4double halfY = (extent.GetYmax()-extent.GetYmin())/2.;
286 const G4double halfZ = (extent.GetZmax()-extent.GetZmin())/2.;
287 G4Box extentBox(
"extent",halfX,halfY,halfZ);
291 }
294 <<
"\", copy no. " << properties.
fCopyNo <<
" drawn";
296 G4cout <<
" with extent box";
297 }
299 }
300 } else {
302 }
303 } else {
305 }
306 return;
307
308 } else if (command == fpCommandDump) {
309
313
319 nullptr,
320 true,
322 const std::map<G4String,G4AttDef>* attDefs = tempPVModel.GetAttDefs();
323 std::vector<G4AttValue>* attValues = tempPVModel.CreateCurrentAttValues();
325 delete attValues;
329 G4cout <<
"\nLocal polyhedron coordinates:\n" << *polyhedron;
330 const G4Transform3D& transform = tempPVModel.GetCurrentTransform();
331 polyhedron->Transform(transform);
332 G4cout <<
"\nGlobal polyhedron coordinates:\n" << *polyhedron;
333 } else {
335 }
336 return;
337
338 } else if (command == fpCommandExtentForField) {
339
349 G4cout <<
"Extent for field set to " << extent
350 << "\nVolume for field has been cleared."
352 }
355 }
356 } else {
358 }
359 return;
360
361 } else if (command == fpCommandFindPath) {
362
365 std::istringstream iss(newValue);
366 iss >> pvName >> copyNo;
367 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
368 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
370 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
373 searchModel.SetModelingParameters (&mp);
374
376 searchModel.DescribeYourselfTo (searchScene);
377 for (const auto& findings: searchScene.GetFindings()) {
378 findingsVector.push_back(findings);
379 }
380 }
381 for (const auto& findings: findingsVector) {
383 << findings.fFoundBasePVPath
384 << ' ' << findings.fpFoundPV->GetName()
385 << ' ' << findings.fFoundPVCopyNo
386 << " (mother logical volume: "
387 << findings.fpFoundPV->GetMotherLogical()->GetName()
388 << ')'
390 }
391 if (findingsVector.size()) {
393 << "Use this to set a particular touchable with \"/vis/set/touchable <path>\""
394 << "\nor to see overlaps: \"/vis/drawLogicalVolume <mother-logical-volume-name>\""
396 } else {
398 if (copyNo >= 0)
G4warn <<
':' << copyNo;
400 }
401
402 } else if (command == fpCommandLocalAxes) {
403
407 const G4double intLog10LengthMax = std::floor(std::log10(lengthMax));
408 G4double length = std::pow(10,intLog10LengthMax);
409 if (5.*length < lengthMax) length *= 5.;
410 else if (2.*length < lengthMax) length *= 2.;
412 axesModel.SetGlobalTag("LocalAxesModel");
414
415 } else if (command == fpCommandShowExtent) {
416
425 } else {
427 }
428 return;
429
430 } else if (command == fpCommandVolumeForField) {
431
448 }
451 }
452 } else {
454 }
455 return;
456
457 } else {
458
461 "ERROR: G4VisCommandsTouchable::SetNewValue: unrecognised command."
463 }
464 return;
465 }
466}
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
static G4bool GetNewBoolValue(const char *paramString)
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
void G4VisCommandsSceneAddUnsuccessful(G4VisManager::Verbosity verbosity)
static std::vector< G4PhysicalVolumesSearchScene::Findings > fCurrrentPVFindingsForField
static G4VisManager * fpVisManager
static G4VisExtent fCurrentExtentForField
void DrawExtent(const G4VisExtent &)
void InterpolateToNewView(G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
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
void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())
G4Scene * GetCurrentScene() const
G4VSceneHandler * GetCurrentSceneHandler() const
static Verbosity GetVerbosity()
void SetVerboseLevel(G4int)
void SetVisAttributes(const G4VisAttributes *)
G4PhysicalVolumeModel::TouchableProperties FindTouchableProperties(G4ModelingParameters::PVNameCopyNoPath path)
G4ModelingParameters::PVNameCopyNoPath fTouchablePath
G4VPhysicalVolume * fpTouchablePV
std::vector< G4PhysicalVolumeNodeID > fTouchableFullPVPath
std::vector< G4PhysicalVolumeNodeID > fTouchableBaseFullPVPath
G4Transform3D fTouchableGlobalTransform