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