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 }
collection_type::const_iterator const_iterator
std::vector< ModuleInfo > & modules()
void scheduleReloadEvent()
void preModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
static const TGPicture * info(bool iBackgroundIsBlack)
void pythonToCppException(const std::string &iType, const std::string &error)
FWGUIManager * m_guiManager
Definition: FWPathsPopup.h:59
FWDialogBuilder & addTextButton(const char *text, TGTextButton **out=nullptr)
std::vector< int > & rowToIndex()
void DoRedraw() override
void cellClicked(Int_t iRow, Int_t iColumn, Int_t iButton, Int_t iKeyMod, Int_t iGlobalX, Int_t iGlobalY)
void SetHeaderBackgroundColor(Pixel_t)
std::string const & moduleName() const
TGTextEntry * m_search
Definition: FWPathsPopup.h:58
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
void updateStatus(const char *status)
FWDialogBuilder & addLabel(const char *text, size_t fontSize=12, size_t weight=0, TGLabel **out=nullptr)
ModuleDescription const * moduleDescription() const noexcept
assert(be >=bs)
void SetLineSeparatorColor(Pixel_t)
const Double_t pi
Definition: looper.py:1
void requestChanges(const std::string &, const edm::ParameterSet &)
Definition: FWFFLooper.cc:449
void applyEditor()
void disableGrowInWidth()
void windowIsClosing()
Definition: FWPathsPopup.cc:31
std::vector< PSetData > & data()
FWTableWidget * m_tableWidget
Definition: FWPathsPopup.h:57
FWTabularWidget * body()
Definition: FWTableWidget.h:90
static std::string const triggerResults
Definition: EdmProvDump.cc:47
FWPSetCellEditor * m_editor
const edm::ScheduleInfo * m_info
Definition: FWPathsPopup.h:45
void updateSchedule(const edm::ScheduleInfo *info)
TGTextButton * m_apply
Definition: FWPathsPopup.h:55
void SetBackgroundColor(Pixel_t) override
FWDialogBuilder & addTextEntry(const char *defaultText, TGTextEntry **out)
void updateFilterString(const char *str)
virtual void updateFilter(const char *filter)
FWDialogBuilder & floatLeft(size_t spacing=3)
#define fwLog(_level_)
Definition: fwLog.h:45
FWDialogBuilder & addTable(FWTableManagerBase *manager, FWTableWidget **out=nullptr)
void setCellValueEditor(FWPSetCellEditor *editor)
bool m_hasChanges
Definition: FWPathsPopup.h:50
FWDialogBuilder & expand(size_t expandX=true, size_t expandY=false)
void postModuleEvent(edm::StreamContext const &, edm::ModuleCallingContext const &)
FWFFLooper * m_looper
Definition: FWPathsPopup.h:48
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
#define update(a, b)
void postEvent(edm::Event const &event)
void update(std::vector< PathUpdate > &pathUpdates)
void setSelection(int row, int column, int mask)
FWPSetTableManager * m_psTable
Definition: FWPathsPopup.h:56
void setup(const edm::ScheduleInfo *info)
#define str(s)
FWPathsPopup(FWFFLooper *, FWGUIManager *)
Definition: FWPathsPopup.cc:36
FWDialogBuilder & indent(int left=2, int right=-1)
std::vector< PSetData > & entries()
Bool_t HandleKey(Event_t *event) override
Definition: FWPathsPopup.cc:92
FWDialogBuilder & spaceDown(size_t spacing=3)
Definition: event.py:1