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