00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 enum ESelectedType {entry_None = -1, entry_Histogram = 0, entry_Tree = 1};
00024
00025 void TGo4EditDynEntry::init()
00026 {
00027 fbTypingMode = true;
00028 fiSelectedType = entry_None;
00029 ResetWidget();
00030 }
00031
00032 bool TGo4EditDynEntry::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
00033 {
00034 if (cl==0) return false;
00035
00036 return cl->InheritsFrom(TGo4DynamicEntry::Class()) ||
00037 cl->InheritsFrom(TH1::Class()) ||
00038 cl->InheritsFrom(TTree::Class()) ||
00039 cl->InheritsFrom(TGo4Condition::Class());
00040 }
00041
00042 void TGo4EditDynEntry::DropItem(const char* itemname, TClass* cl, int kind)
00043 {
00044 if (cl==0) return;
00045
00046 if (cl->InheritsFrom(TGo4DynamicEntry::Class()))
00047 WorkWithEntry(itemname);
00048 else
00049 if (cl->InheritsFrom(TH1::Class()))
00050 DropHistogram(itemname);
00051 else
00052 if (cl->InheritsFrom(TGo4Condition::Class()))
00053 DropCondition(itemname);
00054 else
00055 if (cl->InheritsFrom(TTree::Class()))
00056 DropTree(itemname);
00057 }
00058
00059 void TGo4EditDynEntry::linkedObjectUpdated(const char* linkname, TObject* obj)
00060 {
00061 if (strcmp(linkname, "Entry")==0)
00062 SetPleaseUpdate(false);
00063
00064 RefreshWidget();
00065 }
00066
00067 void TGo4EditDynEntry::RefreshWidget()
00068 {
00069 TGo4DynamicEntry* entry =
00070 dynamic_cast<TGo4DynamicEntry*>(GetLinked("Entry", 0));
00071
00072 TGo4BrowserProxy* br = Browser();
00073
00074 if ((entry==0) || (br==0)) return;
00075
00076 fiSelectedType = entry_None;
00077
00078 fbTypingMode = false;
00079
00080 EntryBox->setTitle(QString("Entry: ") + entry->ClassName());
00081 EntryEnabledButton->setChecked(entry->IsEnabledProcessing());
00082
00083 EntryBox->setEnabled(TRUE);
00084 HistogramBox->setEnabled(TRUE);
00085 EntryTabs->setEnabled(TRUE);
00086
00087 TGo4HistogramEntry* hentry = dynamic_cast<TGo4HistogramEntry*> (entry);
00088 TGo4TreeHistogramEntry* tentry = dynamic_cast<TGo4TreeHistogramEntry*> (entry);
00089
00090 const char* entryitem = GetLinkedName("Entry");
00091
00092 if (hentry!=0) {
00093 fiSelectedType = entry_Histogram;
00094
00095 EntryTabs->setTabEnabled(EventTab, TRUE);
00096 EntryTabs->setTabEnabled(ConditionTab, TRUE);
00097 EntryTabs->setTabEnabled(TreeTab, FALSE);
00098 EntryTabs->setCurrentPage(EntryTabs->indexOf(EventTab));
00099
00100 TString hitemname;
00101 if (!br->DefineRelatedObject(entryitem,
00102 hentry->GetHistogramName(), hitemname))
00103 hitemname = hentry->GetHistogramName();
00104 HistoNameLbl->setText(hitemname.Data());
00105 DrawButton->setShown(hitemname.Length()>0);
00106 ClearButton->setShown(hitemname.Length()>0);
00107
00108 QString fname = hentry->GetHistEventName(0);
00109 if (fname.length()>0) fname += "/";
00110 fname += hentry->GetHistVarName(0);
00111 EvXnameEdit->setText(fname);
00112
00113 fname = hentry->GetHistEventName(1);
00114 if (fname.length()>0) fname += "/";
00115 fname += hentry->GetHistVarName(1);
00116 EvYnameEdit->setText(fname);
00117
00118 fname = hentry->GetHistEventName(2);
00119 if (fname.length()>0) fname += "/";
00120 fname += hentry->GetHistVarName(2);
00121 EvZnameEdit->setText(fname);
00122
00123 TString citemname;
00124 if (!br->DefineRelatedObject(entryitem,
00125 hentry->GetConditionName(), citemname))
00126 citemname = hentry->GetConditionName();
00127 CondNameLbl->setText(citemname.Data());
00128
00129 fname = hentry->GetConEventName(0);
00130 if (fname.length()>0) fname += "/";
00131 fname += hentry->GetConVarName(0);
00132 ConXnameEdit->setText(fname);
00133
00134 fname = hentry->GetConEventName(1);
00135 if (fname.length()>0) fname += "/";
00136 fname += hentry->GetConVarName(1);
00137 ConYnameEdit->setText(fname);
00138 } else
00139 if (tentry!=0) {
00140 fiSelectedType = entry_Tree;
00141
00142 EntryTabs->setTabEnabled(EventTab, FALSE);
00143 EntryTabs->setTabEnabled(ConditionTab, FALSE);
00144 EntryTabs->setTabEnabled(TreeTab, TRUE);
00145 EntryTabs->setCurrentPage(EntryTabs->indexOf(TreeTab));
00146
00147 TString hitemname;
00148 if (!br->DefineRelatedObject(entryitem,
00149 tentry->GetHistogramName(), hitemname))
00150 hitemname = tentry->GetHistogramName();
00151 HistoNameLbl->setText(hitemname.Data());
00152 DrawButton->setShown(hitemname.Length()>0);
00153 ClearButton->setShown(hitemname.Length()>0);
00154
00155 TString titemname;
00156 if (!br->DefineRelatedObject(entryitem,
00157 tentry->GetTreeName(), titemname))
00158 titemname = tentry->GetTreeName();
00159 TreeNameLbl->setText(titemname.Data());
00160
00161 DrawExprEdit->setText(tentry->GetVarExp());
00162 CutExprEdit->setText(tentry->GetCutExp());
00163 DynIntervalSpin->setValue(tentry->GetDynListInterval());
00164 }
00165
00166 fbTypingMode = true;
00167 }
00168
00169 QString TGo4EditDynEntry::GetEventName(const QString& itemname)
00170 {
00171 TString folder, name;
00172 TGo4Slot::ProduceFolderAndName(itemname.latin1(), folder, name);
00173 int pos = folder.Index("/");
00174 if (pos>0) folder.Resize(pos);
00175 return QString(folder.Data());
00176 }
00177
00178 QString TGo4EditDynEntry::GetEventMember(const QString& itemname)
00179 {
00180 TString folder, name;
00181 TGo4Slot::ProduceFolderAndName(itemname.latin1(), folder, name);
00182 return QString(name.Data());
00183 }
00184
00185 void TGo4EditDynEntry::WorkWithEntry(const char* itemname)
00186 {
00187 TGo4DynamicEntry* entry =
00188 dynamic_cast<TGo4DynamicEntry*>(GetLinked("Entry", 0));
00189 const char* oldname = GetLinkedName("Entry");
00190
00191 if ((entry!=0) && (oldname!=0) && PleaseUpdateLabel->isShown()) {
00192
00193 int res = QMessageBox::warning(this, "Dynamic list entry editor",
00194 QString("Current entry ")+oldname+" is modified!\n New entry" +
00195 itemname+ " selected.",
00196 QString("Continue with current"),
00197 QString("Start with new"), QString::null, 0);
00198
00199 if (res==0) return;
00200
00201 }
00202
00203 ResetWidget();
00204
00205 AddLink(itemname, "Entry");
00206
00207 EntryNameLbl->setText(itemname);
00208
00209 QString iconname = "right.png";
00210 QString tooltip = "Refresh dynamic entry from analysis";
00211 if (!BrowserItemRemote(itemname)) {
00212 iconname = "refresh.png";
00213 tooltip = "Refresh dynamic entry from source";
00214 }
00215 RefreshButton->setIconSet( QIconSet( QPixmap::fromMimeSource(iconname) ) );
00216 QToolTip::remove(RefreshButton);
00217 QToolTip::add(RefreshButton, tooltip);
00218
00219 GetLinked("Entry", 2);
00220 RefreshWidget();
00221
00222 SetPleaseUpdate(false);
00223 adjustSize();
00224 setFocus();
00225 }
00226
00227 void TGo4EditDynEntry::DropHistogram(const char * itemname)
00228 {
00229 if (itemname==0) return;
00230
00231 EntryChangedSlot();
00232
00233 HistoNameLbl->setText(itemname);
00234 DrawButton->setShown(true);
00235 ClearButton->setShown(true);
00236
00237 TGo4DynamicEntry* entry =
00238 dynamic_cast<TGo4DynamicEntry*>(GetLinked("Entry", 0));
00239
00240 TGo4HistogramEntry* hentry = dynamic_cast<TGo4HistogramEntry*> (entry);
00241 TGo4TreeHistogramEntry* tentry = dynamic_cast<TGo4TreeHistogramEntry*> (entry);
00242 if (hentry!=0)
00243 hentry->SetHistogramName(itemname);
00244 if (tentry!=0)
00245 tentry->SetHistogramName(itemname);
00246 }
00247
00248 void TGo4EditDynEntry::DropCondition( const char * itemname )
00249 {
00250 if (fiSelectedType != entry_Histogram) return;
00251
00252 EntryChangedSlot();
00253
00254 CondNameLbl->setText(itemname);
00255
00256 EntryTabs->setCurrentPage(EntryTabs->indexOf(ConditionTab));
00257 TGo4HistogramEntry* hentry =
00258 dynamic_cast<TGo4HistogramEntry*> (GetLinked("Entry", 0));
00259 if (hentry!=0)
00260 hentry->SetConditionName(itemname);
00261 }
00262
00263 void TGo4EditDynEntry::DropTree( const char * itemname )
00264 {
00265 if (fiSelectedType != entry_Tree) return;
00266
00267 EntryChangedSlot();
00268
00269 TreeNameLbl->setText(itemname);
00270
00271 TGo4TreeHistogramEntry* tentry =
00272 dynamic_cast<TGo4TreeHistogramEntry*> (GetLinked("Entry", 0));
00273 if (tentry!=0)
00274 tentry->SetTreeName(itemname);
00275 }
00276
00277 void TGo4EditDynEntry::ResetWidget()
00278 {
00279 QGo4Widget::ResetWidget();
00280
00281 fiSelectedType = entry_None;
00282
00283 EntryNameLbl->setText("");
00284 EntryBox->setTitle(QString("Entry: "));
00285
00286 EntryBox->setEnabled(FALSE);
00287 HistogramBox->setEnabled(FALSE);
00288 EntryTabs->setEnabled(FALSE);
00289
00290 DrawButton->setShown(false);
00291
00292 RefreshButton->setIconSet( QIconSet( QPixmap::fromMimeSource( "right" ) ) );
00293
00294 SetPleaseUpdate(false);
00295 }
00296
00297 void TGo4EditDynEntry::RefreshClicked()
00298 {
00299 GetLinked("Entry", 2);
00300 RefreshWidget();
00301 }
00302
00303 void TGo4EditDynEntry::ApplyClicked()
00304 {
00305 if (!PrepareEntryForAnalysis()) return;
00306
00307 if (UpdateItemInAnalysis(GetLinkedName("Entry"))) {
00308 SetPleaseUpdate(false);
00309 RefreshWidget();
00310 }
00311 }
00312
00313 void TGo4EditDynEntry::SetPleaseUpdate( bool on )
00314 {
00315 PleaseUpdateLabel->setShown(on);
00316 polish();
00317 update();
00318 show();
00319 }
00320
00321 void TGo4EditDynEntry::EntryChangedSlot()
00322 {
00323 if(!PleaseUpdateLabel->isShown())
00324 SetPleaseUpdate(true);
00325 }
00326
00327 void TGo4EditDynEntry::SaveEntrySlot()
00328 {
00329 if (!PrepareEntryForAnalysis()) return;
00330
00331 if (SaveItemToFile(GetLinkedName("Entry"), "DynamicLists"))
00332 SetPleaseUpdate(false);
00333 }
00334
00335 void TGo4EditDynEntry::EvXnameEdit_dropped()
00336 {
00337 ProcessDropEvent(EvXnameEdit);
00338 }
00339
00340 void TGo4EditDynEntry::EvYnameEdit_dropped()
00341 {
00342 ProcessDropEvent(EvYnameEdit);
00343 }
00344
00345 void TGo4EditDynEntry::EvZnameEdit_dropped()
00346 {
00347 ProcessDropEvent(EvZnameEdit);
00348 }
00349
00350 void TGo4EditDynEntry::ConXnameEdit_dropped()
00351 {
00352 ProcessDropEvent(ConXnameEdit);
00353 }
00354
00355 void TGo4EditDynEntry::ConYnameEdit_dropped()
00356 {
00357 ProcessDropEvent(ConYnameEdit);
00358 }
00359
00360 void TGo4EditDynEntry::DrawExprEdit_dropped()
00361 {
00362 ProcessTreeDropEvent(DrawExprEdit);
00363 }
00364
00365 void TGo4EditDynEntry::CutExprEdit_dropped()
00366 {
00367 ProcessTreeDropEvent(CutExprEdit);
00368 }
00369
00370 void TGo4EditDynEntry::ProcessDropEvent(QGo4LineEdit* edt)
00371 {
00372 if ((edt==0) || (Browser()==0)) return;
00373
00374 QString value = edt->text();
00375
00376 EntryChangedSlot();
00377
00378 Int_t kind = Browser()->ItemKind(value.latin1());
00379 if (kind!=TGo4Access::kndDataMember) {
00380 edt->setText("");
00381 return;
00382 }
00383
00384 QString serachfor("EventObjects/Events/");
00385 int pos = value.find(serachfor);
00386 if (pos<0) {
00387 edt->setText("");
00388 return;
00389 }
00390
00391 value.remove(0, pos+serachfor.length());
00392
00393 edt->setText(value);
00394 }
00395
00396 void TGo4EditDynEntry::ProcessTreeDropEvent(QGo4LineEdit* edt)
00397 {
00398 if ((edt==0) || (Browser()==0)) return;
00399
00400 QString value = edt->text();
00401
00402 TGo4BrowserProxy* br = Browser();
00403
00404 EntryChangedSlot();
00405
00406 int kind = br->ItemKind(value.latin1());
00407 if (kind!=TGo4Access::kndTreeLeaf) {
00408 edt->setText("");
00409 return;
00410 }
00411
00412 TString treename;
00413 if (br->DefineTreeName(value.latin1(), treename))
00414 DropTree(treename.Data());
00415
00416 TString lfolder, lname;
00417 TGo4Slot::ProduceFolderAndName(value.latin1(), lfolder, lname);
00418 edt->setText(lname.Data());
00419 }
00420
00421
00422 void TGo4EditDynEntry::HisCreateButton_clicked()
00423 {
00424 AskToCreateObject(TH1::Class(), 1);
00425 }
00426
00427
00428 void TGo4EditDynEntry::HisInfoButton_clicked()
00429 {
00430 ShowItemInfo(HistoNameLbl->text().latin1());
00431 }
00432
00433 void TGo4EditDynEntry::ConNewButton_clicked()
00434 {
00435 AskToCreateObject(TGo4Condition::Class(), 1);
00436 }
00437
00438 void TGo4EditDynEntry::ConInfoButton_clicked()
00439 {
00440 EditItem(CondNameLbl->text().latin1());
00441 }
00442
00443 void TGo4EditDynEntry::requestedObjectCreated(const char* itemname, TClass* cl)
00444 {
00445 if ((cl==0) || (fiSelectedType==entry_None)) return;
00446 if (cl->InheritsFrom(TH1::Class()))
00447 DropHistogram(itemname);
00448 else
00449 if (cl->InheritsFrom(TGo4Condition::Class()))
00450 DropCondition(itemname);
00451 }
00452
00453 bool TGo4EditDynEntry::PrepareEntryForAnalysis()
00454 {
00455 TGo4DynamicEntry* entry =
00456 dynamic_cast<TGo4DynamicEntry*>(GetLinked("Entry", 0));
00457
00458 if (entry==0) return false;
00459
00460 TGo4HistogramEntry* hentry = dynamic_cast<TGo4HistogramEntry*> (entry);
00461 TGo4TreeHistogramEntry* tentry = dynamic_cast<TGo4TreeHistogramEntry*> (entry);
00462
00463 if (hentry!=0) {
00464 TString folder, name;
00465
00466 TGo4Slot::ProduceFolderAndName(hentry->GetHistogramName(), folder, name);
00467 hentry->SetHistogramName(name.Data());
00468
00469 TGo4Slot::ProduceFolderAndName(hentry->GetConditionName(), folder, name);
00470 hentry->SetConditionName(name.Data());
00471
00472 return true;
00473 }
00474
00475 if (tentry!=0) {
00476 TString folder, name;
00477
00478 TGo4Slot::ProduceFolderAndName(tentry->GetHistogramName(), folder, name);
00479 tentry->SetHistogramName(name.Data());
00480
00481 TGo4Slot::ProduceFolderAndName(tentry->GetTreeName(), folder, name);
00482 tentry->SetTreeName(name.Data());
00483 return true;
00484 }
00485
00486 return false;
00487 }
00488
00489
00490 void TGo4EditDynEntry::EntryEnabledButton_toggled( bool on)
00491 {
00492 TGo4DynamicEntry* entry =
00493 dynamic_cast<TGo4DynamicEntry*>(GetLinked("Entry", 0));
00494 if ((entry==0) || !fbTypingMode) return;
00495 entry->EnableProcessing(on);
00496 EntryChangedSlot();
00497 }
00498
00499
00500 void TGo4EditDynEntry::EvXnameEdit_textChanged( const QString & xname)
00501 {
00502 TGo4HistogramEntry* hentry =
00503 dynamic_cast<TGo4HistogramEntry*> (GetLinked("Entry", 0));
00504 if ((hentry==0) || !fbTypingMode) return;
00505
00506 hentry->SetHisEventName(0, GetEventName(xname));
00507 hentry->SetHisVarName(0, GetEventMember(xname));
00508 }
00509
00510
00511 void TGo4EditDynEntry::EvYnameEdit_textChanged( const QString & yname)
00512 {
00513 TGo4HistogramEntry* hentry =
00514 dynamic_cast<TGo4HistogramEntry*> (GetLinked("Entry", 0));
00515 if ((hentry==0) || !fbTypingMode) return;
00516
00517 hentry->SetHisEventName(1, GetEventName(yname));
00518 hentry->SetHisVarName(1, GetEventMember(yname));
00519 }
00520
00521
00522 void TGo4EditDynEntry::EvZnameEdit_textChanged( const QString & zname)
00523 {
00524 TGo4HistogramEntry* hentry =
00525 dynamic_cast<TGo4HistogramEntry*> (GetLinked("Entry", 0));
00526 if ((hentry==0) || !fbTypingMode) return;
00527
00528 hentry->SetHisEventName(2, GetEventName(zname));
00529 hentry->SetHisVarName(2, GetEventMember(zname));
00530 }
00531
00532
00533 void TGo4EditDynEntry::ConXnameEdit_textChanged( const QString & xname)
00534 {
00535 TGo4HistogramEntry* hentry =
00536 dynamic_cast<TGo4HistogramEntry*> (GetLinked("Entry", 0));
00537 if ((hentry==0) || !fbTypingMode) return;
00538
00539 hentry->SetConEventName(0, GetEventName(xname));
00540 hentry->SetConVarName(0, GetEventMember(xname));
00541 }
00542
00543
00544 void TGo4EditDynEntry::ConYnameEdit_textChanged( const QString & yname)
00545 {
00546 TGo4HistogramEntry* hentry =
00547 dynamic_cast<TGo4HistogramEntry*> (GetLinked("Entry", 0));
00548 if ((hentry==0) || !fbTypingMode) return;
00549
00550 hentry->SetConEventName(1, GetEventName(yname));
00551 hentry->SetConVarName(1, GetEventMember(yname));
00552 }
00553
00554
00555 void TGo4EditDynEntry::DrawExprEdit_textChanged( const QString & value)
00556 {
00557 TGo4TreeHistogramEntry* tentry =
00558 dynamic_cast<TGo4TreeHistogramEntry*> (GetLinked("Entry", 0));
00559 if ((tentry==0) || !fbTypingMode) return;
00560 tentry->SetVarExp(value.latin1());
00561 }
00562
00563 void TGo4EditDynEntry::CutExprEdit_textChanged( const QString & value)
00564 {
00565 TGo4TreeHistogramEntry* tentry =
00566 dynamic_cast<TGo4TreeHistogramEntry*> (GetLinked("Entry", 0));
00567 if ((tentry==0) || !fbTypingMode) return;
00568 tentry->SetCutExp(value.latin1());
00569 }
00570
00571 void TGo4EditDynEntry::DynIntervalSpin_valueChanged( int value)
00572 {
00573 TGo4TreeHistogramEntry* tentry =
00574 dynamic_cast<TGo4TreeHistogramEntry*> (GetLinked("Entry", 0));
00575 if ((tentry==0) || !fbTypingMode) return;
00576 tentry->SetDynListInterval(value);
00577 }
00578
00579
00580 void TGo4EditDynEntry::DrawButton_clicked()
00581 {
00582 DrawItem(HistoNameLbl->text());
00583 }
00584
00585 void TGo4EditDynEntry::ClearHistogramClicked()
00586 {
00587 TString objname;
00588 TGo4AnalysisProxy* an = Browser()->DefineAnalysisObject(HistoNameLbl->text().latin1(), objname);
00589 if (an!=0) {
00590 an->ClearAnalysisObject(objname.Data());
00591 if (dynamic_cast<TGo4TreeHistogramEntry*>(GetLinked("Entry",0))!=0)
00592 an->ExecuteLine("@ResetBackStores();");
00593 Browser()->GetBrowserObject(HistoNameLbl->text().latin1(), 2);
00594 }
00595 }
00596
00597 void TGo4EditDynEntry::PrintDynList()
00598 {
00599 TString objname;
00600 TGo4AnalysisProxy* an = Browser()->DefineAnalysisObject(GetLinkedName("Entry"), objname);
00601
00602 if (an!=0)
00603 an->PrintDynListEntry(objname.Data());
00604 }
00605
00606
00607
00608 void TGo4EditDynEntry::ConRemoveButton_clicked()
00609 {
00610 DropCondition("");
00611 }
00612
00613