Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 <cstring>
13#include <cstdlib>
14#include <iostream>
15#include <fstream>
16
17#include "TROOT.h"
18#include "TBuffer.h"
19#include "TCanvas.h"
20#include "TCanvasImp.h"
21#include "TDatime.h"
22#include "TClass.h"
23#include "TStyle.h"
24#include "TBox.h"
25#include "TCanvasImp.h"
26#include "TDialogCanvas.h"
27#include "TGuiFactory.h"
28#include "TEnv.h"
29#include "TError.h"
30#include "TContextMenu.h"
31#include "TControlBar.h"
32#include "TInterpreter.h"
33#include "TApplication.h"
34#include "TColor.h"
35#include "TSystem.h"
36#include "TObjArray.h"
37#include "TVirtualPadEditor.h"
38#include "TVirtualViewer3D.h"
39#include "TPadPainter.h"
40#include "TPadPainterPS.h"
41#include "TVirtualGL.h"
42#include "TVirtualPS.h"
43#include "TVirtualX.h"
44#include "TAxis.h"
45#include "TH1.h"
46#include "TGraph.h"
47#include "TMath.h"
48#include "TView.h"
49#include "strlcpy.h"
50#include "snprintf.h"
51
52#include "TVirtualMutex.h"
53
58
59//*-*x16 macros/layout_canvas
60
62
64
65
66TString GetNewCanvasName(const char *arg = nullptr)
67{
68 if (arg && *arg)
69 return arg;
70
71 const char *defcanvas = gROOT->GetDefCanvasName();
73
74 auto lc = (TList*)gROOT->GetListOfCanvases();
75 Int_t n = lc->GetSize() + 1;
76
77 while(lc->FindObject(cdef.Data()))
78 cdef.Form("%s_n%d", defcanvas, n++);
79
80 return cdef;
81}
82
83
84/** \class TCanvas
85\ingroup gpad
86
87The Canvas class.
88
89A Canvas is an area mapped to a window directly under the control of the display
90manager. A ROOT session may have several canvases open at any given time.
91
92A Canvas may be subdivided into independent graphical areas: the __Pads__.
93A canvas has a default pad which has the name of the canvas itself.
94An example of a Canvas layout is sketched in the picture below.
95
96\image html gpad_canvas.png
97
98This canvas contains two pads named P1 and P2. Both Canvas, P1 and P2 can be
99moved, grown, shrunk using the normal rules of the Display manager.
100
101Once objects have been drawn in a canvas, they can be edited/moved by pointing
102directly to them. The cursor shape is changed to suggest the type of action that
103one can do on this object. Clicking with the right mouse button on an object
104pops-up a contextmenu with a complete list of actions possible on this object.
105
106A graphical editor may be started from the canvas "View" menu under the menu
107entry "Toolbar".
108
109An interactive HELP is available by clicking on the HELP button at the top right
110of the canvas. It gives a short explanation about the canvas' menus.
111
112A canvas may be automatically divided into pads via `TPad::Divide`.
113
114At creation time, no matter if in interactive or batch mode, the constructor
115defines the size of the canvas window (including the size of the ROOT menu bar but
116excluding the size of the OS window manager's decoration). To define precisely the
117graphics area size of a canvas in batch/interactive mode, the following code should
118be used:
119~~~ {.cpp}
120 {
121 Double_t w = 600;
122 Double_t h = 600;
123 auto c = new TCanvas("c", "c", w, h);
124 c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));
125 }
126~~~
127
128To ensure similar painting size for the canvas created with default size for both interactive and batch mode:
129~~~ {.cpp}
130 {
131 auto c = new TCanvas("c", "c");
132 c->SetWindowSize(c->GetWindowWidth() + (c->GetWindowWidth() - c->GetWw()), c->GetWindowHeight() + (c->GetWindowHeight() - c->GetWh()));
133 }
134~~~
135
136If you are in batch mode, you can also specify the fixed painting area as follows:
137~~~ {.cpp}
138 c->SetCanvasSize(w, h);
139~~~
140
141If the canvas size exceeds the window size, scroll bars will be added to the canvas
142This allows to display very large canvases (even bigger than the screen size). The
143Following example shows how to proceed.
144~~~ {.cpp}
145 {
146 auto c = new TCanvas("c","c");
147 c->SetCanvasSize(1500, 1500);
148 c->SetWindowSize(500, 500);
149 }
150~~~
151*/
152
153////////////////////////////////////////////////////////////////////////////////
154/// Canvas default constructor.
155
156TCanvas::TCanvas(Bool_t build) : TPad(), fDoubleBuffer(0)
157{
158 fPainter = nullptr;
159 fWindowTopX = 0;
160 fWindowTopY = 0;
161 fWindowWidth = 0;
162 fWindowHeight = 0;
163 fCw = 0;
164 fCh = 0;
165 fXsizeUser = 0;
166 fYsizeUser = 0;
169 fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
170 fEvent = -1;
171 fEventX = -1;
172 fEventY = -1;
173 fSelectedX = 0;
174 fSelectedY = 0;
176 fDrawn = kFALSE;
178 fSelected = nullptr;
179 fClickSelected = nullptr;
180 fSelectedPad = nullptr;
181 fClickSelectedPad = nullptr;
182 fPadSave = nullptr;
183 fCanvasImp = nullptr;
184 fContextMenu = nullptr;
185
187
188 if (!build || TClass::IsCallingNew() != TClass::kRealNew) {
189 Constructor();
190 } else {
191 auto cdef = GetNewCanvasName();
192
193 Constructor(cdef.Data(), cdef.Data(), 1);
194 }
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Canvas default constructor
199
201{
202 if (gThreadXAR) {
203 void *arr[2];
204 arr[1] = this;
205 if ((*gThreadXAR)("CANV", 2, arr, nullptr)) return;
206 }
207
208 fCanvas = nullptr;
209 fCanvasID = -1;
210 fCanvasImp = nullptr;
211 fBatch = kTRUE;
213
214 fContextMenu = nullptr;
215 fSelected = nullptr;
216 fClickSelected = nullptr;
217 fSelectedPad = nullptr;
218 fClickSelectedPad = nullptr;
219 fPadSave = nullptr;
223}
224
225////////////////////////////////////////////////////////////////////////////////
226/// Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
227/// which is placed in a TGFrame. This ctor is only called via the
228/// TRootEmbeddedCanvas class.
229///
230/// If "name" starts with "gl" the canvas is ready to receive GL output.
231
232TCanvas::TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid) : TPad(), fDoubleBuffer(0)
233{
234 fCanvasImp = nullptr;
235 fPainter = nullptr;
236 Init();
237
239 fWindowTopX = 0;
240 fWindowTopY = 0;
241 fWindowWidth = ww;
243 fCw = ww + 4;
244 fCh = wh +28;
245 fBatch = kFALSE;
247
248 //This is a very special ctor. A window exists already!
249 //Can create painter now.
251
252 if (fUseGL) {
253 fGLDevice = gGLManager->CreateGLContext(winid);
254 if (fGLDevice == -1)
255 fUseGL = kFALSE;
256 }
257
259 if (!fCanvasImp) return;
260
262 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
263 Build();
264}
265
266////////////////////////////////////////////////////////////////////////////////
267/// Create a new canvas with a predefined size form.
268/// If form < 0 the menubar is not shown.
269///
270/// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
271/// - form = 2 500x500 at 20,20
272/// - form = 3 500x500 at 30,30
273/// - form = 4 500x500 at 40,40
274/// - form = 5 500x500 at 50,50
275///
276/// If "name" starts with "gl" the canvas is ready to receive GL output.
277
278TCanvas::TCanvas(const char *name, const char *title, Int_t form) : TPad(), fDoubleBuffer(0)
279{
280 fPainter = nullptr;
282
283 Constructor(name, title, form);
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Create a new canvas with a predefined size form.
288/// If form < 0 the menubar is not shown.
289///
290/// - form = 1 700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
291/// - form = 2 500x500 at 20,20
292/// - form = 3 500x500 at 30,30
293/// - form = 4 500x500 at 40,40
294/// - form = 5 500x500 at 50,50
295
296void TCanvas::Constructor(const char *name, const char *title, Int_t form)
297{
298 if (gThreadXAR) {
299 void *arr[6];
300 static Int_t ww = 500;
301 static Int_t wh = 500;
302 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
303 if ((*gThreadXAR)("CANV", 6, arr, nullptr)) return;
304 }
305
306 Init();
307 SetBit(kMenuBar,true);
308 if (form < 0) {
309 form = -form;
310 SetBit(kMenuBar,false);
311 }
312
313 fCanvas = this;
314
315 fCanvasID = -1;
316 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
317 if (old && old->IsOnHeap()) {
318 Warning("Constructor","Deleting canvas with same name: %s",name);
319 delete old;
320 }
321 if (gROOT->IsBatch()) { //We are in Batch mode
323 if (form == 1) {
326 } else {
327 fWindowWidth = 500;
328 fWindowHeight = 500;
329 }
333 if (!fCanvasImp) return;
334 fBatch = kTRUE;
335 } else { //normal mode with a screen window
337 if (form < 1 || form > 20) form = 1;
338 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
339 Int_t ux, uy, cw, ch;
340 if (form == 1) {
341 cw = gStyle->GetCanvasDefW();
342 ch = gStyle->GetCanvasDefH();
345 } else {
346 cw = ch = 500;
347 ux = uy = form * 10;
348 }
349
350 fCanvasImp = factory->CreateCanvasImp(this, name, Int_t(cx*ux), Int_t(cx*uy), UInt_t(cx*cw), UInt_t(cx*ch));
351 if (!fCanvasImp) return;
352
353 if (!gROOT->IsBatch() && fCanvasID == -1)
355
357 fBatch = kFALSE;
358 }
359
361
362 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
363 SetTitle(title); // requires fCanvasImp set
364 Build();
365
366 // Popup canvas
367 fCanvasImp->Show();
368}
369
370////////////////////////////////////////////////////////////////////////////////
371/// Create a new canvas at a random position.
372///
373/// \param[in] name canvas name
374/// \param[in] title canvas title
375/// \param[in] ww is the window size in pixels along X
376/// (if ww < 0 the menubar is not shown)
377/// \param[in] wh is the window size in pixels along Y
378///
379/// If "name" starts with "gl" the canvas is ready to receive GL output.
380
381TCanvas::TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad(), fDoubleBuffer(0)
382{
383 fPainter = nullptr;
385
386 Constructor(name, title, ww, wh);
387}
388
389////////////////////////////////////////////////////////////////////////////////
390/// Create a new canvas at a random position.
391///
392/// \param[in] name canvas name
393/// \param[in] title canvas title
394/// \param[in] ww is the window size in pixels along X
395/// (if ww < 0 the menubar is not shown)
396/// \param[in] wh is the window size in pixels along Y
397
398void TCanvas::Constructor(const char *name, const char *title, Int_t ww, Int_t wh)
399{
400 if (gThreadXAR) {
401 void *arr[6];
402 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title; arr[4] =&ww; arr[5] = &wh;
403 if ((*gThreadXAR)("CANV", 6, arr, nullptr)) return;
404 }
405
406 Init();
407 SetBit(kMenuBar,true);
408 if (ww < 0) {
409 ww = -ww;
410 SetBit(kMenuBar,false);
411 }
412 if (wh <= 0) {
413 Error("Constructor", "Invalid canvas height: %d",wh);
414 return;
415 }
416 fCw = ww;
417 fCh = wh;
418 fCanvasID = -1;
419 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
420 if (old && old->IsOnHeap()) {
421 Warning("Constructor","Deleting canvas with same name: %s",name);
422 delete old;
423 }
424 if (gROOT->IsBatch()) { //We are in Batch mode
426 fWindowWidth = ww;
428 fCw = ww;
429 fCh = wh;
431 if (!fCanvasImp) return;
432 fBatch = kTRUE;
433 } else {
435 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
436 fCanvasImp = factory->CreateCanvasImp(this, name, UInt_t(cx*ww), UInt_t(cx*wh));
437 if (!fCanvasImp) return;
438
439 if (!gROOT->IsBatch() && fCanvasID == -1)
441
443 fBatch = kFALSE;
444 }
445
447
448 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
449 SetTitle(title); // requires fCanvasImp set
450 Build();
451
452 // Popup canvas
453 fCanvasImp->Show();
454}
455
456////////////////////////////////////////////////////////////////////////////////
457/// Create a new canvas.
458///
459/// \param[in] name canvas name
460/// \param[in] title canvas title
461/// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
462/// the canvas (if wtopx < 0) the menubar is not shown)
463/// \param[in] ww is the window size in pixels along X
464/// \param[in] wh is the window size in pixels along Y
465///
466/// If "name" starts with "gl" the canvas is ready to receive GL output.
467
468TCanvas::TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)
469 : TPad(), fDoubleBuffer(0)
470{
471 fPainter = nullptr;
473
474 Constructor(name, title, wtopx, wtopy, ww, wh);
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Create a new canvas.
479///
480/// \param[in] name canvas name
481/// \param[in] title canvas title
482/// \param[in] wtopx,wtopy are the pixel coordinates of the top left corner of
483/// the canvas (if wtopx < 0) the menubar is not shown)
484/// \param[in] ww is the window size in pixels along X
485/// \param[in] wh is the window size in pixels along Y
486
487void TCanvas::Constructor(const char *name, const char *title, Int_t wtopx,
488 Int_t wtopy, Int_t ww, Int_t wh)
489{
490 if (gThreadXAR) {
491 void *arr[8];
492 arr[1] = this; arr[2] = (void*)name; arr[3] = (void*)title;
493 arr[4] = &wtopx; arr[5] = &wtopy; arr[6] = &ww; arr[7] = &wh;
494 if ((*gThreadXAR)("CANV", 8, arr, nullptr)) return;
495 }
496
497 Init();
498 SetBit(kMenuBar,true);
499 if (wtopx < 0) {
500 wtopx = -wtopx;
501 SetBit(kMenuBar,false);
502 }
503 fCw = ww;
504 fCh = wh;
505 fCanvasID = -1;
506 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
507 if (old && old->IsOnHeap()) {
508 Warning("Constructor","Deleting canvas with same name: %s",name);
509 delete old;
510 }
511 if (gROOT->IsBatch()) { //We are in Batch mode
513 fWindowWidth = ww;
515 fCw = ww;
516 fCh = wh;
518 if (!fCanvasImp) return;
519 fBatch = kTRUE;
520 } else { //normal mode with a screen window
522 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
523 fCanvasImp = factory->CreateCanvasImp(this, name, Int_t(cx*wtopx), Int_t(cx*wtopy), UInt_t(cx*ww), UInt_t(cx*wh));
524 if (!fCanvasImp) return;
525
526 if (!gROOT->IsBatch() && fCanvasID == -1)
528
530 fBatch = kFALSE;
531 }
532
534
535 fName = GetNewCanvasName(name); // avoid Modified() signal from SetName
536 SetTitle(title); // requires fCanvasImp set
537 Build();
538
539 // Popup canvas
540 fCanvasImp->Show();
541}
542
543////////////////////////////////////////////////////////////////////////////////
544/// Initialize the TCanvas members. Called by all constructors.
545
547{
548 // Make sure the application environment exists. It is need for graphics
549 // (colors are initialized in the TApplication ctor).
550 if (!gApplication)
552
553 // Load and initialize graphics libraries if
554 // TApplication::NeedGraphicsLibs() has been called by a
555 // library static initializer.
556 if (gApplication)
557 gApplication->InitializeGraphics(gROOT->IsWebDisplay());
558
559 // Get some default from .rootrc. Used in fCanvasImp->InitWindow().
560 fHighLightColor = gEnv->GetValue("Canvas.HighLightColor", kRed);
561 SetBit(kMoveOpaque, gEnv->GetValue("Canvas.MoveOpaque", 0));
562 SetBit(kResizeOpaque, gEnv->GetValue("Canvas.ResizeOpaque", 0));
563 if (gEnv->GetValue("Canvas.ShowEventStatus", kFALSE)) SetBit(kShowEventStatus);
564 if (gEnv->GetValue("Canvas.ShowToolTips", kFALSE)) SetBit(kShowToolTips);
565 if (gEnv->GetValue("Canvas.ShowToolBar", kFALSE)) SetBit(kShowToolBar);
566 if (gEnv->GetValue("Canvas.ShowEditor", kFALSE)) SetBit(kShowEditor);
567 if (gEnv->GetValue("Canvas.AutoExec", kTRUE)) SetBit(kAutoExec);
568
569 // Fill canvas ROOT data structure
570 fXsizeUser = 0;
571 fYsizeUser = 0;
574
575 fDISPLAY = "$DISPLAY";
578 fSelected = nullptr;
579 fClickSelected = nullptr;
580 fSelectedX = 0;
581 fSelectedY = 0;
582 fSelectedPad = nullptr;
583 fClickSelectedPad= nullptr;
584 fPadSave = nullptr;
585 fEvent = -1;
586 fEventX = -1;
587 fEventY = -1;
588 fContextMenu = nullptr;
589 fDrawn = kFALSE;
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// Build a canvas. Called by all constructors.
595
597{
598 // Get window identifier
599 if (fCanvasID == -1 && fCanvasImp)
601 if (fCanvasID == -1) return;
602
603 if (fCw !=0 && fCh !=0) {
606 }
607
608 // Set Pad parameters
609 gPad = this;
610 fCanvas = this;
611 fMother = (TPad*)gPad;
612
613 if (IsBatch()) {
614 // Make sure that batch interactive canvas sizes are the same
615 fCw -= 4;
616 fCh -= 28;
617 } else if (IsWeb()) {
618 // mark canvas as batch - avoid gVirtualX in many places
620 } else {
621 //normal mode with a screen window
622 if (auto pp = GetCanvasPainter()) {
623 // Set default physical canvas attributes
624 pp->SelectDrawable(fCanvasID);
625 pp->SetAttFill({1, 1001}); //Set color index for fill area
626 pp->SetAttLine({1, 1, 1}); //Set color index for lines
627 pp->SetAttMarker({1, 1, 1}); //Set color index for markers
628 // pp->SetAttText({22, 0., 1, 42, 12}); //Set color index for text
629 // Clear workstation
630 pp->ClearWindow(fCanvasID);
631 }
632
633 // Set Double Buffer on by default
635
636 // Get effective window parameters (with borders and menubar)
639
640 // Get effective canvas parameters without borders
642
643 fContextMenu = new TContextMenu("ContextMenu");
644 }
645
646 gROOT->GetListOfCanvases()->Add(this);
647
648 if (!fPrimitives) {
649 fPrimitives = new TList;
651 SetFillStyle(1001);
663 fBorderMode=gStyle->GetCanvasBorderMode(); // do not call SetBorderMode (function redefined in TCanvas)
664 SetPad(0, 0, 1, 1);
665 Range(0, 0, 1, 1); //pad range is set by default to [0,1] in x and y
666
667 if (auto pp = GetCanvasPainter())
668 pp->SelectDrawable(fPixmapID); //pixmap must be selected
669 PaintBorder(GetFillColor(), kTRUE); //paint background
670 }
671
672 // transient canvases have typically no menubar and should not get
673 // by default the event status bar (if set by default)
674 if (TestBit(kMenuBar) && fCanvasImp) {
676 // ... and toolbar + editor
680 }
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// Canvas destructor
685
687{
688 Destructor();
689}
690
691////////////////////////////////////////////////////////////////////////////////
692/// Browse.
693
695{
696 Draw();
697 cd();
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// Actual canvas destructor.
703
705{
706 if (gThreadXAR) {
707 void *arr[2];
708 arr[1] = this;
709 if ((*gThreadXAR)("CDEL", 2, arr, nullptr)) return;
710 }
711
712 if (ROOT::Detail::HasBeenDeleted(this)) return;
713
715 if (!gPad) return;
716
717 Close();
718
719 //If not yet (batch mode?).
721}
722
723////////////////////////////////////////////////////////////////////////////////
724/// Set current canvas & pad. Returns the new current pad,
725/// or 0 in case of failure.
726/// See TPad::cd() for an explanation of the parameter.
727
729{
730 if (fCanvasID == -1) return nullptr;
731
733
734 // in case doublebuffer is off, draw directly onto display window
735 if (!IsBatch() && !IsWeb() && !fDoubleBuffer && fPainter)
736 fPainter->SelectDrawable(fCanvasID);//Ok, does not matter for glpad.
737
738 return gPad;
739}
740
741////////////////////////////////////////////////////////////////////////////////
742/// Remove all primitives from the canvas.
743/// If option "D" is specified, direct sub-pads are cleared but not deleted.
744/// This option is not recursive, i.e. pads in direct sub-pads are deleted.
745
747{
748 if (fCanvasID == -1) return;
749
751
752 TString opt = option;
753 opt.ToLower();
754 if (opt.Contains("d")) {
755 // clear subpads, but do not delete pads in case the canvas
756 // has been divided (note: option "D" is propagated so could cause
757 // conflicts for primitives using option "D" for something else)
758 if (fPrimitives) {
759 TIter next(fPrimitives);
760 TObject *obj;
761 while ((obj=next())) {
762 obj->Clear(option);
763 }
764 }
765 } else {
766 //default, clear everything in the canvas. Subpads are deleted
767 TPad::Clear(option); //Remove primitives from pad
768 }
769
770 fSelected = nullptr;
771 fClickSelected = nullptr;
772 fSelectedPad = nullptr;
773 fClickSelectedPad = nullptr;
774}
775
776////////////////////////////////////////////////////////////////////////////////
777/// Emit pad Cleared signal.
778
780{
781 Emit("Cleared(TVirtualPad*)", (Longptr_t)pad);
782}
783
784////////////////////////////////////////////////////////////////////////////////
785/// Emit Closed signal.
786
788{
789 Emit("Closed()");
790}
791
792////////////////////////////////////////////////////////////////////////////////
793/// Close canvas.
794///
795/// Delete window/pads data structure
796
798{
799 auto padsave = gPad;
800 TCanvas *cansave = padsave ? padsave->GetCanvas() : nullptr;
801
802 if (fCanvasID != -1) {
803
804 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
805 gInterpreter->Execute(this, IsA(), "Close", option);
806 return;
807 }
808
810
812
813 cd();
815
816 if (!IsBatch() && !IsWeb()) {
817 //select current canvas
818 if (fPainter)
820
822
823 if (fCanvasImp)
824 fCanvasImp->Close();
825 }
826 fCanvasID = -1;
827 fBatch = kTRUE;
828
829 gROOT->GetListOfCanvases()->Remove(this);
830
831 // Close actual window on screen
833 }
834
835 if (cansave == this) {
836 gPad = (TCanvas *) gROOT->GetListOfCanvases()->First();
837 } else {
838 gPad = padsave;
839 }
840
841 Closed();
842}
843
844////////////////////////////////////////////////////////////////////////////////
845/// Copy the canvas pixmap of the pad to the canvas.
846
848{
849 if (!IsBatch()) {
852 }
853}
854
855////////////////////////////////////////////////////////////////////////////////
856/// Draw a canvas.
857/// If a canvas with the name is already on the screen, the canvas is repainted.
858/// This function is useful when a canvas object has been saved in a Root file.
859/// One can then do:
860/// ~~~ {.cpp}
861/// Root > TFile::Open("file.root");
862/// Root > canvas->Draw();
863/// ~~~
864
866{
867 // Load and initialize graphics libraries if
868 // TApplication::NeedGraphicsLibs() has been called by a
869 // library static initializer.
870 if (gApplication)
871 gApplication->InitializeGraphics(gROOT->IsWebDisplay());
872
873 fDrawn = kTRUE;
874
875 TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(GetName());
876 if (old == this) {
877 if (IsWeb()) {
878 Modified();
879 UpdateAsync();
880 } else {
881 Paint();
882 }
883 return;
884 }
885 if (old) { gROOT->GetListOfCanvases()->Remove(old); delete old;}
886
887 if (fWindowWidth == 0) {
888 if (fCw !=0) fWindowWidth = fCw+4;
889 else fWindowWidth = 800;
890 }
891 if (fWindowHeight == 0) {
892 if (fCh !=0) fWindowHeight = fCh+28;
893 else fWindowHeight = 600;
894 }
895 if (gROOT->IsBatch()) { //We are in Batch mode
897 if (!fCanvasImp) return;
898 fBatch = kTRUE;
899
900 } else { //normal mode with a screen window
901 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
902 fCanvasImp = factory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
904 if (!fCanvasImp) return;
906 }
907 Build();
908 ResizePad();
910 fCanvasImp->Show();
911 Modified();
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Draw a clone of this canvas
916/// A new canvas is created that is a clone of this canvas
917
919{
921 newCanvas->SetName();
922
923 newCanvas->Draw(option);
924 newCanvas->Update();
925 return newCanvas;
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Draw a clone of this canvas into the current pad
930/// In an interactive session, select the destination/current pad
931/// with the middle mouse button, then point to the canvas area to select
932/// the canvas context menu item DrawClonePad.
933/// Note that the original canvas may have subpads.
934
936{
937 auto padsav = gPad;
938 auto selpad = gROOT->GetSelectedPad();
939 auto pad = padsav;
940 if (pad == this) pad = selpad;
941 if (!padsav || !pad || pad == this) {
943 newCanvas->SetWindowSize(GetWindowWidth(),GetWindowHeight());
944 return newCanvas;
945 }
946 if (fCanvasID == -1) {
947 auto factory = gROOT->IsWebDisplay() ? gBatchGuiFactory : gGuiFactory;
948 fCanvasImp = factory->CreateCanvasImp(this, GetName(), fWindowTopX, fWindowTopY,
950 if (!fCanvasImp) return nullptr;
953 }
954 this->cd();
955 //copy pad attributes
956 pad->Range(fX1,fY1,fX2,fY2);
957 pad->SetTickx(GetTickx());
958 pad->SetTicky(GetTicky());
959 pad->SetGridx(GetGridx());
960 pad->SetGridy(GetGridy());
961 pad->SetLogx(GetLogx());
962 pad->SetLogy(GetLogy());
963 pad->SetLogz(GetLogz());
964 pad->SetBorderSize(GetBorderSize());
965 pad->SetBorderMode(GetBorderMode());
969
970 //copy primitives
972 while (auto obj = next()) {
973 pad->cd();
974 pad->Add(obj->Clone(), next.GetOption(), kFALSE); // do not issue modified for each object
975 }
976 pad->ResizePad();
977 pad->Modified();
978 pad->Update();
979 if (padsav) padsav->cd();
980 return nullptr;
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// Report name and title of primitive below the cursor.
985///
986/// This function is called when the option "Event Status"
987/// in the canvas menu "Options" is selected.
988
989void TCanvas::DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)
990{
991 const Int_t kTMAX=256;
992 static char atext[kTMAX];
993
994 if (!TestBit(kShowEventStatus) || !selected) return;
995
996 if (!fCanvasImp) return; //this may happen when closing a TAttCanvas
997
999
1000 fCanvasImp->SetStatusText(selected->GetTitle(),0);
1001 fCanvasImp->SetStatusText(selected->GetName(),1);
1002 if (event == kKeyPress)
1003 snprintf(atext, kTMAX, "%c", (char) px);
1004 else
1005 snprintf(atext, kTMAX, "%d,%d", px, py);
1007
1008 // Show date/time if TimeDisplay is selected
1009 TAxis *xaxis = nullptr;
1010 if ( selected->InheritsFrom("TH1") )
1011 xaxis = ((TH1*)selected)->GetXaxis();
1012 else if ( selected->InheritsFrom("TGraph") )
1013 xaxis = ((TGraph*)selected)->GetXaxis();
1014 else if ( selected->InheritsFrom("TAxis") )
1015 xaxis = (TAxis*)selected;
1016 if ( xaxis != nullptr && xaxis->GetTimeDisplay()) {
1017 TString objinfo = selected->GetObjectInfo(px,py);
1018 // check if user has overwritten GetObjectInfo and altered
1019 // the default text from TObject::GetObjectInfo "x=.. y=.."
1020 if (objinfo.Contains("x=") && objinfo.Contains("y=") ) {
1021 UInt_t toff = 0;
1022 TString time_format(xaxis->GetTimeFormat());
1023 // TimeFormat may contain offset: %F2000-01-01 00:00:00
1024 Int_t idF = time_format.Index("%F");
1025 if (idF>=0) {
1026 Int_t lnF = time_format.Length();
1027 // minimal check for correct format
1028 if (lnF - idF == 21) {
1031 toff = dtoff.Convert();
1032 }
1033 } else {
1035 }
1036 TDatime dt((UInt_t)gPad->AbsPixeltoX(px) + toff);
1037 snprintf(atext, kTMAX, "%s, y=%g",
1038 dt.AsSQLString(),gPad->AbsPixeltoY(py));
1040 return;
1041 }
1042 }
1043 // default
1044 fCanvasImp->SetStatusText(selected->GetObjectInfo(px,py),3);
1045}
1046
1047////////////////////////////////////////////////////////////////////////////////
1048/// Get editor bar.
1049
1054
1055////////////////////////////////////////////////////////////////////////////////
1056/// Embedded a canvas into a TRootEmbeddedCanvas. This method is only called
1057/// via TRootEmbeddedCanvas::AdoptCanvas.
1058
1060{
1061 // If fCanvasImp already exists, no need to go further.
1062 if(fCanvasImp) return;
1063
1064 fCanvasID = winid;
1065 fWindowTopX = 0;
1066 fWindowTopY = 0;
1067 fWindowWidth = ww;
1068 fWindowHeight = wh;
1069 fCw = ww;
1070 fCh = wh;
1071 fBatch = kFALSE;
1072 fUpdating = kFALSE;
1073
1075 if (!fCanvasImp) return;
1076 Build();
1077 Resize();
1078}
1079
1080////////////////////////////////////////////////////////////////////////////////
1081/// Generate kMouseEnter and kMouseLeave events depending on the previously
1082/// selected object and the currently selected object. Does nothing if the
1083/// selected object does not change.
1084
1086{
1087 if (prevSelObj == fSelected) return;
1088
1091
1092 if (prevSelObj) {
1093 gPad = prevSelPad;
1094 prevSelObj->ExecuteEvent(kMouseLeave, fEventX, fEventY);
1096 RunAutoExec();
1098 }
1099
1101
1102 if (fSelected) {
1105 RunAutoExec();
1107 }
1108
1109 fEvent = sevent;
1110}
1111
1112////////////////////////////////////////////////////////////////////////////////
1113/// Execute action corresponding to one event.
1114///
1115/// This member function must be implemented to realize the action
1116/// corresponding to the mouse click on the object in the canvas
1117///
1118/// Only handle mouse motion events in TCanvas, all other events are
1119/// ignored for the time being
1120
1122{
1123 if (gROOT->GetEditorMode()) {
1124 TPad::ExecuteEvent(event,px,py);
1125 return;
1126 }
1127
1128 switch (event) {
1129
1130 case kMouseMotion:
1132 break;
1133 }
1134}
1135
1136////////////////////////////////////////////////////////////////////////////////
1137/// Turn rubberband feedback mode on or off.
1138
1140{
1141 if (IsWeb() || (fCanvasID == -1))
1142 return;
1143
1144 SetDoubleBuffer(set ? 0 : 1); // switch double buffer
1145
1146 if (fPainter)
1148}
1149
1150////////////////////////////////////////////////////////////////////////////////
1151/// Flush canvas buffers.
1152
1154{
1155 if ((fCanvasID == -1) || IsWeb() || IsBatch())
1156 return;
1157
1158 if (!UseGL() || fGLDevice == -1) {
1160 CopyPixmaps();
1162 } else {
1163 if (IsEditable())
1165
1166 TContext ctxt(this, kTRUE);
1167
1169 gVirtualPS = nullptr;
1170 gGLManager->MakeCurrent(fGLDevice);
1172 Paint();
1174 gGLManager->Flush(fGLDevice);
1175 gVirtualPS = tvps;
1176 fHilightPadBorder = nullptr;
1177 }
1178}
1179
1180////////////////////////////////////////////////////////////////////////////////
1181/// Force canvas update
1182
1187
1188////////////////////////////////////////////////////////////////////////////////
1189/// Force a copy of current style for all objects in canvas.
1190
1192{
1193 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
1194 gInterpreter->Execute(this, IsA(), "UseCurrentStyle", "");
1195 return;
1196 }
1197
1199
1201
1202 if (gStyle->IsReading()) {
1206 } else {
1210 }
1211}
1212
1213////////////////////////////////////////////////////////////////////////////////
1214/// Returns current top x position of window on screen.
1215
1223
1224////////////////////////////////////////////////////////////////////////////////
1225/// Returns current top y position of window on screen.
1226
1234
1235////////////////////////////////////////////////////////////////////////////////
1236/// Handle Input Events.
1237///
1238/// Handle input events, like button up/down in current canvas.
1239
1241{
1242 TPad *pad;
1245
1246 fPadSave = (TPad*)gPad;
1247 cd(); // make sure this canvas is the current canvas
1248
1249 fEvent = event;
1250 fEventX = px;
1251 fEventY = py;
1252
1253 switch (event) {
1254
1255 case kMouseMotion:
1256 // highlight object tracked over
1257 pad = Pick(px, py, prevSelObj);
1258 if (!pad) return;
1259
1261
1262 gPad = pad; // don't use cd() we will use the current
1263 // canvas via the GetCanvas member and not via
1264 // gPad->GetCanvas
1265
1266 if (fSelected) {
1267 fSelected->ExecuteEvent(event, px, py);
1268 RunAutoExec();
1269 }
1270
1271 break;
1272
1273 case kMouseEnter:
1274 // mouse enters canvas
1275 //FeedbackMode(kTRUE);
1276 break;
1277
1278 case kMouseLeave:
1279 // mouse leaves canvas
1280 {
1281 // force popdown of tooltips
1284 fSelected = nullptr;
1285 fSelectedPad = nullptr;
1287 fSelected = sobj;
1289 //FeedbackMode(kFALSE);
1290 }
1291 break;
1292
1293 case kButton1Double:
1294 // triggered on the second button down within 350ms and within
1295 // 3x3 pixels of the first button down, button up finishes action
1296
1297 case kButton1Down:
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
1305 if (fSelected) {
1306 FeedbackMode(kTRUE); // to draw in rubberband mode
1307 fSelected->ExecuteEvent(event, px, py);
1308
1309 RunAutoExec();
1310 }
1311
1312 break;
1313
1314 case kArrowKeyPress:
1315 case kArrowKeyRelease:
1316 case kButton1Motion:
1317 case kButton1ShiftMotion: //8 == kButton1Motion + shift modifier
1318 if (fSelected) {
1320
1321 fSelected->ExecuteEvent(event, px, py);
1324 Bool_t resize = kFALSE;
1326 resize = ((TBox*)fSelected)->IsBeingResized();
1328 resize = ((TVirtualPad*)fSelected)->IsBeingResized();
1329
1330 if ((!resize && TestBit(kMoveOpaque)) || (resize && TestBit(kResizeOpaque))) {
1331 gPad = fPadSave;
1332 Update();
1334 }
1335 }
1336
1337 RunAutoExec();
1338 }
1339
1340 break;
1341
1342 case kButton1Up:
1343
1344 if (fSelected) {
1346
1347 fSelected->ExecuteEvent(event, px, py);
1348
1349 RunAutoExec();
1350
1351 if (fPadSave)
1352 gPad = fPadSave;
1353 else {
1354 gPad = this;
1355 fPadSave = this;
1356 }
1357
1358 Update(); // before calling update make sure gPad is reset
1359 }
1360 break;
1361
1362//*-*----------------------------------------------------------------------
1363
1364 case kButton2Down:
1365 // find pad in which input occurred
1366 pad = Pick(px, py, prevSelObj);
1367 if (!pad) return;
1368
1369 gPad = pad; // don't use cd() because we won't draw in pad
1370 // we will only use its coordinate system
1371
1373
1374 if (fSelected) fSelected->Pop(); // pop object to foreground
1375 pad->cd(); // and make its pad the current pad
1376 if (gDebug)
1377 printf("Current Pad: %s / %s\n", pad->GetName(), pad->GetTitle());
1378
1379 // loop over all canvases to make sure that only one pad is highlighted
1380 {
1381 TIter next(gROOT->GetListOfCanvases());
1382 TCanvas *tc;
1383 while ((tc = (TCanvas *)next()))
1384 tc->Update();
1385 }
1386
1387 //if (pad->GetGLDevice() != -1 && fSelected)
1388 // fSelected->ExecuteEvent(event, px, py);
1389
1390 break; // don't want fPadSave->cd() to be executed at the end
1391
1392 case kButton2Motion:
1393 //was empty!
1394 case kButton2Up:
1395 if (fSelected) {
1397
1398 fSelected->ExecuteEvent(event, px, py);
1399 RunAutoExec();
1400 }
1401 break;
1402
1403 case kButton2Double:
1404 break;
1405
1406//*-*----------------------------------------------------------------------
1407
1408 case kButton3Down:
1409 // popup context menu
1410 pad = Pick(px, py, prevSelObj);
1411 if (!pad) return;
1412
1414
1416 !pad->TestBit(kNoContextMenu) && !TestBit(kNoContextMenu))
1417 fContextMenu->Popup(px, py, fSelected, this, pad);
1418
1419 break;
1420
1421 case kButton3Motion:
1422 break;
1423
1424 case kButton3Up:
1426 break;
1427
1428 case kButton3Double:
1429 break;
1430
1431 case kKeyPress:
1432 if (!fSelectedPad || !fSelected) return;
1433 gPad = fSelectedPad; // don't use cd() because we won't draw in pad
1434 // we will only use its coordinate system
1435 fSelected->ExecuteEvent(event, px, py);
1436
1437 RunAutoExec();
1438
1439 break;
1440
1441 case kButton1Shift:
1442 // Try to select
1443 pad = Pick(px, py, prevSelObj);
1444
1445 if (!pad) return;
1446
1448
1449 gPad = pad; // don't use cd() we will use the current
1450 // canvas via the GetCanvas member and not via
1451 // gPad->GetCanvas
1452 if (fSelected) {
1453 fSelected->ExecuteEvent(event, px, py);
1454 RunAutoExec();
1455 }
1456 break;
1457
1458 case kWheelUp:
1459 case kWheelDown:
1460 pad = Pick(px, py, prevSelObj);
1461 if (!pad) return;
1462
1463 gPad = pad;
1464 if (fSelected)
1465 fSelected->ExecuteEvent(event, px, py);
1466 break;
1467
1468 default:
1469 break;
1470 }
1471
1472 if (fPadSave && event != kButton2Down)
1473 fPadSave->cd();
1474
1475 if (event != kMouseLeave) { // signal was already emitted for this event
1476 ProcessedEvent(event, px, py, fSelected); // emit signal
1477 DrawEventStatus(event, px, py, fSelected);
1478 }
1479}
1480
1481////////////////////////////////////////////////////////////////////////////////
1482/// Iconify canvas
1483
1485{
1486 if (fCanvasImp)
1488}
1489
1490////////////////////////////////////////////////////////////////////////////////
1491/// Is folder ?
1492
1494{
1495 return fgIsFolder;
1496}
1497
1498////////////////////////////////////////////////////////////////////////////////
1499/// Is web canvas
1500
1502{
1503 return fCanvasImp ? fCanvasImp->IsWeb() : kFALSE;
1504}
1505
1506////////////////////////////////////////////////////////////////////////////////
1507/// List all pads.
1508
1510{
1512 std::cout <<"Canvas Name=" <<GetName()<<" Title="<<GetTitle()<<" Option="<<option<<std::endl;
1516}
1517
1518////////////////////////////////////////////////////////////////////////////////
1519/// Static function to build a default canvas.
1520
1522{
1523 auto cdef = GetNewCanvasName();
1524
1525 auto c = new TCanvas(cdef.Data(), cdef.Data(), 1);
1526
1527 ::Info("TCanvas::MakeDefCanvas"," created default TCanvas with name %s", cdef.Data());
1528 return c;
1529}
1530
1531////////////////////////////////////////////////////////////////////////////////
1532/// Set option to move objects/pads in a canvas.
1533///
1534/// - set = 1 (default) graphics objects are moved in opaque mode
1535/// - set = 0 only the outline of objects is drawn when moving them
1536///
1537/// The option opaque produces the best effect. It requires however a
1538/// a reasonably fast workstation or response time.
1539
1541{
1542 SetBit(kMoveOpaque,set);
1543}
1544
1545////////////////////////////////////////////////////////////////////////////////
1546/// Paint canvas.
1547
1549{
1550 if (fCanvas)
1552}
1553
1554////////////////////////////////////////////////////////////////////////////////
1555/// Prepare for pick, call TPad::Pick() and when selected object
1556/// is different from previous then emit Picked() signal.
1557
1559{
1560 TObjLink *pickobj = nullptr;
1561
1562 fSelected = nullptr;
1563 fSelectedOpt = "";
1564 fSelectedPad = nullptr;
1565
1566 TPad *pad = Pick(px, py, pickobj);
1567 if (!pad) return nullptr;
1568
1569 if (!pickobj) {
1570 fSelected = pad;
1571 fSelectedOpt = "";
1572 } else {
1573 if (!fSelected) { // can be set via TCanvas::SetSelected()
1574 fSelected = pickobj->GetObject();
1575 fSelectedOpt = pickobj->GetOption();
1576 }
1577 }
1578 fSelectedPad = pad;
1579
1580 if (fSelected != prevSelObj)
1581 Picked(fSelectedPad, fSelected, fEvent); // emit signal
1582
1583 if ((fEvent == kButton1Down) || (fEvent == kButton2Down) || (fEvent == kButton3Down)) {
1587 Selected(fSelectedPad, fSelected, fEvent); // emit signal
1588 fSelectedX = px;
1589 fSelectedY = py;
1590 }
1591 }
1592 return pad;
1593}
1594
1595////////////////////////////////////////////////////////////////////////////////
1596/// Emit Picked() signal.
1597
1599{
1600 Longptr_t args[3];
1601
1602 args[0] = (Longptr_t) pad;
1603 args[1] = (Longptr_t) obj;
1604 args[2] = event;
1605
1606 Emit("Picked(TPad*,TObject*,Int_t)", args);
1607}
1608
1609////////////////////////////////////////////////////////////////////////////////
1610/// Emit Highlighted() signal.
1611///
1612/// - pad is pointer to pad with highlighted histogram or graph
1613/// - obj is pointer to highlighted histogram or graph
1614/// - x is highlighted x bin for 1D histogram or highlighted x-th point for graph
1615/// - y is highlighted y bin for 2D histogram (for 1D histogram or graph not in use)
1616
1618{
1619 Longptr_t args[4];
1620
1621 args[0] = (Longptr_t) pad;
1622 args[1] = (Longptr_t) obj;
1623 args[2] = x;
1624 args[3] = y;
1625
1626 Emit("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", args);
1627}
1628
1629////////////////////////////////////////////////////////////////////////////////
1630/// This is "simplification" for function TCanvas::Connect with Highlighted
1631/// signal for specific slot.
1632///
1633/// Slot has to be defined "UserFunction(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)"
1634/// all parameters of UserFunction are taken from TCanvas::Highlighted
1635
1637{
1638 Connect("Highlighted(TVirtualPad*,TObject*,Int_t,Int_t)", nullptr, nullptr, slot);
1639}
1640
1641////////////////////////////////////////////////////////////////////////////////
1642/// Emit Selected() signal.
1643
1645{
1646 Longptr_t args[3];
1647
1648 args[0] = (Longptr_t) pad;
1649 args[1] = (Longptr_t) obj;
1650 args[2] = event;
1651
1652 Emit("Selected(TVirtualPad*,TObject*,Int_t)", args);
1653}
1654
1655////////////////////////////////////////////////////////////////////////////////
1656/// Emit ProcessedEvent() signal.
1657
1659{
1660 Longptr_t args[4];
1661
1662 args[0] = event;
1663 args[1] = x;
1664 args[2] = y;
1665 args[3] = (Longptr_t) obj;
1666
1667 Emit("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", args);
1668}
1669
1670////////////////////////////////////////////////////////////////////////////////
1671/// Recompute canvas parameters following a X11 Resize.
1672
1674{
1675 if (fCanvasID == -1)
1676 return;
1677
1678 if (!gROOT->IsLineProcessing() && !gVirtualX->IsCmdThread()) {
1679 gInterpreter->Execute(this, IsA(), "Resize", "");
1680 return;
1681 }
1682
1684
1685 TContext ctxt(this, kTRUE);
1686
1687 if (!IsBatch() && !IsWeb()) {
1688 // SL: do we need it here?
1689 fPainter->SelectDrawable(fCanvasID); //select current canvas for painting???
1690
1691 fCanvasImp->ResizeCanvasWindow(fCanvasID); //resize canvas and off-screen buffer
1692
1693 // Get effective window parameters including menubar and borders
1696
1697 // Get effective canvas parameters without borders
1699 }
1700
1701 if (fXsizeUser && fYsizeUser) {
1702 UInt_t nwh = fCh;
1703 UInt_t nww = fCw;
1705 if (rxy < 1) {
1707 if (twh > fCh)
1709 else
1710 nwh = twh;
1711 if (nww > fCw) {
1712 nww = fCw; nwh = twh;
1713 }
1714 if (nwh > fCh) {
1715 nwh = fCh; nww = UInt_t(Double_t(fCh)/rxy);
1716 }
1717 } else {
1719 if (twh > fCh)
1721 else
1722 nww = twh;
1723 if (nww > fCw) {
1724 nww = fCw; nwh = twh;
1725 }
1726 if (nwh > fCh) {
1727 nwh = fCh; nww = UInt_t(Double_t(fCh)*rxy);
1728 }
1729 }
1730 fCw = nww;
1731 fCh = nwh;
1732 }
1733
1734 if (fCw < fCh) {
1737 }
1738 else {
1741 }
1742
1743 //*-*- Loop on all pads to recompute conversion coefficients
1745}
1746
1747
1748////////////////////////////////////////////////////////////////////////////////
1749/// Raise canvas window
1750
1752{
1753 if (fCanvasImp)
1755}
1756
1757////////////////////////////////////////////////////////////////////////////////
1758/// Set option to resize objects/pads in a canvas.
1759///
1760/// - set = 1 (default) graphics objects are resized in opaque mode
1761/// - set = 0 only the outline of objects is drawn when resizing them
1762///
1763/// The option opaque produces the best effect. It requires however a
1764/// a reasonably fast workstation or response time.
1765
1767{
1768 SetBit(kResizeOpaque,set);
1769}
1770
1771////////////////////////////////////////////////////////////////////////////////
1772/// Execute the list of TExecs in the current pad.
1773
1775{
1776 if (!TestBit(kAutoExec))
1777 return;
1778 if (gPad)
1779 ((TPad*)gPad)->AutoExec();
1780}
1781
1782////////////////////////////////////////////////////////////////////////////////
1783/// Save primitives in this canvas in C++ macro file with GUI.
1784
1785void TCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1786{
1787 // Write canvas options (in $TROOT or $TStyle)
1788 out << " gStyle->SetOptFit(" << gStyle->GetOptFit() << ");\n";
1789 out << " gStyle->SetOptStat(" << gStyle->GetOptStat() << ");\n";
1790 out << " gStyle->SetOptTitle(" << gStyle->GetOptTitle() << ");\n";
1791
1792 if (gROOT->GetEditHistograms())
1793 out << " gROOT->SetEditHistograms();\n";
1794
1795 if (GetShowEventStatus())
1796 out << " " << GetName() << "->ToggleEventStatus();\n";
1797
1798 if (GetShowToolTips())
1799 out << " " << GetName() << "->ToggleToolTips();\n";
1800
1801 if (GetShowToolBar())
1802 out << " " << GetName() << "->ToggleToolBar();\n";
1803 if (GetHighLightColor() != 5)
1804 out << " " << GetName() << "->SetHighLightColor(" << TColor::SavePrimitiveColor(GetHighLightColor()) << ");\n";
1805
1806 // Now recursively scan all pads of this canvas
1807 cd();
1809}
1810
1811////////////////////////////////////////////////////////////////////////////////
1812/// Save primitives in this canvas as a C++ macro file.
1813/// This function loops on all the canvas primitives and for each primitive
1814/// calls the object SavePrimitive function.
1815/// When outputting floating point numbers, the default precision is 7 digits.
1816/// The precision can be changed (via system.rootrc) by changing the value
1817/// of the environment variable "Canvas.SavePrecision"
1818
1819void TCanvas::SaveSource(const char *filename, Option_t * /*option*/)
1820{
1821 // Reset the ClassSaved status of all classes
1822 gROOT->ResetClassSaved();
1823
1826
1828 if (cname.IsNull()) {
1829 invalid = kTRUE;
1830 cname = "c1";
1831 }
1832
1833 // if filename is given, open this file, otherwise create a file
1834 // with a name equal to the canvasname.C
1835 TString fname;
1836 if (filename && *filename) {
1837 fname = filename;
1838 } else {
1839 fname = cname + ".C";
1840 }
1841
1842 std::ofstream out;
1843 out.open(fname.Data(), std::ios::out);
1844 if (!out.good()) {
1845 Error("SaveSource", "Cannot open file: %s", fname.Data());
1846 return;
1847 }
1848
1849 //set precision
1850 Int_t precision = gEnv->GetValue("Canvas.SavePrecision",7);
1851 out.precision(precision);
1852
1853 // Write macro header and date/time stamp
1854 TDatime t;
1856 Int_t topx,topy;
1857 UInt_t w, h;
1858 if (!fCanvasImp) {
1859 Error("SaveSource", "Cannot open TCanvas");
1860 return;
1861 }
1864 h = UInt_t((fWindowHeight)/cx);
1865 topx = GetWindowTopX();
1866 topy = GetWindowTopY();
1867
1868 if (w == 0) {
1869 w = GetWw()+4; h = GetWh()+4;
1870 topx = 1; topy = 1;
1871 }
1872
1874 out << R"CODE(#ifdef __CLING__
1875#pragma cling optimize(0)
1876#endif
1877)CODE";
1878 Int_t p = mname.Last('.');
1879 Int_t s = mname.Last('/')+1;
1880
1881 // A named macro is generated only if the function name is valid. If not, the
1882 // macro is unnamed.
1883 TString first(mname(s,s+1));
1884 if (!first.IsDigit()) out <<"void " << mname(s,p-s) << "()" << std::endl;
1885
1886 out <<"{"<<std::endl;
1887 out <<"//=========Macro generated from canvas: "<<GetName()<<"/"<<GetTitle()<<std::endl;
1888 out <<"//========= ("<<t.AsString()<<") by ROOT version "<<gROOT->GetVersion()<<std::endl;
1889
1891 out <<std::endl<<" gStyle->SetCanvasPreferGL(kTRUE);"<<std::endl<<std::endl;
1892
1893 // Write canvas parameters (TDialogCanvas case)
1895 out << " " << ClassName() << " *" << cname << " = new " << ClassName() << "(\"" << GetName() << "\", \""
1896 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << w << ", " << h << ");\n";
1897 } else {
1898 // Write canvas parameters (TCanvas case)
1899 out << " TCanvas *" << cname << " = new TCanvas(\"" << GetName() << "\", \""
1900 << TString(GetTitle()).ReplaceSpecialCppChars() << "\", " << (HasMenuBar() ? topx : -topx) << ", " << topy
1901 << ", " << w << ", " << h << ");\n";
1902 }
1903 // Write canvas options (in $TROOT or $TStyle)
1904 out << " gStyle->SetOptFit(" << gStyle->GetOptFit() << ");\n";
1905 out << " gStyle->SetOptStat(" << gStyle->GetOptStat() << ");\n";
1906 out << " gStyle->SetOptTitle(" << gStyle->GetOptTitle() << ");\n";
1907 if (gROOT->GetEditHistograms())
1908 out << " gROOT->SetEditHistograms();\n";
1909 if (GetShowEventStatus())
1910 out << " " << GetName() << "->ToggleEventStatus();\n";
1911 if (GetShowToolTips())
1912 out << " " << GetName() << "->ToggleToolTips();\n";
1913 if (GetHighLightColor() != 5)
1914 out << " " << GetName() << "->SetHighLightColor(" << TColor::SavePrimitiveColor(GetHighLightColor()) << ");\n";
1915
1917
1918 // Now recursively scan all pads of this canvas
1919 cd();
1920 if (invalid) fName = cname;
1921 TPad::SavePrimitive(out,"toplevel");
1922
1923 // Write canvas options related to pad editor
1924 out << " " << GetName() << "->SetSelected(" << GetName() << ");\n";
1925 if (GetShowToolBar())
1926 out << " " << GetName() << "->ToggleToolBar();\n";
1927 if (invalid)
1928 fName = cname0;
1929
1930 out <<"}\n";
1931 out.close();
1932 Info("SaveSource","C++ Macro file: %s has been generated", fname.Data());
1933
1934 // Reset the ClassSaved status of all classes
1935 gROOT->ResetClassSaved();
1936}
1937
1938////////////////////////////////////////////////////////////////////////////////
1939/// Toggle batch mode. However, if the canvas is created without a window
1940/// then batch mode always stays set.
1941
1943{
1944 if (gROOT->IsBatch() || IsWeb())
1945 fBatch = kTRUE;
1946 else
1947 fBatch = batch;
1948}
1949
1950////////////////////////////////////////////////////////////////////////////////
1951/// Set Width and Height of canvas to ww and wh respectively. If ww and/or wh
1952/// are greater than the current canvas window a scroll bar is automatically
1953/// generated. Use this function to zoom in a canvas and navigate via
1954/// the scroll bars. The Width and Height in this method are different from those
1955/// given in the TCanvas constructors where these two dimensions include the size
1956/// of the ROOT canvas menubar decoration whereas they do not in this method.
1957/// When both ww==0 and wh==0, auto resize mode will be enabled again and
1958/// canvas drawing area will automatically fit available window size
1959
1961{
1962 if (fCanvasImp) {
1963 fCw = ww;
1964 fCh = wh;
1966 TContext ctxt(this, kTRUE);
1967 ResizePad();
1968 }
1969}
1970
1971////////////////////////////////////////////////////////////////////////////////
1972/// Set cursor.
1973
1975{
1976 if (!IsBatch() && !IsWeb() && fCanvasID != -1)
1978}
1979
1980////////////////////////////////////////////////////////////////////////////////
1981/// Set Double Buffer On/Off.
1982
1984{
1985 if (IsBatch() || IsWeb())
1986 return;
1988 if (fCanvasID != -1)
1990
1991 // depending of the buffer mode set the drawing window to either
1992 // the canvas pixmap or to the canvas on-screen window
1993 if (fDoubleBuffer) {
1995 } else
1997}
1998
1999////////////////////////////////////////////////////////////////////////////////
2000/// Fix canvas aspect ratio to current value if fixed is true.
2001
2003{
2004 if (fixed) {
2005 if (!fFixedAspectRatio) {
2006 if (fCh != 0)
2008 else {
2009 Error("SetAspectRatio", "cannot fix aspect ratio, height of canvas is 0");
2010 return;
2011 }
2013 }
2014 } else {
2016 fAspectRatio = 0;
2017 }
2018}
2019
2020////////////////////////////////////////////////////////////////////////////////
2021/// If isfolder=kTRUE, the canvas can be browsed like a folder
2022/// by default a canvas is not browsable.
2023
2025{
2027}
2028
2029////////////////////////////////////////////////////////////////////////////////
2030/// Set canvas name. In case `name` is an empty string, a default name is set.
2031/// Canvas automatically marked as modified when SetName method called
2032
2033void TCanvas::SetName(const char *name)
2034{
2036
2037 Modified();
2038}
2039
2040
2041////////////////////////////////////////////////////////////////////////////////
2042/// Function to resize a canvas so that the plot inside is shown in real aspect
2043/// ratio
2044///
2045/// \param[in] axis 1 for resizing horizontally (x-axis) in order to get real
2046/// aspect ratio, 2 for the resizing vertically (y-axis)
2047/// \return false if error is encountered, true otherwise
2048///
2049/// ~~~ {.cpp}
2050/// hpxpy->Draw();
2051/// c1->SetRealAspectRatio();
2052/// ~~~
2053///
2054/// - For defining the concept of real aspect ratio, it is assumed that x and y
2055/// axes are in same units, e.g. both in MeV or both in ns.
2056/// - You can resize either the width of the canvas or the height, but not both
2057/// at the same time
2058/// - Call this function AFTER drawing AND zooming (SetUserRange) your TGraph or
2059/// Histogram, otherwise it cannot infer your actual axes lengths
2060/// - This function ensures that the TFrame has a real aspect ratio, this does not
2061/// mean that the full pad (i.e. the canvas or png output) including margins has
2062/// exactly the same ratio
2063/// - This function does not work if the canvas is divided in several subpads
2064
2065bool TCanvas::SetRealAspectRatio(const Int_t axis)
2066{
2067 Update();
2068
2069 //Get how many pixels are occupied by the canvas
2070 Int_t npx = GetWw();
2071 Int_t npy = GetWh();
2072
2073 //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes, NOT at the edges of the histogram)
2074 Double_t x1 = GetX1();
2075 Double_t y1 = GetY1();
2076 Double_t x2 = GetX2();
2077 Double_t y2 = GetY2();
2078
2079 //Get the length of extrapolated x and y axes
2080 Double_t xlength2 = x2 - x1;
2081 Double_t ylength2 = y2 - y1;
2083
2084 //Now get the number of pixels including the canvas borders
2087
2088 if (axis==1) {
2091 } else if (axis==2) {
2094 } else {
2095 Error("SetRealAspectRatio", "axis value %d is neither 1 (resize along x-axis) nor 2 (resize along y-axis).",axis);
2096 return false;
2097 }
2098
2099 //Check now that resizing has worked
2100
2101 Update();
2102
2103 //Get how many pixels are occupied by the canvas
2104 npx = GetWw();
2105 npy = GetWh();
2106
2107 //Get x-y coordinates at the edges of the canvas (extrapolating outside the axes,
2108 //NOT at the edges of the histogram)
2109 x1 = GetX1();
2110 y1 = GetY1();
2111 x2 = GetX2();
2112 y2 = GetY2();
2113
2114 //Get the length of extrapolated x and y axes
2115 xlength2 = x2 - x1;
2116 ylength2 = y2 - y1;
2118
2119 //Check accuracy +/-1 pixel due to rounding
2120 if (abs(TMath::Nint(npy*ratio2) - npx)<2) {
2121 return true;
2122 } else {
2123 Error("SetRealAspectRatio", "Resizing failed.");
2124 return false;
2125 }
2126}
2127
2128
2129////////////////////////////////////////////////////////////////////////////////
2130/// Set selected canvas.
2131
2133{
2134 fSelected = obj;
2135 if (obj) obj->SetBit(kMustCleanup);
2136}
2137
2138////////////////////////////////////////////////////////////////////////////////
2139/// Set canvas title.
2140
2141void TCanvas::SetTitle(const char *title)
2142{
2143 fTitle = title;
2145}
2146
2147////////////////////////////////////////////////////////////////////////////////
2148/// Set canvas window position
2149
2151{
2152 if (fCanvasImp)
2154}
2155
2156////////////////////////////////////////////////////////////////////////////////
2157/// Set canvas window size
2158
2160{
2161 if (fBatch && !IsWeb())
2162 SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2);
2163 else if (fCanvasImp)
2165}
2166
2167////////////////////////////////////////////////////////////////////////////////
2168/// Set canvas implementation
2169/// If web-based implementation provided, some internal fields also initialized
2170
2172{
2173 Bool_t was_web = IsWeb();
2174
2175 fCanvasImp = imp;
2176
2177 if (!was_web && IsWeb()) {
2179 fPixmapID = 0;
2180 fMother = this;
2181 if (!fCw) fCw = 800;
2182 if (!fCh) fCh = 600;
2183 } else if (was_web && !imp) {
2184 fCanvasID = -1;
2185 fPixmapID = -1;
2186 fMother = nullptr;
2187 fCw = fCh = 0;
2188 }
2189}
2190
2191////////////////////////////////////////////////////////////////////////////////
2192/// Set the canvas scale in centimeters.
2193///
2194/// This information is used by PostScript to set the page size.
2195///
2196/// \param[in] xsize size of the canvas in centimeters along X
2197/// \param[in] ysize size of the canvas in centimeters along Y
2198///
2199/// if xsize and ysize are not equal to 0, then the scale factors will
2200/// be computed to keep the ratio ysize/xsize independently of the canvas
2201/// size (parts of the physical canvas will be unused).
2202///
2203/// if xsize = 0 and ysize is not zero, then xsize will be computed
2204/// to fit to the current canvas scale. If the canvas is resized,
2205/// a new value for xsize will be recomputed. In this case the aspect
2206/// ratio is not preserved.
2207///
2208/// if both xsize = 0 and ysize = 0, then the scaling is automatic.
2209/// the largest dimension will be allocated a size of 20 centimeters.
2210
2212{
2213 fXsizeUser = xsize;
2214 fYsizeUser = ysize;
2215
2216 Resize();
2217}
2218
2219////////////////////////////////////////////////////////////////////////////////
2220/// Show canvas
2221
2222void TCanvas::Show()
2223{
2224 if (fCanvasImp)
2225 fCanvasImp->Show();
2226}
2227
2228////////////////////////////////////////////////////////////////////////////////
2229/// Stream a class object.
2230
2232{
2233 UInt_t R__s, R__c;
2234 if (b.IsReading()) {
2235 Version_t v = b.ReadVersion(&R__s, &R__c);
2236 gPad = this;
2237 fCanvas = this;
2238 if (v>7) b.ClassBegin(TCanvas::IsA());
2239 if (v>7) b.ClassMember("TPad");
2241 gPad = this;
2242 //restore the colors
2243 auto colors = dynamic_cast<TObjArray *>(fPrimitives->FindObject("ListOfColors"));
2244 if (colors) {
2245 auto root_colors = dynamic_cast<TObjArray *>(gROOT->GetListOfColors());
2246
2247 TIter next(colors);
2248 while (auto colold = static_cast<TColor *>(next())) {
2249 Int_t cn = colold->GetNumber();
2250 TColor *colcur = gROOT->GetColor(cn);
2251 if (colcur && (colcur->IsA() == TColor::Class()) && (colold->IsA() == TColor::Class())) {
2252 colcur->SetName(colold->GetName());
2253 colcur->SetRGB(colold->GetRed(), colold->GetGreen(), colold->GetBlue());
2254 colcur->SetAlpha(colold->GetAlpha());
2255 } else {
2256 if (colcur) {
2257 if (root_colors) root_colors->Remove(colcur);
2258 delete colcur;
2259 }
2260 colors->Remove(colold);
2261 if (root_colors) {
2262 if (colcur) {
2263 root_colors->AddAtAndExpand(colold, cn);
2264 }
2265 else {
2266 // Copy to current session
2267 // do not use copy constructor which does not update highest color index
2268 [[maybe_unused]] TColor* const colnew = new TColor(cn, colold->GetRed(), colold->GetGreen(), colold->GetBlue(), colold->GetName(), colold->GetAlpha());
2269 delete colold;
2270 // No need to delete colnew, as the constructor adds it to global list of colors
2271 assert(root_colors->At(cn) == colnew);
2272 }
2273 }
2274 }
2275 }
2276 //restore the palette if needed
2277 auto palette = dynamic_cast<TObjArray *>(fPrimitives->FindObject("CurrentColorPalette"));
2278 if (palette) {
2280 Int_t number = palette->GetEntries();
2281 TArrayI palcolors(number);
2282 Int_t i = 0;
2283 while (auto col = static_cast<TColor *>(nextcol()))
2284 palcolors[i++] = col->GetNumber();
2285 gStyle->SetPalette(number, palcolors.GetArray());
2287 delete palette;
2288 }
2290 colors->Delete();
2291 delete colors;
2292 }
2293
2294 if (v>7) b.ClassMember("fDISPLAY","TString");
2296 if (v>7) b.ClassMember("fDoubleBuffer", "Int_t");
2297 b >> fDoubleBuffer;
2298 if (v>7) b.ClassMember("fRetained", "Bool_t");
2299 b >> fRetained;
2300 if (v>7) b.ClassMember("fXsizeUser", "Size_t");
2301 b >> fXsizeUser;
2302 if (v>7) b.ClassMember("fYsizeUser", "Size_t");
2303 b >> fYsizeUser;
2304 if (v>7) b.ClassMember("fXsizeReal", "Size_t");
2305 b >> fXsizeReal;
2306 if (v>7) b.ClassMember("fYsizeReal", "Size_t");
2307 b >> fYsizeReal;
2308 fCanvasID = -1;
2309 if (v>7) b.ClassMember("fWindowTopX", "Int_t");
2310 b >> fWindowTopX;
2311 if (v>7) b.ClassMember("fWindowTopY", "Int_t");
2312 b >> fWindowTopY;
2313 if (v > 2) {
2314 if (v>7) b.ClassMember("fWindowWidth", "UInt_t");
2315 b >> fWindowWidth;
2316 if (v>7) b.ClassMember("fWindowHeight", "UInt_t");
2317 b >> fWindowHeight;
2318 }
2319 if (v>7) b.ClassMember("fCw", "UInt_t");
2320 b >> fCw;
2321 if (v>7) b.ClassMember("fCh", "UInt_t");
2322 b >> fCh;
2323 if (v <= 2) {
2324 fWindowWidth = fCw;
2326 }
2327 if (v>7) b.ClassMember("fCatt", "TAttCanvas");
2328 fCatt.Streamer(b);
2329 Bool_t dummy;
2330 if (v>7) b.ClassMember("kMoveOpaque", "Bool_t");
2331 b >> dummy; if (dummy) MoveOpaque(1);
2332 if (v>7) b.ClassMember("kResizeOpaque", "Bool_t");
2333 b >> dummy; if (dummy) ResizeOpaque(1);
2334 if (v>7) b.ClassMember("fHighLightColor", "Color_t");
2335 b >> fHighLightColor;
2336 if (v>7) b.ClassMember("fBatch", "Bool_t");
2337 b >> dummy; //was fBatch
2338 if (v < 2) return;
2339 if (v>7) b.ClassMember("kShowEventStatus", "Bool_t");
2340 b >> dummy; if (dummy) SetBit(kShowEventStatus);
2341
2342 if (v > 3) {
2343 if (v>7) b.ClassMember("kAutoExec", "Bool_t");
2344 b >> dummy; if (dummy) SetBit(kAutoExec);
2345 }
2346 if (v>7) b.ClassMember("kMenuBar", "Bool_t");
2347 b >> dummy; if (dummy) SetBit(kMenuBar);
2348 fBatch = gROOT->IsBatch();
2349 if (v>7) b.ClassEnd(TCanvas::IsA());
2350 b.CheckByteCount(R__s, R__c, TCanvas::IsA());
2351 } else {
2352 //save list of colors
2353 //we must protect the case when two or more canvases are saved
2354 //in the same buffer. If the list of colors has already been saved
2355 //in the buffer, do not add the list of colors to the list of primitives.
2356 TObjArray *colors = nullptr;
2357 TObjArray *CurrentColorPalette = nullptr;
2358 // fPrimitives can be temporarily null while streaming a web-canvas
2359 // snapshot (see TWebCanvas::CreatePadSnapshot). In that case colors and
2360 // palette are delivered separately, so the list of colors must not be
2361 // added here. The guard also avoids a null dereference that crashes when
2362 // colors storage has been forced on via TColor::DefinedColors(1)
2363 // (see https://github.com/root-project/root/issues/20018).
2365 if (!b.CheckObject(gROOT->GetListOfColors(),TObjArray::Class())) {
2366 colors = (TObjArray*)gROOT->GetListOfColors();
2368 }
2369 //save the current palette
2371 Int_t palsize = pal.GetSize();
2373 CurrentColorPalette->SetName("CurrentColorPalette");
2374 for (Int_t i=0; i<palsize; i++) CurrentColorPalette->Add(gROOT->GetColor(pal[i]));
2376 }
2377
2378 R__c = b.WriteVersion(TCanvas::IsA(), kTRUE);
2379 b.ClassBegin(TCanvas::IsA());
2380 b.ClassMember("TPad");
2384 b.ClassMember("fDISPLAY","TString");
2386 b.ClassMember("fDoubleBuffer", "Int_t");
2387 b << fDoubleBuffer;
2388 b.ClassMember("fRetained", "Bool_t");
2389 b << fRetained;
2390 b.ClassMember("fXsizeUser", "Size_t");
2391 b << fXsizeUser;
2392 b.ClassMember("fYsizeUser", "Size_t");
2393 b << fYsizeUser;
2394 b.ClassMember("fXsizeReal", "Size_t");
2395 b << fXsizeReal;
2396 b.ClassMember("fYsizeReal", "Size_t");
2397 b << fYsizeReal;
2400 UInt_t editorWidth = 0;
2402 b.ClassMember("fWindowTopX", "Int_t");
2403 b << topx;
2404 b.ClassMember("fWindowTopY", "Int_t");
2405 b << topy;
2406 b.ClassMember("fWindowWidth", "UInt_t");
2407 b << (UInt_t)(w-editorWidth);
2408 b.ClassMember("fWindowHeight", "UInt_t");
2409 b << h;
2410 b.ClassMember("fCw", "UInt_t");
2411 b << fCw;
2412 b.ClassMember("fCh", "UInt_t");
2413 b << fCh;
2414 b.ClassMember("fCatt", "TAttCanvas");
2415 fCatt.Streamer(b);
2416 b.ClassMember("kMoveOpaque", "Bool_t");
2417 b << TestBit(kMoveOpaque); //please remove in ROOT version 6
2418 b.ClassMember("kResizeOpaque", "Bool_t");
2419 b << TestBit(kResizeOpaque); //please remove in ROOT version 6
2420 b.ClassMember("fHighLightColor", "Color_t");
2421 b << fHighLightColor;
2422 b.ClassMember("fBatch", "Bool_t");
2423 b << fBatch; //please remove in ROOT version 6
2424 b.ClassMember("kShowEventStatus", "Bool_t");
2425 b << TestBit(kShowEventStatus); //please remove in ROOT version 6
2426 b.ClassMember("kAutoExec", "Bool_t");
2427 b << TestBit(kAutoExec); //please remove in ROOT version 6
2428 b.ClassMember("kMenuBar", "Bool_t");
2429 b << TestBit(kMenuBar); //please remove in ROOT version 6
2430 b.ClassEnd(TCanvas::IsA());
2431 b.SetByteCount(R__c, kTRUE);
2432 }
2433}
2434
2435////////////////////////////////////////////////////////////////////////////////
2436/// Toggle pad auto execution of list of TExecs.
2437
2439{
2442}
2443
2444////////////////////////////////////////////////////////////////////////////////
2445/// Toggle event statusbar.
2446
2448{
2451
2453}
2454
2455////////////////////////////////////////////////////////////////////////////////
2456/// Toggle toolbar.
2457
2459{
2462
2464}
2465
2466////////////////////////////////////////////////////////////////////////////////
2467/// Toggle editor.
2468
2470{
2473
2475}
2476
2477////////////////////////////////////////////////////////////////////////////////
2478/// Toggle tooltip display.
2479
2481{
2484
2486}
2487
2488
2489////////////////////////////////////////////////////////////////////////////////
2490/// Static function returning "true" if transparency is supported.
2491
2493{
2494 if (gPad)
2495 if (auto pp = gPad->GetPainter())
2496 return pp->IsSupportAlpha();
2497 return kFALSE;
2498}
2499
2500extern "C" void ROOT_TCanvas_Update(void* TheCanvas) {
2501 static_cast<TCanvas*>(TheCanvas)->Update();
2502}
2503
2504////////////////////////////////////////////////////////////////////////////////
2505/// Update canvas pad buffers.
2506
2507void TCanvas::Update()
2508{
2509 fUpdated = kTRUE;
2510
2511 if (fUpdating) return;
2512
2513 if (fPixmapID == -1) return;
2514
2515 static const union CastFromFuncToVoidPtr_t {
2517 void (*fFuncPtr)(void*);
2518 void* fVoidPtr;
2520
2521 if (gThreadXAR) {
2522 void *arr[3];
2523 arr[1] = this;
2524 arr[2] = castFromFuncToVoidPtr.fVoidPtr;
2525 if ((*gThreadXAR)("CUPD", 3, arr, nullptr)) return;
2526 }
2527
2528 if (!fCanvasImp) return;
2529
2530 if (!gVirtualX->IsCmdThread()) {
2531 // Why do we have this (which uses the interpreter to funnel the Update()
2532 // through the main thread) when the gThreadXAR mechanism does seemingly
2533 // the same?
2534 gInterpreter->Execute(this, IsA(), "Update", "");
2535 return;
2536 }
2537
2539
2540 fUpdating = kTRUE;
2541
2543
2544 if (!IsBatch()) FeedbackMode(kFALSE); // Goto double buffer mode
2545
2546 if (!UseGL() || fGLDevice == -1) PaintModified(); // Repaint all modified pad's
2547
2548 Flush(); // Copy all pad pixmaps to the screen
2549
2551 }
2552
2553 fUpdating = kFALSE;
2554}
2555
2556////////////////////////////////////////////////////////////////////////////////
2557/// Asynchronous pad update.
2558/// In case of web-based canvas triggers update of the canvas on the client side,
2559/// but does not wait that real update is completed. Avoids blocking of caller thread.
2560/// Have to be used if called from other web-based widget to avoid logical dead-locks.
2561/// In case of normal canvas just canvas->Update() is performed.
2562
2564{
2565 fUpdated = kTRUE;
2566
2567 if (IsWeb())
2569 else
2570 Update();
2571}
2572
2573////////////////////////////////////////////////////////////////////////////////
2574/// Used by friend class TCanvasImp.
2575
2577{
2578 fCanvasID = 0;
2579 fContextMenu = nullptr;
2580}
2581
2582////////////////////////////////////////////////////////////////////////////////
2583/// Check whether this canvas is to be drawn in grayscale mode.
2584
2586{
2587 return TestBit(kIsGrayscale);
2588}
2589
2590////////////////////////////////////////////////////////////////////////////////
2591/// Set whether this canvas should be painted in grayscale, and re-paint
2592/// it if necessary.
2593
2594void TCanvas::SetGrayscale(Bool_t set /*= kTRUE*/)
2595{
2596 if (IsGrayscale() == set) return;
2597 SetBit(kIsGrayscale, set);
2598 if (IsWeb()) {
2599 Modified();
2600 UpdateAsync();
2601 } else {
2602 Paint(); // update canvas and all sub-pads, unconditionally!
2603 }
2604}
2605
2606////////////////////////////////////////////////////////////////////////////////
2607/// Probably, TPadPainter must be placed in a separate ROOT module -
2608/// "padpainter" (the same as "histpainter"). But now, it's directly in a
2609/// gpad dir, so, in case of default painter, no *.so should be loaded,
2610/// no need in plugin managers.
2611/// May change in future.
2612
2614{
2615 //Even for batch mode painter is still required, just to delegate
2616 //some calls to batch "virtual X".
2617 if (!UseGL() || fBatch || IsWeb()) {
2618 fPainter = nullptr;
2620 if (!fPainter) fPainter = new TPadPainter; // Do not need plugin manager for this!
2621 } else {
2623 if (!fPainter) {
2624 Error("CreatePainter", "GL Painter creation failed! Will use default!");
2625 fPainter = new TPadPainter;
2626 fUseGL = kFALSE;
2627 }
2628 }
2629}
2630
2631////////////////////////////////////////////////////////////////////////////////
2632/// Access and (probably) creation of pad painter.
2633
2635{
2636 if (!fPainter) CreatePainter();
2637 return fPainter;
2638}
2639
2640////////////////////////////////////////////////////////////////////////////////
2641/// Replace canvas painter
2642/// For internal use only - when creating PS images
2643
2645{
2646 if (!create) {
2647 delete fPainter;
2648 fPainter = oldp;
2649 return kFALSE;
2650 }
2651
2652 if (!gVirtualPS /* || !IsBatch() */)
2653 return kFALSE;
2654
2655
2657 return kFALSE;
2658
2659 oldp = fPainter;
2661 return kTRUE;
2662}
2663
2664////////////////////////////////////////////////////////////////////////////////
2665///assert on IsBatch() == false?
2666
2668{
2669 if (fGLDevice != -1) {
2670 //fPainter has a font manager.
2671 //Font manager will delete textures.
2672 //If context is wrong (we can have several canvases) -
2673 //wrong texture will be deleted, damaging some of our fonts.
2674 gGLManager->MakeCurrent(fGLDevice);
2675 }
2676
2678
2679 if (fGLDevice != -1) {
2680 gGLManager->DeleteGLContext(fGLDevice);//?
2681 fGLDevice = -1;
2682 }
2683}
2684
2685
2686////////////////////////////////////////////////////////////////////////////////
2687/// Save provided pads/canvases into the image file(s)
2688/// Filename can include printf argument for image number - like "image%03d.png".
2689/// In this case images: "image000.png", "image001.png", "image002.png" will be created.
2690/// If pattern is not provided - it will be automatically inserted before extension except PDF and ROOT files.
2691/// In last case PDF or ROOT file will contain all pads.
2692/// Parameter option only used when output into PDF/PS files
2693/// If TCanvas::SaveAll() called without arguments - all existing canvases will be stored in allcanvases.pdf file.
2694
2695Bool_t TCanvas::SaveAll(const std::vector<TPad *> &pads, const char *filename, Option_t *option)
2696{
2697 if (pads.empty()) {
2698 std::vector<TPad *> canvases;
2699 TIter iter(gROOT->GetListOfCanvases());
2700 while (auto c = dynamic_cast<TCanvas *>(iter()))
2701 canvases.emplace_back(c);
2702
2703 if (canvases.empty()) {
2704 ::Warning("TCanvas::SaveAll", "No pads are provided");
2705 return kFALSE;
2706 }
2707
2708 return TCanvas::SaveAll(canvases, filename && *filename ? filename : "allcanvases.pdf", option);
2709 }
2710
2712
2713 Bool_t hasArg = fname.Contains("%");
2714
2715 if ((pads.size() == 1) && !hasArg) {
2716 pads[0]->SaveAs(filename);
2717 return kTRUE;
2718 }
2719
2720 auto p = fname.Last('.');
2721 if (p != kNPOS) {
2722 ext = fname(p+1, fname.Length() - p - 1);
2723 ext.ToLower();
2724 } else {
2725 p = fname.Length();
2726 ::Warning("TCanvas::SaveAll", "Extension is not provided in file name %s, append .png", filename);
2727 fname.Append(".png");
2728 ext = "png";
2729 }
2730
2731 if (ext != "pdf" && ext != "ps" && ext != "root" && ext != "html" && ext != "xml" && !hasArg) {
2732 fname.Insert(p, "%d");
2733 hasArg = kTRUE;
2734 }
2735
2736 static std::vector<TString> webExtensions = { "png", "json", "html", "svg", "pdf", "jpg", "jpeg", "webp" };
2737
2738 if (gROOT->IsWebDisplay() || (ext == "html")) {
2740 for (auto &wext : webExtensions) {
2741 if ((isSupported = (wext == ext)))
2742 break;
2743 }
2744
2745 if (isSupported) {
2746 auto cmd = TString::Format("TWebCanvas::ProduceImages( *((std::vector<TPad *> *) 0x%zx), \"%s\");", (size_t) &pads, fname.Data());
2747
2748 return (Bool_t) gROOT->ProcessLine(cmd);
2749 }
2750
2751 if ((ext != "root") && (ext != "xml"))
2752 ::Warning("TCanvas::SaveAll", "TWebCanvas does not support image format %s - using normal ROOT functionality", fname.Data());
2753 }
2754
2755 // store all pads into single PDF/PS files
2756 if (ext == "pdf" || ext == "ps") {
2757 for (unsigned n = 0; n < pads.size(); ++n) {
2758 TString fn = fname;
2759 if (hasArg)
2760 fn = TString::Format(fname.Data(), (int) n);
2761 else if (n == 0)
2762 fn.Append("(");
2763 else if (n == pads.size() - 1)
2764 fn.Append(")");
2765
2766 pads[n]->Print(fn.Data(), option && *option ? option : ext.Data());
2767 }
2768
2769 return kTRUE;
2770 }
2771
2772 // store all pads in single ROOT file
2773 if ((ext == "root" || ext == "xml") && !hasArg) {
2774 TString fn = fname;
2776 if (fn.IsNull()) {
2777 fn.Form("%s.%s", pads[0]->GetName(), ext.Data());
2778 ::Warning("TCanvas::SaveAll", "Filename %s cannot be used - use pad name %s as pattern", fname.Data(), fn.Data());
2779 }
2780
2782
2783 if (!gDirectory) {
2784 isError = kTRUE;
2785 } else {
2786 for (unsigned n = 0; n < pads.size(); ++n) {
2787 auto sz = gDirectory->SaveObjectAs(pads[n], fn.Data(), n==0 ? "q" : "qa");
2788 if (!sz) { isError = kTRUE; break; }
2789 }
2790 }
2791
2792 if (isError)
2793 ::Error("TCanvas::SaveAll", "Failure to store pads in %s", filename);
2794 else
2795 ::Info("TCanvas::SaveAll", "ROOT file %s has been created", filename);
2796
2797 return !isError;
2798 }
2799
2800 for (unsigned n = 0; n < pads.size(); ++n) {
2801 TString fn = TString::Format(fname.Data(), (int) n);
2803 if (fn.IsNull()) {
2804 fn.Form("%s%d.%s", pads[n]->GetName(), (int) n, ext.Data());
2805 ::Warning("TCanvas::SaveAll", "Filename %s cannot be used - use pad name %s as pattern", fname.Data(), fn.Data());
2806 }
2807
2808 pads[n]->SaveAs(fn.Data());
2809 }
2810
2811 return kTRUE;
2812
2813}
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
ECursor
Definition GuiTypes.h:373
@ kCross
Definition GuiTypes.h:375
#define SafeDelete(p)
Definition RConfig.hxx:531
#define b(i)
Definition RSha256.hxx:100
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
float Size_t
Attribute size (float)
Definition RtypesCore.h:104
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
@ kRed
Definition Rtypes.h:67
R__EXTERN TApplication * gApplication
void ROOT_TCanvas_Update(void *TheCanvas)
Definition TCanvas.cxx:2497
class TCanvasInit gCanvasInit
TString GetNewCanvasName(const char *arg=nullptr)
Definition TCanvas.cxx:66
const Size_t kDefaultCanvasSize
Definition TCanvas.cxx:63
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:385
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetDoubleBuffer
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetCursor
Option_t Option_t SetFillColor
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:148
R__EXTERN TGuiFactory * gBatchGuiFactory
Definition TGuiFactory.h:67
R__EXTERN TGuiFactory * gGuiFactory
Definition TGuiFactory.h:66
#define gInterpreter
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:777
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
#define gGLManager
Definition TVirtualGL.h:159
#define R__LOCKGUARD(mutex)
R__EXTERN TVirtualPS * gVirtualPS
Definition TVirtualPS.h:88
#define gPad
R__EXTERN Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gVirtualX
Definition TVirtualX.h:377
Color * colors
Definition X3DBuffer.c:21
#define snprintf
Definition civetweb.c:1579
void InitializeGraphics(Bool_t only_web=kFALSE)
Initialize the graphics environment.
static void CreateApplication()
Static function used to create a default application environment.
static void NeedGraphicsLibs()
Static method.
Array of integers (32 bits per element).
Definition TArrayI.h:27
virtual void Streamer(TBuffer &)
Fill Area Attributes class.
Definition TAttFill.h:21
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
Definition TAttFill.cxx:203
Line Attributes class.
Definition TAttLine.h:21
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
Definition TAttLine.cxx:176
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:98
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition TAttPad.cxx:108
virtual void Copy(TAttPad &attpad) const
copy function
Definition TAttPad.cxx:43
virtual void SetRightMargin(Float_t rightmargin)
Set Pad right margin in fraction of the pad width.
Definition TAttPad.cxx:118
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition TAttPad.cxx:128
Class to manage histogram axis.
Definition TAxis.h:32
static TClass * Class()
Create a Box.
Definition TBox.h:22
static TClass * Class()
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition TCanvasImp.h:30
virtual void SetStatusText(const char *text=nullptr, Int_t partidx=0)
Definition TCanvasImp.h:70
virtual void SetWindowPosition(Int_t x, Int_t y)
Definition TCanvasImp.h:71
virtual void ShowMenuBar(Bool_t show=kTRUE)
Definition TCanvasImp.h:76
virtual void Show()
Definition TCanvasImp.h:75
virtual Bool_t PerformUpdate(Bool_t)
Definition TCanvasImp.h:49
virtual void ShowToolTips(Bool_t show=kTRUE)
Definition TCanvasImp.h:83
virtual void Iconify()
Definition TCanvasImp.h:68
virtual Int_t InitWindow()
Definition TCanvasImp.h:69
virtual void UpdateDisplay(Int_t mode=0, Bool_t sleep=kFALSE)
Update gVirtualX display, also optionally sleep to wait until operation finished.
virtual void Close()
Definition TCanvasImp.h:59
virtual void SetWindowTitle(const char *newTitle)
Definition TCanvasImp.h:73
virtual void GetCanvasGeometry(Int_t wid, UInt_t &w, UInt_t &h)
Gets the size and position of the canvas paint area.
virtual Bool_t IsWeb() const
Definition TCanvasImp.h:48
virtual UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Definition TCanvasImp.h:61
virtual void ResizeCanvasWindow(Int_t wid)
Resize canvas window, redirect to gVirtualX.
virtual TVirtualPadPainter * CreatePadPainter()
Definition TCanvasImp.h:50
virtual void ShowEditor(Bool_t show=kTRUE)
Definition TCanvasImp.h:81
virtual void RaiseWindow()
Definition TCanvasImp.h:78
virtual void SetWindowSize(UInt_t width, UInt_t height)
Definition TCanvasImp.h:72
virtual void SetCanvasSize(UInt_t w, UInt_t h)
Definition TCanvasImp.h:74
virtual void ForceUpdate()
Definition TCanvasImp.h:60
virtual void ShowStatusBar(Bool_t show=kTRUE)
Definition TCanvasImp.h:77
virtual void ShowToolBar(Bool_t show=kTRUE)
Definition TCanvasImp.h:82
The Canvas class.
Definition TCanvas.h:23
void Init()
Initialize the TCanvas members. Called by all constructors.
Definition TCanvas.cxx:546
UInt_t fCw
Width of the canvas along X (pixels)
Definition TCanvas.h:44
~TCanvas() override
Canvas destructor.
Definition TCanvas.cxx:686
void EmbedInto(Int_t winid, Int_t ww, Int_t wh)
Embedded a canvas into a TRootEmbeddedCanvas.
Definition TCanvas.cxx:1059
void SetWindowSize(UInt_t ww, UInt_t wh)
Set canvas window size.
Definition TCanvas.cxx:2156
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:2021
void Browse(TBrowser *b) override
Browse.
Definition TCanvas.cxx:694
UInt_t GetWindowHeight() const
Definition TCanvas.h:166
virtual void EditorBar()
Get editor bar.
Definition TCanvas.cxx:1050
static TCanvas * MakeDefCanvas()
Static function to build a default canvas.
Definition TCanvas.cxx:1521
void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)
Generate kMouseEnter and kMouseLeave events depending on the previously selected object and the curre...
Definition TCanvas.cxx:1085
Size_t fYsizeReal
Current size of canvas along Y in CM.
Definition TCanvas.h:37
void Constructor()
Canvas default constructor.
Definition TCanvas.cxx:200
virtual void ToggleAutoExec()
Toggle pad auto execution of list of TExecs.
Definition TCanvas.cxx:2435
TCanvas(const TCanvas &canvas)=delete
Int_t fWindowTopX
Top X position of window (in pixels)
Definition TCanvas.h:40
void Draw(Option_t *option="") override
Draw a canvas.
Definition TCanvas.cxx:865
void SetDoubleBuffer(Int_t mode=1) override
Set Double Buffer On/Off.
Definition TCanvas.cxx:1980
virtual void ToggleToolTips()
Toggle tooltip display.
Definition TCanvas.cxx:2477
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
Definition TCanvas.cxx:746
void UseCurrentStyle() override
Force a copy of current style for all objects in canvas.
Definition TCanvas.cxx:1191
void Iconify()
Iconify canvas.
Definition TCanvas.cxx:1484
Int_t GetWindowTopX()
Returns current top x position of window on screen.
Definition TCanvas.cxx:1216
virtual void ToggleEventStatus()
Toggle event statusbar.
Definition TCanvas.cxx:2444
void Destructor()
Actual canvas destructor.
Definition TCanvas.cxx:704
Bool_t fUpdated
! Set to True when Update method was called
Definition TCanvas.h:65
void DeleteCanvasPainter()
assert on IsBatch() == false?
Definition TCanvas.cxx:2664
TPad * fPadSave
! Pointer to saved pad in HandleInput
Definition TCanvas.h:57
static Bool_t SupportAlpha()
Static function returning "true" if transparency is supported.
Definition TCanvas.cxx:2489
Bool_t fBatch
! True when in batchmode
Definition TCanvas.h:60
Bool_t fUseGL
! True when rendering is with GL
Definition TCanvas.h:63
Int_t fEventX
! Last X mouse position in canvas
Definition TCanvas.h:47
Bool_t IsBatch() const override
Definition TCanvas.h:177
TObject * DrawClone(Option_t *option="") const override
Draw a clone of this canvas A new canvas is created that is a clone of this canvas.
Definition TCanvas.cxx:918
Size_t fXsizeReal
Current size of canvas along X in CM.
Definition TCanvas.h:36
Bool_t HasMenuBar() const
Definition TCanvas.h:174
TVirtualPadPainter * GetCanvasPainter()
Access and (probably) creation of pad painter.
Definition TCanvas.cxx:2631
virtual void HighlightConnect(const char *slot)
This is "simplification" for function TCanvas::Connect with Highlighted signal for specific slot.
Definition TCanvas.cxx:1636
TPad * Pick(Int_t px, Int_t py, TObjLink *&pickobj) override
Search for an object at pixel position px,py.
Definition TCanvas.h:189
void Close(Option_t *option="") override
Close canvas.
Definition TCanvas.cxx:797
void SetFixedAspectRatio(Bool_t fixed=kTRUE) override
Fix canvas aspect ratio to current value if fixed is true.
Definition TCanvas.cxx:1999
virtual void Resize(Option_t *option="")
Recompute canvas parameters following a X11 Resize.
Definition TCanvas.cxx:1673
Color_t GetHighLightColor() const override
Definition TCanvas.h:142
Bool_t GetShowToolBar() const
Definition TCanvas.h:153
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:989
Bool_t IsFolder() const override
Is folder ?
Definition TCanvas.cxx:1493
Bool_t EnsurePSPainter(Bool_t create, TVirtualPadPainter *&oldp)
Replace canvas painter For internal use only - when creating PS images.
Definition TCanvas.cxx:2641
UInt_t fWindowWidth
Width of window (including borders, etc.)
Definition TCanvas.h:42
TVirtualPadPainter * fPainter
! Canvas (pad) painter.
Definition TCanvas.h:67
void CopyPixmaps() override
Copy the canvas pixmap of the pad to the canvas.
Definition TCanvas.cxx:847
Bool_t IsGrayscale()
Check whether this canvas is to be drawn in grayscale mode.
Definition TCanvas.cxx:2582
TPad * fClickSelectedPad
! Pad containing currently click-selected object
Definition TCanvas.h:56
Bool_t fUpdating
! True when Updating the canvas
Definition TCanvas.h:61
void SaveSource(const char *filename="", Option_t *option="")
Save primitives in this canvas as a C++ macro file.
Definition TCanvas.cxx:1819
void SetCanvasImp(TCanvasImp *i)
Set canvas implementation If web-based implementation provided, some internal fields also initialized...
Definition TCanvas.cxx:2168
Color_t fHighLightColor
Highlight color of active pad.
Definition TCanvas.h:38
virtual void Size(Float_t xsizeuser=0, Float_t ysizeuser=0)
Set the canvas scale in centimeters.
Definition TCanvas.cxx:2208
virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected)
Emit ProcessedEvent() signal.
Definition TCanvas.cxx:1658
virtual void HandleInput(EEventType button, Int_t x, Int_t y)
Handle Input Events.
Definition TCanvas.cxx:1240
void UpdateAsync() override
Asynchronous pad update.
Definition TCanvas.cxx:2560
Size_t fXsizeUser
User specified size of canvas along X in CM.
Definition TCanvas.h:34
Int_t fEventY
! Last Y mouse position in canvas
Definition TCanvas.h:48
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Definition TCanvas.cxx:728
UInt_t fWindowHeight
Height of window (including menubar, borders, etc.)
Definition TCanvas.h:43
Int_t GetWindowTopY()
Returns current top y position of window on screen.
Definition TCanvas.cxx:1227
TObject * fClickSelected
! Currently click-selected object
Definition TCanvas.h:51
void SetCanvasSize(UInt_t ww, UInt_t wh) override
Set Width and Height of canvas to ww and wh respectively.
Definition TCanvas.cxx:1957
void Show()
Show canvas.
Definition TCanvas.cxx:2219
TPad * fSelectedPad
! Pad containing currently selected object
Definition TCanvas.h:55
virtual void Selected(TVirtualPad *pad, TObject *obj, Int_t event)
Emit Selected() signal.
Definition TCanvas.cxx:1644
Int_t fSelectedX
! X of selected object
Definition TCanvas.h:52
virtual void ToggleEditor()
Toggle editor.
Definition TCanvas.cxx:2466
TVirtualPad * GetSelectedPad() const override
Definition TCanvas.h:150
virtual void Picked(TPad *selpad, TObject *selected, Int_t event)
Emit Picked() signal.
Definition TCanvas.cxx:1598
TObject * fSelected
! Currently selected object
Definition TCanvas.h:50
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this canvas in C++ macro file with GUI.
Definition TCanvas.cxx:1785
void SetCursor(ECursor cursor) override
Set cursor.
Definition TCanvas.cxx:1971
void Streamer(TBuffer &) override
Stream a class object.
Definition TCanvas.cxx:2228
Bool_t GetShowToolTips() const
Definition TCanvas.h:155
Int_t fCanvasID
! Canvas identifier
Definition TCanvas.h:49
void SetGrayscale(Bool_t set=kTRUE)
Set whether this canvas should be painted in grayscale, and re-paint it if necessary.
Definition TCanvas.cxx:2591
void SetTitle(const char *title="") override
Set canvas title.
Definition TCanvas.cxx:2138
UInt_t fCh
Height of the canvas along Y (pixels)
Definition TCanvas.h:45
TContextMenu * fContextMenu
! Context menu pointer
Definition TCanvas.h:59
TAttCanvas fCatt
Canvas attributes.
Definition TCanvas.h:32
void SetName(const char *name="") override
Set canvas name.
Definition TCanvas.cxx:2030
UInt_t GetWindowWidth() const
Definition TCanvas.h:165
Bool_t fRetained
Retain structure flag.
Definition TCanvas.h:62
void DisconnectWidget()
Used by friend class TCanvasImp.
Definition TCanvas.cxx:2573
void FeedbackMode(Bool_t set)
Turn rubberband feedback mode on or off.
Definition TCanvas.cxx:1139
void ls(Option_t *option="") const override
List all pads.
Definition TCanvas.cxx:1509
void RaiseWindow()
Raise canvas window.
Definition TCanvas.cxx:1751
void Build()
Build a canvas. Called by all constructors.
Definition TCanvas.cxx:596
static Bool_t SaveAll(const std::vector< TPad * > &={}, const char *filename="", Option_t *option="")
Save provided pads/canvases into the image file(s) Filename can include printf argument for image num...
Definition TCanvas.cxx:2692
Int_t fWindowTopY
Top Y position of window (in pixels)
Definition TCanvas.h:41
void Paint(Option_t *option="") override
Paint canvas.
Definition TCanvas.cxx:1548
@ kResizeOpaque
Definition TCanvas.h:99
@ kShowToolTips
Definition TCanvas.h:101
@ kShowToolBar
Definition TCanvas.h:96
@ kMoveOpaque
Definition TCanvas.h:98
@ kIsGrayscale
Definition TCanvas.h:100
@ kShowEventStatus
Definition TCanvas.h:93
@ kAutoExec
Definition TCanvas.h:94
@ kMenuBar
Definition TCanvas.h:95
@ kShowEditor
Definition TCanvas.h:97
TClass * IsA() const override
Definition TCanvas.h:244
void Update() override
Update canvas pad buffers.
Definition TCanvas.cxx:2504
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TCanvas.cxx:1121
void RunAutoExec()
Execute the list of TExecs in the current pad.
Definition TCanvas.cxx:1774
virtual void Cleared(TVirtualPad *pad)
Emit pad Cleared signal.
Definition TCanvas.cxx:779
UInt_t GetWw() const override
Definition TCanvas.h:167
TCanvasImp * fCanvasImp
! Window system specific canvas implementation
Definition TCanvas.h:58
UInt_t GetWh() const override
Definition TCanvas.h:168
virtual void Highlighted(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)
Emit Highlighted() signal.
Definition TCanvas.cxx:1617
void Flush()
Flush canvas buffers.
Definition TCanvas.cxx:1153
Size_t fYsizeUser
User specified size of canvas along Y in CM.
Definition TCanvas.h:35
Int_t fDoubleBuffer
Double buffer flag (0=off, 1=on)
Definition TCanvas.h:39
void ForceUpdate()
Force canvas update.
Definition TCanvas.cxx:1183
void CreatePainter()
Probably, TPadPainter must be placed in a separate ROOT module - "padpainter" (the same as "histpaint...
Definition TCanvas.cxx:2610
void SetSelected(TObject *obj) override
Set selected canvas.
Definition TCanvas.cxx:2129
void MoveOpaque(Int_t set=1)
Set option to move objects/pads in a canvas.
Definition TCanvas.cxx:1540
static Bool_t fgIsFolder
Indicates if canvas can be browsed as a folder.
Definition TCanvas.h:71
void Closed() override
Emit Closed signal.
Definition TCanvas.cxx:787
Bool_t IsWeb() const override
Is web canvas.
Definition TCanvas.cxx:1501
void SetWindowPosition(Int_t x, Int_t y)
Set canvas window position.
Definition TCanvas.cxx:2147
TString fDISPLAY
Name of destination screen.
Definition TCanvas.h:33
bool SetRealAspectRatio(const Int_t axis=1)
Function to resize a canvas so that the plot inside is shown in real aspect ratio.
Definition TCanvas.cxx:2062
Int_t fEvent
! Type of current or last handled event
Definition TCanvas.h:46
Bool_t GetShowEventStatus() const
Definition TCanvas.h:152
TString fSelectedOpt
! Drawing option of selected object
Definition TCanvas.h:54
Int_t fSelectedY
! Y of selected object
Definition TCanvas.h:53
Bool_t fDrawn
! Set to True when the Draw method is called
Definition TCanvas.h:64
void SetBatch(Bool_t batch=kTRUE) override
Toggle batch mode.
Definition TCanvas.cxx:1939
Bool_t UseGL() const
Definition TCanvas.h:234
void ResizeOpaque(Int_t set=1)
Set option to resize objects/pads in a canvas.
Definition TCanvas.cxx:1766
virtual void ToggleToolBar()
Toggle toolbar.
Definition TCanvas.cxx:2455
TVirtualPad * fHilightPadBorder
! pad which border will be hilghlighrt when paint canvas
Definition TCanvas.h:69
virtual TObject * DrawClonePad()
Draw a clone of this canvas into the current pad In an interactive session, select the destination/cu...
Definition TCanvas.cxx:935
@ kRealNew
Definition TClass.h:110
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition TClass.cxx:6007
void Browse(TBrowser *b) override
Browse this collection (called by TBrowser).
The color creation and management class.
Definition TColor.h:22
static const TArrayI & GetPalette()
Static function returning the current active palette.
Definition TColor.cxx:1521
static void SaveColorsPalette(std::ostream &out)
Store current palette in the output macro.
Definition TColor.cxx:3649
static TClass * Class()
static TString SavePrimitiveColor(Int_t ci)
Convert color in C++ statement which can be used in SetColor directives Produced statement either inc...
Definition TColor.cxx:2556
static Bool_t DefinedColors(Int_t set_always_on=0)
Static method returning kTRUE if some new colors have been defined after initialisation or since the ...
Definition TColor.cxx:1542
This class provides an interface to context sensitive popup menus.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
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
static TClass * Class()
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
virtual TCanvasImp * CreateCanvasImp(TCanvas *c, const char *title, UInt_t width, UInt_t height)
Create a batch version of TCanvasImp.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
Option_t * GetOption() const
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
An array of TObjects.
Definition TObjArray.h:31
static TClass * Class()
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Clear(Option_t *="")
Definition TObject.h:127
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:242
R__ALWAYS_INLINE Bool_t IsOnHeap() const
Definition TObject.h:160
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition TObject.cxx:414
virtual void Delete(Option_t *option="")
Delete this object.
Definition TObject.cxx:267
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
Definition TObject.cxx:639
@ kNoContextMenu
if object does not want context menu
Definition TObject.h:78
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1070
static TClass * Class()
Implement TVirtualPadPainter which abstracts painting operations.
Definition TPadPainter.h:25
The most important graphics class in the ROOT system.
Definition TPad.h:28
Short_t GetBorderMode() const override
Definition TPad.h:199
void SetBorderSize(Short_t bordersize) override
Definition TPad.h:332
Int_t GetTicky() const override
Definition TPad.h:241
void PaintBorder(Color_t color, Bool_t tops)
Paint the pad border.
Definition TPad.cxx:3687
Bool_t IsEditable() const override
Definition TPad.h:274
void ResizePad(Option_t *option="") override
Compute pad conversion coefficients.
Definition TPad.cxx:5647
void SetGrid(Int_t valuex=1, Int_t valuey=1) override
Definition TPad.h:341
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitives in this pad on the C++ source file out.
Definition TPad.cxx:5862
Bool_t GetGridx() const override
Definition TPad.h:237
Double_t fX2
X of upper X coordinate.
Definition TPad.h:38
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition TPad.cxx:6075
Double_t GetY2() const override
Definition TPad.h:245
void Close(Option_t *option="") override
Delete all primitives in pad and pad itself.
Definition TPad.cxx:1084
void PaintModified() override
Traverse pad hierarchy and (re)paint only modified pads.
Definition TPad.cxx:3822
const char * GetTitle() const override
Returns title of object.
Definition TPad.h:263
Double_t fX1
X of lower X coordinate.
Definition TPad.h:36
TList * GetListOfPrimitives() const override
Definition TPad.h:247
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) override
Set all pad parameters.
Definition TPad.cxx:6135
void UseCurrentStyle() override
Force a copy of current style for all objects in pad.
Definition TPad.cxx:6892
void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2) override
Set world coordinate system for the pad.
Definition TPad.cxx:5354
Double_t fY1
Y of lower Y coordinate.
Definition TPad.h:37
Int_t fGLDevice
! OpenGL off-screen pixmap identifier
Definition TPad.h:85
void Clear(Option_t *option="") override
Delete all pad primitives.
Definition TPad.cxx:723
Int_t GetTickx() const override
Definition TPad.h:240
Double_t fAspectRatio
ratio of w/h in case of fixed ratio
Definition TPad.h:82
void SetLogy(Int_t value=1) override
Set Lin/Log scale for Y.
Definition TPad.cxx:6064
TCanvas * fCanvas
! Pointer to mother canvas
Definition TPad.h:106
Bool_t fFixedAspectRatio
True if fixed aspect ratio.
Definition TPad.h:104
void Modified(Bool_t flag=true) override
Mark pad modified Will be repainted when TCanvas::Update() will be called next time.
Definition TPad.cxx:7353
void ls(Option_t *option="") const override
List all primitives in pad.
Definition TPad.cxx:3118
void Streamer(TBuffer &) override
Stream a class object.
Definition TPad.cxx:6678
TString fTitle
Pad title.
Definition TPad.h:110
void CopyPixmaps() override
Copy the sub-pixmaps of the pad to the canvas.
Definition TPad.cxx:1156
void CopyPixmap() override
Copy the pixmap of the pad to the canvas.
Definition TPad.cxx:1143
Double_t GetY1() const override
Definition TPad.h:244
Bool_t GetGridy() const override
Definition TPad.h:238
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TPad.cxx:1948
Int_t GetLogz() const override
Definition TPad.h:260
Short_t GetBorderSize() const override
Definition TPad.h:200
TList * fPrimitives
->List of primitives (subpads)
Definition TPad.h:107
Short_t fBorderSize
pad bordersize in pixels
Definition TPad.h:97
void Paint(Option_t *option="") override
Paint all primitives in pad.
Definition TPad.cxx:3612
TString fName
Pad name.
Definition TPad.h:109
Int_t fPixmapID
! Off-screen pixmap identifier
Definition TPad.h:84
TObject * FindObject(const char *name) const override
Search if object named name is inside this pad or in pads inside this pad.
Definition TPad.cxx:2693
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition TPad.cxx:694
Int_t GetLogy() const override
Definition TPad.h:259
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:331
void SetTicks(Int_t valuex=1, Int_t valuey=1) override
Definition TPad.h:361
Double_t fY2
Y of upper Y coordinate.
Definition TPad.h:39
Short_t fBorderMode
Bordermode (-1=down, 0 = no border, 1=up)
Definition TPad.h:98
void SetLogx(Int_t value=1) override
Set Lin/Log scale for X.
Definition TPad.cxx:6050
Int_t GetLogx() const override
Definition TPad.h:258
Double_t GetX2() const override
Definition TPad.h:243
Double_t GetX1() const override
Definition TPad.h:242
TPad * fMother
! pointer to mother of the list
Definition TPad.h:105
const char * GetName() const override
Returns name of object.
Definition TPad.h:262
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
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:865
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3044
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3052
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2901
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1910
@ kBoth
Definition TString.h:284
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1492
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2459
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:643
Double_t GetTimeOffset() const
Definition TStyle.h:271
Int_t GetOptLogy() const
Definition TStyle.h:250
Int_t GetOptStat() const
Definition TStyle.h:247
Int_t GetOptTitle() const
Definition TStyle.h:248
void SetCanvasBorderSize(Width_t size=1)
Definition TStyle.h:348
Float_t GetScreenFactor() const
Definition TStyle.h:258
Int_t GetPadTickX() const
Definition TStyle.h:219
Bool_t IsReading() const
Definition TStyle.h:300
void SetCanvasColor(Color_t color=19)
Definition TStyle.h:347
Float_t GetPadRightMargin() const
Definition TStyle.h:216
void SetCanvasBorderMode(Int_t mode=1)
Definition TStyle.h:349
Int_t GetCanvasDefH() const
Definition TStyle.h:193
Int_t GetCanvasDefX() const
Definition TStyle.h:195
Bool_t GetPadGridY() const
Definition TStyle.h:218
Float_t GetPadLeftMargin() const
Definition TStyle.h:215
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1889
Bool_t GetCanvasPreferGL() const
Definition TStyle.h:189
Int_t GetCanvasDefY() const
Definition TStyle.h:196
Bool_t GetPadGridX() const
Definition TStyle.h:217
Int_t GetPadTickY() const
Definition TStyle.h:220
Color_t GetCanvasColor() const
Definition TStyle.h:190
Float_t GetPadBottomMargin() const
Definition TStyle.h:213
Int_t GetCanvasDefW() const
Definition TStyle.h:194
Int_t GetOptLogx() const
Definition TStyle.h:249
Int_t GetCanvasBorderMode() const
Definition TStyle.h:192
Width_t GetCanvasBorderSize() const
Definition TStyle.h:191
Int_t GetOptFit() const
Definition TStyle.h:246
Int_t GetOptLogz() const
Definition TStyle.h:251
Float_t GetPadTopMargin() const
Definition TStyle.h:214
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1289
static TClass * Class()
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 UpdateDrawable(Int_t)
virtual void LockPainter()
Empty definition.
virtual void SetDrawMode(Int_t, Int_t)
virtual void SetCursor(Int_t win, ECursor cursor)
Set cursor for specified device, redirect to gVirtualX.
virtual TClass * IsA() const
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.
virtual void SetDoubleBuffer(Int_t device, Int_t mode)
Set double buffer mode for specified device, redirect to gVirtualX.
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:61
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
static TClass * Class()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:409
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Definition TMath.h:706
th1 Draw()