00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4WindowEditSlots.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TPad.h"
00021 #include "TCanvas.h"
00022 #include "TPaveText.h"
00023 #include "TRefArray.h"
00024
00025 #include "Go4GUIRegistry/TGo4GUIRegistry.h"
00026 #include "Go4LockGuard/TGo4LockGuard.h"
00027 #include "Go4StatusBase/TGo4Status.h"
00028 #include "Go4ConditionsBase/TGo4Condition.h"
00029 #include "Go4ConditionsBase/TGo4CondArray.h"
00030 #include "Go4ConditionsBase/TGo4WinCond.h"
00031 #include "Go4ConditionsBase/TGo4PolyCond.h"
00032 #include "Go4CommandsAnalysis/TGo4ComGetObject.h"
00033 #include "Go4CommandsAnalysis/TGo4ComGetCondition.h"
00034 #include "Go4CommandsAnalysis/TGo4ComSetCondition.h"
00035 #include "TGo4WindowEdit.h"
00036 #include "TGo4PreviewPanel.h"
00037 #include "TGo4PreviewPanelSlots.h"
00038 #include "TGo4PadOptions.h"
00039 #include "TGo4MainWindow.h"
00040 #include "TGo4BrowserSlots.h"
00041 #include "TGo4Browser.h"
00042 #include "Go4QtBaseWidgets/TGo4QItem.h"
00043 #include "Go4QtBaseWidgets/TGo4QPicItem.h"
00044 #include "TGo4WindowEditStatus.h"
00045
00046 TGo4WindowEditSlots::TGo4WindowEditSlots(const char * name, const char * title, TGo4WindowEdit * p)
00047 :TGo4SlotsBaseClass(name , title),
00048 fxTGo4GUIRegistry(0),fxTGo4WindowEdit(p),fxTGo4WindowEditStatus(0),
00049 fxView(0),fxWorkView(0), fiCurrentPad(0), fiNumPads(1), fxHisto(0),
00050 fbHideAll(kFALSE),
00051 fiMouseMode(kMouseROOT),
00052 fbPickArray(kFALSE), fuPickCounter(0),
00053 fbInitDone(kFALSE), fbNeedsUpdate(kFALSE)
00054
00055 {
00056 TGo4LockGuard Global;
00057 fxPad.clear();
00058 for(Int_t ix=0; ix<fiNumPads; ++ix) fxPad.push_back(0);
00059 char StatusName[256];
00060 fxTGo4GUIRegistry=TGo4GUIRegistry::Instance();
00061 snprintf(StatusName,255,"%s%s",name,"_Status" );
00062 fxTGo4WindowEditStatus= new TGo4WindowEditStatus(StatusName, "Cond. Status");
00063 fxTGo4WindowEditStatus->SetSlot(this);
00064 fxTGo4GUIRegistry->RegisterSlotClass(this, fxTGo4WindowEditStatus, p);
00065 TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
00066 mw->RegisterWindowEditSlots(this);
00067 }
00068
00069 TGo4WindowEditSlots::~TGo4WindowEditSlots()
00070 {
00071 TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
00072 mw->UnregisterWindowEditSlots(this);
00073
00074 TGo4PreviewPanelSlots* wvslots=0;
00075 if(fxWorkView) wvslots=fxWorkView->GetSlots();
00076 if(wvslots) wvslots->SetMouseMode(kMouseROOT);
00077 TPad* wpad=WorkingPad();
00078 if(wpad)
00079 {
00080 TPad* savepad= (TPad*) gPad;
00081 wpad->cd();
00082 delete fxTGo4WindowEditStatus;
00083 wpad->Modified();
00084 wpad->Update();
00085 savepad->cd();
00086 }
00087 else
00088 {
00089
00090 delete fxTGo4WindowEditStatus;
00091 }
00092
00093 }
00094
00095 TGo4Status* TGo4WindowEditSlots::GetStatus()
00096 {
00097 return fxTGo4WindowEditStatus;
00098 }
00099
00100
00101 void TGo4WindowEditSlots::AddObject(TNamed *fxData)
00102 {
00103 if(fxData==0) return;
00104 TGo4LockGuard Global;
00105
00106 TGo4Condition* condi=0;
00107 if(fxData->InheritsFrom("TGo4Condition"))
00108 {
00109 condi=dynamic_cast <TGo4Condition*> (fxData->Clone());
00110 if(fxTGo4WindowEdit==0)
00111 {
00112 fxTGo4WindowEdit= new TGo4WindowEdit(fxTGo4GUIRegistry->GetCentralWindow(),fxData->GetName());
00113 fxTGo4WindowEdit->show();
00114 }
00115 else {}
00116 }
00117 else
00118 {
00119 condi=0;
00120 }
00121 ClearConditions(kFALSE);
00122 fxTGo4WindowEditStatus->SetCondition(condi);
00123 fbNeedsUpdate=kFALSE;
00124
00125 if(condi && condi->IsHistogramLink() && !fxTGo4WindowEdit->IsCentralMode())
00126 {
00127 const Text_t* hname=condi->GetLinkedHistogram();
00128
00129 TPad* pad=0;
00130 TCanvas *can=0;
00131 TGo4PreviewPanel* viewpanel=0;
00132 TGo4BrowserSlots* brslot=dynamic_cast<TGo4BrowserSlots*>(fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots"));
00133 TGo4MainWindow* mw= (TGo4MainWindow*) fxTGo4GUIRegistry->GetMainWindow();
00134 if(brslot)
00135 {
00136 TGo4Browser* brgui=brslot->GetBrowserGUI();
00137 TGo4QItem* hitem= (TGo4QItem*) brgui->ListViewLocal->findItem(hname,0);
00138 if(hitem)
00139 {
00140
00141 pad=hitem->GetDrawPad();
00142 can=hitem->GetDrawCanvas();
00143 viewpanel=hitem->GetDrawPanel();
00144 if(!hitem->IsExisting(can, pad))
00145 {
00146
00147
00148 viewpanel =mw->ViewPanelSlot(1);
00149 hitem->DrawObj(viewpanel);
00150 pad=hitem->GetDrawPad();
00151 can=hitem->GetDrawCanvas();
00152 }
00153
00154
00155 if(pad)
00156 viewpanel->SetActivePad(pad);
00157 SetViewPanel(viewpanel);
00158 SetWorkingPad();
00159 }
00160 else
00161 {
00162
00163 }
00164 }
00165 else{}
00166 }
00167 else {}
00168 fxTGo4WindowEdit->RefreshDisplay();
00169 DrawMarkers();
00170 }
00171
00172 void TGo4WindowEditSlots::SendUpdateCommand(const Text_t* newname)
00173 {
00174 TGo4LockGuard Global;
00175 TGo4Condition* con=fxTGo4WindowEditStatus->GetCondition();
00176 if(con)
00177 {
00178 Text_t oldname [256];
00179 if(newname)
00180 snprintf(oldname,256,"%s",con->GetName());
00181 TGo4ComSetCondition* com = new TGo4ComSetCondition();
00182 if(newname) con->SetName(newname);
00183 Bool_t multi=con->IsMultiEdit();
00184 con->SetMultiEdit(kTRUE);
00185
00186
00187 com->SetCondition(con);
00188 fxTGo4GUIRegistry->SubmitCommand(com);
00189 if(newname) con->SetName(oldname);
00190 SetWorkPadCondition(con);
00191 con->SetMultiEdit(multi);
00192 fbNeedsUpdate=kFALSE;
00193 }
00194 }
00195
00196 void TGo4WindowEditSlots::SendRefreshCommand(const Text_t* newname)
00197 {
00198 TGo4LockGuard Global;
00199 const Text_t* name;
00200 TGo4Condition* con=fxTGo4WindowEditStatus->GetCondition();
00201 if(con)
00202 {
00203
00204 if(con->IsHistogramLink())
00205 {
00206 const Text_t* hname=con->GetLinkedHistogram();
00207 TGo4ComGetObject *hcom = new TGo4ComGetObject(hname);
00208 fxTGo4GUIRegistry->SubmitCommand(hcom,hname);
00209
00210 }
00211
00212 if(newname)
00213 name=newname;
00214 else
00215 name=con->GetName();
00216 }
00217 else
00218 {
00219 name=newname;
00220 }
00221 TGo4ComGetCondition *com = new TGo4ComGetCondition(name);
00222 fxTGo4GUIRegistry->SubmitCommand(com,name,this);
00223 }
00224
00225 void TGo4WindowEditSlots::CreateNewCondition(const Text_t* name,
00226 const Text_t* classname, Int_t num, Int_t dim)
00227 {
00228 if(name=="") return;
00229 TGo4LockGuard main;
00230
00231
00232 TGo4Condition* condi;
00233 TClass* nclass=gROOT->GetClass(classname);
00234 if(nclass && nclass->InheritsFrom("TGo4Condition"))
00235 {
00236 if(num>1)
00237 {
00238
00239 TGo4CondArray* arconny=new TGo4CondArray(name,num, classname);
00240 TGo4WinCond* win=0;
00241 TGo4PolyCond* pol=0;
00243 Double_t a=100;
00244 Double_t b=10;
00245 Double_t c=60;
00246 Double_t d=200;
00247 for(int i=0; i<num; ++i)
00248 {
00249 if((win=arconny->Win(i))!=0)
00250 {
00251 win->SetDimension(dim);
00252 if(dim>1)
00253 win->SetValues(a*i,a*(i+1)-b,a*i,a*(i+1)-b);
00254 else
00255 win->SetValues(a*i,a*(i+1)-b);
00256 }
00257 else if ((pol=arconny->Poly(i))!=0)
00258 {
00259 Double_t initx[4]={c*i, c*i+d, c*i+0.5*d,c*i};
00260 Double_t inity[4]={c*i, c*i, c*i+d,c*i};
00261 pol->SetValues(initx,inity,4);
00262 }
00263 }
00264 condi=arconny;
00265 }
00266 else
00267 {
00268
00269 condi= (TGo4Condition*) nclass->New();
00270
00271 condi->SetName(name);
00272 }
00273 condi->Enable();
00274 condi->SetDimension(dim);
00275 condi->SetBit(TGo4Status::kGo4CanDelete);
00276 AddObject(condi);
00277 delete condi;
00278 }
00279 else
00280 {
00281
00282 }
00283 }
00284
00285
00286 void TGo4WindowEditSlots::SetWorkingPad()
00287 {
00288 TGo4LockGuard Global;
00289
00290 ClearConditions(kTRUE);
00291 fxPad.clear();
00292 fiNumPads=1;
00293 fiCurrentPad=0;
00294 fxWorkView=fxView;
00295 if(fxWorkView)
00296 {
00297 fxPad[0]=fxWorkView->GetActivePad();
00298 }
00299 else
00300 {
00301 fxPad[0]=0;
00302 }
00303 SetHistogram();
00304 }
00305
00306 void TGo4WindowEditSlots::SetHistogram()
00307 {
00308 if(fxWorkView)
00309 {
00310 fxHisto= fxWorkView->GetPadHistogram(WorkingPad());
00311 }
00312 else
00313 {
00314 fxPad[fiCurrentPad]=0;
00315 fxHisto=0;
00316 }
00317 }
00318
00319
00320 void TGo4WindowEditSlots::SetViewPanel(TGo4PreviewPanel* view)
00321 {
00322 fxView=view;
00323
00324 SetHistogram();
00325
00326 }
00327
00328 void TGo4WindowEditSlots::Click(TGo4PreviewPanel* view, TPad* pad)
00329 {
00330 TPad* wpad=WorkingPad();
00331 if(view==fxWorkView && wpad==pad)
00332 {
00333 Int_t px = 0;
00334 Int_t py = 0;
00335 Double_t x = 0;
00336 Double_t y = 0;
00337 Double_t xmin = 0;
00338 Double_t xmax = 0;
00339 Double_t ymin = 0;
00340 Double_t ymax = 0;
00341 Int_t mix,ix=0;
00342 TPad* pad=0;
00343 switch(fiMouseMode)
00344 {
00345 case kMouseROOT:
00346
00347 break;
00348
00349 case kMousePickCursor:
00350
00351 break;
00352
00353 case kMousePickLimits:
00354 pad=wpad;
00355 px = pad->GetEventX();
00356 py = pad->GetEventY();
00357 x = pad->PadtoX(pad->AbsPixeltoX(px));
00358 y = pad->PadtoX(pad->AbsPixeltoY(py));
00359 xmin=fxTGo4WindowEditStatus->Xmin();
00360 xmax=fxTGo4WindowEditStatus->Xmax();
00361 ymin=fxTGo4WindowEditStatus->Ymin();
00362 ymax=fxTGo4WindowEditStatus->Ymax();
00363 if(fuPickCounter==2)
00364 {
00365 xmin=x;
00366 xmax=x;
00367 ymin=y;
00368 ymax=y;
00369 }
00370 else if (fuPickCounter==1)
00371 {
00372 xmax=x;
00373 ymax=y;
00374 }
00375 else
00376 {
00377 cout <<"TGo4WindowEditSlots::Click() NEVER COME HERE" << endl;
00378 }
00379 SetLimits(xmin,xmax,ymin,ymax);
00380 DrawConditions();
00381 if(fuPickCounter==1)
00382 {
00383 if(IsPickArray() && fxTGo4WindowEditStatus->IsArray())
00384 {
00385
00386 ix=fxTGo4WindowEditStatus->GetCurrentIndex();
00387 mix=fxTGo4WindowEditStatus->GetNumberOfConditions()-1;
00388 if(++ix>mix) ix=mix;
00389 fxTGo4WindowEdit->SelectedCond(ix);
00390 fuPickCounter=3;
00391 }
00392 else
00393 {
00394 fiMouseMode=kMouseROOT;
00395 }
00396 }
00397 fuPickCounter--;
00398 fxTGo4WindowEdit->RefreshEditor();
00399 break;
00400
00401 case kMouseDraw:
00402
00403 break;
00404
00405 default:
00406 break;
00407
00408 }
00409 }
00410 }
00411
00412 void TGo4WindowEditSlots::RemoveViewPanel(TGo4PreviewPanel* view)
00413 {
00414 if(view==fxWorkView)
00415 {
00416 fxPad.clear();
00417 fiNumPads=1;
00418 fiCurrentPad=0;
00419 fxPad[0]=0;
00420 fxView=0;
00421 fxWorkView=0;
00422 if(fxTGo4WindowEdit->IsCentralMode())
00423 {
00424
00425 fxTGo4WindowEdit->ResetConditionNames();
00426 }
00427 }
00428 else if(view==fxView)
00429 {
00430 fxView=0;
00431 }
00432 else {}
00433 SetHistogram();
00434 fxTGo4WindowEdit->RefreshEditor();
00435 }
00436
00437 void TGo4WindowEditSlots::DrawMarkers()
00438 {
00439 DrawConditions();
00440 }
00441
00442
00443 void TGo4WindowEditSlots::DrawConditions()
00444 {
00445 TGo4LockGuard Global;
00446 TPad* wpad=WorkingPad();
00447 if(wpad==0) return;
00448 TPad* savepad= (TPad*) gPad;
00449 wpad->cd();
00450
00451
00452 {
00453 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00454 if(conny)
00455 {
00456
00457
00458 conny->SetWorkHistogram(fxHisto);
00459 conny->SetLineColor(2);
00460 conny->SetFillColor(2);
00461 conny->SetFillStyle(3002);
00462
00463
00464 conny->Draw("fixstyle");
00465 }
00466 else
00467 {
00468
00469
00470 }
00471 if(fxTGo4WindowEditStatus->IsPolygon())
00472 TGo4PolyCond::CleanupSpecials();
00473 }
00474
00475
00476
00477
00478
00479 wpad->Modified();
00480 wpad->Update();
00481 savepad->cd();
00482 }
00483
00484
00485
00486 void TGo4WindowEditSlots::HighlightCondition(Int_t )
00487 {
00488
00489
00490
00491
00492
00493 TPad* wpad=WorkingPad();
00494 if(wpad==0) return;
00495 wpad->Modified();
00496 wpad->Update();
00497 }
00498
00499
00500
00501
00502
00503
00504 void TGo4WindowEditSlots::ClearConditions(Bool_t keeplabels)
00505 {
00506 TPad* wpad=WorkingPad();
00507 if(wpad==0) return;
00508 TGo4LockGuard Global;
00509 TPad* savepad= (TPad*) gPad;
00510 wpad->cd();
00511
00512 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00513 if(conny)
00514 {
00515 if(keeplabels)
00516 conny->UnDraw("keeplabel");
00517 else
00518 conny->UnDraw();
00519 }
00520 else
00521 {
00522
00523
00524 }
00525
00526 if(fxTGo4WindowEditStatus->IsPolygon())
00527 TGo4PolyCond::CleanupSpecials();
00528 wpad->Modified();
00529 wpad->Update();
00530 savepad->cd();
00531 }
00532
00533
00534
00535 void TGo4WindowEditSlots::EnterEvent()
00536 {
00537
00538
00539
00540 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00541 if(conny && conny->IsChanged())
00542 {
00543 fbNeedsUpdate=kTRUE;
00544 conny->SetChanged(kFALSE);
00545 }
00546 if(fxTGo4WindowEditStatus->IsPolygon())
00547 TGo4PolyCond::CleanupSpecials();
00548 }
00549
00550 void TGo4WindowEditSlots::ClearCounters()
00551 {
00552 TGo4LockGuard Global;
00553 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00554 if(workingcon==0) return;
00555 workingcon->ResetCounts();
00556 workingcon->MarkReset(kTRUE);
00557 SendUpdateCommand();
00558 SendRefreshCommand();
00559 }
00560
00561 void TGo4WindowEditSlots::SetLimits(Double_t xmin,
00562 Double_t xmax,
00563 Double_t ymin, Double_t ymax)
00564 {
00565 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00566 if(workingcon==0) return;
00567 if(fxTGo4WindowEditStatus->Is2D())
00568 workingcon->SetValues(xmin,xmax,ymin,ymax);
00569 else
00570 workingcon->SetValues(xmin,xmax);
00571
00572
00573 }
00574
00575 void TGo4WindowEditSlots::SetResultMode(Int_t mode)
00576 {
00577 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00578 if(workingcon==0) return;
00579 switch (mode)
00580 {
00581 case 0:
00582 workingcon->Enable();
00583 break;
00584 case 1:
00585 workingcon->Disable(kTRUE);
00586 break;
00587 case 2:
00588 workingcon->Disable(kFALSE );
00589 break;
00590 default:
00591 workingcon->Enable();
00592 break;
00593 }
00594
00595 }
00596
00597 void TGo4WindowEditSlots::SetInvertMode(Int_t mode)
00598 {
00599 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00600 if(workingcon==0) return;
00601 switch (mode)
00602 {
00603 case 0:
00604 workingcon->Invert(kFALSE);
00605 break;
00606 case 1:
00607 workingcon->Invert(kTRUE);
00608 break;
00609 default:
00610 workingcon->Invert(kFALSE);
00611 break;
00612
00613 }
00614 }
00615
00616 Bool_t TGo4WindowEditSlots::IsVisible()
00617 {
00618 return fxTGo4WindowEditStatus->IsVisible();
00619 }
00620
00621
00622 void TGo4WindowEditSlots::SetVisible(Bool_t on)
00623 {
00624 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00625 if(workingcon)
00626 workingcon->SetVisible(on);
00627 }
00628
00629 Bool_t TGo4WindowEditSlots::IsHistogramLink()
00630 {
00631 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00632
00633 if(workingcon)
00634 return (workingcon->IsHistogramLink());
00635 else
00636 return kFALSE;
00637 }
00638
00639
00640 void TGo4WindowEditSlots::SetHistogramLink(Bool_t on)
00641 {
00642 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00643
00644 if(workingcon)
00645 {
00646 workingcon->SetHistogramLink(on);
00647 if(on && fxHisto)
00648 workingcon->SetHistogram(fxHisto->GetName());
00649 }
00650 }
00651
00652
00653
00654 void TGo4WindowEditSlots::StatusChanged(TGo4Status *status)
00655 {
00656
00657 }
00658
00659
00660
00661 const Text_t* TGo4WindowEditSlots::GetHistogramName()
00662 {
00663 if(fxHisto)
00664 return fxHisto->GetName();
00665 else
00666 return 0;
00667 }
00668
00669 const Text_t* TGo4WindowEditSlots::GetLinkedHistogramName()
00670 {
00671 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00672 if(conny)
00673 return conny->GetLinkedHistogram();
00674 else
00675 return 0;
00676
00677 }
00678
00679 Double_t TGo4WindowEditSlots::GetIntegral()
00680 {
00681 Double_t result=0;
00682 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00683 if(conny)
00684 result=conny->GetIntegral(fxHisto,"");
00685 else
00686 result=0;
00687 return result;
00688 }
00689
00690 Double_t TGo4WindowEditSlots::GetMean(Int_t axis)
00691 {
00692 Double_t result=0;
00693 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00694 if(conny)
00695 result=conny->GetMean(fxHisto, axis);
00696 else
00697 result=0;
00698 return result;
00699 }
00700
00701 Double_t TGo4WindowEditSlots::GetRMS(Int_t axis)
00702 {
00703 Double_t result=0;
00704 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00705 if(conny)
00706 result=conny->GetRMS(fxHisto, axis);
00707 else
00708 result=0;
00709 return result;
00710 }
00711
00712 Double_t TGo4WindowEditSlots::GetXMax()
00713 {
00714 Double_t result=0;
00715 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00716 if(conny)
00717 result=conny->GetXMax(fxHisto);
00718 else
00719 result=0;
00720 return result;
00721 }
00722
00723 Double_t TGo4WindowEditSlots::GetYMax()
00724 {
00725 Double_t result=0;
00726 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00727 if(conny)
00728 result=conny->GetYMax(fxHisto);
00729 else
00730 result=0;
00731 return result;
00732 }
00733
00734 Double_t TGo4WindowEditSlots::GetCMax()
00735 {
00736 Double_t result=0;
00737 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00738 if(conny)
00739 result=conny->GetCMax(fxHisto);
00740 else
00741 result=0;
00742 return result;
00743 }
00744
00745 void TGo4WindowEditSlots::SetLabelDraw(Bool_t on)
00746 {
00747 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00748 if(workingcon)
00749 workingcon->SetLabelDraw(on);
00750 }
00751
00752 void TGo4WindowEditSlots::SetLimitsDraw(Bool_t on)
00753 {
00754 TGo4Condition* workingcon=fxTGo4WindowEditStatus->GetCondition();
00755 if(workingcon)
00756 workingcon->SetLimitsDraw(on);
00757 }
00758
00759
00760 void TGo4WindowEditSlots::SetIntDraw(Bool_t on)
00761 {
00762 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00763 if(conny) conny->SetIntDraw(on);
00764 }
00765
00766 void TGo4WindowEditSlots::SetXMeanDraw(Bool_t on)
00767 {
00768 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00769 if(conny) conny->SetXMeanDraw(on);
00770 }
00771
00772 void TGo4WindowEditSlots::SetXRMSDraw(Bool_t on)
00773 {
00774 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00775 if(conny) conny->SetXRMSDraw(on);
00776 }
00777
00778 void TGo4WindowEditSlots::SetYMeanDraw(Bool_t on)
00779 {
00780 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00781 if(conny) conny->SetYMeanDraw(on);
00782 }
00783
00784 void TGo4WindowEditSlots::SetYRMSDraw(Bool_t on)
00785 {
00786 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00787 if(conny) conny->SetYRMSDraw(on);
00788 }
00789
00790 void TGo4WindowEditSlots::SetXMaxDraw(Bool_t on)
00791 {
00792 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00793 if(conny) conny->SetXMaxDraw(on);
00794 }
00795
00796 void TGo4WindowEditSlots::SetYMaxDraw(Bool_t on)
00797 {
00798 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00799 if(conny) conny->SetYMaxDraw(on);
00800 }
00801
00802 void TGo4WindowEditSlots::SetCMaxDraw(Bool_t on)
00803 {
00804 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00805 if(conny) conny->SetCMaxDraw(on);
00806 }
00807
00808 Bool_t TGo4WindowEditSlots::IsLabelDraw()
00809 {
00810 Bool_t rev=kFALSE;
00811 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00812 if(conny) rev=conny->IsLabelDraw();
00813 return rev;
00814 }
00815
00816 Bool_t TGo4WindowEditSlots::IsLimitsDraw()
00817 {
00818 Bool_t rev=kFALSE;
00819 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00820 if(conny) rev=conny->IsLimitsDraw();
00821 return rev;
00822 }
00823
00824 Bool_t TGo4WindowEditSlots::IsIntDraw()
00825 {
00826 Bool_t rev=kFALSE;
00827 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00828 if(conny) rev=conny->IsIntDraw();
00829 return rev;
00830 }
00831
00832 Bool_t TGo4WindowEditSlots::IsXMeanDraw()
00833 {
00834 Bool_t rev=kFALSE;
00835 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00836 if(conny) rev=conny->IsXMeanDraw();
00837 return rev;
00838 }
00839
00840 Bool_t TGo4WindowEditSlots::IsXRMSDraw()
00841 {
00842 Bool_t rev=kFALSE;
00843 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00844 if(conny) rev=conny->IsXRMSDraw();
00845 return rev;
00846 }
00847
00848 Bool_t TGo4WindowEditSlots::IsYMeanDraw()
00849 {
00850 Bool_t rev=kFALSE;
00851 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00852 if(conny) rev=conny->IsYMeanDraw();
00853 return rev;
00854 }
00855
00856 Bool_t TGo4WindowEditSlots::IsYRMSDraw()
00857 {
00858 Bool_t rev=kFALSE;
00859 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00860 if(conny) rev=conny->IsYRMSDraw();
00861 return rev;
00862 }
00863
00864 Bool_t TGo4WindowEditSlots::IsXMaxDraw()
00865 {
00866 Bool_t rev=kFALSE;
00867 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00868 if(conny) rev=conny->IsXMaxDraw();
00869 return rev;
00870 }
00871
00872 Bool_t TGo4WindowEditSlots::IsYMaxDraw()
00873 {
00874 Bool_t rev=kFALSE;
00875 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00876 if(conny) rev=conny->IsYMaxDraw();
00877 return rev;
00878 }
00879
00880 Bool_t TGo4WindowEditSlots::IsCMaxDraw()
00881 {
00882 Bool_t rev=kFALSE;
00883 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00884 if(conny) rev=conny->IsCMaxDraw();
00885 return rev;
00886 }
00887
00888
00889 void TGo4WindowEditSlots::SetNewTCutG(Bool_t editmode, Bool_t cancel)
00890 {
00891 TPad* wpad=WorkingPad();
00892 if(wpad==0 || !fxTGo4WindowEditStatus->IsPolygon() ) return;
00893 TGo4LockGuard glob;
00894 TPad* savepad = (TPad*) gPad;
00895 wpad->cd();
00896 TGo4PreviewPanelSlots* wvslots=0;
00897 if(fxWorkView) wvslots=fxWorkView->GetSlots();
00898 if(editmode)
00899 {
00900 gROOT->SetEditorMode("CutG");
00901 if(wvslots) wvslots->SetMouseMode(kMouseConditionEditor);
00902
00903 }
00904 else
00905 {
00906 gROOT->SetEditorMode("");
00907 if(wvslots) wvslots->SetMouseMode(kMouseROOT);
00908 TObject *entry=0;
00909 TCutG *CG=0;
00910 TCutG* newcut=0;
00911 TList *ListOfPadPrimitives = wpad->GetListOfPrimitives();
00912 TIterator* Padlistiter = ListOfPadPrimitives->MakeIterator();
00913 while((entry= Padlistiter->Next()) !=0)
00914 {
00915 if(entry->InheritsFrom("TCutG"))
00916 {
00917 CG = dynamic_cast<TCutG *> (entry);
00918
00919 if(CG && CG->GetLineColor()==1)
00920 {
00921
00922
00923
00924 newcut=CG;
00925 break;
00926 }
00927 }
00928 }
00929 delete Padlistiter;
00930 if (newcut)
00931 {
00932 if(!cancel)
00933 {
00934 TGo4Condition* conny=fxTGo4WindowEditStatus->GetCondition();
00935 if(conny)
00936 {
00937 TGo4Condition* aconny=conny->GetActiveCondition();
00938 TGo4PolyCond* pconny=dynamic_cast<TGo4PolyCond*>(aconny);
00939 if(pconny)
00940 {
00941 pconny->UnDraw();
00942 pconny->SetValues(newcut);
00943 pconny->Draw();
00944 }
00945 delete newcut;
00946 }
00947 }
00948 else
00949 {
00950 delete newcut;
00951 }
00952 }
00953 else
00954 {
00955
00956 }
00957 DrawConditions();
00958 }
00959 savepad->cd();
00960 }
00961
00962 TPad* TGo4WindowEditSlots::FindObjectSubpad(TObject* obj, TPad* parent)
00963 {
00964 TPad* rev=0;
00965 if(parent)
00966 {
00967 TObject* prim=0;
00968 TIter iter(parent->GetListOfPrimitives());
00969 while((prim=iter())!=0)
00970 {
00971 if(prim==obj)
00972 {
00973 rev=parent;
00974 break;
00975 }
00976 else if(prim->InheritsFrom("TPad"))
00977 {
00978 TPad* subpad=dynamic_cast<TPad*>(prim);
00979 rev=FindObjectSubpad(obj,subpad);
00980 if(rev) break;
00981 }
00982 else
00983 {
00984 rev=0;
00985 }
00986 }
00987
00988 }
00989
00990 return rev;
00991 }
00992
00993 TGo4Condition* TGo4WindowEditSlots::GetWorkPadCondition(Int_t index)
00994 {
00995 TGo4Condition* con=0;
00996 if(fxWorkView!=0 && WorkingPad(index)!=0)
00997 {
00998 TGo4PadOptions* popt=fxWorkView->GetPadOptions(WorkingPad(index));
00999 if(popt)
01000 con=popt->GetCondition();
01001 }
01002 return con;
01003 }
01004
01005 void TGo4WindowEditSlots::SetWorkPadCondition(TGo4Condition* con)
01006 {
01007 TPad* wpad=WorkingPad();
01008 if(fxWorkView!=0 && wpad!=0)
01009 {
01010 TGo4PadOptions* popt=fxWorkView->GetPadOptions(wpad);
01011 if(popt)
01012 popt->SetCondition(con);
01013 }
01014
01015 }
01016
01017 void TGo4WindowEditSlots::SetCurrentPad(Int_t index)
01018 {
01019 TGo4Condition* con=fxTGo4WindowEditStatus->GetCondition();
01020 if(con && fiCurrentPad!=index)
01021 SetWorkPadCondition(con);
01022
01023 ClearConditions(kTRUE);
01024
01025 Int_t set=0;
01026 if(index<0)
01027 set=0;
01028 else if(index>=fiNumPads)
01029 set=fiNumPads-1;
01030 else
01031 set=index;
01032 fiCurrentPad=set;
01033
01034 TGo4Condition* padcon=GetWorkPadCondition(fiCurrentPad);
01035 if(padcon)
01036 AddObject(padcon);
01037 SetHistogram();
01038 }
01039
01040 TPad* TGo4WindowEditSlots::WorkingPad(Int_t index)
01041 {
01042 Int_t selected=0;
01043 if(index<0)
01044 selected=fiCurrentPad;
01045 else if (index>=fiNumPads)
01046 selected=fiNumPads-1;
01047 else
01048 selected=index;
01049
01050 if(fxWorkView && fxPad[selected])
01051 {
01052
01053
01054 TRefArray* padlist= fxWorkView->GetListOfPads();
01055
01056 if(padlist->FindObject(fxPad[selected]))
01057 {
01058
01059 }
01060 else
01061 {
01062
01063 fxPad[selected]=0;
01064 }
01065 }
01066 return fxPad[selected];
01067 }
01068
01069 void TGo4WindowEditSlots::AssignWorkViewPanel(TGo4PreviewPanel* view)
01070 {
01071 ClearConditions(kTRUE);
01072 fxTGo4WindowEditStatus->SetCondition(0);
01073 fxPad.clear();
01074 fiNumPads=0;
01075 fiCurrentPad=0;
01076 if(view)
01077 fxWorkView=view;
01078 else
01079 fxWorkView=fxView;
01080
01081 if(fxWorkView)
01082 {
01083 TRefArray* padlist=fxWorkView->GetListOfPads();
01084
01085 if(padlist)
01086 {
01087 TIterator* piter=padlist->MakeIterator();
01088 TObject* ob=0;
01089 TGo4PadOptions* popt=0;
01090 while((ob=piter->Next())!=0)
01091 {
01092 TPad* pad=dynamic_cast<TPad*>(ob);
01093 if(pad)
01094 {
01095 popt=fxWorkView->GetPadOptions(pad);
01096 TGo4Condition* con=0;
01097 if(popt)
01098 con=popt->GetCondition();
01099 if(con)
01100 {
01101
01102 fxPad.push_back(pad);
01103 fiNumPads++;
01104 }
01105 }
01106 }
01107 delete piter;
01108 }
01109 }
01110 if(fiNumPads==0)
01111 {
01112
01113 fxPad.push_back(0);
01114 fiNumPads=1;
01115 AddObject(0);
01116 }
01117 }
01118
01119
01120
01121
01122
01123
01124