//*-- Author :    Damir Buskulic   20/10/00

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// VSPlot2                                                              //
//                                                                      //
// class describing a plot (representation) of a 2D series              //
// (time-frequency, video images)                                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "VManagerFrameL.h"
#include "VStyle.h"
#include "VSPlot2.h"
#include "VGPSTime.h"
#include "TPad.h"
//#include "TPaveStats.h"
#include "TLatex.h"
#include "TAxis.h"

const Int_t kNoStats     = BIT(9);
const Int_t kAxisRange   = BIT(11);

ClassImp(VSPlot2)

//______________________________________________________________________________
VSPlot2::VSPlot2() : TH2D()
{}

//______________________________________________________________________________
VSPlot2::VSPlot2(Text_t* name, Text_t* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup, VManager* mng)
           :TH2D(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
{
   mManager = mng;
   BuildVSP();
}

//______________________________________________________________________________
VSPlot2::VSPlot2(Text_t* name, Text_t* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup)
           :TH2D(name,title,nbinsx,xlow,xup,nbinsy,ylow,yup)
{
   mManager = 0;
   BuildVSP();
}

//______________________________________________________________________________
VSPlot2::VSPlot2(Text_t* name, Text_t* title, Int_t nbinsx, Axis_t* xbins, Int_t nbinsy, Axis_t* ybins)
           :TH2D(name,title,nbinsx,xbins,nbinsy,ybins)
{
   mManager = 0;
   BuildVSP();
}

//______________________________________________________________________________
VSPlot2::VSPlot2(VSPlot2 &vsplot2)
{
   ((VSPlot2&)vsplot2).Copy(*this);
   vsplot2.AdoptManager(0);
}

//______________________________________________________________________________
 void VSPlot2::Copy(TObject& newvsp2)
{
   TH2D::Copy((VSPlot2&)newvsp2);
   ((VSPlot2&)newvsp2).mGPSStart = mGPSStart;
   ((VSPlot2&)newvsp2).mStepX = mStepX;
   ((VSPlot2&)newvsp2).mStepY = mStepY;
   ((VSPlot2&)newvsp2).mLeapS = mLeapS;
   ((VSPlot2&)newvsp2).mLocalTime = mLocalTime;
   ((VSPlot2&)newvsp2).fStartTimeDisplay = fStartTimeDisplay;
   ((VSPlot2&)newvsp2).mStartTimeXOffset = mStartTimeXOffset;
   ((VSPlot2&)newvsp2).mStartTimeYOffset = mStartTimeYOffset;
   ((VSPlot2&)newvsp2).mUnitX = mUnitX.Data();
   ((VSPlot2&)newvsp2).mUnitY = mUnitY.Data();
   ((VSPlot2&)newvsp2).mUnitZ = mUnitZ.Data();
}

//______________________________________________________________________________
 void VSPlot2::BuildVSP()
{
// Builds the VSPlot and sets it's kCanDelete bit. Allows deletion of a plot
// if another one replaces it in the canvas.

   if (mManager) {
      SetBit(kCanDelete);
      mManager->GetListOfPlots2()->Add(this);
   }

// Sets the options
   if (gVStyle) {
      fStartTimeDisplay = gVStyle->GetStartTimeDisplay();
      mStartTimeXOffset = gVStyle->GetStartTimeXOffset();
      mStartTimeYOffset = gVStyle->GetStartTimeYOffset();
      fXaxis.SetTimeDisplay(gVStyle->GetTimeOnXAxis());
      fXaxis.SetTimeFormat(VGPSTime::ExpandFormat(gVStyle->GetTimeFormat()));
   } else {
      fStartTimeDisplay = 1;
      mStartTimeXOffset = 0.02;
      mStartTimeYOffset = 0.02;
   }

// Do not draw the stat box by default
   SetStats(0);
}
//______________________________________________________________________________
VSPlot2::~VSPlot2()
{
// VSPlot destructor. Also removes the entry concerning this plot
// in the original serie

   AbandonManager();
}

//______________________________________________________________________________
 void VSPlot2::AbandonManager()
{
// Removes this plot from the maintenance of the VEGA manager

   if (mManager) {
      mManager->RemovePlot2(GetName());
      mManager=0;
   }
}

//______________________________________________________________________________
 void VSPlot2::AdoptManager(VManager* mgr)
{
// Adopt the manager as the maintainer of this plot
   if (mManager) AbandonManager();
   mManager=mgr;
   if (mManager) mManager->GetListOfPlots2()->Add(this);
}

// ______________________________________________________________________________
 void VSPlot2::Paint(Option_t *option)
{
//*-*-*-*-*-*-*-*-*Control routine to paint the VSPlots*-*-*-*-*-*-*
//*-*              ===============================================
//
//  This function is automatically called by TCanvas::Update.
//  (see TH2::Draw for the list of options)
   
   TString t;
   Double_t tosave=0;
   Double_t timeoffsave=0;
   Double_t utctimeT;
   
   if (!fPainter) fPainter = TVirtualHistPainter::HistPainter(this);
   
   if (gPad->GetLogx()) {
//      bmsave = gPad->GetBottomMargin();
//      gPad->SetBottomMargin(bmsave+0.02);
      tosave = GetTitleOffset();
      SetTitleOffset(tosave+0.35);
   }

#if ROOT_VERSION_CODE <= ROOT_VERSION(3,5,2)
// If axis painting with time display, uses the frame start time as time offset
   if (GetXaxis()->GetTimeDisplay()) {
      timeoffsave = gVStyle->GetTimeOffset();
     // Transform gps time into utc time
      utctimeT = (mGPSStart.GetSec() - mLeapS + 19 + 315964800);
      if (strstr(gVStyle->GetStartTimeFormat(),"local")) {
         utctimeT += mLocalTime;
      }
      gVStyle->SetTimeOffset(utctimeT);
   }
#endif
      
   if (fPainter) {
     fPainter->Paint(option);
//  Painting the start time below axis
      if (fStartTimeDisplay) {
         TLatex* textstime = new TLatex();
         textstime->SetNDC(kTRUE);
         textstime->SetTextColor(fXaxis.GetLabelColor());
         textstime->SetTextFont(fXaxis.GetLabelFont());
         textstime->SetTextSize(fXaxis.GetLabelSize());
         textstime->SetX(mStartTimeXOffset);
         textstime->SetY(mStartTimeYOffset);
         textstime->SetTextAlign(12);
         if (strstr(gVStyle->GetStartTimeFormat(),"local") && mLocalTime>0 && mLocalTime<85300) {
            t = "local (this site) T0: ";
         } else {
            t = "GPS T0: ";
         }
         t = t + VGPSTime::ExpressTime(mGPSStart.GetTimeD(), gVStyle->GetStartTimeFormat(), mLeapS,mLocalTime);
         textstime->SetTitle(t.Data());
         textstime->Paint();
        delete textstime;
      }
   }
   if (gPad->GetLogx()) {
//      gPad->SetBottomMargin(bmsave);
      SetTitleOffset(tosave);
   }
#if ROOT_VERSION_CODE <= ROOT_VERSION(3,5,2)
// Restore ref. time in gVStyle
   if (GetXaxis()->GetTimeDisplay()) gVStyle->SetTimeOffset(timeoffsave);
#endif
}

//______________________________________________________________________________
 void VSPlot2::SetGPSStart(Double_t gpsstart)
{
// Set GPS time of the start of the X axis
   
   time_t utctime;
   
   mGPSStart = gpsstart;
#if ROOT_VERSION_CODE > ROOT_VERSION(3,5,2)
   if (gpsstart>0) {
     // Transform gps time into utc time
      utctime = (mGPSStart.GetSec() - mLeapS + 19 + 315964800);
      if (strstr(gVStyle->GetStartTimeFormat(),"local") && mLocalTime>0 && mLocalTime<85300) {
         utctime += mLocalTime;
      }
      struct tm* tg;
      tg = gmtime(&utctime);
      tg->tm_isdst = -1;
      GetXaxis()->SetTimeOffset(mktime(tg));
   }
#endif
}

//______________________________________________________________________________
 void VSPlot2::SetGPSStart(UInt_t gpsstartS, UInt_t gpsstartNS)
{
// Set GPS time of the start of the X axis
   
   time_t utctime;
   
   mGPSStart.SetSec(gpsstartS); mGPSStart.SetNsec(gpsstartNS);
#if ROOT_VERSION_CODE > ROOT_VERSION(3,5,2)
   if (gpsstartS>0) {
     // Transform gps time into utc time
      utctime = (mGPSStart.GetSec() - mLeapS + 19 + 315964800);
      if (strstr(gVStyle->GetStartTimeFormat(),"local") && mLocalTime>0 && mLocalTime<85300) {
         utctime += mLocalTime;
      }
      struct tm* tg;
      tg = gmtime(&utctime);
      tg->tm_isdst = -1;
      GetXaxis()->SetTimeOffset(mktime(tg));
   }
#endif
}


- ROOT page - VEGA page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to , or contact with any questions or problems regarding ROOT or VEGA.