[529] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: G4OpenGLXmViewer.hh,v 1.10 2006/06/29 21:18:52 gunter Exp $ |
---|
[850] | 28 | // GEANT4 tag $Name: HEAD $ |
---|
[529] | 29 | // |
---|
| 30 | // |
---|
| 31 | // Andrew Walkden 10th February 1997 |
---|
| 32 | // G4OpenGLXmViewer : Class derived from G4OpenGLXViewer, to provide |
---|
| 33 | // (Motif) widget OpenGL functionality for GEANT4. |
---|
| 34 | |
---|
| 35 | #ifdef G4VIS_BUILD_OPENGLXM_DRIVER |
---|
| 36 | |
---|
| 37 | #ifndef G4OPENGLXMVIEWER_HH |
---|
| 38 | #define G4OPENGLXMVIEWER_HH |
---|
| 39 | |
---|
| 40 | #include "G4OpenGLXViewer.hh" |
---|
| 41 | #include "globals.hh" |
---|
| 42 | |
---|
| 43 | #include <Xm/Xm.h> |
---|
| 44 | #include <Xm/MainW.h> |
---|
| 45 | #include <Xm/Label.h> |
---|
| 46 | #include <Xm/Form.h> |
---|
| 47 | #include <Xm/RowColumn.h> |
---|
| 48 | #include <Xm/PushB.h> |
---|
| 49 | #include <Xm/ToggleB.h> |
---|
| 50 | #include <Xm/ArrowBG.h> |
---|
| 51 | #include <Xm/CascadeB.h> |
---|
| 52 | #include <Xm/DrawingA.h> |
---|
| 53 | #include <Xm/Frame.h> |
---|
| 54 | #include <X11/keysym.h> |
---|
| 55 | #include <Xm/XmStrDefs.h> |
---|
| 56 | #include <X11/Xmu/StdCmap.h> |
---|
| 57 | #include <Xm/TextF.h> |
---|
| 58 | #include <Xm/ToggleB.h> |
---|
| 59 | #include <X11/Shell.h> |
---|
| 60 | #include <Xm/Separator.h> |
---|
| 61 | #include <Xm/Scale.h> |
---|
| 62 | |
---|
| 63 | class G4OpenGLXmTopLevelShell; |
---|
| 64 | class G4OpenGLXmRadioButton; |
---|
| 65 | class G4OpenGLXmPushButton; |
---|
| 66 | class G4OpenGLXmSliderBar; |
---|
| 67 | class G4OpenGLXmBox; |
---|
| 68 | class G4OpenGLXmTextField; |
---|
| 69 | class G4OpenGLXmFramedBox; |
---|
| 70 | class G4OpenGLXmFourArrowButtons; |
---|
| 71 | class G4OpenGLXmSeparator; |
---|
| 72 | |
---|
| 73 | class G4OpenGLXmViewer: public G4OpenGLXViewer { |
---|
| 74 | |
---|
| 75 | public: |
---|
| 76 | G4OpenGLXmViewer (G4OpenGLSceneHandler& scene); |
---|
| 77 | virtual ~G4OpenGLXmViewer (); |
---|
| 78 | |
---|
| 79 | protected: |
---|
| 80 | virtual void ShowView (); |
---|
| 81 | void GetXmConnection (); |
---|
| 82 | virtual void CreateMainWindow (); |
---|
| 83 | |
---|
| 84 | XtAppContext app; |
---|
| 85 | XtWorkProcId workId; |
---|
| 86 | Widget toplevel, |
---|
| 87 | shell, |
---|
| 88 | main_win, |
---|
| 89 | menubar, |
---|
| 90 | style_cascade, |
---|
| 91 | actions_cascade, |
---|
| 92 | misc_cascade, |
---|
| 93 | spec_cascade, |
---|
| 94 | rep_style_pullright, |
---|
| 95 | drawing_style_pullright, |
---|
| 96 | background_color_pullright, |
---|
| 97 | transparency_pullright, |
---|
| 98 | antialias_pullright, |
---|
| 99 | haloing_pullright, |
---|
| 100 | aux_edge_pullright, |
---|
| 101 | frame, |
---|
| 102 | glxarea; |
---|
| 103 | |
---|
| 104 | XmString style_str, |
---|
| 105 | actions_str, |
---|
| 106 | misc_str, |
---|
| 107 | spec_str, |
---|
| 108 | rep_str, |
---|
| 109 | draw_str, |
---|
| 110 | polyhedron_str, |
---|
| 111 | nurbs_str, |
---|
| 112 | wireframe_str, |
---|
| 113 | hlr_str, |
---|
| 114 | hsr_str, |
---|
| 115 | hlhsr_str, |
---|
| 116 | set_str, |
---|
| 117 | rot_str, |
---|
| 118 | pan_str, |
---|
| 119 | exit_str, |
---|
| 120 | quit_str, |
---|
| 121 | print_str, |
---|
| 122 | white_str, |
---|
| 123 | black_str, |
---|
| 124 | anti_str, |
---|
| 125 | trans_str, |
---|
| 126 | halo_str, |
---|
| 127 | aux_edge_str, |
---|
| 128 | bgnd_str, |
---|
| 129 | off_str, |
---|
| 130 | on_str; |
---|
| 131 | |
---|
| 132 | G4double zoom_high, |
---|
| 133 | zoom_low, |
---|
| 134 | pan_low, |
---|
| 135 | pan_high, |
---|
| 136 | dolly_low, |
---|
| 137 | dolly_high, |
---|
| 138 | fov, |
---|
| 139 | rot_sens_limit, |
---|
| 140 | pan_sens_limit, |
---|
| 141 | rot_sens, |
---|
| 142 | pan_sens, |
---|
| 143 | wob_sens; |
---|
| 144 | |
---|
| 145 | Pixel bgnd, |
---|
| 146 | borcol; |
---|
| 147 | |
---|
| 148 | G4bool pan_right, |
---|
| 149 | rotate_right, |
---|
| 150 | pan_up, |
---|
| 151 | rotate_up; |
---|
| 152 | |
---|
| 153 | XtIntervalId rotation_timer, |
---|
| 154 | pan_timer, |
---|
| 155 | wobble_timer; |
---|
| 156 | |
---|
| 157 | G4Vector3D original_vp; |
---|
| 158 | |
---|
| 159 | G4int frameNo; |
---|
| 160 | |
---|
| 161 | G4OpenGLXmTopLevelShell* fprotation_top; |
---|
| 162 | G4OpenGLXmBox* fprotation_button_box; |
---|
| 163 | G4OpenGLXmRadioButton* fprotation_button1; |
---|
| 164 | G4OpenGLXmRadioButton* fprotation_button2; |
---|
| 165 | G4OpenGLXmBox* fprotation_slider_box; |
---|
| 166 | G4OpenGLXmSliderBar* fprotation_slider; |
---|
| 167 | G4OpenGLXmBox* fprotation_arrow_box; |
---|
| 168 | G4OpenGLXmFourArrowButtons* fprotation_arrow; |
---|
| 169 | |
---|
| 170 | G4OpenGLXmTopLevelShell* fppanning_top; |
---|
| 171 | G4OpenGLXmFramedBox* fppanning_box; |
---|
| 172 | G4OpenGLXmFourArrowButtons* fppanning_arrows; |
---|
| 173 | G4OpenGLXmSliderBar* fppanning_slider; |
---|
| 174 | G4OpenGLXmFramedBox* fpzoom_box; |
---|
| 175 | G4OpenGLXmSliderBar* fpzoom_slider; |
---|
| 176 | G4OpenGLXmFramedBox* fpdolly_box; |
---|
| 177 | G4OpenGLXmSliderBar* fpdolly_slider; |
---|
| 178 | |
---|
| 179 | G4OpenGLXmTopLevelShell* fpsetting_top; |
---|
| 180 | G4OpenGLXmFramedBox* fpsetting_box; |
---|
| 181 | G4OpenGLXmTextField* fppan_set; |
---|
| 182 | G4OpenGLXmTextField* fprot_set; |
---|
| 183 | G4OpenGLXmTextField* fpzoom_upper; |
---|
| 184 | G4OpenGLXmTextField* fpzoom_lower; |
---|
| 185 | G4OpenGLXmTextField* fpdolly_upper; |
---|
| 186 | G4OpenGLXmTextField* fpdolly_lower; |
---|
| 187 | G4OpenGLXmPushButton* fpok_button; |
---|
| 188 | |
---|
| 189 | G4OpenGLXmTopLevelShell* fpmiscellany_top; |
---|
| 190 | G4OpenGLXmFramedBox* fpwobble_box; |
---|
| 191 | G4OpenGLXmPushButton* fpwobble_button; |
---|
| 192 | G4OpenGLXmSliderBar* fpwobble_slider; |
---|
| 193 | G4OpenGLXmFramedBox* fpreset_box; |
---|
| 194 | G4OpenGLXmPushButton* fpreset_button; |
---|
| 195 | G4OpenGLXmFramedBox* fpproj_style_box; |
---|
| 196 | G4OpenGLXmRadioButton* fporthogonal_button; |
---|
| 197 | G4OpenGLXmRadioButton* fpperspective_button; |
---|
| 198 | G4OpenGLXmTextField* fpfov_text; |
---|
| 199 | |
---|
| 200 | G4OpenGLXmTopLevelShell* fpprint_top; |
---|
| 201 | G4OpenGLXmFramedBox* fpprint_box; |
---|
| 202 | G4OpenGLXmFramedBox* fpprint_col_box; |
---|
| 203 | G4OpenGLXmFramedBox* fpprint_style_box; |
---|
| 204 | G4OpenGLXmTextField* fpprint_text; |
---|
| 205 | G4OpenGLXmPushButton* fpprint_button; |
---|
| 206 | G4OpenGLXmSeparator* fpprint_line; |
---|
| 207 | G4OpenGLXmRadioButton* fpprint_col_radio1; |
---|
| 208 | G4OpenGLXmRadioButton* fpprint_col_radio2; |
---|
| 209 | G4OpenGLXmRadioButton* fpprint_style_radio1; |
---|
| 210 | G4OpenGLXmRadioButton* fpprint_style_radio2; |
---|
| 211 | |
---|
| 212 | public: |
---|
| 213 | |
---|
| 214 | static void expose_callback (Widget w, |
---|
| 215 | XtPointer clientData, |
---|
| 216 | XtPointer callData); |
---|
| 217 | |
---|
| 218 | static void resize_callback (Widget w, |
---|
| 219 | XtPointer clientData, |
---|
| 220 | XtPointer callData); |
---|
| 221 | |
---|
| 222 | static void actions_callback (Widget w, |
---|
| 223 | XtPointer clientData, |
---|
| 224 | XtPointer callData); |
---|
| 225 | |
---|
| 226 | static void misc_callback (Widget w, |
---|
| 227 | XtPointer clientData, |
---|
| 228 | XtPointer callData); |
---|
| 229 | |
---|
| 230 | static void Add_set_field (char* widget, |
---|
| 231 | char* widget_text, |
---|
| 232 | Widget* row_col_box, |
---|
| 233 | Widget* wid, |
---|
| 234 | G4double* val, |
---|
| 235 | G4OpenGLXmViewer* pView); |
---|
| 236 | |
---|
| 237 | static void zoom_callback (Widget w, |
---|
| 238 | XtPointer clientData, |
---|
| 239 | XtPointer callData); |
---|
| 240 | |
---|
| 241 | static void dolly_callback (Widget w, |
---|
| 242 | XtPointer clientData, |
---|
| 243 | XtPointer callData); |
---|
| 244 | |
---|
| 245 | static void pan_left_right_callback (Widget w, |
---|
| 246 | XtPointer clientData, |
---|
| 247 | XtPointer callData); |
---|
| 248 | |
---|
| 249 | static void left_right_pan_callback (XtPointer clientData, |
---|
| 250 | XtIntervalId* timer_id); |
---|
| 251 | |
---|
| 252 | static void theta_rotation_callback (Widget w, |
---|
| 253 | XtPointer clientData, |
---|
| 254 | XtPointer callData); |
---|
| 255 | |
---|
| 256 | static void phi_rotation_callback (Widget w, |
---|
| 257 | XtPointer clientData, |
---|
| 258 | XtPointer callData); |
---|
| 259 | |
---|
| 260 | static void pan_up_down_callback (Widget w, |
---|
| 261 | XtPointer clientData, |
---|
| 262 | XtPointer callData); |
---|
| 263 | |
---|
| 264 | static void up_down_pan_callback (XtPointer clientData, |
---|
| 265 | XtIntervalId* timer_id); |
---|
| 266 | |
---|
| 267 | static void drawing_style_callback (Widget w, |
---|
| 268 | XtPointer clientData, |
---|
| 269 | XtPointer callData); |
---|
| 270 | |
---|
| 271 | static void rep_style_callback (Widget w, |
---|
| 272 | XtPointer clientData, |
---|
| 273 | XtPointer callData); |
---|
| 274 | |
---|
| 275 | static void background_color_callback (Widget w, |
---|
| 276 | XtPointer clientData, |
---|
| 277 | XtPointer callData); |
---|
| 278 | |
---|
| 279 | static void set_rot_subject_callback (Widget w, |
---|
| 280 | XtPointer clientData, |
---|
| 281 | XtPointer callData); |
---|
| 282 | |
---|
| 283 | static void set_rot_sens_callback (Widget w, |
---|
| 284 | XtPointer clientData, |
---|
| 285 | XtPointer callData); |
---|
| 286 | |
---|
| 287 | static void set_pan_sens_callback (Widget w, |
---|
| 288 | XtPointer clientData, |
---|
| 289 | XtPointer callData); |
---|
| 290 | |
---|
| 291 | static void set_wob_sens_callback (Widget w, |
---|
| 292 | XtPointer clientData, |
---|
| 293 | XtPointer callData); |
---|
| 294 | |
---|
| 295 | static void projection_callback (Widget w, |
---|
| 296 | XtPointer clientData, |
---|
| 297 | XtPointer callData); |
---|
| 298 | |
---|
| 299 | static void wobble_callback (Widget w, |
---|
| 300 | XtPointer clientData, |
---|
| 301 | XtPointer callData); |
---|
| 302 | |
---|
| 303 | static void reset_callback (Widget w, |
---|
| 304 | XtPointer clientData, |
---|
| 305 | XtPointer callData); |
---|
| 306 | |
---|
| 307 | static void update_panels_callback (Widget w, |
---|
| 308 | XtPointer clientData, |
---|
| 309 | XtPointer callData); |
---|
| 310 | |
---|
| 311 | static void wobble_timer_callback (XtPointer clientData, |
---|
| 312 | XtIntervalId* timerid); |
---|
| 313 | |
---|
| 314 | static void Add_radio_box (char* label_string, |
---|
| 315 | Widget* parent_frame_widget, |
---|
| 316 | XtCallbackRec* radio_box_cb, |
---|
| 317 | G4int num_buttons, |
---|
| 318 | G4int default_button, |
---|
| 319 | char* radio_box_name, |
---|
| 320 | char** button_names, |
---|
| 321 | G4OpenGLXmViewer* pView); |
---|
| 322 | |
---|
| 323 | static void Add_four_arrow_buttons (G4OpenGLXmViewer* pView, |
---|
| 324 | XtCallbackRec** arrow_callbacks, |
---|
| 325 | Widget* parent_widget); |
---|
| 326 | |
---|
| 327 | static void Add_slider_box (char* label_string, |
---|
| 328 | G4int num_sliders, |
---|
| 329 | char** slider_name, |
---|
| 330 | G4OpenGLXmViewer* pView, |
---|
| 331 | G4double* min_array, |
---|
| 332 | G4double* max_array, |
---|
| 333 | G4double* value_array, |
---|
| 334 | G4bool* show, |
---|
| 335 | short* decimals, |
---|
| 336 | unsigned char* orientation, |
---|
| 337 | unsigned char* direction, |
---|
| 338 | XtCallbackRec** slider_box_cb, |
---|
| 339 | Widget* parent_frame_widget); |
---|
| 340 | |
---|
| 341 | static void rotate_in_theta (XtPointer clientData, |
---|
| 342 | XtIntervalId* timer_id); |
---|
| 343 | |
---|
| 344 | static void rotate_in_phi (XtPointer clientData, |
---|
| 345 | XtIntervalId* timer_id); |
---|
| 346 | |
---|
| 347 | static void get_double_value_callback (Widget w, |
---|
| 348 | XtPointer clientData, |
---|
| 349 | XtPointer callData); |
---|
| 350 | |
---|
| 351 | static void get_text_callback (Widget w, |
---|
| 352 | XtPointer clientData, |
---|
| 353 | XtPointer callData); |
---|
| 354 | |
---|
| 355 | static void transparency_callback (Widget w, |
---|
| 356 | XtPointer clientData, |
---|
| 357 | XtPointer callData); |
---|
| 358 | |
---|
| 359 | static void antialias_callback (Widget w, |
---|
| 360 | XtPointer clientData, |
---|
| 361 | XtPointer callData); |
---|
| 362 | |
---|
| 363 | static void haloing_callback (Widget w, |
---|
| 364 | XtPointer clientData, |
---|
| 365 | XtPointer callData); |
---|
| 366 | |
---|
| 367 | static void aux_edge_callback (Widget w, |
---|
| 368 | XtPointer clientData, |
---|
| 369 | XtPointer callData); |
---|
| 370 | |
---|
| 371 | static void set_print_colour_callback (Widget w, |
---|
| 372 | XtPointer clientData, |
---|
| 373 | XtPointer callData); |
---|
| 374 | |
---|
| 375 | static void set_print_style_callback (Widget w, |
---|
| 376 | XtPointer clientData, |
---|
| 377 | XtPointer callData); |
---|
| 378 | |
---|
| 379 | static void print_callback (Widget w, |
---|
| 380 | XtPointer clientData, |
---|
| 381 | XtPointer callData); |
---|
| 382 | |
---|
| 383 | static G4bool get_boolean_userData (Widget w); |
---|
| 384 | |
---|
| 385 | static G4int get_int_userData (Widget w); |
---|
| 386 | |
---|
| 387 | friend class G4OpenGLXmVWidgetObject; |
---|
| 388 | friend class G4OpenGLXmViewerMessenger; |
---|
| 389 | |
---|
| 390 | private: |
---|
| 391 | G4OpenGLXmViewer (const G4OpenGLXmViewer&); |
---|
| 392 | G4OpenGLXmViewer& operator = (const G4OpenGLXmViewer&); |
---|
| 393 | |
---|
| 394 | }; |
---|
| 395 | |
---|
| 396 | #endif |
---|
| 397 | |
---|
| 398 | #endif |
---|
| 399 | |
---|