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