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