Logo ROOT   6.12/07
Reference Guide
TStyle.cxx
Go to the documentation of this file.
1 /// \file TStyle.cxx
2 /// \ingroup Gpad ROOT7
3 /// \author Axel Naumann <axel@cern.ch>
4 /// \date 2017-10-11
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 
16 #include "ROOT/TStyle.hxx"
17 
18 #include "ROOT/TLogger.hxx"
19 #include "ROOT/TPadExtent.hxx"
20 #include "ROOT/TPadPos.hxx"
21 
22 #include <cassert>
23 #include <limits>
24 
25 using namespace ROOT::Experimental;
26 
27 namespace {
28 static std::unordered_map<std::string, TStyle> ReadGlobalDefaultStyles()
29 {
30  // TODO: use AttrReader
31  return {};
32 }
33 
34 static std::unordered_map<std::string, TStyle> &GetGlobalStyles()
35 {
36  static std::unordered_map<std::string, TStyle> sStyles = ReadGlobalDefaultStyles();
37  return sStyles;
38 }
39 }
40 
42 {
43  GetGlobalStyles()[style.GetName()] = style;
44 }
45 
47 {
48  auto iStyle = GetGlobalStyles().find(std::string(name));
49  if (iStyle != GetGlobalStyles().end())
50  return &iStyle->second;
51  return nullptr;
52 }
53 
54 
55 namespace {
56 static TStyle GetInitialCurrent()
57 {
58  static constexpr const char* kDefaultStyleName = "plain";
59  auto iDefStyle = GetGlobalStyles().find(std::string(kDefaultStyleName));
60  if (iDefStyle == GetGlobalStyles().end()) {
61  R__ERROR_HERE("Gpad") << "Cannot find initial default style named \"" << kDefaultStyleName
62  << "\", using an empty one.";
63  TStyle defStyle(kDefaultStyleName);
64  TStyle::Register(defStyle);
65  return defStyle;
66  } else {
67  return iDefStyle->second;
68  }
69 }
70 }
71 
73 {
74  static TStyle sCurrentStyle = GetInitialCurrent();
75  return sCurrentStyle;
76 }
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 set of defaults for graphics attributes, e.g.
Definition: TStyle.hxx:34
static TStyle & GetCurrent()
Get the current TStyle.
Definition: TStyle.cxx:72
const std::string & GetName() const
Definition: TStyle.hxx:55
static void Register(const TStyle &style)
Register a copy of style in the global style collection, possibly replacing a global style with the s...
Definition: TStyle.cxx:41
TCanvas * style()
Definition: style.C:1
char name[80]
Definition: TGX11.cxx:109
#define R__ERROR_HERE(GROUP)
Definition: TLogger.hxx:126