#include "Riostream.h"
#include "TAttAxis.h"
#include "TStyle.h"
#include "TVirtualPad.h"
#include "TColor.h"
#include "TClass.h"
#include "TMathBase.h"
#include <stdlib.h>
ClassImp(TAttAxis)
TAttAxis::TAttAxis()
{
ResetAttAxis();
}
TAttAxis::~TAttAxis()
{
}
void TAttAxis::Copy(TAttAxis &attaxis) const
{
attaxis.fNdivisions = fNdivisions;
attaxis.fAxisColor = fAxisColor;
attaxis.fLabelColor = fLabelColor;
attaxis.fLabelFont = fLabelFont;
attaxis.fLabelOffset = fLabelOffset;
attaxis.fLabelSize = fLabelSize;
attaxis.fTickLength = fTickLength;
attaxis.fTitleOffset = fTitleOffset;
attaxis.fTitleSize = fTitleSize;
attaxis.fTitleColor = fTitleColor;
attaxis.fTitleFont = fTitleFont;
}
void TAttAxis::ResetAttAxis(Option_t *option)
{
if (gStyle) {
fNdivisions = gStyle->GetNdivisions(option);
fAxisColor = gStyle->GetAxisColor(option);
fLabelColor = gStyle->GetLabelColor(option);
fLabelFont = gStyle->GetLabelFont(option);
fLabelOffset = gStyle->GetLabelOffset(option);
fLabelSize = gStyle->GetLabelSize(option);
fTickLength = gStyle->GetTickLength(option);
fTitleOffset = gStyle->GetTitleOffset(option);
fTitleSize = gStyle->GetTitleSize(option);
fTitleColor = gStyle->GetTitleColor(option);
fTitleFont = gStyle->GetTitleFont(option);
} else {
fNdivisions = 510;
fAxisColor = 1;
fLabelColor = 1;
fLabelFont = 62;
fLabelOffset = 0.005;
fLabelSize = 0.04;
fTickLength = 0.03;
fTitleOffset = 1;
fTitleSize = fLabelSize;
fTitleColor = 1;
fTitleFont = 62;
}
}
void TAttAxis::SaveAttributes(ostream &out, const char *name, const char *subname)
{
if (fNdivisions != 510) {
out<<" "<<name<<subname<<"->SetNdivisions("<<fNdivisions<<");"<<endl;
}
if (fAxisColor != 1) {
if (fAxisColor > 228) {
TColor::SaveColor(out, fAxisColor);
out<<" "<<name<<subname<<"->SetAxisColor(ci);" << endl;
} else
out<<" "<<name<<subname<<"->SetAxisColor("<<fAxisColor<<");"<<endl;
}
if (fLabelColor != 1) {
if (fLabelColor > 228) {
TColor::SaveColor(out, fLabelColor);
out<<" "<<name<<subname<<"->SetLabelColor(ci);" << endl;
} else
out<<" "<<name<<subname<<"->SetLabelColor("<<fLabelColor<<");"<<endl;
}
if (fLabelFont != 62) {
out<<" "<<name<<subname<<"->SetLabelFont("<<fLabelFont<<");"<<endl;
}
if (TMath::Abs(fLabelOffset-0.005) > 0.0001) {
out<<" "<<name<<subname<<"->SetLabelOffset("<<fLabelOffset<<");"<<endl;
}
if (TMath::Abs(fLabelSize-0.04) > 0.001) {
out<<" "<<name<<subname<<"->SetLabelSize("<<fLabelSize<<");"<<endl;
}
if (TMath::Abs(fTitleSize-0.04) > 0.001) {
out<<" "<<name<<subname<<"->SetTitleSize("<<fTitleSize<<");"<<endl;
}
if (TMath::Abs(fTickLength-0.03) > 0.001) {
out<<" "<<name<<subname<<"->SetTickLength("<<fTickLength<<");"<<endl;
}
if (TMath::Abs(fTitleOffset-1) > 0.001) {
out<<" "<<name<<subname<<"->SetTitleOffset("<<fTitleOffset<<");"<<endl;
}
if (fTitleColor != 1) {
if (fTitleColor > 228) {
TColor::SaveColor(out, fTitleColor);
out<<" "<<name<<subname<<"->SetTitleColor(ci);" << endl;
} else
out<<" "<<name<<subname<<"->SetTitleColor("<<fTitleColor<<");"<<endl;
}
if (fTitleFont != 62) {
out<<" "<<name<<subname<<"->SetTitleFont("<<fTitleFont<<");"<<endl;
}
}
void TAttAxis::SetAxisColor(Color_t color, Float_t alpha)
{
if (alpha<1.) fAxisColor = TColor::GetColorTransparent(color, alpha);
else fAxisColor = color;
if (gPad) gPad->Modified();
}
void TAttAxis::SetLabelColor(Color_t color, Float_t alpha)
{
if (alpha<1.) fLabelColor = TColor::GetColorTransparent(color, alpha);
else fLabelColor = color;
if (gPad) gPad->Modified();
}
void TAttAxis::SetLabelFont(Style_t font)
{
fLabelFont = font;
if (gPad) gPad->Modified();
}
void TAttAxis::SetLabelOffset(Float_t offset)
{
fLabelOffset = offset;
if (gPad) gPad->Modified();
}
void TAttAxis::SetLabelSize(Float_t size)
{
fLabelSize = size;
if (gPad) gPad->Modified();
}
void TAttAxis::SetNdivisions(Int_t n, Bool_t optim)
{
fNdivisions = n;
if (!optim) fNdivisions = -abs(n);
if (gPad) gPad->Modified();
}
void TAttAxis::SetNdivisions(Int_t n1, Int_t n2, Int_t n3, Bool_t optim)
{
SetNdivisions(n1+100*n2+10000*n3, optim);
}
void TAttAxis::SetTickLength(Float_t length)
{
fTickLength = length;
if (gPad) gPad->Modified();
}
void TAttAxis::SetTitleOffset(Float_t offset)
{
fTitleOffset = offset;
if (gPad) gPad->Modified();
}
void TAttAxis::SetTitleSize(Float_t size)
{
fTitleSize = size;
if (gPad) gPad->Modified();
}
void TAttAxis::SetTitleColor(Color_t color)
{
fTitleColor = color;
if (gPad) gPad->Modified();
}
void TAttAxis::SetTitleFont(Style_t font)
{
fTitleFont = font;
if (gPad) gPad->Modified();
}
void TAttAxis::Streamer(TBuffer &R__b)
{
if (R__b.IsReading()) {
UInt_t R__s, R__c;
Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
if (R__v > 3) {
R__b.ReadClassBuffer(TAttAxis::Class(), this, R__v, R__s, R__c);
return;
}
R__b >> fNdivisions;
R__b >> fAxisColor;
R__b >> fLabelColor;
R__b >> fLabelFont;
R__b >> fLabelOffset;
R__b >> fLabelSize;
R__b >> fTickLength;
R__b >> fTitleOffset;
if (R__v > 1 && R__b.GetVersionOwner() > 900)
R__b >> fTitleSize;
else
fTitleSize = fLabelSize;
if (R__v > 2) {
R__b >> fTitleColor;
R__b >> fTitleFont;
}
} else {
R__b.WriteClassBuffer(TAttAxis::Class(),this);
}
}