File indexing completed on 2025-09-16 08:57:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 #ifndef G4VISMANAGER_HH
0080 #define G4VISMANAGER_HH
0081
0082
0083 #ifndef __MIC__
0084 #define G4VIS_USE_STD11
0085 #endif
0086
0087 #include "G4VVisManager.hh"
0088
0089 #include "globals.hh"
0090 #include "G4GraphicsSystemList.hh"
0091 #include "G4ModelingParameters.hh"
0092 #include "G4NullModel.hh"
0093 #include "G4SceneHandlerList.hh"
0094 #include "G4SceneList.hh"
0095 #include "G4TrajectoriesModel.hh"
0096 #include "G4Transform3D.hh"
0097 #include "G4UImessenger.hh"
0098
0099 #include <iostream>
0100 #include <vector>
0101 #include <map>
0102
0103 #include "G4Threading.hh"
0104
0105 class G4Scene;
0106 class G4UIcommand;
0107 class G4UImessenger;
0108 class G4VisStateDependent;
0109 class G4VTrajectoryModel;
0110 class G4VUserVisAction;
0111 template <typename> class G4VFilter;
0112 template <typename> class G4VisFilterManager;
0113 template <typename> class G4VisModelManager;
0114 template <typename> class G4VModelFactory;
0115 class G4Event;
0116
0117
0118 typedef G4VModelFactory<G4VTrajectoryModel> G4TrajDrawModelFactory;
0119 typedef G4VModelFactory<G4VFilter<G4VTrajectory> > G4TrajFilterFactory;
0120 typedef G4VModelFactory<G4VFilter<G4VHit> > G4HitFilterFactory;
0121 typedef G4VModelFactory<G4VFilter<G4VDigi> > G4DigiFilterFactory;
0122
0123 class G4VisManager: public G4VVisManager {
0124
0125
0126 friend class G4VSceneHandler;
0127 friend class G4VViewer;
0128 friend class G4VisStateDependent;
0129 friend class G4VisCommandList;
0130
0131
0132 friend std::ostream& operator << (std::ostream&, const G4VGraphicsSystem&);
0133 friend std::ostream& operator << (std::ostream&, const G4VSceneHandler&);
0134
0135 public:
0136
0137 enum Verbosity {
0138 quiet,
0139 startup,
0140 errors,
0141 warnings,
0142 confirmations,
0143 parameters,
0144 all
0145 };
0146
0147
0148 protected:
0149
0150 G4VisManager (const G4String& verbosityString = "warnings");
0151
0152
0153
0154 public:
0155
0156 virtual ~G4VisManager ();
0157
0158 private:
0159
0160
0161
0162 G4VisManager (const G4VisManager&);
0163 G4VisManager& operator = (const G4VisManager&);
0164
0165 public:
0166 static G4VisManager* GetInstance ();
0167
0168
0169
0170
0171
0172
0173 public:
0174
0175 void Initialise ();
0176 void Initialize ();
0177
0178
0179
0180 void RegisterRunDurationUserVisAction
0181 (const G4String& name, G4VUserVisAction*,
0182 const G4VisExtent& = G4VisExtent());
0183 void RegisterEndOfEventUserVisAction
0184 (const G4String& name, G4VUserVisAction*,
0185 const G4VisExtent& = G4VisExtent());
0186 void RegisterEndOfRunUserVisAction
0187 (const G4String& name, G4VUserVisAction*,
0188 const G4VisExtent& = G4VisExtent());
0189
0190 G4bool RegisterGraphicsSystem (G4VGraphicsSystem*);
0191
0192
0193
0194
0195 void RegisterModelFactory(G4TrajDrawModelFactory* factory);
0196
0197
0198 void RegisterModel(G4VTrajectoryModel* model);
0199
0200
0201 void RegisterModelFactory(G4TrajFilterFactory* factory);
0202
0203
0204 void RegisterModel(G4VFilter<G4VTrajectory>* filter);
0205
0206
0207 void RegisterModelFactory(G4HitFilterFactory* factory);
0208
0209
0210 void RegisterModel(G4VFilter<G4VHit>* filter);
0211
0212
0213 void RegisterModelFactory(G4DigiFilterFactory* factory);
0214
0215
0216 void RegisterModel(G4VFilter<G4VDigi>* filter);
0217
0218
0219 void SelectTrajectoryModel(const G4String& model);
0220
0221
0222 void RegisterMessenger(G4UImessenger* messenger);
0223
0224
0225
0226
0227
0228
0229
0230 void Draw (const G4Circle&,
0231 const G4Transform3D& objectTransformation = G4Transform3D());
0232
0233 void Draw (const G4Polyhedron&,
0234 const G4Transform3D& objectTransformation = G4Transform3D());
0235
0236 void Draw (const G4Polyline&,
0237 const G4Transform3D& objectTransformation = G4Transform3D());
0238
0239 void Draw (const G4Polymarker&,
0240 const G4Transform3D& objectTransformation = G4Transform3D());
0241
0242 void Draw (const G4Square&,
0243 const G4Transform3D& objectTransformation = G4Transform3D());
0244
0245 void Draw (const G4Text&,
0246 const G4Transform3D& objectTransformation = G4Transform3D());
0247
0248 void Draw2D (const G4Circle&,
0249 const G4Transform3D& objectTransformation = G4Transform3D());
0250
0251 void Draw2D (const G4Polyhedron&,
0252 const G4Transform3D& objectTransformation = G4Transform3D());
0253
0254 void Draw2D (const G4Polyline&,
0255 const G4Transform3D& objectTransformation = G4Transform3D());
0256
0257 void Draw2D (const G4Polymarker&,
0258 const G4Transform3D& objectTransformation = G4Transform3D());
0259
0260 void Draw2D (const G4Square&,
0261 const G4Transform3D& objectTransformation = G4Transform3D());
0262
0263 void Draw2D (const G4Text&,
0264 const G4Transform3D& objectTransformation = G4Transform3D());
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274 void Draw (const G4VTrajectory&);
0275
0276 void Draw (const G4VHit&);
0277
0278 void Draw (const G4VDigi&);
0279
0280 void Draw (const G4LogicalVolume&, const G4VisAttributes&,
0281 const G4Transform3D& objectTransformation = G4Transform3D());
0282
0283 void Draw (const G4VPhysicalVolume&, const G4VisAttributes&,
0284 const G4Transform3D& objectTransformation = G4Transform3D());
0285
0286 void Draw (const G4VSolid&, const G4VisAttributes&,
0287 const G4Transform3D& objectTransformation = G4Transform3D());
0288
0289 void DrawGeometry
0290 (G4VPhysicalVolume*, const G4Transform3D& t = G4Transform3D());
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300 void BeginDraw
0301 (const G4Transform3D& objectTransformation = G4Transform3D());
0302
0303 void EndDraw ();
0304
0305 void BeginDraw2D
0306 (const G4Transform3D& objectTransformation = G4Transform3D());
0307
0308 void EndDraw2D ();
0309
0310
0311
0312
0313 void GeometryHasChanged ();
0314
0315
0316 void IgnoreStateChanges(G4bool);
0317
0318
0319
0320
0321
0322
0323
0324 void NotifyHandlers();
0325
0326
0327
0328
0329 void DispatchToModel(const G4VTrajectory&);
0330
0331
0332 G4bool FilterTrajectory(const G4VTrajectory&);
0333 G4bool FilterHit(const G4VHit&);
0334 G4bool FilterDigi(const G4VDigi&);
0335
0336 virtual void SetUpForAThread();
0337
0338
0339 virtual void EventReadyForVis(const G4Event*);
0340
0341
0342
0343 static G4ThreadFunReturnType G4VisSubThread(G4ThreadFunArgType);
0344
0345
0346
0347
0348
0349
0350 void CreateSceneHandler (const G4String& name = "");
0351
0352
0353 void CreateViewer (const G4String& name = "", const G4String& XGeometry = "");
0354
0355
0356 private:
0357
0358 void BeginOfRun ();
0359
0360 void BeginOfEvent ();
0361
0362 void EndOfEvent ();
0363 void EndOfEventKernel (const G4Event* currentEvent);
0364 void EndOfEventCleanup (const G4Event* currentEvent);
0365 G4bool RequiredToBeKeptForVis (G4int eventID);
0366
0367
0368 void EndOfRun ();
0369
0370 public:
0371
0372
0373
0374
0375 void Enable();
0376 void Disable();
0377 G4bool IsEnabled() const;
0378
0379
0380 const G4VTrajectoryModel* CurrentTrajDrawModel() const;
0381
0382 struct UserVisAction {
0383 UserVisAction(const G4String& name, G4VUserVisAction* pUserVisAction)
0384 :fName(name), fpUserVisAction(pUserVisAction) {}
0385 G4String fName;
0386 G4VUserVisAction* fpUserVisAction;
0387 };
0388 const std::vector<UserVisAction>& GetRunDurationUserVisActions () const;
0389 const std::vector<UserVisAction>& GetEndOfEventUserVisActions () const;
0390 const std::vector<UserVisAction>& GetEndOfRunUserVisActions () const;
0391 const std::map<G4VUserVisAction*,G4VisExtent>& GetUserVisActionExtents () const;
0392 G4VGraphicsSystem* GetCurrentGraphicsSystem () const;
0393 G4Scene* GetCurrentScene () const;
0394 G4VSceneHandler* GetCurrentSceneHandler () const;
0395 G4VViewer* GetCurrentViewer () const;
0396 const G4GraphicsSystemList& GetAvailableGraphicsSystems ();
0397
0398
0399
0400 const G4SceneHandlerList& GetAvailableSceneHandlers () const;
0401 const G4SceneList& GetSceneList () const;
0402 static Verbosity GetVerbosity ();
0403 G4bool GetTransientsDrawnThisRun () const;
0404 G4bool GetTransientsDrawnThisEvent () const;
0405 G4bool GetDrawEventOnlyIfToBeKept () const;
0406 const G4Event* GetRequestedEvent () const;
0407 G4int GetNKeepForPostProcessingRequests () const;
0408 G4int GetNKeepTheEventRequests () const;
0409 G4int GetNKeepRequests () const;
0410 G4bool GetReviewingKeptEvents () const;
0411 G4bool GetAbortReviewKeptEvents () const;
0412 G4bool GetReviewingPlots () const;
0413 G4bool GetAbortReviewPlots () const;
0414 const G4ViewParameters& GetDefaultViewParameters () const;
0415 G4int GetMaxEventQueueSize () const;
0416 G4bool GetWaitOnEventQueueFull () const;
0417 virtual const G4String& GetDefaultGraphicsSystemName();
0418
0419
0420
0421 const G4String& GetDefaultXGeometryString () const;
0422 const G4String& GetDefaultGraphicsSystemBasis() const;
0423 const G4String& GetDefaultXGeometryStringBasis() const;
0424
0425 void SetCurrentGraphicsSystem (G4VGraphicsSystem*);
0426 void SetCurrentScene (G4Scene*);
0427 void SetCurrentSceneHandler (G4VSceneHandler*);
0428 void SetCurrentViewer (G4VViewer*);
0429 G4SceneHandlerList& SetAvailableSceneHandlers ();
0430 G4SceneList& SetSceneList ();
0431 void SetVerboseLevel (G4int);
0432 void SetVerboseLevel (const G4String&);
0433 void SetVerboseLevel (Verbosity);
0434 void SetEventRefreshing (G4bool);
0435 void ResetTransientsDrawnFlags ();
0436 void SetTransientsDrawnThisRun (G4bool);
0437 void SetTransientsDrawnThisEvent (G4bool);
0438 void SetDrawEventOnlyIfToBeKept (G4bool);
0439
0440 void SetRequestedEvent (const G4Event*);
0441 void SetReviewingKeptEvents (G4bool);
0442 void SetAbortReviewKeptEvents (G4bool);
0443 void SetReviewingPlots (G4bool);
0444 void SetAbortReviewPlots (G4bool);
0445 void SetDefaultViewParameters (const G4ViewParameters&);
0446 void SetMaxEventQueueSize (G4int);
0447 void SetWaitOnEventQueueFull (G4bool);
0448 void SetDefaultGraphicsSystemName(const G4String&);
0449 void SetDefaultXGeometryString (const G4String&);
0450 void SetDefaultGraphicsSystemBasis(const G4String&);
0451 void SetDefaultXGeometryStringBasis(const G4String&);
0452
0453
0454
0455
0456 G4String ViewerShortName (const G4String& viewerName) const;
0457
0458
0459
0460 G4VViewer* GetViewer (const G4String& viewerName) const;
0461
0462
0463
0464 static Verbosity GetVerbosityValue(const G4String&);
0465
0466
0467 static Verbosity GetVerbosityValue(G4int);
0468
0469
0470
0471 static G4String VerbosityString(Verbosity);
0472
0473
0474 static std::vector<G4String> VerbosityGuidanceStrings;
0475
0476
0477 static void PrintAvailableVerbosity (std::ostream& os);
0478
0479 void PrintAvailableGraphicsSystems (Verbosity, std::ostream& = G4cout) const;
0480
0481 protected:
0482
0483 virtual void RegisterGraphicsSystems () = 0;
0484
0485
0486
0487 virtual void RegisterModelFactories();
0488
0489
0490 void RegisterMessengers ();
0491
0492 const G4int fVerbose;
0493
0494
0495
0496
0497
0498 static Verbosity fVerbosity;
0499
0500 G4String fDefaultGraphicsSystemName;
0501 G4String fDefaultXGeometryString;
0502 G4String fDefaultGraphicsSystemBasis;
0503 G4String fDefaultXGeometryStringBasis;
0504
0505 private:
0506
0507
0508
0509 template <class T> void DrawT
0510 (const T& graphics_primitive, const G4Transform3D& objectTransform);
0511 template <class T> void DrawT2D
0512 (const T& graphics_primitive, const G4Transform3D& objectTransform);
0513
0514 void PrintAvailableModels (Verbosity) const;
0515 void InitialiseG4ColourMap () const;
0516 void PrintAvailableColours (Verbosity) const;
0517 void PrintAvailableUserVisActions (Verbosity) const;
0518 void PrintInvalidPointers () const;
0519 G4bool IsValidView ();
0520
0521 void ClearTransientStoreIfMarked();
0522
0523
0524
0525 static G4VisManager* fpInstance;
0526 G4bool fInitialised;
0527 std::vector<UserVisAction> fRunDurationUserVisActions;
0528 std::vector<UserVisAction> fEndOfEventUserVisActions;
0529 std::vector<UserVisAction> fEndOfRunUserVisActions;
0530 std::map<G4VUserVisAction*,G4VisExtent> fUserVisActionExtents;
0531 G4VGraphicsSystem* fpGraphicsSystem;
0532 G4Scene* fpScene;
0533 G4VSceneHandler* fpSceneHandler;
0534 G4VViewer* fpViewer;
0535 G4GraphicsSystemList fAvailableGraphicsSystems;
0536 G4SceneList fSceneList;
0537 G4SceneHandlerList fAvailableSceneHandlers;
0538 std::vector<G4UImessenger*> fMessengerList;
0539 std::vector<G4UIcommand*> fDirectoryList;
0540 G4VisStateDependent* fpStateDependent;
0541 G4bool fEventRefreshing;
0542 G4bool fTransientsDrawnThisRun;
0543 G4bool fTransientsDrawnThisEvent;
0544 G4int fNoOfEventsDrawnThisRun;
0545 G4int fNKeepForPostProcessingRequests;
0546 G4int fNKeepTheEventRequests;
0547 G4bool fEventKeepingSuspended;
0548 G4bool fDrawEventOnlyIfToBeKept;
0549 const G4Event* fpRequestedEvent;
0550 G4bool fReviewingKeptEvents;
0551 G4bool fAbortReviewKeptEvents;
0552 G4bool fReviewingPlots;
0553 G4bool fAbortReviewPlots;
0554 G4ViewParameters fDefaultViewParameters;
0555 G4bool fIsDrawGroup;
0556 G4int fDrawGroupNestingDepth;
0557 G4bool fIgnoreStateChanges;
0558 G4int fMaxEventQueueSize;
0559 G4bool fWaitOnEventQueueFull;
0560
0561
0562 G4VisModelManager<G4VTrajectoryModel>* fpTrajDrawModelMgr;
0563
0564
0565 G4VisFilterManager<G4VTrajectory>* fpTrajFilterMgr;
0566
0567
0568 G4VisFilterManager<G4VHit>* fpHitFilterMgr;
0569
0570
0571 G4VisFilterManager<G4VDigi>* fpDigiFilterMgr;
0572 };
0573
0574 #include "G4VisManager.icc"
0575
0576 #endif