Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/visualization/management/src/G4VisCommands.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/management/src/G4VisCommands.cc (Version 11.3.0) and /visualization/management/src/G4VisCommands.cc (Version 10.4.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id$
 27                                                    28 
 28 // /vis/ top level commands - John Allison  5t     29 // /vis/ top level commands - John Allison  5th February 2001
 29                                                    30 
 30 #include "G4VisCommands.hh"                        31 #include "G4VisCommands.hh"
 31                                                    32 
 32 #include "G4VisManager.hh"                         33 #include "G4VisManager.hh"
 33 #include "G4UImanager.hh"                          34 #include "G4UImanager.hh"
 34 #include "G4UIcmdWithABool.hh"                     35 #include "G4UIcmdWithABool.hh"
 35 #include "G4UIcmdWithAString.hh"                   36 #include "G4UIcmdWithAString.hh"
 36 #include "G4UIcmdWithoutParameter.hh"              37 #include "G4UIcmdWithoutParameter.hh"
 37 #include "G4RunManager.hh"                         38 #include "G4RunManager.hh"
 38 #include "G4RunManagerFactory.hh"              <<  39 #ifdef G4MULTITHREADED
                                                   >>  40 #include "G4MTRunManager.hh"
                                                   >>  41 #endif
 39 #include "G4Run.hh"                                42 #include "G4Run.hh"
 40 #include "G4UIsession.hh"                          43 #include "G4UIsession.hh"
 41 #include "G4Trajectory.hh"                         44 #include "G4Trajectory.hh"
 42 #include "G4TrajectoryPoint.hh"                    45 #include "G4TrajectoryPoint.hh"
 43 #include "G4RichTrajectory.hh"                     46 #include "G4RichTrajectory.hh"
 44 #include "G4RichTrajectoryPoint.hh"                47 #include "G4RichTrajectoryPoint.hh"
 45 #include "G4SmoothTrajectory.hh"                   48 #include "G4SmoothTrajectory.hh"
 46 #include "G4SmoothTrajectoryPoint.hh"              49 #include "G4SmoothTrajectoryPoint.hh"
 47 #include "G4PhysicalVolumeModel.hh"                50 #include "G4PhysicalVolumeModel.hh"
 48 #include "G4AttDef.hh"                             51 #include "G4AttDef.hh"
 49                                                    52 
 50 #define G4warn G4cout                          << 
 51                                                << 
 52 ////////////// /vis/abortReviewKeptEvents ////     53 ////////////// /vis/abortReviewKeptEvents /////////////////////////////
 53                                                    54 
 54 G4VisCommandAbortReviewKeptEvents::G4VisComman     55 G4VisCommandAbortReviewKeptEvents::G4VisCommandAbortReviewKeptEvents () {
 55   G4bool omitable;                                 56   G4bool omitable;
 56                                                    57 
 57   fpCommand = new G4UIcmdWithABool("/vis/abort     58   fpCommand = new G4UIcmdWithABool("/vis/abortReviewKeptEvents", this);
 58   fpCommand -> SetGuidance("Abort review of ke     59   fpCommand -> SetGuidance("Abort review of kept events.");
 59   fpCommand -> SetParameterName("abort", omita     60   fpCommand -> SetParameterName("abort", omitable=true);
 60   fpCommand -> SetDefaultValue(true);              61   fpCommand -> SetDefaultValue(true);
 61 }                                                  62 }
 62                                                    63 
 63 G4VisCommandAbortReviewKeptEvents::~G4VisComma     64 G4VisCommandAbortReviewKeptEvents::~G4VisCommandAbortReviewKeptEvents () {
 64   delete fpCommand;                                65   delete fpCommand;
 65 }                                                  66 }
 66                                                    67 
 67 G4String G4VisCommandAbortReviewKeptEvents::Ge     68 G4String G4VisCommandAbortReviewKeptEvents::GetCurrentValue (G4UIcommand*) {
 68   return G4String();                               69   return G4String();
 69 }                                                  70 }
 70                                                    71 
 71 void G4VisCommandAbortReviewKeptEvents::SetNew     72 void G4VisCommandAbortReviewKeptEvents::SetNewValue (G4UIcommand*,
 72                                                    73                                                      G4String newValue) {
 73   fpVisManager->SetAbortReviewKeptEvents(G4UIc     74   fpVisManager->SetAbortReviewKeptEvents(G4UIcommand::ConvertToBool(newValue));
 74   G4warn << "Type \"continue\" to complete the <<  75   G4cout << "Type \"continue\" to complete the abort." << G4endl;
 75 }                                              << 
 76                                                << 
 77 ////////////// /vis/abortReviewPlots ///////// << 
 78                                                << 
 79 G4VisCommandAbortReviewPlots::G4VisCommandAbor << 
 80   G4bool omitable;                             << 
 81                                                << 
 82   fpCommand = new G4UIcmdWithABool("/vis/abort << 
 83   fpCommand -> SetGuidance("Abort review of pl << 
 84   fpCommand -> SetParameterName("abort", omita << 
 85   fpCommand -> SetDefaultValue(true);          << 
 86 }                                              << 
 87                                                << 
 88 G4VisCommandAbortReviewPlots::~G4VisCommandAbo << 
 89   delete fpCommand;                            << 
 90 }                                              << 
 91                                                << 
 92 G4String G4VisCommandAbortReviewPlots::GetCurr << 
 93   return G4String();                           << 
 94 }                                              << 
 95                                                << 
 96 void G4VisCommandAbortReviewPlots::SetNewValue << 
 97                                                << 
 98   fpVisManager->SetAbortReviewPlots(G4UIcomman << 
 99   G4warn << "Type \"continue\" to complete the << 
100 }                                                  76 }
101                                                    77 
102 ////////////// /vis/drawOnlyToBeKeptEvents ///     78 ////////////// /vis/drawOnlyToBeKeptEvents /////////////////////////////
103                                                    79 
104 G4VisCommandDrawOnlyToBeKeptEvents::G4VisComma     80 G4VisCommandDrawOnlyToBeKeptEvents::G4VisCommandDrawOnlyToBeKeptEvents ()
105 {                                                  81 {
106   G4bool omitable;                                 82   G4bool omitable;
107                                                    83 
108   fpCommand = new G4UIcmdWithABool("/vis/drawO     84   fpCommand = new G4UIcmdWithABool("/vis/drawOnlyToBeKeptEvents", this);
109   fpCommand -> SetGuidance                         85   fpCommand -> SetGuidance
110   ("DURING A RUN draw only those events that h     86   ("DURING A RUN draw only those events that have been \"to be kept\" by the user"
111    "\nwith G4EventManager::GetEventManager()->     87    "\nwith G4EventManager::GetEventManager()->KeepTheCurrentEvent() or"
112    "\nwith \"/event/keepCurrentEvent\".");         88    "\nwith \"/event/keepCurrentEvent\".");
113   fpCommand -> SetGuidance(                        89   fpCommand -> SetGuidance(
114   "To draw selected events the user should set     90   "To draw selected events the user should set this flag, then in a user action:"
115   "\n  if ( some criterion ) {"                    91   "\n  if ( some criterion ) {"
116   "\n    G4EventManager::GetEventManager()->Ke     92   "\n    G4EventManager::GetEventManager()->KeepTheCurrentEvent();"
117   "\n  }");                                        93   "\n  }");
118   fpCommand -> SetParameterName("draw", omitab     94   fpCommand -> SetParameterName("draw", omitable=true);
119   fpCommand -> SetDefaultValue(true);              95   fpCommand -> SetDefaultValue(true);
120 }                                                  96 }
121                                                    97 
122 G4VisCommandDrawOnlyToBeKeptEvents::~G4VisComm     98 G4VisCommandDrawOnlyToBeKeptEvents::~G4VisCommandDrawOnlyToBeKeptEvents () {
123   delete fpCommand;                                99   delete fpCommand;
124 }                                                 100 }
125                                                   101 
126 G4String G4VisCommandDrawOnlyToBeKeptEvents::G    102 G4String G4VisCommandDrawOnlyToBeKeptEvents::GetCurrentValue (G4UIcommand*) {
127   return G4String();                              103   return G4String();
128 }                                                 104 }
129                                                   105 
130 void G4VisCommandDrawOnlyToBeKeptEvents::SetNe    106 void G4VisCommandDrawOnlyToBeKeptEvents::SetNewValue (G4UIcommand*,
131                                                   107                                                   G4String newValue) {
132   fpVisManager->SetDrawEventOnlyIfToBeKept(G4U    108   fpVisManager->SetDrawEventOnlyIfToBeKept(G4UIcommand::ConvertToBool(newValue));
133   G4VisManager::Verbosity verbosity = fpVisMan    109   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
134   if (verbosity < G4VisManager::warnings) {       110   if (verbosity < G4VisManager::warnings) {
135     if (fpVisManager->GetDrawEventOnlyIfToBeKe    111     if (fpVisManager->GetDrawEventOnlyIfToBeKept()) {
136       G4warn << "Only events that have been ke << 112       G4cout << "Only events that have been kept will be drawn." << G4endl;
137     } else {                                      113     } else {
138       G4warn << "All events will be drawn." << << 114       G4cout << "All events will be drawn." << G4endl;
139     }                                             115     }
140   }                                               116   }
141 }                                                 117 }
142                                                   118 
143 ////////////// /vis/enable ///////////////////    119 ////////////// /vis/enable ///////////////////////////////////////
144                                                   120 
145 G4VisCommandEnable::G4VisCommandEnable () {       121 G4VisCommandEnable::G4VisCommandEnable () {
146   G4bool omitable;                                122   G4bool omitable;
147                                                   123 
148   fpCommand = new G4UIcmdWithABool("/vis/enabl    124   fpCommand = new G4UIcmdWithABool("/vis/enable", this);
149   fpCommand -> SetGuidance("Enables/disables v    125   fpCommand -> SetGuidance("Enables/disables visualization system.");
150   fpCommand -> SetParameterName("enabled", omi    126   fpCommand -> SetParameterName("enabled", omitable=true);
151   fpCommand -> SetDefaultValue(true);             127   fpCommand -> SetDefaultValue(true);
152                                                   128 
153   fpCommand1 = new G4UIcmdWithoutParameter("/v    129   fpCommand1 = new G4UIcmdWithoutParameter("/vis/disable", this);
154   fpCommand1 -> SetGuidance("Disables visualiz    130   fpCommand1 -> SetGuidance("Disables visualization system.");
155 }                                                 131 }
156                                                   132 
157 G4VisCommandEnable::~G4VisCommandEnable () {      133 G4VisCommandEnable::~G4VisCommandEnable () {
158   delete fpCommand;                               134   delete fpCommand;
159   delete fpCommand1;                              135   delete fpCommand1;
160 }                                                 136 }
161                                                   137 
162 G4String G4VisCommandEnable::GetCurrentValue (    138 G4String G4VisCommandEnable::GetCurrentValue (G4UIcommand*) {
163   return G4String();                              139   return G4String();
164 }                                                 140 }
165                                                   141 
166 void G4VisCommandEnable::SetNewValue (G4UIcomm    142 void G4VisCommandEnable::SetNewValue (G4UIcommand* command,
167               G4String newValue) {                143               G4String newValue) {
168   if (command == fpCommand) {                     144   if (command == fpCommand) {
169     G4bool enable = G4UIcommand::ConvertToBool    145     G4bool enable = G4UIcommand::ConvertToBool(newValue);
170     if (enable) fpVisManager->Enable();  // Pr    146     if (enable) fpVisManager->Enable();  // Printing is in vis manager.
171     else fpVisManager->Disable();        // Pr    147     else fpVisManager->Disable();        // Printing is in vis manager.
172   } else fpVisManager->Disable();        // Pr    148   } else fpVisManager->Disable();        // Printing is in vis manager.
173   // Note: Printing is in vis manager.            149   // Note: Printing is in vis manager.
174 }                                                 150 }
175                                                   151 
176 ////////////// /vis/initialize ///////////////    152 ////////////// /vis/initialize ///////////////////////////////////////
177                                                   153 
178 G4VisCommandInitialize::G4VisCommandInitialize    154 G4VisCommandInitialize::G4VisCommandInitialize ()
179 {                                                 155 {
180   fpCommand = new G4UIcmdWithoutParameter("/vi    156   fpCommand = new G4UIcmdWithoutParameter("/vis/initialize", this);
181   fpCommand -> SetGuidance("Initialise visuali    157   fpCommand -> SetGuidance("Initialise visualisation manager.");
182 }                                                 158 }
183                                                   159 
184 G4VisCommandInitialize::~G4VisCommandInitializ    160 G4VisCommandInitialize::~G4VisCommandInitialize () {
185   delete fpCommand;                               161   delete fpCommand;
186 }                                                 162 }
187                                                   163 
188 void G4VisCommandInitialize::SetNewValue (G4UI    164 void G4VisCommandInitialize::SetNewValue (G4UIcommand*,
189             G4String) {                           165             G4String) {
190   fpVisManager->Initialize();                     166   fpVisManager->Initialize();
191 }                                                 167 }
192                                                   168 
193 ////////////// /vis/list /////////////////////    169 ////////////// /vis/list ///////////////////////////////////////
194                                                   170 
195 G4VisCommandList::G4VisCommandList ()             171 G4VisCommandList::G4VisCommandList ()
196 {                                                 172 {
197   G4bool omitable;                                173   G4bool omitable;
198                                                   174 
199   fpCommand = new G4UIcmdWithAString("/vis/lis    175   fpCommand = new G4UIcmdWithAString("/vis/list", this);
200   fpCommand -> SetGuidance("Lists visualizatio    176   fpCommand -> SetGuidance("Lists visualization parameters.");
201   fpCommand -> SetParameterName("verbosity", o    177   fpCommand -> SetParameterName("verbosity", omitable=true);
202   fpCommand -> SetDefaultValue("warnings");       178   fpCommand -> SetDefaultValue("warnings");
203 }                                                 179 }
204                                                   180 
205 G4VisCommandList::~G4VisCommandList ()            181 G4VisCommandList::~G4VisCommandList ()
206 {                                                 182 {
207   delete fpCommand;                               183   delete fpCommand;
208 }                                                 184 }
209                                                   185 
210 G4String G4VisCommandList::GetCurrentValue (G4    186 G4String G4VisCommandList::GetCurrentValue (G4UIcommand*)
211 {                                                 187 {
212   return "";                                      188   return "";
213 }                                                 189 }
214                                                   190 
215 void G4VisCommandList::SetNewValue (G4UIcomman    191 void G4VisCommandList::SetNewValue (G4UIcommand*, G4String newValue)
216 {                                                 192 {
217   G4VisManager::Verbosity verbosity = fpVisMan << 193   G4String& verbosityString = newValue;
                                                   >> 194   G4VisManager::Verbosity verbosity =
                                                   >> 195     fpVisManager->GetVerbosityValue(verbosityString);
218                                                   196 
219   G4VisManager::PrintAvailableVerbosity(G4cout << 
220   G4cout << G4endl;                            << 
221   fpVisManager->PrintAvailableGraphicsSystems(    197   fpVisManager->PrintAvailableGraphicsSystems(verbosity);
222   G4cout << G4endl;                               198   G4cout << G4endl;
223   fpVisManager->PrintAvailableModels(verbosity    199   fpVisManager->PrintAvailableModels(verbosity);
224   G4cout << G4endl;                               200   G4cout << G4endl;
225   fpVisManager->PrintAvailableUserVisActions(v    201   fpVisManager->PrintAvailableUserVisActions(verbosity);
226   G4cout << G4endl;                               202   G4cout << G4endl;
227   fpVisManager->PrintAvailableColours(verbosit    203   fpVisManager->PrintAvailableColours(verbosity);
228   G4cout << G4endl;                               204   G4cout << G4endl;
229   G4UImanager* UImanager = G4UImanager::GetUIp    205   G4UImanager* UImanager = G4UImanager::GetUIpointer();
230   UImanager->ApplyCommand("/vis/scene/list ! "    206   UImanager->ApplyCommand("/vis/scene/list ! " + newValue);
231   G4cout << G4endl;                            << 
232   UImanager->ApplyCommand("/vis/viewer/list !     207   UImanager->ApplyCommand("/vis/viewer/list ! " + newValue);
233                                                   208 
234   G4cout <<                                       209   G4cout <<
235   "\nAttributes available for modeling and fil    210   "\nAttributes available for modeling and filtering with"
236   "\n  \"/vis/modeling/trajectories/create/dra    211   "\n  \"/vis/modeling/trajectories/create/drawByAttribute\" and"
237   "\n  \"/vis/filtering/trajectories/create/at    212   "\n  \"/vis/filtering/trajectories/create/attributeFilter\" commands"
238   "\nand by picking:"                             213   "\nand by picking:"
239   << G4endl;                                      214   << G4endl;
240   G4cout                                          215   G4cout
241   << *G4TrajectoriesModel().GetAttDefs();         216   << *G4TrajectoriesModel().GetAttDefs();
242   G4cout                                          217   G4cout
243   << *G4RichTrajectory().GetAttDefs()             218   << *G4RichTrajectory().GetAttDefs()
244   << *G4RichTrajectoryPoint().GetAttDefs();       219   << *G4RichTrajectoryPoint().GetAttDefs();
245   G4cout                                          220   G4cout
246   << *G4SmoothTrajectory().GetAttDefs()           221   << *G4SmoothTrajectory().GetAttDefs()
247   << *G4SmoothTrajectoryPoint().GetAttDefs();     222   << *G4SmoothTrajectoryPoint().GetAttDefs();
248   G4cout                                          223   G4cout
249   << *G4Trajectory().GetAttDefs()                 224   << *G4Trajectory().GetAttDefs()
250   << *G4TrajectoryPoint().GetAttDefs();           225   << *G4TrajectoryPoint().GetAttDefs();
251                                                   226 
252   G4cout <<                                       227   G4cout <<
253   "\nGeometry attributes available for touchab    228   "\nGeometry attributes available for touchables by picking:\n";
254   G4cout                                          229   G4cout
255   << *G4PhysicalVolumeModel().GetAttDefs();       230   << *G4PhysicalVolumeModel().GetAttDefs();
256                                                   231 
257   if (verbosity < G4VisManager::parameters)       232   if (verbosity < G4VisManager::parameters)
258     G4cout <<                                     233     G4cout <<
259   "\nTo get more information, \"/vis/list all\    234   "\nTo get more information, \"/vis/list all\" or use individual commands"
260   "\n  such as (use \"ls\" or \"help\"):"         235   "\n  such as (use \"ls\" or \"help\"):"
261   "\n    /vis/scene/list all all"                 236   "\n    /vis/scene/list all all"
262   "\n    /vis/viewer/list all all"                237   "\n    /vis/viewer/list all all"
263   "\n    /vis/modeling/trajectories/list"         238   "\n    /vis/modeling/trajectories/list"
264   "\n    /vis/filtering/trajectories/list"        239   "\n    /vis/filtering/trajectories/list"
265      << G4endl;                                   240      << G4endl;
266 }                                                 241 }
267                                                   242 
268 ////////////// /vis/reviewKeptEvents /////////    243 ////////////// /vis/reviewKeptEvents ///////////////////////////////////////
269                                                   244 
270 G4VisCommandReviewKeptEvents::G4VisCommandRevi    245 G4VisCommandReviewKeptEvents::G4VisCommandReviewKeptEvents ()
271 {                                                 246 {
272   G4bool omitable;                                247   G4bool omitable;
273                                                   248 
274   fpCommand = new G4UIcmdWithAString("/vis/rev    249   fpCommand = new G4UIcmdWithAString("/vis/reviewKeptEvents", this);
275   fpCommand -> SetGuidance("Review kept events    250   fpCommand -> SetGuidance("Review kept events.");
276   fpCommand -> SetGuidance                        251   fpCommand -> SetGuidance
277     ("If a macro file is specified, it is exec    252     ("If a macro file is specified, it is executed for each event.");
278   fpCommand -> SetGuidance(                       253   fpCommand -> SetGuidance(
279   "If a macro file is not specified, each even    254   "If a macro file is not specified, each event is drawn to the current"
280   "\nviewer.  After each event, the session is    255   "\nviewer.  After each event, the session is paused.  The user may issue"
281   "\nany allowed command.  Then enter \"cont[i    256   "\nany allowed command.  Then enter \"cont[inue]\" to continue to the next"
282   "\nevent."                                      257   "\nevent."
283   "\nUseful commands might be:"                   258   "\nUseful commands might be:"
284   "\n  \"/vis/viewer/...\" to change the view     259   "\n  \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
285   "\n  \"/vis/ogl/export\" to get hard copy."  << 260   "\n  \"/vis/oglx/printEPS\" to get hard copy."
286   "\n  \"/vis/open\" to get alternative viewer    261   "\n  \"/vis/open\" to get alternative viewer."
287   "\n  \"/vis/abortReviewKeptEvents\", then \"    262   "\n  \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort.");
288   fpCommand -> SetParameterName("macro-file-na    263   fpCommand -> SetParameterName("macro-file-name", omitable=true);
289   fpCommand -> SetDefaultValue("");               264   fpCommand -> SetDefaultValue("");
290 }                                                 265 }
291                                                   266 
292 G4VisCommandReviewKeptEvents::~G4VisCommandRev    267 G4VisCommandReviewKeptEvents::~G4VisCommandReviewKeptEvents ()
293 {                                                 268 {
294   delete fpCommand;                               269   delete fpCommand;
295 }                                                 270 }
296                                                   271 
297 G4String G4VisCommandReviewKeptEvents::GetCurr    272 G4String G4VisCommandReviewKeptEvents::GetCurrentValue (G4UIcommand*)
298 {                                                 273 {
299   return "";                                      274   return "";
300 }                                                 275 }
301                                                   276 
302 void G4VisCommandReviewKeptEvents::SetNewValue    277 void G4VisCommandReviewKeptEvents::SetNewValue (G4UIcommand*, G4String newValue)
303 {                                                 278 {
304   if (fpVisManager->GetReviewingKeptEvents())  << 279   static bool reviewing = false;
305     G4warn <<                                  << 280   if (reviewing) {
                                                   >> 281     G4cout <<
306       "\"/vis/reviewKeptEvents\" not allowed w    282       "\"/vis/reviewKeptEvents\" not allowed within an already started review."
307       "\n  No action taken."                      283       "\n  No action taken."
308      << G4endl;                                   284      << G4endl;
309     return;                                       285     return;
310   }                                               286   }
311                                                   287 
312   G4String& macroFileName = newValue;             288   G4String& macroFileName = newValue;
313   G4VisManager::Verbosity verbosity = fpVisMan    289   G4VisManager::Verbosity verbosity = fpVisManager->GetVerbosity();
314                                                   290 
315   G4RunManager* runManager = G4RunManagerFacto << 291   G4RunManager* runManager = G4RunManager::GetRunManager();
316   const G4Run* run         = runManager ? runM << 292 #ifdef G4MULTITHREADED
317   const std::vector<const G4Event*>* events =  << 293   if(G4Threading::IsMultithreadedApplication())
318     run ? run->GetEventVector() : nullptr;     << 294   { runManager = G4MTRunManager::GetMasterRunManager(); }
319   size_t nKeptEvents = events ? events->size() << 295 #endif
                                                   >> 296   const G4Run* run = runManager? runManager->GetCurrentRun(): 0;
                                                   >> 297   const std::vector<const G4Event*>* events = run? run->GetEventVector(): 0;
                                                   >> 298   size_t nKeptEvents = events? events->size(): 0;
320                                                   299 
321   if (!nKeptEvents) {                             300   if (!nKeptEvents) {
322     if (verbosity >= G4VisManager::errors) {      301     if (verbosity >= G4VisManager::errors) {
323       G4warn <<                                << 302       G4cerr <<
324   "ERROR: G4VisCommandReviewKeptEvents::SetNew    303   "ERROR: G4VisCommandReviewKeptEvents::SetNewValue: No kept events,"
325   "\n  or kept events not accessible."            304   "\n  or kept events not accessible."
326        << G4endl;                                 305        << G4endl;
327     }                                             306     }
328     return;                                       307     return;
329   }                                               308   }
330                                                   309 
331   G4VViewer* viewer = fpVisManager->GetCurrent    310   G4VViewer* viewer = fpVisManager->GetCurrentViewer();
332   if (!viewer) {                                  311   if (!viewer) {
333     if (verbosity >= G4VisManager::errors) {      312     if (verbosity >= G4VisManager::errors) {
334       G4warn <<                                << 313       G4cerr <<
335   "ERROR: No current viewer - \"/vis/viewer/li    314   "ERROR: No current viewer - \"/vis/viewer/list\" to see possibilities."
336              << G4endl;                           315              << G4endl;
337     }                                             316     }
338     return;                                       317     return;
339   }                                               318   }
340                                                   319 
341   G4Scene* pScene = fpVisManager->GetCurrentSc    320   G4Scene* pScene = fpVisManager->GetCurrentScene();
342   if (!pScene) {                                  321   if (!pScene) {
343     if (verbosity >= G4VisManager::errors) {      322     if (verbosity >= G4VisManager::errors) {
344       G4warn << "ERROR: No current scene.  Ple << 323       G4cerr << "ERROR: No current scene.  Please create one." << G4endl;
345     }                                             324     }
346     return;                                       325     return;
347   }                                               326   }
348                                                   327 
349   G4UImanager* UImanager = G4UImanager::GetUIp    328   G4UImanager* UImanager = G4UImanager::GetUIpointer();
350   G4int keepControlVerbose = UImanager->GetVer << 329   G4int keepVerbose = UImanager->GetVerboseLevel();
351   G4int newVerbose(0);                            330   G4int newVerbose(0);
352   if (keepControlVerbose >= 2 || verbosity >=  << 331   if (keepVerbose >= 2 || verbosity >= G4VisManager::confirmations)
353     newVerbose = 2;                               332     newVerbose = 2;
354   UImanager->SetVerboseLevel(newVerbose);         333   UImanager->SetVerboseLevel(newVerbose);
355                                                   334   
356   G4VVisManager* keepConcreteInstance = fpVisM    335   G4VVisManager* keepConcreteInstance = fpVisManager->GetConcreteInstance();
357   fpVisManager->Enable();                         336   fpVisManager->Enable();
358                                                << 337   
359   // Start on clean view                       << 
360   UImanager->ApplyCommand("/vis/viewer/rebuild << 
361                                                << 
362   // Event by event refreshing...                 338   // Event by event refreshing...
363   fpVisManager->SetReviewingKeptEvents(true);  << 339   reviewing  = true;
364   G4bool currentRefreshAtEndOfEvent = pScene->    340   G4bool currentRefreshAtEndOfEvent = pScene->GetRefreshAtEndOfEvent();
365   pScene->SetRefreshAtEndOfEvent(true);           341   pScene->SetRefreshAtEndOfEvent(true);
366   if (macroFileName.empty()) {                    342   if (macroFileName.empty()) {
367                                                   343 
368     // Draw to viewer and pause session...        344     // Draw to viewer and pause session...
369     G4UIsession* session = UImanager->GetSessi    345     G4UIsession* session = UImanager->GetSession();
370     for (size_t i = 0; i < nKeptEvents; ++i) {    346     for (size_t i = 0; i < nKeptEvents; ++i) {
371       const G4Event* event = (*events)[i];        347       const G4Event* event = (*events)[i];
372       if (verbosity >= G4VisManager::warnings)    348       if (verbosity >= G4VisManager::warnings) {
373   G4warn << "Drawing event : " << event->GetEv << 349   G4cout << "Drawing event : " << event->GetEventID() <<
374     ".  At EndOfEvent, enter any command, then    350     ".  At EndOfEvent, enter any command, then \"cont[inue]\"..."
375          << G4endl;                               351          << G4endl;
376   static G4bool first = true;                     352   static G4bool first = true;
377   if (first) {                                    353   if (first) {
378     first = false;                                354     first = false;
379     G4warn <<                                  << 355     G4cout <<
380   "  Useful commands might be:"                   356   "  Useful commands might be:"
381   "\n    \"/vis/scene/add/trajectories\" if no    357   "\n    \"/vis/scene/add/trajectories\" if not already added."
382   "\n    \"/vis/viewer/...\" to change the vie    358   "\n    \"/vis/viewer/...\" to change the view (zoom, set/viewpoint,...)."
383   "\n    \"/vis/ogl/export\" to get hard copy. << 359   "\n    \"/vis/oglx/printEPS\" to get hard copy."
384   "\n    \"/vis/open\" to get alternative view    360   "\n    \"/vis/open\" to get alternative viewer."
385   "\n    \"/vis/abortReviewKeptEvents\", then     361   "\n    \"/vis/abortReviewKeptEvents\", then \"cont[inue]\", to abort."
386      << G4endl;                                   362      << G4endl;
387   }                                               363   }
388       }                                           364       }
389       fpVisManager->SetRequestedEvent(event);     365       fpVisManager->SetRequestedEvent(event);
390       UImanager->ApplyCommand("/vis/viewer/reb    366       UImanager->ApplyCommand("/vis/viewer/rebuild");
391       /* The above command forces a rebuild of    367       /* The above command forces a rebuild of the scene, including
392    the detector.  This is fine for "immediate"    368    the detector.  This is fine for "immediate" viewers - a
393    refresh requires a rebuild anyway.  But for    369    refresh requires a rebuild anyway.  But for "stored mode"
394    viewers, you could, in principle, avoid a r    370    viewers, you could, in principle, avoid a rebuild of the
395    detector with something like the following:    371    detector with something like the following:
396       sceneHandler->ClearTransientStore();        372       sceneHandler->ClearTransientStore();
397       viewer->DrawView();                         373       viewer->DrawView();
398       sceneHandler->DrawEvent(event);             374       sceneHandler->DrawEvent(event);
399          but this causes mayhem for "immediate    375          but this causes mayhem for "immediate" viewers because
400          ClearTransientStore issues a DrawView    376          ClearTransientStore issues a DrawView and some curious sort
401          of recursion takes place.  For "store    377          of recursion takes place.  For "stored" viewers, the event
402          gets drawn but not the eventID, so so    378          gets drawn but not the eventID, so something odd is happening
403          there too.  This needs further invest    379          there too.  This needs further investigation - enhanced
404          features or a complete re-think.         380          features or a complete re-think.
405       */                                          381       */
406       UImanager->ApplyCommand("/vis/viewer/flu    382       UImanager->ApplyCommand("/vis/viewer/flush");
407       session->PauseSessionStart("EndOfEvent")    383       session->PauseSessionStart("EndOfEvent");
408       fpVisManager->SetRequestedEvent(0);         384       fpVisManager->SetRequestedEvent(0);
409       if (fpVisManager->GetAbortReviewKeptEven    385       if (fpVisManager->GetAbortReviewKeptEvents()) break;
410     }                                             386     }
411     fpVisManager->SetAbortReviewKeptEvents(fal    387     fpVisManager->SetAbortReviewKeptEvents(false);
412                                                   388 
413   } else {                                        389   } else {
414                                                   390 
415     // Execute macro file...                      391     // Execute macro file...
416     for (size_t i = 0; i < nKeptEvents; ++i) {    392     for (size_t i = 0; i < nKeptEvents; ++i) {
417       const G4Event* event = (*events)[i];        393       const G4Event* event = (*events)[i];
418       if (verbosity >= G4VisManager::warnings)    394       if (verbosity >= G4VisManager::warnings) {
419   G4warn << "Drawing event : " << event->GetEv << 395   G4cout << "Drawing event : " << event->GetEventID()
420          << " with macro file \"" << macroFile    396          << " with macro file \"" << macroFileName << G4endl;
421       }                                           397       }
422       fpVisManager->SetRequestedEvent(event);     398       fpVisManager->SetRequestedEvent(event);
423       UImanager->ApplyCommand("/control/execut    399       UImanager->ApplyCommand("/control/execute " + macroFileName);
424       fpVisManager->SetRequestedEvent(0);         400       fpVisManager->SetRequestedEvent(0);
425     }                                             401     }
426   }                                               402   }
427   pScene->SetRefreshAtEndOfEvent(currentRefres    403   pScene->SetRefreshAtEndOfEvent(currentRefreshAtEndOfEvent);
428   fpVisManager->SetReviewingKeptEvents(false); << 404   reviewing  = false;
429                                                   405 
430   if (keepConcreteInstance) fpVisManager->Enab    406   if (keepConcreteInstance) fpVisManager->Enable();
431   else fpVisManager->Disable();                   407   else fpVisManager->Disable();
432   UImanager->SetVerboseLevel(keepControlVerbos << 408   UImanager->SetVerboseLevel(keepVerbose);
433 }                                              << 
434                                                << 
435 ////////////// /vis/reviewPlots ////////////// << 
436                                                << 
437 G4VisCommandReviewPlots::G4VisCommandReviewPlo << 
438 {                                              << 
439   fpCommand = new G4UIcmdWithoutParameter("/vi << 
440   fpCommand -> SetGuidance("Review plots.");   << 
441   fpCommand -> SetGuidance                     << 
442   ("Each plot is drawn, one by one, to the cur << 
443    "\nplot the session is paused.  The user ma << 
444    "\nThen enter \"cont[inue]\" to continue to << 
445    "\nUseful commands might be:"               << 
446    "\n  \"/vis/tsg/export\" to get hard copy." << 
447    "\n  \"/vis/abortReviewPlots\", then \"cont << 
448 }                                              << 
449                                                << 
450 G4VisCommandReviewPlots::~G4VisCommandReviewPl << 
451 {                                              << 
452   delete fpCommand;                            << 
453 }                                              << 
454                                                << 
455 G4String G4VisCommandReviewPlots::GetCurrentVa << 
456 {                                              << 
457   return "";                                   << 
458 }                                              << 
459                                                << 
460 #include <tools/histo/h1d>                     << 
461 #include <tools/histo/h2d>                     << 
462                                                << 
463 namespace {                                    << 
464   template <typename HT>  // tools::histo::h1d << 
465   G4bool ReviewPlots(const G4String& plotType) << 
466     auto visManager = G4VisManager::GetInstanc << 
467     auto ui = G4UImanager::GetUIpointer();     << 
468     auto session = ui->GetSession();           << 
469     G4bool aborting = false;                   << 
470     auto keepControlVerbose = ui->GetVerboseLe << 
471     ui->SetVerboseLevel(0);                    << 
472     auto status = ui->ApplyCommand("/analysis/ << 
473     ui->SetVerboseLevel(keepControlVerbose);   << 
474     if(status==G4UIcommandStatus::fCommandSucc << 
475       G4String hexString = ui->GetCurrentValue << 
476       if(hexString.size()) {                   << 
477         void* ptr;                             << 
478         std::istringstream is(hexString);      << 
479         is >> ptr;                             << 
480         auto _v = (const std::vector<HT*>*)ptr << 
481         auto _n = _v->size();                  << 
482         for (size_t i = 0; i < _n; ++i) {      << 
483           //  Draw then pause session...       << 
484           std::ostringstream oss;              << 
485           oss << "/vis/plot " << plotType << ' << 
486           ui->ApplyCommand(oss.str());         << 
487           session->PauseSessionStart("EndOfEve << 
488           if (visManager->GetAbortReviewPlots( << 
489             aborting = true;                   << 
490             break;                             << 
491           }                                    << 
492         }                                      << 
493       }                                        << 
494     }                                          << 
495     return aborting;                           << 
496   }                                            << 
497 }                                              << 
498                                                << 
499 void G4VisCommandReviewPlots::SetNewValue (G4U << 
500 {                                              << 
501   if (fpVisManager->GetReviewingPlots()) {     << 
502     G4warn <<                                  << 
503     "\"/vis/reviewPlots\" not allowed within a << 
504     "\n  No action taken."                     << 
505     << G4endl;                                 << 
506     return;                                    << 
507   }                                            << 
508                                                << 
509   auto verbosity = fpVisManager->GetVerbosity( << 
510                                                << 
511   auto currentViewer = fpVisManager->GetCurren << 
512   if (!currentViewer) {                        << 
513     if (verbosity >= G4VisManager::errors) {   << 
514       G4warn <<                                << 
515       "ERROR: No current viewer - \"/vis/viewe << 
516       << G4endl;                               << 
517     }                                          << 
518     return;                                    << 
519   }                                            << 
520                                                << 
521   if (currentViewer->GetName().find("TOOLSSG") << 
522     G4warn <<                                  << 
523     "WARNING: Current viewer not able to draw  << 
524     "\n  Try \"/vis/open TSG\", then \"/vis/re << 
525     << G4endl;                                 << 
526     return;                                    << 
527   }                                            << 
528                                                << 
529   G4Scene* pScene = fpVisManager->GetCurrentSc << 
530   if (!pScene) {                               << 
531     if (verbosity >= G4VisManager::errors) {   << 
532       G4warn << "ERROR: No current scene.  Ple << 
533     }                                          << 
534     return;                                    << 
535   }                                            << 
536                                                << 
537   auto ui = G4UImanager::GetUIpointer();       << 
538                                                << 
539   auto keepControlVerbose = ui->GetVerboseLeve << 
540   ui->SetVerboseLevel(0);                      << 
541   auto keepVisVerbose = fpVisManager->GetVerbo << 
542   fpVisManager->SetVerboseLevel(G4VisManager:: << 
543   auto keepEnable = fpVisManager->IsEnabled(); << 
544   fpVisManager->Enable();                      << 
545   fpVisManager->SetReviewingPlots(true);       << 
546                                                << 
547   if (ReviewPlots<tools::histo::h1d>("h1")) go << 
548   if (ReviewPlots<tools::histo::h2d>("h2")) go << 
549                                                << 
550 finish:                                        << 
551   fpVisManager->SetReviewingPlots(false);      << 
552   if (!keepEnable) fpVisManager->Disable();    << 
553   fpVisManager->SetVerboseLevel(keepVisVerbose << 
554   ui->SetVerboseLevel(keepControlVerbose);     << 
555 }                                                 409 }
556                                                   410 
557 ////////////// /vis/verbose //////////////////    411 ////////////// /vis/verbose ///////////////////////////////////////
558                                                   412 
559 G4VisCommandVerbose::G4VisCommandVerbose () {     413 G4VisCommandVerbose::G4VisCommandVerbose () {
560   G4bool omitable;                                414   G4bool omitable;
561                                                   415 
562   fpCommand = new G4UIcmdWithAString("/vis/ver    416   fpCommand = new G4UIcmdWithAString("/vis/verbose", this);
563   for (size_t i = 0; i < G4VisManager::Verbosi    417   for (size_t i = 0; i < G4VisManager::VerbosityGuidanceStrings.size(); ++i) {
564     fpCommand -> SetGuidance(G4VisManager::Ver    418     fpCommand -> SetGuidance(G4VisManager::VerbosityGuidanceStrings[i]);
565   }                                               419   }
566   fpCommand -> SetParameterName("verbosity", o    420   fpCommand -> SetParameterName("verbosity", omitable=true);
567   fpCommand -> SetDefaultValue("");            << 421   fpCommand -> SetDefaultValue("warnings");
568 }                                                 422 }
569                                                   423 
570 G4VisCommandVerbose::~G4VisCommandVerbose () {    424 G4VisCommandVerbose::~G4VisCommandVerbose () {
571   delete fpCommand;                               425   delete fpCommand;
572 }                                                 426 }
573                                                   427 
574 G4String G4VisCommandVerbose::GetCurrentValue     428 G4String G4VisCommandVerbose::GetCurrentValue (G4UIcommand*) {
575   return G4String();                              429   return G4String();
576 }                                                 430 }
577                                                   431 
578 void G4VisCommandVerbose::SetNewValue (G4UIcom    432 void G4VisCommandVerbose::SetNewValue (G4UIcommand*,
579                G4String newValue) {               433                G4String newValue) {
580   G4VisManager::Verbosity verbosity =             434   G4VisManager::Verbosity verbosity =
581     fpVisManager->GetVerbosityValue(newValue);    435     fpVisManager->GetVerbosityValue(newValue);
582   fpVisManager->SetVerboseLevel(verbosity);       436   fpVisManager->SetVerboseLevel(verbosity);
583   // Always prints whatever the verbosity...      437   // Always prints whatever the verbosity...
584   G4cout << "Visualization verbosity is now "  << 438   G4cout << "Visualization verbosity changed to "
585    << G4VisManager::VerbosityString(verbosity)    439    << G4VisManager::VerbosityString(verbosity) << G4endl;
586 }                                                 440 }
587                                                   441