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