Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4OpenGLXmViewerMessenger Class Reference

#include <G4OpenGLXmViewerMessenger.hh>

+ Inheritance diagram for G4OpenGLXmViewerMessenger:

Public Member Functions

 ~G4OpenGLXmViewerMessenger ()
 
void SetNewValue (G4UIcommand *, G4String)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool CommandsShouldBeInMaster () const
 

Static Public Member Functions

static G4OpenGLXmViewerMessengerGetInstance ()
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 40 of file G4OpenGLXmViewerMessenger.hh.

Constructor & Destructor Documentation

◆ ~G4OpenGLXmViewerMessenger()

G4OpenGLXmViewerMessenger::~G4OpenGLXmViewerMessenger ( )

Definition at line 91 of file G4OpenGLXmViewerMessenger.cc.

92{
93 delete fpCommandSetZoomLow;
94 delete fpCommandSetZoomHigh;
95 delete fpCommandSetRotationHigh;
96 delete fpCommandSetPanHigh;
97 delete fpCommandSetDollyLow;
98 delete fpCommandSetDollyHigh;
99 delete fpDirectorySet;
100 delete fpDirectory;
101}

Member Function Documentation

◆ GetInstance()

G4OpenGLXmViewerMessenger * G4OpenGLXmViewerMessenger::GetInstance ( )
static

Definition at line 44 of file G4OpenGLXmViewerMessenger.cc.

45{
46 if (!fpInstance) fpInstance = new G4OpenGLXmViewerMessenger;
47 return fpInstance;
48}

Referenced by G4OpenGLImmediateXm::G4OpenGLImmediateXm(), and G4OpenGLStoredXm::G4OpenGLStoredXm().

◆ SetNewValue()

void G4OpenGLXmViewerMessenger::SetNewValue ( G4UIcommand * command,
G4String newValue )
virtual

Reimplemented from G4UImessenger.

Definition at line 103 of file G4OpenGLXmViewerMessenger.cc.

105{
107
108 G4VViewer* pVViewer = pVisManager->GetCurrentViewer();
109
110 if (!pVViewer) {
111 G4cout <<
112 "G4OpenGLXmViewerMessenger::SetNewValue: No current viewer."
113 "\n \"/vis/open\", or similar, to get one."
114 << G4endl;
115 return;
116 }
117
118 G4OpenGLXmViewer* pViewer = dynamic_cast<G4OpenGLXmViewer*>(pVViewer);
119
120 if (!pViewer) {
121 G4cout <<
122 "G4OpenGLXmViewerMessenger::SetNewValue: Current viewer is not of type"
123 "\n OGLIXm or OGLSXm. Use \"/vis/viewer/select\" or \"/vis/open\"."
124 << G4endl;
125 return;
126 }
127
128 G4bool panningControlPanel = true;
129 G4bool rotationControlPanel = true;
130
131 if (command == fpCommandSetDollyHigh)
132 {
133 if (pViewer->fpdolly_slider)
134 {
135 pViewer->dolly_high =
136 fpCommandSetDollyHigh->GetNewDoubleValue(newValue);
137 pViewer->fpdolly_slider->SetMaxValue (pViewer->dolly_high);
138 if (pViewer->fVP.GetDolly() > pViewer->dolly_high)
139 {
140 pViewer->fpdolly_slider->SetInitialValue (pViewer->dolly_high);
141 pViewer->fVP.SetDolly(pViewer->dolly_high);
142 }
143 else
144 {
145 pViewer->fpdolly_slider->SetInitialValue (pViewer->fVP.GetDolly());
146 }
147 }
148 else
149 {
150 panningControlPanel = false;
151 }
152 }
153
154 else if (command == fpCommandSetDollyLow)
155 {
156 if (pViewer->fpdolly_slider)
157 {
158 pViewer->dolly_low =
159 fpCommandSetDollyLow->GetNewDoubleValue(newValue);
160 pViewer->fpdolly_slider->SetMinValue (pViewer->dolly_low);
161 if (pViewer->fVP.GetDolly() < pViewer->dolly_low)
162 {
163 pViewer->fpdolly_slider->SetInitialValue (pViewer->dolly_low);
164 pViewer->fVP.SetDolly(pViewer->dolly_low);
165 }
166 else
167 {
168 pViewer->fpdolly_slider->SetInitialValue (pViewer->fVP.GetDolly());
169 }
170 }
171 else
172 {
173 panningControlPanel = false;
174 }
175 }
176
177 else if (command == fpCommandSetPanHigh)
178 {
179 if (pViewer->fppanning_slider)
180 {
181 pViewer->pan_sens_limit =
182 fpCommandSetPanHigh->GetNewDoubleValue(newValue);
183 pViewer->fppanning_slider->SetMaxValue (pViewer->pan_sens_limit);
184 pViewer->fppanning_slider->SetInitialValue (pViewer->pan_sens_limit / 2.);
185 }
186 else
187 {
188 panningControlPanel = false;
189 }
190 }
191
192 else if (command == fpCommandSetRotationHigh)
193 {
194 if (pViewer->fprotation_slider)
195 {
196 // Internally in OpenGLXm, it's in degrees...
197 pViewer->rot_sens_limit =
198 fpCommandSetRotationHigh->GetNewDoubleValue(newValue) / deg;
199 pViewer->fprotation_slider->SetMaxValue (pViewer->rot_sens_limit);
200 pViewer->fprotation_slider->SetInitialValue (pViewer->rot_sens_limit / 2.);
201 }
202 else
203 {
204 rotationControlPanel = false;
205 }
206 }
207
208 else if (command == fpCommandSetZoomHigh)
209 {
210 if (pViewer->fpzoom_slider)
211 {
212 pViewer->zoom_high =
213 fpCommandSetZoomHigh->GetNewDoubleValue(newValue);
214 pViewer->fpzoom_slider->SetMaxValue (pViewer->zoom_high);
215 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
216 if (pViewer->fVP.GetZoomFactor() > pViewer->zoom_high)
217 {
218 pViewer->fpzoom_slider->SetInitialValue (pViewer->zoom_high);
219 pViewer->fVP.SetZoomFactor(pViewer->zoom_high);
220 }
221 else
222 {
223 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
224 }
225 }
226 else
227 {
228 panningControlPanel = false;
229 }
230 }
231
232 else if (command == fpCommandSetZoomLow)
233 {
234 if (pViewer->fpzoom_slider)
235 {
236 pViewer->zoom_low =
237 fpCommandSetZoomLow->GetNewDoubleValue(newValue);
238 pViewer->fpzoom_slider->SetMinValue (pViewer->zoom_low);
239 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
240 if (pViewer->fVP.GetZoomFactor() < pViewer->zoom_low)
241 {
242 pViewer->fpzoom_slider->SetInitialValue (pViewer->zoom_low);
243 pViewer->fVP.SetZoomFactor(pViewer->zoom_low);
244 }
245 else
246 {
247 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
248 }
249 }
250 else
251 {
252 panningControlPanel = false;
253 }
254 }
255
256 if (!panningControlPanel)
257 {
258 G4cout <<
259 "G4OpenGLXmViewerMessenger::SetNewValue: pull down panning"
260 "\n control panel and re-issue command."
261 << G4endl;
262 return;
263 }
264
265 if (!rotationControlPanel)
266 {
267 G4cout <<
268 "G4OpenGLXmViewerMessenger::SetNewValue: pull down rotation"
269 "\n control panel and re-issue command."
270 << G4endl;
271 return;
272 }
273
274 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
275}
bool G4bool
Definition G4Types.hh:86
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4OpenGLXmSliderBar * fppanning_slider
G4OpenGLXmSliderBar * fprotation_slider
G4OpenGLXmSliderBar * fpzoom_slider
G4OpenGLXmSliderBar * fpdolly_slider
static G4double GetNewDoubleValue(const char *paramString)
static G4double GetNewDoubleValue(const char *paramString)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
G4ViewParameters fVP
Definition G4VViewer.hh:257
G4double GetZoomFactor() const
void SetDolly(G4double dolly)
void SetZoomFactor(G4double zoomFactor)
G4double GetDolly() const
G4VViewer * GetCurrentViewer() const
static G4VisManager * GetInstance()

The documentation for this class was generated from the following files: