29 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER
45 G4OpenGLXmViewerMessenger* G4OpenGLXmViewerMessenger::fpInstance = 0;
49 if (!fpInstance) fpInstance =
new G4OpenGLXmViewerMessenger;
53 G4OpenGLXmViewerMessenger::G4OpenGLXmViewerMessenger()
58 fpDirectory->SetGuidance(
"G4OpenGLXmViewer commands.");
61 fpDirectorySet->SetGuidance(
"G4OpenGLXmViewer set commands.");
63 fpCommandSetDollyHigh =
65 fpCommandSetDollyHigh->SetGuidance(
"Higher limit of dolly slider.");
66 fpCommandSetDollyHigh->SetParameterName(
"dolly-high", omitable =
false);
68 fpCommandSetDollyLow =
70 fpCommandSetDollyLow->SetGuidance(
"Lower limit of dolly slider.");
71 fpCommandSetDollyLow->SetParameterName(
"dolly-low", omitable =
false);
75 fpCommandSetPanHigh->SetGuidance(
"Higher limit of pan slider.");
76 fpCommandSetPanHigh->SetParameterName(
"pan-high", omitable =
false);
78 fpCommandSetRotationHigh =
80 fpCommandSetRotationHigh->SetGuidance(
"Higher limit of rotation slider.");
81 fpCommandSetRotationHigh->SetParameterName(
"rotation-high", omitable =
false);
83 fpCommandSetZoomHigh =
85 fpCommandSetZoomHigh->SetGuidance(
"Higher limit of zoom slider.");
86 fpCommandSetZoomHigh->SetParameterName(
"zoom-high", omitable =
false);
90 fpCommandSetZoomLow->SetGuidance(
"Lower limit of zoom slider.");
91 fpCommandSetZoomLow->SetParameterName(
"zoom-low", omitable =
false);
94 G4OpenGLXmViewerMessenger::~G4OpenGLXmViewerMessenger ()
96 delete fpCommandSetZoomLow;
97 delete fpCommandSetZoomHigh;
98 delete fpCommandSetRotationHigh;
99 delete fpCommandSetPanHigh;
100 delete fpCommandSetDollyLow;
101 delete fpCommandSetDollyHigh;
102 delete fpDirectorySet;
106 void G4OpenGLXmViewerMessenger::SetNewValue
115 "G4OpenGLXmViewerMessenger::SetNewValue: No current viewer."
116 "\n \"/vis/open\", or similar, to get one."
121 G4OpenGLXmViewer* pViewer =
dynamic_cast<G4OpenGLXmViewer*
>(pVViewer);
125 "G4OpenGLXmViewerMessenger::SetNewValue: Current viewer is not of type"
126 "\n OGLIXm or OGLSXm. Use \"/vis/viewer/select\" or \"/vis/open\"."
131 G4bool panningControlPanel =
true;
132 G4bool rotationControlPanel =
true;
134 if (command == fpCommandSetDollyHigh)
136 if (pViewer->fpdolly_slider)
138 pViewer->dolly_high =
139 fpCommandSetDollyHigh->GetNewDoubleValue(newValue);
140 pViewer->fpdolly_slider->SetMaxValue (pViewer->dolly_high);
141 if (pViewer->fVP.GetDolly() > pViewer->dolly_high)
143 pViewer->fpdolly_slider->SetInitialValue (pViewer->dolly_high);
144 pViewer->fVP.SetDolly(pViewer->dolly_high);
148 pViewer->fpdolly_slider->SetInitialValue (pViewer->fVP.GetDolly());
153 panningControlPanel =
false;
157 else if (command == fpCommandSetDollyLow)
159 if (pViewer->fpdolly_slider)
162 fpCommandSetDollyLow->GetNewDoubleValue(newValue);
163 pViewer->fpdolly_slider->SetMinValue (pViewer->dolly_low);
164 if (pViewer->fVP.GetDolly() < pViewer->dolly_low)
166 pViewer->fpdolly_slider->SetInitialValue (pViewer->dolly_low);
167 pViewer->fVP.SetDolly(pViewer->dolly_low);
171 pViewer->fpdolly_slider->SetInitialValue (pViewer->fVP.GetDolly());
176 panningControlPanel =
false;
180 else if (command == fpCommandSetPanHigh)
182 if (pViewer->fppanning_slider)
184 pViewer->pan_sens_limit =
185 fpCommandSetPanHigh->GetNewDoubleValue(newValue);
186 pViewer->fppanning_slider->SetMaxValue (pViewer->pan_sens_limit);
187 pViewer->fppanning_slider->SetInitialValue (pViewer->pan_sens_limit / 2.);
191 panningControlPanel =
false;
195 else if (command == fpCommandSetRotationHigh)
197 if (pViewer->fprotation_slider)
200 pViewer->rot_sens_limit =
201 fpCommandSetRotationHigh->GetNewDoubleValue(newValue) /
deg;
202 pViewer->fprotation_slider->SetMaxValue (pViewer->rot_sens_limit);
203 pViewer->fprotation_slider->SetInitialValue (pViewer->rot_sens_limit / 2.);
207 rotationControlPanel =
false;
211 else if (command == fpCommandSetZoomHigh)
213 if (pViewer->fpzoom_slider)
216 fpCommandSetZoomHigh->GetNewDoubleValue(newValue);
217 pViewer->fpzoom_slider->SetMaxValue (pViewer->zoom_high);
218 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
219 if (pViewer->fVP.GetZoomFactor() > pViewer->zoom_high)
221 pViewer->fpzoom_slider->SetInitialValue (pViewer->zoom_high);
222 pViewer->fVP.SetZoomFactor(pViewer->zoom_high);
226 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
231 panningControlPanel =
false;
235 else if (command == fpCommandSetZoomLow)
237 if (pViewer->fpzoom_slider)
240 fpCommandSetZoomLow->GetNewDoubleValue(newValue);
241 pViewer->fpzoom_slider->SetMinValue (pViewer->zoom_low);
242 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
243 if (pViewer->fVP.GetZoomFactor() < pViewer->zoom_low)
245 pViewer->fpzoom_slider->SetInitialValue (pViewer->zoom_low);
246 pViewer->fVP.SetZoomFactor(pViewer->zoom_low);
250 pViewer->fpzoom_slider->SetInitialValue (pViewer->fVP.GetZoomFactor());
255 panningControlPanel =
false;
259 if (!panningControlPanel)
262 "G4OpenGLXmViewerMessenger::SetNewValue: pull down panning"
263 "\n control panel and re-issue command."
268 if (!rotationControlPanel)
271 "G4OpenGLXmViewerMessenger::SetNewValue: pull down rotation"
272 "\n control panel and re-issue command."
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
static G4VisManager * GetInstance()
G4VViewer * GetCurrentViewer() const
std::map< G4String, G4AttDef > * GetInstance(const G4String &storeKey, G4bool &isNew)
static constexpr double deg
G4int ApplyCommand(const char *aCommand)