Logo ROOT   6.10/00
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TCanvas.cxx
Go to the documentation of this file.
1 // @(#)root/gpad:$Id$
2 // Author: Rene Brun 12/12/94
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 <string.h>
13 #include <stdlib.h>
14 
15 #include "Riostream.h"
16 #include "TROOT.h"
17 #include "TCanvas.h"
18 #include "TClass.h"
19 #include "TStyle.h"
20 #include "TText.h"
21 #include "TBox.h"
22 #include "TCanvasImp.h"
23 #include "TDialogCanvas.h"
24 #include "TGuiFactory.h"
25 #include "TEnv.h"
26 #include "TError.h"
27 #include "TContextMenu.h"
28 #include "TControlBar.h"
29 #include "TInterpreter.h"
30 #include "TApplication.h"
31 #include "TColor.h"
32 #include "TVirtualPadEditor.h"
33 #include "TVirtualViewer3D.h"
34 #include "TPadPainter.h"
35 #include "TVirtualGL.h"
36 #include "TVirtualPS.h"
37 #include "TObjectSpy.h"
38 #include "TAxis.h"
39 #include "TView.h"
40 
41 #include "TVirtualMutex.h"
42 
43 class TCanvasInit {
44 public:
45  TCanvasInit() { TApplication::NeedGraphicsLibs(); }
46 };
47 static TCanvasInit gCanvasInit;
48 
49 
50 //*-*x16 macros/layout_canvas
51 
53 
55 
57 
58 
59 /** \class TCanvas
60 \ingroup gpad
61 
62 The Canvas class.
63 
64 A Canvas is an area mapped to a window directly under the control of the display
65 manager. A ROOT session may have several canvases open at any given time.
66 
67 A Canvas may be subdivided into independent graphical areas: the __Pads__.
68 A canvas has a default pad which has the name of the canvas itself.
69 An example of a Canvas layout is sketched in the picture below.
70 
71 \image html gpad_canvas.png
72 
73 This canvas contains two pads named P1 and P2. Both Canvas, P1 and P2 can be
74 moved, grown, shrinked using the normal rules of the Display manager.
75 
76 Once objects have been drawn in a canvas, they can be edited/moved by pointing
77 directly to them. The cursor shape is changed to suggest the type of action that
78 one can do on this object. Clicking with the right mouse button on an object
79 pops-up a contextmenu with a complete list of actions possible on this object.
80 
81 A graphical editor may be started from the canvas "View" menu under the menu
82 entry "Toolbar".
83 
84 An interactive HELP is available by clicking on the HELP button at the top right
85 of the canvas. It gives a short explanation about the canvas' menus.
86 
87 A canvas may be automatically divided into pads via `TPad::Divide`.
88 
89 At creation time, no matter if in interactive or batch mode, the canvas size
90 defines the size of the canvas window (including the size of the window
91 manager's decoration). To define precisely the graphics area size of a canvas in
92 the interactive mode, the following four lines of code should be used:
93 ~~~ {.cpp}
94  {
95  Double_t w = 600;
96  Double_t h = 600;
97  TCanvas * c1 = new TCanvas("c", "c", w, h);
98  c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
99  }
100 ~~~
101 and in the batch mode simply do:
102 ~~~ {.cpp}
103  c->SetCanvasSize(w,h);
104 ~~~
105 */
106 
107 ////////////////////////////////////////////////////////////////////////////////
108 /// Canvas default constructor.
109 
110 TCanvas::TCanvas(Bool_t build) : TPad(), fDoubleBuffer(0)
111 {
112  fPainter = 0;
113  fWindowTopX = 0;
114  fWindowTopY = 0;
115  fWindowWidth = 0;
116  fWindowHeight = 0;
117  fCw = 0;
118  fCh = 0;
119  fXsizeUser = 0;
120  fYsizeUser = 0;
121  fXsizeReal = kDefaultCanvasSize;
122  fYsizeReal = kDefaultCanvasSize;
123  fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
124  fEvent = -1;
125  fEventX = -1;
126  fEventY = -1;
127  fSelectedX = 0;
128  fSelectedY = 0;
129  fRetained = kTRUE;
130  fDrawn = kFALSE;
131  fSelected = 0;
132  fClickSelected = 0;
133  fSelectedPad = 0;
134  fClickSelectedPad = 0;
135  fPadSave = 0;
136  fCanvasImp = 0;
137  fContextMenu = 0;
138 
139  fUseGL = gStyle->GetCanvasPreferGL();
140 
141  if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
142  Constructor();
143  } else {
144  const char *defcanvas = gROOT->GetDefCanvasName();
145  char *cdef;
146 
147  TList *lc = (TList*)gROOT->GetListOfCanvases();
148  if (lc->FindObject(defcanvas)) {
149  Int_t n = lc->GetSize()+1;
150  while (lc->FindObject(Form("%s_n%d",defcanvas,n))) n++;
151  cdef = StrDup(Form("%s_n%d",defcanvas,n));
152  } else {
153  cdef = StrDup(Form("%s",defcanvas));
154  }
155  Constructor(cdef, cdef, 1);
156  delete [] cdef;
157  }
158 }
159 
160 ////////////////////////////////////////////////////////////////////////////////
161 /// Canvas default constructor
162 
164 {
165  if (gThreadXAR) {
166  void *arr[2];
167  arr[1] = this;
168  if ((*gThreadXAR)("CANV", 2, arr, 0)) return;
169  }
170 
171  fCanvas = 0;
172  fCanvasID = -1;
173  fCanvasImp = 0;
174  fBatch = kTRUE;
175  fUpdating = kFALSE;
176 
177  fContextMenu = 0;
178  fSelected = 0;
179  fClickSelected = 0;
180  fSelectedPad = 0;
181  fClickSelectedPad = 0;
182  fPadSave = 0;
183  SetBit(kAutoExec);
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
190 /// which is placed in a TGFrame. This ctor is only called via the
191 /// TRootEmbeddedCanvas class.
192 ///
193 /// If "name" starts with "gl" the canvas is ready to receive GL output.
194 
195 TCanvas::TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
196 {
197  fPainter = 0;
198  Init();
199 
200  fCanvasID = winid;
201  fWindowTopX = 0;
202  fWindowTopY = 0;
203  fWindowWidth = ww;
204  fWindowHeight = wh;
205  fCw = ww + 4;
206  fCh = wh +28;
207  fBatch = kFALSE;
208  fUpdating = kFALSE;
209 
210  //This is a very special ctor. A window exists already!
211  //Can create painter now.
213 
214  if (fUseGL) {
215  fGLDevice = gGLManager->CreateGLContext(winid);
216  if (fGLDevice == -1)
217  fUseGL = kFALSE;
218  }
219 
220  CreatePainter();
221 
223  if (!fCanvasImp) return;
224  SetName(name);
225  Build();
226 }
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 /// Create a new canvas with a predefined size form.
230 /// If form < 0 the menubar is not shown.
231 ///
232 /// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
233 /// - form = 2 500x500 at 20,20
234 /// - form = 3 500x500 at 30,30
235 /// - form = 4 500x500 at 40,40
236 /// - form = 5 500x500 at 50,50
237 ///
238 /// If "name" starts with "gl" the canvas is ready to receive GL output.
239 
240 TCanvas::TCanvas(const char *name, const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
241 {
242  fPainter = 0;
244 
245  Constructor(name, title, form);
246 }
247 
248 ////////////////////////////////////////////////////////////////////////////////
249 /// Create a new canvas with a predefined size form.
250 /// If form < 0 the menubar is not shown.
251 ///
252 /// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
253 /// - form = 2 500x500 at 20,20
254 /// - form = 3 500x500 at 30,30
255 /// - form = 4 500x500 at 40,40
256 /// - form = 5 500x500 at 50,50
257 
258 void TCanvas::Constructor(const char *name, const char *title, Int_t form)
259 {
260  if (gThreadXAR) {
261  void *arr[6];
262  static Int_t ww = 500;
263  static Int_t wh = 500;
264  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
265  if ((*gThreadXAR)("CANV", 6, arr, 0)) return;
266  }
267 
268  Init();
269  SetBit(kMenuBar,1);
270  if (form < 0) {
271  form = -form;
272  SetBit(kMenuBar,0);
273  }
274 
275  fCanvas = this;
276 
277  fCanvasID = -1;
278  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
279  if (old && old->IsOnHeap()) {
280  Warning("Constructor","Deleting canvas with same name: %s",name);
281  delete old;
282  }
283  if (!name[0] || gROOT->IsBatch()) { //We are in Batch mode
284  fWindowTopX = fWindowTopY = 0;
285  if (form == 1) {
288  } else {
289  fWindowWidth = 500;
290  fWindowHeight = 500;
291  }
292  fCw = fWindowWidth;
293  fCh = fWindowHeight;
295  if (!fCanvasImp) return;
296  fBatch = kTRUE;
297  } else { //normal mode with a screen window
299  if (form < 1 || form > 5) form = 1;
300  if (form == 1) {
301  UInt_t uh = UInt_t(cx*gStyle->GetCanvasDefH());
302  UInt_t uw = UInt_t(cx*gStyle->GetCanvasDefW());
303  Int_t ux = Int_t(cx*gStyle->GetCanvasDefX());
304  Int_t uy = Int_t(cx*gStyle->GetCanvasDefY());
305  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, ux, uy, uw, uh);
306  }
307  fCw = 500;
308  fCh = 500;
309  if (form == 2) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 20, 20, UInt_t(cx*500), UInt_t(cx*500));
310  if (form == 3) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 30, 30, UInt_t(cx*500), UInt_t(cx*500));
311  if (form == 4) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 40, 40, UInt_t(cx*500), UInt_t(cx*500));
312  if (form == 5) fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, 50, 50, UInt_t(cx*500), UInt_t(cx*500));
313  if (!fCanvasImp) return;
314 
315  if (!gROOT->IsBatch() && fCanvasID == -1)
317 
319  fBatch = kFALSE;
320  }
321 
322  CreatePainter();
323 
324  SetName(name);
325  SetTitle(title); // requires fCanvasImp set
326  Build();
327 
328  // Popup canvas
329  fCanvasImp->Show();
330 }
331 
332 ////////////////////////////////////////////////////////////////////////////////
333 /// Create a new canvas at a random position.
334 ///
335 /// \param[in] name canvas name
336 /// \param[in] title canvas title
337 /// \param[in] ww is the canvas size in pixels along X
338 /// (if ww < 0 the menubar is not shown)
339 /// \param[in] wh is the canvas size in pixels along Y
340 ///
341 /// If "name" starts with "gl" the canvas is ready to receive GL output.
342 
343 TCanvas::TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
344 {
345  fPainter = 0;
347 
348  Constructor(name, title, ww, wh);
349 }
350 
351 ////////////////////////////////////////////////////////////////////////////////
352 /// Create a new canvas at a random position.
353 ///
354 /// \param[in] name canvas name
355 /// \param[in] title canvas title
356 /// \param[in] ww is the canvas size in pixels along X
357 /// (if ww < 0 the menubar is not shown)
358 /// \param[in] wh is the canvas size in pixels along Y
359 
360 void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t wh)
361 {
362  if (gThreadXAR) {
363  void *arr[6];
364  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
365  if ((*gThreadXAR)("CANV", 6, arr, 0)) return;
366  }
367 
368  Init();
369  SetBit(kMenuBar,1);
370  if (ww < 0) {
371  ww = -ww;
372  SetBit(kMenuBar,0);
373  }
374  fCw = ww;
375  fCh = wh;
376  fCanvasID = -1;
377  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
378  if (old && old->IsOnHeap()) {
379  Warning("Constructor","Deleting canvas with same name: %s",name);
380  delete old;
381  }
382  if (!name[0] || gROOT->IsBatch()) { //We are in Batch mode
383  fWindowTopX = fWindowTopY = 0;
384  fWindowWidth = ww;
385  fWindowHeight = wh;
386  fCw = ww;
387  fCh = wh;
389  if (!fCanvasImp) return;
390  fBatch = kTRUE;
391  } else {
393  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
394  if (!fCanvasImp) return;
395 
396  if (!gROOT->IsBatch() && fCanvasID == -1)
398 
400  fBatch = kFALSE;
401  }
402 
403  CreatePainter();
404 
405  SetName(name);
406  SetTitle(title); // requires fCanvasImp set
407  Build();
408 
409  // Popup canvas
410  fCanvasImp->Show();
411 }
412 
413 ////////////////////////////////////////////////////////////////////////////////
414 /// Create a new canvas.
415 ///
416 /// \param[in] name canvas name
417 /// \param[in] title canvas title
418 /// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
419 /// the canvas (if wtopx < 0) the menubar is not shown)
420 /// \param[in] ww is the canvas size in pixels along X
421 /// \param[in] wh is the canvas size in pixels along Y
422 ///
423 /// If "name" starts with "gl" the canvas is ready to receive GL output.
424 
425 TCanvas::TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
426  : TPad(), fDoubleBuffer(0)
427 {
428  fPainter = 0;
430 
431  Constructor(name, title, wtopx, wtopy, ww, wh);
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Create a new canvas.
436 ///
437 /// \param[in] name canvas name
438 /// \param[in] title canvas title
439 /// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
440 /// the canvas (if wtopx < 0) the menubar is not shown)
441 /// \param[in] ww is the canvas size in pixels along X
442 /// \param[in] wh is the canvas size in pixels along Y
443 
444 void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
445  Int_t wtopy, Int_t ww, Int_t wh)
446 {
447  if (gThreadXAR) {
448  void *arr[8];
449  arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title;
450  arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
451  if ((*gThreadXAR)("CANV", 8, arr, 0)) return;
452  }
453 
454  Init();
455  SetBit(kMenuBar,1);
456  if (wtopx < 0) {
457  wtopx = -wtopx;
458  SetBit(kMenuBar,0);
459  }
460  fCw = ww;
461  fCh = wh;
462  fCanvasID = -1;
463  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
464  if (old && old->IsOnHeap()) {
465  Warning("Constructor","Deleting canvas with same name: %s",name);
466  delete old;
467  }
468  if (!name[0] || gROOT->IsBatch()) { //We are in Batch mode
469  fWindowTopX = fWindowTopY = 0;
470  fWindowWidth = ww;
471  fWindowHeight = wh;
472  fCw = ww;
473  fCh = wh;
475  if (!fCanvasImp) return;
476  fBatch = kTRUE;
477  } else { //normal mode with a screen window
479  fCanvasImp = gGuiFactory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
480  if (!fCanvasImp) return;
481 
482  if (!gROOT->IsBatch() && fCanvasID == -1)
484 
486  fBatch = kFALSE;
487  }
488 
489  CreatePainter();
490 
491  SetName(name);
492  SetTitle(title); // requires fCanvasImp set
493  Build();
494 
495  // Popup canvas
496  fCanvasImp->Show();
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// Initialize the TCanvas members. Called by all constructors.
501 
503 {
504  // Make sure the application environment exists. It is need for graphics
505  // (colors are initialized in the TApplication ctor).
506  if (!gApplication)
508 
509  // Load and initialize graphics libraries if
510  // TApplication::NeedGraphicsLibs() has been called by a
511  // library static initializer.
512  if (gApplication)
514 
515  // Get some default from .rootrc. Used in fCanvasImp->InitWindow().
516  fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
517  SetBit(kMoveOpaque, gEnv->GetValue("Canvas.MoveOpaque", 0));
518  SetBit(kResizeOpaque, gEnv->GetValue("Canvas.ResizeOpaque", 0));
519  if (gEnv->GetValue("Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
520  if (gEnv->GetValue("Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
521  if (gEnv->GetValue("Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
522  if (gEnv->GetValue("Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
523  if (gEnv->GetValue("Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
524 
525  // Fill canvas ROOT data structure
526  fXsizeUser = 0;
527  fYsizeUser = 0;
530 
531  fDISPLAY = "$DISPLAY";
532  fUpdating = kFALSE;
533  fRetained = kTRUE;
534  fSelected = 0;
535  fClickSelected = 0;
536  fSelectedX = 0;
537  fSelectedY = 0;
538  fSelectedPad = 0;
540  fPadSave = 0;
541  fEvent = -1;
542  fEventX = -1;
543  fEventY = -1;
544  fContextMenu = 0;
545  fDrawn = kFALSE;
546 }
547 
548 ////////////////////////////////////////////////////////////////////////////////
549 /// Build a canvas. Called by all constructors.
550 
552 {
553  // Get window identifier
554  if (fCanvasID == -1 && fCanvasImp)
556  if (fCanvasID == -1) return;
557 
558  if (fCw !=0 && fCh !=0) {
561  }
562 
563  // Set Pad parameters
564  gPad = this;
565  fCanvas = this;
566  fMother = (TPad*)gPad;
567 
568  if (!IsBatch()) { //normal mode with a screen window
569  // Set default physical canvas attributes
570  //Should be done via gVirtualX, not via fPainter (at least now). No changes here.
571  gVirtualX->SelectWindow(fCanvasID);
572  gVirtualX->SetFillColor(1); //Set color index for fill area
573  gVirtualX->SetLineColor(1); //Set color index for lines
574  gVirtualX->SetMarkerColor(1); //Set color index for markers
575  gVirtualX->SetTextColor(1); //Set color index for text
576  // Clear workstation
577  gVirtualX->ClearWindow();
578 
579  // Set Double Buffer on by default
580  SetDoubleBuffer(1);
581 
582  // Get effective window parameters (with borders and menubar)
585 
586  // Get effective canvas parameters without borders
587  Int_t dum1, dum2;
588  gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
589 
590  fContextMenu = new TContextMenu("ContextMenu");
591  } else {
592  // Make sure that batch interactive canvas sizes are the same
593  fCw -= 4;
594  fCh -= 28;
595  }
596  gROOT->GetListOfCanvases()->Add(this);
597 
598  if (!fPrimitives) {
599  fPrimitives = new TList;
601  SetFillStyle(1001);
613  fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
614  SetPad(0, 0, 1, 1);
615  Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y
616 
618  if (vpp) vpp->SelectDrawable(fPixmapID);//gVirtualX->SelectPixmap(fPixmapID); //pixmap must be selected
619  PaintBorder(GetFillColor(), kTRUE); //paint background
620  }
621 
622  // transient canvases have typically no menubar and should not get
623  // by default the event status bar (if set by default)
624  if (TestBit(kMenuBar) && fCanvasImp) {
626  // ... and toolbar + editor
630  }
631 }
632 
633 ////////////////////////////////////////////////////////////////////////////////
634 /// Canvas destructor
635 
637 {
638  Destructor();
639 }
640 
641 ////////////////////////////////////////////////////////////////////////////////
642 /// Browse.
643 
645 {
646  Draw();
647  cd();
648  if (fgIsFolder) fPrimitives->Browse(b);
649 }
650 
651 ////////////////////////////////////////////////////////////////////////////////
652 /// Actual canvas destructor.
653 
655 {
656  if (gThreadXAR) {
657  void *arr[2];
658  arr[1] = this;
659  if ((*gThreadXAR)("CDEL", 2, arr, 0)) return;
660  }
661 
662  if (!TestBit(kNotDeleted)) return;
663 
664  if (fContextMenu) { delete fContextMenu; fContextMenu = 0; }
665  if (!gPad) return;
666 
667  Close();
668 
669  //If not yet (batch mode?).
670  delete fPainter;
671 }
672 
673 ////////////////////////////////////////////////////////////////////////////////
674 /// Set current canvas & pad. Returns the new current pad,
675 /// or 0 in case of failure.
676 /// See TPad::cd() for an explanation of the parameter.
677 
679 {
680  if (fCanvasID == -1) return 0;
681 
682  TPad::cd(subpadnumber);
683 
684  // in case doublebuffer is off, draw directly onto display window
685  if (!IsBatch()) {
686  if (!fDoubleBuffer)
687  gVirtualX->SelectWindow(fCanvasID);//Ok, does not matter for glpad.
688  }
689  return gPad;
690 }
691 
692 ////////////////////////////////////////////////////////////////////////////////
693 /// Remove all primitives from the canvas.
694 /// If option "D" is specified, direct sub-pads are cleared but not deleted.
695 /// This option is not recursive, i.e. pads in direct sub-pads are deleted.
696 
698 {
699  if (fCanvasID == -1) return;
700 
702 
703  TString opt = option;
704  opt.ToLower();
705  if (opt.Contains("d")) {
706  // clear subpads, but do not delete pads in case the canvas
707  // has been divided (note: option "D" is propagated so could cause
708  // conflicts for primitives using option "D" for something else)
709  if (fPrimitives) {
710  TIter next(fPrimitives);
711  TObject *obj;
712  while ((obj=next())) {
713  obj->Clear(option);
714  }
715  }
716  } else {
717  //default, clear everything in the canvas. Subpads are deleted
718  TPad::Clear(option); //Remove primitives from pad
719  }
720 
721  fSelected = 0;
722  fClickSelected = 0;
723  fSelectedPad = 0;
724  fClickSelectedPad = 0;
725 }
726 
727 ////////////////////////////////////////////////////////////////////////////////
728 /// Emit pad Cleared signal.
729 
731 {
732  Emit("Cleared(TVirtualPad*)", (Long_t)pad);
733 }
734 
735 ////////////////////////////////////////////////////////////////////////////////
736 /// Emit Closed signal.
737 
739 {
740  Emit("Closed()");
741 }
742 
743 ////////////////////////////////////////////////////////////////////////////////
744 /// Close canvas.
745 ///
746 /// Delete window/pads data structure
747 
749 {
750  TPad *padsave = (TPad*)gPad;
751  TCanvas *cansave = 0;
752  if (padsave) cansave = (TCanvas*)gPad->GetCanvas();
753 
754  if (fCanvasID != -1 && fCanvasImp) {
755 
756  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
757  gInterpreter->Execute(this, IsA(), "Close", option);
758  return;
759  }
760 
762 
764 
765  cd();
766  TPad::Close(option);
767 
768  if (!IsBatch()) {
769  gVirtualX->SelectWindow(fCanvasID); //select current canvas
770 
772 
773  fCanvasImp->Close();
774  }
775  fCanvasID = -1;
776  fBatch = kTRUE;
777 
778  gROOT->GetListOfCanvases()->Remove(this);
779 
780  // Close actual window on screen
782  }
783 
784  if (cansave == this) {
785  gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
786  } else {
787  gPad = padsave;
788  }
789 
790  Closed();
791 }
792 
793 ////////////////////////////////////////////////////////////////////////////////
794 /// Copy the canvas pixmap of the pad to the canvas.
795 
797 {
798  if (!IsBatch()) {
799  CopyPixmap();
801  }
802 }
803 
804 ////////////////////////////////////////////////////////////////////////////////
805 /// Draw a canvas.
806 /// If a canvas with the name is already on the screen, the canvas is repainted.
807 /// This function is useful when a canvas object has been saved in a Root file.
808 /// One can then do:
809 /// ~~~ {.cpp}
810 /// Root > Tfile f("file.root");
811 /// Root > canvas.Draw();
812 /// ~~~
813 
815 {
816  // Load and initialize graphics libraries if
817  // TApplication::NeedGraphicsLibs() has been called by a
818  // library static initializer.
819  if (gApplication)
821 
822  fDrawn = kTRUE;
823 
824  TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
825  if (old == this) {
826  Paint();
827  return;
828  }
829  if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
830 
831  if (fWindowWidth == 0) {
832  if (fCw !=0) fWindowWidth = fCw+4;
833  else fWindowWidth = 800;
834  }
835  if (fWindowHeight == 0) {
836  if (fCh !=0) fWindowHeight = fCh+28;
837  else fWindowHeight = 600;
838  }
839  if (gROOT->IsBatch()) { //We are in Batch mode
841  if (!fCanvasImp) return;
842  fBatch = kTRUE;
843 
844  } else { //normal mode with a screen window
847  if (!fCanvasImp) return;
849  }
850  Build();
851  ResizePad();
853  fCanvasImp->Show();
854  Modified();
855 }
856 
857 ////////////////////////////////////////////////////////////////////////////////
858 /// Draw a clone of this canvas
859 /// A new canvas is created that is a clone of this canvas
860 
862 {
863  const char *defcanvas = gROOT->GetDefCanvasName();
864  char *cdef;
865 
866  TList *lc = (TList*)gROOT->GetListOfCanvases();
867  if (lc->FindObject(defcanvas))
868  cdef = Form("%s_n%d",defcanvas,lc->GetSize()+1);
869  else
870  cdef = Form("%s",defcanvas);
871 
872  TCanvas *newCanvas = (TCanvas*)Clone();
873  newCanvas->SetName(cdef);
874 
875  newCanvas->Draw(option);
876  newCanvas->Update();
877  return newCanvas;
878 }
879 
880 ////////////////////////////////////////////////////////////////////////////////
881 /// Draw a clone of this canvas into the current pad
882 /// In an interactive session, select the destination/current pad
883 /// with the middle mouse button, then point to the canvas area to select
884 /// the canvas context menu item DrawClonePad.
885 /// Note that the original canvas may have subpads.
886 
888 {
889  TPad *padsav = (TPad*)gPad;
890  TPad *selpad = (TPad*)gROOT->GetSelectedPad();
891  TPad *pad = padsav;
892  if (pad == this) pad = selpad;
893  if (padsav == 0 || pad == 0 || pad == this) {
894  TCanvas *newCanvas = (TCanvas*)DrawClone();
896  return newCanvas;
897  }
898  if (fCanvasID == -1) {
901  if (!fCanvasImp) return 0;
904  }
905  this->cd();
906  TObject *obj, *clone;
907  //copy pad attributes
908  pad->Range(fX1,fY1,fX2,fY2);
909  pad->SetTickx(GetTickx());
910  pad->SetTicky(GetTicky());
911  pad->SetGridx(GetGridx());
912  pad->SetGridy(GetGridy());
913  pad->SetLogx(GetLogx());
914  pad->SetLogy(GetLogy());
915  pad->SetLogz(GetLogz());
918  TAttLine::Copy((TAttLine&)*pad);
919  TAttFill::Copy((TAttFill&)*pad);
920  TAttPad::Copy((TAttPad&)*pad);
921 
922  //copy primitives
923  TIter next(GetListOfPrimitives());
924  while ((obj=next())) {
925  pad->cd();
926  clone = obj->Clone();
927  pad->GetListOfPrimitives()->Add(clone,next.GetOption());
928  }
929  pad->ResizePad();
930  pad->Modified();
931  pad->Update();
932  if (padsav) padsav->cd();
933  return 0;
934 }
935 
936 ////////////////////////////////////////////////////////////////////////////////
937 /// Report name and title of primitive below the cursor.
938 ///
939 /// This function is called when the option "Event Status"
940 /// in the canvas menu "Options" is selected.
941 
942 void TCanvas::DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
943 {
944  const Int_t kTMAX=256;
945  static char atext[kTMAX];
946 
947  if (!TestBit(kShowEventStatus) || !selected) return;
948 
949  if (!fCanvasImp) return; //this may happen when closing a TAttCanvas
950 
951  TVirtualPad* savepad;
952  savepad = gPad;
953  gPad = GetSelectedPad();
954 
955  fCanvasImp->SetStatusText(selected->GetTitle(),0);
956  fCanvasImp->SetStatusText(selected->GetName(),1);
957  if (event == kKeyPress)
958  snprintf(atext, kTMAX, "%c", (char) px);
959  else
960  snprintf(atext, kTMAX, "%d,%d", px, py);
961  fCanvasImp->SetStatusText(atext,2);
962  fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
963  gPad = savepad;
964 }
965 
966 ////////////////////////////////////////////////////////////////////////////////
967 /// Get editor bar.
968 
970 {
972 }
973 
974 ////////////////////////////////////////////////////////////////////////////////
975 /// Embedded a canvas into a TRootEmbeddedCanvas. This method is only called
976 /// via TRootEmbeddedCanvas::AdoptCanvas.
977 
978 void TCanvas::EmbedInto(Int_t winid, Int_t ww, Int_t wh)
979 {
980  // If fCanvasImp already exists, no need to go further.
981  if(fCanvasImp) return;
982 
983  fCanvasID = winid;
984  fWindowTopX = 0;
985  fWindowTopY = 0;
986  fWindowWidth = ww;
987  fWindowHeight = wh;
988  fCw = ww;
989  fCh = wh;
990  fBatch = kFALSE;
991  fUpdating = kFALSE;
992 
994  if (!fCanvasImp) return;
995  Build();
996  Resize();
997 }
998 
999 ////////////////////////////////////////////////////////////////////////////////
1000 /// Generate kMouseEnter and kMouseLeave events depending on the previously
1001 /// selected object and the currently selected object. Does nothing if the
1002 /// selected object does not change.
1003 
1004 void TCanvas::EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
1005 {
1006  if (prevSelObj == fSelected) return;
1007 
1008  TPad *padsav = (TPad *)gPad;
1009  Int_t sevent = fEvent;
1010 
1011  if (prevSelObj) {
1012  gPad = prevSelPad;
1013  prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
1014  fEvent = kMouseLeave;
1015  RunAutoExec();
1016  ProcessedEvent(kMouseLeave, fEventX, fEventY, prevSelObj); // emit signal
1017  }
1018 
1019  gPad = fSelectedPad;
1020 
1021  if (fSelected) {
1023  fEvent = kMouseEnter;
1024  RunAutoExec();
1025  ProcessedEvent(kMouseEnter, fEventX, fEventY, fSelected); // emit signal
1026  }
1027 
1028  fEvent = sevent;
1029  gPad = padsav;
1030 }
1031 
1032 ////////////////////////////////////////////////////////////////////////////////
1033 /// Execute action corresponding to one event.
1034 ///
1035 /// This member function must be implemented to realize the action
1036 /// corresponding to the mouse click on the object in the canvas
1037 ///
1038 /// Only handle mouse motion events in TCanvas, all other events are
1039 /// ignored for the time being
1040 
1042 {
1043  if (gROOT->GetEditorMode()) {
1044  TPad::ExecuteEvent(event,px,py);
1045  return;
1046  }
1047 
1048  switch (event) {
1049 
1050  case kMouseMotion:
1051  SetCursor(kCross);
1052  break;
1053  }
1054 }
1055 
1056 ////////////////////////////////////////////////////////////////////////////////
1057 /// Turn rubberband feedback mode on or off.
1058 
1060 {
1061  if (set) {
1062  SetDoubleBuffer(0); // turn off double buffer mode
1063  gVirtualX->SetDrawMode(TVirtualX::kInvert); // set the drawing mode to XOR mode
1064  } else {
1065  SetDoubleBuffer(1); // turn on double buffer mode
1066  gVirtualX->SetDrawMode(TVirtualX::kCopy); // set drawing mode back to normal (copy) mode
1067  }
1068 }
1069 
1070 ////////////////////////////////////////////////////////////////////////////////
1071 /// Flush canvas buffers.
1072 
1074 {
1075  if (fCanvasID == -1) return;
1076 
1077  TPad *padsav = (TPad*)gPad;
1078  cd();
1079  if (!IsBatch()) {
1080  if (!UseGL()) {
1081  gVirtualX->SelectWindow(fCanvasID);
1082  gPad = padsav; //don't do cd() because than also the pixmap is changed
1083  CopyPixmaps();
1084  gVirtualX->UpdateWindow(1);
1085  } else {
1086  TVirtualPS *tvps = gVirtualPS;
1087  gVirtualPS = 0;
1088  gGLManager->MakeCurrent(fGLDevice);
1089  fPainter->InitPainter();
1090  Paint();
1091  if (padsav && padsav->GetCanvas() == this) {
1092  padsav->cd();
1093  padsav->HighLight(padsav->GetHighLightColor());
1094  //cd();
1095  }
1096  fPainter->LockPainter();
1097  gGLManager->Flush(fGLDevice);
1098  gVirtualPS = tvps;
1099  }
1100  }
1101  if (padsav) padsav->cd();
1102 }
1103 
1104 ////////////////////////////////////////////////////////////////////////////////
1105 /// Force a copy of current style for all objects in canvas.
1106 
1108 {
1109  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1110  gInterpreter->Execute(this, IsA(), "UseCurrentStyle", "");
1111  return;
1112  }
1113 
1115 
1117 
1118  if (gStyle->IsReading()) {
1122  } else {
1126  }
1127 }
1128 
1129 ////////////////////////////////////////////////////////////////////////////////
1130 /// Returns current top x position of window on screen.
1131 
1133 {
1136 
1137  return fWindowTopX;
1138 }
1139 
1140 ////////////////////////////////////////////////////////////////////////////////
1141 /// Returns current top y position of window on screen.
1142 
1144 {
1147 
1148  return fWindowTopY;
1149 }
1150 
1151 ////////////////////////////////////////////////////////////////////////////////
1152 /// Handle Input Events.
1153 ///
1154 /// Handle input events, like button up/down in current canvas.
1155 
1157 {
1158  TPad *pad;
1159  TPad *prevSelPad = (TPad*) fSelectedPad;
1160  TObject *prevSelObj = fSelected;
1161 
1162  fPadSave = (TPad*)gPad;
1163  cd(); // make sure this canvas is the current canvas
1164 
1165  fEvent = event;
1166  fEventX = px;
1167  fEventY = py;
1168 
1169  switch (event) {
1170 
1171  case kMouseMotion:
1172  // highlight object tracked over
1173  pad = Pick(px, py, prevSelObj);
1174  if (!pad) return;
1175 
1176  EnterLeave(prevSelPad, prevSelObj);
1177 
1178  gPad = pad; // don't use cd() we will use the current
1179  // canvas via the GetCanvas member and not via
1180  // gPad->GetCanvas
1181 
1182  if (fSelected) {
1183  fSelected->ExecuteEvent(event, px, py);
1184  RunAutoExec();
1185  }
1186 
1187  break;
1188 
1189  case kMouseEnter:
1190  // mouse enters canvas
1192  break;
1193 
1194  case kMouseLeave:
1195  // mouse leaves canvas
1196  {
1197  // force popdown of tooltips
1198  TObject *sobj = fSelected;
1199  TPad *spad = fSelectedPad;
1200  fSelected = 0;
1201  fSelectedPad = 0;
1202  EnterLeave(prevSelPad, prevSelObj);
1203  fSelected = sobj;
1204  fSelectedPad = spad;
1206  }
1207  break;
1208 
1209  case kButton1Double:
1210  // triggered on the second button down within 350ms and within
1211  // 3x3 pixels of the first button down, button up finishes action
1212 
1213  case kButton1Down:
1214  // find pad in which input occurred
1215  pad = Pick(px, py, prevSelObj);
1216  if (!pad) return;
1217 
1218  gPad = pad; // don't use cd() because we won't draw in pad
1219  // we will only use its coordinate system
1220 
1221  if (fSelected) {
1222  FeedbackMode(kTRUE); // to draw in rubberband mode
1223  fSelected->ExecuteEvent(event, px, py);
1224 
1225  RunAutoExec();
1226  }
1227 
1228  break;
1229 
1230  case kArrowKeyPress:
1231  case kArrowKeyRelease:
1232  case kButton1Motion:
1233  case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
1234  if (fSelected) {
1235  gPad = fSelectedPad;
1236 
1237  fSelected->ExecuteEvent(event, px, py);
1238  gVirtualX->Update();
1240  Bool_t resize = kFALSE;
1242  resize = ((TBox*)fSelected)->IsBeingResized();
1244  resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1245 
1246  if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1247  gPad = fPadSave;
1248  Update();
1250  }
1251  }
1252 
1253  RunAutoExec();
1254  }
1255 
1256  break;
1257 
1258  case kButton1Up:
1259 
1260  if (fSelected) {
1261  gPad = fSelectedPad;
1262 
1263  fSelected->ExecuteEvent(event, px, py);
1264 
1265  RunAutoExec();
1266 
1267  if (fPadSave)
1268  gPad = fPadSave;
1269  else {
1270  gPad = this;
1271  fPadSave = this;
1272  }
1273 
1274  Update(); // before calling update make sure gPad is reset
1275  }
1276  break;
1277 
1278 //*-*----------------------------------------------------------------------
1279 
1280  case kButton2Down:
1281  // find pad in which input occurred
1282  pad = Pick(px, py, prevSelObj);
1283  if (!pad) return;
1284 
1285  gPad = pad; // don't use cd() because we won't draw in pad
1286  // we will only use its coordinate system
1287 
1289 
1290  if (fSelected) fSelected->Pop(); // pop object to foreground
1291  pad->cd(); // and make its pad the current pad
1292  if (gDebug)
1293  printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
1294 
1295  // loop over all canvases to make sure that only one pad is highlighted
1296  {
1297  TIter next(gROOT->GetListOfCanvases());
1298  TCanvas *tc;
1299  while ((tc = (TCanvas *)next()))
1300  tc->Update();
1301  }
1302 
1303  //if (pad->GetGLDevice() != -1 && fSelected)
1304  // fSelected->ExecuteEvent(event, px, py);
1305 
1306  break; // don't want fPadSave->cd() to be executed at the end
1307 
1308  case kButton2Motion:
1309  //was empty!
1310  case kButton2Up:
1311  if (fSelected) {
1312  gPad = fSelectedPad;
1313 
1314  fSelected->ExecuteEvent(event, px, py);
1315  RunAutoExec();
1316  }
1317  break;
1318 
1319  case kButton2Double:
1320  break;
1321 
1322 //*-*----------------------------------------------------------------------
1323 
1324  case kButton3Down:
1325  // popup context menu
1326  pad = Pick(px, py, prevSelObj);
1327  if (!pad) return;
1328 
1330 
1333  fContextMenu->Popup(px, py, fSelected, this, pad);
1334 
1335  break;
1336 
1337  case kButton3Motion:
1338  break;
1339 
1340  case kButton3Up:
1342  break;
1343 
1344  case kButton3Double:
1345  break;
1346 
1347  case kKeyPress:
1348  if (!fSelectedPad || !fSelected) return;
1349  gPad = fSelectedPad; // don't use cd() because we won't draw in pad
1350  // we will only use its coordinate system
1351  fSelected->ExecuteEvent(event, px, py);
1352 
1353  RunAutoExec();
1354 
1355  break;
1356 
1357  case kButton1Shift:
1358  // Try to select
1359  pad = Pick(px, py, prevSelObj);
1360 
1361  if (!pad) return;
1362 
1363  EnterLeave(prevSelPad, prevSelObj);
1364 
1365  gPad = pad; // don't use cd() we will use the current
1366  // canvas via the GetCanvas member and not via
1367  // gPad->GetCanvas
1368  if (fSelected) {
1369  fSelected->ExecuteEvent(event, px, py);
1370  RunAutoExec();
1371  }
1372  break;
1373 
1374  case kWheelUp:
1375  case kWheelDown:
1376  pad = Pick(px, py, prevSelObj);
1377  if (!pad) return;
1378 
1379  gPad = pad;
1380  if (fSelected)
1381  fSelected->ExecuteEvent(event, px, py);
1382  break;
1383 
1384  default:
1385  break;
1386  }
1387 
1388  if (fPadSave && event != kButton2Down)
1389  fPadSave->cd();
1390 
1391  if (event != kMouseLeave) { // signal was already emitted for this event
1392  ProcessedEvent(event, px, py, fSelected); // emit signal
1393  DrawEventStatus(event, px, py, fSelected);
1394  }
1395 }
1396 
1397 ////////////////////////////////////////////////////////////////////////////////
1398 /// Is folder ?
1399 
1401 {
1402  return fgIsFolder;
1403 }
1404 
1405 ////////////////////////////////////////////////////////////////////////////////
1406 /// List all pads.
1407 
1408 void TCanvas::ls(Option_t *option) const
1409 {
1411  std::cout <<"Canvas Name=" <<GetName()<<" Title="<<GetTitle()<<" Option="<<option<<std::endl;
1413  TPad::ls(option);
1415 }
1416 
1417 ////////////////////////////////////////////////////////////////////////////////
1418 /// Static function to build a default canvas.
1419 
1421 {
1422  const char *defcanvas = gROOT->GetDefCanvasName();
1423  char *cdef;
1424 
1425  TList *lc = (TList*)gROOT->GetListOfCanvases();
1426  if (lc->FindObject(defcanvas)) {
1427  Int_t n = lc->GetSize() + 1;
1428  cdef = new char[strlen(defcanvas)+15];
1429  do {
1430  strlcpy(cdef,Form("%s_n%d", defcanvas, n++),strlen(defcanvas)+15);
1431  } while (lc->FindObject(cdef));
1432  } else
1433  cdef = StrDup(Form("%s",defcanvas));
1434 
1435  TCanvas *c = new TCanvas(cdef, cdef, 1);
1436 
1437  ::Info("TCanvas::MakeDefCanvas"," created default TCanvas with name %s",cdef);
1438  delete [] cdef;
1439  return c;
1440 }
1441 
1442 ////////////////////////////////////////////////////////////////////////////////
1443 /// Set option to move objects/pads in a canvas.
1444 ///
1445 /// - set = 1 (default) graphics objects are moved in opaque mode
1446 /// - set = 0 only the outline of objects is drawn when moving them
1447 ///
1448 /// The option opaque produces the best effect. It requires however a
1449 /// a reasonably fast workstation or response time.
1450 
1452 {
1453  SetBit(kMoveOpaque,set);
1454 }
1455 
1456 ////////////////////////////////////////////////////////////////////////////////
1457 /// Paint canvas.
1458 
1460 {
1461  if (fCanvas) TPad::Paint(option);
1462 }
1463 
1464 ////////////////////////////////////////////////////////////////////////////////
1465 /// Prepare for pick, call TPad::Pick() and when selected object
1466 /// is different from previous then emit Picked() signal.
1467 
1468 TPad *TCanvas::Pick(Int_t px, Int_t py, TObject *prevSelObj)
1469 {
1470  TObjLink *pickobj = 0;
1471 
1472  fSelected = 0;
1473  fSelectedOpt = "";
1474  fSelectedPad = 0;
1475 
1476  TPad *pad = Pick(px, py, pickobj);
1477  if (!pad) return 0;
1478 
1479  if (!pickobj) {
1480  fSelected = pad;
1481  fSelectedOpt = "";
1482  } else {
1483  if (!fSelected) { // can be set via TCanvas::SetSelected()
1484  fSelected = pickobj->GetObject();
1485  fSelectedOpt = pickobj->GetOption();
1486  }
1487  }
1488  fSelectedPad = pad;
1489 
1490  if (fSelected != prevSelObj)
1491  Picked(fSelectedPad, fSelected, fEvent); // emit signal
1492 
1493  if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1497  Selected(fSelectedPad, fSelected, fEvent); // emit signal
1498  fSelectedX = px;
1499  fSelectedY = py;
1500  }
1501  }
1502  return pad;
1503 }
1504 
1505 ////////////////////////////////////////////////////////////////////////////////
1506 /// Emit Picked() signal.
1507 
1508 void TCanvas::Picked(TPad *pad, TObject *obj, Int_t event)
1509 {
1510  Long_t args[3];
1511 
1512  args[0] = (Long_t) pad;
1513  args[1] = (Long_t) obj;
1514  args[2] = event;
1515 
1516  Emit("Picked(TPad*,TObject*,Int_t)", args);
1517 }
1518 
1519 ////////////////////////////////////////////////////////////////////////////////
1520 /// Emit Selected() signal.
1521 
1523 {
1524  Long_t args[3];
1525 
1526  args[0] = (Long_t) pad;
1527  args[1] = (Long_t) obj;
1528  args[2] = event;
1529 
1530  Emit("Selected(TVirtualPad*,TObject*,Int_t)", args);
1531 }
1532 
1533 ////////////////////////////////////////////////////////////////////////////////
1534 /// Emit ProcessedEvent() signal.
1535 
1537 {
1538  Long_t args[4];
1539 
1540  args[0] = event;
1541  args[1] = x;
1542  args[2] = y;
1543  args[3] = (Long_t) obj;
1544 
1545  Emit("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1546 }
1547 
1548 ////////////////////////////////////////////////////////////////////////////////
1549 /// Recompute canvas parameters following a X11 Resize.
1550 
1552 {
1553  if (fCanvasID == -1) return;
1554 
1555  if ((!gROOT->IsLineProcessing()) && (!gVirtualX->IsCmdThread())) {
1556  gInterpreter->Execute(this, IsA(), "Resize", "");
1557  return;
1558  }
1559 
1561 
1562  TPad *padsav = (TPad*)gPad;
1563  cd();
1564 
1565  if (!IsBatch()) {
1566  gVirtualX->SelectWindow(fCanvasID); //select current canvas
1567  gVirtualX->ResizeWindow(fCanvasID); //resize canvas and off-screen buffer
1568 
1569  // Get effective window parameters including menubar and borders
1572 
1573  // Get effective canvas parameters without borders
1574  Int_t dum1, dum2;
1575  gVirtualX->GetGeometry(fCanvasID, dum1, dum2, fCw, fCh);
1576  }
1577 
1578  if (fXsizeUser && fYsizeUser) {
1579  UInt_t nwh = fCh;
1580  UInt_t nww = fCw;
1582  if (rxy < 1) {
1583  UInt_t twh = UInt_t(Double_t(fCw)/rxy);
1584  if (twh > fCh)
1585  nww = UInt_t(Double_t(fCh)*rxy);
1586  else
1587  nwh = twh;
1588  if (nww > fCw) {
1589  nww = fCw; nwh = twh;
1590  }
1591  if (nwh > fCh) {
1592  nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1593  }
1594  } else {
1595  UInt_t twh = UInt_t(Double_t(fCw)*rxy);
1596  if (twh > fCh)
1597  nwh = UInt_t(Double_t(fCw)/rxy);
1598  else
1599  nww = twh;
1600  if (nww > fCw) {
1601  nww = fCw; nwh = twh;
1602  }
1603  if (nwh > fCh) {
1604  nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1605  }
1606  }
1607  fCw = nww;
1608  fCh = nwh;
1609  }
1610 
1611  if (fCw < fCh) {
1614  }
1615  else {
1618  }
1619 
1620 //*-*- Loop on all pads to recompute conversion coefficients
1621  TPad::ResizePad();
1622 
1623  if (padsav) padsav->cd();
1624 }
1625 
1626 ////////////////////////////////////////////////////////////////////////////////
1627 /// Set option to resize objects/pads in a canvas.
1628 ///
1629 /// - set = 1 (default) graphics objects are resized in opaque mode
1630 /// - set = 0 only the outline of objects is drawn when resizing them
1631 ///
1632 /// The option opaque produces the best effect. It requires however a
1633 /// a reasonably fast workstation or response time.
1634 
1636 {
1637  SetBit(kResizeOpaque,set);
1638 }
1639 
1640 ////////////////////////////////////////////////////////////////////////////////
1641 /// Execute the list of TExecs in the current pad.
1642 
1644 {
1645  if (!TestBit(kAutoExec)) return;
1646  if (!gPad) return;
1647  ((TPad*)gPad)->AutoExec();
1648 }
1649 
1650 
1651 ////////////////////////////////////////////////////////////////////////////////
1652 /// Save primitives in this canvas in C++ macro file with GUI.
1653 
1654 void TCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1655 {
1656  // Write canvas options (in $TROOT or $TStyle)
1657  if (gStyle->GetOptFit()) {
1658  out<<" gStyle->SetOptFit(1);"<<std::endl;
1659  }
1660  if (!gStyle->GetOptStat()) {
1661  out<<" gStyle->SetOptStat(0);"<<std::endl;
1662  }
1663  if (!gStyle->GetOptTitle()) {
1664  out<<" gStyle->SetOptTitle(0);"<<std::endl;
1665  }
1666  if (gROOT->GetEditHistograms()) {
1667  out<<" gROOT->SetEditHistograms();"<<std::endl;
1668  }
1669  if (GetShowEventStatus()) {
1670  out<<" "<<GetName()<<"->ToggleEventStatus();"<<std::endl;
1671  }
1672  if (GetShowToolTips()) {
1673  out<<" "<<GetName()<<"->ToggleToolTips();"<<std::endl;
1674  }
1675  if (GetShowToolBar()) {
1676  out<<" "<<GetName()<<"->ToggleToolBar();"<<std::endl;
1677  }
1678  if (GetHighLightColor() != 5) {
1679  if (GetHighLightColor() > 228) {
1681  out<<" "<<GetName()<<"->SetHighLightColor(ci);" << std::endl;
1682  } else
1683  out<<" "<<GetName()<<"->SetHighLightColor("<<GetHighLightColor()<<");"<<std::endl;
1684  }
1685 
1686  // Now recursively scan all pads of this canvas
1687  cd();
1688  TPad::SavePrimitive(out,option);
1689 }
1690 
1691 ////////////////////////////////////////////////////////////////////////////////
1692 /// Save primitives in this canvas as a C++ macro file.
1693 /// This function loops on all the canvas primitives and for each primitive
1694 /// calls the object SavePrimitive function.
1695 /// When outputting floating point numbers, the default precision is 7 digits.
1696 /// The precision can be changed (via system.rootrc) by changing the value
1697 /// of the environment variable "Canvas.SavePrecision"
1698 
1699 void TCanvas::SaveSource(const char *filename, Option_t *option)
1700 {
1701  // reset bit TClass::kClassSaved for all classes
1702  TIter next(gROOT->GetListOfClasses());
1703  TClass *cl;
1704  while((cl = (TClass*)next())) {
1706  }
1707 
1708  char quote = '"';
1709  std::ofstream out;
1710  Int_t lenfile = strlen(filename);
1711  char * fname;
1712  char lcname[10];
1713  const char *cname = GetName();
1714  Bool_t invalid = kFALSE;
1715  // if filename is given, open this file, otherwise create a file
1716  // with a name equal to the canvasname.C
1717  if (lenfile) {
1718  fname = (char*)filename;
1719  out.open(fname, std::ios::out);
1720  } else {
1721  Int_t nch = strlen(cname);
1722  if (nch < 10) {
1723  strlcpy(lcname,cname,10);
1724  for (Int_t k=1;k<=nch;k++) {if (lcname[nch-k] == ' ') lcname[nch-k] = 0;}
1725  if (lcname[0] == 0) {invalid = kTRUE; strlcpy(lcname,"c1",10); nch = 2;}
1726  cname = lcname;
1727  }
1728  fname = new char[nch+3];
1729  strlcpy(fname,cname,nch+3);
1730  strncat(fname,".C",2);
1731  out.open(fname, std::ios::out);
1732  }
1733  if (!out.good ()) {
1734  Error("SaveSource", "Cannot open file: %s",fname);
1735  if (!lenfile) delete [] fname;
1736  return;
1737  }
1738 
1739  //set precision
1740  Int_t precision = gEnv->GetValue("Canvas.SavePrecision",7);
1741  out.precision(precision);
1742 
1743  // Write macro header and date/time stamp
1744  TDatime t;
1745  Float_t cx = gStyle->GetScreenFactor();
1746  Int_t topx,topy;
1747  UInt_t w, h;
1748  if (!fCanvasImp) {
1749  Error("SaveSource", "Cannot open TCanvas");
1750  return;
1751  }
1752  UInt_t editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
1753  w = UInt_t((fWindowWidth - editorWidth)/cx);
1754  h = UInt_t((fWindowHeight)/cx);
1755  topx = GetWindowTopX();
1756  topy = GetWindowTopY();
1757 
1758  if (w == 0) {
1759  w = GetWw()+4; h = GetWh()+4;
1760  topx = 1; topy = 1;
1761  }
1762 
1763  TString mname(fname);
1764 // out <<"#ifdef __CLING__"<<std::endl;
1765 // out <<"#pragma cling optimize(0)"<<std::endl;
1766 // out <<"#endif"<<std::endl;
1767 // out <<""<<std::endl;
1768  Int_t p = mname.Last('.');
1769  Int_t s = mname.Last('/')+1;
1770  out <<"void " << mname(s,p-s) << "()" <<std::endl;
1771  out <<"{"<<std::endl;
1772  out <<"//=========Macro generated from canvas: "<<GetName()<<"/"<<GetTitle()<<std::endl;
1773  out <<"//========= ("<<t.AsString()<<") by ROOT version"<<gROOT->GetVersion()<<std::endl;
1774 
1775  if (gStyle->GetCanvasPreferGL())
1776  out <<std::endl<<" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1777 
1778  // Write canvas parameters (TDialogCanvas case)
1780  out<<" "<<ClassName()<<" *"<<cname<<" = new "<<ClassName()<<"("<<quote<<GetName()
1781  <<quote<<", "<<quote<<GetTitle()<<quote<<","<<w<<","<<h<<");"<<std::endl;
1782  } else {
1783  // Write canvas parameters (TCanvas case)
1784  out<<" TCanvas *"<<cname<<" = new TCanvas("<<quote<<GetName()<<quote<<", "<<quote<<GetTitle()
1785  <<quote;
1786  if (!HasMenuBar())
1787  out<<",-"<<topx<<","<<topy<<","<<w<<","<<h<<");"<<std::endl;
1788  else
1789  out<<","<<topx<<","<<topy<<","<<w<<","<<h<<");"<<std::endl;
1790  }
1791  // Write canvas options (in $TROOT or $TStyle)
1792  if (gStyle->GetOptFit()) {
1793  out<<" gStyle->SetOptFit(1);"<<std::endl;
1794  }
1795  if (!gStyle->GetOptStat()) {
1796  out<<" gStyle->SetOptStat(0);"<<std::endl;
1797  }
1798  if (!gStyle->GetOptTitle()) {
1799  out<<" gStyle->SetOptTitle(0);"<<std::endl;
1800  }
1801  if (gROOT->GetEditHistograms()) {
1802  out<<" gROOT->SetEditHistograms();"<<std::endl;
1803  }
1804  if (GetShowEventStatus()) {
1805  out<<" "<<GetName()<<"->ToggleEventStatus();"<<std::endl;
1806  }
1807  if (GetShowToolTips()) {
1808  out<<" "<<GetName()<<"->ToggleToolTips();"<<std::endl;
1809  }
1810  if (GetHighLightColor() != 5) {
1811  if (GetHighLightColor() > 228) {
1813  out<<" "<<GetName()<<"->SetHighLightColor(ci);" << std::endl;
1814  } else
1815  out<<" "<<GetName()<<"->SetHighLightColor("<<GetHighLightColor()<<");"<<std::endl;
1816  }
1817 
1818  // Now recursively scan all pads of this canvas
1819  cd();
1820  if (invalid) SetName("c1");
1821  TPad::SavePrimitive(out,option);
1822  // Write canvas options related to pad editor
1823  out<<" "<<GetName()<<"->SetSelected("<<GetName()<<");"<<std::endl;
1824  if (GetShowToolBar()) {
1825  out<<" "<<GetName()<<"->ToggleToolBar();"<<std::endl;
1826  }
1827  if (invalid) SetName(" ");
1828 
1829  out <<"}"<<std::endl;
1830  out.close();
1831  Info("SaveSource","C++ Macro file: %s has been generated", fname);
1832 
1833  // reset bit TClass::kClassSaved for all classes
1834  next.Reset();
1835  while((cl = (TClass*)next())) {
1836  cl->ResetBit(TClass::kClassSaved);
1837  }
1838  if (!lenfile) delete [] fname;
1839 }
1840 
1841 ////////////////////////////////////////////////////////////////////////////////
1842 /// Toggle batch mode. However, if the canvas is created without a window
1843 /// then batch mode always stays set.
1844 
1846 {
1847  if (gROOT->IsBatch())
1848  fBatch = kTRUE;
1849  else
1850  fBatch = batch;
1851 }
1852 
1853 ////////////////////////////////////////////////////////////////////////////////
1854 /// Set Width and Height of canvas to ww and wh respectively. If ww and/or wh
1855 /// are greater than the current canvas window a scroll bar is automatically
1856 /// generated. Use this function to zoom in a canvas and navigate via
1857 /// the scroll bars. The Width and Height in this method are different from those
1858 /// given in the TCanvas constructors where these two dimension include the size
1859 /// of the window decoration whereas they do not in this method.
1860 
1862 {
1863  if (fCanvasImp) {
1864  fCanvasImp->SetCanvasSize(ww, wh);
1865  fCw = ww;
1866  fCh = wh;
1867  ResizePad();
1868  }
1869 }
1870 
1871 ////////////////////////////////////////////////////////////////////////////////
1872 /// Set cursor.
1873 
1875 {
1876  if (IsBatch()) return;
1877  gVirtualX->SetCursor(fCanvasID, cursor);
1878 }
1879 
1880 ////////////////////////////////////////////////////////////////////////////////
1881 /// Set Double Buffer On/Off.
1882 
1884 {
1885  if (IsBatch()) return;
1886  fDoubleBuffer = mode;
1887  gVirtualX->SetDoubleBuffer(fCanvasID, mode);
1888 
1889  // depending of the buffer mode set the drawing window to either
1890  // the canvas pixmap or to the canvas on-screen window
1891  if (fDoubleBuffer) {
1893  } else
1895 }
1896 
1897 ////////////////////////////////////////////////////////////////////////////////
1898 /// Fix canvas aspect ratio to current value if fixed is true.
1899 
1901 {
1902  if (fixed) {
1903  if (!fFixedAspectRatio) {
1904  if (fCh != 0)
1906  else {
1907  Error("SetAspectRatio", "cannot fix aspect ratio, height of canvas is 0");
1908  return;
1909  }
1911  }
1912  } else {
1914  fAspectRatio = 0;
1915  }
1916 }
1917 
1918 ////////////////////////////////////////////////////////////////////////////////
1919 /// If isfolder=kTRUE, the canvas can be browsed like a folder
1920 /// by default a canvas is not browsable.
1921 
1923 {
1924  fgIsFolder = isfolder;
1925 }
1926 
1927 ////////////////////////////////////////////////////////////////////////////////
1928 /// Set selected canvas.
1929 
1931 {
1932  fSelected = obj;
1933  if (obj) obj->SetBit(kMustCleanup);
1934 }
1935 
1936 ////////////////////////////////////////////////////////////////////////////////
1937 /// Set canvas title.
1938 
1939 void TCanvas::SetTitle(const char *title)
1940 {
1941  fTitle = title;
1942  if (fCanvasImp) fCanvasImp->SetWindowTitle(title);
1943 }
1944 
1945 ////////////////////////////////////////////////////////////////////////////////
1946 /// Set the canvas scale in centimeters.
1947 ///
1948 /// This information is used by PostScript to set the page size.
1949 ///
1950 /// \param[in] xsize size of the canvas in centimeters along X
1951 /// \param[in] ysize size of the canvas in centimeters along Y
1952 ///
1953 /// if xsize and ysize are not equal to 0, then the scale factors will
1954 /// be computed to keep the ratio ysize/xsize independently of the canvas
1955 /// size (parts of the physical canvas will be unused).
1956 ///
1957 /// if xsize = 0 and ysize is not zero, then xsize will be computed
1958 /// to fit to the current canvas scale. If the canvas is resized,
1959 /// a new value for xsize will be recomputed. In this case the aspect
1960 /// ratio is not preserved.
1961 ///
1962 /// if both xsize = 0 and ysize = 0, then the scaling is automatic.
1963 /// the largest dimension will be allocated a size of 20 centimeters.
1964 
1965 void TCanvas::Size(Float_t xsize, Float_t ysize)
1966 {
1967  fXsizeUser = xsize;
1968  fYsizeUser = ysize;
1969 
1970  Resize();
1971 }
1972 
1973 ////////////////////////////////////////////////////////////////////////////////
1974 /// Stream a class object.
1975 
1976 void TCanvas::Streamer(TBuffer &b)
1977 {
1978  UInt_t R__s, R__c;
1979  if (b.IsReading()) {
1980  Version_t v = b.ReadVersion(&R__s, &R__c);
1981  gPad = this;
1982  fCanvas = this;
1983  if (v>7) b.ClassBegin(TCanvas::IsA());
1984  if (v>7) b.ClassMember("TPad");
1985  TPad::Streamer(b);
1986  gPad = this;
1987  //restore the colors
1988  TObjArray *colors = (TObjArray*)fPrimitives->FindObject("ListOfColors");
1989  if (colors) {
1990  TIter next(colors);
1991  TColor *colold;
1992  while ((colold = (TColor*)next())) {
1993  if (colold) {
1994  Int_t cn = 0;
1995  if (colold) cn = colold->GetNumber();
1996  TColor *colcur = gROOT->GetColor(cn);
1997  if (colcur) {
1998  colcur->SetRGB(colold->GetRed(),colold->GetGreen(),colold->GetBlue());
1999  } else {
2000  colcur = new TColor(cn,colold->GetRed(),
2001  colold->GetGreen(),
2002  colold->GetBlue(),
2003  colold->GetName());
2004  if (!colcur) return;
2005  }
2006  }
2007  }
2008  fPrimitives->Remove(colors);
2009  colors->Delete();
2010  delete colors;
2011  }
2012  if (v>7) b.ClassMember("fDISPLAY","TString");
2013  fDISPLAY.Streamer(b);
2014  if (v>7) b.ClassMember("fDoubleBuffer", "Int_t");
2015  b >> fDoubleBuffer;
2016  if (v>7) b.ClassMember("fRetained", "Bool_t");
2017  b >> fRetained;
2018  if (v>7) b.ClassMember("fXsizeUser", "Size_t");
2019  b >> fXsizeUser;
2020  if (v>7) b.ClassMember("fYsizeUser", "Size_t");
2021  b >> fYsizeUser;
2022  if (v>7) b.ClassMember("fXsizeReal", "Size_t");
2023  b >> fXsizeReal;
2024  if (v>7) b.ClassMember("fYsizeReal", "Size_t");
2025  b >> fYsizeReal;
2026  fCanvasID = -1;
2027  if (v>7) b.ClassMember("fWindowTopX", "Int_t");
2028  b >> fWindowTopX;
2029  if (v>7) b.ClassMember("fWindowTopY", "Int_t");
2030  b >> fWindowTopY;
2031  if (v > 2) {
2032  if (v>7) b.ClassMember("fWindowWidth", "UInt_t");
2033  b >> fWindowWidth;
2034  if (v>7) b.ClassMember("fWindowHeight", "UInt_t");
2035  b >> fWindowHeight;
2036  }
2037  if (v>7) b.ClassMember("fCw", "UInt_t");
2038  b >> fCw;
2039  if (v>7) b.ClassMember("fCh", "UInt_t");
2040  b >> fCh;
2041  if (v <= 2) {
2042  fWindowWidth = fCw;
2043  fWindowHeight = fCh;
2044  }
2045  if (v>7) b.ClassMember("fCatt", "TAttCanvas");
2046  fCatt.Streamer(b);
2047  Bool_t dummy;
2048  if (v>7) b.ClassMember("kMoveOpaque", "Bool_t");
2049  b >> dummy; if (dummy) MoveOpaque(1);
2050  if (v>7) b.ClassMember("kResizeOpaque", "Bool_t");
2051  b >> dummy; if (dummy) ResizeOpaque(1);
2052  if (v>7) b.ClassMember("fHighLightColor", "Color_t");
2053  b >> fHighLightColor;
2054  if (v>7) b.ClassMember("fBatch", "Bool_t");
2055  b >> dummy; //was fBatch
2056  if (v < 2) return;
2057  if (v>7) b.ClassMember("kShowEventStatus", "Bool_t");
2058  b >> dummy; if (dummy) SetBit(kShowEventStatus);
2059 
2060  if (v > 3) {
2061  if (v>7) b.ClassMember("kAutoExec", "Bool_t");
2062  b >> dummy; if (dummy) SetBit(kAutoExec);
2063  }
2064  if (v>7) b.ClassMember("kMenuBar", "Bool_t");
2065  b >> dummy; if (dummy) SetBit(kMenuBar);
2066  fBatch = gROOT->IsBatch();
2067  if (v>7) b.ClassEnd(TCanvas::IsA());
2068  b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2069  } else {
2070  //save list of colors
2071  //we must protect the case when two or more canvases are saved
2072  //in the same buffer. If the list of colors has already been saved
2073  //in the buffer, do not add the list of colors to the list of primitives.
2074  TObjArray *colors = 0;
2075  if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2076  colors = (TObjArray*)gROOT->GetListOfColors();
2077  fPrimitives->Add(colors);
2078  }
2079  R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2080  b.ClassBegin(TCanvas::IsA());
2081  b.ClassMember("TPad");
2082  TPad::Streamer(b);
2083  if(colors) fPrimitives->Remove(colors);
2084  b.ClassMember("fDISPLAY","TString");
2085  fDISPLAY.Streamer(b);
2086  b.ClassMember("fDoubleBuffer", "Int_t");
2087  b << fDoubleBuffer;
2088  b.ClassMember("fRetained", "Bool_t");
2089  b << fRetained;
2090  b.ClassMember("fXsizeUser", "Size_t");
2091  b << fXsizeUser;
2092  b.ClassMember("fYsizeUser", "Size_t");
2093  b << fYsizeUser;
2094  b.ClassMember("fXsizeReal", "Size_t");
2095  b << fXsizeReal;
2096  b.ClassMember("fYsizeReal", "Size_t");
2097  b << fYsizeReal;
2099  Int_t topx = fWindowTopX, topy = fWindowTopY;
2100  UInt_t editorWidth = 0;
2101  if(fCanvasImp) editorWidth = fCanvasImp->GetWindowGeometry(topx,topy,w,h);
2102  b.ClassMember("fWindowTopX", "Int_t");
2103  b << topx;
2104  b.ClassMember("fWindowTopY", "Int_t");
2105  b << topy;
2106  b.ClassMember("fWindowWidth", "UInt_t");
2107  b << (UInt_t)(w-editorWidth);
2108  b.ClassMember("fWindowHeight", "UInt_t");
2109  b << h;
2110  b.ClassMember("fCw", "UInt_t");
2111  b << fCw;
2112  b.ClassMember("fCh", "UInt_t");
2113  b << fCh;
2114  b.ClassMember("fCatt", "TAttCanvas");
2115  fCatt.Streamer(b);
2116  b.ClassMember("kMoveOpaque", "Bool_t");
2117  b << TestBit(kMoveOpaque); //please remove in ROOT version 6
2118  b.ClassMember("kResizeOpaque", "Bool_t");
2119  b << TestBit(kResizeOpaque); //please remove in ROOT version 6
2120  b.ClassMember("fHighLightColor", "Color_t");
2121  b << fHighLightColor;
2122  b.ClassMember("fBatch", "Bool_t");
2123  b << fBatch; //please remove in ROOT version 6
2124  b.ClassMember("kShowEventStatus", "Bool_t");
2125  b << TestBit(kShowEventStatus); //please remove in ROOT version 6
2126  b.ClassMember("kAutoExec", "Bool_t");
2127  b << TestBit(kAutoExec); //please remove in ROOT version 6
2128  b.ClassMember("kMenuBar", "Bool_t");
2129  b << TestBit(kMenuBar); //please remove in ROOT version 6
2130  b.ClassEnd(TCanvas::IsA());
2131  b.SetByteCount(R__c, kTRUE);
2132  }
2133 }
2134 
2135 ////////////////////////////////////////////////////////////////////////////////
2136 /// Toggle pad auto execution of list of TExecs.
2137 
2139 {
2140  Bool_t autoExec = TestBit(kAutoExec);
2141  SetBit(kAutoExec,!autoExec);
2142 }
2143 
2144 ////////////////////////////////////////////////////////////////////////////////
2145 /// Toggle event statusbar.
2146 
2148 {
2149  Bool_t showEventStatus = !TestBit(kShowEventStatus);
2150  SetBit(kShowEventStatus,showEventStatus);
2151 
2152  if (fCanvasImp) fCanvasImp->ShowStatusBar(showEventStatus);
2153 }
2154 
2155 ////////////////////////////////////////////////////////////////////////////////
2156 /// Toggle toolbar.
2157 
2159 {
2160  Bool_t showToolBar = !TestBit(kShowToolBar);
2161  SetBit(kShowToolBar,showToolBar);
2162 
2163  if (fCanvasImp) fCanvasImp->ShowToolBar(showToolBar);
2164 }
2165 
2166 ////////////////////////////////////////////////////////////////////////////////
2167 /// Toggle editor.
2168 
2170 {
2171  Bool_t showEditor = !TestBit(kShowEditor);
2172  SetBit(kShowEditor,showEditor);
2173 
2174  if (fCanvasImp) fCanvasImp->ShowEditor(showEditor);
2175 }
2176 
2177 ////////////////////////////////////////////////////////////////////////////////
2178 /// Toggle tooltip display.
2179 
2181 {
2182  Bool_t showToolTips = !TestBit(kShowToolTips);
2183  SetBit(kShowToolTips, showToolTips);
2184 
2185  if (fCanvasImp) fCanvasImp->ShowToolTips(showToolTips);
2186 }
2187 
2188 
2189 ////////////////////////////////////////////////////////////////////////////////
2190 /// Static function returning "true" if transparency is supported.
2191 
2193 {
2194  return gPad && (gVirtualX->InheritsFrom("TGQuartz") ||
2195  gPad->GetGLDevice() != -1);
2196 }
2197 
2198 extern "C" void ROOT_TCanvas_Update(void* TheCanvas) {
2199  static_cast<TCanvas*>(TheCanvas)->Update();
2200 }
2201 
2202 ////////////////////////////////////////////////////////////////////////////////
2203 /// Update canvas pad buffers.
2204 
2206 {
2207  if (fUpdating) return;
2208 
2209  if (fPixmapID == -1) return;
2210 
2211  static const union CastFromFuncToVoidPtr_t {
2212  CastFromFuncToVoidPtr_t(): fFuncPtr(ROOT_TCanvas_Update) {}
2213  void (*fFuncPtr)(void*);
2214  void* fVoidPtr;
2215  } castFromFuncToVoidPtr;
2216 
2217  if (gThreadXAR) {
2218  void *arr[3];
2219  arr[1] = this;
2220  arr[2] = castFromFuncToVoidPtr.fVoidPtr;
2221  if ((*gThreadXAR)("CUPD", 3, arr, 0)) return;
2222  }
2223 
2224  if (!fCanvasImp) return;
2225 
2226  if (!gVirtualX->IsCmdThread()) {
2227  // Why do we have this (which uses the interpreter to funnel the Update()
2228  // through the main thread) when the gThreadXAR mechanism does seemingly
2229  // the same?
2230  gInterpreter->Execute(this, IsA(), "Update", "");
2231  return;
2232  }
2233 
2235 
2236  fUpdating = kTRUE;
2237 
2238  if (!IsBatch()) FeedbackMode(kFALSE); // Goto double buffer mode
2239 
2240  if (!UseGL())
2241  PaintModified(); // Repaint all modified pad's
2242 
2243  Flush(); // Copy all pad pixmaps to the screen
2244 
2245  SetCursor(kCross);
2246  fUpdating = kFALSE;
2247 }
2248 
2249 ////////////////////////////////////////////////////////////////////////////////
2250 /// Used by friend class TCanvasImp.
2251 
2253 {
2254  fCanvasID = 0;
2255  fContextMenu = 0;
2256 }
2257 
2258 ////////////////////////////////////////////////////////////////////////////////
2259 /// Check whether this canvas is to be drawn in grayscale mode.
2260 
2262 {
2263  return TestBit(kIsGrayscale);
2264 }
2265 
2266 ////////////////////////////////////////////////////////////////////////////////
2267 /// Set whether this canvas should be painted in grayscale, and re-paint
2268 /// it if necessary.
2269 
2270 void TCanvas::SetGrayscale(Bool_t set /*= kTRUE*/)
2271 {
2272  if (IsGrayscale() == set) return;
2273  SetBit(kIsGrayscale, set);
2274  Paint(); // update canvas and all sub-pads, unconditionally!
2275 }
2276 
2277 ////////////////////////////////////////////////////////////////////////////////
2278 /// Probably, TPadPainter must be placed in a separate ROOT module -
2279 /// "padpainter" (the same as "histpainter"). But now, it's directly in a
2280 /// gpad dir, so, in case of default painter, no *.so should be loaded,
2281 /// no need in plugin managers.
2282 /// May change in future.
2283 
2285 {
2286  //Even for batch mode painter is still required, just to delegate
2287  //some calls to batch "virtual X".
2288  if (!UseGL() || fBatch)
2289  fPainter = new TPadPainter;//Do not need plugin manager for this!
2290  else {
2292  if (!fPainter) {
2293  Error("CreatePainter", "GL Painter creation failed! Will use default!");
2294  fPainter = new TPadPainter;
2295  fUseGL = kFALSE;
2296  }
2297  }
2298 }
2299 
2300 ////////////////////////////////////////////////////////////////////////////////
2301 /// Access and (probably) creation of pad painter.
2302 
2304 {
2305  if (!fPainter) CreatePainter();
2306  return fPainter;
2307 }
2308 
2309 
2310 ////////////////////////////////////////////////////////////////////////////////
2311 ///assert on IsBatch() == false?
2312 
2314 {
2315  if (fGLDevice != -1) {
2316  //fPainter has a font manager.
2317  //Font manager will delete textures.
2318  //If context is wrong (we can have several canvases) -
2319  //wrong texture will be deleted, damaging some of our fonts.
2320  gGLManager->MakeCurrent(fGLDevice);
2321  }
2322 
2323  delete fPainter;
2324  fPainter = 0;
2325 
2326  if (fGLDevice != -1) {
2327  gGLManager->DeleteGLContext(fGLDevice);//?
2328  fGLDevice = -1;
2329  }
2330 }
virtual void Clear(Option_t *="")
Definition: TObject.h:91
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TCanvas.cxx:1041
void RunAutoExec()
Execute the list of TExecs in the current pad.
Definition: TCanvas.cxx:1643
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
Generate kMouseEnter and kMouseLeave events depending on the previously selected object and the curre...
Definition: TCanvas.cxx:1004
Bool_t IsFolder() const
Is folder ?
Definition: TCanvas.cxx:1400
virtual void SetGridx(Int_t value=1)
Definition: TPad.h:324
object has not been deleted
Definition: TObject.h:71
Ssiz_t Last(char c) const
Find last occurrence of a character c.
Definition: TString.cxx:875
void FeedbackMode(Bool_t set)
Turn rubberband feedback mode on or off.
Definition: TCanvas.cxx:1059
Int_t GetTicky() const
Definition: TPad.h:230
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition: TGuiFactory.h:67
virtual void SetPad(const char *name, const char *title, Double_t xlow, Double_t ylow, Double_t xup, Double_t yup, Color_t color=35, Short_t bordersize=5, Short_t bordermode=-1)
Set all pad parameters.
Definition: TPad.cxx:5824
virtual void SetTickx(Int_t value=1)
Definition: TPad.h:344
An array of TObjects.
Definition: TObjArray.h:37
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2569
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition: TCanvas.cxx:1522
virtual void ClassBegin(const TClass *, Version_t=-1)=0
TList * fPrimitives
-&gt;List of primitives (subpads)
Definition: TPad.h:106
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition: TCanvas.cxx:1451
virtual void ResizePad(Option_t *option="")
Compute pad conversion coefficients.
Definition: TPad.cxx:5328
Bool_t IsOnHeap() const
Definition: TObject.h:121
virtual TCanvas * GetCanvas() const
Definition: TPad.h:253
TPad * fSelectedPad
! Pad containing currently selected object
Definition: TCanvas.h:61
virtual void SetCursor(ECursor cursor)
Set cursor.
Definition: TCanvas.cxx:1874
Bool_t GetPadGridX() const
Definition: TStyle.h:200
Bool_t UseGL() const
Definition: TCanvas.h:226
TCanvas(const TCanvas &canvas)
Int_t fEvent
! Type of current or last handled event
Definition: TCanvas.h:52
TContextMenu * fContextMenu
! Context menu pointer
Definition: TCanvas.h:65
Int_t GetCanvasBorderMode() const
Definition: TStyle.h:176
virtual void Copy(TAttPad &attpad) const
copy function
Definition: TAttPad.cxx:45
TString fTitle
Pad title.
Definition: TPad.h:109
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition: TCanvas.cxx:2147
Bool_t fDrawn
! Set to True when the Draw method is called
Definition: TCanvas.h:70
Bool_t IsReading() const
Definition: TBuffer.h:81
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class &quot;classname&quot;.
Definition: TObject.cxx:436
Bool_t fUseGL
! True when rendering is with GL
Definition: TCanvas.h:69
short Version_t
Definition: RtypesCore.h:61
TPad * fPadSave
! Pointer to saved pad in HandleInput
Definition: TCanvas.h:63
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition: TCanvas.cxx:2303
float Float_t
Definition: RtypesCore.h:53
Size_t fYsizeReal
Current size of canvas along Y in CM.
Definition: TCanvas.h:43
Bool_t GetCanvasPreferGL() const
Definition: TStyle.h:173
float Size_t
Definition: RtypesCore.h:83
virtual void Paint(Option_t *option="")
Paint all primitives in pad.
Definition: TPad.cxx:3346
void SetTitle(const char *title="")
Set canvas title.
Definition: TCanvas.cxx:1939
const char Option_t
Definition: RtypesCore.h:62
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Definition: TObjArray.cxx:329
Definition: Rtypes.h:56
void Build()
Build a canvas. Called by all constructors.
Definition: TCanvas.cxx:551
Manages default Pad attributes.
Definition: TAttPad.h:19
Create a Box.
Definition: TBox.h:24
Int_t GetPadTickX() const
Definition: TStyle.h:202
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
TVirtualPadPainter * fPainter
! Canvas (pad) painter.
Definition: TCanvas.h:72
Int_t GetLogx() const
Definition: TPad.h:247
TObject * fSelected
! Currently selected object
Definition: TCanvas.h:56
TH1 * h
Definition: legend2.C:5
static void SaveColor(std::ostream &out, Int_t ci)
Save a color with index &gt; 228 as a C++ statement(s) on output stream out.
Definition: TColor.cxx:2022
Short_t fBorderSize
pad bordersize in pixels
Definition: TPad.h:96
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:847
virtual void SetBorderMode(Short_t bordermode)
Definition: TPad.h:313
static Bool_t fgIsFolder
Indicates if canvas can be browsed as a folder.
Definition: TCanvas.h:74
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas &amp; pad.
Definition: TCanvas.cxx:678
Int_t fCanvasID
! Canvas identifier
Definition: TCanvas.h:55
Int_t GetLogz() const
Definition: TPad.h:249
static TVirtualPadPainter * PadPainter(Option_t *opt="")
Create a pad painter of specified type.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition: TAttLine.cxx:162
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
virtual void CopyPixmap()
Copy the pixmap of the pad to the canvas.
Definition: TPad.cxx:1012
virtual void SetWindowTitle(const char *newTitle)
Definition: TCanvasImp.h:88
EEventType
Definition: Buttons.h:15
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
#define gROOT
Definition: TROOT.h:375
virtual void ToggleToolTips()
Toggle tooltip display.
Definition: TCanvas.cxx:2180
Size_t fYsizeUser
User specified size of canvas along Y in CM.
Definition: TCanvas.h:41
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition: TPad.cxx:3408
Basic string class.
Definition: TString.h:129
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition: TAttFill.cxx:200
Int_t fWindowTopX
Top X position of window (in pixels)
Definition: TCanvas.h:46
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
Int_t fSelectedX
! X of selected object
Definition: TCanvas.h:58
int Int_t
Definition: RtypesCore.h:41
virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0)
Set the canvas scale in centimeters.
Definition: TCanvas.cxx:1965
bool Bool_t
Definition: RtypesCore.h:59
virtual void PaintModified()
Traverse pad hierarchy and (re)paint only modified pads.
Definition: TPad.cxx:3563
R__EXTERN TVirtualMutex * gROOTMutex
Definition: TROOT.h:57
Int_t GetOptStat() const
Definition: TStyle.h:229
Float_t GetGreen() const
Definition: TColor.h:57
virtual void InitPainter()
Empty definition.
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:501
#define gInterpreter
Definition: TInterpreter.h:499
Int_t GetTickx() const
Definition: TPad.h:229
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
void Constructor()
Canvas default constructor.
Definition: TCanvas.cxx:163
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
ECursor
Definition: TVirtualX.h:44
void DrawEventStatus(Int_t event, Int_t x, Int_t y, TObject *selected)
Report name and title of primitive below the cursor.
Definition: TCanvas.cxx:942
virtual Short_t GetBorderMode() const
Definition: TPad.h:196
UInt_t GetWindowHeight() const
Definition: TCanvas.h:168
void Flush()
Flush canvas buffers.
Definition: TCanvas.cxx:1073
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:130
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:687
virtual TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj)
Search for an object at pixel position px,py.
Definition: TCanvas.h:186
void SetCanvasColor(Color_t color=19)
Definition: TStyle.h:318
Bool_t HasMenuBar() const
Definition: TCanvas.h:174
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Emit ProcessedEvent() signal.
Definition: TCanvas.cxx:1536
virtual void ClassMember(const char *, const char *=0, Int_t=-1, Int_t=-1)=0
#define SafeDelete(p)
Definition: RConfig.h:499
Size_t fXsizeReal
Current size of canvas along X in CM.
Definition: TCanvas.h:42
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:151
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:563
virtual void Browse(TBrowser *b)
Browse.
Definition: TCanvas.cxx:644
TString fSelectedOpt
! Drawing option of selected object
Definition: TCanvas.h:60
Fill Area Attributes class.
Definition: TAttFill.h:19
Double_t x[n]
Definition: legend1.C:17
Int_t GetWindowTopY()
Returns current top y position of window on screen.
Definition: TCanvas.cxx:1143
virtual void SetFixedAspectRatio(Bool_t fixed=kTRUE)
Fix canvas aspect ratio to current value if fixed is true.
Definition: TCanvas.cxx:1900
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition: TCanvas.cxx:730
virtual void Paint(Option_t *option="")
Paint canvas.
Definition: TCanvas.cxx:1459
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition: TCanvas.cxx:1551
virtual void Close(Option_t *option="")
Delete all primitives in pad and pad itself.
Definition: TPad.cxx:954
void Class()
Definition: Class.C:29
Float_t GetPadBottomMargin() const
Definition: TStyle.h:196
Bool_t IsBeingResized() const
Definition: TVirtualPad.h:142
void HighLight(Color_t col=kRed, Bool_t set=kTRUE)
Highlight pad.
Definition: TPad.cxx:2886
virtual void ShowEditor(Bool_t show=kTRUE)
Definition: TCanvasImp.h:95
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:323
Float_t GetBlue() const
Definition: TColor.h:58
virtual void Show()
Definition: TCanvasImp.h:62
TCanvas * fCanvas
! Pointer to mother canvas
Definition: TPad.h:105
TPad * fClickSelectedPad
! Pad containing currently click-selected object
Definition: TCanvas.h:62
void SetCanvasBorderSize(Width_t size=1)
Definition: TStyle.h:319
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition: TCanvas.cxx:2313
void Clear(Option_t *option="")
Remove all primitives from the canvas.
Definition: TCanvas.cxx:697
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
Definition: TObject.cxx:521
virtual void Close()
Definition: TCanvasImp.h:52
virtual void ShowToolBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:96
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
UInt_t GetWw() const
Get Ww.
Definition: TCanvas.h:169
virtual ~TCanvas()
Canvas destructor.
Definition: TCanvas.cxx:636
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:873
virtual void SetLogx(Int_t value=1)
Set Lin/Log scale for X.
Definition: TPad.cxx:5759
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition: TClass.cxx:5538
virtual void ShowMenuBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:90
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
R__EXTERN TGuiFactory * gGuiFactory
Definition: TGuiFactory.h:66
static void SetFolder(Bool_t isfolder=kTRUE)
If isfolder=kTRUE, the canvas can be browsed like a folder by default a canvas is not browsable...
Definition: TCanvas.cxx:1922
Int_t GetLogy() const
Definition: TPad.h:248
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition: TCanvas.cxx:1699
void ROOT_TCanvas_Update(void *TheCanvas)
Definition: TCanvas.cxx:2198
Int_t GetOptFit() const
Definition: TStyle.h:228
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
Definition: TVirtualPad.h:286
static TCanvasInit gCanvasInit
Definition: TCanvas.cxx:47
static Bool_t SupportAlpha()
Static function returning &quot;true&quot; if transparency is supported.
Definition: TCanvas.cxx:2192
Double_t fX2
X of upper X coordinate.
Definition: TPad.h:37
const char * GetName() const
Returns name of object.
Definition: TPad.h:251
A doubly linked list.
Definition: TList.h:43
Int_t GetOptLogz() const
Definition: TStyle.h:233
virtual Color_t GetHighLightColor() const
Get highlight color.
Definition: TPad.cxx:2640
Bool_t fRetained
Retain structure flag.
Definition: TCanvas.h:68
virtual void CopyPixmaps()
Copy the sub-pixmaps of the pad to the canvas.
Definition: TPad.cxx:1026
Int_t GetPadTickY() const
Definition: TStyle.h:203
Int_t GetOptTitle() const
Definition: TStyle.h:230
Float_t GetPadRightMargin() const
Definition: TStyle.h:199
Bool_t IsReading() const
Definition: TStyle.h:274
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
UInt_t fCw
Width of the canvas along X (pixels)
Definition: TCanvas.h:50
void DisconnectWidget()
Used by friend class TCanvasImp.
Definition: TCanvas.cxx:2252
TPad * fMother
! pointer to mother of the list
Definition: TPad.h:104
virtual Bool_t CheckObject(const TObject *obj)=0
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TPad.cxx:1643
void CopyPixmaps()
Copy the canvas pixmap of the pad to the canvas.
Definition: TCanvas.cxx:796
virtual void ToggleToolBar()
Toggle toolbar.
Definition: TCanvas.cxx:2158
Int_t fSelectedY
! Y of selected object
Definition: TCanvas.h:59
void SetCanvasBorderMode(Int_t mode=1)
Definition: TStyle.h:320
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:100
static void NeedGraphicsLibs()
Static method.
Int_t fPixmapID
! Off-screen pixmap identifier
Definition: TPad.h:83
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition: TCanvas.cxx:1635
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this canvas A new canvas is created that is a clone of this canvas.
Definition: TCanvas.cxx:861
SVector< double, 2 > v
Definition: Dict.h:5
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:5078
UInt_t fWindowHeight
Height of window (including menubar, borders, etc.)
Definition: TCanvas.h:49
Int_t GetOptLogy() const
Definition: TStyle.h:232
virtual void SetTicky(Int_t value=1)
Definition: TPad.h:345
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:482
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
virtual void ls(Option_t *option="") const
List all primitives in pad.
Definition: TPad.cxx:2921
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:679
virtual void UseCurrentStyle()
Force a copy of current style for all objects in pad.
Definition: TPad.cxx:6575
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
Bool_t GetShowToolTips() const
Definition: TCanvas.h:157
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
TString fDISPLAY
Name of destination screen.
Definition: TCanvas.h:39
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
The most important graphics class in the ROOT system.
Definition: TPad.h:29
char * Form(const char *fmt,...)
void CreatePainter()
Probably, TPadPainter must be placed in a separate ROOT module - &quot;padpainter&quot; (the same as &quot;histpaint...
Definition: TCanvas.cxx:2284
virtual Short_t GetBorderSize() const
Definition: TPad.h:197
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitives in this pad on the C++ source file out.
Definition: TPad.cxx:5524
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Definition: TCanvas.cxx:1420
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2632
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual void ToggleEditor()
Toggle editor.
Definition: TCanvas.cxx:2169
Bool_t fUpdating
! True when Updating the canvas
Definition: TCanvas.h:67
Bool_t GetGridx() const
Definition: TPad.h:226
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition: TCanvas.cxx:2138
void Destructor()
Actual canvas destructor.
Definition: TCanvas.cxx:654
if object destructor must call RecursiveRemove()
Definition: TObject.h:59
#define gVirtualX
Definition: TVirtualX.h:350
UInt_t GetWindowWidth() const
Definition: TCanvas.h:167
Int_t GetCanvasDefW() const
Definition: TStyle.h:178
virtual void ShowStatusBar(Bool_t show=kTRUE)
Definition: TCanvasImp.h:91
virtual void SelectDrawable(Int_t device)=0
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2524
#define R__LOCKGUARD2(mutex)
const Bool_t kFALSE
Definition: RtypesCore.h:92
Double_t fY2
Y of upper Y coordinate.
Definition: TPad.h:38
static void CreateApplication()
Static function used to create a default application environment.
Double_t fAspectRatio
ratio of w/h in case of fixed ratio
Definition: TPad.h:81
Float_t GetPadLeftMargin() const
Definition: TStyle.h:198
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition: TCanvas.cxx:1132
TAttCanvas fCatt
Canvas attributes.
Definition: TCanvas.h:38
const char * GetTitle() const
Returns title of object.
Definition: TPad.h:252
void InitializeGraphics()
Initialize the graphics environment.
if object does not want context menu
Definition: TObject.h:64
long Long_t
Definition: RtypesCore.h:50
Color * colors
Definition: X3DBuffer.c:19
TCanvasImp * fCanvasImp
! Window system specific canvas implementation
Definition: TCanvas.h:64
Option_t * GetOption() const
Definition: TCollection.h:155
The Canvas class.
Definition: TCanvas.h:31
Int_t GetCanvasDefX() const
Definition: TStyle.h:179
virtual Int_t GetSize() const
Definition: TCollection.h:89
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:393
const Size_t kDefaultCanvasSize
Definition: TCanvas.cxx:54
Int_t GetCanvasDefY() const
Definition: TStyle.h:180
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TObject.cxx:318
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:364
double Double_t
Definition: RtypesCore.h:55
virtual void SetGridy(Int_t value=1)
Definition: TPad.h:325
R__EXTERN TEnv * gEnv
Definition: TEnv.h:170
void SetCanvasSize(UInt_t ww, UInt_t wh)
Set Width and Height of canvas to ww and wh respectively.
Definition: TCanvas.cxx:1861
virtual void SetFillStyle(Style_t fstyle)
Override TAttFill::FillStyle for TPad because we want to handle style=0 as style 4000.
Definition: TPad.cxx:5747
Bool_t IsBatch() const
Is pad in batch mode ?
Definition: TCanvas.h:176
static RooMathCoreReg dummy
Double_t y[n]
Definition: legend1.C:17
void Init()
Initialize the TCanvas members. Called by all constructors.
Definition: TCanvas.cxx:502
virtual void SetRGB(Float_t r, Float_t g, Float_t b)
Initialize this color and its associated colors.
Definition: TColor.cxx:1646
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition: TCanvas.cxx:2261
virtual TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
Create a batch version of TCanvasImp.
Definition: TGuiFactory.cxx:56
#define gGLManager
Definition: TVirtualGL.h:162
Color_t fHighLightColor
Highlight color of active pad.
Definition: TCanvas.h:44
Size_t fXsizeUser
User specified size of canvas along X in CM.
Definition: TCanvas.h:40
The color creation and management class.
Definition: TColor.h:19
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
Float_t GetRed() const
Definition: TColor.h:56
void SetWindowSize(UInt_t ww, UInt_t wh)
Definition: TCanvas.h:204
virtual void SetTicks(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:343
Int_t fWindowTopY
Top Y position of window (in pixels)
Definition: TCanvas.h:47
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition: TAttPad.cxx:120
virtual void SetName(const char *name)
Definition: TPad.h:341
Bool_t GetShowToolBar() const
Definition: TCanvas.h:155
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t fFixedAspectRatio
True if fixed aspect ratio.
Definition: TPad.h:103
void UseCurrentStyle()
Force a copy of current style for all objects in canvas.
Definition: TCanvas.cxx:1107
void Clear(Option_t *option="")
Delete all pad primitives.
Definition: TPad.cxx:592
virtual void Draw(Option_t *option="")
Draw a canvas.
Definition: TCanvas.cxx:814
Int_t fDoubleBuffer
Double buffer flag (0=off, 1=on)
Definition: TCanvas.h:45
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2624
virtual void SetDoubleBuffer(Int_t mode=1)
Set Double Buffer On/Off.
Definition: TCanvas.cxx:1883
typedef void((*Func_t)())
void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitives in this canvas in C++ macro file with GUI.
Definition: TCanvas.cxx:1654
TList * GetListOfPrimitives() const
Definition: TPad.h:236
virtual TObject * DrawClonePad()
Draw a clone of this canvas into the current pad In an interactive session, select the destination/cu...
Definition: TCanvas.cxx:887
#define ClassImpQ(name)
Definition: TQObject.h:282
void EmbedInto(Int_t winid, Int_t ww, Int_t wh)
Embedded a canvas into a TRootEmbeddedCanvas.
Definition: TCanvas.cxx:978
virtual void ShowToolTips(Bool_t show=kTRUE)
Definition: TCanvasImp.h:97
virtual void Add(TObject *obj)
Definition: TList.h:77
virtual void LockPainter()
Empty definition.
virtual void ClassEnd(const TClass *)=0
Int_t fEventX
! Last X mouse position in canvas
Definition: TCanvas.h:53
virtual void ls(Option_t *option="") const
List all pads.
Definition: TCanvas.cxx:1408
void SetSelected(TObject *obj)
Set selected canvas.
Definition: TCanvas.cxx:1930
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:568
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
void Close(Option_t *option="")
Close canvas.
Definition: TCanvas.cxx:748
virtual void EditorBar()
Get editor bar.
Definition: TCanvas.cxx:969
#define snprintf
Definition: civetweb.c:822
R__EXTERN TVirtualPS * gVirtualPS
Definition: TVirtualPS.h:81
TVirtualPad * GetSelectedPad() const
Definition: TCanvas.h:152
#define gPad
Definition: TVirtualPad.h:284
virtual Int_t InitWindow()
Definition: TCanvasImp.h:56
Width_t GetCanvasBorderSize() const
Definition: TStyle.h:175
R__EXTERN Int_t gDebug
Definition: Rtypes.h:83
Implement TVirtualPadPainter which abstracts painting operations.
Definition: TPadPainter.h:26
TObject * fClickSelected
! Currently click-selected object
Definition: TCanvas.h:57
Int_t fEventY
! Last Y mouse position in canvas
Definition: TCanvas.h:54
Bool_t GetShowEventStatus() const
Definition: TCanvas.h:154
Bool_t GetPadGridY() const
Definition: TStyle.h:201
Bool_t GetGridy() const
Definition: TPad.h:227
void SetBatch(Bool_t batch=kTRUE)
Toggle batch mode.
Definition: TCanvas.cxx:1845
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:164
void ResetBit(UInt_t f)
Definition: TObject.h:158
virtual UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Definition: TCanvasImp.h:83
TVirtualPS is an abstract interface to Postscript, PDF, SVG.
Definition: TVirtualPS.h:30
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition: TCanvas.cxx:1156
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:314
virtual void Update()
Update canvas pad buffers.
Definition: TCanvas.cxx:2205
Double_t fY1
Y of lower Y coordinate.
Definition: TPad.h:36
virtual void SetStatusText(const char *text=0, Int_t partidx=0)
Definition: TCanvasImp.h:85
Int_t fGLDevice
! OpenGL off-screen pixmap identifier
Definition: TPad.h:84
Bool_t fBatch
! True when in batchmode
Definition: TCanvas.h:66
Float_t GetPadTopMargin() const
Definition: TStyle.h:197
const char * AsString() const
Return the date &amp; time as a string (ctime() format).
Definition: TDatime.cxx:101
Int_t GetOptLogx() const
Definition: TStyle.h:231
virtual void SetCanvasSize(UInt_t w, UInt_t h)
Definition: TCanvasImp.h:89
Double_t fX1
X of lower X coordinate.
Definition: TPad.h:35
virtual void SetLogz(Int_t value=1)
Set Lin/Log scale for Z.
Definition: TPad.cxx:5784
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:408
Float_t GetScreenFactor() const
Definition: TStyle.h:240
Color_t GetHighLightColor() const
Get highlight color.
Definition: TCanvas.h:144
Int_t GetCanvasDefH() const
Definition: TStyle.h:177
const Bool_t kTRUE
Definition: RtypesCore.h:91
virtual void Closed()
Emit Closed signal.
Definition: TCanvas.cxx:738
const Int_t n
Definition: legend1.C:16
Color_t GetCanvasColor() const
Definition: TStyle.h:174
Line Attributes class.
Definition: TAttLine.h:18
void Modified(Bool_t flag=1)
Definition: TPad.h:410
To make it possible to use GL for 2D graphic in a TPad/TCanvas.
char name[80]
Definition: TGX11.cxx:109
UInt_t GetWh() const
Get Wh.
Definition: TCanvas.h:170
virtual void Picked(TPad *selpad, TObject *selected, Int_t event)
Emit Picked() signal.
Definition: TCanvas.cxx:1508
UInt_t fCh
Height of the canvas along Y (pixels)
Definition: TCanvas.h:51
Short_t fBorderMode
Bordermode (-1=down, 0 = no border, 1=up)
Definition: TPad.h:97
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
UInt_t fWindowWidth
Width of window (including borders, etc.)
Definition: TCanvas.h:48
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
Int_t GetNumber() const
Definition: TColor.h:54
void SetGrayscale(Bool_t set=kTRUE)
Set whether this canvas should be painted in grayscale, and re-paint it if necessary.
Definition: TCanvas.cxx:2270
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:110
virtual void SetLogy(Int_t value=1)
Set Lin/Log scale for Y.
Definition: TPad.cxx:5773
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:859