Logo ROOT   6.12/07
Reference Guide
TDrawingOptsBase.cxx
Go to the documentation of this file.
1 /// \file TDrawingOptsBase.cxx
2 /// \ingroup Gpad ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2017-09-26
5 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6 /// is welcome!
7 
8 /*************************************************************************
9  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
10  * All rights reserved. *
11  * *
12  * For the licensing terms see $ROOTSYS/LICENSE. *
13  * For the list of contributors see $ROOTSYS/README/CREDITS. *
14  *************************************************************************/
15 
17 
18 #include "ROOT/TCanvas.hxx"
19 #include "ROOT/TColor.hxx"
20 #include "ROOT/TLogger.hxx"
21 #include "ROOT/TPad.hxx"
22 
23 #include "TDrawingOptsReader.hxx" // in src/
24 
25 #include <cstddef>
26 #include <unordered_map>
27 
28 using namespace ROOT::Experimental;
29 
31 fCanvas(&pad.GetCanvas()), fName(configPrefix) {}
32 
34 {
35  static std::unordered_map<std::string, TCanvas> sCanv;
36 
37  auto iCanv = sCanv.find(style.GetName());
38  if (iCanv != sCanv.end())
39  return iCanv->second;
40 
41  TCanvas &canv = sCanv[style.GetName()];
42  canv.SetTitle(style.GetName());
43  return canv;
44 }
45 
47 {
48  if (const TCanvas* canv = dynamic_cast<const TCanvas*>(&canvPad)) {
49  if (TStyle* style = TStyle::Get(canv->GetTitle()))
50  return &GetDefaultCanvas(*style) == &canvPad;
51  }
52  return false;
53 }
54 
55 
57 {
58  fColorIdx.Release(GetCanvas());
61 }
62 
64  : fCanvas(other.fCanvas), fColorIdx(other.fColorIdx), fIntIdx(other.fIntIdx), fFPIdx(other.fFPIdx)
65 {
66  fColorIdx.RegisterCopy(GetCanvas());
69 }
static TStyle * Get(std::string_view name)
Get the TStyle named name from the global style collection, or nullptr if that doesn&#39;t exist...
Definition: TStyle.cxx:46
basic_string_view< char > string_view
Definition: RStringView.h:35
A window&#39;s topmost TPad.
Definition: TCanvas.hxx:39
TCanvas * fCanvas
The TCanvas holding the TDrawable (or its TPad).
A set of defaults for graphics attributes, e.g.
Definition: TStyle.hxx:34
OptsAttrRefArr< TColor > fColorIdx
Indexes of the TCanvas&#39;s color table entries used by this options object.
void RegisterCopy(TCanvas &canv)
Once copied, elements of a OptsAttrRefArr need to increase their use count.
Base class for graphic containers for TDrawable-s.
Definition: TPad.hxx:41
OptsAttrRefArr< long long > fIntIdx
Indexes of the TCanvas&#39;s integer table entries used by this options object.
TCanvas & GetCanvas()
The TCanvas holding the TDrawable (or its TPad) (non-const version).
static bool IsDefaultCanvas(const TPadBase &canv)
Whether the canvas is one of the canvases used to store attribute defaults.
void Release(TCanvas &canv)
Clear all attribute references, removing their uses in TCanvas.
const std::string & GetName() const
Definition: TStyle.hxx:55
TCanvas * style()
Definition: style.C:1
static TPadBase & GetDefaultCanvas(const TStyle &style)
Default attributes need to register their values in a pad - they will take this pad for default attri...
OptsAttrRefArr< double > fFPIdx
Indexes of the TCanvas&#39;s floating point table entries used by this options object.