CMS 3D CMS Logo

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