ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TGLSAViewer.cxx
Go to the documentation of this file.
1 // @(#)root/gl:$Id$
2 // Author: Timur Pocheptsov / Richard Maunder
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include <memory>
13 
14 #include "TRootHelpDialog.h"
15 #include "TPluginManager.h"
16 #include "TApplication.h"
17 #include "TGClient.h"
18 #include "TGCanvas.h"
19 #include "HelpText.h"
20 #include "GuiTypes.h"
21 #include "TG3DLine.h"
22 #include "TSystem.h"
23 #include "TGFrame.h"
24 #include "TGLabel.h"
25 #include "TGMenu.h"
26 #include "TGButton.h"
27 #include "TGSplitter.h"
28 #include "TColor.h"
29 
30 #include "TVirtualPad.h"
31 #include "TGedEditor.h"
32 #include "TRootEmbeddedCanvas.h"
33 #include "TString.h"
34 #include "TGFileDialog.h"
35 
36 #include "TGLOutput.h"
37 #include "TGLFormat.h"
38 
39 #include "TGLLogicalShape.h"
40 #include "TGLPhysicalShape.h"
41 #include "TGLPShapeObj.h"
42 #include "TGLClip.h"
43 #include "TROOT.h"
44 
45 #ifdef WIN32
46 #include "TWin32SplashThread.h"
47 #endif
48 
49 #include "TGLPhysicalShape.h"
50 #include "TGLWidget.h"
51 #include "TGLSAViewer.h"
52 #include "TGLSAFrame.h"
53 #include "TGLOutput.h"
54 #include "TGLEventHandler.h"
55 
56 
57 const char * TGLSAViewer::fgHelpText1 = "\
58 DIRECT SCENE INTERACTIONS\n\n\
59  Press:\n\
60  \tw --- wireframe mode\n\
61  \te --- switch between dark / light color-set\n\
62  \tr --- filled polygons mode\n\
63  \tt --- outline mode\n\
64  \tj --- ZOOM in\n\
65  \tk --- ZOOM out\n\
66  \ta --- switch on/off arc-ball camera rotation control\n\
67  \tArrow Keys --- PAN (TRUCK) across scene\n\
68  \tHome --- reset current camera\n\
69  \tCtrl-Home --- switch external/automatic camera center\n\
70 \n\
71  LEFT mouse button -- ROTATE (ORBIT) the scene by holding the mouse button and moving\n\
72  the mouse (perspective camera, needs to be enabled in menu for orthographic cameras).\n\
73  By default, the scene will be rotated about its center. To select arbitrary center\n\
74  bring up the viewer-editor (e.g., shift-click into empty background) and use\n\
75  'Camera center' controls in the 'Guides' tab.\n\
76 \n\
77  MIDDLE mouse button or arrow keys -- PAN (TRUCK) the camera.\n\
78 \n\
79  RIGHT mouse button action depends on camera type:\n\
80  orthographic -- zoom,\n\
81  perspective -- move camera forwards / backwards\n\
82 \n\
83  By pressing Ctrl and Shift keys the mouse precision can be changed:\n\
84  Shift -- 10 times less precise\n\
85  Ctrl -- 10 times more precise\n\
86  Ctrl Shift -- 100 times more precise\n\
87 \n\
88  Mouse wheel action depends on camera type:\n\
89  orthographic -- zoom,\n\
90  perspective -- change field-of-view (focal length)\n\
91 \n\
92  To invert direction of mouse and key actions from scene-centric\n\
93  to viewer-centric, set in your .rootrc file:\n\
94  OpenGL.EventHandler.ViewerCentricControls: 1\n\
95 \n\
96  Double click will show GUI editor of the viewer (if assigned).\n\
97 \n\
98  RESET the camera via the button in viewer-editor or Home key.\n\
99 \n\
100  SELECT a shape with Shift+Left mouse button click.\n\
101 \n\
102  SELECT the viewer with Shift+Left mouse button click on a free space.\n\
103 \n\
104  MOVE a selected shape using Shift+Mid mouse drag.\n\
105 \n\
106  Invoke the CONTEXT menu with Shift+Right mouse click.\n\n"
107  "Secondary selection and direct render object interaction is initiated\n\
108  by Alt+Left mouse click (Mod1, actually). Only few classes support this option.\n\
109  When 'Alt' is taken by window manager, try Alt-Ctrl-Left.\n\
110 \n\
111 CAMERA\n\
112 \n\
113  The \"Camera\" menu is used to select the different projections from \n\
114  the 3D world onto the 2D viewport. There are three perspective cameras:\n\
115 \n\
116  \tPerspective (Floor XOZ)\n\
117  \tPerspective (Floor YOZ)\n\
118  \tPerspective (Floor XOY)\n\
119 \n\
120  In each case the floor plane (defined by two axes) is kept level.\n\
121 \n\
122  There are also three orthographic cameras:\n\
123 \n\
124  \tOrthographic (XOY)\n\
125  \tOrthographic (XOZ)\n\
126  \tOrthographic (ZOY)\n\
127 \n\
128  In each case the first axis is placed horizontal, the second vertical e.g.\n\
129  XOY means X horizontal, Y vertical.\n\n";
130 
131 const char * TGLSAViewer::fgHelpText2 = "\
132 SHAPES COLOR AND MATERIAL\n\
133 \n\
134  The selected shape's color can be modified in the Shapes-Color tabs.\n\
135  Shape's color is specified by the percentage of red, green, blue light\n\
136  it reflects. A surface can reflect DIFFUSE, AMBIENT and SPECULAR light.\n\
137  A surface can also emit light. The EMISSIVE parameter allows to define it.\n\
138  The surface SHININESS can also be modified.\n\
139 \n\
140 SHAPES GEOMETRY\n\
141 \n\
142  The selected shape's location and geometry can be modified in the Shapes-Geom\n\
143  tabs by entering desired values in respective number entry controls.\n\
144 \n\
145 SCENE CLIPPING\n\
146 \n\
147  In the Scene-Clipping tabs select a 'Clip Type': None, Plane, Box\n\
148 \n\
149  For 'Plane' and 'Box' the lower pane shows the relevant parameters:\n\
150 \n\
151 \tPlane: Equation coefficients of form aX + bY + cZ + d = 0\n\
152 \tBox: Center X/Y/Z and Length X/Y/Z\n\n"
153  "For Box checking the 'Show / Edit' checkbox shows the clip box (in light blue)\n\
154  in viewer. It also attaches the current manipulator to the box - enabling\n\
155  direct editing in viewer.\n\
156 \n\
157 MANIPULATORS\n\
158 \n\
159  A widget attached to the selected object - allowing direct manipulation\n\
160  of the object with respect to its local axes.\n\
161 \n\
162  There are three modes, toggled with keys while manipulator is active, that is,\n\
163  mouse pointer is above it (switches color to yellow):\n\
164  \tMode\t\tWidget Component Style\t\tKey\n\
165  \t----\t\t----------------------\t\t---\n\
166  \tTranslation\tLocal axes with arrows\t\tv\n\
167  \tScale\t\tLocal axes with boxes\t\tx\n\
168  \tRotate\t\tLocal axes rings\t\tc\n\
169 \n\
170  Each widget has three axis components - red (X), green (Y) and blue (Z).\n\
171  The component turns yellow, indicating an active state, when the mouse is moved\n\
172  over it. Left click and drag on the active component to adjust the objects\n\
173  translation, scale or rotation.\n\
174  Some objects do not support all manipulations (e.g. clipping planes cannot be \n\
175  scaled). If a manipulation is not permitted the component it drawn in grey and \n\
176  cannot be selected/dragged.\n";
177 
178 
179 /** \class TGLSAViewer
180 \ingroup opengl
181 The top level standalone GL-viewer - created via plugin manager.
182 */
183 
185 
187 
188 const Int_t TGLSAViewer::fgInitX = 0;
189 const Int_t TGLSAViewer::fgInitY = 0;
190 const Int_t TGLSAViewer::fgInitW = 780;
191 const Int_t TGLSAViewer::fgInitH = 670;
192 
193 // A lot of raw pointers/naked new-expressions - good way to discredit C++ (or C++ programmer
194 // ROOT has system to cleanup - I'll try to use it
195 
196 const char *gGLSaveAsTypes[] = {"Encapsulated PostScript", "*.eps",
197  "PDF", "*.pdf",
198  "GIF", "*.gif",
199  "Animated GIF", "*.gif+",
200  "JPEG", "*.jpg",
201  "PNG", "*.png",
202  0, 0};
203 
204 ////////////////////////////////////////////////////////////////////////////////
205 /// Construct a standalone viewer, bound to supplied 'pad'.
206 
208  TGLViewer(pad, fgInitX, fgInitY, fgInitW, fgInitH),
209  fFrame(0),
210  fFormat(format),
211  fFileMenu(0),
212  fFileSaveMenu(0),
213  fCameraMenu(0),
214  fHelpMenu(0),
215  fLeftVerticalFrame(0),
216  fRightVerticalFrame(0),
217  fDirName("."),
218  fTypeIdx(0),
219  fOverwrite(kFALSE),
220  fMenuBar(0),
221  fMenuBut(0),
222  fHideMenuBar(kFALSE),
223  fMenuHidingTimer(0),
224  fMenuHidingShowMenu(kTRUE),
225  fDeleteMenuBar(kFALSE)
226 {
227  fFrame = new TGLSAFrame(*this);
228 
229  CreateMenus();
230  CreateFrames();
231 
232  fFrame->SetWindowName("ROOT's GL viewer");
233  fFrame->SetClassHints("GLViewer", "GLViewer");
237 
241 
242  // set recursive cleanup, but exclude fGedEditor
243  // destructor of fGedEditor has own way of handling child nodes
248 
249  Show();
250 }
251 
252 ////////////////////////////////////////////////////////////////////////////////
253 /// Construct an embedded standalone viewer, bound to supplied 'pad'.
254 /// If format is passed, it gets adopted by the viewer as it might
255 /// need to be reused several times when recreating the GL-widget.
256 ///
257 /// Modified version of the previous constructor for embedding the
258 /// viewer into another frame (parent).
259 
261  TGLFormat* format) :
262  TGLViewer(pad, fgInitX, fgInitY, fgInitW, fgInitH),
263  fFrame(0),
264  fFormat(format),
265  fFileMenu(0),
266  fCameraMenu(0),
267  fHelpMenu(0),
268  fLeftVerticalFrame(0),
269  fRightVerticalFrame(0),
270  fTypeIdx(0),
271  fMenuBar(0),
272  fMenuBut(0),
273  fHideMenuBar(kFALSE),
274  fMenuHidingTimer(0),
275  fMenuHidingShowMenu(kTRUE),
276  fDeleteMenuBar(kFALSE)
277 {
278  fGedEditor = ged;
279  fFrame = new TGLSAFrame(parent, *this);
280 
281  CreateMenus();
282  CreateFrames();
283 
288 
289  // set recursive cleanup, but exclude fGedEditor
290  // destructor of fGedEditor has own way of handling child nodes
291  if (fLeftVerticalFrame)
292  {
297  }
298 
299  Show();
300 }
301 
302 ////////////////////////////////////////////////////////////////////////////////
303 /// Destroy standalone viewer object.
304 
306 {
308 
310 
311  delete fHelpMenu;
312  delete fCameraMenu;
313  delete fFileSaveMenu;
314  delete fFileMenu;
315  if(fDeleteMenuBar) {
316  delete fMenuBar;
317  }
318  delete fFormat;
319  delete fFrame;
320  fGLWidget = 0;
321 }
322 
323 ////////////////////////////////////////////////////////////////////////////////
324 /// Return the main-frame.
325 
327 {
328  return fFrame;
329 }
330 
331 ////////////////////////////////////////////////////////////////////////////////
332 /// Create a GLwidget, it is an error if it is already created.
333 /// This is needed for frame-swapping on mac.
334 
336 {
337  if (fGLWidget) {
338  Error("CreateGLWidget", "Widget already exists.");
339  return;
340  }
341 
342  if (fFormat == 0)
343  fFormat = new TGLFormat;
344 
347 
349  fFrame->Layout();
350 
351  fGLWidget->MapWindow();
352 }
353 
354 ////////////////////////////////////////////////////////////////////////////////
355 /// Destroy the GLwidget, it is an error if it does not exist.
356 /// This is needed for frame-swapping on mac.
357 
359 {
360  if (fGLWidget == 0) {
361  Error("DestroyGLWidget", "Widget does not exist.");
362  return;
363  }
364 
367 
370  fGLWidget = 0;
371 }
372 
373 ////////////////////////////////////////////////////////////////////////////////
374 ///File/Camera/Help menus.
375 
377 {
379  fFileMenu->AddEntry("&Hide Menus", kGLHideMenus);
380  fFileMenu->AddEntry("&Edit Object", kGLEditObject);
382  fFileMenu->AddEntry("&Close Viewer", kGLCloseViewer);
385  fFileSaveMenu->AddEntry("viewer.&eps", kGLSaveEPS);
386  fFileSaveMenu->AddEntry("viewer.&pdf", kGLSavePDF);
387  fFileSaveMenu->AddEntry("viewer.&gif", kGLSaveGIF);
388  fFileSaveMenu->AddEntry("viewer.g&if+", kGLSaveAnimGIF);
389  fFileSaveMenu->AddEntry("viewer.&jpg", kGLSaveJPG);
390  fFileSaveMenu->AddEntry("viewer.p&ng", kGLSavePNG);
391  fFileMenu->AddPopup("&Save", fFileSaveMenu);
392  fFileMenu->AddEntry("Save &As...", kGLSaveAS);
394  fFileMenu->AddEntry("&Quit ROOT", kGLQuitROOT);
396 
398  fCameraMenu->AddEntry("Perspective (Floor XOZ)", kGLPerspXOZ);
399  fCameraMenu->AddEntry("Perspective (Floor YOZ)", kGLPerspYOZ);
400  fCameraMenu->AddEntry("Perspective (Floor XOY)", kGLPerspXOY);
401  fCameraMenu->AddEntry("Orthographic (XOY)", kGLXOY);
402  fCameraMenu->AddEntry("Orthographic (XOZ)", kGLXOZ);
403  fCameraMenu->AddEntry("Orthographic (ZOY)", kGLZOY);
404  fCameraMenu->AddEntry("Orthographic (XnOY)", kGLXnOY);
405  fCameraMenu->AddEntry("Orthographic (XnOZ)", kGLXnOZ);
406  fCameraMenu->AddEntry("Orthographic (ZnOY)", kGLZnOY);
408  fCameraMenu->AddEntry("Ortho allow rotate", kGLOrthoRotate);
409  fCameraMenu->AddEntry("Ortho allow dolly", kGLOrthoDolly);
411 
413  fHelpMenu->AddEntry("Help on GL Viewer...", kGLHelpViewer);
415  fHelpMenu->AddEntry("&About ROOT...", kGLHelpAbout);
417 
418  // Create menubar
419  fMenuBar = new TGMenuBar(fFrame);
420  fMenuBar->AddPopup("&File", fFileMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
421  fMenuBar->AddPopup("&Camera", fCameraMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
424  gVirtualX->SelectInput(fMenuBar->GetId(),
428 
429  fMenuBut = new TGButton(fFrame);
431  fMenuBut->Resize(20, 4);
432  fMenuBut->SetBackgroundColor(0x80A0C0);
434 }
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// Internal frames creation.
438 
440 {
441  TGCompositeFrame* compositeFrame = fFrame;
442  if (fGedEditor == 0)
443  {
444  compositeFrame = new TGCompositeFrame(fFrame, 100, 100, kHorizontalFrame | kRaisedFrame);
445  fFrame->AddFrame(compositeFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
446 
447  fLeftVerticalFrame = new TGVerticalFrame(compositeFrame, 195, 10, kFixedWidth);
448  compositeFrame->AddFrame(fLeftVerticalFrame, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));
449 
450  const TGWindow* cw = fFrame->GetClient()->GetRoot();
452 
453  fGedEditor = new TGedEditor();
459 
460  TGVSplitter *splitter = new TGVSplitter(compositeFrame);
461  splitter->SetFrame(fLeftVerticalFrame, kTRUE);
462  compositeFrame->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0,1,2,2) );
463  }
464 
465  // SunkenFrame introduces 1-pixel offset - in TGFrame.cxx:163
466  //
467  // TGVerticalFrame *rightVerticalFrame = new TGVerticalFrame(compositeFrame, 10, 10, kSunkenFrame);
468  // compositeFrame->AddFrame(rightVerticalFrame, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY,0,2,2,2));
469  fRightVerticalFrame = new TGVerticalFrame(compositeFrame, 10, 10);
471 
472  fEventHandler = new TGLEventHandler(0, this);
473  CreateGLWidget();
474 }
475 
476 ////////////////////////////////////////////////////////////////////////////////
477 /// Update GUI components for embedded viewer selection change.
478 /// Override from TGLViewer.
479 
481 {
482  TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
483 
484  if (selected) {
485  fPShapeWrap->fPShape = selected;
488  else
490  } else {
491  fPShapeWrap->fPShape = 0;
493  }
494 }
495 
496 ////////////////////////////////////////////////////////////////////////////////
497 /// Show the viewer
498 
500 {
501  fFrame->MapRaised();
503  RequestDraw();
504 }
505 
506 ////////////////////////////////////////////////////////////////////////////////
507 /// Close the viewer - destructed.
508 
510 {
511  // Commit suicide when contained GUI is closed.
512  delete this;
513 }
514 
515 ////////////////////////////////////////////////////////////////////////////////
516 /// Delete the menu bar.
517 
519 {
521 }
522 
523 ////////////////////////////////////////////////////////////////////////////////
524 /// Deactivate menu entries for closing the GL window and exiting ROOT.
525 
527 {
530 }
531 
532 ////////////////////////////////////////////////////////////////////////////////
533 /// Enable hiding of menu bar.
534 
536 {
537  if (fHideMenuBar)
538  return;
539 
541 
542  fMenuBar->Connect("ProcessedEvent(Event_t*)", "TGLSAViewer", this, "HandleMenuBarHiding(Event_t*)");
543  fMenuBut->Connect("ProcessedEvent(Event_t*)", "TGLSAViewer", this, "HandleMenuBarHiding(Event_t*)");
544 
547  fFrame->Layout();
548 
549  fMenuHidingTimer = new TTimer;
550  fMenuHidingTimer->Connect("Timeout()", "TGLSAViewer", this, "MenuHidingTimeout()");
551 
553 }
554 
555 ////////////////////////////////////////////////////////////////////////////////
556 /// Disable hiding of menu bar.
557 
559 {
560  if (!fHideMenuBar)
561  return;
562 
564 
565  fMenuBar->Disconnect("ProcessedEvent(Event_t*)", this, "HandleMenuBarHiding(Event_t*)");
566  fMenuBut->Disconnect("ProcessedEvent(Event_t*)", this, "HandleMenuBarHiding(Event_t*)");
567 
570  fFrame->Layout();
571 
573  delete fMenuHidingTimer;
574  fMenuHidingTimer = 0;
575 
577 }
578 
579 ////////////////////////////////////////////////////////////////////////////////
580 /// Maybe switch menu-bar / menu-button.
581 
583 {
584  TGFrame *f = (TGFrame*) gTQSender;
585 
586  if (f == fMenuBut)
587  {
588  if (ev->fType == kEnterNotify)
590  else
592  }
593  else if (f == fMenuBar)
594  {
595  if (ev->fType == kLeaveNotify &&
596  (ev->fX < 0 || ev->fX >= (Int_t) f->GetWidth() ||
597  ev->fY < 0 || ev->fY >= (Int_t) f->GetHeight()))
598  {
599  if (fMenuBar->GetCurrent() == 0)
601  else
602  fMenuBar->GetCurrent()->Connect("ProcessedEvent(Event_t*)", "TGLSAViewer", this, "HandleMenuBarHiding(Event_t*)");
603  }
604  else
605  {
607  }
608  }
609  else
610  {
611  f->Disconnect("ProcessedEvent(Event_t*)", this);
613  }
614 }
615 
616 ////////////////////////////////////////////////////////////////////////////////
617 /// Reset the timer for menu-bar hiding.
618 
620 {
621  // This happens, mysteriously.
622  if (fMenuHidingTimer == 0)
623  return;
624 
626 
627  fMenuHidingShowMenu = show_menu;
628 
632 }
633 
634 ////////////////////////////////////////////////////////////////////////////////
635 /// Action for menu-hiding timeout.
636 
638 {
640  if (fMenuHidingShowMenu) {
643  } else {
646  }
647  fFrame->Layout();
648 }
649 
650 ////////////////////////////////////////////////////////////////////////////////
651 /// Set global timeout for menu-hiding in mili-seconds.
652 /// Static function.
653 
655 {
656  fgMenuHidingTimeout = timeout;
657 }
658 
659 ////////////////////////////////////////////////////////////////////////////////
660 /// Process GUI message capture by the main GUI frame (TGLSAFrame).
661 
663 {
664  switch (GET_MSG(msg)) {
665  case kC_COMMAND:
666  switch (GET_SUBMSG(msg)) {
667  case kCM_BUTTON:
668  case kCM_MENU:
669  switch (parm1) {
670  case kGLHelpAbout: {
671 #ifdef R__UNIX
672  TString rootx;
673 #ifdef ROOTBINDIR
674  rootx = ROOTBINDIR;
675 #else
676  rootx = gSystem->Getenv("ROOTSYS");
677  if (!rootx.IsNull()) rootx += "/bin";
678 #endif
679  rootx += "/root -a &";
680  gSystem->Exec(rootx);
681 #else
682 #ifdef WIN32
684 #else
685  char str[32];
686  snprintf(str,32, "About ROOT %s...", gROOT->GetVersion());
687  hd = new TRootHelpDialog(this, str, 600, 400);
688  hd->SetText(gHelpAbout);
689  hd->Popup();
690 #endif
691 #endif
692  break;
693  }
694  case kGLHelpViewer: {
695  TRootHelpDialog * hd = new TRootHelpDialog(fFrame, "Help on GL Viewer...", 660, 400);
696  hd->AddText(fgHelpText1);
697  hd->AddText(fgHelpText2);
698  hd->Popup();
699  break;
700  }
701  case kGLPerspYOZ:
703  break;
704  case kGLPerspXOZ:
706  break;
707  case kGLPerspXOY:
709  break;
710  case kGLXOY:
712  break;
713  case kGLXOZ:
715  break;
716  case kGLZOY:
718  break;
719  case kGLXnOY:
721  break;
722  case kGLXnOZ:
724  break;
725  case kGLZnOY:
727  break;
728  case kGLOrthoRotate:
730  break;
731  case kGLOrthoDolly:
733  break;
734  case kGLSaveEPS:
735  SavePicture("viewer.eps");
736  break;
737  case kGLSavePDF:
738  SavePicture("viewer.pdf");
739  break;
740  case kGLSaveGIF:
741  SavePicture("viewer.gif");
742  break;
743  case kGLSaveAnimGIF:
744  SavePicture("viewer.gif+");
745  break;
746  case kGLSaveJPG:
747  SavePicture("viewer.jpg");
748  break;
749  case kGLSavePNG:
750  SavePicture("viewer.png");
751  break;
752  case kGLSaveAS:
753  {
754  TGFileInfo fi;
756  fi.fIniDir = StrDup(fDirName);
757  fi.fFileTypeIdx = fTypeIdx;
758  fi.fOverwrite = fOverwrite;
759  new TGFileDialog(gClient->GetDefaultRoot(), fFrame, kFDSave, &fi);
760  if (!fi.fFilename) return kTRUE;
761  TString ft(fi.fFileTypes[fi.fFileTypeIdx+1]);
762  fDirName = fi.fIniDir;
763  fTypeIdx = fi.fFileTypeIdx;
764  fOverwrite = fi.fOverwrite;
765 
766  TString file = fi.fFilename;
767  Bool_t match = kFALSE;
768  const char** fin = gGLSaveAsTypes; ++fin;
769  while (*fin != 0)
770  {
771  if (file.EndsWith(*fin + 1))
772  {
773  match = kTRUE;
774  break;
775  }
776  fin += 2;
777  }
778  if ( ! match)
779  {
780  file += ft(ft.Index("."), ft.Length());
781  }
782  SavePicture(file);
783  }
784  break;
785  case kGLHideMenus:
786  if (fHideMenuBar)
788  else
790  break;
791  case kGLEditObject:
793  break;
794  case kGLCloseViewer:
795  // Exit needs to be delayed to avoid bad drawable X ids - GUI
796  // will all be changed in future anyway
797  TTimer::SingleShot(50, "TGLSAFrame", fFrame, "SendCloseMessage()");
798  break;
799  case kGLQuitROOT:
800  if (!gApplication->ReturnFromRun())
801  delete this;
803  break;
804  default:
805  break;
806  }
807  default:
808  break;
809  }
810  default:
811  break;
812  }
813 
814  return kTRUE;
815 }
816 
817 ////////////////////////////////////////////////////////////////////////////////
818 /// Toggle state of the 'Edit Object' menu entry.
819 
821 {
824  else
827 }
828 
829 ////////////////////////////////////////////////////////////////////////////////
830 /// Toggle state of the 'Ortho allow rotate' menu entry.
831 
833 {
836  else
845 }
846 
847 ////////////////////////////////////////////////////////////////////////////////
848 /// Toggle state of the 'Ortho allow dolly' menu entry.
849 
851 {
854  else
860 }
TGEventHandler * fEventHandler
select record from last overlay select
Definition: TGLViewer.h:119
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
void ToggleEditObject()
Toggle state of the 'Edit Object' menu entry.
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TGMenuBar * fMenuBar
Definition: TGLSAViewer.h:67
void SetRoot(TGWindow *root=0)
Sets the current root (i.e.
Definition: TGClient.cxx:242
TGLFormat * fFormat
Definition: TGLSAViewer.h:53
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
TGPopupMenu * fHelpMenu
Definition: TGLSAViewer.h:57
static const Int_t fgInitX
Definition: TGLSAViewer.h:80
TObject * GetExternal() const
void Reset()
Reset the timer.
Definition: TTimer.cxx:155
static const Int_t fgInitW
Definition: TGLSAViewer.h:82
TGCanvas * GetTGCanvas() const
Definition: TGedEditor.h:91
Ssiz_t Length() const
Definition: TString.h:390
Bool_t fOverwrite
Definition: TGFileDialog.h:67
static const Int_t fgInitH
Definition: TGLSAViewer.h:83
void MenuHidingTimeout()
Action for menu-hiding timeout.
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
R__EXTERN void * gTQSender
Definition: TQObject.h:49
REAL splitter
Definition: triangle.c:616
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
TGLOrthoCamera fOrthoXnOZCamera
Definition: TGLViewer.h:94
UInt_t GetWidth() const
Definition: TGFrame.h:287
TGLSAFrame * fFrame
Definition: TGLSAViewer.h:52
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:169
virtual void SetFrame(TGFrame *frame, Bool_t left)
Set frame to be resized.
Definition: TGSplitter.cxx:140
TGLOrthoCamera fOrthoXOZCamera
Definition: TGLViewer.h:91
TGLOrthoCamera fOrthoXOYCamera
Definition: TGLViewer.h:90
void ResetMenuHidingTimer(Bool_t show_menu)
Reset the timer for menu-bar hiding.
virtual void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition: TList.cxx:93
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1833
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1795
#define gROOT
Definition: TROOT.h:344
Int_t fY
Definition: GuiTypes.h:179
Basic string class.
Definition: TString.h:137
virtual TList * GetList() const
Definition: TGFrame.h:385
#define gClient
Definition: TGClient.h:174
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition: TTimer.cxx:254
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGButton * fMenuBut
Definition: TGLSAViewer.h:68
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu entry.
Definition: TGMenu.cxx:985
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event)
Activate object editors according to the selected object.
Definition: TGedEditor.cxx:349
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Bool_t fDeleteMenuBar
Definition: TGLSAViewer.h:73
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
static std::string format(double x, double y, int digits, int width)
Bool_t fHideMenuBar
Definition: TGLSAViewer.h:69
UInt_t GetHeight() const
Definition: TGFrame.h:288
virtual void MapRaised()
Definition: TGFrame.h:268
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1055
Bool_t ReturnFromRun() const
Definition: TApplication.h:154
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
TFile * f
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1131
void SetEnableRotate(Bool_t x)
Concrete physical shape - a GL drawable.
static TGLWidget * Create(const TGWindow *parent, Bool_t selectInput, Bool_t shareDefault, const TGLPaintDevice *shareDevice, UInt_t width, UInt_t height)
Static constructor for creating widget with default pixel format.
Definition: TGLWidget.cxx:83
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:164
void HandleMenuBarHiding(Event_t *ev)
Maybe switch menu-bar / menu-button.
const char ** fFileTypes
Definition: TGFileDialog.h:65
const TGLLogicalShape * GetLogical() const
TGPopupMenu * fFileMenu
Definition: TGLSAViewer.h:54
TGLSAViewer(const TGLSAViewer &)
void SetEventHandler(TGEventHandler *eh)
Set event-handler. All events are passed to this object.
Definition: TGLWidget.cxx:558
TString fDirName
Definition: TGLSAViewer.h:64
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1575
void DeleteMenuBar()
Delete the menu bar.
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:294
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
TGCompositeFrame * GetFrame() const
Return the main-frame.
TVirtualPad * fPad
Definition: TGLViewer.h:80
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
void ToggleOrthoDolly()
Toggle state of the 'Ortho allow dolly' menu entry.
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:35
const char * gGLSaveAsTypes[]
TGLWidget * fGLWidget
Definition: TGLViewer.h:185
virtual TGMenuTitle * GetCurrent() const
Definition: TGMenu.h:356
static void SetMenuHidingTimeout(Long_t timeout)
Set global timeout for menu-hiding in mili-seconds.
The top level standalone GL-viewer - created via plugin manager.
Definition: TGLSAViewer.h:37
TGPopupMenu * fCameraMenu
Definition: TGLSAViewer.h:56
const Mask_t kKeyPressMask
Definition: GuiTypes.h:160
TGLPhysicalShape * fPShape
Definition: TGLPShapeObj.h:23
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:1135
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail 'LOD' Request is directed via cross thread gVirt...
Definition: TGLViewer.cxx:436
ClassImp(TGLSAViewer)
void Close()
Close the viewer - destructed.
Bool_t fOverwrite
Definition: TGLSAViewer.h:66
void DisableCloseMenuEntries()
Deactivate menu entries for closing the GL window and exiting ROOT.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2207
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:176
Int_t GET_SUBMSG(Long_t val)
virtual void CreateGLWidget()
Create a GLwidget, it is an error if it is already created.
TGCompositeFrame * fLeftVerticalFrame
Definition: TGLSAViewer.h:60
void EnableMenuBarHiding()
Enable hiding of menu bar.
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:675
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:227
const Mask_t kExposureMask
Definition: GuiTypes.h:166
Bool_t ProcessFrameMessage(Long_t msg, Long_t parm1, Long_t)
Process GUI message capture by the main GUI frame (TGLSAFrame).
virtual void TurnOff()
Remove timer from system timer list.
Definition: TTimer.cxx:227
TGPopupMenu * fFileSaveMenu
Definition: TGLSAViewer.h:55
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:57
void AddText(const char *helpText)
Add help text from helpText buffer to already existing text in TGTextView.
TTimer * fMenuHidingTimer
Definition: TGLSAViewer.h:70
virtual void SelectionChanged()
Update GUI components for embedded viewer selection change.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:657
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
Bool_t IsNull() const
Definition: TString.h:387
Standalone GL Viewer GUI main frame.
Definition: TGLSAFrame.h:32
tuple pad
Definition: first.py:38
~TGLSAViewer()
Destroy standalone viewer object.
#define gVirtualX
Definition: TVirtualX.h:362
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2500
Int_t GET_MSG(Long_t val)
void SetDollyToZoom(Bool_t x)
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:168
long Long_t
Definition: RtypesCore.h:50
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
TGCompositeFrame * fRightVerticalFrame
Definition: TGLSAViewer.h:62
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:167
tuple file
Definition: fildir.py:20
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1054
friend class TGLEventHandler
Definition: TGLViewer.h:59
void CreateFrames()
Internal frames creation.
TGLOrthoCamera fOrthoXnOYCamera
Definition: TGLViewer.h:93
TGClient * GetClient() const
Definition: TGObject.h:53
TGLOrthoCamera fOrthoZOYCamera
Definition: TGLViewer.h:92
TGLOrthoCamera fOrthoZnOYCamera
Definition: TGLViewer.h:95
Int_t fFileTypeIdx
Definition: TGFileDialog.h:66
char * fFilename
Definition: TGFileDialog.h:63
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1293
void SetCurrentCamera(ECameraType camera)
Set current active camera - 'cameraType' one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1779
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
static const Int_t fgInitY
Definition: TGLSAViewer.h:81
void ToggleOrthoRotate()
Toggle state of the 'Ortho allow rotate' menu entry.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
Mother of all ROOT objects.
Definition: TObject.h:58
Int_t fTypeIdx
Definition: TGLSAViewer.h:65
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:557
virtual void UnmapWindow()
Definition: TGFrame.h:269
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition: TGFrame.cxx:1837
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition: TGMenu.cxx:1770
static Long_t fgMenuHidingTimeout
Definition: TGLSAViewer.h:75
virtual void MapWindow()
Definition: TGFrame.h:267
static const char * fgHelpText1
Definition: TGLSAViewer.h:85
const Mask_t kFocusChangeMask
Definition: GuiTypes.h:170
virtual void DeleteEntry(Int_t id)
Delete entry with specified id from menu.
Definition: TGMenu.cxx:1914
Bool_t fMenuHidingShowMenu
Definition: TGLSAViewer.h:71
void Show()
Show the viewer.
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=0, const TGPicture *p=0)
Add a (cascading) popup menu to a popup menu.
Definition: TGMenu.cxx:1147
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:391
virtual void DisconnectFromCanvas()
Disconnect this editor from the Selected signal of fCanvas.
Definition: TGedEditor.cxx:322
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: Rtypes.h:91
void CreateMenus()
File/Camera/Help menus.
virtual void DestroyGLWidget()
Destroy the GLwidget, it is an error if it does not exist.
void SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition: TGFrame.cxx:1824
TGedEditor * fGedEditor
event handler
Definition: TGLViewer.h:120
void DisableMenuBarHiding()
Disable hiding of menu bar.
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:239
static const char * fgHelpText2
Definition: TGLSAViewer.h:86
Handle_t GetId() const
Definition: TGObject.h:52
virtual void ChangeOptions(UInt_t options)
Change frame options. Options is an OR of the EFrameTypes.
Definition: TGFrame.cxx:303
Int_t fX
Definition: GuiTypes.h:179
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition: TGMenu.cxx:415
Bool_t SavePicture()
Save current image using the default file name which can be set via SetPictureFileName() and defaults...
Definition: TGLViewer.cxx:781
char * fIniDir
Definition: TGFileDialog.h:64
const TGLPhysicalShape * GetSelected() const
Return selected physical shape.
Definition: TGLViewer.cxx:2056
TGLPShapeObj * fPShapeWrap
GED editor.
Definition: TGLViewer.h:121
void SetTime(Long_t milliSec)
Definition: TTimer.h:96