ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyG4UImanager.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyG4UImanager.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // ====================================================================
27 // pyG4UImanager.cc
28 //
29 // G4UImanager class is pure singleton, so it cannnot be exposed
30 // from BPL. Functionality of G4UImanager is exposed in global
31 // name space via wrappers.
32 // 2006 Q
33 // ====================================================================
34 #include <boost/python.hpp>
35 #include "G4UImanager.hh"
36 #include "G4UIcommandTree.hh"
37 
38 using namespace boost::python;
39 
40 // ====================================================================
41 // wrappers
42 // ====================================================================
43 namespace pyG4UImanager {
44 
45 // ApplyCommand
49 
50 // CreateHTML
51 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateHTML, CreateHTML, 0, 1)
52 
53 
54 
57 {
59  G4int returnVal= UImgr-> ApplyCommand(cmdstr);
60  if( returnVal == fCommandSucceeded ) return returnVal;
61 
62  G4int paramIndex= returnVal % 100;
63  G4int commandStatus= returnVal - paramIndex;
64 
65  switch(commandStatus) {
66  case fCommandSucceeded:
67  break;
68 
69  case fCommandNotFound:
70  G4cout << "command <" << UImgr-> SolveAlias(cmdstr)
71  << "> not found" << G4endl;
72  break;
73 
75  G4cout << "illegal application state -- command refused"
76  << G4endl;
77  break;
78 
80  break;
81 
83  G4cout << "Parameter is out of candidate list (index "
84  << paramIndex << ")"
85  << G4endl;
86  break;
87 
89  G4cout << "Parameter is wrong type and/or is not omittable (index "
90  << paramIndex << ")" << G4endl;
91  break;
92 
93  case fAliasNotFound:
94  break;
95 
96  default:
97  G4cout << "command refused (" << commandStatus << ")" << G4endl;
98  break;
99  }
100 
101  return returnVal;
102 }
103 
105 G4int ApplyUICommand_2(const std::string& cmdstr)
107 {
108  return ApplyUICommand_1(cmdstr);
109 }
110 
111 }
112 
113 using namespace pyG4UImanager;
114 
115 // ====================================================================
116 // module definition
117 // ====================================================================
119 {
120  class_<G4UImanager, boost::noncopyable>
121  ("G4UImanager", "UI manager class", no_init)
122  .def("GetUIpointer", &G4UImanager::GetUIpointer,
123  return_value_policy<reference_existing_object>())
124  .staticmethod("GetUIpointer")
125  // ---
126  .def("GetCurrentValues", &G4UImanager::GetCurrentValues)
127  .def("ExecuteMacroFile", &G4UImanager::ExecuteMacroFile)
128  .def("ApplyCommand", f1_ApplyCommand)
129  .def("ApplyCommand", f2_ApplyCommand)
130  .def("CreateHTML", &G4UImanager::CreateHTML, f_CreateHTML())
131  .def("SetMacroSearchPath", &G4UImanager::SetMacroSearchPath)
132  .def("GetMacroSearchPath", &G4UImanager::GetMacroSearchPath,
133  return_value_policy<return_by_value>())
134  // ---
135  .def("SetPauseAtBeginOfEvent", &G4UImanager::SetPauseAtBeginOfEvent)
136  .def("GetPauseAtBeginOfEvent", &G4UImanager::GetPauseAtBeginOfEvent)
137  .def("SetPauseAtEndOfEvent", &G4UImanager::SetPauseAtEndOfEvent)
138  .def("GetPauseAtEndOfEvent", &G4UImanager::GetPauseAtEndOfEvent)
139  .def("SetVerboseLevel", &G4UImanager::SetVerboseLevel)
140  .def("GetVerboseLevel", &G4UImanager::GetVerboseLevel)
141  // ---
142  .def("GetTree", &G4UImanager::GetTree,
143  return_value_policy<reference_existing_object>())
144  ;
145 
146  // ---
147  def("ApplyUICommand", ApplyUICommand_1);
148  def("ApplyUICommand", ApplyUICommand_2);
149 
150 }