Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
12namespace ROOT {
13namespace CocoaTutorials {
14
15//___________________________________________________________
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//___________________________________________________________
37template <unsigned 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} // namespace CocoaTutorials
60} // namespace ROOT
61
62#endif
#define e(i)
Definition RSha256.hxx:103
short Color_t
Definition RtypesCore.h:85
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
#define N
#define gROOT
Definition TROOT.h:406
Color_t FindFreeCustomColorIndex(Color_t start=1000)
Definition customcolor.h:16
unsigned FindFreeCustomColorIndices(Color_t(&indices)[N])
Definition customcolor.h:38
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...