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

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

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