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 interactive defines how gPad will be restored: with cd() call (kTRUE) or just by assign gPad back
45/// @param not_null allows to set only pad which is not null
46
48{
49 fInteractive = interactive;
50 fSaved = gPad;
51 if (fInteractive && gpad)
52 gpad->cd();
53 else if (!not_null || gpad)
54 gPad = gpad;
55}
56
57////////////////////////////////////////////////////////////////////////////////
58/// Destructor
59/// Restores previous value of gPad
60
62{
63 if (!fInteractive || !fSaved)
64 gPad = fSaved;
65 else
66 fSaved->cd();
67}
68
69////////////////////////////////////////////////////////////////////////////////
70/// Inform context that pad deleted or will be deleted soon
71/// Reference on that pad should be cleared
72
74{
75 if (pad == fSaved)
76 fSaved = nullptr;
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// Return the current pad for the current thread.
81
83{
84 static TVirtualPad *currentPad = nullptr;
85 if (!gThreadTsd)
86 return currentPad;
87 else
88 return *(TVirtualPad**)(*gThreadTsd)(&currentPad,ROOT::kPadThreadSlot);
89}
90
92
93////////////////////////////////////////////////////////////////////////////////
94/// VirtualPad default constructor
95
97{
99}
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
118{
119}
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/// Does nothing, unless you implement your own picking.
163/// When complex object containing sub-objects (which can be picked)
164/// is painted in a pad, this "top-level" object is pushed into
165/// the selectables stack.
166
168{
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Does nothing, unless you implement your own picking.
173/// "Complete" object, or part of complex object, which
174/// can be picked.
175
177{
178}
179
180////////////////////////////////////////////////////////////////////////////////
181/// Does nothing, unless you implement your own picking.
182/// Remove top level selectable and all its' children.
183
185{
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// Scope-guards ctor, pushe the object on stack.
190
192{
193 gPad->PushTopLevelSelectable(obj);
194}
195
196////////////////////////////////////////////////////////////////////////////////
197/// Guard does out of scope, pop object from stack.
198
200{
201 gPad->PopTopLevelSelectable();
202}
int Int_t
Definition RtypesCore.h:45
short Color_t
Definition RtypesCore.h:92
short Version_t
Definition RtypesCore.h:65
short Short_t
Definition RtypesCore.h:39
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t SetFillStyle
Option_t Option_t SetFillColor
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
Int_t(* gThreadXAR)(const char *xact, Int_t nb, void **ar, Int_t *iret)
#define gPad
virtual void Streamer(TBuffer &)
virtual void Streamer(TBuffer &)
Manages default Pad attributes.
Definition TAttPad.h:19
virtual void Streamer(TBuffer &)
Stream an object of class TAttPad.
Definition TAttPad.cxx:150
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:41
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:888
~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.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
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 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 PushSelectableObject(TObject *obj)
Does nothing, unless you implement your own picking.
static TClass * Class()
TVirtualPad()
VirtualPad default constructor.
static TVirtualPad *& Pad()
Return the current pad for the current thread.
Bool_t fResizing
Definition TVirtualPad.h:54
virtual void PopTopLevelSelectable()
Does nothing, unless you implement your own picking.
@ kPadThreadSlot