Diana Software
QStyle.cc
Go to the documentation of this file.
1 #include "QStyle.hh"
2 #include <TROOT.h>
3 #include <TCanvas.h>
4 #include <TPad.h>
5 #include <TColor.h>
6 #include <TText.h>
7 #include <iostream>
8 
9 
11 
12 //QStyles fQStyles;
13 
14 QStyle::QStyle(const char *name,const char *title) : TStyle(name,title) {}
15 
17 
19 
20  int ncolors=250;
21  int *Map=new int [ncolors];
22  int nstops=2;
23  double s[]={0.00,1.0};
24  double r[]={2./255,0./255};
25  double g[]={35./255,247./255};
26  double b[]={255./255,255./255};
27  Int_t FI=TColor::CreateGradientColorTable(nstops,s,r,g,b,ncolors);
28  for(int i=0;i<ncolors;i++) Map[i]=FI+i;
29  this->SetPalette(ncolors,Map);
30  this->SetNumberContours(256);
31  delete[] Map;
32 
33 
34 }
35 
36 void QStyle::DrawDianaDate(const char *date,Double_t xpos,Double_t ypos){
37  TString Date=date;
38  TString tmp=date;
39  tmp.ToLower();
40  if(tmp=="today"){
41  time_t today=time(NULL);
42  char buffer[32];
43  strftime(buffer,32,"%b-%d-%Y",gmtime(&today));
44  Date=buffer;
45  }
46  TText DateText;
47  DateText.SetTextAlign(11);
48  DateText.SetTextSize(.03);
49  DateText.DrawTextNDC(xpos,ypos,Date);
50  return;
51 }
52 
54 {
56  // load default style with this library
57  const char* defaultStyle = "qprod";
58  gROOT->SetStyle(defaultStyle);
59  std::cout<<"QStyles: Style\""<<defaultStyle<<"\" has been set"<<std::endl;
60 }
62 
63 
64 QProductionStyle::QProductionStyle() : QStyle("qprod","DIANA production style")
65 {
66  // taken from style "plain"
67  this->SetFrameBorderMode(0);
68  this->SetFrameFillColor(0);
69  this->SetCanvasBorderMode(0);
70  this->SetPadBorderMode(0);
71  this->SetPadColor(0);
72  this->SetCanvasColor(0);
73  this->SetTitleFillColor(0);
74  this->SetTitleBorderSize(1);
75  this->SetStatColor(0);
76  this->SetStatBorderSize(1);
77  this->SetLegendBorderSize(1);
78  // added
79  int myFont = 132;
80 // this->SetFillColor(0);
81  this->SetOptTitle(1);
82  this->SetTitleX(0.5);
83  this->SetTitleAlign(23);
84  this->SetTitleBorderSize(0);
85  this->SetLegendBorderSize(0);
86 
87  this->SetTitleFont(myFont);
88  this->SetOptFit(112);
89  this->SetOptStat("rmei");
90  this->SetStatFont(myFont);
91  this->SetStatX(0.9);
92  this->SetStatY(0.9);
93  this->SetStatW(0.2);
94  this->SetStatH(0.2);
95  this->SetTextFont(myFont);
96  this->SetLabelFont(myFont,"xyz");
97  this->SetTitleFont(myFont,"xyz");
98  this->SetTitleFont(myFont,"t"); // The font of the title
99  // proper of qprod
100  float size = 0.04;
101  this->SetLabelSize(size,"xyz"); // 0.04
102  this->SetTitleSize(size,"xyz"); // 0.04
103  this->SetPadBottomMargin(0.10);
104  this->SetPadLeftMargin(0.10);
105 
107 
108 }
109 QConferenceStyle::QConferenceStyle() : QStyle("qconf","DIANA conference style")
110 {
111  // taken from style "plain"
112  this->SetFrameBorderMode(0);
113  this->SetFrameFillColor(0);
114  this->SetCanvasBorderMode(0);
115  this->SetPadBorderMode(0);
116  this->SetPadColor(0);
117  this->SetCanvasColor(0);
118  this->SetTitleFillColor(0);
119  this->SetTitleBorderSize(1);
120  this->SetStatColor(0);
121  this->SetStatBorderSize(1);
122  this->SetLegendBorderSize(1);
123  int myFont = 132;
124  this->SetOptTitle(1);
125  this->SetTitleX(0.5);
126  this->SetTitleAlign(23);
127  this->SetTitleBorderSize(0);
128  this->SetLegendBorderSize(0);
129 
130  this->SetTitleFont(myFont);
131  this->SetOptFit(112);
132  this->SetOptStat("rmei");
133  this->SetStatFont(myFont);
134  this->SetStatX(0.93);
135  this->SetStatY(0.9);
136  this->SetStatW(0.2);
137  this->SetStatH(0.15);
138  this->SetTextFont(myFont);
139  this->SetLabelFont(myFont,"xyz");
140  this->SetTitleFont(myFont,"xyz");
141  this->SetTitleFont(myFont,"t"); // The font of the title
142  // proper of qprod
143  float size = 0.055;
144  this->SetLabelSize(size,"xyz");
145  this->SetTitleSize(size,"xyz");
146  this->SetPadBottomMargin(0.13);
147  this->SetPadLeftMargin(0.12);
148  this->SetPadRightMargin(0.07);
149 
150  this->SetTitleFontSize(.07);
151  this->SetLineWidth(2);
152  this->SetFrameLineWidth(2);
153  this->SetHistLineWidth(2);
154 
156 }
157 
158 
159 QPublicationStyle::QPublicationStyle() : QStyle("qpub","DIANA pubblication style")
160 {
161  TString name = this->GetName();
162  TString title = this->GetTitle();
163  // copy qpub
164  TStyle* prodStyle = gROOT->GetStyle("qprod");
165  TStyle* me = this;
166  (*me) = (*prodStyle);
167  this->SetName(name);
168  this->SetTitle(title);
169  // proper of qpub
170  this->SetOptTitle(0);
171  this->SetLabelSize(0.04,"xyz");
172  this->SetTitleSize(0.05,"xyz");
173  this->SetPadBottomMargin(0.11);
174  this->SetPadLeftMargin(0.1);
175  this->SetPadRightMargin(.02);
176  this->SetPadTopMargin(.02);
177 
178 
179 
181 }
182 
QVector b
Definition: CheckOF.C:21
ClassImp(QStyle) QStyle
Definition: QStyle.cc:10
Definition: QStyle.hh:6
virtual ~QStyle()
Definition: QStyle.cc:16
QStyle(const char *name="", const char *title="")
static void DrawDianaDate(const char *date="Today", Double_t xpos=.01, Double_t ypos=.01)
Definition: QStyle.cc:36
void LoadDefaultPalette()
Definition: QStyle.cc:18
QConferenceStyle * s3
Definition: QStyle.hh:51
QStyles()
Definition: QStyle.cc:53
~QStyles()
Definition: QStyle.cc:61
QPublicationStyle * s2
Definition: QStyle.hh:50
QProductionStyle * s1
Definition: QStyle.hh:49