Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TVirtualPad.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 05/12/95
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 "TVirtualPad.h"
13#include "TBuffer.h"
14#include "TThreadSlots.h"
15
16/** \class TVirtualPad
17\ingroup Base
18
19TVirtualPad is an abstract base class for the Pad and Canvas classes.
20*/
21
22Int_t (*gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret) = nullptr;
23
24
25/** \class TVirtualPad::TContext
26\ingroup Base
27
28Small helper class to preserve gPad, which will be restored when TContext object is destroyed
29*/
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// Constructor which just store gPad
34/// @param _interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
35
37{
38 fInteractive = _interactive;
39 fSaved = gPad;
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// Constructor which stores gPad and set it to new value
44/// @param gpad pointer to current pad
45/// @param interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
46/// @param not_null allows to set only pad which is not null
47
49{
50 fInteractive = interactive;
51 fSaved = gPad;
52 if (fInteractive && gpad)
53 gpad->cd();
54 else if (!not_null || gpad)
55 gPad = gpad;
56}
57
58////////////////////////////////////////////////////////////////////////////////
59/// Destructor
60/// Restores previous value of gPad
61
63{
64 if (!fInteractive || !fSaved)
65 gPad = fSaved;
66 else
67 fSaved->cd();
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Inform context that pad deleted or will be deleted soon
72/// Reference on that pad should be cleared
73
75{
76 if (pad == fSaved)
77 fSaved = nullptr;
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Return the current pad for the current thread.
82
84{
85 static TVirtualPad *currentPad = nullptr;
86 if (!gThreadTsd)
87 return currentPad;
88 else
89 return *(TVirtualPad**)(*gThreadTsd)(&currentPad,ROOT::kPadThreadSlot);
90}
91
92
93////////////////////////////////////////////////////////////////////////////////
94/// VirtualPad default constructor
95
100
101////////////////////////////////////////////////////////////////////////////////
102/// VirtualPad constructor
103
104TVirtualPad::TVirtualPad(const char *, const char *, Double_t,
106 : TAttPad()
107{
109
110 SetFillColor(color);
111 SetFillStyle(1001);
112}
113
114////////////////////////////////////////////////////////////////////////////////
115/// VirtualPad destructor
116
120
121////////////////////////////////////////////////////////////////////////////////
122/// Stream an object of class TVirtualPad.
123
125{
126 if (R__b.IsReading()) {
127 UInt_t R__s, R__c;
128 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
129 if (R__v > 1) {
130 R__b.ReadClassBuffer(TVirtualPad::Class(), this, R__v, R__s, R__c);
131 return;
132 }
133 //====process old versions before automatic schema evolution
134 TObject::Streamer(R__b);
135 TAttLine::Streamer(R__b);
136 TAttFill::Streamer(R__b);
137 TAttPad::Streamer(R__b);
138 //====end of old versions
139
140 } else {
142 }
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Should always return false unless you have non-standard picking.
147
149{
150 return kFALSE;
151}
152
153////////////////////////////////////////////////////////////////////////////////
154/// Should always return false, unless you can highlight selected object in pad.
155
157{
158 return kFALSE;
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Paint N individual segments
163/// Provided arrays should have 2*n elements
164/// IMPORTANT! Provided arrays can be modified after function call!
165
167{
168 for (Int_t i = 0; i < 2*n; i += 2)
169 PaintLine(x[i], y[i], x[i+1], y[i+1]);
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Paint N individual segments in NDC coordinates
174/// Provided arrays should have 2*n elements
175
177{
178 for (Int_t i = 0; i < 2*n; i += 2)
179 PaintLineNDC(u[i], v[i], u[i+1], v[i+1]);
180}
181
182
183////////////////////////////////////////////////////////////////////////////////
184/// Does nothing, unless you implement your own picking.
185/// When complex object containing sub-objects (which can be picked)
186/// is painted in a pad, this "top-level" object is pushed into
187/// the selectables stack.
188
190{
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Does nothing, unless you implement your own picking.
195/// "Complete" object, or part of complex object, which
196/// can be picked.
197
199{
200}
201
202////////////////////////////////////////////////////////////////////////////////
203/// Does nothing, unless you implement your own picking.
204/// Remove top level selectable and all its' children.
205
209
210////////////////////////////////////////////////////////////////////////////////
211/// Scope-guards ctor, pushe the object on stack.
212
214{
215 gPad->PushTopLevelSelectable(obj);
216}
217
218////////////////////////////////////////////////////////////////////////////////
219/// Guard does out of scope, pop object from stack.
220
222{
223 gPad->PopTopLevelSelectable();
224}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
short Version_t
Class version identifier (short).
Definition RtypesCore.h:79
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
short Short_t
Signed Short integer 2 bytes (short).
Definition RtypesCore.h:53
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
short Color_t
Color number (short).
Definition RtypesCore.h:99
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
#define gPad
externInt_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
virtual void Streamer(TBuffer &)
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
virtual void Streamer(TBuffer &)
TAttPad()
Constructor.
Definition TAttPad.cxx:28
virtual void Streamer(TBuffer &)
Stream an object of class TAttPad.
Definition TAttPad.cxx:149
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
Mother of all ROOT objects.
Definition TObject.h:42
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:997
TObject()
TObject constructor.
Definition TObject.h:259
~TPickerStackGuard()
Guard does out of scope, pop object from stack.
TPickerStackGuard(TObject *obj)
Scope-guards ctor, pushe the object on stack.
~TContext()
Destructor Restores previous value of gPad.
TContext(Bool_t _interactive=kFALSE)
Constructor which just store gPad.
TVirtualPad * fSaved
Definition TVirtualPad.h:63
void PadDeleted(TVirtualPad *pad)
Inform context that pad deleted or will be deleted soon Reference on that pad should be cleared.
virtual Bool_t PadInHighlightMode() const
Should always return false, unless you can highlight selected object in pad.
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual ~TVirtualPad()
VirtualPad destructor.
virtual void PaintLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2)=0
virtual Bool_t PadInSelectionMode() const
Should always return false unless you have non-standard picking.
virtual void PushTopLevelSelectable(TObject *top)
Does nothing, unless you implement your own picking.
void Streamer(TBuffer &) override
Stream an object of class TVirtualPad.
virtual void PaintSegmentsNDC(Int_t n, Double_t *u, Double_t *v)
Paint N individual segments in NDC coordinates Provided arrays should have 2*n elements.
virtual void PushSelectableObject(TObject *obj)
Does nothing, unless you implement your own picking.
static TClass * Class()
virtual void PaintLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2)=0
TVirtualPad()
VirtualPad default constructor.
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Bool_t fResizing
!true when resizing the pad
Definition TVirtualPad.h:54
virtual void PopTopLevelSelectable()
Does nothing, unless you implement your own picking.
virtual void PaintSegments(Int_t n, Double_t *x, Double_t *y, Option_t *option="")
Paint N individual segments Provided arrays should have 2*n elements IMPORTANT!
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
@ kPadThreadSlot