ROOT
v6-20
Reference Guide
customcolor.h
Go to the documentation of this file.
1
//Author: Timur Pocheptsov, 14/1/2014.
2
3
#ifndef CUSTOMCOLOR_INCLUDED
4
#define CUSTOMCOLOR_INCLUDED
5
6
#include <algorithm>
7
8
#include "
TError.h
"
9
#include "
Rtypes.h
"
10
#include "
TROOT.h
"
11
12
namespace
ROOT
{
13
namespace
CocoaTutorials {
14
15
//___________________________________________________________
16
inline
Color_t
FindFreeCustomColorIndex
(
Color_t
start = 1000)
17
{
18
if
(!
gROOT
) {
19
//AH??? WHAT??? Should never happen! :)
20
::Error
(
"FindFreeCustomColorIndex"
,
"gROOT is null"
);
21
return
-1;
22
}
23
//Some (probably stupid) assumption about the TColor -
24
//I'm trying to find some 'free' index in the range [1000, 10000).
25
for
(
Color_t
i = std::max(start,
Color_t
(1000)),
e
= 10000; i <
e
; ++i)
26
if
(!
gROOT
->GetColor(i))
27
return
i;
28
29
::Error
(
"FindFreeCustomColorIndex"
,
"no index found"
);
30
31
return
-1;
32
}
33
34
//
35
//Ho-ho-ho! Say good-bye to CINT and hello CLING ... and good old templates!!!
36
//___________________________________________________________
37
template
<
unsigned
N>
38
inline
unsigned
FindFreeCustomColorIndices
(
Color_t
(&
indices
)[
N
])
39
{
40
//All or none.
41
Color_t
tmp[
N
] = {};
42
tmp[0] =
FindFreeCustomColorIndex
();
43
if
(tmp[0] == -1)
//Not found.
44
return
0;
45
46
unsigned
nFound = 1;
47
for
(; nFound <
N
; ++nFound) {
48
tmp[nFound] =
FindFreeCustomColorIndex
(tmp[nFound - 1] + 1);
//the next free color index.
49
if
(tmp[nFound] == -1)
50
break
;
51
}
52
53
if
(nFound ==
N
)
54
std::copy(tmp, tmp +
N
,
indices
);
55
56
return
nFound;
57
}
58
59
}
//CocoaTutorials
60
}
//ROOT
61
62
#endif
e
#define e(i)
Definition:
RSha256.hxx:103
Color_t
short Color_t
Definition:
RtypesCore.h:79
Rtypes.h
TError.h
Error
void Error(const char *location, const char *msgfmt,...)
N
#define N
TROOT.h
gROOT
#define gROOT
Definition:
TROOT.h:415
ROOT::CocoaTutorials::FindFreeCustomColorIndex
Color_t FindFreeCustomColorIndex(Color_t start=1000)
Definition:
customcolor.h:16
ROOT::CocoaTutorials::FindFreeCustomColorIndices
unsigned FindFreeCustomColorIndices(Color_t(&indices)[N])
Definition:
customcolor.h:38
ROOT
VSD Structures.
Definition:
StringConv.hxx:21
ROOT::Detail::indices
Definition:
span.hxx:60
tutorials
cocoa
customcolor.h
ROOT v6-20 - Reference Guide Generated on Fri Apr 1 2022 00:23:38 (GVA Time) using Doxygen 1.9.4