Loading [MathJax]/extensions/tex2jax.js
ROOT
6.14/05
Reference Guide
ROOT Home
Main Page
Tutorials
Functional Parts
+
Namespaces
Namespace List
+
Namespace Members
+
All
<
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
<
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
u
w
x
+
Enumerations
a
e
f
g
m
p
t
v
w
y
+
Enumerator
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
w
+
All Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
w
y
+
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Properties
f
+
Related Functions
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Files
File List
+
File Members
+
All
1
2
3
4
5
6
7
8
9
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Enumerations
c
e
f
i
l
m
p
r
u
x
+
Enumerator
a
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
u
v
w
+
Macros
1
2
3
4
5
6
7
8
9
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
tutorials
cocoa
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
ROOT::CocoaTutorials::FindFreeCustomColorIndices
unsigned FindFreeCustomColorIndices(Color_t(&indices)[N])
Definition:
customcolor.h:38
ROOT
Namespace for new ROOT classes and functions.
Definition:
StringConv.hxx:21
Rtypes.h
N
#define N
gROOT
#define gROOT
Definition:
TROOT.h:410
ROOT::CocoaTutorials::FindFreeCustomColorIndex
Color_t FindFreeCustomColorIndex(Color_t start=1000)
Definition:
customcolor.h:16
Color_t
short Color_t
Definition:
RtypesCore.h:79
TROOT.h
TError.h
ROOT::Detail::indices
Definition:
span.hxx:61
e
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition:
TRolke.cxx:630
ROOT::Error
void Error(ErrorHandler_t func, int code, const char *va_(fmt),...)
Write error message and call a handler, if required.
Definition:
DaemonUtils.cxx:565