File indexing completed on 2025-01-18 09:59:24
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 #ifdef G4MULTITHREADED
0337
0338 virtual void SetUpForAThread();
0339
0340
0341 static G4ThreadFunReturnType G4VisSubThread(G4ThreadFunArgType);
0342
0343
0344 #endif
0345
0346
0347
0348
0349 void CreateSceneHandler (const G4String& name = "");
0350
0351
0352 void CreateViewer (const G4String& name = "", const G4String& XGeometry = "");
0353
0354
0355 private:
0356
0357 void BeginOfRun ();
0358
0359 void BeginOfEvent ();
0360
0361 void EndOfEvent ();
0362
0363
0364
0365
0366 void EndOfRun ();
0367
0368 public:
0369
0370
0371
0372
0373 void Enable();
0374 void Disable();
0375 G4bool IsEnabled() const;
0376
0377
0378 const G4VTrajectoryModel* CurrentTrajDrawModel() const;
0379
0380 struct UserVisAction {
0381 UserVisAction(const G4String& name, G4VUserVisAction* pUserVisAction)
0382 :fName(name), fpUserVisAction(pUserVisAction) {}
0383 G4String fName;
0384 G4VUserVisAction* fpUserVisAction;
0385 };
0386 const std::vector<UserVisAction>& GetRunDurationUserVisActions () const;
0387 const std::vector<UserVisAction>& GetEndOfEventUserVisActions () const;
0388 const std::vector<UserVisAction>& GetEndOfRunUserVisActions () const;
0389 const std::map<G4VUserVisAction*,G4VisExtent>& GetUserVisActionExtents () const;
0390 G4VGraphicsSystem* GetCurrentGraphicsSystem () const;
0391 G4Scene* GetCurrentScene () const;
0392 G4VSceneHandler* GetCurrentSceneHandler () const;
0393 G4VViewer* GetCurrentViewer () const;
0394 const G4GraphicsSystemList& GetAvailableGraphicsSystems ();
0395
0396
0397
0398 const G4SceneHandlerList& GetAvailableSceneHandlers () const;
0399 const G4SceneList& GetSceneList () const;
0400 static Verbosity GetVerbosity ();
0401 G4bool GetTransientsDrawnThisRun () const;
0402 G4bool GetTransientsDrawnThisEvent () const;
0403 G4bool GetDrawEventOnlyIfToBeKept () const;
0404 const G4Event* GetRequestedEvent () const;
0405 G4int GetNKeepRequests () const;
0406 G4bool GetReviewingKeptEvents () const;
0407 G4bool GetAbortReviewKeptEvents () const;
0408 G4bool GetReviewingPlots () const;
0409 G4bool GetAbortReviewPlots () const;
0410 const G4ViewParameters& GetDefaultViewParameters () const;
0411 #ifdef G4MULTITHREADED
0412 G4int GetMaxEventQueueSize () const;
0413 G4bool GetWaitOnEventQueueFull () const;
0414 #endif
0415 const G4String& GetDefaultGraphicsSystemName() const;
0416 const G4String& GetDefaultXGeometryString () const;
0417 const G4String& GetDefaultGraphicsSystemBasis() const;
0418 const G4String& GetDefaultXGeometryStringBasis() const;
0419
0420 void SetCurrentGraphicsSystem (G4VGraphicsSystem*);
0421 void SetCurrentScene (G4Scene*);
0422 void SetCurrentSceneHandler (G4VSceneHandler*);
0423 void SetCurrentViewer (G4VViewer*);
0424 G4SceneHandlerList& SetAvailableSceneHandlers ();
0425 G4SceneList& SetSceneList ();
0426 void SetVerboseLevel (G4int);
0427 void SetVerboseLevel (const G4String&);
0428 void SetVerboseLevel (Verbosity);
0429 void SetEventRefreshing (G4bool);
0430 void ResetTransientsDrawnFlags ();
0431 void SetTransientsDrawnThisRun (G4bool);
0432 void SetTransientsDrawnThisEvent (G4bool);
0433 void SetDrawEventOnlyIfToBeKept (G4bool);
0434
0435 void SetRequestedEvent (const G4Event*);
0436 void SetReviewingKeptEvents (G4bool);
0437 void SetAbortReviewKeptEvents (G4bool);
0438 void SetReviewingPlots (G4bool);
0439 void SetAbortReviewPlots (G4bool);
0440 void SetDefaultViewParameters (const G4ViewParameters&);
0441 #ifdef G4MULTITHREADED
0442 void SetMaxEventQueueSize (G4int);
0443 void SetWaitOnEventQueueFull (G4bool);
0444 #endif
0445 void SetDefaultGraphicsSystemName(const G4String&);
0446 void SetDefaultXGeometryString (const G4String&);
0447 void SetDefaultGraphicsSystemBasis(const G4String&);
0448 void SetDefaultXGeometryStringBasis(const G4String&);
0449
0450
0451
0452
0453 G4String ViewerShortName (const G4String& viewerName) const;
0454
0455
0456
0457 G4VViewer* GetViewer (const G4String& viewerName) const;
0458
0459
0460
0461 static Verbosity GetVerbosityValue(const G4String&);
0462
0463
0464 static Verbosity GetVerbosityValue(G4int);
0465
0466
0467
0468 static G4String VerbosityString(Verbosity);
0469
0470
0471 static std::vector<G4String> VerbosityGuidanceStrings;
0472
0473
0474 void PrintAvailableGraphicsSystems (Verbosity, std::ostream& = G4cout) const;
0475
0476 protected:
0477
0478 virtual void RegisterGraphicsSystems () = 0;
0479
0480
0481
0482 virtual void RegisterModelFactories();
0483
0484
0485 void RegisterMessengers ();
0486
0487 const G4int fVerbose;
0488
0489
0490
0491
0492
0493
0494 static Verbosity fVerbosity;
0495
0496 G4String fDefaultGraphicsSystemName;
0497 G4String fDefaultXGeometryString;
0498 G4String fDefaultGraphicsSystemBasis;
0499 G4String fDefaultXGeometryStringBasis;
0500
0501 private:
0502
0503
0504
0505 template <class T> void DrawT
0506 (const T& graphics_primitive, const G4Transform3D& objectTransform);
0507 template <class T> void DrawT2D
0508 (const T& graphics_primitive, const G4Transform3D& objectTransform);
0509
0510 void PrintAvailableModels (Verbosity) const;
0511 void InitialiseG4ColourMap () const;
0512 void PrintAvailableColours (Verbosity) const;
0513 void PrintAvailableUserVisActions (Verbosity) const;
0514 void PrintInvalidPointers () const;
0515 G4bool IsValidView ();
0516
0517 void ClearTransientStoreIfMarked();
0518
0519
0520
0521 static G4VisManager* fpInstance;
0522 G4bool fInitialised;
0523 std::vector<UserVisAction> fRunDurationUserVisActions;
0524 std::vector<UserVisAction> fEndOfEventUserVisActions;
0525 std::vector<UserVisAction> fEndOfRunUserVisActions;
0526 std::map<G4VUserVisAction*,G4VisExtent> fUserVisActionExtents;
0527 G4VGraphicsSystem* fpGraphicsSystem;
0528 G4Scene* fpScene;
0529 G4VSceneHandler* fpSceneHandler;
0530 G4VViewer* fpViewer;
0531 G4GraphicsSystemList fAvailableGraphicsSystems;
0532 G4SceneList fSceneList;
0533 G4SceneHandlerList fAvailableSceneHandlers;
0534 std::vector<G4UImessenger*> fMessengerList;
0535 std::vector<G4UIcommand*> fDirectoryList;
0536 G4VisStateDependent* fpStateDependent;
0537 G4bool fEventRefreshing;
0538 G4bool fTransientsDrawnThisRun;
0539 G4bool fTransientsDrawnThisEvent;
0540 G4int fNoOfEventsDrawnThisRun;
0541 G4int fNKeepRequests;
0542 G4bool fEventKeepingSuspended;
0543 G4bool fDrawEventOnlyIfToBeKept;
0544 const G4Event* fpRequestedEvent;
0545 G4bool fReviewingKeptEvents;
0546 G4bool fAbortReviewKeptEvents;
0547 G4bool fReviewingPlots;
0548 G4bool fAbortReviewPlots;
0549 G4ViewParameters fDefaultViewParameters;
0550 G4bool fIsDrawGroup;
0551 G4int fDrawGroupNestingDepth;
0552 G4bool fIgnoreStateChanges;
0553 #ifdef G4MULTITHREADED
0554 G4int fMaxEventQueueSize;
0555 G4bool fWaitOnEventQueueFull;
0556 #endif
0557
0558
0559 G4VisModelManager<G4VTrajectoryModel>* fpTrajDrawModelMgr;
0560
0561
0562 G4VisFilterManager<G4VTrajectory>* fpTrajFilterMgr;
0563
0564
0565 G4VisFilterManager<G4VHit>* fpHitFilterMgr;
0566
0567
0568 G4VisFilterManager<G4VDigi>* fpDigiFilterMgr;
0569 };
0570
0571 #include "G4VisManager.icc"
0572
0573 #endif