Logo ROOT   6.12/07
Reference Guide
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 four orthographic cameras:\n\
123 \n\
124  \tOrthographic (XOY)\n\
125  \tOrthographic (XOZ)\n\
126  \tOrthographic (ZOY)\n\
127  \tOrthographic (ZOX)\n\
128 \n\
129  In each case the first axis is placed horizontal, the second vertical e.g.\n\
130  XOY means X horizontal, Y vertical.\n\n";
131 
132 const char * TGLSAViewer::fgHelpText2 = "\
133 SHAPES COLOR AND MATERIAL\n\
134 \n\
135  The selected shape's color can be modified in the Shapes-Color tabs.\n\
136  Shape's color is specified by the percentage of red, green, blue light\n\
137  it reflects. A surface can reflect DIFFUSE, AMBIENT and SPECULAR light.\n\
138  A surface can also emit light. The EMISSIVE parameter allows to define it.\n\
139  The surface SHININESS can also be modified.\n\
140 \n\
141 SHAPES GEOMETRY\n\
142 \n\
143  The selected shape's location and geometry can be modified in the Shapes-Geom\n\
144  tabs by entering desired values in respective number entry controls.\n\
145 \n\
146 SCENE CLIPPING\n\
147 \n\
148  In the Scene-Clipping tabs select a 'Clip Type': None, Plane, Box\n\
149 \n\
150  For 'Plane' and 'Box' the lower pane shows the relevant parameters:\n\
151 \n\
152 \tPlane: Equation coefficients of form aX + bY + cZ + d = 0\n\
153 \tBox: Center X/Y/Z and Length X/Y/Z\n\n"
154  "For Box checking the 'Show / Edit' checkbox shows the clip box (in light blue)\n\
155  in viewer. It also attaches the current manipulator to the box - enabling\n\
156  direct editing in viewer.\n\
157 \n\
158 MANIPULATORS\n\
159 \n\
160  A widget attached to the selected object - allowing direct manipulation\n\
161  of the object with respect to its local axes.\n\
162 \n\
163  There are three modes, toggled with keys while manipulator is active, that is,\n\
164  mouse pointer is above it (switches color to yellow):\n\
165  \tMode\t\tWidget Component Style\t\tKey\n\
166  \t----\t\t----------------------\t\t---\n\
167  \tTranslation\tLocal axes with arrows\t\tv\n\
168  \tScale\t\tLocal axes with boxes\t\tx\n\
169  \tRotate\t\tLocal axes rings\t\tc\n\
170 \n\
171  Each widget has three axis components - red (X), green (Y) and blue (Z).\n\
172  The component turns yellow, indicating an active state, when the mouse is moved\n\
173  over it. Left click and drag on the active component to adjust the objects\n\
174  translation, scale or rotation.\n\
175  Some objects do not support all manipulations (e.g. clipping planes cannot be \n\
176  scaled). If a manipulation is not permitted the component it drawn in grey and \n\
177  cannot be selected/dragged.\n";
178 
179 
180 /** \class TGLSAViewer
181 \ingroup opengl
182 The top level standalone GL-viewer - created via plugin manager.
183 */
184 
186 
188 
189 const Int_t TGLSAViewer::fgInitX = 0;
190 const Int_t TGLSAViewer::fgInitY = 0;
191 const Int_t TGLSAViewer::fgInitW = 780;
192 const Int_t TGLSAViewer::fgInitH = 670;
193 
194 // A lot of raw pointers/naked new-expressions - good way to discredit C++ (or C++ programmer
195 // ROOT has system to cleanup - I'll try to use it
196 
197 const char *gGLSaveAsTypes[] = {"Encapsulated PostScript", "*.eps",
198  "PDF", "*.pdf",
199  "GIF", "*.gif",
200  "Animated GIF", "*.gif+",
201  "JPEG", "*.jpg",
202  "PNG", "*.png",
203  0, 0};
204 
205 ////////////////////////////////////////////////////////////////////////////////
206 /// Construct a standalone viewer, bound to supplied 'pad'.
207 
209  TGLViewer(pad, fgInitX, fgInitY, fgInitW, fgInitH),
210  fFrame(0),
211  fFormat(format),
212  fFileMenu(0),
213  fFileSaveMenu(0),
214  fCameraMenu(0),
215  fHelpMenu(0),
216  fLeftVerticalFrame(0),
217  fRightVerticalFrame(0),
218  fDirName("."),
219  fTypeIdx(0),
220  fOverwrite(kFALSE),
221  fMenuBar(0),
222  fMenuBut(0),
223  fHideMenuBar(kFALSE),
224  fMenuHidingTimer(0),
225  fMenuHidingShowMenu(kTRUE),
226  fDeleteMenuBar(kFALSE)
227 {
228  fFrame = new TGLSAFrame(*this);
229 
230  CreateMenus();
231  CreateFrames();
232 
233  fFrame->SetWindowName("ROOT's GL viewer");
234  fFrame->SetClassHints("GLViewer", "GLViewer");
238 
242 
243  // set recursive cleanup, but exclude fGedEditor
244  // destructor of fGedEditor has own way of handling child nodes
249 
250  Show();
251 }
252 
253 ////////////////////////////////////////////////////////////////////////////////
254 /// Construct an embedded standalone viewer, bound to supplied 'pad'.
255 /// If format is passed, it gets adopted by the viewer as it might
256 /// need to be reused several times when recreating the GL-widget.
257 ///
258 /// Modified version of the previous constructor for embedding the
259 /// viewer into another frame (parent).
260 
262  TGLFormat* format) :
264  fFrame(0),
265  fFormat(format),
266  fFileMenu(0),
267  fCameraMenu(0),
268  fHelpMenu(0),
271  fTypeIdx(0),
272  fMenuBar(0),
273  fMenuBut(0),
275  fMenuHidingTimer(0),
278 {
279  fGedEditor = ged;
280  fFrame = new TGLSAFrame(parent, *this);
281 
282  CreateMenus();
283  CreateFrames();
284 
289 
290  // set recursive cleanup, but exclude fGedEditor
291  // destructor of fGedEditor has own way of handling child nodes
292  if (fLeftVerticalFrame)
293  {
298  }
299 
300  Show();
301 }
302 
303 ////////////////////////////////////////////////////////////////////////////////
304 /// Destroy standalone viewer object.
305 
307 {
309 
311 
312  delete fHelpMenu;
313  delete fCameraMenu;
314  delete fFileSaveMenu;
315  delete fFileMenu;
316  if(fDeleteMenuBar) {
317  delete fMenuBar;
318  }
319  delete fFormat;
320  delete fFrame;
321  fGLWidget = 0;
322 }
323 
324 ////////////////////////////////////////////////////////////////////////////////
325 /// Return the main-frame.
326 
328 {
329  return fFrame;
330 }
331 
332 ////////////////////////////////////////////////////////////////////////////////
333 /// Create a GLwidget, it is an error if it is already created.
334 /// This is needed for frame-swapping on mac.
335 
337 {
338  if (fGLWidget) {
339  Error("CreateGLWidget", "Widget already exists.");
340  return;
341  }
342 
343  if (fFormat == 0)
344  fFormat = new TGLFormat;
345 
348 
350  fFrame->Layout();
351 
352  fGLWidget->MapWindow();
353 }
354 
355 ////////////////////////////////////////////////////////////////////////////////
356 /// Destroy the GLwidget, it is an error if it does not exist.
357 /// This is needed for frame-swapping on mac.
358 
360 {
361  if (fGLWidget == 0) {
362  Error("DestroyGLWidget", "Widget does not exist.");
363  return;
364  }
365 
368 
371  fGLWidget = 0;
372 }
373 
374 ////////////////////////////////////////////////////////////////////////////////
375 ///File/Camera/Help menus.
376 
378 {
380  fFileMenu->AddEntry("&Hide Menus", kGLHideMenus);
381  fFileMenu->AddEntry("&Edit Object", kGLEditObject);
383  fFileMenu->AddEntry("&Close Viewer", kGLCloseViewer);
386  fFileSaveMenu->AddEntry("viewer.&eps", kGLSaveEPS);
387  fFileSaveMenu->AddEntry("viewer.&pdf", kGLSavePDF);
388  fFileSaveMenu->AddEntry("viewer.&gif", kGLSaveGIF);
389  fFileSaveMenu->AddEntry("viewer.g&if+", kGLSaveAnimGIF);
390  fFileSaveMenu->AddEntry("viewer.&jpg", kGLSaveJPG);
391  fFileSaveMenu->AddEntry("viewer.p&ng", kGLSavePNG);
392  fFileMenu->AddPopup("&Save", fFileSaveMenu);
393  fFileMenu->AddEntry("Save &As...", kGLSaveAS);
395  fFileMenu->AddEntry("&Quit ROOT", kGLQuitROOT);
397 
399  fCameraMenu->AddEntry("Perspective (Floor XOZ)", kGLPerspXOZ);
400  fCameraMenu->AddEntry("Perspective (Floor YOZ)", kGLPerspYOZ);
401  fCameraMenu->AddEntry("Perspective (Floor XOY)", kGLPerspXOY);
402  fCameraMenu->AddEntry("Orthographic (XOY)", kGLXOY);
403  fCameraMenu->AddEntry("Orthographic (XOZ)", kGLXOZ);
404  fCameraMenu->AddEntry("Orthographic (ZOY)", kGLZOY);
405  fCameraMenu->AddEntry("Orthographic (ZOX)", kGLZOX);
406  fCameraMenu->AddEntry("Orthographic (XnOY)", kGLXnOY);
407  fCameraMenu->AddEntry("Orthographic (XnOZ)", kGLXnOZ);
408  fCameraMenu->AddEntry("Orthographic (ZnOY)", kGLZnOY);
409  fCameraMenu->AddEntry("Orthographic (ZnOX)", kGLZnOX);
411  fCameraMenu->AddEntry("Ortho allow rotate", kGLOrthoRotate);
412  fCameraMenu->AddEntry("Ortho allow dolly", kGLOrthoDolly);
414 
416  fHelpMenu->AddEntry("Help on GL Viewer...", kGLHelpViewer);
418  fHelpMenu->AddEntry("&About ROOT...", kGLHelpAbout);
420 
421  // Create menubar
422  fMenuBar = new TGMenuBar(fFrame);
423  fMenuBar->AddPopup("&File", fFileMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
424  fMenuBar->AddPopup("&Camera", fCameraMenu, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
427  gVirtualX->SelectInput(fMenuBar->GetId(),
431 
432  fMenuBut = new TGButton(fFrame);
434  fMenuBut->Resize(20, 4);
435  fMenuBut->SetBackgroundColor(0x80A0C0);
437 }
438 
439 ////////////////////////////////////////////////////////////////////////////////
440 /// Internal frames creation.
441 
443 {
444  TGCompositeFrame* compositeFrame = fFrame;
445  if (fGedEditor == 0)
446  {
447  compositeFrame = new TGCompositeFrame(fFrame, 100, 100, kHorizontalFrame | kRaisedFrame);
448  fFrame->AddFrame(compositeFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
449 
450  fLeftVerticalFrame = new TGVerticalFrame(compositeFrame, 195, 10, kFixedWidth);
451  compositeFrame->AddFrame(fLeftVerticalFrame, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));
452 
453  const TGWindow* cw = fFrame->GetClient()->GetRoot();
455 
456  fGedEditor = new TGedEditor();
462 
463  TGVSplitter *splitter = new TGVSplitter(compositeFrame);
464  splitter->SetFrame(fLeftVerticalFrame, kTRUE);
465  compositeFrame->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0,1,2,2) );
466  }
467 
468  // SunkenFrame introduces 1-pixel offset - in TGFrame.cxx:163
469  //
470  // TGVerticalFrame *rightVerticalFrame = new TGVerticalFrame(compositeFrame, 10, 10, kSunkenFrame);
471  // compositeFrame->AddFrame(rightVerticalFrame, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY,0,2,2,2));
472  fRightVerticalFrame = new TGVerticalFrame(compositeFrame, 10, 10);
474 
475  fEventHandler = new TGLEventHandler(0, this);
476  CreateGLWidget();
477 }
478 
479 ////////////////////////////////////////////////////////////////////////////////
480 /// Update GUI components for embedded viewer selection change.
481 /// Override from TGLViewer.
482 
484 {
485  TGLPhysicalShape *selected = const_cast<TGLPhysicalShape*>(GetSelected());
486 
487  if (selected) {
488  fPShapeWrap->fPShape = selected;
491  else
493  } else {
494  fPShapeWrap->fPShape = 0;
496  }
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// Show the viewer
501 
503 {
504  fFrame->MapRaised();
506  RequestDraw();
507 }
508 
509 ////////////////////////////////////////////////////////////////////////////////
510 /// Close the viewer - destructed.
511 
513 {
514  // Commit suicide when contained GUI is closed.
515  delete this;
516 }
517 
518 ////////////////////////////////////////////////////////////////////////////////
519 /// Delete the menu bar.
520 
522 {
524 }
525 
526 ////////////////////////////////////////////////////////////////////////////////
527 /// Deactivate menu entries for closing the GL window and exiting ROOT.
528 
530 {
533 }
534 
535 ////////////////////////////////////////////////////////////////////////////////
536 /// Enable hiding of menu bar.
537 
539 {
540  if (fHideMenuBar)
541  return;
542 
544 
545  fMenuBar->Connect("ProcessedEvent(Event_t*)", "TGLSAViewer", this, "HandleMenuBarHiding(Event_t*)");
546  fMenuBut->Connect("ProcessedEvent(Event_t*)", "TGLSAViewer", this, "HandleMenuBarHiding(Event_t*)");
547 
550  fFrame->Layout();
551 
552  fMenuHidingTimer = new TTimer;
553  fMenuHidingTimer->Connect("Timeout()", "TGLSAViewer", this, "MenuHidingTimeout()");
554 
556 }
557 
558 ////////////////////////////////////////////////////////////////////////////////
559 /// Disable hiding of menu bar.
560 
562 {
563  if (!fHideMenuBar)
564  return;
565 
567 
568  fMenuBar->Disconnect("ProcessedEvent(Event_t*)", this, "HandleMenuBarHiding(Event_t*)");
569  fMenuBut->Disconnect("ProcessedEvent(Event_t*)", this, "HandleMenuBarHiding(Event_t*)");
570 
573  fFrame->Layout();
574 
576  delete fMenuHidingTimer;
577  fMenuHidingTimer = 0;
578 
580 }
581 
582 ////////////////////////////////////////////////////////////////////////////////
583 /// Maybe switch menu-bar / menu-button.
584 
586 {
587  TGFrame *f = (TGFrame*) gTQSender;
588 
589  if (f == fMenuBut)
590  {
591  if (ev->fType == kEnterNotify)
593  else
595  }
596  else if (f == fMenuBar)
597  {
598  if (ev->fType == kLeaveNotify &&
599  (ev->fX < 0 || ev->fX >= (Int_t) f->GetWidth() ||
600  ev->fY < 0 || ev->fY >= (Int_t) f->GetHeight()))
601  {
602  if (fMenuBar->GetCurrent() == 0)
604  else
605  fMenuBar->GetCurrent()->Connect("ProcessedEvent(Event_t*)", "TGLSAViewer", this, "HandleMenuBarHiding(Event_t*)");
606  }
607  else
608  {
610  }
611  }
612  else
613  {
614  f->Disconnect("ProcessedEvent(Event_t*)", this);
616  }
617 }
618 
619 ////////////////////////////////////////////////////////////////////////////////
620 /// Reset the timer for menu-bar hiding.
621 
623 {
624  // This happens, mysteriously.
625  if (fMenuHidingTimer == 0)
626  return;
627 
629 
630  fMenuHidingShowMenu = show_menu;
631 
635 }
636 
637 ////////////////////////////////////////////////////////////////////////////////
638 /// Action for menu-hiding timeout.
639 
641 {
643  if (fMenuHidingShowMenu) {
646  } else {
649  }
650  fFrame->Layout();
651 }
652 
653 ////////////////////////////////////////////////////////////////////////////////
654 /// Set global timeout for menu-hiding in mili-seconds.
655 /// Static function.
656 
658 {
659  fgMenuHidingTimeout = timeout;
660 }
661 
662 ////////////////////////////////////////////////////////////////////////////////
663 /// Process GUI message capture by the main GUI frame (TGLSAFrame).
664 
666 {
667  switch (GET_MSG(msg)) {
668  case kC_COMMAND:
669  switch (GET_SUBMSG(msg)) {
670  case kCM_BUTTON:
671  case kCM_MENU:
672  switch (parm1) {
673  case kGLHelpAbout: {
674 #ifdef R__UNIX
675  TString rootx = TROOT::GetBinDir() + "/root -a &";
676  gSystem->Exec(rootx);
677 #else
678 #ifdef WIN32
680 #else
681  char str[32];
682  snprintf(str,32, "About ROOT %s...", gROOT->GetVersion());
683  hd = new TRootHelpDialog(this, str, 600, 400);
684  hd->SetText(gHelpAbout);
685  hd->Popup();
686 #endif
687 #endif
688  break;
689  }
690  case kGLHelpViewer: {
691  TRootHelpDialog * hd = new TRootHelpDialog(fFrame, "Help on GL Viewer...", 660, 400);
692  hd->AddText(fgHelpText1);
693  hd->AddText(fgHelpText2);
694  hd->Popup();
695  break;
696  }
697  case kGLPerspYOZ:
699  break;
700  case kGLPerspXOZ:
702  break;
703  case kGLPerspXOY:
705  break;
706  case kGLXOY:
708  break;
709  case kGLXOZ:
711  break;
712  case kGLZOY:
714  break;
715  case kGLZOX:
717  break;
718  case kGLXnOY:
720  break;
721  case kGLXnOZ:
723  break;
724  case kGLZnOY:
726  break;
727  case kGLZnOX:
729  break;
730  case kGLOrthoRotate:
732  break;
733  case kGLOrthoDolly:
735  break;
736  case kGLSaveEPS:
737  SavePicture("viewer.eps");
738  break;
739  case kGLSavePDF:
740  SavePicture("viewer.pdf");
741  break;
742  case kGLSaveGIF:
743  SavePicture("viewer.gif");
744  break;
745  case kGLSaveAnimGIF:
746  SavePicture("viewer.gif+");
747  break;
748  case kGLSaveJPG:
749  SavePicture("viewer.jpg");
750  break;
751  case kGLSavePNG:
752  SavePicture("viewer.png");
753  break;
754  case kGLSaveAS:
755  {
756  TGFileInfo fi;
758  fi.fIniDir = StrDup(fDirName);
759  fi.fFileTypeIdx = fTypeIdx;
760  fi.fOverwrite = fOverwrite;
761  new TGFileDialog(gClient->GetDefaultRoot(), fFrame, kFDSave, &fi);
762  if (!fi.fFilename) return kTRUE;
763  TString ft(fi.fFileTypes[fi.fFileTypeIdx+1]);
764  fDirName = fi.fIniDir;
765  fTypeIdx = fi.fFileTypeIdx;
766  fOverwrite = fi.fOverwrite;
767 
768  TString file = fi.fFilename;
769  Bool_t match = kFALSE;
770  const char** fin = gGLSaveAsTypes; ++fin;
771  while (*fin != 0)
772  {
773  if (file.EndsWith(*fin + 1))
774  {
775  match = kTRUE;
776  break;
777  }
778  fin += 2;
779  }
780  if ( ! match)
781  {
782  file += ft(ft.Index("."), ft.Length());
783  }
784  SavePicture(file);
785  }
786  break;
787  case kGLHideMenus:
788  if (fHideMenuBar)
790  else
792  break;
793  case kGLEditObject:
795  break;
796  case kGLCloseViewer:
797  // Exit needs to be delayed to avoid bad drawable X ids - GUI
798  // will all be changed in future anyway
799  TTimer::SingleShot(50, "TGLSAFrame", fFrame, "SendCloseMessage()");
800  break;
801  case kGLQuitROOT:
802  if (!gApplication->ReturnFromRun())
803  delete this;
805  break;
806  default:
807  break;
808  }
809  default:
810  break;
811  }
812  default:
813  break;
814  }
815 
816  return kTRUE;
817 }
818 
819 ////////////////////////////////////////////////////////////////////////////////
820 /// Toggle state of the 'Edit Object' menu entry.
821 
823 {
826  else
829 }
830 
831 ////////////////////////////////////////////////////////////////////////////////
832 /// Toggle state of the 'Ortho allow rotate' menu entry.
833 
835 {
838  else
847 }
848 
849 ////////////////////////////////////////////////////////////////////////////////
850 /// Toggle state of the 'Ortho allow dolly' menu entry.
851 
853 {
856  else
862 }
TGEventHandler * fEventHandler
select record from last overlay select
Definition: TGLViewer.h:121
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
void ToggleEditObject()
Toggle state of the &#39;Edit Object&#39; 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
void Reset()
Reset the timer.
Definition: TTimer.cxx:157
static const Int_t fgInitW
Definition: TGLSAViewer.h:82
Bool_t fOverwrite
Definition: TGFileDialog.h:65
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:45
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
REAL splitter
Definition: triangle.c:616
UInt_t GetHeight() const
Definition: TGFrame.h:272
TGLOrthoCamera fOrthoXnOZCamera
Definition: TGLViewer.h:95
TGLSAFrame * fFrame
Definition: TGLSAViewer.h:52
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
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:97
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1835
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1797
#define gROOT
Definition: TROOT.h:402
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
Int_t fY
Definition: GuiTypes.h:177
Basic string class.
Definition: TString.h:125
#define gClient
Definition: TGClient.h:166
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:256
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
const TGLPhysicalShape * GetSelected() const
Return selected physical shape.
Definition: TGLViewer.cxx:2086
TGButton * fMenuBut
Definition: TGLSAViewer.h:68
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:987
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:165
Bool_t fHideMenuBar
Definition: TGLSAViewer.h:69
UInt_t GetWidth() const
Definition: TGFrame.h:271
virtual void MapRaised()
Definition: TGFrame.h:252
Handle_t GetId() const
Definition: TGObject.h:47
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1057
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:14
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:162
void HandleMenuBarHiding(Event_t *ev)
Maybe switch menu-bar / menu-button.
const char ** fFileTypes
Definition: TGFileDialog.h:63
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
void DeleteMenuBar()
Delete the menu bar.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2231
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:294
virtual TList * GetList() const
Definition: TGFrame.h:369
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
TGCanvas * GetTGCanvas() const
Definition: TGedEditor.h:83
TVirtualPad * fPad
Definition: TGLViewer.h:80
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
void ToggleOrthoDolly()
Toggle state of the &#39;Ortho allow dolly&#39; menu entry.
Encapsulation of format / contents of an OpenGL buffer.
Definition: TGLFormat.h:35
const char * gGLSaveAsTypes[]
TGLWidget * fGLWidget
Definition: TGLViewer.h:187
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:158
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:867
void RequestDraw(Short_t LOD=TGLRnrCtx::kLODMed)
Post request for redraw of viewer at level of detail &#39;LOD&#39; Request is directed via cross thread gVirt...
Definition: TGLViewer.cxx:440
TObject * GetExternal() const
void Close()
Close the viewer - destructed.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:655
Bool_t fOverwrite
Definition: TGLSAViewer.h:66
void DisableCloseMenuEntries()
Deactivate menu entries for closing the GL window and exiting ROOT.
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:174
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
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:818
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:219
const Mask_t kExposureMask
Definition: GuiTypes.h:164
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Ssiz_t Length() const
Definition: TString.h:386
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:229
TGPopupMenu * fFileSaveMenu
Definition: TGLSAViewer.h:55
virtual TGMenuTitle * GetCurrent() const
Definition: TGMenu.h:348
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
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:661
Base GL viewer object - used by both standalone and embedded (in pad) GL.
Definition: TGLViewer.h:53
TGClient * GetClient() const
Definition: TGObject.h:48
Standalone GL Viewer GUI main frame.
Definition: TGLSAFrame.h:28
~TGLSAViewer()
Destroy standalone viewer object.
#define gVirtualX
Definition: TVirtualX.h:350
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2544
Int_t GET_MSG(Long_t val)
const Bool_t kFALSE
Definition: RtypesCore.h:88
void SetDollyToZoom(Bool_t x)
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
long Long_t
Definition: RtypesCore.h:50
TGCompositeFrame * fRightVerticalFrame
Definition: TGLSAViewer.h:62
#define ClassImp(name)
Definition: Rtypes.h:359
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:165
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:94
TGLOrthoCamera fOrthoZOYCamera
Definition: TGLViewer.h:92
TGLOrthoCamera fOrthoZnOYCamera
Definition: TGLViewer.h:96
Int_t fFileTypeIdx
Definition: TGFileDialog.h:64
char * fFilename
Definition: TGFileDialog.h:61
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:1025
void SetCurrentCamera(ECameraType camera)
Set current active camera - &#39;cameraType&#39; one of: kCameraPerspX, kCameraPerspY, kCameraPerspZ, kCameraOrthoXOY, kCameraOrthoXOZ, kCameraOrthoZOY, kCameraOrthoXnOY, kCameraOrthoXnOZ, kCameraOrthoZnOY.
Definition: TGLViewer.cxx:1794
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 &#39;Ortho allow rotate&#39; menu entry.
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
Definition: TGedEditor.cxx:349
TGCompositeFrame * GetFrame() const
Return the main-frame.
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:37
Int_t fTypeIdx
Definition: TGLSAViewer.h:65
virtual void UnmapWindow()
Definition: TGFrame.h:253
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:1772
static Long_t fgMenuHidingTimeout
Definition: TGLSAViewer.h:75
Definition: file.py:1
virtual void MapWindow()
Definition: TGFrame.h:251
static const char * fgHelpText1
Definition: TGLSAViewer.h:85
const Mask_t kFocusChangeMask
Definition: GuiTypes.h:168
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
#define snprintf
Definition: civetweb.c:822
virtual void DeleteEntry(Int_t id)
Delete entry with specified id from menu.
Definition: TGMenu.cxx:1916
Bool_t fMenuHidingShowMenu
Definition: TGLSAViewer.h:71
void Show()
Show the viewer.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2842
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:1149
Bool_t ReturnFromRun() const
Definition: TApplication.h:148
virtual void DisconnectFromCanvas()
Disconnect this editor from the Selected signal of fCanvas.
Definition: TGedEditor.cxx:322
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
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:122
void DisableMenuBarHiding()
Disable hiding of menu bar.
virtual void TurnOn()
Add the timer to the system timer list.
Definition: TTimer.cxx:241
const Bool_t kTRUE
Definition: RtypesCore.h:87
static const char * fgHelpText2
Definition: TGLSAViewer.h:86
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:177
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition: TGMenu.cxx:415
const TGLLogicalShape * GetLogical() const
Bool_t SavePicture()
Save current image using the default file name which can be set via SetPictureFileName() and defaults...
Definition: TGLViewer.cxx:785
char * fIniDir
Definition: TGFileDialog.h:62
TGLPShapeObj * fPShapeWrap
GED editor.
Definition: TGLViewer.h:123
void SetTime(Long_t milliSec)
Definition: TTimer.h:90