Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:40

0001 #include "TGLabel.h"
0002 #include "TGComboBox.h"
0003 
0004 #include "Fireworks/Core/interface/FWGUIEventSelector.h"
0005 #include "Fireworks/Core/interface/FWEventSelector.h"
0006 #include "Fireworks/Core/interface/FWHLTValidator.h"
0007 #include "Fireworks/Core/src/FWGUIValidatingTextEntry.h"
0008 #include "Fireworks/Core/interface/FWCustomIconsButton.h"
0009 #include "Fireworks/Core/src/FWCheckBoxIcon.h"
0010 
0011 FWGUIEventSelector::FWGUIEventSelector(TGCompositeFrame* p,
0012                                        FWEventSelector* sel,
0013                                        std::vector<std::string>& triggerProcessList)
0014     : TGHorizontalFrame(p),
0015       m_guiSelector(nullptr),
0016       m_origSelector(nullptr),
0017       m_text1(nullptr),
0018       m_text2(nullptr),
0019       m_enableBtn(nullptr),
0020       m_deleteBtn(nullptr),
0021       m_nEvents(nullptr),
0022       m_combo(nullptr),
0023       m_validator(nullptr) {
0024   m_origSelector = sel;
0025   m_guiSelector = new FWEventSelector(m_origSelector);
0026 
0027   if (!m_guiSelector->m_triggerProcess.empty()) {
0028     m_combo = new TGComboBox(this);
0029     int cnt = 0;
0030     int id = -1;
0031     for (std::vector<std::string>::iterator i = triggerProcessList.begin(); i != triggerProcessList.end(); ++i) {
0032       if (*i == sel->m_triggerProcess)
0033         id = cnt;
0034       m_combo->AddEntry((*i).c_str(), cnt++);
0035     }
0036 
0037     if (id < 0) {
0038       m_combo->AddEntry(sel->m_triggerProcess.c_str(), cnt);
0039       id = cnt;
0040     }
0041     m_combo->Select(id, false);
0042     m_combo->Resize(80, 21);
0043     AddFrame(m_combo, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 1));
0044 
0045     m_validator = new FWHLTValidator(m_guiSelector->m_triggerProcess);
0046     m_combo->Connect("Selected(const char*)", "FWGUIEventSelector", this, "triggerProcessCallback(const char*)");
0047   }
0048 
0049   // -------------- expression
0050 
0051   m_text1 = new FWGUIValidatingTextEntry(this, m_guiSelector->m_expression.c_str());
0052   m_text1->SetHeight(20);
0053   m_text1->setValidator(m_validator);
0054   m_text1->ChangeOptions(0);
0055   m_text1->Connect("TextChanged(char*)", "FWGUIEventSelector", this, "expressionCallback(char*)");
0056   AddFrame(m_text1, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 2, 2, 1, 1));
0057 
0058   // -------------- comment
0059 
0060   TGCompositeFrame* cfr = new TGHorizontalFrame(this, 120, 20, kFixedSize);
0061   AddFrame(cfr, new TGLayoutHints(kLHintsNormal, 2, 2, 1, 3));
0062   m_text2 = new FWGUIValidatingTextEntry(cfr, m_guiSelector->m_description.c_str());
0063   //   m_text2->SetHeight(21);
0064   m_text2->setValidator(m_validator);
0065   m_text2->ChangeOptions(0);
0066   m_text2->Connect("TextChanged(char*)", "string", &m_guiSelector->m_description, "assign(char*)");
0067   cfr->AddFrame(m_text2, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 2, 2, 0, 0));
0068 
0069   // ---------------- selection info
0070 
0071   TGHorizontalFrame* labFrame = new TGHorizontalFrame(this, 60, 22, kFixedSize);
0072   AddFrame(labFrame, new TGLayoutHints(kLHintsBottom, 2, 2, 2, 2));
0073   m_nEvents = new TGLabel(labFrame, "");
0074   m_nEvents->SetTextJustify(kTextLeft);
0075   labFrame->AddFrame(m_nEvents, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX));
0076   updateNEvents();
0077 
0078   // ---------------- enable
0079 
0080   m_enableBtn = new TGCheckButton(this, "");
0081   m_enableBtn->SetToolTipText("Enable/disable the selection");
0082   m_enableBtn->SetOn(m_guiSelector->m_enabled);
0083   m_enableBtn->Connect("Toggled(bool)", "FWGUIEventSelector", this, "enableCallback(bool)");
0084   AddFrame(m_enableBtn, new TGLayoutHints(kLHintsNormal | kLHintsCenterY, 2, 2, 0, 0));
0085 
0086   // ---------------- delete
0087   m_deleteBtn = new FWCustomIconsButton(this,
0088                                         fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "delete.png"),
0089                                         fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "delete-over.png"),
0090                                         fClient->GetPicture(FWCheckBoxIcon::coreIcondir() + "delete-disabled.png"));
0091   AddFrame(m_deleteBtn, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 2, 2, 0, 0));
0092   TQObject::Connect(m_deleteBtn, "Clicked()", "FWGUIEventSelector", this, "deleteCallback()");
0093 }
0094 //____________________________________________________________________________
0095 FWGUIEventSelector::~FWGUIEventSelector() {
0096   delete m_guiSelector;
0097   delete m_validator;
0098 }
0099 
0100 //____________________________________________________________________________
0101 void FWGUIEventSelector::enableCallback(bool x) {
0102   m_guiSelector->m_enabled = x;
0103   selectorChanged();
0104 }
0105 
0106 //______________________________________________________________________________
0107 void FWGUIEventSelector::removeSelector(FWGUIEventSelector* s) {
0108   Emit("removeSelector(FWGUIEventSelector*)", (Long_t)s);
0109 }
0110 
0111 //______________________________________________________________________________
0112 void FWGUIEventSelector::deleteCallback() { removeSelector(this); }
0113 
0114 //______________________________________________________________________________
0115 void FWGUIEventSelector::triggerProcessCallback(const char* txt) {
0116   m_guiSelector->m_triggerProcess = txt;
0117   m_validator->setProcess(txt);
0118   selectorChanged();
0119 }
0120 
0121 //______________________________________________________________________________
0122 void FWGUIEventSelector::expressionCallback(char* txt) {
0123   m_guiSelector->m_expression = txt;
0124   selectorChanged();
0125 }
0126 
0127 //______________________________________________________________________________
0128 void FWGUIEventSelector::selectorChanged() {
0129   if (m_origSelector)
0130     m_origSelector->m_updated = false;
0131   Emit("selectorChanged()");
0132 }
0133 
0134 //______________________________________________________________________________
0135 void FWGUIEventSelector::updateNEvents() {
0136   if (m_origSelector && m_origSelector->m_updated) {
0137     m_nEvents->Enable();
0138     const char* txtInfo = Form("%3d", m_origSelector ? m_origSelector->m_selected : -1);
0139     m_nEvents->SetText(txtInfo);
0140   } else {
0141     m_nEvents->Disable();
0142     m_nEvents->SetText("no check");
0143   }
0144 }