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