Geant4 Cross Reference |
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 // 28 // 29 // Andrew Walkden 10th February 1997 30 // G4OpenGLXmViewer : Class derived from G4OpenGLXViewer, to provide 31 // (Motif) widget OpenGL functionality for GEANT4. 32 33 #ifndef G4OPENGLXMVIEWER_HH 34 #define G4OPENGLXMVIEWER_HH 35 36 #include "G4OpenGLXViewer.hh" 37 #include "globals.hh" 38 39 #include <Xm/Xm.h> 40 41 class G4OpenGLXmTopLevelShell; 42 class G4OpenGLXmRadioButton; 43 class G4OpenGLXmPushButton; 44 class G4OpenGLXmSliderBar; 45 class G4OpenGLXmBox; 46 class G4OpenGLXmTextField; 47 class G4OpenGLXmFramedBox; 48 class G4OpenGLXmFourArrowButtons; 49 class G4OpenGLXmSeparator; 50 51 class G4OpenGLXmViewer: public G4OpenGLXViewer { 52 53 public: 54 G4OpenGLXmViewer (G4OpenGLSceneHandler& scene); 55 virtual ~G4OpenGLXmViewer (); 56 57 protected: 58 virtual void ShowView (); 59 void ResetView (); 60 void GetXmConnection (); 61 virtual void CreateMainWindow (); 62 63 XtAppContext app; 64 XtWorkProcId workId; 65 Widget toplevel, 66 shell, 67 main_win, 68 menubar, 69 style_cascade, 70 actions_cascade, 71 misc_cascade, 72 spec_cascade, 73 drawing_style_pullright, 74 background_color_pullright, 75 transparency_pullright, 76 antialias_pullright, 77 haloing_pullright, 78 aux_edge_pullright, 79 frame, 80 glxarea; 81 82 XmString style_str, 83 actions_str, 84 misc_str, 85 spec_str, 86 draw_str, 87 polyhedron_str, 88 wireframe_str, 89 hlr_str, 90 hsr_str, 91 hlhsr_str, 92 set_str, 93 rot_str, 94 pan_str, 95 exit_str, 96 quit_str, 97 print_str, 98 white_str, 99 black_str, 100 anti_str, 101 trans_str, 102 halo_str, 103 aux_edge_str, 104 bgnd_str, 105 off_str, 106 on_str; 107 108 G4double zoom_high, 109 zoom_low, 110 pan_low, 111 pan_high, 112 dolly_low, 113 dolly_high, 114 fov, 115 rot_sens_limit, 116 pan_sens_limit, 117 wob_high, 118 wob_low, 119 wob_sens; 120 121 Pixel bgnd, 122 borcol; 123 124 G4bool pan_right, 125 rotate_right, 126 pan_up, 127 rotate_up; 128 129 XtIntervalId rotation_timer, 130 pan_timer, 131 wobble_timer; 132 133 G4Vector3D original_vp; 134 135 G4int frameNo; 136 static const G4String e_str; 137 G4String menu_str[37] = { "Style", "style", 138 "Actions", "actions", 139 "Miscellany", "miscellany", 140 "Special", "special", 141 "menubar", "Drawing", 142 "Background color", "Wireframe", 143 "Hidden line removal", "Hidden surface removal", 144 "Hidden line and surface removal", "drawing_style", 145 "White", "Black", 146 "background_color", "Rotation control panel", 147 "Panning control panel", "Set control panel limits", 148 "Miscellany control panel", 149 "Exit to G4Vis>", "Create .eps file", 150 "Transparency", "transparency", 151 "Antialiasing", "antialias", 152 "Haloing", "haloing", 153 "Auxiliary edges", "aux_edge", 154 "Off", "On", "frame", "glxarea" }; 155 156 G4OpenGLXmTopLevelShell* fprotation_top; 157 G4OpenGLXmBox* fprotation_button_box; 158 G4OpenGLXmRadioButton* fprotation_button1; 159 G4OpenGLXmRadioButton* fprotation_button2; 160 G4OpenGLXmBox* fprotation_slider_box; 161 G4OpenGLXmSliderBar* fprotation_slider; 162 G4OpenGLXmBox* fprotation_arrow_box; 163 G4OpenGLXmFourArrowButtons* fprotation_arrow; 164 165 G4OpenGLXmTopLevelShell* fppanning_top; 166 G4OpenGLXmFramedBox* fppanning_box; 167 G4OpenGLXmFourArrowButtons* fppanning_arrows; 168 G4OpenGLXmSliderBar* fppanning_slider; 169 G4OpenGLXmFramedBox* fpzoom_box; 170 G4OpenGLXmSliderBar* fpzoom_slider; 171 G4OpenGLXmFramedBox* fpdolly_box; 172 G4OpenGLXmSliderBar* fpdolly_slider; 173 174 G4OpenGLXmTopLevelShell* fpsetting_top; 175 G4OpenGLXmFramedBox* fpsetting_box; 176 G4OpenGLXmTextField* fppan_set; 177 G4OpenGLXmTextField* fprot_set; 178 G4OpenGLXmTextField* fpzoom_upper; 179 G4OpenGLXmTextField* fpzoom_lower; 180 G4OpenGLXmTextField* fpdolly_upper; 181 G4OpenGLXmTextField* fpdolly_lower; 182 G4OpenGLXmPushButton* fpok_button; 183 184 G4OpenGLXmTopLevelShell* fpmiscellany_top; 185 G4OpenGLXmFramedBox* fpwobble_box; 186 G4OpenGLXmPushButton* fpwobble_button; 187 G4OpenGLXmSliderBar* fpwobble_slider; 188 G4OpenGLXmFramedBox* fpreset_box; 189 G4OpenGLXmPushButton* fpreset_button; 190 G4OpenGLXmFramedBox* fpproj_style_box; 191 G4OpenGLXmRadioButton* fporthogonal_button; 192 G4OpenGLXmRadioButton* fpperspective_button; 193 G4OpenGLXmTextField* fpfov_text; 194 195 G4OpenGLXmTopLevelShell* fpprint_top; 196 G4OpenGLXmFramedBox* fpprint_box; 197 G4OpenGLXmFramedBox* fpprint_col_box; 198 G4OpenGLXmFramedBox* fpprint_style_box; 199 G4OpenGLXmTextField* fpprint_text; 200 G4OpenGLXmPushButton* fpprint_button; 201 G4OpenGLXmSeparator* fpprint_line; 202 G4OpenGLXmRadioButton* fpprint_col_radio1; 203 G4OpenGLXmRadioButton* fpprint_col_radio2; 204 G4OpenGLXmRadioButton* fpprint_style_radio1; 205 G4OpenGLXmRadioButton* fpprint_style_radio2; 206 207 public: 208 209 static void expose_callback (Widget w, 210 XtPointer clientData, 211 XtPointer callData); 212 213 static void resize_callback (Widget w, 214 XtPointer clientData, 215 XtPointer callData); 216 217 static void actions_callback (Widget w, 218 XtPointer clientData, 219 XtPointer callData); 220 221 static void misc_callback (Widget w, 222 XtPointer clientData, 223 XtPointer callData); 224 225 static void Add_set_field (char* widget, 226 char* widget_text, 227 Widget* row_col_box, 228 Widget* wid, 229 G4double* val, 230 G4OpenGLXmViewer* pView); 231 232 static void zoom_callback (Widget w, 233 XtPointer clientData, 234 XtPointer callData); 235 236 static void dolly_callback (Widget w, 237 XtPointer clientData, 238 XtPointer callData); 239 240 static void pan_left_right_callback (Widget w, 241 XtPointer clientData, 242 XtPointer callData); 243 244 static void left_right_pan_callback (XtPointer clientData, 245 XtIntervalId* timer_id); 246 247 static void theta_rotation_callback (Widget w, 248 XtPointer clientData, 249 XtPointer callData); 250 251 static void phi_rotation_callback (Widget w, 252 XtPointer clientData, 253 XtPointer callData); 254 255 static void pan_up_down_callback (Widget w, 256 XtPointer clientData, 257 XtPointer callData); 258 259 static void up_down_pan_callback (XtPointer clientData, 260 XtIntervalId* timer_id); 261 262 static void drawing_style_callback (Widget w, 263 XtPointer clientData, 264 XtPointer callData); 265 266 static void background_color_callback (Widget w, 267 XtPointer clientData, 268 XtPointer callData); 269 270 static void set_rot_subject_callback (Widget w, 271 XtPointer clientData, 272 XtPointer callData); 273 274 static void set_rot_sens_callback (Widget w, 275 XtPointer clientData, 276 XtPointer callData); 277 278 static void set_pan_sens_callback (Widget w, 279 XtPointer clientData, 280 XtPointer callData); 281 282 static void set_wob_sens_callback (Widget w, 283 XtPointer clientData, 284 XtPointer callData); 285 286 static void projection_callback (Widget w, 287 XtPointer clientData, 288 XtPointer callData); 289 290 static void wobble_callback (Widget w, 291 XtPointer clientData, 292 XtPointer callData); 293 294 static void reset_callback (Widget w, 295 XtPointer clientData, 296 XtPointer callData); 297 298 static void update_panels_callback (Widget w, 299 XtPointer clientData, 300 XtPointer callData); 301 302 static void wobble_timer_callback (XtPointer clientData, 303 XtIntervalId* timerid); 304 305 static void Add_radio_box (char* label_string, 306 Widget* parent_frame_widget, 307 XtCallbackRec* radio_box_cb, 308 G4int num_buttons, 309 G4int default_button, 310 char* radio_box_name, 311 char** button_names, 312 G4OpenGLXmViewer* pView); 313 314 static void Add_four_arrow_buttons (G4OpenGLXmViewer* pView, 315 XtCallbackRec** arrow_callbacks, 316 Widget* parent_widget); 317 318 static void Add_slider_box (char* label_string, 319 G4int num_sliders, 320 char** slider_name, 321 G4OpenGLXmViewer* pView, 322 G4double* min_array, 323 G4double* max_array, 324 G4double* value_array, 325 G4bool* show, 326 short* decimals, 327 unsigned char* orientation, 328 unsigned char* direction, 329 XtCallbackRec** slider_box_cb, 330 Widget* parent_frame_widget); 331 332 static void rotate_in_theta (XtPointer clientData, 333 XtIntervalId* timer_id); 334 335 static void rotate_in_phi (XtPointer clientData, 336 XtIntervalId* timer_id); 337 338 static void get_double_value_callback (Widget w, 339 XtPointer clientData, 340 XtPointer callData); 341 342 static void get_text_callback (Widget w, 343 XtPointer clientData, 344 XtPointer callData); 345 346 static void transparency_callback (Widget w, 347 XtPointer clientData, 348 XtPointer callData); 349 350 static void antialias_callback (Widget w, 351 XtPointer clientData, 352 XtPointer callData); 353 354 static void haloing_callback (Widget w, 355 XtPointer clientData, 356 XtPointer callData); 357 358 static void aux_edge_callback (Widget w, 359 XtPointer clientData, 360 XtPointer callData); 361 362 static void set_print_colour_callback (Widget w, 363 XtPointer clientData, 364 XtPointer callData); 365 366 static void set_print_style_callback (Widget w, 367 XtPointer clientData, 368 XtPointer callData); 369 370 static void print_callback (Widget w, 371 XtPointer clientData, 372 XtPointer callData); 373 374 static G4bool get_boolean_userData (Widget w); 375 376 static G4int get_int_userData (Widget w); 377 378 friend class G4OpenGLXmVWidgetObject; 379 friend class G4OpenGLXmViewerMessenger; 380 381 private: 382 G4OpenGLXmViewer (const G4OpenGLXmViewer&); 383 G4OpenGLXmViewer& operator = (const G4OpenGLXmViewer&); 384 void UpdateControlPanel(); 385 // Update the content of the control panel 386 }; 387 388 #endif 389 390