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

/Go4ConditionsBase/TGo4PolyCondView.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 "TGo4PolyCondView.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "TCutG.h"
00021 #include "TPad.h"
00022 #include "Buttons.h"
00023 
00024 #include "TGo4PolyCond.h"
00025 
00026 TGo4PolyCondView::TGo4PolyCondView(TCutG* source)
00027    :TCutG(), fxPolyCondition(0)
00028 {
00029    SetCut(source);
00030 }
00031 
00032 TGo4PolyCondView::TGo4PolyCondView()
00033    :TCutG(), fxPolyCondition(0)
00034 {
00035 
00036 }
00037 
00038 TGo4PolyCondView::~TGo4PolyCondView()
00039 {
00040 }
00041 
00042 void TGo4PolyCondView::Paint(Option_t* opt)
00043 {
00044 if(fxPolyCondition) TCutG::Paint(opt);
00045 // we have a valid condition set from painter.Otherwise,
00046 // suppress painting of condition view without owner. This case
00047 // happens after inserting canvas in go4 (separate cloning
00048 // of lists of primitive members), thus leading to a
00049 // second "ghost condition polygon"
00050 
00051 }
00052 
00053 void TGo4PolyCondView::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00054 {
00056 // the following is necessary to avoid bug in ROOT TGraph::ExecuteEvent
00057 // that does not handle the kButton1Up after kButton1Double
00058 // (temporary coordinates array not allocated for button double,
00059 // thus crash in button up)
00060 // we supress the button up event after button double for the moment...
00061 static Bool_t ignoreNext=kFALSE;
00062 if(ignoreNext)
00063    {
00064       //cout <<"PolyCondView supressing event "<<event << endl;
00065       ignoreNext=kFALSE;
00066       return;
00067    }
00068 if(event==kButton1Double)
00069    {
00070       //cout <<"PolyCondView supressing double click" << endl;
00071       ignoreNext=kTRUE;
00072       return;
00073    }
00075 TCutG::ExecuteEvent(event,px,py);
00076 if(event==kButton1Up && fxPolyCondition)
00077    {
00078       Pop(); // do condition under edit into foreground, for condarray
00079       if(IsCutChanged()) UpdateCondition();
00080    }// if(event==...)
00081 }
00082 
00083 Bool_t TGo4PolyCondView::IsCutChanged()
00084 {
00085 if(fxPolyCondition==0) return kFALSE;
00086 Bool_t needsupdate=kFALSE;
00087 Double_t epsilon=fxPolyCondition->GetUpdateEpsilon();
00088 TCutG* concut=fxPolyCondition->GetCut(kFALSE);
00089 // check if update is needed:
00090 if(concut)
00091    {
00092       Int_t oldmaxpoints=concut->GetN();
00093       Int_t newmaxpoints=GetN();
00094       if(oldmaxpoints!=newmaxpoints)
00095          {
00096              needsupdate=kTRUE;
00097          }
00098       else
00099          {
00100             for(Int_t point=0; point<oldmaxpoints; ++point)
00101                {
00102                  Double_t xn=0;
00103                  Double_t yn=0;
00104                  Double_t xo=0;
00105                  Double_t yo=0;
00106                  concut->GetPoint(point,xo,yo);
00107                  GetPoint(point,xn,yn);
00108                  if(TMath::Abs(xo-xn) > epsilon)
00109                      {
00110                         needsupdate=kTRUE;
00111                         break;
00112                      }
00113                  if(TMath::Abs(yo-yn) > epsilon)
00114                      {
00115                         needsupdate=kTRUE;
00116                         break;
00117                      }
00118                }//for
00119          } // if(oldmaxpoints!=...)
00120    }// if(concut)
00121 return needsupdate;
00122 }
00123 
00124 void TGo4PolyCondView::UpdateCondition()
00125 {
00126  if(fxPolyCondition==0) return;
00127  TCutG* ccut=CreateCut();
00128  fxPolyCondition->SetValues(ccut);
00129  delete ccut;
00130  TGo4PolyCond::CleanupSpecials();
00131  fxPolyCondition->SetChanged(kTRUE);
00132 }
00133 
00134 
00135 void TGo4PolyCondView::SetCut(TCutG* source)
00136 {
00137 Set(0); // clear array of points
00138 if(source==0)
00139    {
00140       SetPoint(0,0,0); //dummy to suppress empty graph warnings
00141    }
00142 else
00143    {
00144    Int_t pn=source->GetN();
00145    Double_t xp=0;
00146    Double_t yp=0;
00147    for(Int_t i=0; i<pn; ++i)
00148       {
00149         source->GetPoint(i,xp,yp);
00150         SetPoint(i,xp,yp);
00151       }
00152    }
00153 }
00154 
00155 TCutG* TGo4PolyCondView::CreateCut()
00156 {
00157 TCutG* result=new TCutG;
00158 Int_t pn=GetN();
00159 Double_t xp=0;
00160 Double_t yp=0;
00161 for(Int_t i=0; i<pn; ++i)
00162    {
00163      GetPoint(i,xp,yp);
00164      result->SetPoint(i,xp,yp);
00165    }
00166 result->SetLineColor(GetLineColor());
00167 result->SetLineWidth(GetLineWidth());
00168 result->SetLineStyle(GetLineStyle());
00169 result->SetFillColor(GetFillColor());
00170 result->SetFillStyle(GetFillStyle());
00171 return result;
00172 }
00173 
00174 const char* TGo4PolyCondView::GetName() const
00175 {
00176    if(fxPolyCondition)
00177       return (fxPolyCondition->GetName());
00178    else
00179       return 0;
00180 }
00181 
00182 void TGo4PolyCondView::SetName(const Text_t* nam)
00183 {
00184    if(fxPolyCondition) fxPolyCondition->SetName(nam);
00185 }
00186 
00187 void TGo4PolyCondView::SetLabelDraw(Bool_t on)
00188 {
00189    if(fxPolyCondition) fxPolyCondition->SetLabelDraw(on);
00190 }
00191 void TGo4PolyCondView::SetLimitsDraw(Bool_t on)
00192 {
00193    if(fxPolyCondition) fxPolyCondition->SetLimitsDraw(on);
00194 }
00195 
00196 void TGo4PolyCondView::SetIntDraw(Bool_t on)
00197 {
00198    if(fxPolyCondition) fxPolyCondition->SetIntDraw(on);
00199 }
00200 
00201 void TGo4PolyCondView::SetXMeanDraw(Bool_t on)
00202 {
00203    if(fxPolyCondition) fxPolyCondition->SetXMeanDraw(on);
00204 }
00205 
00206 void TGo4PolyCondView::SetYMeanDraw(Bool_t on)
00207 {
00208    if(fxPolyCondition) fxPolyCondition->SetYMeanDraw(on);
00209 }
00210 
00211 void TGo4PolyCondView::SetXRMSDraw(Bool_t on)
00212 {
00213    if(fxPolyCondition) fxPolyCondition->SetXRMSDraw(on);
00214 }
00215 
00216 void TGo4PolyCondView::SetYRMSDraw(Bool_t on)
00217 {
00218    if(fxPolyCondition) fxPolyCondition->SetYRMSDraw(on);
00219 }
00220 
00221 void TGo4PolyCondView::SetXMaxDraw(Bool_t on)
00222 {
00223    if(fxPolyCondition) fxPolyCondition->SetXMaxDraw(on);
00224 }
00225 
00226 void TGo4PolyCondView::SetYMaxDraw(Bool_t on)
00227 {
00228    if(fxPolyCondition) fxPolyCondition->SetYMaxDraw(on);
00229 }
00230 
00231 void TGo4PolyCondView::SetCMaxDraw(Bool_t on)
00232 {
00233    if(fxPolyCondition) fxPolyCondition->SetCMaxDraw(on);
00234 }
00235 
00236 void TGo4PolyCondView::DeleteRegion()
00237 {
00238    if(fxPolyCondition && !fxPolyCondition->IsOwnedByEditor()) fxPolyCondition->Delete("");
00239 }
00240 
00241 void TGo4PolyCondView::SaveLabelStyle()
00242 {
00243    if(fxPolyCondition) fxPolyCondition->SaveLabelStyle();
00244 }
00245 
00246 void TGo4PolyCondView::ResetLabel()
00247 {
00248    if(fxPolyCondition) fxPolyCondition->ResetLabel();
00249 }
00250 
00251 
00252 ClassImp(TGo4PolyCondView)
00253 
00254 
00255 
00256 
00257 //----------------------------END OF GO4 SOURCE FILE ---------------------

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