Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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,v 1.1 2006-08-08 05:20:57 kmura Exp $
27 // $Name: not supported by cvs2svn $
28 // ====================================================================
29 // pyG4UImanager.cc
30 //
31 // G4UImanager class is pure singleton, so it cannnot be exposed
32 // from BPL. Functionality of G4UImanager is exposed in global
33 // name space via wrappers.
34 // 2006 Q
35 // ====================================================================
36 #include <boost/python.hpp>
37 #include "G4UImanager.hh"
38 #include "G4UIcommandTree.hh"
39 
40 using namespace boost::python;
41 
42 // ====================================================================
43 // wrappers
44 // ====================================================================
45 namespace pyG4UImanager {
46 
47 // ApplyCommand
51 
52 // CreateHTML
53 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateHTML, CreateHTML, 0, 1);
54 
55 
59 {
61  G4int returnVal= UImgr-> ApplyCommand(cmdstr);
62  if( returnVal == fCommandSucceeded ) return returnVal;
63 
64  G4int paramIndex= returnVal % 100;
65  G4int commandStatus= returnVal - paramIndex;
66 
67  switch(commandStatus) {
68  case fCommandSucceeded:
69  break;
70 
71  case fCommandNotFound:
72  G4cout << "command <" << UImgr-> SolveAlias(cmdstr)
73  << "> not found" << G4endl;
74  break;
75 
77  G4cout << "illegal application state -- command refused"
78  << G4endl;
79  break;
80 
82  break;
83 
85  G4cout << "Parameter is out of candidate list (index "
86  << paramIndex << ")"
87  << G4endl;
88  break;
89 
91  G4cout << "Parameter is wrong type and/or is not omittable (index "
92  << paramIndex << ")" << G4endl;
93  break;
94 
95  case fAliasNotFound:
96  break;
97 
98  default:
99  G4cout << "command refused (" << commandStatus << ")" << G4endl;
100  break;
101  }
102 
103  return returnVal;
104 }
105 
107 G4int ApplyUICommand_2(const std::string& cmdstr)
109 {
110  return ApplyUICommand_1(cmdstr);
111 }
112 
113 };
114 
115 using namespace pyG4UImanager;
116 
117 // ====================================================================
118 // module definition
119 // ====================================================================
121 {
122  class_<G4UImanager, boost::noncopyable>
123  ("G4UImanager", "UI manager class", no_init)
124  .def("GetUIpointer", &G4UImanager::GetUIpointer,
125  return_value_policy<reference_existing_object>())
126  .staticmethod("GetUIpointer")
127  // ---
128  .def("GetCurrentValues", &G4UImanager::GetCurrentValues)
129  .def("ExecuteMacroFile", &G4UImanager::ExecuteMacroFile)
130  .def("ApplyCommand", f1_ApplyCommand)
131  .def("ApplyCommand", f2_ApplyCommand)
132  .def("CreateHTML", &G4UImanager::CreateHTML, f_CreateHTML())
133  .def("SetMacroSearchPath", &G4UImanager::SetMacroSearchPath)
134  .def("GetMacroSearchPath", &G4UImanager::GetMacroSearchPath,
135  return_value_policy<return_by_value>())
136  // ---
137  .def("SetPauseAtBeginOfEvent", &G4UImanager::SetPauseAtBeginOfEvent)
138  .def("GetPauseAtBeginOfEvent", &G4UImanager::GetPauseAtBeginOfEvent)
139  .def("SetPauseAtEndOfEvent", &G4UImanager::SetPauseAtEndOfEvent)
140  .def("GetPauseAtEndOfEvent", &G4UImanager::GetPauseAtEndOfEvent)
141  .def("SetVerboseLevel", &G4UImanager::SetVerboseLevel)
142  .def("GetVerboseLevel", &G4UImanager::GetVerboseLevel)
143  // ---
144  .def("GetTree", &G4UImanager::GetTree,
145  return_value_policy<reference_existing_object>())
146  ;
147 
148  // ---
149  def("ApplyUICommand", ApplyUICommand_1);
150  def("ApplyUICommand", ApplyUICommand_2);
151 
152 }