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$ 27 // 28 // 28 // 29 // 29 // Andrew Walkden 10th February 1997 30 // Andrew Walkden 10th February 1997 30 // G4OpenGLXmViewer : Class derived from G4Ope 31 // G4OpenGLXmViewer : Class derived from G4OpenGLXViewer, to provide 31 // (Motif) widget OpenGL func 32 // (Motif) widget OpenGL functionality for GEANT4. 32 33 >> 34 #ifdef G4VIS_BUILD_OPENGLXM_DRIVER >> 35 33 #include "globals.hh" 36 #include "globals.hh" 34 37 35 #include "G4OpenGLXmViewer.hh" 38 #include "G4OpenGLXmViewer.hh" 36 #include "G4OpenGLSceneHandler.hh" 39 #include "G4OpenGLSceneHandler.hh" 37 40 38 #include "G4VisExtent.hh" 41 #include "G4VisExtent.hh" 39 #include "G4LogicalVolume.hh" 42 #include "G4LogicalVolume.hh" 40 #include "G4VSolid.hh" 43 #include "G4VSolid.hh" 41 #include "G4Point3D.hh" 44 #include "G4Point3D.hh" 42 #include "G4Normal3D.hh" 45 #include "G4Normal3D.hh" 43 46 44 #include "G4Scene.hh" 47 #include "G4Scene.hh" 45 48 46 #include "G4OpenGLXmSliderBar.hh" 49 #include "G4OpenGLXmSliderBar.hh" 47 #include "G4OpenGLXmTextField.hh" 50 #include "G4OpenGLXmTextField.hh" 48 51 49 #include "G4Xt.hh" 52 #include "G4Xt.hh" 50 #include <X11/Shell.h> 53 #include <X11/Shell.h> 51 #include <Xm/MainW.h> 54 #include <Xm/MainW.h> 52 #include <Xm/Frame.h> 55 #include <Xm/Frame.h> 53 #include <Xm/DrawingA.h> 56 #include <Xm/DrawingA.h> 54 57 55 #include <sstream> 58 #include <sstream> 56 59 57 void G4OpenGLXmViewer::ShowView () { 60 void G4OpenGLXmViewer::ShowView () { 58 61 59 // glXWaitGL (); //Wait for effects of all pr << 60 //be propagated before progres << 61 // JA: Commented out July 2021 - slows renderi << 62 // don't see any adverse effects. << 63 << 64 glFlush (); << 65 << 66 G4Xt::getInstance () -> SecondaryLoop (); 62 G4Xt::getInstance () -> SecondaryLoop (); 67 63 68 } 64 } 69 65 70 void G4OpenGLXmViewer::ResetView () { 66 void G4OpenGLXmViewer::ResetView () { 71 // reset global parameters 67 // reset global parameters 72 G4OpenGLViewer::ResetView(); 68 G4OpenGLViewer::ResetView(); 73 69 74 //reset Xm parameteres 70 //reset Xm parameteres 75 zoom_high = fVP.GetZoomFactor() * 10.0; 71 zoom_high = fVP.GetZoomFactor() * 10.0; 76 zoom_low = fVP.GetZoomFactor() / 10.0; 72 zoom_low = fVP.GetZoomFactor() / 10.0; 77 rot_sens_limit = 90.; 73 rot_sens_limit = 90.; 78 wob_low = 0.; 74 wob_low = 0.; 79 wob_high = 50.; 75 wob_high = 50.; 80 wob_sens = 20.; 76 wob_sens = 20.; 81 77 82 bool firstInit = true; 78 bool firstInit = true; 83 if (GetSceneHandler() != NULL) { 79 if (GetSceneHandler() != NULL) { 84 if (GetSceneHandler()->GetScene() != NULL) 80 if (GetSceneHandler()->GetScene() != NULL) { 85 firstInit = false; 81 firstInit = false; 86 } 82 } 87 } 83 } 88 if (firstInit) { 84 if (firstInit) { 89 pan_sens_limit = 100.; 85 pan_sens_limit = 100.; 90 fPan_sens = pan_sens_limit / 10.0; 86 fPan_sens = pan_sens_limit / 10.0; 91 dolly_low = fVP.GetDolly() - 1000.0; 87 dolly_low = fVP.GetDolly() - 1000.0; 92 dolly_high = fVP.GetDolly() + 1000.0; 88 dolly_high = fVP.GetDolly() + 1000.0; 93 } else { 89 } else { 94 fPan_sens = GetSceneHandler()->GetScene()- 90 fPan_sens = GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius() / 10.0; 95 pan_sens_limit = GetSceneHandler()->GetSce 91 pan_sens_limit = GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(); 96 92 97 dolly_high = GetSceneHandler()->GetScene() 93 dolly_high = GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius(); 98 dolly_low = -(GetSceneHandler()->GetScene( 94 dolly_low = -(GetSceneHandler()->GetScene()->GetExtent().GetExtentRadius()); 99 } 95 } 100 96 101 UpdateControlPanel (); 97 UpdateControlPanel (); 102 98 103 99 104 // FIXME : L.Garnier 12 Oct 2011 100 // FIXME : L.Garnier 12 Oct 2011 105 // Has also to change the Camera/Object, but 101 // Has also to change the Camera/Object, but tricky to do... 106 102 107 } 103 } 108 104 109 105 110 void G4OpenGLXmViewer::GetXmConnection () { 106 void G4OpenGLXmViewer::GetXmConnection () { 111 107 112 G4Xt* interactorManager = G4Xt::getInstance 108 G4Xt* interactorManager = G4Xt::getInstance (); 113 toplevel = (Widget)interactorManager->GetMai 109 toplevel = (Widget)interactorManager->GetMainInteractor(); 114 app = XtWidgetToApplicationContext(topl 110 app = XtWidgetToApplicationContext(toplevel); 115 111 116 if (!toplevel) { 112 if (!toplevel) { 117 fViewId = -1; // This flags an error. 113 fViewId = -1; // This flags an error. 118 G4cerr << "G4OpenGLXmViewer::GetXmConnecti 114 G4cerr << "G4OpenGLXmViewer::GetXmConnection unable to Initialize" 119 " application context." << G4endl; 115 " application context." << G4endl; 120 return; 116 return; 121 } 117 } 122 118 123 // Better to put this in an X11 resource fil 119 // Better to put this in an X11 resource file !!! 124 std::ostringstream oss; 120 std::ostringstream oss; 125 oss << 121 oss << 126 "*glxarea*width: " << fVP.GetWindowSizeHin 122 "*glxarea*width: " << fVP.GetWindowSizeHintX() << "\n" 127 "*glxarea*height: " << fVP.GetWindowSizeHi 123 "*glxarea*height: " << fVP.GetWindowSizeHintY() << "\n" 128 /* 124 /* 129 // Tried this as a replacement for the abo 125 // Tried this as a replacement for the above two lines, but 130 // sub-windows (rotation, etc.) came same 126 // sub-windows (rotation, etc.) came same size!! 131 "*geometry: " << fVP.GetXGeometryString() 127 "*geometry: " << fVP.GetXGeometryString() << "\n" 132 */ 128 */ 133 "*frame*x: 10\n" 129 "*frame*x: 10\n" 134 "*frame*y: 10\n" 130 "*frame*y: 10\n" 135 "*frame*topOffset: 10\n" 131 "*frame*topOffset: 10\n" 136 "*frame*bottomOffset: 10\n" 132 "*frame*bottomOffset: 10\n" 137 "*frame*rightOffset: 10\n" 133 "*frame*rightOffset: 10\n" 138 "*frame*leftOffset: 10\n" 134 "*frame*leftOffset: 10\n" 139 "*frame*shadowType: SHADOW_IN\n" 135 "*frame*shadowType: SHADOW_IN\n" 140 "*frame*useColorObj: False\n" 136 "*frame*useColorObj: False\n" 141 "*frame*primaryColorSetId: 3\n" 137 "*frame*primaryColorSetId: 3\n" 142 "*frame*secondaryColorSetId: 3\n" 138 "*frame*secondaryColorSetId: 3\n" 143 "*menubar*useColorObj: False\n" 139 "*menubar*useColorObj: False\n" 144 "*menubar*primaryColorSetId: 3\n" 140 "*menubar*primaryColorSetId: 3\n" 145 "*menubar*secondaryColorSetId: 3\n" 141 "*menubar*secondaryColorSetId: 3\n" 146 "*toplevel*useColorObj: False\n" 142 "*toplevel*useColorObj: False\n" 147 "*toplevel*primaryColorSetId: 3\n" 143 "*toplevel*primaryColorSetId: 3\n" 148 "*toplevel*secondaryColorSetId: 3\n"; 144 "*toplevel*secondaryColorSetId: 3\n"; 149 interactorManager->PutStringInResourceDataba 145 interactorManager->PutStringInResourceDatabase ((char*)oss.str().c_str()); 150 146 151 // interactorManager->AddSecondaryLoopPostA 147 // interactorManager->AddSecondaryLoopPostAction ((G4SecondaryLoopAction)G4OpenGLXmViewerSecondaryLoopPostAction); 152 148 153 shell = XtAppCreateShell ((String)fName.data 149 shell = XtAppCreateShell ((String)fName.data(),(String)fName.data(),topLevelShellWidgetClass,XtDisplay(toplevel),NULL,0); 154 interactorManager->AddShell (shell); 150 interactorManager->AddShell (shell); 155 151 156 dpy = XtDisplay (shell); 152 dpy = XtDisplay (shell); 157 153 158 if (!dpy) { 154 if (!dpy) { 159 fViewId = -1; // This flags an error. 155 fViewId = -1; // This flags an error. 160 G4cerr << "G4OpenGLXmViewer::GetXmConnecti 156 G4cerr << "G4OpenGLXmViewer::GetXmConnection unable to connect to display." 161 << G4endl; 157 << G4endl; 162 return; 158 return; 163 } 159 } 164 160 165 if (!glXQueryExtension (dpy, &errorBase, &ev 161 if (!glXQueryExtension (dpy, &errorBase, &eventBase)) { 166 fViewId = -1; // This flags an error. 162 fViewId = -1; // This flags an error. 167 G4cerr << "G4OpenGLXmViewer::GetXmConnecti 163 G4cerr << "G4OpenGLXmViewer::GetXmConnection. X Server has no GLX extension." 168 << G4endl;; 164 << G4endl;; 169 return; 165 return; 170 } 166 } 171 } 167 } 172 168 173 void G4OpenGLXmViewer::CreateMainWindow () { 169 void G4OpenGLXmViewer::CreateMainWindow () { 174 170 175 bgnd = XWhitePixelOfScreen (XtScreen(shell)) 171 bgnd = XWhitePixelOfScreen (XtScreen(shell)); 176 borcol = XBlackPixelOfScreen (XtScreen(shell 172 borcol = XBlackPixelOfScreen (XtScreen(shell)); 177 173 178 ResizeWindow(fVP.GetWindowSizeHintX(),fVP.Ge 174 ResizeWindow(fVP.GetWindowSizeHintX(),fVP.GetWindowSizeHintY()); 179 175 180 G4int x_origin = fVP.GetWindowAbsoluteLocati 176 G4int x_origin = fVP.GetWindowAbsoluteLocationHintX(DisplayWidth(dpy, vi -> screen)); 181 177 182 // FIXME, screen size != window size on MAC 178 // FIXME, screen size != window size on MAC, but I don't know have to get the menuBar 183 // size on MAC. L.Garnier 01/2009 179 // size on MAC. L.Garnier 01/2009 184 G4int y_origin = fVP.GetWindowAbsoluteLocati 180 G4int y_origin = fVP.GetWindowAbsoluteLocationHintY(DisplayHeight(dpy, vi -> screen)); 185 181 186 if (fVP.IsWindowSizeHintX () && fVP.IsWindow 182 if (fVP.IsWindowSizeHintX () && fVP.IsWindowLocationHintX () && fVP.IsWindowLocationHintY ()) { 187 XtVaSetValues (shell, 183 XtVaSetValues (shell, 188 XtNvisual, vi -> visual, 184 XtNvisual, vi -> visual, 189 XtNdepth, vi -> depth, 185 XtNdepth, vi -> depth, 190 XtNcolormap, cmap, 186 XtNcolormap, cmap, 191 XtNwidth, getWinWidth(), 187 XtNwidth, getWinWidth(), 192 XtNheight, getWinHeight(), 188 XtNheight, getWinHeight(), 193 XtNx, x_origin, 189 XtNx, x_origin, 194 XtNy, y_origin, 190 XtNy, y_origin, 195 XtNborderColor, &borcol, 191 XtNborderColor, &borcol, 196 XtNbackground, &bgnd, 192 XtNbackground, &bgnd, 197 XmNtitle, fName.data(), 193 XmNtitle, fName.data(), 198 NULL); 194 NULL); 199 } else if (fVP.IsWindowSizeHintX () && !(fVP 195 } else if (fVP.IsWindowSizeHintX () && !(fVP.IsWindowLocationHintX () || fVP.IsWindowLocationHintY ())) { 200 XtVaSetValues (shell, 196 XtVaSetValues (shell, 201 XtNvisual, vi -> visual, 197 XtNvisual, vi -> visual, 202 XtNdepth, vi -> depth, 198 XtNdepth, vi -> depth, 203 XtNcolormap, cmap, 199 XtNcolormap, cmap, 204 XtNwidth, getWinWidth(), 200 XtNwidth, getWinWidth(), 205 XtNheight, getWinHeight(), 201 XtNheight, getWinHeight(), 206 XtNborderColor, &borcol, 202 XtNborderColor, &borcol, 207 XtNbackground, &bgnd, 203 XtNbackground, &bgnd, 208 XmNtitle, fName.data(), 204 XmNtitle, fName.data(), 209 NULL); 205 NULL); 210 } else if ((!fVP.IsWindowSizeHintX ()) && fV 206 } else if ((!fVP.IsWindowSizeHintX ()) && fVP.IsWindowLocationHintX () && fVP.IsWindowLocationHintY ()) { 211 XtVaSetValues (shell, 207 XtVaSetValues (shell, 212 XtNvisual, vi -> visual, 208 XtNvisual, vi -> visual, 213 XtNdepth, vi -> depth, 209 XtNdepth, vi -> depth, 214 XtNcolormap, cmap, 210 XtNcolormap, cmap, 215 XtNx, x_origin, 211 XtNx, x_origin, 216 XtNy, y_origin, 212 XtNy, y_origin, 217 XtNborderColor, &borcol, 213 XtNborderColor, &borcol, 218 XtNbackground, &bgnd, 214 XtNbackground, &bgnd, 219 XmNtitle, fName.data(), 215 XmNtitle, fName.data(), 220 NULL); 216 NULL); 221 } else { 217 } else { 222 XtVaSetValues (shell, 218 XtVaSetValues (shell, 223 XtNvisual, vi -> visual, 219 XtNvisual, vi -> visual, 224 XtNdepth, vi -> depth, 220 XtNdepth, vi -> depth, 225 XtNcolormap, cmap, 221 XtNcolormap, cmap, 226 XtNborderColor, &borcol, 222 XtNborderColor, &borcol, 227 XtNbackground, &bgnd, 223 XtNbackground, &bgnd, 228 XmNtitle, fName.data(), 224 XmNtitle, fName.data(), 229 NULL); 225 NULL); 230 } 226 } 231 227 232 228 233 main_win = XtVaCreateManagedWidget ("main_wi 229 main_win = XtVaCreateManagedWidget ("main_win", 234 xmMainWindowWidgetClass, 230 xmMainWindowWidgetClass, 235 shell, 231 shell, 236 XtNvisual, vi -> visual, 232 XtNvisual, vi -> visual, 237 XtNdepth, vi -> depth, 233 XtNdepth, vi -> depth, 238 XtNcolormap, cmap, 234 XtNcolormap, cmap, 239 XtNborderColor, borcol, 235 XtNborderColor, borcol, 240 XtNbackground, bgnd, 236 XtNbackground, bgnd, 241 NULL); 237 NULL); 242 238 243 //*********Create a menu bar for the window* 239 //*********Create a menu bar for the window******** 244 style_str = XmStringCreateLocalized ((char*) << 240 style_str = XmStringCreateLocalized ((char*)"Style"); 245 actions_str = XmStringCreateLocalized ((char << 241 actions_str = XmStringCreateLocalized ((char*)"Actions"); 246 misc_str = XmStringCreateLocalized ((char*)m << 242 misc_str = XmStringCreateLocalized ((char*)"Miscellany"); 247 spec_str = XmStringCreateLocalized ((char*)m << 243 spec_str = XmStringCreateLocalized ((char*)"Special"); 248 244 249 menubar = XmVaCreateSimpleMenuBar (main_win, 245 menubar = XmVaCreateSimpleMenuBar (main_win, 250 (char*)menu_str[8].c_str(), << 246 (char*)"menubar", 251 XmVaCASCADEBUTTON, style_str, ( << 247 XmVaCASCADEBUTTON, style_str, 'S', 252 XmVaCASCADEBUTTON, actions_str, ( << 248 XmVaCASCADEBUTTON, actions_str, 'A', 253 XmVaCASCADEBUTTON, misc_str, ( << 249 XmVaCASCADEBUTTON, misc_str, 'M', 254 XmVaCASCADEBUTTON, spec_str, ( << 250 XmVaCASCADEBUTTON, spec_str, 'p', 255 XtNvisual, vi -> visual, 251 XtNvisual, vi -> visual, 256 XtNdepth, vi -> depth, 252 XtNdepth, vi -> depth, 257 XtNcolormap, cmap, 253 XtNcolormap, cmap, 258 XtNborderColor, borcol, 254 XtNborderColor, borcol, 259 XtNbackground, bgnd, 255 XtNbackground, bgnd, 260 NULL); 256 NULL); 261 257 262 XmStringFree (style_str); 258 XmStringFree (style_str); 263 XmStringFree (actions_str); 259 XmStringFree (actions_str); 264 XmStringFree (misc_str); 260 XmStringFree (misc_str); 265 XmStringFree (spec_str); 261 XmStringFree (spec_str); 266 262 267 G4cout << "Created menubar" << G4endl; 263 G4cout << "Created menubar" << G4endl; 268 264 269 265 270 //*********Create style pulldown menu on men 266 //*********Create style pulldown menu on menubar********* 271 draw_str = XmStringCreateLocalized ((char*)m << 267 rep_str = XmStringCreateLocalized ((char*)"Representation"); 272 bgnd_str = XmStringCreateLocalized ((char*)m << 268 draw_str = XmStringCreateLocalized ((char*)"Drawing"); >> 269 bgnd_str = XmStringCreateLocalized ((char*)"Background color"); 273 270 274 style_cascade = XmVaCreateSimplePulldownMenu 271 style_cascade = XmVaCreateSimplePulldownMenu 275 (menubar, 272 (menubar, 276 (char*)menu_str[1].c_str(), << 273 (char*)"style", 277 0, 274 0, 278 NULL, 275 NULL, 279 XmVaCASCADEBUTTON, draw_str, (KeySym)XK_D << 276 XmVaCASCADEBUTTON, rep_str, 'R', 280 XmVaCASCADEBUTTON, bgnd_str, (KeySym)XK_B << 277 XmVaCASCADEBUTTON, draw_str, 'D', >> 278 XmVaCASCADEBUTTON, bgnd_str, 'B', 281 XtNvisual, vi -> visual, 279 XtNvisual, vi -> visual, 282 XtNdepth, vi -> depth, 280 XtNdepth, vi -> depth, 283 XtNcolormap, cmap, 281 XtNcolormap, cmap, 284 XtNborderColor, borcol, 282 XtNborderColor, borcol, 285 XtNbackground, bgnd, 283 XtNbackground, bgnd, 286 NULL); 284 NULL); 287 285 >> 286 XmStringFree (rep_str); 288 XmStringFree (draw_str); 287 XmStringFree (draw_str); 289 XmStringFree (bgnd_str); 288 XmStringFree (bgnd_str); 290 289 291 // G4cout << "Created Style pulldown menu" 290 // G4cout << "Created Style pulldown menu" << G4endl; 292 291 >> 292 //Add Representation pullright menu to style cascade... >> 293 polyhedron_str = XmStringCreateLocalized ((char*)"Polyhedron"); >> 294 nurbs_str = XmStringCreateLocalized ((char*)"NURBS"); >> 295 >> 296 rep_style_pullright = XmVaCreateSimplePulldownMenu >> 297 (style_cascade, >> 298 (char*)"rep_style", >> 299 0, >> 300 rep_style_callback, >> 301 XmVaRADIOBUTTON, polyhedron_str, 'P', NULL, NULL, >> 302 XmVaRADIOBUTTON, nurbs_str, 'N', NULL, NULL, >> 303 XmNradioBehavior, True, >> 304 XmNradioAlwaysOne, True, >> 305 XmNuserData, this, >> 306 XtNvisual, vi -> visual, >> 307 XtNdepth, vi -> depth, >> 308 XtNcolormap, cmap, >> 309 XtNborderColor, borcol, >> 310 XtNbackground, bgnd, >> 311 NULL); >> 312 >> 313 Widget special_widget; >> 314 >> 315 G4ViewParameters::RepStyle style; >> 316 style = fVP.GetRepStyle(); >> 317 >> 318 if (style == G4ViewParameters::polyhedron) { >> 319 special_widget = XtNameToWidget(rep_style_pullright, "button_0"); >> 320 if(special_widget) { >> 321 XtVaSetValues (special_widget, XmNset, True, NULL); >> 322 } >> 323 } else if (style == G4ViewParameters::nurbs) { >> 324 special_widget = XtNameToWidget(rep_style_pullright, "button_1"); >> 325 if(special_widget) { >> 326 XtVaSetValues (special_widget, XmNset, True, NULL); >> 327 } >> 328 } else { >> 329 G4Exception >> 330 ("G4OpenGLXmViewer::CreateMainWindow", >> 331 "opengl2014", FatalException, >> 332 "Invalid Representation style"); >> 333 } >> 334 XmStringFree (polyhedron_str); >> 335 XmStringFree (nurbs_str); >> 336 >> 337 // G4cout << "Created Representation pulldown menu" << G4endl; >> 338 293 //Add Drawing pullright menu to style cascad 339 //Add Drawing pullright menu to style cascade... 294 wireframe_str = XmStringCreateLocalized ((ch << 340 wireframe_str = XmStringCreateLocalized ((char*)"Wireframe"); 295 hlr_str = XmStringCreateLocalized ((char*)me << 341 hlr_str = XmStringCreateLocalized ((char*)"Hidden line removal"); 296 hsr_str = XmStringCreateLocalized ((char*)me << 342 hsr_str = XmStringCreateLocalized ((char*)"Hidden surface removal"); 297 hlhsr_str = XmStringCreateLocalized ((char*) << 343 hlhsr_str = XmStringCreateLocalized ((char*)"Hidden line and surface removal"); 298 344 299 drawing_style_pullright = XmVaCreateSimplePu 345 drawing_style_pullright = XmVaCreateSimplePulldownMenu 300 (style_cascade, 346 (style_cascade, 301 (char*)menu_str[15].c_str(), << 347 (char*)"drawing_style", 302 1, 348 1, 303 drawing_style_callback, 349 drawing_style_callback, 304 XmVaRADIOBUTTON, wireframe_str, (KeySym)X << 350 XmVaRADIOBUTTON, wireframe_str, 'W', NULL, NULL, 305 XmVaRADIOBUTTON, hlr_str, (KeySym)X << 351 XmVaRADIOBUTTON, hlr_str, 'L', NULL, NULL, 306 XmVaRADIOBUTTON, hsr_str, (KeySym)X << 352 XmVaRADIOBUTTON, hsr_str, 'S', NULL, NULL, 307 XmVaRADIOBUTTON, hlhsr_str, (KeySym)X << 353 XmVaRADIOBUTTON, hlhsr_str, 'H', NULL, NULL, 308 XmNradioBehavior, True, 354 XmNradioBehavior, True, 309 XmNradioAlwaysOne, True, 355 XmNradioAlwaysOne, True, 310 XmNuserData, this, 356 XmNuserData, this, 311 XtNvisual, vi -> visual, 357 XtNvisual, vi -> visual, 312 XtNdepth, vi -> depth, 358 XtNdepth, vi -> depth, 313 XtNcolormap, cmap, 359 XtNcolormap, cmap, 314 XtNborderColor, borcol, 360 XtNborderColor, borcol, 315 XtNbackground, bgnd, 361 XtNbackground, bgnd, 316 NULL); 362 NULL); 317 363 318 Widget special_widget; << 319 << 320 G4ViewParameters::DrawingStyle d_style; 364 G4ViewParameters::DrawingStyle d_style; 321 d_style = fVP.GetDrawingStyle(); 365 d_style = fVP.GetDrawingStyle(); 322 366 323 if (d_style == G4ViewParameters::wireframe) 367 if (d_style == G4ViewParameters::wireframe) { 324 special_widget = XtNameToWidget(drawing_st 368 special_widget = XtNameToWidget(drawing_style_pullright, "button_0"); 325 if(special_widget) { 369 if(special_widget) { 326 XtVaSetValues (special_widget, XmNset, T 370 XtVaSetValues (special_widget, XmNset, True, NULL); 327 } 371 } 328 } else if (d_style == G4ViewParameters::hlr) 372 } else if (d_style == G4ViewParameters::hlr) { 329 special_widget = XtNameToWidget(drawing_st 373 special_widget = XtNameToWidget(drawing_style_pullright, "button_1"); 330 if(special_widget) { 374 if(special_widget) { 331 XtVaSetValues (special_widget, XmNset, T 375 XtVaSetValues (special_widget, XmNset, True, NULL); 332 } 376 } 333 } else if (d_style == G4ViewParameters::hsr) 377 } else if (d_style == G4ViewParameters::hsr) { 334 special_widget = XtNameToWidget(drawing_st 378 special_widget = XtNameToWidget(drawing_style_pullright, "button_2"); 335 if(special_widget) { 379 if(special_widget) { 336 XtVaSetValues (special_widget, XmNset, T 380 XtVaSetValues (special_widget, XmNset, True, NULL); 337 } 381 } 338 } else if (d_style == G4ViewParameters::hlhs 382 } else if (d_style == G4ViewParameters::hlhsr) { 339 special_widget = XtNameToWidget(drawing_st 383 special_widget = XtNameToWidget(drawing_style_pullright, "button_3"); 340 if(special_widget) { 384 if(special_widget) { 341 XtVaSetValues (special_widget, XmNset, T 385 XtVaSetValues (special_widget, XmNset, True, NULL); 342 } 386 } 343 } else { 387 } else { 344 G4Exception 388 G4Exception 345 ("G4OpenGLXmViewer::CreateMainWindow", 389 ("G4OpenGLXmViewer::CreateMainWindow", 346 "opengl2015", FatalException, 390 "opengl2015", FatalException, 347 "Invalid Drawing style in G4OpenGLXmVie 391 "Invalid Drawing style in G4OpenGLXmViewer::CreateContext"); 348 } 392 } 349 393 350 XmStringFree (wireframe_str); 394 XmStringFree (wireframe_str); 351 XmStringFree (hlr_str); 395 XmStringFree (hlr_str); 352 XmStringFree (hsr_str); 396 XmStringFree (hsr_str); 353 XmStringFree (hlhsr_str); 397 XmStringFree (hlhsr_str); 354 398 355 // G4cout << "Created Drawing pullright men 399 // G4cout << "Created Drawing pullright menu" << G4endl; 356 400 357 //Add Drawing pullright menu to style cascad 401 //Add Drawing pullright menu to style cascade... 358 white_str = XmStringCreateLocalized ((char*) << 402 white_str = XmStringCreateLocalized ((char*)"White"); 359 black_str = XmStringCreateLocalized ((char*) << 403 black_str = XmStringCreateLocalized ((char*)"Black"); 360 404 361 background_color_pullright = XmVaCreateSimpl 405 background_color_pullright = XmVaCreateSimplePulldownMenu 362 (style_cascade, 406 (style_cascade, 363 (char*)menu_str[18].c_str(), << 407 (char*)"background_color", 364 2, 408 2, 365 background_color_callback, 409 background_color_callback, 366 XmVaRADIOBUTTON, white_str, (KeySym)XK_W, << 410 XmVaRADIOBUTTON, white_str, 'W', NULL, NULL, 367 XmVaRADIOBUTTON, black_str, (KeySym)XK_B, << 411 XmVaRADIOBUTTON, black_str, 'B', NULL, NULL, 368 XmNradioBehavior, True, 412 XmNradioBehavior, True, 369 XmNradioAlwaysOne, True, 413 XmNradioAlwaysOne, True, 370 XmNuserData, this, 414 XmNuserData, this, 371 XtNvisual, vi -> visual, 415 XtNvisual, vi -> visual, 372 XtNdepth, vi -> depth, 416 XtNdepth, vi -> depth, 373 XtNcolormap, cmap, 417 XtNcolormap, cmap, 374 XtNborderColor, borcol, 418 XtNborderColor, borcol, 375 XtNbackground, bgnd, 419 XtNbackground, bgnd, 376 NULL); 420 NULL); 377 421 378 if (background.GetRed() == 1. && 422 if (background.GetRed() == 1. && 379 background.GetGreen() == 1. && 423 background.GetGreen() == 1. && 380 background.GetBlue() == 1.) { 424 background.GetBlue() == 1.) { 381 special_widget = XtNameToWidget(background 425 special_widget = XtNameToWidget(background_color_pullright, "button_0"); 382 if(special_widget) { 426 if(special_widget) { 383 XtVaSetValues (special_widget, XmNset, T 427 XtVaSetValues (special_widget, XmNset, True, NULL); 384 } 428 } 385 } else { 429 } else { 386 special_widget = XtNameToWidget(background 430 special_widget = XtNameToWidget(background_color_pullright, "button_1"); 387 if(special_widget) { 431 if(special_widget) { 388 XtVaSetValues (special_widget, XmNset, T 432 XtVaSetValues (special_widget, XmNset, True, NULL); 389 } 433 } 390 } 434 } 391 435 392 XmStringFree (white_str); 436 XmStringFree (white_str); 393 XmStringFree (black_str); 437 XmStringFree (black_str); 394 438 395 // G4cout << "Created Background color pull 439 // G4cout << "Created Background color pullright menu" << G4endl; 396 440 397 //*********Create actions pulldown menu on m 441 //*********Create actions pulldown menu on menubar********* 398 rot_str = XmStringCreateLocalized ((char*)me << 442 rot_str = XmStringCreateLocalized ((char*)"Rotation control panel"); 399 pan_str = XmStringCreateLocalized ((char*)me << 443 pan_str = XmStringCreateLocalized ((char*)"Panning control panel"); 400 set_str = XmStringCreateLocalized ((char*)me << 444 set_str = XmStringCreateLocalized ((char*)"Set control panel limits"); 401 445 402 actions_cascade = XmVaCreateSimplePulldownMe 446 actions_cascade = XmVaCreateSimplePulldownMenu 403 (menubar, 447 (menubar, 404 (char*)menu_str[3].c_str(), << 448 (char*)"actions", 405 1, 449 1, 406 actions_callback, 450 actions_callback, 407 XmVaPUSHBUTTON, rot_str, (KeySym)XK_R, NU << 451 XmVaPUSHBUTTON, rot_str, 'R', NULL, NULL, 408 XmVaPUSHBUTTON, pan_str, (KeySym)XK_P, NU << 452 XmVaPUSHBUTTON, pan_str, 'P', NULL, NULL, 409 XmVaPUSHBUTTON, set_str, (KeySym)XK_S, NU << 453 XmVaPUSHBUTTON, set_str, 'S', NULL, NULL, 410 XmNuserData, this, 454 XmNuserData, this, 411 XtNvisual, vi -> visual, 455 XtNvisual, vi -> visual, 412 XtNdepth, vi -> depth, 456 XtNdepth, vi -> depth, 413 XtNcolormap, cmap, 457 XtNcolormap, cmap, 414 XtNborderColor, borcol, 458 XtNborderColor, borcol, 415 XtNbackground, bgnd, 459 XtNbackground, bgnd, 416 NULL); 460 NULL); 417 461 418 XmStringFree (rot_str); 462 XmStringFree (rot_str); 419 XmStringFree (pan_str); 463 XmStringFree (pan_str); 420 XmStringFree (set_str); 464 XmStringFree (set_str); 421 G4cout << "Created Actions pulldown menu" << 465 G4cout << "Created Actions pulldown menu" << G4endl; 422 466 423 misc_str = XmStringCreateLocalized ((char*)m << 467 misc_str = XmStringCreateLocalized ((char*)"Miscellany control panel"); 424 exit_str = XmStringCreateLocalized ((char*)m << 468 exit_str = XmStringCreateLocalized ((char*)"Exit to G4Vis>"); 425 print_str = XmStringCreateLocalized ((char*) << 469 print_str = XmStringCreateLocalized ((char*)"Create .eps file"); 426 470 427 //*********Create miscellany pulldown menu o 471 //*********Create miscellany pulldown menu on menubar********* 428 misc_cascade = XmVaCreateSimplePulldownMenu 472 misc_cascade = XmVaCreateSimplePulldownMenu 429 (menubar, 473 (menubar, 430 (char*)menu_str[5].c_str(), << 474 (char*)"miscellany", 431 2, 475 2, 432 misc_callback, 476 misc_callback, 433 XmVaPUSHBUTTON, misc_str, (KeySym)XK_M, << 477 XmVaPUSHBUTTON, misc_str, 'M', NULL, NULL, 434 XmVaPUSHBUTTON, exit_str, (KeySym)XK_E, << 478 XmVaPUSHBUTTON, exit_str, 'E', NULL, NULL, 435 XmVaPUSHBUTTON, print_str, (KeySym)XK_P, << 479 XmVaPUSHBUTTON, print_str, 'P', NULL, NULL, 436 XmNuserData, this, 480 XmNuserData, this, 437 XtNvisual, vi -> visual, 481 XtNvisual, vi -> visual, 438 XtNdepth, vi -> depth, 482 XtNdepth, vi -> depth, 439 XtNcolormap, cmap, 483 XtNcolormap, cmap, 440 XtNborderColor, borcol, 484 XtNborderColor, borcol, 441 XtNbackground, bgnd, 485 XtNbackground, bgnd, 442 NULL); 486 NULL); 443 487 444 XmStringFree (misc_str); 488 XmStringFree (misc_str); 445 XmStringFree (exit_str); 489 XmStringFree (exit_str); 446 XmStringFree (print_str); 490 XmStringFree (print_str); 447 G4cout << "Created Miscellany pulldown menu" 491 G4cout << "Created Miscellany pulldown menu" << G4endl; 448 492 449 trans_str = XmStringCreateLocalized ((char*) << 493 trans_str = XmStringCreateLocalized ((char*)"Transparency"); 450 anti_str = XmStringCreateLocalized ((char*)m << 494 anti_str = XmStringCreateLocalized ((char*)"Antialiasing"); 451 halo_str = XmStringCreateLocalized ((char*)m << 495 halo_str = XmStringCreateLocalized ((char*)"Haloing"); 452 aux_edge_str = XmStringCreateLocalized ((cha << 496 aux_edge_str = XmStringCreateLocalized ((char*)"Auxiliary edges"); 453 497 454 //*********Create special pulldown menu on m 498 //*********Create special pulldown menu on menubar********* 455 spec_cascade = XmVaCreateSimplePulldownMenu 499 spec_cascade = XmVaCreateSimplePulldownMenu 456 (menubar, 500 (menubar, 457 (char*)menu_str[7].c_str(), << 501 (char*)"special", 458 3, 502 3, 459 NULL, 503 NULL, 460 XmVaCASCADEBUTTON, trans_str, (KeySym) << 504 XmVaCASCADEBUTTON, trans_str, 'T', 461 XmVaCASCADEBUTTON, anti_str, (KeySym) << 505 XmVaCASCADEBUTTON, anti_str, 'A', 462 XmVaCASCADEBUTTON, halo_str, (KeySym) << 506 XmVaCASCADEBUTTON, halo_str, 'H', 463 XmVaCASCADEBUTTON, aux_edge_str, (KeySym) << 507 XmVaCASCADEBUTTON, aux_edge_str, 'E', 464 XtNvisual, vi -> visual, 508 XtNvisual, vi -> visual, 465 XtNdepth, vi -> depth, 509 XtNdepth, vi -> depth, 466 XtNcolormap, cmap, 510 XtNcolormap, cmap, 467 XtNborderColor, borcol, 511 XtNborderColor, borcol, 468 XtNbackground, bgnd, 512 XtNbackground, bgnd, 469 NULL); 513 NULL); 470 514 471 XmStringFree (trans_str); 515 XmStringFree (trans_str); 472 XmStringFree (anti_str); 516 XmStringFree (anti_str); 473 XmStringFree (halo_str); 517 XmStringFree (halo_str); 474 XmStringFree (aux_edge_str); 518 XmStringFree (aux_edge_str); 475 519 476 // G4cout << "Created Special pulldown menu 520 // G4cout << "Created Special pulldown menu" << G4endl; 477 521 478 //Add Transparency pullright menu to special 522 //Add Transparency pullright menu to special cascade... 479 off_str = XmStringCreateLocalized ((char*)me << 523 off_str = XmStringCreateLocalized ((char*)"Off"); 480 on_str = XmStringCreateLocalized ((char*)men << 524 on_str = XmStringCreateLocalized ((char*)"On"); 481 525 482 transparency_pullright = XmVaCreateSimplePul 526 transparency_pullright = XmVaCreateSimplePulldownMenu 483 (spec_cascade, 527 (spec_cascade, 484 (char*)menu_str[26].c_str(), << 528 (char*)"transparency", 485 0, 529 0, 486 transparency_callback, 530 transparency_callback, 487 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, N << 531 XmVaRADIOBUTTON, off_str, 'f', NULL, NULL, 488 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, N << 532 XmVaRADIOBUTTON, on_str, 'n', NULL, NULL, 489 XmNradioBehavior, True, 533 XmNradioBehavior, True, 490 XmNradioAlwaysOne, True, 534 XmNradioAlwaysOne, True, 491 XmNuserData, this, 535 XmNuserData, this, 492 XtNvisual, vi -> visual, 536 XtNvisual, vi -> visual, 493 XtNdepth, vi -> depth, 537 XtNdepth, vi -> depth, 494 XtNcolormap, cmap, 538 XtNcolormap, cmap, 495 XtNborderColor, borcol, 539 XtNborderColor, borcol, 496 XtNbackground, bgnd, 540 XtNbackground, bgnd, 497 NULL); 541 NULL); 498 542 499 if (transparency_enabled == false) { 543 if (transparency_enabled == false) { 500 special_widget = XtNameToWidget(transparen 544 special_widget = XtNameToWidget(transparency_pullright, "button_0"); 501 if(special_widget) { 545 if(special_widget) { 502 XtVaSetValues (special_widget, XmNset, T 546 XtVaSetValues (special_widget, XmNset, True, NULL); 503 } 547 } 504 } else if (transparency_enabled == true) { 548 } else if (transparency_enabled == true) { 505 special_widget = XtNameToWidget(transparen 549 special_widget = XtNameToWidget(transparency_pullright, "button_1"); 506 if(special_widget) { 550 if(special_widget) { 507 XtVaSetValues (special_widget, XmNset, T 551 XtVaSetValues (special_widget, XmNset, True, NULL); 508 } 552 } 509 } else { 553 } else { 510 G4Exception 554 G4Exception 511 ("G4OpenGLXmViewer::CreateMainWindow", 555 ("G4OpenGLXmViewer::CreateMainWindow", 512 "opengl2016", FatalException, 556 "opengl2016", FatalException, 513 "transparency_enabled in G4OpenGLXmView 557 "transparency_enabled in G4OpenGLXmViewer is neither true nor false!!"); 514 } 558 } 515 559 516 //Add antialias pullright menu to special ca 560 //Add antialias pullright menu to special cascade... 517 antialias_pullright = XmVaCreateSimplePulldo 561 antialias_pullright = XmVaCreateSimplePulldownMenu 518 (spec_cascade, 562 (spec_cascade, 519 (char*)menu_str[28].c_str(), << 563 (char*)"antialias", 520 1, 564 1, 521 antialias_callback, 565 antialias_callback, 522 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, N << 566 XmVaRADIOBUTTON, off_str, 'f', NULL, NULL, 523 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, N << 567 XmVaRADIOBUTTON, on_str, 'n', NULL, NULL, 524 XmNradioBehavior, True, 568 XmNradioBehavior, True, 525 XmNradioAlwaysOne, True, 569 XmNradioAlwaysOne, True, 526 XmNuserData, this, 570 XmNuserData, this, 527 XtNvisual, vi -> visual, 571 XtNvisual, vi -> visual, 528 XtNdepth, vi -> depth, 572 XtNdepth, vi -> depth, 529 XtNcolormap, cmap, 573 XtNcolormap, cmap, 530 XtNborderColor, borcol, 574 XtNborderColor, borcol, 531 XtNbackground, bgnd, 575 XtNbackground, bgnd, 532 NULL); 576 NULL); 533 577 534 if (antialiasing_enabled == false) { 578 if (antialiasing_enabled == false) { 535 special_widget = XtNameToWidget(antialias_ 579 special_widget = XtNameToWidget(antialias_pullright, "button_0"); 536 if(special_widget) { 580 if(special_widget) { 537 XtVaSetValues (special_widget, XmNset, T 581 XtVaSetValues (special_widget, XmNset, True, NULL); 538 } 582 } 539 } else if (antialiasing_enabled == true) { 583 } else if (antialiasing_enabled == true) { 540 special_widget = XtNameToWidget(antialias_ 584 special_widget = XtNameToWidget(antialias_pullright, "button_1"); 541 if(special_widget) { 585 if(special_widget) { 542 XtVaSetValues (special_widget, XmNset, T 586 XtVaSetValues (special_widget, XmNset, True, NULL); 543 } 587 } 544 } else { 588 } else { 545 G4Exception 589 G4Exception 546 ("G4OpenGLXmViewer::CreateMainWindow", 590 ("G4OpenGLXmViewer::CreateMainWindow", 547 "opengl2017", FatalException, 591 "opengl2017", FatalException, 548 "antialiasing_enabled in G4OpenGLXmView 592 "antialiasing_enabled in G4OpenGLXmViewer is neither true nor false!!"); 549 } 593 } 550 594 551 //Add Haloing pullright menu to special casc 595 //Add Haloing pullright menu to special cascade... 552 haloing_pullright = XmVaCreateSimplePulldown 596 haloing_pullright = XmVaCreateSimplePulldownMenu 553 (spec_cascade, 597 (spec_cascade, 554 (char*)menu_str[30].c_str(), << 598 (char*)"haloing", 555 2, 599 2, 556 haloing_callback, 600 haloing_callback, 557 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, N << 601 XmVaRADIOBUTTON, off_str, 'f', NULL, NULL, 558 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, N << 602 XmVaRADIOBUTTON, on_str, 'n', NULL, NULL, 559 XmNradioBehavior, True, 603 XmNradioBehavior, True, 560 XmNradioAlwaysOne, True, 604 XmNradioAlwaysOne, True, 561 XmNuserData, this, 605 XmNuserData, this, 562 XtNvisual, vi -> visual, 606 XtNvisual, vi -> visual, 563 XtNdepth, vi -> depth, 607 XtNdepth, vi -> depth, 564 XtNcolormap, cmap, 608 XtNcolormap, cmap, 565 XtNborderColor, borcol, 609 XtNborderColor, borcol, 566 XtNbackground, bgnd, 610 XtNbackground, bgnd, 567 NULL); 611 NULL); 568 612 569 if (haloing_enabled == false) { 613 if (haloing_enabled == false) { 570 special_widget = XtNameToWidget(haloing_pu 614 special_widget = XtNameToWidget(haloing_pullright, "button_0"); 571 if(special_widget) { 615 if(special_widget) { 572 XtVaSetValues (special_widget, XmNset, T 616 XtVaSetValues (special_widget, XmNset, True, NULL); 573 } 617 } 574 } else if (haloing_enabled == true) { 618 } else if (haloing_enabled == true) { 575 special_widget = XtNameToWidget(haloing_pu 619 special_widget = XtNameToWidget(haloing_pullright, "button_1"); 576 if(special_widget) { 620 if(special_widget) { 577 XtVaSetValues (special_widget, XmNset, T 621 XtVaSetValues (special_widget, XmNset, True, NULL); 578 } 622 } 579 } else { 623 } else { 580 G4Exception 624 G4Exception 581 ("G4OpenGLXmViewer::CreateMainWindow", 625 ("G4OpenGLXmViewer::CreateMainWindow", 582 "opengl2018", FatalException, 626 "opengl2018", FatalException, 583 "haloing_enabled in G4OpenGLXmViewer is 627 "haloing_enabled in G4OpenGLXmViewer is neither true nor false!!"); 584 } 628 } 585 629 586 //Add Aux_Edge pullright menu to special cas 630 //Add Aux_Edge pullright menu to special cascade... 587 aux_edge_pullright = XmVaCreateSimplePulldow 631 aux_edge_pullright = XmVaCreateSimplePulldownMenu 588 (spec_cascade, 632 (spec_cascade, 589 (char*)menu_str[32].c_str(), << 633 (char*)"aux_edge", 590 3, 634 3, 591 aux_edge_callback, 635 aux_edge_callback, 592 XmVaRADIOBUTTON, off_str, (KeySym)XK_f, N << 636 XmVaRADIOBUTTON, off_str, 'f', NULL, NULL, 593 XmVaRADIOBUTTON, on_str, (KeySym)XK_n, N << 637 XmVaRADIOBUTTON, on_str, 'n', NULL, NULL, 594 XmNradioBehavior, True, 638 XmNradioBehavior, True, 595 XmNradioAlwaysOne, True, 639 XmNradioAlwaysOne, True, 596 XmNuserData, this, 640 XmNuserData, this, 597 XtNvisual, vi -> visual, 641 XtNvisual, vi -> visual, 598 XtNdepth, vi -> depth, 642 XtNdepth, vi -> depth, 599 XtNcolormap, cmap, 643 XtNcolormap, cmap, 600 XtNborderColor, borcol, 644 XtNborderColor, borcol, 601 XtNbackground, bgnd, 645 XtNbackground, bgnd, 602 NULL); 646 NULL); 603 647 604 if (!fVP.IsAuxEdgeVisible()) { 648 if (!fVP.IsAuxEdgeVisible()) { 605 special_widget = XtNameToWidget(aux_edge_p 649 special_widget = XtNameToWidget(aux_edge_pullright, "button_0"); 606 if(special_widget) { 650 if(special_widget) { 607 XtVaSetValues (special_widget, XmNset, T 651 XtVaSetValues (special_widget, XmNset, True, NULL); 608 } 652 } 609 } else { 653 } else { 610 special_widget = XtNameToWidget(aux_edge_p 654 special_widget = XtNameToWidget(aux_edge_pullright, "button_1"); 611 if(special_widget) { 655 if(special_widget) { 612 XtVaSetValues (special_widget, XmNset, T 656 XtVaSetValues (special_widget, XmNset, True, NULL); 613 } 657 } 614 } 658 } 615 659 616 XtManageChild (menubar); 660 XtManageChild (menubar); 617 frame = XtVaCreateManagedWidget ((char*)menu << 661 frame = XtVaCreateManagedWidget ((char*)"frame", 618 xmFrameWidgetClass, main_win, 662 xmFrameWidgetClass, main_win, 619 XtNvisual, vi -> visual, 663 XtNvisual, vi -> visual, 620 XtNdepth, vi -> depth, 664 XtNdepth, vi -> depth, 621 XtNcolormap, cmap, 665 XtNcolormap, cmap, 622 XtNborderColor, borcol, 666 XtNborderColor, borcol, 623 XtNbackground, bgnd, 667 XtNbackground, bgnd, 624 NULL); 668 NULL); 625 669 626 glxarea = XtVaCreateManagedWidget ((char*)me << 670 glxarea = XtVaCreateManagedWidget ((char*)"glxarea", 627 xmDrawingAreaWidgetClass, 671 xmDrawingAreaWidgetClass, 628 frame, 672 frame, 629 XtNvisual, vi -> visual, 673 XtNvisual, vi -> visual, 630 XtNdepth, vi -> depth, 674 XtNdepth, vi -> depth, 631 XtNcolormap, cmap, 675 XtNcolormap, cmap, 632 XtNborderColor, borcol, 676 XtNborderColor, borcol, 633 XtNbackground, bgnd, 677 XtNbackground, bgnd, 634 NULL); 678 NULL); 635 679 636 680 637 XmMainWindowSetAreas (main_win, // main wid 681 XmMainWindowSetAreas (main_win, // main widget, children are specified 638 menubar, // widget to use as menu bar 682 menubar, // widget to use as menu bar 639 NULL, // widget to use as command w 683 NULL, // widget to use as command window 640 NULL, // widget for horizontal scro 684 NULL, // widget for horizontal scroll bar 641 NULL, // widget for vertical scroll 685 NULL, // widget for vertical scroll bar 642 frame // widget to be used for work 686 frame // widget to be used for work window 643 ); 687 ); 644 688 645 XtRealizeWidget(shell); 689 XtRealizeWidget(shell); 646 690 647 // Once widget is realized (ie, associated w 691 // Once widget is realized (ie, associated with a created X window), we 648 // can bind the OpenGL rendering context to 692 // can bind the OpenGL rendering context to the window. 649 693 650 win = XtWindow (glxarea); 694 win = XtWindow (glxarea); 651 695 652 glXMakeCurrent (dpy, win, cxMaster); << 696 glXMakeCurrent (dpy, win, cx); 653 697 654 // This should be add AFTER glXMakeCurrent d 698 // This should be add AFTER glXMakeCurrent done because it will fire a resizeCallback 655 XtAddCallback (glxarea, 699 XtAddCallback (glxarea, 656 XmNresizeCallback, 700 XmNresizeCallback, 657 resize_callback, 701 resize_callback, 658 this); 702 this); 659 703 660 XtAddCallback (glxarea, 704 XtAddCallback (glxarea, 661 XmNexposeCallback, 705 XmNexposeCallback, 662 expose_callback, 706 expose_callback, 663 this); 707 this); 664 708 665 } 709 } 666 710 667 G4OpenGLXmViewer::G4OpenGLXmViewer (G4OpenGLSc 711 G4OpenGLXmViewer::G4OpenGLXmViewer (G4OpenGLSceneHandler& scene): 668 G4VViewer (scene, -1), 712 G4VViewer (scene, -1), 669 G4OpenGLViewer (scene), 713 G4OpenGLViewer (scene), 670 G4OpenGLXViewer (scene), 714 G4OpenGLXViewer (scene), 671 toplevel (0), << 672 shell (0), << 673 main_win (0), << 674 menubar (0), << 675 style_cascade (0), << 676 actions_cascade (0), << 677 misc_cascade (0), << 678 spec_cascade (0), << 679 drawing_style_pullright (0), << 680 background_color_pullright (0), << 681 transparency_pullright (0), << 682 antialias_pullright (0), << 683 haloing_pullright (0), << 684 aux_edge_pullright (0), << 685 frame (0), << 686 glxarea (0), << 687 style_str (0), << 688 actions_str (0), << 689 misc_str (0), << 690 spec_str (0), << 691 draw_str (0), << 692 polyhedron_str (0), << 693 wireframe_str (0), << 694 hlr_str (0), << 695 hsr_str (0), << 696 hlhsr_str (0), << 697 set_str (0), << 698 rot_str (0), << 699 pan_str (0), << 700 exit_str (0), << 701 quit_str (0), << 702 print_str (0), << 703 white_str (0), << 704 black_str (0), << 705 anti_str (0), << 706 trans_str (0), << 707 halo_str (0), << 708 aux_edge_str (0), << 709 bgnd_str (0), << 710 off_str (0), << 711 on_str (0), << 712 zoom_high (0.0), << 713 zoom_low (0.0), << 714 pan_low (0.0), << 715 pan_high (0.0), << 716 dolly_low (0.0), << 717 dolly_high (0.0), << 718 fov (0.0), 715 fov (0.0), 719 rot_sens_limit (0.0), << 720 pan_sens_limit (0.0), << 721 wob_high (0.0), << 722 wob_low (0.0), << 723 wob_sens (0.0), << 724 pan_right (false), << 725 rotate_right (false), << 726 pan_up (false), << 727 rotate_up (false), << 728 original_vp(fVP.GetViewpointDirection()), 716 original_vp(fVP.GetViewpointDirection()), 729 frameNo (0), 717 frameNo (0), 730 fprotation_top (0), 718 fprotation_top (0), 731 fprotation_button_box (0), << 732 fprotation_button1 (0), << 733 fprotation_button2 (0), << 734 fprotation_slider_box (0), << 735 fprotation_slider (0), 719 fprotation_slider (0), 736 fprotation_arrow_box (0), << 737 fprotation_arrow (0), << 738 fppanning_top (0), 720 fppanning_top (0), 739 fppanning_box (0), << 740 fppanning_arrows (0), << 741 fppanning_slider (0), 721 fppanning_slider (0), 742 fpzoom_box (0), << 743 fpzoom_slider (0), 722 fpzoom_slider (0), 744 fpdolly_box (0), << 745 fpdolly_slider (0), 723 fpdolly_slider (0), 746 fpsetting_top (0), 724 fpsetting_top (0), 747 fpsetting_box (0), << 748 fppan_set (0), 725 fppan_set (0), 749 fprot_set (0), 726 fprot_set (0), 750 fpzoom_upper (0), 727 fpzoom_upper (0), 751 fpzoom_lower (0), 728 fpzoom_lower (0), 752 fpdolly_upper (0), 729 fpdolly_upper (0), 753 fpdolly_lower (0), 730 fpdolly_lower (0), 754 fpok_button (0), << 755 fpmiscellany_top (0), 731 fpmiscellany_top (0), 756 fpwobble_box (0), << 757 fpwobble_button (0), << 758 fpwobble_slider (0), 732 fpwobble_slider (0), 759 fpreset_box (0), << 733 fpprint_top (0) 760 fpreset_button (0), << 761 fpproj_style_box (0), << 762 fporthogonal_button (0), << 763 fpperspective_button (0), << 764 fpfov_text (0), << 765 fpprint_top (0), << 766 fpprint_box (0), << 767 fpprint_col_box (0), << 768 fpprint_style_box (0), << 769 fpprint_text (0), << 770 fpprint_button (0), << 771 fpprint_line (0), << 772 fpprint_col_radio1 (0), << 773 fpprint_col_radio2 (0), << 774 fpprint_style_radio1 (0), << 775 fpprint_style_radio2 (0) << 776 { 734 { 777 GetXmConnection (); 735 GetXmConnection (); 778 ResetView(); 736 ResetView(); 779 if (fViewId < 0) return; 737 if (fViewId < 0) return; 780 } 738 } 781 739 782 740 783 void G4OpenGLXmViewer::UpdateControlPanel () { 741 void G4OpenGLXmViewer::UpdateControlPanel () { 784 742 785 // set new values 743 // set new values 786 744 787 if (fprotation_slider) { 745 if (fprotation_slider) { 788 fprotation_slider->SetInitialValue(fRot_se 746 fprotation_slider->SetInitialValue(fRot_sens); 789 fprotation_slider->SetMaxValue(rot_sens_li 747 fprotation_slider->SetMaxValue(rot_sens_limit); 790 fprotation_slider->SetMinValue(0); 748 fprotation_slider->SetMinValue(0); 791 } 749 } 792 if (fppanning_slider) { 750 if (fppanning_slider) { 793 fppanning_slider->SetInitialValue(fPan_sen 751 fppanning_slider->SetInitialValue(fPan_sens); 794 fppanning_slider->SetMaxValue(pan_sens_lim 752 fppanning_slider->SetMaxValue(pan_sens_limit); 795 fppanning_slider->SetMinValue(0); 753 fppanning_slider->SetMinValue(0); 796 } 754 } 797 if (fpzoom_slider) { 755 if (fpzoom_slider) { 798 fpzoom_slider->SetInitialValue(fVP.GetZoom 756 fpzoom_slider->SetInitialValue(fVP.GetZoomFactor()); 799 fpzoom_slider->SetMinValue(zoom_low); 757 fpzoom_slider->SetMinValue(zoom_low); 800 fpzoom_slider->SetMaxValue(zoom_high); 758 fpzoom_slider->SetMaxValue(zoom_high); 801 } 759 } 802 if (fpdolly_slider) { 760 if (fpdolly_slider) { 803 fpdolly_slider->SetInitialValue(fVP.GetDol 761 fpdolly_slider->SetInitialValue(fVP.GetDolly()); 804 fpdolly_slider->SetMinValue(dolly_low); 762 fpdolly_slider->SetMinValue(dolly_low); 805 fpdolly_slider->SetMaxValue(dolly_high); 763 fpdolly_slider->SetMaxValue(dolly_high); 806 } 764 } 807 765 808 if (fpwobble_slider) { 766 if (fpwobble_slider) { 809 fpwobble_slider->SetInitialValue(fVP.GetDo 767 fpwobble_slider->SetInitialValue(fVP.GetDolly()); 810 } 768 } 811 769 812 if (fppan_set) { 770 if (fppan_set) { 813 fppan_set->SetValue(pan_sens_limit); 771 fppan_set->SetValue(pan_sens_limit); 814 } 772 } 815 773 816 if (fprot_set) { 774 if (fprot_set) { 817 fprot_set->SetValue(rot_sens_limit); 775 fprot_set->SetValue(rot_sens_limit); 818 } 776 } 819 777 820 if (fpzoom_upper) { 778 if (fpzoom_upper) { 821 fpzoom_upper->SetValue(zoom_high); 779 fpzoom_upper->SetValue(zoom_high); 822 } 780 } 823 781 824 if (fpzoom_lower) { 782 if (fpzoom_lower) { 825 fpzoom_lower->SetValue(zoom_low); 783 fpzoom_lower->SetValue(zoom_low); 826 } 784 } 827 if (fpdolly_upper) { 785 if (fpdolly_upper) { 828 fpdolly_upper->SetValue(dolly_high); 786 fpdolly_upper->SetValue(dolly_high); 829 } 787 } 830 788 831 if (fpdolly_lower) { 789 if (fpdolly_lower) { 832 fpdolly_lower->SetValue(dolly_low); 790 fpdolly_lower->SetValue(dolly_low); 833 } 791 } 834 792 835 793 836 } 794 } 837 795 838 796 839 G4OpenGLXmViewer::~G4OpenGLXmViewer () 797 G4OpenGLXmViewer::~G4OpenGLXmViewer () 840 { 798 { 841 XtDestroyWidget (shell); 799 XtDestroyWidget (shell); 842 win = 0; // ...to avoid XDestroyWindow in G4 800 win = 0; // ...to avoid XDestroyWindow in G4OpenGLXViewer base class 843 // because XtDestroyWidget has already destr 801 // because XtDestroyWidget has already destroyed it. 844 G4Xt::getInstance () ->RemoveShell (shell); 802 G4Xt::getInstance () ->RemoveShell (shell); 845 803 846 /****************************** 804 /****************************** 847 if (fprotation_top) { 805 if (fprotation_top) { 848 delete fprotation_top; 806 delete fprotation_top; 849 } 807 } 850 808 851 if (fppanning_top) { 809 if (fppanning_top) { 852 delete fppanning_top; 810 delete fppanning_top; 853 } 811 } 854 812 855 if (fpsetting_top) { 813 if (fpsetting_top) { 856 delete fpsetting_top; 814 delete fpsetting_top; 857 } 815 } 858 816 859 if (fpmiscellany_top) { 817 if (fpmiscellany_top) { 860 delete fpmiscellany_top; 818 delete fpmiscellany_top; 861 } 819 } 862 ******************************/ 820 ******************************/ 863 821 864 } 822 } >> 823 >> 824 #endif 865 825