Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4ConditionsBase/TGo4WinCondPainter.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 "TGo4WinCondPainter.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TVirtualPad.h"
00021 
00022 #include "TGo4WinCond.h"
00023 #include "TGo4WinCondView.h"
00024 
00025 TGo4WinCondPainter::TGo4WinCondPainter(const Text_t * name, const Text_t * title)
00026 : TGo4ConditionPainter(name,title), fxBox(0)
00027 {
00028 
00029 }
00030 
00031 TGo4WinCondPainter::TGo4WinCondPainter(const Text_t * name)
00032 : TGo4ConditionPainter(name,"Go4 window condition"), fxBox(0)
00033 {
00034 
00035 }
00036 
00037 TGo4WinCondPainter::TGo4WinCondPainter()
00038 : TGo4ConditionPainter(), fxBox(0)
00039 {
00040 
00041 }
00042 
00043 TGo4WinCondPainter::~TGo4WinCondPainter()
00044 {
00045    UnPaintCondition();
00046 }
00047 
00048 
00049 void TGo4WinCondPainter::PaintCondition(Option_t* opt)
00050 {
00051 if(gPad==0) return;
00052 //cout <<"WinCondPainter PaintCondition on gPad "<<gPad << endl;
00053 //cout <<"TGo4WinCondPainter::PaintCondition "<<GetName() << endl;
00054 double xpmin=0;
00055 double xpmax=0;
00056 double ypmin=0;
00057 double ypmax=0;
00058 int dim=0;
00059 TGo4WinCond* wconny=dynamic_cast<TGo4WinCond*>(fxCondition);
00060 if(wconny && wconny->IsVisible())
00061    {
00062       wconny->GetValues(dim, xpmin, xpmax, ypmin, ypmax);
00063 
00064       // for loaded window conditions, we have to correct limits
00065       // otherwise, this would yield wrong statistics from work histogram
00066       // root would correct box limits only on first edge resize!
00067       if(xpmin>xpmax)
00068             {
00069                if(wconny->GetDimension()>1) // keep dimension!
00070                   wconny->SetValues(xpmax, xpmin, ypmin, ypmax );
00071                else
00072                   wconny->SetValues(xpmax, xpmin);
00073             }
00074       if(ypmin>ypmax)
00075             {
00076                if(wconny->GetDimension()>1) // keep dimension!
00077                   wconny->SetValues(xpmin, xpmax, ypmax, ypmin );
00078             }
00079 
00080 //      cout <<"\nBefore toPad:"<< endl;
00081 //      cout <<" xpmin="<<xpmin << endl;
00082 //      cout <<" xpmax="<<xpmax << endl;
00083 //      cout <<" ypmin="<<ypmin << endl;
00084 //      cout <<" ypmax="<<ypmax << endl;
00085 
00086 // note: newer root versions treat log scale correctly in TBox
00087 #if __GO4ROOTVERSION__ < 40302
00088       
00089       xpmin=gPad->XtoPad(xpmin); // for case of log scale
00090       xpmax=gPad->XtoPad(xpmax);
00091       if(dim==1)
00092          {
00093             ypmin =gPad->GetUymin();
00094             ypmax =gPad->GetUymax();
00095          }
00096       else
00097          {
00098             ypmin=gPad->YtoPad(ypmin);
00099             ypmax=gPad->YtoPad(ypmax);
00100          }
00101 
00102 #else         
00103       if(dim==1)
00104          {
00105             ypmin=gPad->PadtoY(gPad->GetUymin());
00106             ypmax=gPad->PadtoY(gPad->GetUymax());
00107          }
00108 #endif //__GO4ROOTVERSION__ < 40302         
00109       
00110       if(fxBox==0 || gPad->GetListOfPrimitives()->FindObject(fxBox)==0)
00111       // user might have deleted box from pad by mouse even if fxBox!=0
00112          {
00113             fxBox= new TGo4WinCondView(xpmin,ypmin,xpmax, ypmax);
00114          }
00115       else
00116          {
00117              fxBox->SetX1(xpmin);
00118              fxBox->SetY1(ypmin);
00119              fxBox->SetX2(xpmax);
00120              fxBox->SetY2(ypmax);
00121          }
00122       fxBox->SetCondition(wconny);
00123       if(!strcmp(opt,"fixstyle"))
00124          {
00125             // reproduce condition colors always
00126             // this mode will prevent the user from changing box color interactively
00127             fxBox->SetLineWidth(wconny->GetLineWidth());
00128             fxBox->SetLineColor(wconny->GetLineColor());
00129             fxBox->SetLineStyle(wconny->GetLineStyle());
00130             fxBox->SetFillColor(wconny->GetFillColor());
00131             fxBox->SetFillStyle(wconny->GetFillStyle());
00132          }
00133       if(gPad->GetListOfPrimitives()->FindObject(fxBox)==0)
00134          {
00135             fxBox->SetLineWidth(wconny->GetLineWidth());
00136             fxBox->SetLineColor(wconny->GetLineColor());
00137             fxBox->SetLineStyle(wconny->GetLineStyle());
00138             fxBox->SetFillColor(wconny->GetFillColor());
00139             fxBox->SetFillStyle(wconny->GetFillStyle());
00140             fxBox->AppendPad(); // only append to pad if not already there
00141                                 // this is necessary for the Pop() in array painter
00142          }
00143         fxBox->Paint(); // for condarrays
00144         //cout <<"------WinCondPainter PaintCondition painted box" << endl;
00145 
00146    }// if(wconny && wconny->IsVisible())
00147 else
00148    {
00149       UnPaintCondition();
00150    }
00151 }
00152 
00153 void TGo4WinCondPainter::UnPaintCondition(Option_t* opt)
00154 {
00155 if(gPad==0) return;
00156 //cout <<"WinCondPainter UnPaintCondition removing box from pad " << gPad << endl;
00157 if(gPad->GetListOfPrimitives()->Remove(fxBox)!=0)
00158 {
00159    // we do not delete view, but restore graphics properties though invisible
00160    TString option=opt;
00161    if(option.Contains("reset"))
00162       {
00163          // case of reset option: discard old label geometry
00164          delete fxBox;
00165          fxBox=0;
00166       }
00167 }
00168 }
00169 
00170 ClassImp(TGo4WinCondPainter)
00171 
00172 
00173 
00174 
00175 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:52 2005 for Go4-v2.10-5 by doxygen1.2.15