File indexing completed on 2023-03-17 11:01:25
0001 #include "TGLabel.h"
0002 #include "TG3DLine.h"
0003 #include "TGResourcePool.h"
0004 #include "Fireworks/Core/interface/RootGuiUtils.h"
0005 #include "Fireworks/Core/interface/FWGUIEventFilter.h"
0006 #include "Fireworks/Core/interface/FWGUIEventSelector.h"
0007 #include "Fireworks/Core/interface/FWConfiguration.h"
0008 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
0009 #include "Fireworks/Core/interface/FWJobMetadataManager.h"
0010 #include "Fireworks/Core/interface/CmsShowNavigator.h"
0011 #include "Fireworks/Core/interface/Context.h"
0012 #include "Fireworks/Core/interface/CSGAction.h"
0013 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
0014 #include "Fireworks/Core/interface/FWGUIManager.h"
0015 #include "Fireworks/Core/interface/CmsShowMainFrame.h"
0016
0017 FWGUIEventFilter::FWGUIEventFilter(CmsShowNavigator* n)
0018 : TGMainFrame(gClient->GetRoot(), 560, 300),
0019
0020 m_origFilterMode(CmsShowNavigator::kOr),
0021 m_isOpen(false),
0022 m_filtersRemoved(false),
0023
0024 m_eventSelectionFrameParent(nullptr),
0025 m_eventSelectionFrame(nullptr),
0026 m_triggerSelectionFrameParent(nullptr),
0027 m_triggerSelectionFrame(nullptr),
0028
0029 m_rad1(nullptr),
0030 m_rad2(nullptr),
0031 m_stateLabel(nullptr),
0032 m_disableFilteringBtn(nullptr),
0033 m_addBtn(nullptr),
0034
0035 m_navigator(n) {
0036 SetWindowName("Event Filters");
0037
0038 TGVerticalFrame* v1 = new TGVerticalFrame(this);
0039 AddFrame(v1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
0040
0041
0042
0043 {
0044 m_eventSelectionFrameParent = new TGVerticalFrame(v1, GetWidth(), s_entryHeight, 0);
0045 v1->AddFrame(m_eventSelectionFrameParent, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 2, 2, 0, 0));
0046
0047
0048 TGHorizontalFrame* selH = new TGHorizontalFrame(m_eventSelectionFrameParent);
0049 m_eventSelectionFrameParent->AddFrame(selH, new TGLayoutHints(kLHintsExpandX));
0050
0051 {
0052 TGCompositeFrame* cfr = new TGHorizontalFrame(selH);
0053 selH->AddFrame(cfr, new TGLayoutHints(kLHintsExpandX));
0054 cfr->AddFrame(new TGLabel(cfr, "Event Filter Expression:"),
0055 new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 6, 4));
0056 }
0057 {
0058 TGCompositeFrame* cfr = new TGHorizontalFrame(selH, 122, 22, kFixedSize);
0059 selH->AddFrame(cfr);
0060 cfr->AddFrame(new TGLabel(cfr, "Comment:"), new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 2, 0));
0061 }
0062 {
0063 TGCompositeFrame* cfr = new TGHorizontalFrame(selH, 105, 22, kFixedSize);
0064 selH->AddFrame(cfr);
0065 cfr->AddFrame(new TGLabel(cfr, "Pass:"), new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 2, 0));
0066 }
0067
0068 TGHorizontalFrame* addBtnFrame = new TGHorizontalFrame(v1);
0069 v1->AddFrame(addBtnFrame, new TGLayoutHints(kLHintsExpandX));
0070 addBtnFrame->AddFrame(new TGHorizontal3DLine(addBtnFrame),
0071 new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 4, 8, 2, 2));
0072
0073 m_addBtn = new FWCustomIconsButton(addBtnFrame,
0074 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign.png"),
0075 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-over.png"),
0076 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-disabled.png"));
0077
0078 addBtnFrame->AddFrame(m_addBtn, new TGLayoutHints(kLHintsRight , 0, 6, 4, 1));
0079 TQObject::Connect(m_addBtn, "Clicked()", "FWGUIEventFilter", this, "newEventEntry()");
0080 }
0081
0082
0083
0084 {
0085 m_triggerSelectionFrameParent = new TGVerticalFrame(v1, GetWidth(), s_entryHeight, 0);
0086 v1->AddFrame(m_triggerSelectionFrameParent, new TGLayoutHints(kLHintsExpandX | kLHintsTop, 2, 2, 0, 0));
0087
0088
0089 TGHorizontalFrame* selH = new TGHorizontalFrame(m_triggerSelectionFrameParent);
0090 m_triggerSelectionFrameParent->AddFrame(selH, new TGLayoutHints(kLHintsExpandX));
0091
0092 {
0093 TGCompositeFrame* cfr = new TGHorizontalFrame(selH);
0094 selH->AddFrame(cfr, new TGLayoutHints(kLHintsExpandX));
0095 cfr->AddFrame(new TGLabel(cfr, "TriggerResults Filter Expression:"),
0096 new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 6, 04));
0097 }
0098 {
0099 TGCompositeFrame* cfr = new TGHorizontalFrame(selH, 122, 22, kFixedSize);
0100 selH->AddFrame(cfr);
0101 cfr->AddFrame(new TGLabel(cfr, "Comment:"), new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
0102 }
0103 {
0104 TGCompositeFrame* cfr = new TGHorizontalFrame(selH, 105, 22, kFixedSize);
0105 selH->AddFrame(cfr);
0106 cfr->AddFrame(new TGLabel(cfr, "Pass:"), new TGLayoutHints(kLHintsLeft | kLHintsBottom, 2, 2, 0, 0));
0107 }
0108
0109
0110
0111 TGHorizontalFrame* addBtnFrame = new TGHorizontalFrame(v1);
0112 v1->AddFrame(addBtnFrame, new TGLayoutHints(kLHintsExpandX));
0113
0114 addBtnFrame->AddFrame(new TGHorizontal3DLine(addBtnFrame),
0115 new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 4, 8, 2, 2));
0116 m_addBtn = new FWCustomIconsButton(addBtnFrame,
0117 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign.png"),
0118 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-over.png"),
0119 fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "plus-sign-disabled.png"));
0120
0121 addBtnFrame->AddFrame(m_addBtn, new TGLayoutHints(kLHintsRight , 0, 6, 4, 1));
0122 TQObject::Connect(m_addBtn, "Clicked()", "FWGUIEventFilter", this, "newTriggerEntry()");
0123 }
0124
0125
0126
0127 TGHorizontalFrame* headerFrame = new TGHorizontalFrame(v1 );
0128
0129 {
0130 TGHorizontalFrame* xx = new TGHorizontalFrame(v1);
0131 fireworks_root_gui::makeLabel(xx, "Combine Expression Width:", 152, 2, 2, 2, 2);
0132 m_rad1 = new TGRadioButton(xx, "OR", 81);
0133 xx->AddFrame(m_rad1, new TGLayoutHints(kLHintsNormal, 2, 10, 0, 0));
0134 m_rad1->SetState(kButtonDown);
0135 m_rad2 = new TGRadioButton(xx, "AND", 82);
0136 xx->AddFrame(m_rad2);
0137 m_rad1->Connect("Clicked()", "FWGUIEventFilter", this, "changeFilterMode()");
0138 m_rad2->Connect("Clicked()", "FWGUIEventFilter", this, "changeFilterMode()");
0139
0140 v1->AddFrame(xx, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
0141 }
0142 v1->AddFrame(headerFrame, new TGLayoutHints(kLHintsNormal, 1, 1, 1, 1));
0143
0144
0145 {
0146 TGHorizontalFrame* hf = new TGHorizontalFrame(v1);
0147 v1->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 20));
0148 fireworks_root_gui::makeLabel(hf, "Status:", 37, 2, 2, 2, 2);
0149 {
0150 TGGC* fTextGC;
0151 const TGFont* font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
0152 if (!font)
0153 font = gClient->GetResourcePool()->GetDefaultFont();
0154 GCValues_t gval;
0155 gval.fMask = kGCBackground | kGCFont | kGCForeground;
0156 gval.fFont = font->GetFontHandle();
0157 fTextGC = gClient->GetGC(&gval, kTRUE);
0158
0159 TGHorizontalFrame* labFrame = new TGHorizontalFrame(hf, 380, 22, kHorizontalFrame | kFixedWidth);
0160 hf->AddFrame(labFrame, new TGLayoutHints(kLHintsNormal));
0161
0162 m_stateLabel = new TGLabel(labFrame, "x", fTextGC->GetGC());
0163 labFrame->AddFrame(m_stateLabel, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
0164 }
0165 }
0166
0167
0168 TGHorizontalFrame* btnFrame = new TGHorizontalFrame(v1, 280, 30);
0169 v1->AddFrame(btnFrame, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX | kLHintsBottom, 0, 0, 2, 4));
0170
0171 TGTextButton* cancel = new TGTextButton(btnFrame, " Close ");
0172 btnFrame->AddFrame(cancel, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 20, 20, 2, 4));
0173 cancel->Connect("Clicked()", "FWGUIEventFilter", this, "CloseWindow()");
0174
0175 {
0176 TGHorizontalFrame* f = new TGHorizontalFrame(btnFrame);
0177 btnFrame->AddFrame(f, new TGLayoutHints(kLHintsRight, 4, 18, 2, 4));
0178 m_disableFilteringBtn = new TGTextButton(f, " Disable Filtering ");
0179 f->AddFrame(m_disableFilteringBtn, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4, 10, 2, 4));
0180 m_disableFilteringBtn->Connect("Clicked()", "FWGUIEventFilter", this, "disableFilters()");
0181
0182 m_applyBtn = new TGTextButton(f, "Apply Filters");
0183 f->AddFrame(m_applyBtn, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4, 8, 2, 4));
0184 m_applyBtn->Connect("Clicked()", "FWGUIEventFilter", this, "apply()");
0185 m_applyBtn->SetToolTipText("Enable filtering and apply changes.");
0186 }
0187 }
0188
0189 FWGUIEventFilter::~FWGUIEventFilter() {}
0190
0191 void FWGUIEventFilter::addSelector(FWEventSelector* sel) {
0192 TGCompositeFrame* parent = sel->m_triggerProcess.empty() ? m_eventSelectionFrame : m_triggerSelectionFrame;
0193 FWGUIEventSelector* es = new FWGUIEventSelector(parent, sel, m_navigator->getProcessList());
0194 parent->AddFrame(es, new TGLayoutHints(kLHintsExpandX));
0195 TQObject::Connect(
0196 es, "removeSelector(FWGUIEventSelector*)", "FWGUIEventFilter", this, "deleteEntry(FWGUIEventSelector*)");
0197 TQObject::Connect(es, "selectorChanged()", "FWGUIEventFilter", this, "checkApplyButton()");
0198
0199 m_guiSelectors.push_back(es);
0200 }
0201
0202 void FWGUIEventFilter::changeFilterMode() {
0203 TGButton* btn = (TGButton*)gTQSender;
0204
0205 if (btn->WidgetId() == 81)
0206 m_rad2->SetState(kButtonUp);
0207 else
0208 m_rad1->SetState(kButtonUp);
0209 checkApplyButton();
0210 }
0211
0212 void FWGUIEventFilter::show(std::list<FWEventSelector*>* sels, int filterMode, int filterState) {
0213 m_applyBtn->SetForegroundColor(0x000000);
0214 m_filtersRemoved = false;
0215
0216 m_isOpen = true;
0217
0218 m_origFilterMode = filterMode;
0219
0220 if (filterMode == CmsShowNavigator::kOr) {
0221 m_rad1->SetState(kButtonDown, false);
0222 m_rad2->SetState(kButtonUp, false);
0223 } else {
0224 m_rad2->SetState(kButtonDown, false);
0225 m_rad1->SetState(kButtonUp, false);
0226 }
0227
0228 assert(m_eventSelectionFrame == nullptr);
0229
0230 m_eventSelectionFrame = new TGVerticalFrame(m_eventSelectionFrameParent);
0231 m_eventSelectionFrameParent->AddFrame(m_eventSelectionFrame, new TGLayoutHints(kLHintsExpandX));
0232
0233 m_triggerSelectionFrame = new TGVerticalFrame(m_triggerSelectionFrameParent);
0234 m_triggerSelectionFrameParent->AddFrame(m_triggerSelectionFrame, new TGLayoutHints(kLHintsExpandX));
0235
0236 for (std::list<FWEventSelector*>::iterator i = sels->begin(); i != sels->end(); ++i)
0237 addSelector(*i);
0238
0239 updateFilterStateLabel(filterState);
0240
0241 MapSubwindows();
0242 Layout();
0243 MapRaised();
0244 }
0245
0246 void FWGUIEventFilter::reset() {
0247
0248 if (m_eventSelectionFrameParent) {
0249 m_eventSelectionFrameParent->RemoveFrame(m_eventSelectionFrame);
0250 m_eventSelectionFrame = nullptr;
0251 }
0252 if (m_triggerSelectionFrameParent) {
0253 m_triggerSelectionFrameParent->RemoveFrame(m_triggerSelectionFrame);
0254 m_triggerSelectionFrame = nullptr;
0255 }
0256
0257 for (std::list<FWGUIEventSelector*>::iterator i = m_guiSelectors.begin(); i != m_guiSelectors.end(); ++i)
0258 delete *i;
0259
0260 m_guiSelectors.clear();
0261 }
0262
0263
0264
0265
0266
0267 void FWGUIEventFilter::deleteEntry(FWGUIEventSelector* sel) {
0268 m_filtersRemoved = true;
0269
0270 m_guiSelectors.remove(sel);
0271
0272 TGCompositeFrame* p = nullptr;
0273 if (sel->origSelector()->m_triggerProcess.empty())
0274 p = m_eventSelectionFrame;
0275 else
0276 p = m_triggerSelectionFrame;
0277
0278 p->RemoveFrame(sel);
0279 Resize(GetWidth(), GetDefaultHeight());
0280 Layout();
0281 gClient->NeedRedraw(this);
0282 }
0283
0284 void FWGUIEventFilter::newTriggerEntry() {
0285 FWEventSelector* s = new FWEventSelector;
0286 s->m_triggerProcess = "HLT";
0287 addSelector(s);
0288 MapSubwindows();
0289
0290 Resize(GetWidth(), GetDefaultHeight());
0291
0292 Layout();
0293 }
0294
0295 void FWGUIEventFilter::newEventEntry() {
0296 addSelector(new FWEventSelector());
0297 MapSubwindows();
0298 Resize(GetWidth(), GetDefaultHeight());
0299 Layout();
0300 }
0301
0302 void FWGUIEventFilter::apply() {
0303 m_navigator->applyFiltersFromGUI();
0304
0305 m_origFilterMode = getFilterMode();
0306 m_filtersRemoved = false;
0307 m_applyBtn->SetForegroundColor(0x000000);
0308 fClient->NeedRedraw(this);
0309 }
0310
0311 void FWGUIEventFilter::setupDisableFilteringButton(bool x) { m_disableFilteringBtn->SetEnabled(x); }
0312
0313 void FWGUIEventFilter::disableFilters() { m_navigator->toggleFilterEnable(); }
0314
0315 int FWGUIEventFilter::getFilterMode() {
0316 if (m_rad1->IsOn())
0317 return CmsShowNavigator::kOr;
0318 else
0319 return CmsShowNavigator::kAnd;
0320 }
0321
0322 void FWGUIEventFilter::CloseWindow() {
0323 m_isOpen = false;
0324 m_eventSelectionFrameParent->RemoveFrame(m_eventSelectionFrame);
0325 m_eventSelectionFrame = nullptr;
0326 m_triggerSelectionFrameParent->RemoveFrame(m_triggerSelectionFrame);
0327 m_triggerSelectionFrame = nullptr;
0328
0329 FWGUIEventSelector* gs;
0330 for (std::list<FWGUIEventSelector*>::iterator i = m_guiSelectors.begin(); i != m_guiSelectors.end(); ++i) {
0331 gs = *i;
0332 delete gs;
0333 }
0334
0335 m_guiSelectors.clear();
0336 UnmapWindow();
0337 m_navigator->editFiltersExternally();
0338 }
0339
0340 void FWGUIEventFilter::checkApplyButton() {
0341
0342
0343 bool changed = (m_filtersRemoved || (getFilterMode() != m_origFilterMode));
0344
0345 if (!changed) {
0346 std::list<FWGUIEventSelector*>::iterator i = m_guiSelectors.begin();
0347 while (i != m_guiSelectors.end()) {
0348 if ((*i)->origSelector() == nullptr || (*i)->guiSelector()->m_enabled != (*i)->origSelector()->m_enabled ||
0349 (*i)->guiSelector()->m_expression != (*i)->origSelector()->m_expression) {
0350 changed = true;
0351 break;
0352 }
0353
0354 ++i;
0355 }
0356 }
0357
0358 m_applyBtn->SetForegroundColor(changed ? 0x40FF80 : 0x000000);
0359 gClient->NeedRedraw(m_applyBtn);
0360 }
0361
0362 void FWGUIEventFilter::updateFilterStateLabel(int state) {
0363 if (state == CmsShowNavigator::kOn)
0364 m_stateLabel->SetText(
0365 Form("%d events selected from %d ", m_navigator->getNSelectedEvents(), m_navigator->getNTotalEvents()));
0366 else if (state == CmsShowNavigator::kOff)
0367 m_stateLabel->SetText("Filtering Disabled ");
0368 else
0369 m_stateLabel->SetText("Filtering Withdrawn ");
0370
0371 Layout();
0372 }
0373
0374
0375
0376
0377
0378
0379
0380
0381
0382
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407 bool FWGUIEventFilter::HandleKey(Event_t* event) {
0408
0409
0410 if (GetBindList()->IsEmpty())
0411 FWGUIManager::getGUIManager()->getMainFrame()->bindCSGActionKeys(this);
0412
0413 TIter next(fBindList);
0414 TGMapKey* m;
0415 TGFrame* w = nullptr;
0416
0417 while ((m = (TGMapKey*)next())) {
0418 if (m->fKeyCode == event->fCode) {
0419 w = (TGFrame*)m->fWindow;
0420 if (w->HandleKey(event))
0421 return kTRUE;
0422 }
0423 }
0424 return kFALSE;
0425 }