Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VisCommandViewerCentreOn Class Reference

#include <G4VisCommandsViewer.hh>

+ Inheritance diagram for G4VisCommandViewerCentreOn:

Public Member Functions

 G4VisCommandViewerCentreOn ()
 
virtual ~G4VisCommandViewerCentreOn ()
 
G4String GetCurrentValue (G4UIcommand *command)
 
void SetNewValue (G4UIcommand *command, G4String newValue)
 
- Public Member Functions inherited from G4VVisCommand
 G4VVisCommand ()
 
virtual ~G4VVisCommand ()
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VVisCommand
static void SetVisManager (G4VisManager *pVisManager)
 
static const G4ColourGetCurrentTextColour ()
 
- Protected Member Functions inherited from G4VVisCommand
void SetViewParameters (G4VViewer *viewer, const G4ViewParameters &viewParams)
 
void RefreshIfRequired (G4VViewer *viewer)
 
void InterpolateViews (G4VViewer *currentViewer, std::vector< G4ViewParameters > viewVector, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
void InterpolateToNewView (G4VViewer *currentViewer, const G4ViewParameters &oldVP, const G4ViewParameters &newVP, const G4int nInterpolationPoints=50, const G4int waitTimePerPointmilliseconds=20, const G4String exportString="")
 
const G4StringConvertToColourGuidance ()
 
void ConvertToColour (G4Colour &colour, const G4String &redOrString, G4double green, G4double blue, G4double opacity)
 
G4bool ProvideValueOfUnit (const G4String &where, const G4String &unit, const G4String &category, G4double &value)
 
void CheckSceneAndNotifyHandlers (G4Scene *=nullptr)
 
G4bool CheckView ()
 
void G4VisCommandsSceneAddUnsuccessful (G4VisManager::Verbosity verbosity)
 
void CopyGuidanceFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)
 
void CopyParametersFrom (const G4UIcommand *fromCmd, G4UIcommand *toCmd)
 
void DrawExtent (const G4VisExtent &)
 
- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Static Protected Member Functions inherited from G4VVisCommand
static G4String ConvertToString (G4double x, G4double y, const char *unitName)
 
static G4bool ConvertToDoublePair (const G4String &paramString, G4double &xval, G4double &yval)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 
- Static Protected Attributes inherited from G4VVisCommand
static G4VisManagerfpVisManager = 0
 
static G4int fCurrentArrow3DLineSegmentsPerCircle = 6
 
static G4Colour fCurrentColour = G4Colour::White()
 
static G4double fCurrentLineWidth = 1.
 
static G4Colour fCurrentTextColour = G4Colour::Blue()
 
static G4Text::Layout fCurrentTextLayout = G4Text::left
 
static G4double fCurrentTextSize = 12.
 
static G4PhysicalVolumeModel::TouchableProperties fCurrentTouchableProperties
 
static G4VisExtent fCurrentExtentForField
 
static std::vector< G4PhysicalVolumesSearchScene::FindingsfCurrrentPVFindingsForField
 

Detailed Description

Definition at line 56 of file G4VisCommandsViewer.hh.

Constructor & Destructor Documentation

◆ G4VisCommandViewerCentreOn()

G4VisCommandViewerCentreOn::G4VisCommandViewerCentreOn ( )

Definition at line 142 of file G4VisCommandsViewer.cc.

142 {
143 G4bool omitable;
144 fpCommandCentreAndZoomInOn = new G4UIcommand ("/vis/viewer/centreAndZoomInOn", this);
145 fpCommandCentreAndZoomInOn->SetGuidance
146 ("Centre and zoom in on the given physical volume.");
147 fpCommandCentreAndZoomInOn->SetGuidance
148 ("The names of all volumes in all worlds are matched against pv-name. If"
149 "\ncopy-no is supplied, it matches the copy number too. If pv-name is of the"
150 "\nform \"/regexp/\", where regexp is a regular expression (see C++ regex),"
151 "\nthe match uses the usual rules of regular expression matching."
152 "\nOtherwise an exact match is required."
153 "\nFor example, \"/Shap/\" matches \"Shape1\" and \"Shape2\".");
154 fpCommandCentreAndZoomInOn->SetGuidance
155 ("It may help to see a textual representation of the geometry hierarchy of"
156 "\nthe worlds. Try \"/vis/drawTree [worlds]\" or one of the driver/browser"
157 "\ncombinations that have the required functionality, e.g., HepRepFile.");
158 fpCommandCentreAndZoomInOn->SetGuidance
159 ("If there are more than one matching physical volumes they will all be"
160 "\nincluded. If this is not what you want, and what you want is to centre on a"
161 "\nparticular touchable, then select the touchable (\"/vis/set/touchable\") and"
162 "\nuse \"/vis/touchable/centreOn\". (You may need \"/vis/touchable/findPath\".)");
163 G4UIparameter* parameter;
164 parameter = new G4UIparameter("pv-name",'s',omitable = false);
165 parameter->SetGuidance ("Physical volume name.");
166 fpCommandCentreAndZoomInOn->SetParameter(parameter);
167 parameter = new G4UIparameter("copy-no",'i',omitable = true);
168 parameter->SetDefaultValue (-1);
169 parameter->SetGuidance ("Copy number. -1 means any or all copy numbers");
170 fpCommandCentreAndZoomInOn->SetParameter(parameter);
171
172 fpCommandCentreOn = new G4UIcommand ("/vis/viewer/centreOn", this);
173 fpCommandCentreOn->SetGuidance ("Centre the view on the given physical volume.");
174 // Pick up additional guidance from /vis/viewer/centreAndZoomInOn
175 CopyGuidanceFrom(fpCommandCentreAndZoomInOn,fpCommandCentreOn,1);
176 // Pick up parameters from /vis/viewer/centreAndZoomInOn
177 CopyParametersFrom(fpCommandCentreAndZoomInOn,fpCommandCentreOn);
178}
bool G4bool
Definition: G4Types.hh:86
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetDefaultValue(const char *theDefaultValue)
void SetGuidance(const char *theGuidance)
void CopyParametersFrom(const G4UIcommand *fromCmd, G4UIcommand *toCmd)
void CopyGuidanceFrom(const G4UIcommand *fromCmd, G4UIcommand *toCmd, G4int startLine=0)

◆ ~G4VisCommandViewerCentreOn()

G4VisCommandViewerCentreOn::~G4VisCommandViewerCentreOn ( )
virtual

Definition at line 180 of file G4VisCommandsViewer.cc.

180 {
181 delete fpCommandCentreAndZoomInOn;
182 delete fpCommandCentreOn;
183}

Member Function Documentation

◆ GetCurrentValue()

G4String G4VisCommandViewerCentreOn::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 185 of file G4VisCommandsViewer.cc.

185 {
186 return "";
187}

◆ SetNewValue()

void G4VisCommandViewerCentreOn::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 189 of file G4VisCommandsViewer.cc.

189 {
190
192 G4bool warn = verbosity >= G4VisManager::warnings;
193
194 G4VViewer* currentViewer = fpVisManager -> GetCurrentViewer ();
195 if (!currentViewer) {
196 if (verbosity >= G4VisManager::errors) {
197 G4cerr <<
198 "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
199 << G4endl;
200 }
201 return;
202 }
203
204 G4String pvName;
205 G4int copyNo;
206 std::istringstream is (newValue);
207 is >> pvName >> copyNo;
208
209 // Find physical volumes
210 G4TransportationManager* transportationManager =
212 size_t nWorlds = transportationManager->GetNoWorlds();
213 std::vector<G4PhysicalVolumesSearchScene::Findings> findingsVector;
214 std::vector<G4VPhysicalVolume*>::iterator iterWorld =
215 transportationManager->GetWorldsIterator();
216 for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
217 G4PhysicalVolumeModel searchModel (*iterWorld); // Unlimited depth.
218 G4ModelingParameters mp; // Default - no culling.
219 searchModel.SetModelingParameters (&mp);
220 G4PhysicalVolumesSearchScene searchScene (&searchModel, pvName, copyNo);
221 searchModel.DescribeYourselfTo (searchScene); // Initiate search.
222 for (const auto& findings: searchScene.GetFindings()) {
223 findingsVector.push_back(findings);
224 }
225 }
226
227 if (findingsVector.empty()) {
228 if (verbosity >= G4VisManager::warnings) {
229 G4cerr
230 << "WARNING: Volume \"" << pvName << "\" ";
231 if (copyNo > 0) {
232 G4cerr << "copy number " << copyNo;
233 }
234 G4cerr << " not found." << G4endl;
235 }
236 return;
237 }
238
239 // Use a temporary scene in order to find vis extent
240 G4Scene tempScene("Centre Scene");
241 for (const auto& findings: findingsVector) {
242 // To handle paramaterisations we have to set the copy number
243 findings.fpFoundPV->SetCopyNo(findings.fFoundPVCopyNo);
244 // Create a temporary physical volume model.
245 // They have to be created on the heap because they have
246 // to hang about long enough to be conflated.
248 (findings.fpFoundPV,
249 0, // Only interested in top volume
250 findings.fFoundObjectTransformation,
251 0, // No modelling parameters (these are set later by the scene handler).
252 true, // Use full extent
253 findings.fFoundBasePVPath);
254 // ...and add it to the scene.
255 G4bool successful = tempScene.AddRunDurationModel(tempPVModel,warn);
256 if (successful) {
257 if (verbosity >= G4VisManager::confirmations) {
258 G4cout << "\"" << findings.fpFoundPV->GetName()
259 << "\", copy no. " << findings.fFoundPVCopyNo
260 << ",\n found in searched volume \""
261 << findings.fpSearchPV->GetName()
262 << "\" at depth " << findings.fFoundDepth
263 << ",\n base path: \"" << findings.fFoundBasePVPath
264 << ",\n has been added to temporary scene \"" << tempScene.GetName() << "\"."
265 << G4endl;
266 }
267 }
268 }
269 // Delete temporary physical volume models
270 for (const auto& sceneModel: tempScene.GetRunDurationModelList()) {
271 delete sceneModel.fpModel;
272 }
273
274 // Relevant results
275 const G4VisExtent& newExtent = tempScene.GetExtent();
276 const G4ThreeVector& newTargetPoint = newExtent.GetExtentCentre();
277
278 G4Scene* currentScene = currentViewer->GetSceneHandler()->GetScene();
279 G4ViewParameters saveVP = currentViewer->GetViewParameters();
280 G4ViewParameters newVP = saveVP;
281 if (command == fpCommandCentreAndZoomInOn) {
282 // Calculate the new zoom factor
283 const G4double zoomFactor
284 = currentScene->GetExtent().GetExtentRadius()/newExtent.GetExtentRadius();
285 newVP.SetZoomFactor(zoomFactor);
286 }
287 // Change the target point
288 const G4Point3D& standardTargetPoint = currentScene->GetStandardTargetPoint();
289 newVP.SetCurrentTargetPoint(newTargetPoint - standardTargetPoint);
290 // Interpolate
291 InterpolateToNewView(currentViewer, saveVP, newVP);
292
293 if (verbosity >= G4VisManager::confirmations) {
294 G4cout
295 << "Viewer \"" << currentViewer->GetName()
296 << "\" centred ";
297 if (fpCommandCentreAndZoomInOn) {
298 G4cout << "and zoomed in";
299 }
300 G4cout << " on physical volume(s) \"" << pvName << '\"'
301 << G4endl;
302 }
303
304 SetViewParameters(currentViewer, newVP);
305}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
static G4TransportationManager * GetTransportationManager()
std::vector< G4VPhysicalVolume * >::iterator GetWorldsIterator()
size_t GetNoWorlds() const
G4Scene * GetScene() const
const G4String & GetName() const
const G4ViewParameters & GetViewParameters() const
G4VSceneHandler * GetSceneHandler() const
static G4VisManager * fpVisManager
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)
void SetCurrentTargetPoint(const G4Point3D &currentTargetPoint)
void SetZoomFactor(G4double zoomFactor)
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
const G4Point3D & GetExtentCentre() const
Definition: G4VisExtent.cc:65
static Verbosity GetVerbosity()

The documentation for this class was generated from the following files: