CMS 3D CMS Logo

FWPathsPopup.cc
Go to the documentation of this file.
4 
7 
11 
16 
18 
22 
25 
27 #include <boost/python/errors.hpp>
28 #include "TGLabel.h"
29 #include "KeySymbols.h"
30 
32  UnmapWindow();
33  DontCallClose();
34 }
35 
37  : TGMainFrame(gClient->GetRoot(), 400, 600),
38  m_info(nullptr),
39  m_looper(looper),
40  m_hasChanges(false),
41  m_moduleLabel(nullptr),
42  m_moduleName(nullptr),
43  m_apply(nullptr),
44  m_psTable(new FWPSetTableManager()),
45  m_guiManager(guiManager) {
46  gVirtualX->SelectInput(GetId(),
47  kKeyPressMask | kKeyReleaseMask | kExposureMask | kPointerMotionMask | kStructureNotifyMask |
48  kFocusChangeMask | kEnterWindowMask | kLeaveWindowMask);
49  this->Connect("CloseWindow()", "FWPathsPopup", this, "windowIsClosing()");
50 
51  FWDialogBuilder builder(this);
52  builder.indent(4)
53  .spaceDown(10)
54  .addLabel("Filter:")
55  .floatLeft(4)
56  .expand(false, false)
57  .addTextEntry("", &m_search)
58  .expand(true, false)
59  .spaceDown(10)
61  .expand(true, true)
62  .addTextButton("Apply changes and reload", &m_apply);
63 
65  editor->SetBackgroundColor(gVirtualX->GetPixel(kYellow - 7));
66  editor->SetFrameDrawn(false);
68  m_psTable->m_editor->Connect("ReturnPressed()", "FWPathsPopup", this, "applyEditor()");
69 
70  m_apply->Connect("Clicked()", "FWPathsPopup", this, "scheduleReloadEvent()");
71  m_apply->SetEnabled(false);
72  m_search->SetEnabled(true);
73  m_search->Connect("TextChanged(const char *)", "FWPathsPopup", this, "updateFilterString(const char *)");
77  m_tableWidget->Connect("cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)",
78  "FWPathsPopup",
79  this,
80  "cellClicked(Int_t,Int_t,Int_t,Int_t,Int_t,Int_t)");
82 
83  SetWindowName("CMSSW Configuration Editor");
84  MapSubwindows();
85  editor->UnmapWindow();
86 
87  Layout();
88 }
89 
92 Bool_t FWPathsPopup::HandleKey(Event_t *event) {
93  UInt_t keysym = event->fCode;
94 
95  if (keysym == (UInt_t)gVirtualX->KeysymToKeycode(kKey_Escape)) {
96  // called from FWPSetCellEditor
98  m_psTable->setSelection(-1, -1, 0);
99  }
100  return TGMainFrame::HandleKey(event);
101 }
102 
106  bool applied = m_psTable->applyEditor();
107  if (applied)
108  m_apply->SetEnabled(true);
109 }
110 
117 void FWPathsPopup::cellClicked(Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t, Int_t) {
118  if (iButton != kButton1)
119  return;
120 
121  if (iColumn == 0 || iColumn == 1) {
122  // Save and close the previous editor, if required.
123  if (m_psTable->selectedColumn() == 1 && m_psTable->selectedRow() != -1) {
124  int oldIndex = m_psTable->rowToIndex()[m_psTable->selectedRow()];
125  FWPSetTableManager::PSetData &oldData = m_psTable->data()[oldIndex];
126 
127  if (oldData.editable)
128  applyEditor();
129  }
130 
131  m_psTable->setSelection(iRow, iColumn, iKeyMod);
132 
133  if (iColumn == 0)
134  m_psTable->setExpanded(iRow);
135  }
136 }
137 
140  m_psTable->setSelection(-1, -1, 0);
142 }
143 
146  assert(info);
147  m_info = info;
148 }
149 
152  m_guiManager->updateStatus((mcc.moduleDescription()->moduleName() + " processed.").c_str());
153  gSystem->ProcessEvents();
154 }
155 
158  m_guiManager->updateStatus(("Processing " + mcc.moduleDescription()->moduleName() + "...").c_str());
159  gSystem->ProcessEvents();
160 }
161 
163  m_guiManager->updateStatus("Done processing.");
164  gSystem->ProcessEvents();
165 
166  // Get the last process name from the process history:
167  // this should be the one specified in the cfg file
168 
169  if (event.processHistory().empty()) {
170  fwLog(fwlog::kInfo) << "Path GUI:: no process history available.\n";
171  return;
172  }
173  edm::ProcessHistory::const_iterator pi = event.processHistory().end() - 1;
174  std::string processName = pi->processName();
175 
176  // It's called TriggerResults but actually contains info on all paths
177  edm::InputTag tag("TriggerResults", "", processName);
179  event.getByLabel(tag, triggerResults);
180 
181  std::vector<FWPSetTableManager::PathUpdate> pathUpdates;
182 
183  if (triggerResults.isValid()) {
184  const edm::TriggerNames &triggerNames = event.triggerNames(*triggerResults);
185 
186  for (size_t i = 0, e = triggerResults->size(); i != e; ++i) {
188  update.pathName = triggerNames.triggerName(i);
189  update.passed = triggerResults->accept(i);
190  update.choiceMaker = triggerResults->index(i);
191  pathUpdates.push_back(update);
192  }
193  }
195  m_psTable->update(pathUpdates);
198 }
199 
210  applyEditor();
211  try {
212  for (size_t mni = 0, mne = m_psTable->modules().size(); mni != mne; ++mni) {
214  if (module.dirty == false)
215  continue;
217  m_looper->requestChanges(data.label, *module.current_pset);
218  }
219  m_hasChanges = true;
220  m_apply->SetEnabled(false);
221  gSystem->ExitLoop();
222  } catch (boost::python::error_already_set const &) {
223  edm::pythonToCppException("Configuration", "");
224  Py_Finalize();
225  } catch (cms::Exception &exception) {
226  std::cout << exception.what() << std::endl;
227  }
228  // Return control to the FWFFLooper so that it can decide what to do next.
229 }
FWPathsPopup::postEvent
void postEvent(edm::Event const &event)
Definition: FWPathsPopup.cc:162
FWTableWidget::SetBackgroundColor
void SetBackgroundColor(Pixel_t) override
Definition: FWTableWidget.cc:173
ModuleCallingContext.h
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
mps_fire.i
i
Definition: mps_fire.py:428
FWGUIManager
Definition: FWGUIManager.h:95
funct::false
false
Definition: Factorize.h:29
FWPathsPopup::m_psTable
FWPSetTableManager * m_psTable
Definition: FWPathsPopup.h:56
FWPSetTableManager.h
TriggerResults.h
ScheduleInfo.h
edm::pythonToCppException
void pythonToCppException(const std::string &iType, const std::string &error)
Definition: PyBind11Wrapper.cc:6
FWPSetTableManager::setCellValueEditor
void setCellValueEditor(FWPSetCellEditor *editor)
Definition: FWPSetTableManager.cc:500
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FWPSetTableManager::ModuleInfo::current_pset
edm::ParameterSet * current_pset
Definition: FWPSetTableManager.h:124
edm::ModuleDescription::moduleName
std::string const & moduleName() const
Definition: ModuleDescription.h:42
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
FWDialogBuilder::indent
FWDialogBuilder & indent(int left=2, int right=-1)
Definition: FWDialogBuilder.cc:202
FWPSetTableManager::updateFilter
virtual void updateFilter(const char *filter)
Definition: FWPSetTableManager.cc:742
cms::cuda::assert
assert(be >=bs)
FWPSetTableManager::selectedColumn
int selectedColumn() const
Definition: FWPSetTableManager.cc:567
FWPSetTableManager::cancelEditor
void cancelEditor()
Definition: FWPSetTableManager.cc:506
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
FWPSetTableManager::data
std::vector< PSetData > & data()
Definition: FWPSetTableManager.h:104
FWPathsPopup.h
FWDialogBuilder::floatLeft
FWDialogBuilder & floatLeft(size_t spacing=3)
Definition: FWDialogBuilder.cc:408
edm::ModuleCallingContext::moduleDescription
ModuleDescription const * moduleDescription() const
Definition: ModuleCallingContext.h:50
FWPathsPopup::preModuleEvent
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
Definition: FWPathsPopup.cc:157
edm::Handle< edm::TriggerResults >
FWPSetTableManager::selectedRow
int selectedRow() const
Definition: FWPSetTableManager.cc:565
FWDialogBuilder::addTextButton
FWDialogBuilder & addTextButton(const char *text, TGTextButton **out=nullptr)
Definition: FWDialogBuilder.cc:285
FWFFLooper.h
ModuleDescription.h
FWPathsPopup::m_tableWidget
FWTableWidget * m_tableWidget
Definition: FWPathsPopup.h:57
FWPSetTableManager::entries
std::vector< PSetData > & entries()
Definition: FWPSetTableManager.h:142
FWGUIManager::updateStatus
void updateStatus(const char *status)
Definition: FWGUIManager.cc:367
FWPSetTableManager::update
void update(std::vector< PathUpdate > &pathUpdates)
Definition: FWPSetTableManager.cc:466
FWTableWidget::disableGrowInWidth
void disableGrowInWidth()
Definition: FWTableWidget.cc:498
FWPathsPopup::m_guiManager
FWGUIManager * m_guiManager
Definition: FWPathsPopup.h:59
alignCSCRings.s
s
Definition: alignCSCRings.py:92
FWPSetTableManager::m_editor
FWPSetCellEditor * m_editor
Definition: FWPSetTableManager.h:185
FWPathsPopup::cellClicked
void cellClicked(Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t iGlobalX, Int_t iGlobalY)
Definition: FWPathsPopup.cc:117
FWDialogBuilder
Definition: FWDialogBuilder.h:93
ProcessHistory.h
edm::StreamContext
Definition: StreamContext.h:31
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
L1TEGammaOffline_cfi.triggerNames
triggerNames
Definition: L1TEGammaOffline_cfi.py:40
FWTableWidget.h
FWDialogBuilder::spaceDown
FWDialogBuilder & spaceDown(size_t spacing=3)
Definition: FWDialogBuilder.cc:418
FWPSetTableManager::updateSchedule
void updateSchedule(const edm::ScheduleInfo *info)
Definition: FWPSetTableManager.cc:383
str
#define str(s)
Definition: TestProcessor.cc:51
FWPathsPopup::m_search
TGTextEntry * m_search
Definition: FWPathsPopup.h:58
FWPSetTableManager::PSetData
Definition: FWPSetTableManager.h:38
FWDialogBuilder.h
FWDialogBuilder::expand
FWDialogBuilder & expand(size_t expandX=true, size_t expandY=false)
Definition: FWDialogBuilder.cc:479
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWPathsPopup::updateFilterString
void updateFilterString(const char *str)
Definition: FWPathsPopup.cc:138
looper
Definition: looper.py:1
FWPSetTableManager::PSetData::editable
bool editable
Definition: FWPSetTableManager.h:78
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
FWTableManagerBase::dataChanged
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes.
Definition: FWTableManagerBase.cc:63
FWPathsPopup::applyEditor
void applyEditor()
Definition: FWPathsPopup.cc:105
Event.h
edm::ProcessHistory::const_iterator
collection_type::const_iterator const_iterator
Definition: ProcessHistory.h:19
FWPathsPopup::m_looper
FWFFLooper * m_looper
Definition: FWPathsPopup.h:48
FWPathsPopup::windowIsClosing
void windowIsClosing()
Definition: FWPathsPopup.cc:31
TriggerNames.h
FWPSetTableManager::ModuleInfo::entry
size_t entry
Definition: FWPSetTableManager.h:116
FWPSetTableManager::setSelection
void setSelection(int row, int column, int mask)
Definition: FWPSetTableManager.cc:577
FWTabularWidget::DoRedraw
void DoRedraw() override
Definition: FWTabularWidget.cc:221
fwLog.h
edm::ScheduleInfo
Definition: ScheduleInfo.h:32
FWPSetTableManager::rowToIndex
std::vector< int > & rowToIndex()
Definition: FWPSetTableManager.h:105
FWPSetTableManager
Definition: FWPSetTableManager.h:33
FWPSetCellEditor.h
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
FWPathsPopup::FWPathsPopup
FWPathsPopup(FWFFLooper *, FWGUIManager *)
Definition: FWPathsPopup.cc:36
fwlog::kInfo
Definition: fwLog.h:35
FWPathsPopup::m_info
const edm::ScheduleInfo * m_info
Definition: FWPathsPopup.h:45
FWPathsPopup::setup
void setup(const edm::ScheduleInfo *info)
Definition: FWPathsPopup.cc:145
FWTableWidget::SetLineSeparatorColor
void SetLineSeparatorColor(Pixel_t)
Definition: FWTableWidget.cc:209
FWTableWidget::body
FWTabularWidget * body()
Definition: FWTableWidget.h:90
FWPathsPopup::HandleKey
Bool_t HandleKey(Event_t *event) override
Definition: FWPathsPopup.cc:92
FWPSetCellEditor
Definition: FWPSetCellEditor.h:24
edm::TriggerNames
Definition: TriggerNames.h:55
FWFFLooper
Definition: FWFFLooper.h:42
EventSetup.h
PyBind11Wrapper.h
Exception.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
FWPathsPopup::m_apply
TGTextButton * m_apply
Definition: FWPathsPopup.h:55
FWTableWidget::SetHeaderBackgroundColor
void SetHeaderBackgroundColor(Pixel_t)
Definition: FWTableWidget.cc:188
FWDialogBuilder::addTable
FWDialogBuilder & addTable(FWTableManagerBase *manager, FWTableWidget **out=nullptr)
Definition: FWDialogBuilder.cc:336
FWPSetTableManager::modules
std::vector< ModuleInfo > & modules()
Definition: FWPSetTableManager.h:141
FWPathsPopup::scheduleReloadEvent
void scheduleReloadEvent()
Definition: FWPathsPopup.cc:209
pi
const Double_t pi
Definition: trackSplitPlot.h:36
cms::Exception
Definition: Exception.h:70
FWPSetTableManager::applyEditor
bool applyEditor()
Definition: FWPSetTableManager.cc:519
StreamContext.h
FWPathsPopup::postModuleEvent
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
Definition: FWPathsPopup.cc:151
FWFFLooper::requestChanges
void requestChanges(const std::string &, const edm::ParameterSet &)
Definition: FWFFLooper.cc:449
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
FWPSetTableManager::ModuleInfo
Definition: FWPSetTableManager.h:110
FWPSetTableManager::ModuleInfo::dirty
bool dirty
Definition: FWPSetTableManager.h:121
FWPSetTableManager::PathUpdate
Definition: FWPSetTableManager.h:128
edm::InputTag
Definition: InputTag.h:15
FWPathsPopup::m_hasChanges
bool m_hasChanges
Definition: FWPathsPopup.h:50
FWDialogBuilder::addTextEntry
FWDialogBuilder & addTextEntry(const char *defaultText, TGTextEntry **out)
Definition: FWDialogBuilder.cc:301
FWDialogBuilder::addLabel
FWDialogBuilder & addLabel(const char *text, size_t fontSize=12, size_t weight=0, TGLabel **out=nullptr)
Definition: FWDialogBuilder.cc:212
update
#define update(a, b)
Definition: TrackClassifier.cc:10
FWGUIManager.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
FWPSetTableManager::setExpanded
void setExpanded(int row)
Definition: FWPSetTableManager.cc:620