Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 #include "TGo4WinCondPainter.h"
00015 
00016 #include "TVirtualPad.h"
00017 #include "RVersion.h"
00018 #include "TList.h"
00019 #include "TROOT.h"
00020 
00021 #include "TGo4WinCond.h"
00022 #include "TGo4WinCondView.h"
00023 
00024 TGo4WinCondPainter::TGo4WinCondPainter() :
00025    TGo4ConditionPainter(),
00026    fxBox(0)
00027 {
00028 }
00029 
00030 TGo4WinCondPainter::TGo4WinCondPainter(const char* name, const char* title) :
00031    TGo4ConditionPainter(name,title),
00032    fxBox(0)
00033 {
00034 }
00035 
00036 TGo4WinCondPainter::~TGo4WinCondPainter()
00037 {
00038    UnPaintCondition();
00039    if (fxBox!=0) {
00040       delete fxBox;
00041       fxBox = 0;
00042    }
00043 }
00044 
00045 
00046 void TGo4WinCondPainter::PaintCondition(Option_t* opt)
00047 {
00048 if(gPad==0) return;
00049 
00050 double xpmin=0;
00051 double xpmax=0;
00052 double ypmin=0;
00053 double ypmax=0;
00054 int dim=0;
00055 TGo4WinCond* wconny=dynamic_cast<TGo4WinCond*>(fxCondition);
00056 if(wconny && wconny->IsVisible())
00057    {
00058       wconny->GetValues(dim, xpmin, xpmax, ypmin, ypmax);
00059 
00060       
00061       
00062       
00063       if(xpmin>xpmax)
00064             {
00065                if(wconny->GetDimension()>1) 
00066                   wconny->SetValues(xpmax, xpmin, ypmin, ypmax );
00067                else
00068                   wconny->SetValues(xpmax, xpmin);
00069             }
00070       if(ypmin>ypmax)
00071             {
00072                if(wconny->GetDimension()>1) 
00073                   wconny->SetValues(xpmin, xpmax, ypmax, ypmin );
00074             }
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 #if ROOT_VERSION_CODE < ROOT_VERSION(4,3,2)
00084 
00085 
00086 
00087       xpmin=gPad->XtoPad(xpmin); 
00088       xpmax=gPad->XtoPad(xpmax);
00089       if(dim==1)
00090          {
00091             ypmin =gPad->GetUymin();
00092             ypmax =gPad->GetUymax();
00093          }
00094       else
00095          {
00096             ypmin=gPad->YtoPad(ypmin);
00097             ypmax=gPad->YtoPad(ypmax);
00098          }
00099 
00100 #else
00101       if(dim==1)
00102          {
00103             ypmin=gPad->PadtoY(gPad->GetUymin());
00104             ypmax=gPad->PadtoY(gPad->GetUymax());
00105          }
00106 #endif //__GO4ROOTVERSION__ < 40302
00107 
00108       if(fxBox==0 || gPad->GetListOfPrimitives()->FindObject(fxBox)==0)
00109       
00110          {
00111             fxBox= new TGo4WinCondView(xpmin,ypmin,xpmax, ypmax);
00112          }
00113       else
00114          {
00115              fxBox->SetX1(xpmin);
00116              fxBox->SetY1(ypmin);
00117              fxBox->SetX2(xpmax);
00118              fxBox->SetY2(ypmax);
00119          }
00120       fxBox->SetCondition(wconny);
00121       if(!strcmp(opt,"fixstyle"))
00122          {
00123             
00124             
00125             fxBox->SetLineWidth(wconny->GetLineWidth());
00126             fxBox->SetLineColor(wconny->GetLineColor());
00127             fxBox->SetLineStyle(wconny->GetLineStyle());
00128             fxBox->SetFillColor(wconny->GetFillColor());
00129             fxBox->SetFillStyle(wconny->GetFillStyle());
00130          }
00131       if(gPad->GetListOfPrimitives()->FindObject(fxBox)==0)
00132          {
00133             fxBox->SetLineWidth(wconny->GetLineWidth());
00134             fxBox->SetLineColor(wconny->GetLineColor());
00135             fxBox->SetLineStyle(wconny->GetLineStyle());
00136             fxBox->SetFillColor(wconny->GetFillColor());
00137             fxBox->SetFillStyle(wconny->GetFillStyle());
00138             fxBox->AppendPad(); 
00139                                 
00140             
00141          }
00142         fxBox->Paint(); 
00143         
00144 
00145    }
00146 else
00147    {
00148       UnPaintCondition();
00149    }
00150 }
00151 
00152 void TGo4WinCondPainter::UnPaintCondition(Option_t* opt)
00153 {
00154    gROOT->GetListOfCanvases()->RecursiveRemove(fxBox);
00155    
00156    TString option(opt);
00157    if(option.Contains("reset")) {
00158       
00159       delete fxBox;
00160       fxBox=0;
00161    }
00162 }
00163 
00164 void TGo4WinCondPainter::DisplayToFront(Option_t* opt)
00165 {
00166    if(fxBox) fxBox->Pop(); 
00167    TGo4LabelPainter::DisplayToFront(opt); 
00168 }