Geant4-11
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// ====================================================================
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
38using namespace boost::python;
39
40// ====================================================================
41// wrappers
42// ====================================================================
43namespace pyG4UImanager {
44
45// ApplyCommand
49
50// CreateHTML
51BOOST_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) {
67 break;
68
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
105G4int ApplyUICommand_2(const std::string& cmdstr)
107{
108 return ApplyUICommand_1(cmdstr);
109}
110
111}
112
113using 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}
int G4int
Definition: G4Types.hh:85
@ fParameterOutOfCandidates
@ fCommandNotFound
@ fAliasNotFound
@ fIllegalApplicationState
@ fParameterUnreadable
@ fCommandSucceeded
@ fParameterOutOfRange
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4String & GetMacroSearchPath() const
Definition: G4UImanager.hh:215
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void CreateHTML(const char *dir="/")
Definition: G4UImanager.cc:772
G4bool GetPauseAtBeginOfEvent() const
Definition: G4UImanager.hh:178
void ExecuteMacroFile(const char *fileName)
Definition: G4UImanager.cc:303
void SetMacroSearchPath(const G4String &path)
Definition: G4UImanager.hh:214
G4int GetVerboseLevel() const
Definition: G4UImanager.hh:200
G4bool GetPauseAtEndOfEvent() const
Definition: G4UImanager.hh:180
void SetPauseAtBeginOfEvent(G4bool vl)
Definition: G4UImanager.hh:177
G4String GetCurrentValues(const char *aCommand)
Definition: G4UImanager.cc:164
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
void SetPauseAtEndOfEvent(G4bool vl)
Definition: G4UImanager.hh:179
void SetVerboseLevel(G4int val)
Definition: G4UImanager.hh:199
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_ClearWaitingStack, ClearWaitingStack, 0, 1) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetNWaitingTrack
G4int(G4UImanager::* f2_ApplyCommand)(const G4String &)
G4int ApplyUICommand_1(const G4String &cmdstr)
G4int(G4UImanager::* f1_ApplyCommand)(const char *)
G4int ApplyUICommand_2(const std::string &cmdstr)
string cmdstr
Definition: test.py:122
void export_G4UImanager()