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