Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4ConditionPainter.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4ConditionPainter.h"
00017 
00018 #include "TVirtualPad.h"
00019 #include "TCutG.h"
00020 #include "TH1.h"
00021 #include "snprintf.h"
00022 
00023 #include "TGo4Condition.h"
00024 #include "TGo4WinCond.h"
00025 #include "TGo4PolyCond.h"
00026 
00027 TGo4ConditionPainter::TGo4ConditionPainter(const Text_t * name, const Text_t * title)
00028 : TGo4LabelPainter(name, title), fxCondition(0)
00029 {
00030 
00031 }
00032 
00033 TGo4ConditionPainter::TGo4ConditionPainter(const Text_t * name)
00034 : TGo4LabelPainter(name, "Go4 ConditionPainter"), fxCondition(0)
00035 {
00036 
00037 }
00038 
00039 TGo4ConditionPainter::TGo4ConditionPainter()
00040 : TGo4LabelPainter(), fxCondition(0)
00041 {
00042 
00043 }
00044 
00045 TGo4ConditionPainter::~TGo4ConditionPainter()
00046 {
00047    UnPaintCondition();
00048 }
00049 
00050 
00051 
00052 void TGo4ConditionPainter::PaintCondition(Option_t*)
00053 {
00054 
00055 
00056 }
00057 
00058 void TGo4ConditionPainter::UnPaintCondition(Option_t*)
00059 {
00060 
00061 
00062 }
00063 
00064 void TGo4ConditionPainter::PaintLabel(Option_t* opt)
00065 {
00066 if(gPad==0) return;
00067 if(fxCondition && fxCondition->IsVisible())
00068    {
00069    //------ find out initial coordinates for labels near condition boundaries:
00070    Double_t xpmin=0;
00071    Double_t ypmin=0;
00072    TGo4WinCond* wconny=dynamic_cast<TGo4WinCond*>(fxCondition);
00073    TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(fxCondition);
00074    if(wconny)
00075       {
00076          Double_t xpmax=0; Double_t ypmax=0; Int_t dim=0; // dummies here
00077          wconny->GetValues(dim, xpmin, xpmax, ypmin, ypmax);
00078          if(ypmin==0) ypmin=(gPad->GetUymax()-gPad->GetUymin())/2;
00079       }
00080    else if(pconny)
00081       {
00082           TCutG* cutg=pconny->GetCut(kFALSE);
00083           if(cutg) cutg->GetPoint(0,xpmin,ypmin);
00084       }
00085    else
00086       {
00087          xpmin=(gPad->GetUxmax()-gPad->GetUxmin())/2;
00088          ypmin=(gPad->GetUymax()-gPad->GetUymin())/2;
00089       }
00090 
00091    Bool_t haslabel=fxCondition->IsLabelDraw();
00092    Bool_t drlimits=fxCondition->IsLimitsDraw();
00093    Bool_t drint=fxCondition->IsIntDraw();
00094    Bool_t drxmean=fxCondition->IsXMeanDraw();
00095    Bool_t drxrms=fxCondition->IsXRMSDraw();
00096    Bool_t drymean=fxCondition->IsYMeanDraw();
00097    Bool_t dryrms=fxCondition->IsYRMSDraw();
00098    Bool_t drxmax=fxCondition->IsXMaxDraw();
00099    Bool_t drymax=fxCondition->IsYMaxDraw();
00100    Bool_t drcmax=fxCondition->IsCMaxDraw();
00101    Bool_t isarray=fxCondition->IsArrayType();
00102    Bool_t ismulti=fxCondition->IsMultiEdit();
00103    TH1* histogram=fxCondition->GetWorkHistogram();
00104    Text_t buffer[256];
00105    if((isarray && !ismulti) || !haslabel)
00106       {
00107          // no label: remove previous label
00108           UnPaintLabel();
00109       }
00110    else
00111       {
00112           // at least one to be displayed: optionally create new label
00113           Double_t xoff=0.015*(gPad->GetUxmax()-gPad->GetUxmin());
00114           Double_t yoff=0.015*(gPad->GetUymax()-gPad->GetUymin()); // these are in pad coordinates (for logscale)
00115           SetX0( gPad->PadtoX( gPad->XtoPad(xpmin) + xoff));
00116           SetY0( gPad->PadtoY( gPad->YtoPad(ypmin) + yoff)); // initial coords are in "real" axis scale
00117           SetLineColor(fxCondition->GetLineColor());
00118           TString cap=fxCondition->GetName();
00119           TH1* his=fxCondition->GetWorkHistogram();
00120           if(his)
00121             {
00122                cap+=":";      
00123                cap+=his->GetName();
00124             }
00125           SetCaption(cap.Data());
00126           TGo4LabelPainter::PaintLabel();// this creates new label at initial coords
00127          if(drlimits)
00128             {
00129                snprintf(buffer,256,"X1   = %.4E",fxCondition->GetXLow());
00130                AddToLabel(buffer);
00131                snprintf(buffer,256,"X2   = %.4E",fxCondition->GetXUp());
00132                AddToLabel(buffer);
00133                if(fxCondition->GetDimension()>1)
00134                {
00135                   snprintf(buffer,256,"Y1   = %.4E",fxCondition->GetYLow());
00136                   AddToLabel(buffer);
00137                   snprintf(buffer,256,"Y2   = %.4E",fxCondition->GetYUp());
00138                   AddToLabel(buffer);
00139                }
00140             }
00141          if(drint)
00142             {
00143                snprintf(buffer,256,"Int   = %.4E",fxCondition->GetIntegral(histogram));
00144                AddToLabel(buffer);
00145             }
00146          if(drxmean)
00147             {
00148                snprintf(buffer,256,"Xmean = %.4E",fxCondition->GetMean(histogram,1));
00149                AddToLabel(buffer);
00150             }
00151 
00152          if(drxrms)
00153             {
00154                snprintf(buffer,256,"Xrms  = %.4E",fxCondition->GetRMS(histogram,1));
00155                AddToLabel(buffer);
00156             }
00157          if(drxmax)
00158             {
00159                snprintf(buffer,256,"Xmax  = %.4E",fxCondition->GetXMax(histogram));
00160                AddToLabel(buffer);
00161             }
00162          if(drymean)
00163             {
00164                snprintf(buffer,256,"Ymean = %.4E",fxCondition->GetMean(histogram,2));
00165                AddToLabel(buffer);
00166             }
00167          if(dryrms)
00168             {
00169                snprintf(buffer,256,"Yrms  = %.4E",fxCondition->GetRMS(histogram,2));
00170                AddToLabel(buffer);
00171             }
00172          if(drymax)
00173             {
00174                snprintf(buffer,256,"Ymax  = %.4E",fxCondition->GetYMax(histogram));
00175                AddToLabel(buffer);
00176             }
00177          if(drcmax)
00178             {
00179                snprintf(buffer,256,"Cmax  = %.4E",fxCondition->GetCMax(histogram));
00180                AddToLabel(buffer);
00181             }
00182          RePaintLabel();
00183       }//if((isarray && !ismulti) || !haslabel)
00184    }//if(fxCondition && fxCondition->IsVisible())
00185 else
00186    {
00187       UnPaintLabel();
00188    }
00189 }
00190 
00191 void TGo4ConditionPainter::SetCondition(TGo4Condition* con)
00192 {
00193  fxCondition=con;
00194 }
00195 
00196 
00197 
00198 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:06 2008 for Go4-v3.04-1 by  doxygen 1.4.2