Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: G4OpenGLXmMainMenubarCallbacks.cc 66373 2012-12-18 09:41:34Z gcosmo $ 27 // 28 // 28 // 29 // 29 // Andrew Walkden 16th April 1997 30 // Andrew Walkden 16th April 1997 30 // G4OpenGLXmMainMenubarCallbacks : 31 // G4OpenGLXmMainMenubarCallbacks : 31 // Collection of callbac 32 // Collection of callback functions 32 // to handle events gene 33 // to handle events generated by the 33 // main OpenGLXm window 34 // main OpenGLXm window menubar. 34 // 35 // 35 // See G4OpenGLXmMainMenubarCallbacks.hh for m 36 // See G4OpenGLXmMainMenubarCallbacks.hh for more information. 36 37 37 38 >> 39 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER >> 40 38 #include "G4OpenGLXmViewer.hh" 41 #include "G4OpenGLXmViewer.hh" 39 42 40 #include "G4Xt.hh" 43 #include "G4Xt.hh" 41 44 42 #include "G4VSceneHandler.hh" 45 #include "G4VSceneHandler.hh" 43 46 44 #include "G4Scene.hh" 47 #include "G4Scene.hh" 45 48 46 #include "G4OpenGLXmRadioButton.hh" 49 #include "G4OpenGLXmRadioButton.hh" 47 #include "G4OpenGLXmSliderBar.hh" 50 #include "G4OpenGLXmSliderBar.hh" 48 #include "G4OpenGLXmFourArrowButtons.hh" 51 #include "G4OpenGLXmFourArrowButtons.hh" 49 #include "G4OpenGLXmTextField.hh" 52 #include "G4OpenGLXmTextField.hh" 50 #include "G4OpenGLXmPushButton.hh" 53 #include "G4OpenGLXmPushButton.hh" 51 #include "G4OpenGLXmBox.hh" 54 #include "G4OpenGLXmBox.hh" 52 #include "G4OpenGLXmFramedBox.hh" 55 #include "G4OpenGLXmFramedBox.hh" 53 #include "G4OpenGLXmTopLevelShell.hh" 56 #include "G4OpenGLXmTopLevelShell.hh" 54 #include "G4OpenGLXmSeparator.hh" 57 #include "G4OpenGLXmSeparator.hh" 55 58 56 #include <sstream> 59 #include <sstream> 57 60 58 void G4OpenGLXmViewer::actions_callback (Widge 61 void G4OpenGLXmViewer::actions_callback (Widget w, 59 XtPointer clientData, 62 XtPointer clientData, 60 XtPointer) 63 XtPointer) 61 { 64 { 62 65 63 G4OpenGLXmViewer* pView; 66 G4OpenGLXmViewer* pView; 64 G4long choice = (G4long)clientData; 67 G4long choice = (G4long)clientData; 65 68 66 69 67 XtVaGetValues (XtParent(w), 70 XtVaGetValues (XtParent(w), 68 XmNuserData, &pView, 71 XmNuserData, &pView, 69 NULL); 72 NULL); 70 73 71 switch (choice) { 74 switch (choice) { 72 75 73 case 0: 76 case 0: 74 77 75 { 78 { 76 79 77 if (!pView->fprotation_top) { 80 if (!pView->fprotation_top) { 78 std::ostringstream rot_Name; 81 std::ostringstream rot_Name; 79 rot_Name << pView->GetSceneHandler()->GetSce 82 rot_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId; 80 83 81 pView->fprotation_top = new G4OpenGLXmTopLev 84 pView->fprotation_top = new G4OpenGLXmTopLevelShell (pView, 82 (char*)rot_Name.str().c_str 85 (char*)rot_Name.str().c_str()); 83 pView->fprotation_button_box = new G4OpenGLX 86 pView->fprotation_button_box = new G4OpenGLXmBox ("Rotation button box", True); 84 87 85 pView->fprotation_top->AddChild (pView->fpro 88 pView->fprotation_top->AddChild (pView->fprotation_button_box); 86 89 87 XtCallbackRec* rot_cb_list = new XtCallbackR 90 XtCallbackRec* rot_cb_list = new XtCallbackRec[2]; 88 rot_cb_list[0].callback = set_rot_subject_ca 91 rot_cb_list[0].callback = set_rot_subject_callback; 89 rot_cb_list[0].closure = pView; 92 rot_cb_list[0].closure = pView; 90 rot_cb_list[1].callback = NULL; 93 rot_cb_list[1].callback = NULL; 91 94 92 pView->fprotation_button1 = new G4OpenGLXmRa 95 pView->fprotation_button1 = new G4OpenGLXmRadioButton 93 ("Object", 96 ("Object", 94 rot_cb_list, 97 rot_cb_list, 95 pView->GetViewParameters().GetLightsMoveW 98 pView->GetViewParameters().GetLightsMoveWithCamera(), 96 0); 99 0); 97 100 98 pView->fprotation_button2 = new G4OpenGLXmRa 101 pView->fprotation_button2 = new G4OpenGLXmRadioButton 99 ("Camera", 102 ("Camera", 100 rot_cb_list, 103 rot_cb_list, 101 !(pView->GetViewParameters().GetLightsMov 104 !(pView->GetViewParameters().GetLightsMoveWithCamera()), 102 1); 105 1); 103 106 104 pView->fprotation_button_box->AddChild (pVie 107 pView->fprotation_button_box->AddChild (pView->fprotation_button1); 105 pView->fprotation_button_box->AddChild (pVie 108 pView->fprotation_button_box->AddChild (pView->fprotation_button2); 106 109 107 pView->fprotation_slider_box = new G4OpenGLX 110 pView->fprotation_slider_box = new G4OpenGLXmBox ("Rotation slider box", False); 108 pView->fprotation_top->AddChild (pView->fpro 111 pView->fprotation_top->AddChild (pView->fprotation_slider_box); 109 112 110 XtCallbackRec* rot_slider_list = new XtCallb 113 XtCallbackRec* rot_slider_list = new XtCallbackRec[2]; 111 rot_slider_list[0].callback = set_rot_sens_c 114 rot_slider_list[0].callback = set_rot_sens_callback; 112 rot_slider_list[0].closure = pView; 115 rot_slider_list[0].closure = pView; 113 rot_slider_list[1].callback = NULL; 116 rot_slider_list[1].callback = NULL; 114 117 115 pView->fprotation_slider = new G4OpenGLXmSli 118 pView->fprotation_slider = new G4OpenGLXmSliderBar ("Rotation slider", 116 rot_slider_list, 119 rot_slider_list, 117 True, 120 True, 118 2, 121 2, 119 pView->fRot_sens, 122 pView->fRot_sens, 120 pView->rot_sens_limit, 123 pView->rot_sens_limit, 121 0); 124 0); 122 pView->fprotation_slider_box->AddChild (pVie 125 pView->fprotation_slider_box->AddChild (pView->fprotation_slider); 123 126 124 pView->fprotation_arrow_box = new G4OpenGLXm 127 pView->fprotation_arrow_box = new G4OpenGLXmBox ("Rotation arrow box", False); 125 pView->fprotation_top->AddChild (pView->fpro 128 pView->fprotation_top->AddChild (pView->fprotation_arrow_box); 126 129 127 XtCallbackRec** rotation_callbacks = new XtC 130 XtCallbackRec** rotation_callbacks = new XtCallbackRec*[4]; 128 for (G4int i = 0; i < 4; i++) { 131 for (G4int i = 0; i < 4; i++) { 129 rotation_callbacks[i] = new XtCallbackRec[ 132 rotation_callbacks[i] = new XtCallbackRec[2]; 130 } 133 } 131 rotation_callbacks[0][0].callback = phi_rota 134 rotation_callbacks[0][0].callback = phi_rotation_callback; 132 rotation_callbacks[0][0].closure = pView; 135 rotation_callbacks[0][0].closure = pView; 133 rotation_callbacks[0][1].callback = NULL; 136 rotation_callbacks[0][1].callback = NULL; 134 137 135 rotation_callbacks[1][0].callback = phi_rota 138 rotation_callbacks[1][0].callback = phi_rotation_callback; 136 rotation_callbacks[1][0].closure = pView; 139 rotation_callbacks[1][0].closure = pView; 137 rotation_callbacks[1][1].callback = NULL; 140 rotation_callbacks[1][1].callback = NULL; 138 141 139 rotation_callbacks[2][0].callback = theta_ro 142 rotation_callbacks[2][0].callback = theta_rotation_callback; 140 rotation_callbacks[2][0].closure = pView; 143 rotation_callbacks[2][0].closure = pView; 141 rotation_callbacks[2][1].callback = NULL; 144 rotation_callbacks[2][1].callback = NULL; 142 145 143 rotation_callbacks[3][0].callback = theta_ro 146 rotation_callbacks[3][0].callback = theta_rotation_callback; 144 rotation_callbacks[3][0].closure = pView; 147 rotation_callbacks[3][0].closure = pView; 145 rotation_callbacks[3][1].callback = NULL; 148 rotation_callbacks[3][1].callback = NULL; 146 149 147 pView->fprotation_arrow = new G4OpenGLXmFour 150 pView->fprotation_arrow = new G4OpenGLXmFourArrowButtons (rotation_callbacks); 148 151 149 pView->fprotation_arrow_box->AddChild (pView 152 pView->fprotation_arrow_box->AddChild (pView->fprotation_arrow); 150 153 151 pView->fprotation_top->Realize (); 154 pView->fprotation_top->Realize (); 152 } 155 } 153 break; 156 break; 154 157 155 } 158 } 156 159 157 160 158 case 1: 161 case 1: 159 { 162 { 160 if (!pView->GetSceneHandler()->GetScene( 163 if (!pView->GetSceneHandler()->GetScene()) { 161 break; 164 break; 162 } 165 } 163 if (!pView->fppanning_top) { 166 if (!pView->fppanning_top) { 164 std::ostringstream pan_Name; 167 std::ostringstream pan_Name; 165 pan_Name << pView->GetSceneHandler()->GetSce 168 pan_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId; 166 169 167 pView->fppanning_top = new G4OpenGLXmTopLeve 170 pView->fppanning_top = new G4OpenGLXmTopLevelShell (pView, 168 (char*)pan_Name.str().c_str( 171 (char*)pan_Name.str().c_str()); 169 172 170 pView->fppanning_box = new G4OpenGLXmFramedB 173 pView->fppanning_box = new G4OpenGLXmFramedBox ("Pan up-down-left-right", 171 False); 174 False); 172 175 173 pView->fppanning_top->AddChild (pView->fppan 176 pView->fppanning_top->AddChild (pView->fppanning_box); 174 177 175 XtCallbackRec** pan_callbacks = new XtCallba 178 XtCallbackRec** pan_callbacks = new XtCallbackRec*[4]; 176 for (G4int i = 0; i < 4; i++) { 179 for (G4int i = 0; i < 4; i++) { 177 pan_callbacks[i] = new XtCallbackRec[2]; 180 pan_callbacks[i] = new XtCallbackRec[2]; 178 } 181 } 179 pan_callbacks[0][0].callback = pan_up_down_c 182 pan_callbacks[0][0].callback = pan_up_down_callback; 180 pan_callbacks[0][0].closure = pView; 183 pan_callbacks[0][0].closure = pView; 181 pan_callbacks[0][1].callback = NULL; 184 pan_callbacks[0][1].callback = NULL; 182 185 183 pan_callbacks[1][0].callback = pan_up_down_c 186 pan_callbacks[1][0].callback = pan_up_down_callback; 184 pan_callbacks[1][0].closure = pView; 187 pan_callbacks[1][0].closure = pView; 185 pan_callbacks[1][1].callback = NULL; 188 pan_callbacks[1][1].callback = NULL; 186 189 187 pan_callbacks[2][0].callback = pan_left_righ 190 pan_callbacks[2][0].callback = pan_left_right_callback; 188 pan_callbacks[2][0].closure = pView; 191 pan_callbacks[2][0].closure = pView; 189 pan_callbacks[2][1].callback = NULL; 192 pan_callbacks[2][1].callback = NULL; 190 193 191 pan_callbacks[3][0].callback = pan_left_righ 194 pan_callbacks[3][0].callback = pan_left_right_callback; 192 pan_callbacks[3][0].closure = pView; 195 pan_callbacks[3][0].closure = pView; 193 pan_callbacks[3][1].callback = NULL; 196 pan_callbacks[3][1].callback = NULL; 194 197 195 pView->fppanning_arrows = new G4OpenGLXmFour 198 pView->fppanning_arrows = new G4OpenGLXmFourArrowButtons (pan_callbacks); 196 199 197 pView->fppanning_box->AddChild (pView->fppan 200 pView->fppanning_box->AddChild (pView->fppanning_arrows); 198 201 199 XtCallbackRec* pan_slider_list = new XtCallb 202 XtCallbackRec* pan_slider_list = new XtCallbackRec[2]; 200 pan_slider_list[0].callback = set_pan_sens_c 203 pan_slider_list[0].callback = set_pan_sens_callback; 201 pan_slider_list[0].closure = pView; 204 pan_slider_list[0].closure = pView; 202 pan_slider_list[1].callback = NULL; 205 pan_slider_list[1].callback = NULL; 203 206 204 pView->fppanning_slider = new G4OpenGLXmSlid 207 pView->fppanning_slider = new G4OpenGLXmSliderBar ("Panning slider", 205 pan_slider_list, 208 pan_slider_list, 206 True, 209 True, 207 2, 210 2, 208 pView->fPan_sens = pView->Get 211 pView->fPan_sens = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius() / 10.0, 209 pView->pan_sens_limit = pView 212 pView->pan_sens_limit = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(), 210 0); 213 0); 211 pView->fppanning_box->AddChild (pView->fppan 214 pView->fppanning_box->AddChild (pView->fppanning_slider); 212 215 213 pView->fpzoom_box = new G4OpenGLXmFramedBox 216 pView->fpzoom_box = new G4OpenGLXmFramedBox ("Zoom", 214 False); 217 False); 215 pView->fppanning_top->AddChild (pView->fpzoo 218 pView->fppanning_top->AddChild (pView->fpzoom_box); 216 219 217 XtCallbackRec* zoom_slider_list = new XtCall 220 XtCallbackRec* zoom_slider_list = new XtCallbackRec[2]; 218 zoom_slider_list[0].callback = zoom_callback 221 zoom_slider_list[0].callback = zoom_callback; 219 zoom_slider_list[0].closure = pView; 222 zoom_slider_list[0].closure = pView; 220 zoom_slider_list[1].callback = NULL; 223 zoom_slider_list[1].callback = NULL; 221 224 222 pView->fpzoom_slider = new G4OpenGLXmSliderB 225 pView->fpzoom_slider = new G4OpenGLXmSliderBar ("Zoom slider", 223 zoom_slider_list, 226 zoom_slider_list, 224 True, 227 True, 225 2, 228 2, 226 pView->fVP.GetZoomFactor(), 229 pView->fVP.GetZoomFactor(), 227 pView->zoom_high, 230 pView->zoom_high, 228 pView->zoom_low); 231 pView->zoom_low); 229 pView->fpzoom_box->AddChild (pView->fpzoom_s 232 pView->fpzoom_box->AddChild (pView->fpzoom_slider); 230 233 231 pView->fpdolly_box = new G4OpenGLXmFramedBox 234 pView->fpdolly_box = new G4OpenGLXmFramedBox ("Dolly", 232 False); 235 False); 233 pView->fppanning_top->AddChild (pView->fpdol 236 pView->fppanning_top->AddChild (pView->fpdolly_box); 234 237 235 XtCallbackRec* dolly_slider_list = new XtCal 238 XtCallbackRec* dolly_slider_list = new XtCallbackRec[2]; 236 dolly_slider_list[0].callback = dolly_callba 239 dolly_slider_list[0].callback = dolly_callback; 237 dolly_slider_list[0].closure = pView; 240 dolly_slider_list[0].closure = pView; 238 dolly_slider_list[1].callback = NULL; 241 dolly_slider_list[1].callback = NULL; 239 242 240 pView->fpdolly_slider = new G4OpenGLXmSlider 243 pView->fpdolly_slider = new G4OpenGLXmSliderBar ("Dolly slider", 241 dolly_slider_list, 244 dolly_slider_list, 242 True, 245 True, 243 2, 246 2, 244 pView->fVP.GetDolly(), 247 pView->fVP.GetDolly(), 245 pView->dolly_high = pView->GetS 248 pView->dolly_high = pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(), 246 pView->dolly_low = -(pView->Get 249 pView->dolly_low = -(pView->GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius())); 247 // pView->dolly_high, 250 // pView->dolly_high, 248 // pView->dolly_low); 251 // pView->dolly_low); 249 pView->fpdolly_box->AddChild (pView->fpdolly 252 pView->fpdolly_box->AddChild (pView->fpdolly_slider); 250 253 251 pView->fppanning_top->Realize (); 254 pView->fppanning_top->Realize (); 252 pView->UpdateControlPanel (); 255 pView->UpdateControlPanel (); 253 } 256 } 254 257 255 break; 258 break; 256 259 257 } 260 } 258 case 2: 261 case 2: 259 { 262 { 260 263 261 if (!pView->fpsetting_top) { 264 if (!pView->fpsetting_top) { 262 std::ostringstream set_Name; 265 std::ostringstream set_Name; 263 set_Name << pView->GetSceneHandler()->GetSce 266 set_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId; 264 267 265 pView->fpsetting_top = new G4OpenGLXmTopLeve 268 pView->fpsetting_top = new G4OpenGLXmTopLevelShell(pView, 266 (char*)set_Name.str().c_str() 269 (char*)set_Name.str().c_str()); 267 270 268 pView->fpsetting_box = new G4OpenGLXmFramedB 271 pView->fpsetting_box = new G4OpenGLXmFramedBox ("Set values for control panels", 269 False); 272 False); 270 pView->fpsetting_top->AddChild (pView->fpset 273 pView->fpsetting_top->AddChild (pView->fpsetting_box); 271 274 272 pView->fppan_set = new G4OpenGLXmTextField ( 275 pView->fppan_set = new G4OpenGLXmTextField ("Upper limit of pan sensitivity", 273 &(pView->pan_sens_limit)); 276 &(pView->pan_sens_limit)); 274 277 275 pView->fprot_set = new G4OpenGLXmTextField ( 278 pView->fprot_set = new G4OpenGLXmTextField ("Upper limit of rotation sensitivity", 276 &(pView->rot_sens_limit)); 279 &(pView->rot_sens_limit)); 277 280 278 pView->fpzoom_upper = new G4OpenGLXmTextFiel 281 pView->fpzoom_upper = new G4OpenGLXmTextField ("Upper limit of zoom", 279 &(pView->zoom_high)); 282 &(pView->zoom_high)); 280 283 281 pView->fpzoom_lower = new G4OpenGLXmTextFiel 284 pView->fpzoom_lower = new G4OpenGLXmTextField ("Lower limit of zoom", 282 &(pView->zoom_low)); 285 &(pView->zoom_low)); 283 286 284 pView->fpdolly_upper = new G4OpenGLXmTextFie 287 pView->fpdolly_upper = new G4OpenGLXmTextField ("Upper limit of dolly", 285 &(pView->dolly_high)); 288 &(pView->dolly_high)); 286 289 287 pView->fpdolly_lower = new G4OpenGLXmTextFie 290 pView->fpdolly_lower = new G4OpenGLXmTextField ("Lower limit of dolly", 288 &(pView->dolly_low)); 291 &(pView->dolly_low)); 289 292 290 XtCallbackRec* ok_list = new XtCallbackRec[2 293 XtCallbackRec* ok_list = new XtCallbackRec[2]; 291 ok_list[0].callback = update_panels_callback 294 ok_list[0].callback = update_panels_callback; 292 ok_list[0].closure = pView; 295 ok_list[0].closure = pView; 293 ok_list[1].callback = NULL; 296 ok_list[1].callback = NULL; 294 297 295 298 296 pView->fpok_button = new G4OpenGLXmPushButto 299 pView->fpok_button = new G4OpenGLXmPushButton ("ok", 297 ok_list); 300 ok_list); 298 301 299 pView->fpsetting_box->AddChild (pView->fppan 302 pView->fpsetting_box->AddChild (pView->fppan_set); 300 pView->fpsetting_box->AddChild (pView->fprot 303 pView->fpsetting_box->AddChild (pView->fprot_set); 301 pView->fpsetting_box->AddChild (pView->fpzoo 304 pView->fpsetting_box->AddChild (pView->fpzoom_upper); 302 pView->fpsetting_box->AddChild (pView->fpzoo 305 pView->fpsetting_box->AddChild (pView->fpzoom_lower); 303 pView->fpsetting_box->AddChild (pView->fpdol 306 pView->fpsetting_box->AddChild (pView->fpdolly_upper); 304 pView->fpsetting_box->AddChild (pView->fpdol 307 pView->fpsetting_box->AddChild (pView->fpdolly_lower); 305 pView->fpsetting_box->AddChild (pView->fpok_ 308 pView->fpsetting_box->AddChild (pView->fpok_button); 306 309 307 pView->fpsetting_top->Realize (); 310 pView->fpsetting_top->Realize (); 308 311 309 } 312 } 310 313 311 break; 314 break; 312 } 315 } 313 316 314 default: 317 default: 315 G4Exception 318 G4Exception 316 ("G4OpenGLXmViewer::actions_callback", 319 ("G4OpenGLXmViewer::actions_callback", 317 "opengl2001", FatalException, 320 "opengl2001", FatalException, 318 "Unrecognised widget child of control_c 321 "Unrecognised widget child of control_callback"); 319 } 322 } 320 323 321 return; 324 return; 322 } 325 } 323 326 324 327 325 328 326 void G4OpenGLXmViewer::misc_callback (Widget w 329 void G4OpenGLXmViewer::misc_callback (Widget w, 327 XtPointer clientData, 330 XtPointer clientData, 328 XtPointer) 331 XtPointer) 329 { 332 { 330 G4OpenGLXmViewer* pView; 333 G4OpenGLXmViewer* pView; 331 G4long choice = (G4long)clientData; 334 G4long choice = (G4long)clientData; 332 XtVaGetValues (XtParent(w), 335 XtVaGetValues (XtParent(w), 333 XmNuserData, &pView, 336 XmNuserData, &pView, 334 NULL); 337 NULL); 335 338 336 switch (choice) { 339 switch (choice) { 337 340 338 case 0: 341 case 0: 339 { 342 { 340 343 341 if (!pView->fpmiscellany_top) { 344 if (!pView->fpmiscellany_top) { 342 345 343 std::ostringstream misc_Name; 346 std::ostringstream misc_Name; 344 misc_Name << pView->GetSceneHandler()->GetSc 347 misc_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId; 345 348 346 pView->fpmiscellany_top = new G4OpenGLXmTopL 349 pView->fpmiscellany_top = new G4OpenGLXmTopLevelShell (pView, 347 (char*)misc_Name.str().c_ 350 (char*)misc_Name.str().c_str()); 348 pView->fpwobble_box = new G4OpenGLXmFramedBo 351 pView->fpwobble_box = new G4OpenGLXmFramedBox ("Wobble view", 349 True); 352 True); 350 pView->fpmiscellany_top->AddChild (pView->fp 353 pView->fpmiscellany_top->AddChild (pView->fpwobble_box); 351 354 352 XtCallbackRec* wob_cb_list = new XtCallbackR 355 XtCallbackRec* wob_cb_list = new XtCallbackRec[2]; 353 wob_cb_list[0].callback = wobble_callback; 356 wob_cb_list[0].callback = wobble_callback; 354 wob_cb_list[0].closure = pView; 357 wob_cb_list[0].closure = pView; 355 wob_cb_list[1].callback = NULL; 358 wob_cb_list[1].callback = NULL; 356 359 357 360 358 pView->fpwobble_button = new G4OpenGLXmPushB 361 pView->fpwobble_button = new G4OpenGLXmPushButton ("Wobble", 359 wob_cb_list); 362 wob_cb_list); 360 363 361 XtCallbackRec* wobble_slider_list = new XtCa 364 XtCallbackRec* wobble_slider_list = new XtCallbackRec[2]; 362 wobble_slider_list[0].callback = set_wob_sen 365 wobble_slider_list[0].callback = set_wob_sens_callback; 363 wobble_slider_list[0].closure = pView; 366 wobble_slider_list[0].closure = pView; 364 wobble_slider_list[1].callback = NULL; 367 wobble_slider_list[1].callback = NULL; 365 368 366 pView->fpwobble_slider = new G4OpenGLXmSlide 369 pView->fpwobble_slider = new G4OpenGLXmSliderBar ("Wobble slider", 367 wobble_slider_list, 370 wobble_slider_list, 368 True, 371 True, 369 0, 372 0, 370 pView->wob_sens, 373 pView->wob_sens, 371 pView->wob_high, 374 pView->wob_high, 372 pView->wob_low); 375 pView->wob_low); 373 pView->fpwobble_box->AddChild (pView->fpwobb 376 pView->fpwobble_box->AddChild (pView->fpwobble_button); 374 pView->fpwobble_box->AddChild (pView->fpwobb 377 pView->fpwobble_box->AddChild (pView->fpwobble_slider); 375 378 376 pView->fpreset_box = new G4OpenGLXmFramedBox 379 pView->fpreset_box = new G4OpenGLXmFramedBox ("Reset view", 377 True); 380 True); 378 pView->fpmiscellany_top->AddChild (pView->fp 381 pView->fpmiscellany_top->AddChild (pView->fpreset_box); 379 382 380 XtCallbackRec* rst_cb_list = new XtCallbackR 383 XtCallbackRec* rst_cb_list = new XtCallbackRec[3]; 381 rst_cb_list[0].callback = reset_callback; 384 rst_cb_list[0].callback = reset_callback; 382 rst_cb_list[0].closure = pView; 385 rst_cb_list[0].closure = pView; 383 rst_cb_list[1].callback = update_panels_call 386 rst_cb_list[1].callback = update_panels_callback; 384 rst_cb_list[1].closure = pView; 387 rst_cb_list[1].closure = pView; 385 rst_cb_list[2].callback = NULL; 388 rst_cb_list[2].callback = NULL; 386 389 387 pView->fpreset_button = new G4OpenGLXmPushBu 390 pView->fpreset_button = new G4OpenGLXmPushButton ("Reset", 388 rst_cb_list); 391 rst_cb_list); 389 392 390 pView->fpreset_box->AddChild (pView->fpreset 393 pView->fpreset_box->AddChild (pView->fpreset_button); 391 394 392 pView->fpproj_style_box = new G4OpenGLXmFram 395 pView->fpproj_style_box = new G4OpenGLXmFramedBox ("Projection style", 393 True); 396 True); 394 pView->fpmiscellany_top->AddChild (pView->fp 397 pView->fpmiscellany_top->AddChild (pView->fpproj_style_box); 395 398 396 XtCallbackRec* proj_cb_list = new XtCallback 399 XtCallbackRec* proj_cb_list = new XtCallbackRec[2]; 397 proj_cb_list[0].callback = projection_callba 400 proj_cb_list[0].callback = projection_callback; 398 proj_cb_list[0].closure = pView; 401 proj_cb_list[0].closure = pView; 399 proj_cb_list[1].callback = NULL; 402 proj_cb_list[1].callback = NULL; 400 403 401 pView->fporthogonal_button = new G4OpenGLXmR 404 pView->fporthogonal_button = new G4OpenGLXmRadioButton ("Orthographic", 402 proj_cb_list, 405 proj_cb_list, 403 pView->fVP.GetFieldHalfAngle() 406 pView->fVP.GetFieldHalfAngle() > 0. ? False : True, 404 0); 407 0); 405 408 406 pView->fpperspective_button = new G4OpenGLXm 409 pView->fpperspective_button = new G4OpenGLXmRadioButton ("Perspective", 407 proj_cb_list, 410 proj_cb_list, 408 pView->fVP.GetFieldHalfAngle( 411 pView->fVP.GetFieldHalfAngle() > 0. ? True : False, 409 1); 412 1); 410 413 411 pView->fpfov_text = new G4OpenGLXmTextField 414 pView->fpfov_text = new G4OpenGLXmTextField ("Field of view 0.1 -> 89.5 degrees.", 412 &(pView->fov)); 415 &(pView->fov)); 413 416 414 pView->fpproj_style_box->AddChild (pView->fp 417 pView->fpproj_style_box->AddChild (pView->fpperspective_button); 415 pView->fpproj_style_box->AddChild (pView->fp 418 pView->fpproj_style_box->AddChild (pView->fporthogonal_button); 416 pView->fpproj_style_box->AddChild (pView->fp 419 pView->fpproj_style_box->AddChild (pView->fpfov_text); 417 420 418 pView->fpmiscellany_top->Realize (); 421 pView->fpmiscellany_top->Realize (); 419 422 420 } 423 } 421 424 422 break; 425 break; 423 } 426 } 424 427 425 case 1: 428 case 1: 426 { 429 { 427 G4Xt::getInstance () -> RequireExitSecon 430 G4Xt::getInstance () -> RequireExitSecondaryLoop (OGL_EXIT_CODE); 428 break; 431 break; 429 } 432 } 430 433 431 case 2: 434 case 2: 432 { 435 { 433 if (!pView->fpprint_top) { 436 if (!pView->fpprint_top) { 434 437 435 std::ostringstream print_Name; 438 std::ostringstream print_Name; 436 print_Name << pView->GetSceneHandler()->GetS 439 print_Name << pView->GetSceneHandler()->GetSceneHandlerId() << '-' << pView->fViewId; 437 440 438 pView->fpprint_top = new G4OpenGLXmTopLevelS 441 pView->fpprint_top = new G4OpenGLXmTopLevelShell (pView, 439 (char*)print_Name.str().c_str( 442 (char*)print_Name.str().c_str()); 440 443 441 pView->fpprint_box = new G4OpenGLXmFramedBox 444 pView->fpprint_box = new G4OpenGLXmFramedBox ("Create EPS file of current view", 442 False); 445 False); 443 446 444 pView->fpprint_top->AddChild (pView->fpprint 447 pView->fpprint_top->AddChild (pView->fpprint_box); 445 448 446 pView->fpprint_col_box = new G4OpenGLXmFrame 449 pView->fpprint_col_box = new G4OpenGLXmFramedBox ("Colour choice", 447 True); 450 True); 448 pView->fpprint_top->AddChild (pView->fpprint 451 pView->fpprint_top->AddChild (pView->fpprint_col_box); 449 452 450 XtCallbackRec* prcol_cb_list = new XtCallbac 453 XtCallbackRec* prcol_cb_list = new XtCallbackRec[2]; 451 prcol_cb_list[0].callback = set_print_colour 454 prcol_cb_list[0].callback = set_print_colour_callback; 452 prcol_cb_list[0].closure = pView; 455 prcol_cb_list[0].closure = pView; 453 prcol_cb_list[1].callback = NULL; 456 prcol_cb_list[1].callback = NULL; 454 457 455 pView->fpprint_col_radio1 = new G4OpenGLXmRa 458 pView->fpprint_col_radio1 = new G4OpenGLXmRadioButton ("Black and white", 456 prcol_cb_list, 459 prcol_cb_list, 457 pView->fPrintColour==fals 460 pView->fPrintColour==false ? True : False, 458 0); 461 0); 459 462 460 pView->fpprint_col_radio2 = new G4OpenGLXmRa 463 pView->fpprint_col_radio2 = new G4OpenGLXmRadioButton ("Colour", 461 prcol_cb_list, 464 prcol_cb_list, 462 pView->fPrintColour==true 465 pView->fPrintColour==true ? True : False, 463 1); 466 1); 464 467 465 pView->fpprint_col_box->AddChild (pView->fpp 468 pView->fpprint_col_box->AddChild (pView->fpprint_col_radio1); 466 pView->fpprint_col_box->AddChild (pView->fpp 469 pView->fpprint_col_box->AddChild (pView->fpprint_col_radio2); 467 470 468 pView->fpprint_style_box = new G4OpenGLXmFra 471 pView->fpprint_style_box = new G4OpenGLXmFramedBox ("File type", 469 True); 472 True); 470 pView->fpprint_top->AddChild (pView->fpprint 473 pView->fpprint_top->AddChild (pView->fpprint_style_box); 471 474 472 XtCallbackRec* prsty_cb_list = new XtCallbac 475 XtCallbackRec* prsty_cb_list = new XtCallbackRec[2]; 473 prsty_cb_list[0].callback = set_print_style_ 476 prsty_cb_list[0].callback = set_print_style_callback; 474 prsty_cb_list[0].closure = pView; 477 prsty_cb_list[0].closure = pView; 475 prsty_cb_list[1].callback = NULL; 478 prsty_cb_list[1].callback = NULL; 476 479 477 pView->fpprint_style_radio1 = new G4OpenGLXm 480 pView->fpprint_style_radio1 = new G4OpenGLXmRadioButton ("Screen dump (pixmap)", 478 prsty_cb_list, 481 prsty_cb_list, 479 pView->fVectoredPs==false ? T 482 pView->fVectoredPs==false ? True : False, 480 0); 483 0); 481 484 482 pView->fpprint_style_radio2 = new G4OpenGLXm 485 pView->fpprint_style_radio2 = new G4OpenGLXmRadioButton ("PostScript", 483 prsty_cb_list, 486 prsty_cb_list, 484 pView->fVectoredPs==true ? Tr 487 pView->fVectoredPs==true ? True : False, 485 1); 488 1); 486 489 487 pView->fpprint_style_box->AddChild (pView->f 490 pView->fpprint_style_box->AddChild (pView->fpprint_style_radio1); 488 pView->fpprint_style_box->AddChild (pView->f 491 pView->fpprint_style_box->AddChild (pView->fpprint_style_radio2); 489 492 490 pView->fpprint_text = new G4OpenGLXmTextFiel 493 pView->fpprint_text = new G4OpenGLXmTextField ("Name of .eps file to save", 491 (pView->getRealPrintFilenam 494 (pView->getRealPrintFilename().c_str())); 492 pView->fpprint_box->AddChild (pView->fpprint 495 pView->fpprint_box->AddChild (pView->fpprint_text); 493 496 494 pView->fpprint_line = new G4OpenGLXmSeparato 497 pView->fpprint_line = new G4OpenGLXmSeparator (); 495 pView->fpprint_box->AddChild (pView->fpprint 498 pView->fpprint_box->AddChild (pView->fpprint_line); 496 499 497 XtCallbackRec* pri_cb_list = new XtCallbackR 500 XtCallbackRec* pri_cb_list = new XtCallbackRec[2]; 498 pri_cb_list[0].callback = print_callback; 501 pri_cb_list[0].callback = print_callback; 499 pri_cb_list[0].closure = pView; 502 pri_cb_list[0].closure = pView; 500 pri_cb_list[1].callback = NULL; 503 pri_cb_list[1].callback = NULL; 501 504 502 505 503 pView->fpprint_button = new G4OpenGLXmPushBu 506 pView->fpprint_button = new G4OpenGLXmPushButton ("Create EPS file", 504 pri_cb_list); 507 pri_cb_list); 505 508 506 pView->fpprint_box->AddChild (pView->fpprint 509 pView->fpprint_box->AddChild (pView->fpprint_button); 507 pView->fpprint_top->Realize (); 510 pView->fpprint_top->Realize (); 508 511 509 } 512 } 510 513 511 ///ajw 514 ///ajw 512 break; 515 break; 513 } 516 } 514 517 515 default: 518 default: 516 G4Exception 519 G4Exception 517 ("G4OpenGLXmViewer::misc_callback", 520 ("G4OpenGLXmViewer::misc_callback", 518 "opengl2002", FatalException, 521 "opengl2002", FatalException, 519 "Unrecognised widget child of misc_call 522 "Unrecognised widget child of misc_callback."); 520 } 523 } 521 524 522 return; 525 return; 523 526 524 } 527 } 525 528 526 void G4OpenGLXmViewer::set_wob_sens_callback ( 529 void G4OpenGLXmViewer::set_wob_sens_callback (Widget w, 527 XtPointer clientData, 530 XtPointer clientData, 528 XtPointer callData) 531 XtPointer callData) 529 { 532 { 530 XmScaleCallbackStruct *cbs = (XmScaleCallbac 533 XmScaleCallbackStruct *cbs = (XmScaleCallbackStruct*) callData; 531 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer* 534 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData; 532 short dp = -1; 535 short dp = -1; 533 G4float ten_to_the_dp = 10.; 536 G4float ten_to_the_dp = 10.; 534 537 535 XtVaGetValues (w, 538 XtVaGetValues (w, 536 XmNdecimalPoints, &dp, 539 XmNdecimalPoints, &dp, 537 NULL); 540 NULL); 538 541 539 if (dp == 0) { 542 if (dp == 0) { 540 ten_to_the_dp = 1.; 543 ten_to_the_dp = 1.; 541 } else if ( dp > 0) { 544 } else if ( dp > 0) { 542 for (G4int i = 1; i < (G4int)dp; i++) { 545 for (G4int i = 1; i < (G4int)dp; i++) { 543 ten_to_the_dp *= 10.; 546 ten_to_the_dp *= 10.; 544 } 547 } 545 } else { 548 } else { 546 G4Exception 549 G4Exception 547 ("G4OpenGLXmViewer::set_wob_sens_callbac 550 ("G4OpenGLXmViewer::set_wob_sens_callback", 548 "opengl2003", FatalException, 551 "opengl2003", FatalException, 549 "Bad value returned for dp in set_rot_s 552 "Bad value returned for dp in set_rot_sens_callback"); 550 } 553 } 551 554 552 pView->wob_sens = (G4float)(cbs->value) / te 555 pView->wob_sens = (G4float)(cbs->value) / ten_to_the_dp; 553 } 556 } 554 557 555 void G4OpenGLXmViewer::update_panels_callback 558 void G4OpenGLXmViewer::update_panels_callback (Widget, 556 XtPointer clientData, 559 XtPointer clientData, 557 XtPointer) 560 XtPointer) 558 { 561 { 559 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer* 562 G4OpenGLXmViewer* pView = (G4OpenGLXmViewer*) clientData; 560 563 561 if (pView->fppanning_slider) { 564 if (pView->fppanning_slider) { 562 pView->fppanning_slider->SetMaxValue (pVie 565 pView->fppanning_slider->SetMaxValue (pView->pan_sens_limit); 563 } 566 } 564 if (pView->fprotation_slider) { 567 if (pView->fprotation_slider) { 565 pView->fprotation_slider->SetMaxValue (pVi 568 pView->fprotation_slider->SetMaxValue (pView->rot_sens_limit); 566 } 569 } 567 570 568 if (pView->fpzoom_slider) { 571 if (pView->fpzoom_slider) { 569 pView->fpzoom_slider->SetMaxValue (pView-> 572 pView->fpzoom_slider->SetMaxValue (pView->zoom_high); 570 pView->fpzoom_slider->SetMinValue (pView-> 573 pView->fpzoom_slider->SetMinValue (pView->zoom_low); 571 pView->fpzoom_slider->SetInitialValue (pVi 574 pView->fpzoom_slider->SetInitialValue (pView->fVP.GetZoomFactor()); 572 } 575 } 573 576 574 if (pView->fpdolly_slider) { 577 if (pView->fpdolly_slider) { 575 pView->fpdolly_slider->SetMaxValue (pView- 578 pView->fpdolly_slider->SetMaxValue (pView->dolly_high); 576 pView->fpdolly_slider->SetMinValue (pView- 579 pView->fpdolly_slider->SetMinValue (pView->dolly_low); 577 } 580 } 578 } 581 } >> 582 >> 583 #endif 579 584