Geant4  10.01.p03
pyG4UImanager.cc
Go to the documentation of this file.
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 // $Id: pyG4UImanager.cc 76884 2013-11-18 12:54:03Z gcosmo $
27 // ====================================================================
28 // pyG4UImanager.cc
29 //
30 // G4UImanager class is pure singleton, so it cannnot be exposed
31 // from BPL. Functionality of G4UImanager is exposed in global
32 // name space via wrappers.
33 // 2006 Q
34 // ====================================================================
35 #include <boost/python.hpp>
36 #include "G4UImanager.hh"
37 #include "G4UIcommandTree.hh"
38 
39 using namespace boost::python;
40 
41 // ====================================================================
42 // wrappers
43 // ====================================================================
44 namespace pyG4UImanager {
45 
46 // ApplyCommand
50 
51 // CreateHTML
52 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateHTML, CreateHTML, 0, 1)
53 
54 
55 G4int ApplyUICommand_1(const G4String& cmdstr)
58 {
60  G4int returnVal= UImgr-> ApplyCommand(cmdstr);
61  if( returnVal == fCommandSucceeded ) return returnVal;
62 
63  G4int paramIndex= returnVal % 100;
64  G4int commandStatus= returnVal - paramIndex;
65 
66  switch(commandStatus) {
67  case fCommandSucceeded:
68  break;
69 
70  case fCommandNotFound:
71  G4cout << "command <" << UImgr-> SolveAlias(cmdstr)
72  << "> not found" << G4endl;
73  break;
74 
76  G4cout << "illegal application state -- command refused"
77  << G4endl;
78  break;
79 
81  break;
82 
84  G4cout << "Parameter is out of candidate list (index "
85  << paramIndex << ")"
86  << G4endl;
87  break;
88 
90  G4cout << "Parameter is wrong type and/or is not omittable (index "
91  << paramIndex << ")" << G4endl;
92  break;
93 
94  case fAliasNotFound:
95  break;
96 
97  default:
98  G4cout << "command refused (" << commandStatus << ")" << G4endl;
99  break;
100  }
101 
102  return returnVal;
103 }
104 
106 G4int ApplyUICommand_2(const std::string& cmdstr)
108 {
109  return ApplyUICommand_1(cmdstr);
110 }
111 
112 }
113 
114 using namespace pyG4UImanager;
115 
116 // ====================================================================
117 // module definition
118 // ====================================================================
120 {
121  class_<G4UImanager, boost::noncopyable>
122  ("G4UImanager", "UI manager class", no_init)
123  .def("GetUIpointer", &G4UImanager::GetUIpointer,
124  return_value_policy<reference_existing_object>())
125  .staticmethod("GetUIpointer")
126  // ---
127  .def("GetCurrentValues", &G4UImanager::GetCurrentValues)
128  .def("ExecuteMacroFile", &G4UImanager::ExecuteMacroFile)
129  .def("ApplyCommand", f1_ApplyCommand)
130  .def("ApplyCommand", f2_ApplyCommand)
131  .def("CreateHTML", &G4UImanager::CreateHTML, f_CreateHTML())
132  .def("SetMacroSearchPath", &G4UImanager::SetMacroSearchPath)
133  .def("GetMacroSearchPath", &G4UImanager::GetMacroSearchPath,
134  return_value_policy<return_by_value>())
135  // ---
136  .def("SetPauseAtBeginOfEvent", &G4UImanager::SetPauseAtBeginOfEvent)
137  .def("GetPauseAtBeginOfEvent", &G4UImanager::GetPauseAtBeginOfEvent)
138  .def("SetPauseAtEndOfEvent", &G4UImanager::SetPauseAtEndOfEvent)
139  .def("GetPauseAtEndOfEvent", &G4UImanager::GetPauseAtEndOfEvent)
140  .def("SetVerboseLevel", &G4UImanager::SetVerboseLevel)
141  .def("GetVerboseLevel", &G4UImanager::GetVerboseLevel)
142  // ---
143  .def("GetTree", &G4UImanager::GetTree,
144  return_value_policy<reference_existing_object>())
145  ;
146 
147  // ---
148  def("ApplyUICommand", ApplyUICommand_1);
149  def("ApplyUICommand", ApplyUICommand_2);
150 
151 }
void SetMacroSearchPath(const G4String &path)
Definition: G4UImanager.hh:243
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:278
G4int(G4UImanager::* f2_ApplyCommand)(const G4String &)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume, CreateTubeVolume, 4, 6) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:227
int G4int
Definition: G4Types.hh:78
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:225
G4int ApplyUICommand_1(const G4String &cmdstr)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void export_G4UImanager()
G4bool GetPauseAtBeginOfEvent() const
Definition: G4UImanager.hh:194
G4bool GetPauseAtEndOfEvent() const
Definition: G4UImanager.hh:198
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:156
G4int ApplyUICommand_2(const std::string &cmdstr)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:206
void SetPauseAtEndOfEvent(G4bool vl)
Definition: G4UImanager.hh:196
const G4String & GetMacroSearchPath() const
Definition: G4UImanager.hh:245
void SetPauseAtBeginOfEvent(G4bool vl)
Definition: G4UImanager.hh:192
#define G4endl
Definition: G4ios.hh:61
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:641
G4int(G4UImanager::* f1_ApplyCommand)(const char *)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:432