Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4PolyCondView.h"
00015
00016 #include "TCutG.h"
00017 #include "TPad.h"
00018 #include "Buttons.h"
00019
00020 #include "TGo4PolyCond.h"
00021
00022 TGo4PolyCondView::TGo4PolyCondView(TCutG* source) :
00023 TCutG(), fxPolyCondition(0)
00024 {
00025 SetCut(source);
00026 SetBit(kMustCleanup);
00027 }
00028
00029 TGo4PolyCondView::TGo4PolyCondView() :
00030 TCutG(), fxPolyCondition(0)
00031 {
00032 SetBit(kMustCleanup);
00033 }
00034
00035 TGo4PolyCondView::~TGo4PolyCondView()
00036 {
00037 }
00038
00039 void TGo4PolyCondView::Paint(Option_t* opt)
00040 {
00041 if(fxPolyCondition) TCutG::Paint(opt);
00042
00043
00044
00045
00046
00047 }
00048
00049 Int_t TGo4PolyCondView::InsertPoint()
00050 {
00051 Int_t rev = TGraph::InsertPoint();
00052 UpdateCondition();
00053 return rev;
00054 }
00055
00056 Int_t TGo4PolyCondView::RemovePoint()
00057 {
00058 Int_t rev = TGraph::RemovePoint();
00059 UpdateCondition();
00060 return rev;
00061 }
00062
00063 void TGo4PolyCondView::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00064 {
00066
00067
00068
00069
00070
00071 static Bool_t ignoreNext=kFALSE;
00072 if(ignoreNext)
00073 {
00074
00075 ignoreNext=kFALSE;
00076 return;
00077 }
00078 if(event==kButton1Double)
00079 {
00080
00081 ignoreNext=kTRUE;
00082 return;
00083 }
00085 TCutG::ExecuteEvent(event,px,py);
00086 if(event==kButton1Up && fxPolyCondition)
00087 {
00088
00089 Pop();
00090 if(IsCutChanged())
00091 {
00092 UpdateCondition();
00093 }
00094 fxPolyCondition->ResetLabel("pop");
00095 }
00096 }
00097
00098 Bool_t TGo4PolyCondView::IsCutChanged()
00099 {
00100 if(fxPolyCondition==0) return kFALSE;
00101 Bool_t needsupdate=kFALSE;
00102 Double_t epsilon=fxPolyCondition->GetUpdateEpsilon();
00103 TCutG* concut=fxPolyCondition->GetCut(kFALSE);
00104
00105 if(concut)
00106 {
00107 Int_t oldmaxpoints=concut->GetN();
00108 Int_t newmaxpoints=GetN();
00109 if(oldmaxpoints!=newmaxpoints)
00110 {
00111 needsupdate=kTRUE;
00112 }
00113 else
00114 {
00115 for(Int_t point=0; point<oldmaxpoints; ++point)
00116 {
00117 Double_t xn=0;
00118 Double_t yn=0;
00119 Double_t xo=0;
00120 Double_t yo=0;
00121 concut->GetPoint(point,xo,yo);
00122 GetPoint(point,xn,yn);
00123 if(TMath::Abs(xo-xn) > epsilon)
00124 {
00125 needsupdate=kTRUE;
00126 break;
00127 }
00128 if(TMath::Abs(yo-yn) > epsilon)
00129 {
00130 needsupdate=kTRUE;
00131 break;
00132 }
00133 }
00134 }
00135 }
00136 return needsupdate;
00137 }
00138
00139 void TGo4PolyCondView::UpdateCondition()
00140 {
00141 if(fxPolyCondition==0) return;
00142 TCutG* ccut = CreateCut();
00143 fxPolyCondition->SetValues(ccut);
00144 delete ccut;
00145 TGo4PolyCond::CleanupSpecials();
00146 fxPolyCondition->SetChanged(kTRUE);
00147 }
00148
00149
00150 void TGo4PolyCondView::SetCut(TCutG* source)
00151 {
00152 Set(0);
00153 if(source==0)
00154 SetPoint(0,0,0);
00155 else {
00156 Int_t pn=source->GetN();
00157 Double_t xp=0;
00158 Double_t yp=0;
00159 for(Int_t i=0; i<pn; ++i) {
00160 source->GetPoint(i,xp,yp);
00161 SetPoint(i,xp,yp);
00162 }
00163 }
00164 }
00165
00166 TCutG* TGo4PolyCondView::CreateCut()
00167 {
00168 TCutG* result = new TCutG;
00169 result->SetBit(kMustCleanup);
00170 Int_t pn = GetN();
00171 Double_t xp=0;
00172 Double_t yp=0;
00173 for(Int_t i=0; i<pn; ++i) {
00174 GetPoint(i,xp,yp);
00175 result->SetPoint(i,xp,yp);
00176 }
00177 result->SetLineColor(GetLineColor());
00178 result->SetLineWidth(GetLineWidth());
00179 result->SetLineStyle(GetLineStyle());
00180 result->SetFillColor(GetFillColor());
00181 result->SetFillStyle(GetFillStyle());
00182 return result;
00183 }
00184
00185 const char* TGo4PolyCondView::GetName() const
00186 {
00187 if(fxPolyCondition)
00188 return (fxPolyCondition->GetName());
00189 else
00190 return 0;
00191 }
00192
00193 void TGo4PolyCondView::SetName(const char* nam)
00194 {
00195 if(fxPolyCondition) fxPolyCondition->SetName(nam);
00196 }
00197
00198 void TGo4PolyCondView::SetLabelDraw(Bool_t on)
00199 {
00200 if(fxPolyCondition) fxPolyCondition->SetLabelDraw(on);
00201 }
00202 void TGo4PolyCondView::SetLimitsDraw(Bool_t on)
00203 {
00204 if(fxPolyCondition) fxPolyCondition->SetLimitsDraw(on);
00205 }
00206
00207 void TGo4PolyCondView::SetIntDraw(Bool_t on)
00208 {
00209 if(fxPolyCondition) fxPolyCondition->SetIntDraw(on);
00210 }
00211
00212 void TGo4PolyCondView::SetXMeanDraw(Bool_t on)
00213 {
00214 if(fxPolyCondition) fxPolyCondition->SetXMeanDraw(on);
00215 }
00216
00217 void TGo4PolyCondView::SetYMeanDraw(Bool_t on)
00218 {
00219 if(fxPolyCondition) fxPolyCondition->SetYMeanDraw(on);
00220 }
00221
00222 void TGo4PolyCondView::SetXRMSDraw(Bool_t on)
00223 {
00224 if(fxPolyCondition) fxPolyCondition->SetXRMSDraw(on);
00225 }
00226
00227 void TGo4PolyCondView::SetYRMSDraw(Bool_t on)
00228 {
00229 if(fxPolyCondition) fxPolyCondition->SetYRMSDraw(on);
00230 }
00231
00232 void TGo4PolyCondView::SetXMaxDraw(Bool_t on)
00233 {
00234 if(fxPolyCondition) fxPolyCondition->SetXMaxDraw(on);
00235 }
00236
00237 void TGo4PolyCondView::SetYMaxDraw(Bool_t on)
00238 {
00239 if(fxPolyCondition) fxPolyCondition->SetYMaxDraw(on);
00240 }
00241
00242 void TGo4PolyCondView::SetCMaxDraw(Bool_t on)
00243 {
00244 if(fxPolyCondition) fxPolyCondition->SetCMaxDraw(on);
00245 }
00246
00247 void TGo4PolyCondView::DeleteRegion()
00248 {
00249 if(fxPolyCondition && !fxPolyCondition->IsOwnedByEditor()) fxPolyCondition->Delete("");
00250 }
00251
00252 void TGo4PolyCondView::SaveLabelStyle()
00253 {
00254 if(fxPolyCondition) fxPolyCondition->SaveLabelStyle();
00255 }
00256
00257 void TGo4PolyCondView::ResetLabel()
00258 {
00259 if(fxPolyCondition) fxPolyCondition->ResetLabel();
00260 }