CMS 3D CMS Logo

FWPSetTableManager.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWInterface
4 // Class : FWPSetTableManager
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author:
10 // Created: Mon Feb 28 17:06:54 CET 2011
11 //
12 
13 #include <map>
14 #include <stdexcept>
15 
21 
25 //
26 // constants, enums and typedefs
27 //
28 
29 //
30 // static data member definitions
31 //
32 
33 
34 // FIXME: copied from Entry.cc should find a way to use the original
35 // table.
36 struct TypeTrans {
37  TypeTrans();
38 
39  typedef std::vector<std::string> CodeMap;
40  CodeMap table_;
41  std::map<std::string, char> type2Code_;
42 };
43 
45  table_['b'] = "vBool";
46  table_['B'] = "bool";
47  table_['i'] = "vint32";
48  table_['I'] = "int32";
49  table_['u'] = "vuint32";
50  table_['U'] = "uint32";
51  table_['l'] = "vint64";
52  table_['L'] = "int64";
53  table_['x'] = "vuint64";
54  table_['X'] = "uint64";
55  table_['s'] = "vstring";
56  table_['S'] = "string";
57  table_['d'] = "vdouble";
58  table_['D'] = "double";
59  table_['p'] = "vPSet";
60  table_['P'] = "PSet";
61  table_['T'] = "path";
62  table_['F'] = "FileInPath";
63  table_['t'] = "InputTag";
64  table_['v'] = "VInputTag";
65  table_['g'] = "ESInputTag";
66  table_['G'] = "VESInputTag";
67  table_['e'] = "VEventID";
68  table_['E'] = "EventID";
69  table_['m'] = "VLuminosityBlockID";
70  table_['M'] = "LuminosityBlockID";
71  table_['a'] = "VLuminosityBlockRange";
72  table_['A'] = "LuminosityBlockRange";
73  table_['r'] = "VEventRange";
74  table_['R'] = "EventRange";
75 
76  for(CodeMap::const_iterator itCode = table_.begin(), itCodeEnd = table_.end();
77  itCode != itCodeEnd;
78  ++itCode) {
79  type2Code_[*itCode] = (itCode - table_.begin());
80  }
81 }
82 
84 
85 
86 //
87 // constructors and destructor
88 //
89 
91  : m_selectedRow(-1)
92 {
93 
95  hc->SetForeground(0xdddddd);
96 
98 
101 }
102 
104 {
105 }
106 
107 //==============================================================================
108 //==============================================================================
109 //========== IMPORT CMSSW CONFIG TO TABLE ======================================
110 //==============================================================================
111 //==============================================================================
112 
114 {
115  PSetData data;
116  data.label = key;
117  data.tracked = entry.isTracked();
118  data.level = m_parentStack.size();
119  data.parent = m_parentStack.back();
120  data.type = 'P';
121  data.module = m_modules.size() - 1;
122  data.path = m_paths.size() - 1;
123  data.pset = & entry.psetForUpdate();
124  data.editable = false;
125  m_parentStack.push_back(m_entries.size());
126  m_entries.push_back(data);
127 
128  handlePSet(data.pset);
129  m_parentStack.pop_back();
130 }
131 
133 {
134  PSetData data;
135  data.label = key;
136  data.tracked = entry.isTracked();
137  data.level = m_parentStack.size();
138  data.parent = m_parentStack.back();
139  data.type = 'p';
140  data.module = m_modules.size() - 1;
141  data.path = m_paths.size() - 1;
142  data.editable = false;
143  m_parentStack.push_back(m_entries.size());
144  m_entries.push_back(data);
145 
146  std::stringstream ss;
147 
148  for (size_t i = 0, e = entry.vpset().size(); i != e; ++i)
149  {
150  ss.str("");
151  ss << key << "[" << i << "]";
152  PSetData vdata;
153  vdata.label = ss.str();
154  vdata.tracked = entry.isTracked();
155  vdata.level = m_parentStack.size();
156  vdata.parent = m_parentStack.back();
157  vdata.module = m_modules.size() - 1;
158  vdata.path = m_paths.size() - 1;
159  vdata.editable = false;
160  vdata.pset = &entry.vpsetForUpdate()[i];
161  m_parentStack.push_back(m_entries.size());
162  m_entries.push_back(vdata);
163  handlePSet( & entry.vpsetForUpdate()[i]);
164  m_parentStack.pop_back();
165  }
166  m_parentStack.pop_back();
167 }
168 
170 {
171  edm::ParameterSet &ps = * psp;
172 
173  typedef edm::ParameterSet::table::const_iterator TIterator;
174  for (TIterator i = ps.tbl().begin(), e = ps.tbl().end(); i != e; ++i)
175  handleEntry(i->second, i->first);
176 
177  typedef edm::ParameterSet::psettable::const_iterator PSIterator;
178  for (PSIterator i = ps.psetTable().begin(), e = ps.psetTable().end(); i != e; ++i)
179  handlePSetEntry(const_cast<edm::ParameterSetEntry&>(i->second), i->first);
180 
181  typedef edm::ParameterSet::vpsettable::const_iterator VPSIterator;
182  for (VPSIterator i = ps.vpsetTable().begin(), e = ps.vpsetTable().end(); i != e; ++i)
183  handleVPSetEntry(const_cast<edm::VParameterSetEntry&>(i->second), i->first);
184 }
185 
186 template <class T>
188 {
189  std::stringstream ss;
190  ss << v;
191  data.value = ss.str();
192  m_entries.push_back(data);
193 }
194 
195 template <typename T>
197 {
198  std::stringstream ss;
199  ss << "[";
200  for (size_t ii = 0, ie = v.size(); ii != ie; ++ii)
201  {
202  if (quotes)
203  ss << "\"";
204  ss << v[ii];
205  if (quotes)
206  ss << "\"";
207  if (ii + 1 != ie)
208  ss << ", ";
209  }
210  ss << "]";
211  data.value = ss.str();
212  m_entries.push_back(data);
213 }
214 
216 {
217  std::stringstream ss;
219  data.label = key;
220  data.tracked = entry.isTracked();
221  data.type = entry.typeCode();
222  data.level = m_parentStack.size();
223  data.parent = m_parentStack.back();
224  data.module = m_modules.size() - 1;
225  data.type = entry.typeCode();
226  if (data.label[0] == '@')
227  data.editable = false;
228  else
229  data.editable = true;
230 
231  switch(entry.typeCode())
232  {
233  case 'b':
234  {
235  data.value = entry.getBool() ? "True" : "False";
236  m_entries.push_back(data);
237  break;
238  }
239  case 'B':
240  {
241  data.value = entry.getBool() ? "True" : "False";
242  m_entries.push_back(data);
243  break;
244  }
245  case 'i':
246  {
247  createVectorString(data, entry.getVInt32(), false);
248  break;
249  }
250  case 'I':
251  {
252  createScalarString(data, entry.getInt32());
253  break;
254  }
255  case 'u':
256  {
257  createVectorString(data, entry.getVUInt32(), false);
258  break;
259  }
260  case 'U':
261  {
262  createScalarString(data, entry.getUInt32());
263  break;
264  }
265  case 'l':
266  {
267  createVectorString(data, entry.getVInt64(), false);
268  break;
269  }
270  case 'L':
271  {
272  createScalarString(data, entry.getInt32());
273  break;
274  }
275  case 'x':
276  {
277  createVectorString(data, entry.getVUInt64(), false);
278  break;
279  }
280  case 'X':
281  {
282  createScalarString(data, entry.getUInt64());
283  break;
284  }
285  case 's':
286  {
287  createVectorString(data, entry.getVString(), false);
288  break;
289  }
290  case 'S':
291  {
292  createScalarString(data, entry.getString());
293  break;
294  }
295  case 'd':
296  {
297  createVectorString(data, entry.getVDouble(), false);
298  break;
299  }
300  case 'D':
301  {
302  createScalarString(data, entry.getDouble());
303  break;
304  }
305  case 'p':
306  {
307  // Matevz ???
308  throw std::runtime_error("FWPSetTableManager::handleEntryGet, entry type 'p' not expected.");
309  // std::vector<edm::ParameterSet> psets = entry.getVPSet();
310  // for (size_t psi = 0, pse = psets.size(); psi != pse; ++psi)
311  // handlePSet(psets[psi]);
312  break;
313  }
314  case 'P':
315  {
316  // Matevz ???
317  throw std::runtime_error("FWPSetTableManager::handleEntry, entry type 'P not expected.");
318  // handlePSet(entry.getPSet());
319  break;
320  }
321  case 't':
322  {
323  data.value = entry.getInputTag().encode();
324  m_entries.push_back(data);
325  break;
326  }
327  case 'v':
328  {
329  std::vector<std::string> tags;
330  tags.resize(entry.getVInputTag().size());
331  for (size_t iti = 0, ite = tags.size(); iti != ite; ++iti)
332  tags[iti] = entry.getVInputTag()[iti].encode();
333  createVectorString(data, tags, true);
334  break;
335  }
336  case 'g':
337  {
338  data.value = entry.getESInputTag().encode();
339  m_entries.push_back(data);
340  break;
341  }
342  case 'G':
343  {
344  std::vector<std::string> tags;
345  tags.resize(entry.getVESInputTag().size());
346  for (size_t iti = 0, ite = tags.size(); iti != ite; ++iti)
347  tags[iti] = entry.getVESInputTag()[iti].encode();
348  createVectorString(data, tags, true);
349  break;
350  }
351  case 'F':
352  {
354  break;
355  }
356  case 'e':
357  {
358  data.editable = false;
359  std::vector<edm::EventID> ids;
360  ids.resize(entry.getVEventID().size());
361  for ( size_t iri = 0, ire = ids.size(); iri != ire; ++iri )
362  ids[iri] = entry.getVEventID()[iri];
363  createVectorString(data, ids, true);
364  break;
365  }
366  case 'E':
367  {
368  data.editable = false;
369  createScalarString(data, entry.getEventID());
370  break;
371  }
372  case 'm':
373  {
374  data.editable = false;
375  std::vector<edm::LuminosityBlockID> ids;
376  ids.resize(entry.getVLuminosityBlockID().size());
377  for ( size_t iri = 0, ire = ids.size(); iri != ire; ++iri )
378  ids[iri] = entry.getVLuminosityBlockID()[iri];
379  createVectorString(data, ids, true);
380  break;
381  }
382  case 'M':
383  {
384  data.editable = false;
386  break;
387  }
388  case 'a':
389  {
390  data.editable = false;
391  std::vector<edm::LuminosityBlockRange> ranges;
392  ranges.resize(entry.getVLuminosityBlockRange().size());
393  for ( size_t iri = 0, ire = ranges.size(); iri != ire; ++iri )
394  ranges[iri] = entry.getVLuminosityBlockRange()[iri];
395  createVectorString(data, ranges, true);
396  break;
397  }
398  case 'A':
399  {
400  data.editable = false;
402  break;
403  }
404  case 'r':
405  {
406  data.editable = false;
407  std::vector<edm::EventRange> ranges;
408  ranges.resize(entry.getVEventRange().size());
409  for ( size_t iri = 0, ire = ranges.size(); iri != ire; ++iri )
410  ranges[iri] = entry.getVEventRange()[iri];
411  createVectorString(data, ranges, true);
412  break;
413  }
414  case 'R':
415  {
416  data.editable = false;
417  createScalarString(data, entry.getEventRange());
418  break;
419  }
420  default:
421  {
422  break;
423  }
424  }
425 }
426 
427 /* the actual structure of the model will not change, only
428  its contents, because of the way CMSSW is designed,
429  hence this method only needs to be called once.
430  */
432 {
433  if (!m_entries.empty())
434  return;
435  // Execute only once since the schedule itself
436  // cannot be altered.
437  assert(m_availablePaths.empty());
439 
440  for (size_t i = 0, e = m_availablePaths.size(); i != e; ++i)
441  {
442  PSetData pathEntry;
443  const std::string &pathName = m_availablePaths[i];
444  pathEntry.label = pathName;
445  m_pathIndex.insert(std::make_pair(pathName, m_paths.size()));
446 
447  pathEntry.value = "Path";
448  pathEntry.level= 0;
449  pathEntry.parent = -1;
450  pathEntry.path = i;
451  pathEntry.editable = false;
452 
453  PathInfo pathInfo;
454  pathInfo.entryId = m_entries.size();
455  pathInfo.passed = false;
456  pathInfo.moduleStart = m_modules.size();
457  m_paths.push_back(pathInfo);
458 
459  m_parentStack.push_back(m_entries.size());
460  m_entries.push_back(pathEntry);
461 
462  std::vector<std::string> pathModules;
463  info->modulesInPath(pathName, pathModules);
464 
465  for (size_t mi = 0, me = pathModules.size(); mi != me; ++mi)
466  {
467  PSetData moduleEntry;
468 
469  const edm::ParameterSet* ps = info->parametersForModule(pathModules[mi]);
470 
471  const edm::ParameterSet::table& pst = ps->tbl();
472  const edm::ParameterSet::table::const_iterator ti = pst.find("@module_edm_type");
473  if (ti == pst.end())
474  moduleEntry.value = "Unknown module name";
475  else
476  moduleEntry.value = ti->second.getString();
477 
478  moduleEntry.label = pathModules[mi];
479  moduleEntry.parent = m_parentStack.back();
480  moduleEntry.level = m_parentStack.size();
481  moduleEntry.module = mi;
482  moduleEntry.path = i;
483  moduleEntry.editable = false;
484 
485  ModuleInfo moduleInfo;
486  moduleInfo.path = m_paths.size() - 1;
487  moduleInfo.entry = m_entries.size();
488  moduleInfo.passed = false;
489  moduleInfo.dirty = false;
490  moduleInfo.orig_pset = new edm::ParameterSet(*ps);
491  moduleInfo.current_pset = new edm::ParameterSet(*ps);
492  m_modules.push_back(moduleInfo);
493 
494  moduleEntry.pset = moduleInfo.current_pset;
495 
496  m_parentStack.push_back(m_entries.size());
497  m_entries.push_back(moduleEntry);
498  handlePSet(moduleEntry.pset);
499  m_parentStack.pop_back();
500  }
501  m_paths.back().moduleEnd = m_modules.size();
502  m_parentStack.pop_back();
503  }
504 
505  // Nothing is expanded by default.
506  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
507  m_entries[i].expandedUser = false;
508 
509  m_filter = "";
510 
512 } //updateSchedule
513 
514 
518 void FWPSetTableManager::update(std::vector<PathUpdate> &pathUpdates)
519 {
520  // Reset all the path / module status information, so that
521  // by default paths and modules are considered "not passed".
522  for (size_t pi = 0, pe = m_paths.size(); pi != pe; ++pi)
523  m_paths[pi].passed = false;
524  for (size_t mi = 0, me = m_modules.size(); mi != me; ++mi)
525  m_modules[mi].passed = false;
526 
527  // Update whether or not a given path / module passed selection.
528  for (size_t pui = 0, pue = pathUpdates.size(); pui != pue; ++pui)
529  {
530  PathUpdate &update = pathUpdates[pui];
531  std::map<std::string, size_t>::const_iterator index = m_pathIndex.find(update.pathName);
532  if (index == m_pathIndex.end())
533  {
534  fwLog(fwlog::kError) << "Path " << update.pathName << "cannot be found!" << std::endl;
535  continue;
536  }
537  PathInfo &pathInfo = m_paths[index->second];
538  pathInfo.passed = update.passed;
539 
540  for (size_t mi = pathInfo.moduleStart, me = pathInfo.moduleEnd; mi != me; ++mi)
541  {
542  ModuleInfo &moduleInfo = m_modules[mi];
543  moduleInfo.passed = update.passed || ((mi-pathInfo.moduleStart) < update.choiceMaker);
544  }
545  }
546 
547  implSort(-1, true);
548 }
549 
550 //==============================================================================
551 //==============================================================================
552 //=============== CELL EDITOR ACTIONS ==========================================
553 //==============================================================================
554 //==============================================================================
555 
557 {
558  m_editor = editor;
560 }
561 
562 
565 {
566  if (!m_editor)
567  return;
568 
569  // printf("FWPSetTableManager::cancelEditor() \n");
570  setSelection(-1, -1, 0);
571  m_editor->UnmapWindow();
572 }
573 
579 {
580  if (!m_editor)
581  return false;
582 
583  if (m_selectedRow == -1 ||m_selectedColumn != 1 )
584  return false;
585 
586 
587  // printf("FWPSetTableManager::applyEditor() \n");
589  PSetData &parent = m_entries[data.parent];
590  bool success = false;
591  try
592  {
593  success = m_editor->apply(data, parent);
594 
595  if (success)
596  {
597  data.value = m_editor->GetText();
598  m_modules[data.module].dirty = true;
599  setSelection(-1, -1, 0);
600  m_editor->UnmapWindow();
601  // ???
602  // copy current to orig
603  }
604  else
605  {
606  // ???
607  // set current from orig? reimport module ... hmmh, hard.
608  }
609  }
610  catch(cms::Exception &e)
611  {
612  m_editor->SetForegroundColor(gVirtualX->GetPixel(kRed));
613  }
614  return success;
615 }
616 
617 
618 //==============================================================================
619 //==============================================================================
620 //======== TABLE UI MNG (virutals FWTableManagerBase virtuals, etc.) =========
621 //==============================================================================
622 //==============================================================================
624  return "Modules & their parameters";
625 }
626 
627 std::vector<std::string> FWPSetTableManager::getTitles() const
628 {
629  std::vector<std::string> returnValue;
630  returnValue.reserve(numberOfColumns());
631  returnValue.push_back("Label");
632  returnValue.push_back("Value");
633  return returnValue;
634 }
635 
637  return m_selectedRow;
638 }
639 
641  return m_selectedColumn;
642 }
643 
645 {
646  return m_selectedRow == row;
647 }
648 
650 {
651  return unsorted;
652 }
653 
655  return m_row_to_index.size();
656 }
657 
659  return 2;
660 }
661 
662 void FWPSetTableManager::setSelection (int iRow, int iColumn, int mask)
663 {
664  // printf("set selection %d %d mode %d\n", iRow, iColumn, mask);
665 
666  // Nothing changes if we clicked selected
667  // twice the same cell.
668  if (iRow == m_selectedRow && iColumn == m_selectedColumn)
669  return;
670 
671  // Otherwise update the selection information
672  // and notify observers.
673  m_selectedRow = iRow;
674  m_selectedColumn = iColumn;
675  if (iColumn == 1 && iRow > 0 )
676  {
677  int unsortedRow = m_row_to_index[iRow];
678  const PSetData& data = m_entries[unsortedRow];
679  if (m_editor && data.editable) {
680  m_editor->MoveResize(0, cellHeight()*iRow, m_editor->GetWidth() , m_editor->GetHeight());
681  m_editor->MapWindow();
682  m_editor->SetText(data.value.c_str());
683  m_editor->SetFocus();
684  m_editor->SetCursorPosition(data.value.size()-1);
685  }
686  }
687  else
688  {
689  if (m_editor) m_editor->UnmapWindow();
690  }
692 }
693 
694 std::vector<unsigned int> FWPSetTableManager::maxWidthForColumns() const
695 {
696  std::vector<unsigned int> ww = FWTableManagerBase::maxWidthForColumns();
697  if (ww.size() > 1 && ww[1] > 0)
698  {
699  // printf("dim W %d \n",ww[1]);
700  // printf("dim H %d \n",cellHeight());
701  if (m_editor)
702  m_editor->MoveResize(m_editor->GetX(),m_editor->GetY(), ww[1], cellHeight());
703  }
704  return ww;
705 
706 }
707 
709 {
710 }
711 //______________________________________________________________________________
712 
714 {
715  if (row == -1)
716  return;
717 
718  int index = rowToIndex()[row];
720 
721  if (m_filter.empty() == false && data.childMatches == false)
722  return;
723 
724  if (m_filter.empty())
725  data.expandedUser = !data.expandedUser;
726  else
727  data.expandedFilter = !data.expandedFilter;
728 
730  dataChanged();
732 }
733 
734 //______________________________________________________________________________
735 
736 FWTableCellRendererBase* FWPSetTableManager::cellRenderer(int iSortedRowNumber, int iCol) const
737 {
738  const static size_t maxSize = 512; // maximum string length
739 
740  static TGGC boldGC(fireworks::boldGC());
741  static TGGC italicGC(fireworks::italicGC());
742  static TGGC defaultGC(FWTextTableCellRenderer::getDefaultGC());
743 
744  const static Pixel_t gray = 0x777777;
745  const static Pixel_t red = gVirtualX->GetPixel(kRed-5);
746  const static Pixel_t green = gVirtualX->GetPixel(kGreen-5);
747 
748  // return in case if nothing maches filter
749  if (static_cast<int>(m_row_to_index.size()) <= iSortedRowNumber)
750  {
751  m_renderer.setData(std::string(), false);
752  return &m_renderer;
753  }
754 
755 
756  int unsortedRow = m_row_to_index[iSortedRowNumber];
757  const PSetData& data = m_entries[unsortedRow];
758 
761  TGGC* gc = nullptr;
762  if (data.level == 0)
763  {
764  const PathInfo &path = m_paths[data.path];
765  label = data.label + " (" + data.value + ")";
766  gc = &boldGC;
767  gc->SetForeground(path.passed ? green: red);
768  }
769  else if (data.level == 1)
770  {
771  // "passed" means if module made decision on path
772  const ModuleInfo &module = m_modules[m_paths[data.path].moduleStart + data.module];
773  label = data.label + " (" + data.value + ")";
774  gc = (TGGC*)&boldGC;
775  gc->SetForeground(module.passed ? green : red);
776  }
777  else
778  {
779  if (data.type > 0)
780  label = data.label + " (" + sTypeTranslations.table_[data.type] + ")";
781  else
782  label = data.label;
783  value = data.value;
784 
785  if (data.editable)
786  {
787  gc = &defaultGC;
788  }
789  else
790  {
791  gc = &italicGC;
792  gc->SetForeground(gray);
793  }
794  }
795 
796  // check string size and cut it if necessary (problems with X11)
797  if (iCol == 1 && value.size() >= maxSize)
798  {
799  if (iSortedRowNumber == m_selectedRow)
800  fwLog(fwlog::kWarning) << "label: " << label << " has too long value " << value << std::endl << std::endl;
801 
802  value = value.substr(0, maxSize);
803  value += "[truncated]";
804  gc->SetForeground(gVirtualX->GetPixel(kMagenta));
805  }
806 
807  // debug
808  // label = Form("%s m[%d] childm[%d] ", label.c_str(), data.matches, data.childMatches);
809 
810  // set text attributes
812  bool selected = data.matches && (m_filter.empty() == false);
813  m_renderer.setData(iCol ? value : label, selected);
814 
815  // set tree attributes
816  bool isParent = false;
817  bool isOpen = false;
818  int indent = 0;
819  if (iCol == 0)
820  {
821  if (m_filter.empty())
822  {
823  size_t nextIdx = unsortedRow + 1;
824  isParent = (nextIdx < m_entries.size() && m_entries[nextIdx].parent == (size_t)unsortedRow);
825  isOpen = data.expandedUser;
826  }
827  else
828  {
829  isParent = data.childMatches;
830  isOpen = data.expandedFilter && data.childMatches;
831  }
832 
833  indent = data.level * 10 ;
834  if (!isParent) indent += FWTextTreeCellRenderer::iconWidth();
835  }
836  m_renderer.setIsParent(isParent);
837  m_renderer.setIsOpen(isOpen);
838  m_renderer.setIndentation(indent);
839 
840 
841  // If we are rendering the selected cell,
842  // we show the editor.
843  bool showEdit = (iCol == 1 && iSortedRowNumber == m_selectedRow && iCol == m_selectedColumn && value.size() < maxSize);
844  m_renderer.showEditor(data.editable && showEdit);
845 
846  return &m_renderer;
847 } // cellRender()
848 
849 //______________________________________________________________________________
850 
852 {
853  m_filter = filter;
854 
855  if (m_filter.empty())
856  {
857  // collapse entries when filter is removed
858  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
859  m_entries[i].expandedFilter = false;
860  }
861  else
862  {
863  // Decide whether or not items match the filter.
864  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
865  {
866  PSetData &data = m_entries[i];
867 
868  // First of all decide whether or not we match
869  // the filter.
870  if (strstr(data.label.c_str(), m_filter.c_str()) || strstr(data.value.c_str(), m_filter.c_str()) )
871  data.matches = true;
872  else
873  data.matches = false;
874  }
875 
876  // We reset whether or not a given parent has children that match the
877  // filter, and we recompute the whole information by checking all the
878  // children.
879  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
880  m_entries[i].childMatches = false;
881 
882  std::vector<int> stack;
883  int previousLevel = 0;
884  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
885  {
886  PSetData &data = m_entries[i];
887  // Top level.
888  if (data.parent == (size_t)-1)
889  {
890  previousLevel = 0;
891  // std::cout << "reset stack for top level " << data.label << std::endl;
892  stack.clear();
893  continue;
894  }
895  // If the level is greater than the previous one,
896  // it means we are among the children of the
897  // previous level, hence we push the parent to
898  // the stack.
899  // If the level is not greater than the previous
900  // one it means we have popped out n levels of
901  // parents, where N is the difference between the
902  // new and the old level. In this case we
903  // pop up N parents from the stack.
904  if (data.level > previousLevel)
905  stack.push_back(data.parent);
906  else
907  for (size_t pi = 0, pe = previousLevel - data.level; pi != pe; ++pi)
908  stack.pop_back();
909 
910  if (data.matches && m_entries[stack.back()].childMatches == false)
911  {
912  // printf("match for %s with level %d\n",data.label.c_str(), data.level );
913  for (size_t pi = 0, pe = stack.size(); pi != pe; ++pi)
914  {
915  // printf("set child match to parent %s with level %d \n",m_entries[stack[pi]].label.c_str(), m_entries[stack[pi]].level);
916  m_entries[stack[pi]].childMatches = true;
917 
918  }
919  }
920 
921  previousLevel = data.level;
922  }
923 
924  // expand to matching children
925  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
926  m_entries[i].expandedFilter = m_entries[i].childMatches;
927 
928  }
929 
931 
932  dataChanged();
933 } // updateFilter()
934 
935 //______________________________________________________________________________
936 
938 {
939  m_row_to_index.clear();
940 
941  // Decide about visibility.
942  // * If the items are toplevel and they match the filter, they get shown
943  // in any case.
944  // * If the item or any of its children match the filter, the item
945  // is visible.
946  // * If the filter is empty and the parent is expanded.
947  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
948  {
949  PSetData &data = m_entries[i];
950  if (data.parent == ((size_t) -1))
951  {
952  data.visible = data.childMatches || data.matches || m_filter.empty();
953  }
954  else
955  {
956  if (m_filter.empty())
957  {
958  data.visible = m_entries[data.parent].expandedUser && m_entries[data.parent].visible;
959  }
960  else
961  {
962  if (data.level < 2)
963  data.visible = m_entries[data.parent].expandedFilter && m_entries[data.parent].visible && (data.matches || data.childMatches);
964  else
965  data.visible = m_entries[data.parent].expandedFilter && m_entries[data.parent].visible;
966  }
967  }
968  }
969 
970  // Put in the index only the entries which are visible.
971  for (size_t i = 0, e = m_entries.size(); i != e; ++i)
972  if (m_entries[i].visible)
973  m_row_to_index.push_back(i);
974 }
975 
void modulesInPath(const std::string &iPathLabel, std::vector< std::string > &oLabelsToFill) const
add to oLabelsToFill in execution order the labels of all modules in path iPathLabel ...
Definition: ScheduleInfo.cc:91
std::vector< unsigned > getVUInt32() const
Definition: Entry.cc:733
std::vector< double > getVDouble() const
Definition: Entry.cc:781
std::vector< std::string > m_availablePaths
static const TGPicture * info(bool iBackgroundIsBlack)
std::vector< unsigned long long > getVUInt64() const
Definition: Entry.cc:757
std::vector< LuminosityBlockID > getVLuminosityBlockID() const
Definition: Entry.cc:913
static TypeTrans const sTypeTranslations
std::vector< PathInfo > m_paths
std::vector< std::string > CodeMap
virtual bool rowIsSelected(int row) const
int getInt32() const
Definition: Entry.cc:673
FWTextTreeCellRenderer m_renderer
unsigned getUInt32() const
Definition: Entry.cc:721
std::vector< size_t > m_parentStack
std::vector< InputTag > getVInputTag() const
Definition: Entry.cc:841
std::vector< int > & rowToIndex()
void implSort(int, bool) override
Called by &#39;sort&#39; method to actually handle the sorting of the rows. Arguments are the same as &#39;sort&#39;...
std::vector< std::string > getTitles() const override
returns the title names for each column
void handlePSetEntry(edm::ParameterSetEntry &entry, const std::string &key)
void createVectorString(FWPSetTableManager::PSetData &data, const T &v, bool quotes)
void dataChanged()
Classes which inherit from FWTableManagerBase must call this when their underlying data changes...
std::vector< ParameterSet > & vpsetForUpdate()
std::vector< ModuleInfo > m_modules
LuminosityBlockRange getLuminosityBlockRange() const
Definition: Entry.cc:924
std::string encode() const
Definition: InputTag.cc:159
virtual std::vector< unsigned int > maxWidthForColumns() const
for each column in the table this returns the present maximum width for that column ...
double getDouble() const
Definition: Entry.cc:769
std::vector< EventID > getVEventID() const
Definition: Entry.cc:889
virtual const std::string title() const
const Double_t pi
unsigned long long getUInt64() const
Definition: Entry.cc:745
char const * label
std::map< std::string, size_t > m_pathIndex
std::vector< PSetData > & data()
void handleVPSetEntry(edm::VParameterSetEntry &entry, const std::string &key)
static const TGGC & getDefaultGC()
std::vector< int > m_row_to_index
std::vector< PSetData > m_entries
bool isTracked() const
Definition: Entry.h:174
void setHighlightContext(const TGGC *context)
virtual void setCellEditor(TGTextEntry *editor)
stack
Definition: svgfig.py:559
int numberOfRows() const override
Number of rows in the table.
bool getBool() const
Definition: Entry.cc:661
InputTag getInputTag() const
Definition: Entry.cc:829
std::map< std::string, char > type2Code_
bool apply(FWPSetTableManager::PSetData &data, FWPSetTableManager::PSetData &parent)
void handleEntry(const edm::Entry &entry, const std::string &key)
static const TGGC & getDefaultHighlightGC()
std::vector< ParameterSet > const & vpset() const
returns the VPSet
std::vector< long long > getVInt64() const
Definition: Entry.cc:709
void handlePSet(edm::ParameterSet *psp)
std::vector< unsigned int > maxWidthForColumns() const override
for each column in the table this returns the present maximum width for that column ...
std::vector< ESInputTag > getVESInputTag() const
Definition: Entry.cc:865
void setGraphicsContext(const TGGC *iContext)
FWPSetCellEditor * m_editor
std::vector< EventRange > getVEventRange() const
Definition: Entry.cc:960
FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const override
ii
Definition: cuy.py:590
int numberOfColumns() const override
Number of columns in the table.
string ranges
Definition: diffTwoXMLs.py:79
virtual void setIndentation(int indentation=0)
void updateSchedule(const edm::ScheduleInfo *info)
int unsortedRowNumber(int unsorted) const override
when passed the index to the sorted order of the rows it returns the original row number from the und...
def green(string)
void createScalarString(PSetData &data, T v)
void setData(const std::string &, bool isSelected)
FileInPath getFileInPath() const
Definition: Entry.cc:817
psettable const & psetTable() const
Definition: ParameterSet.h:226
virtual void updateFilter(const char *filter)
const edm::ParameterSet * parametersForModule(const std::string &iLabel) const
Definition: ScheduleInfo.cc:73
std::string encode() const
Definition: ESInputTag.cc:50
#define fwLog(_level_)
Definition: fwLog.h:50
std::vector< int > getVInt32() const
Definition: Entry.cc:685
void setCellValueEditor(FWPSetCellEditor *editor)
std::map< std::string, Entry > table
Definition: ParameterSet.h:222
LuminosityBlockID getLuminosityBlockID() const
Definition: Entry.cc:901
const TGGC & italicGC()
ParameterSet & psetForUpdate()
vpsettable const & vpsetTable() const
Definition: ParameterSet.h:229
EventRange getEventRange() const
Definition: Entry.cc:948
void update(std::vector< PathUpdate > &pathUpdates)
susybsm::HSCParticleCollection hc
Definition: classes.h:25
void visualPropertiesChanged()
Classes which inherit from FWTableManagerBase must call this when how the data is shown (e...
const TGGC & boldGC()
std::vector< LuminosityBlockRange > getVLuminosityBlockRange() const
Definition: Entry.cc:936
void setSelection(int row, int column, int mask)
char typeCode() const
Definition: Entry.h:176
ESInputTag getESInputTag() const
Definition: Entry.cc:853
virtual unsigned int cellHeight() const
require all cells to be the same height
std::string relativePath() const
Definition: FileInPath.cc:159
table const & tbl() const
Definition: ParameterSet.h:223
long double T
Definition: vlib.h:208
std::vector< std::string > getVString() const
Definition: Entry.cc:805
void availablePaths(std::vector< std::string > &oLabelsToFill) const
adds to oLabelsToFill the labels for all paths in the process
Definition: ScheduleInfo.cc:87
std::string getString() const
Definition: Entry.cc:793
virtual void showEditor(bool value)
EventID getEventID() const
Definition: Entry.cc:877