00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00047
00048
00049
00050
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
00071
00072
00073
00074
00075 static Bool_t ignoreNext=kFALSE;
00076 if(ignoreNext)
00077 {
00078
00079 ignoreNext=kFALSE;
00080 return;
00081 }
00082 if(event==kButton1Double)
00083 {
00084
00085 ignoreNext=kTRUE;
00086 return;
00087 }
00089 TCutG::ExecuteEvent(event,px,py);
00090 if(event==kButton1Up && fxPolyCondition)
00091 {
00092
00093 Pop();
00094 if(IsCutChanged())
00095 {
00096 UpdateCondition();
00097 }
00098 fxPolyCondition->ResetLabel("pop");
00099 }
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
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 }
00138 }
00139 }
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);
00157 if(source==0)
00158 SetPoint(0,0,0);
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