source: head/source/Callbacks.cxx@ 3

Last change on this file since 3 was 3, checked in by barrand, 19 years ago
File size: 2.9 KB
Line 
1//
2// All functions here should be OnX callbacks, that is to say
3// functions with signature :
4// extern "C" {
5// void callback_without_arguments(IUI&);
6// void callback_with_arguments(IUI&,const std::vector<std::string>&);
7// }
8//
9
10#include <OnX/Helpers/OnX.h>
11#include <OnX/Helpers/Inventor.h>
12
13// Slash :
14#include <Slash/Core/ISession.h>
15#include <Slash/UI/IUI.h>
16#include <Slash/UI/ISoViewer.h>
17
18// Lib :
19#include <Lib/System.h>
20#include <Lib/Manager.h>
21#include <Lib/Printer.h>
22#include <Lib/Out.h>
23
24// G4Lab :
25#include <G4Lab/Interfaces/IGeant4Manager.h>
26
27extern "C" {
28
29//////////////////////////////////////////////////////////////////////////////
30/// snovis/scripts/OnX/snovis.onx //////////////////////////////////
31//////////////////////////////////////////////////////////////////////////////
32//////////////////////////////////////////////////////////////////////////////
33void snovis_Initialize(
34 Slash::UI::IUI& aUI
35)
36//////////////////////////////////////////////////////////////////////////////
37// Should be executed (in a widget create callback)
38// when the GUI is constructed
39//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
40{
41 Slash::UI::ISoViewer* soViewer = ui_SoViewer(aUI);
42 if(soViewer) {
43 soViewer->setDecoration(true);
44 soViewer->setViewing(true);
45 }
46
47 aUI.setCallback("OnX_File_exit","activate","DLD","G4Lab G4Lab_exit");
48
49 Slash::Core::ISession& session = aUI.session();
50
51 session.setParameter("modeling.highlightColor","white");
52 session.setParameter("modeling.trajectories","pickable");
53 session.setParameter("event.scan","yes");
54
55 IGeant4Manager* g4Manager =
56 Lib_findManager(session,"Geant4Manager",IGeant4Manager);
57 if(!g4Manager) {
58 aUI.echo("snovis_Initialize : Geant4Manager not found.");
59 } else {
60 // Declare a callback executed at each end of event :
61 g4Manager->setEventEndScript("DLD","snovis snovis_eventEnd");
62 //Declare G4Lab types (PV, Trajectory, HitsCollections, etc...).
63 g4Manager->initialize();
64 }
65}
66//////////////////////////////////////////////////////////////////////////////
67void snovis_Finalize(
68 Slash::UI::IUI&
69)
70//////////////////////////////////////////////////////////////////////////////
71//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
72{
73}
74//////////////////////////////////////////////////////////////////////////////
75void snovis_execute_eventEnd(
76 Slash::UI::IUI& aUI
77)
78//////////////////////////////////////////////////////////////////////////////
79//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
80{
81 Slash::Core::ISession& session = aUI.session();
82
83 std::string value;
84 if(!session.parameterValue("event.scan",value)) return;
85 // To avoid falling in the ui.steer();
86 session.setParameter("event.scan","no");
87
88 aUI.executeScript("DLD","snovis snovis_eventEnd");
89
90 // Restore previous event.scan :
91 session.setParameter("event.scan",value);
92}
93
94} // extern "C"
Note: See TracBrowser for help on using the repository browser.