CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWTableView.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWTableView
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Feb 21 11:22:41 EST 2008
11 // $Id: FWTableView.cc,v 1.36 2013/04/09 05:00:07 amraktad Exp $
12 //
13 
14 // system include files
15 #include <stdlib.h>
16 #include <algorithm>
17 #include <boost/shared_ptr.hpp>
18 #include <iostream>
19 #include <sstream>
20 #include <stdexcept>
21 #include <cassert>
22 
23 #include "TMath.h"
24 #include "TClass.h"
25 #include "TSystem.h"
26 #include "TGComboBox.h"
27 #include "TGLabel.h"
28 #include "TGTextEntry.h"
29 #include "TEveWindow.h"
30 
31 // user include files
45 
46 static const TString& coreIcondir()
47 {
48  static TString path = Form("%s/src/Fireworks/Core/icons/",gSystem->Getenv("CMSSW_BASE"));
49  if ( gSystem->AccessPathName(path.Data()) ){ // cannot find directory
50  assert(gSystem->Getenv("CMSSW_RELEASE_BASE"));
51  path = Form("%s/src/Fireworks/Core/icons/",gSystem->Getenv("CMSSW_RELEASE_BASE"));
52  }
53  return path;
54 }
55 
56 /*
57 static
58 const TGPicture* filtered(bool iBackgroundIsBlack)
59 {
60  if(iBackgroundIsBlack) {
61  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"filtered-blackbg.png");
62  return s;
63  }
64  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"filtered-whitebg.png");
65  return s;
66 
67 }
68 
69 static
70 const TGPicture* filtered_over(bool iBackgroundIsBlack)
71 {
72  if(iBackgroundIsBlack) {
73  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"filtered-whitebg-over.png");
74  return s;
75  }
76  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"filtered-whitebg-over.png");
77  return s;
78 }
79 */
80 /*
81 static
82 const TGPicture* alert_over()
83 {
84  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"alert-blackbg-over.png");
85  return s;
86 }
87 
88 static
89 const TGPicture* alert()
90 {
91  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"alert-blackbg.png");
92  return s;
93 }
94 */
95 
96 /*
97 static
98 const TGPicture* unfiltered(bool iBackgroundIsBlack)
99 {
100  if(iBackgroundIsBlack) {
101  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"unfiltered-blackbg.png");
102  return s;
103  }
104  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"unfiltered-whitebg.png");
105  return s;
106 }
107 static
108 const TGPicture* unfiltered_over(bool iBackgroundIsBlack)
109 {
110  if(iBackgroundIsBlack) {
111  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"unfiltered-blackbg-over.png");
112  return s;
113  }
114  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"unfiltered-whitebg-over.png");
115  return s;
116 }
117 
118 static
119 const TGPicture* info(bool iBackgroundIsBlack)
120 {
121  if(iBackgroundIsBlack) {
122  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"info2-blackbg.png");
123  return s;
124  }
125  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"info2-whitebg.png");
126  return s;
127 }
128 
129 static
130 const TGPicture* info_over(bool iBackgroundIsBlack)
131 {
132  if(iBackgroundIsBlack) {
133  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"info2-blackbg-over.png");
134  return s;
135  }
136  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"info2-whitebg-over.png");
137  return s;
138 }
139 
140 static
141 const TGPicture* info_disabled(bool iBackgroundIsBlack)
142 {
143  if(iBackgroundIsBlack) {
144  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"info2-blackbg-disabled.png");
145  return s;
146  }
147  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"info2-whitebg-disabled.png");
148  return s;
149 }
150 */
151 static
152 const TGPicture* arrow_right(bool iBackgroundIsBlack)
153 {
154  if(iBackgroundIsBlack) {
155  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-white-right-blackbg.png");
156  return s;
157  }
158  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-black-right-whitebg.png");
159  return s;
160 }
161 
162 static
163 const TGPicture* arrow_right_disabled(bool iBackgroundIsBlack)
164 {
165  if(iBackgroundIsBlack) {
166  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-white-right-disabled-blackbg.png");
167  return s;
168  }
169  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-black-right-disabled-whitebg.png");
170  return s;
171 }
172 
173 static
174 const TGPicture* arrow_down(bool iBackgroundIsBlack)
175 {
176  if(iBackgroundIsBlack) {
177  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-white-down-blackbg.png");
178  return s;
179  }
180  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-black-down-whitebg.png");
181  return s;
182 }
183 
184 static
185 const TGPicture* arrow_down_disabled(bool iBackgroundIsBlack)
186 {
187  if(iBackgroundIsBlack) {
188  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-white-down-disabled-blackbg.png");
189  return s;
190  }
191  static const TGPicture* s = gClient->GetPicture(coreIcondir()+"arrow-black-down-disabled-whitebg.png");
192  return s;
193 }
194 
195 //
196 // constants, enums and typedefs
197 //
198 static const std::string kTableView = "TableView";
199 static const std::string kCollection = "collection";
200 static const std::string kColumns = "columns";
201 static const std::string kSortColumn = "sortColumn";
202 static const std::string kDescendingSort = "descendingSort";
203 
204 //
205 // constructors and destructor
206 //
207 FWTableView::FWTableView (TEveWindowSlot* iParent, FWTableViewManager *manager)
208  : FWViewBase(FWViewType::kTable),
209  m_iColl(-1),
210  m_manager(manager),
211  m_tableManager(new FWTableViewTableManager(this)),
212  m_tableWidget(0),
213  m_showColumnUI(false),
214  m_validator(new FWExpressionValidator),
215  m_currentColumn(-1),
216  m_useColumnsFromConfig(false)
217 
218 {
219  m_eveWindow = iParent->MakeFrame(0);
220  TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
221 // TGHorizontalFrame *buttons = new TGHorizontalFrame(frame);
222 // frame->AddFrame(buttons, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
223 
224 // m_collection = new TGComboBox(buttons);
225  m_vert = new TGVerticalFrame(frame);
226  frame->AddFrame(m_vert, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
227  TGHorizontalFrame *header = new TGHorizontalFrame(m_vert);
228  m_vert->AddFrame(header, new TGLayoutHints(kLHintsTop | kLHintsExpandX));
229  const bool bgIsBlack = m_manager->colorManager().background() == kBlack;
231  arrow_right(bgIsBlack),
232  arrow_right_disabled(bgIsBlack),
233  arrow_right_disabled(bgIsBlack));
234  m_columnUIButton->Connect("Clicked()", "FWTableView", this, "toggleShowHide()");
235  header->AddFrame(m_columnUIButton, new TGLayoutHints(kLHintsCenterY | kLHintsLeft,6,10));
236 
237  TGCompositeFrame *labfr = new TGHorizontalFrame(header, 60, 25, kFixedSize);
238  TGLabel *label = new TGLabel(labfr, "Collection");
239  labfr->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1,3,0,0));
240  header->AddFrame(labfr, new TGLayoutHints(kLHintsLeft));
241 
242  m_collection = new TGComboBox(header);
243  updateItems();
244  header->AddFrame(m_collection, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY));
245  m_collection->Connect("Selected(Int_t)", "FWTableView", this, "selectCollection(Int_t)");
246  m_collection->Select(2, true);
247  m_column_control = new TGVerticalFrame(m_vert);
248  m_vert->AddFrame(m_column_control, new TGLayoutHints(kLHintsExpandX));
249  TGLabel *column_control_label = new TGLabel(m_column_control, "Column editor");
250 // column_control_label->SetBackgroundColor(bgIsBlack ? kBlack : kWhite);
251 // column_control_label->SetForegroundColor(bgIsBlack ? kWhite : kBlack);
252 // column_control_label->SetTextColor(bgIsBlack ? kWhite : kBlack);
253  m_column_control->AddFrame(column_control_label, new TGLayoutHints(kLHintsExpandX));
254  TGHorizontalFrame *column_control_fields = new TGHorizontalFrame(m_column_control);
255  m_column_control->AddFrame(column_control_fields, new TGLayoutHints(kLHintsExpandX));
256  m_column_name_field = new TGTextEntry(column_control_fields);
257  m_column_name_field->SetMaxWidth(10);
258  m_column_expr_field = new FWGUIValidatingTextEntry(column_control_fields);
259 // m_column_expr_field->SetEnabled(kFALSE);
261  m_column_prec_field = new TGTextEntry(column_control_fields);
262  m_column_prec_field->SetMaxWidth(10);
263  TGLabel *name_label = new TGLabel(column_control_fields, "Title");
264  TGLabel *expr_label = new TGLabel(column_control_fields, "Expression");
265  TGLabel *prec_label = new TGLabel(column_control_fields, "Precision");
266  column_control_fields->AddFrame(name_label, new TGLayoutHints(kLHintsBottom, 1, 1, 2, 2));
267  column_control_fields->AddFrame(m_column_name_field, new TGLayoutHints(kLHintsExpandX));
268  column_control_fields->AddFrame(expr_label, new TGLayoutHints(kLHintsBottom, 1, 1, 2, 2));
269  column_control_fields->AddFrame(m_column_expr_field, new TGLayoutHints(kLHintsExpandX));
270  column_control_fields->AddFrame(prec_label, new TGLayoutHints( kLHintsBottom, 1, 1, 2, 2));
271  column_control_fields->AddFrame(m_column_prec_field, new TGLayoutHints(kLHintsExpandX));
272  TGTextButton *add_button = new TGTextButton(column_control_fields, "Add");
273  TGTextButton *del_button = new TGTextButton(column_control_fields, "Delete");
274  TGTextButton *mod_button = new TGTextButton(column_control_fields, "Modify");
275  add_button->Connect("Clicked()", "FWTableView", this, "addColumn()");
276  del_button->Connect("Clicked()", "FWTableView", this, "deleteColumn()");
277  mod_button->Connect("Clicked()", "FWTableView", this, "modifyColumn()");
278  column_control_fields->AddFrame(add_button, new TGLayoutHints);
279  column_control_fields->AddFrame(del_button, new TGLayoutHints);
280  column_control_fields->AddFrame(mod_button, new TGLayoutHints);
283  m_tableWidget->SetHeaderBackgroundColor(gVirtualX->GetPixel(kWhite));
284  m_tableWidget->Connect("rowClicked(Int_t,Int_t,Int_t,Int_t,Int_t)", "FWTableView",
285  this, "modelSelected(Int_t,Int_t,Int_t,Int_t,Int_t)");
286  m_tableWidget->Connect("columnClicked(Int_t,Int_t,Int_t)", "FWTableView",
287  this, "columnSelected(Int_t,Int_t,Int_t)");
288  m_vert->AddFrame(m_tableWidget, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
289  frame->MapSubwindows();
290  m_vert->HideFrame(m_column_control);
291  frame->Layout();
292  frame->MapWindow();
293 }
294 
296 {
297  // take out composite frame and delete it directly ( without the timeout)
298  TGCompositeFrame *frame = m_eveWindow->GetGUICompositeFrame();
299  frame->RemoveFrame(m_vert);
300  delete m_vert;
301 
302  m_eveWindow->DestroyWindowAndSlot();
303  delete m_tableManager;
304  delete m_validator;
305 }
306 
307 void
309 {
310  m_tableWidget->SetBackgroundColor(gVirtualX->GetPixel(iColor));
311 // m_tableWidget->SetBackgroundColor(TColor::Number2Pixel(iColor));
312 // m_viewer->GetGLViewer()->SetClearColor(iColor);
313 }
314 
316 {
317  m_tableWidget->SetBackgroundColor(gVirtualX->GetPixel(manager.background()));
318 // m_tableWidget->SetHeaderBackgroundColor(gVirtualX->GetPixel(manager.background()));
319 // switch (manager.foreground()) {
320 // case FWColorManager::kBlackIndex:
321 // m_tableWidget->SetHeaderForegroundColor(gVirtualX->GetPixel(kBlack));
322 // break;
323 // default:
324 // m_tableWidget->SetHeaderForegroundColor(0xffffff);
325 // break;
326 // }
327  m_tableWidget->SetLineSeparatorColor(gVirtualX->GetPixel(manager.foreground()));
328 // m_tableWidget->dataChanged();
329 }
330 
331 //
332 // const member functions
333 //
334 
335 
336 void
338 {
339  // are we the first FWTableView to go into the configuration? If
340  // we are, then we are responsible for writing out the list of
341  // types (which we do by letting FWTableViewManager::addToImpl
342  // write into our configuration)
343  if (this == m_manager->m_views.front().get())
344  m_manager->addToImpl(iTo);
345  // then there is the stuff we have to do anyway: remember what
346  // collection we display
349  if (m_manager->items()[m_iColl])
350  collectionName = m_manager->items()[m_iColl]->name();
351  else
352  collectionName = "NULL";
353 
354  FWConfiguration collection(collectionName);
355  main.addKeyValue(kCollection, collection);
357  main.addKeyValue(kSortColumn, sortColumn);
358  FWConfiguration descendingSort(m_tableWidget->descendingSort());
359  main.addKeyValue(kDescendingSort, descendingSort);
360 // FWConfiguration columns(1);
361 // for (std::vector<FWTableViewManager::TableEntry>::const_iterator
362 // i = m_tableManager->m_tableFormats->begin(),
363 // iEnd = m_tableManager->m_tableFormats->end();
364 // i != iEnd; ++i) {
365 // columns.addValue(i->name);
366 // columns.addValue(i->expression);
367 // char prec[100];
368 // snprintf(prec, 100, "%d", i->precision);
369 // columns.addValue(prec);
370 // }
371 // main.addKeyValue(kColumns, columns);
372  iTo.addKeyValue(kTableView, main);
373  // take care of parameters
375 }
376 
377 void
379 {
380  if (this == m_manager->m_views.front().get())
381  m_manager->setFrom(iFrom);
382  try {
383  const FWConfiguration *main = iFrom.valueForKey(kTableView);
384  assert(main != 0);
385  // use the columns from the config, not the default columns for
386  // the collection type
387 // m_useColumnsFromConfig = true;
388 // m_tableManager->m_tableFormats->clear();
389 // const FWConfiguration *columns = main->valueForKey(kColumns);
390 // for (FWConfiguration::StringValuesIt it = columns->stringValues()->begin(),
391 // itEnd = columns->stringValues()->end(); it != itEnd; ++it) {
392 // const std::string &name = *it++;
393 // const std::string &expr = *it++;
394 // int prec = atoi(it->c_str());
395 // FWTableViewManager::TableEntry e = { expr, name, prec };
396 // m_tableManager->m_tableFormats->push_back(e);
397 // }
399  const std::string &collectionName = collection->value();
400  // find item
401  for (std::vector<const FWEventItem *>::const_iterator
402  it = m_manager->items().begin(),
403  itEnd = m_manager->items().end();
404  it != itEnd; ++it) {
405  if (*it && (*it)->name() == collectionName) {
406  m_collection->Select(it - m_manager->items().begin(), true);
407  break;
408  }
409  }
410  const FWConfiguration *sortColumn = main->valueForKey(kSortColumn);
411  const FWConfiguration *descendingSort = main->valueForKey(kDescendingSort);
412  if (sortColumn != 0 && descendingSort != 0) {
413  unsigned int sort = sortColumn->version();
414  bool descending = descendingSort->version();
415  if (sort < (( unsigned int) m_tableManager->numberOfColumns()))
416  m_tableWidget->sort(sort, descending);
417  }
418  } catch (...) {
419  // configuration doesn't contain info for the table. Be forgiving.
420  std::cerr << "This configuration file contains tables, but no column information. "
421  "(It is probably old.) Using defaults." << std::endl;
422  }
423 
424 // main.addKeyValue(kCollection, collection);
425 // FWConfiguration columns(1);
426 // for (std::vector<FWTableViewManager::TableEntry>::const_iterator
427 // i = m_tableManager->m_tableFormats->begin(),
428 // iEnd = m_tableManager->m_tableFormats->end();
429 // i != iEnd; ++i) {
430 // columns.addValue(i->name);
431 // columns.addValue(i->expression);
432 // columns.addValue(Form("%d", i->precision));
433 // }
434 // main.addKeyValue(kColumns, columns);
435 // iTo.addKeyValue(kTableView, main);
436 // // take care of parameters
437 // FWConfigurableParameterizable::addTo(iTo);
438 
439  // take care of parameters
441 }
442 
443 void
444 FWTableView::saveImageTo(const std::string& /*iName*/) const
445 {
446  TString format;
447  TString data;
448  FWTextTableCellRenderer* textRenderer;
449 
450  // calculate widths
451  int ndheader = TMath::Ceil(TMath::Log10(m_tableManager->numberOfRows()));
452 
453  std::vector<size_t> widths(m_tableManager->numberOfColumns());
454 
455  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
456  widths[c] = m_tableManager->m_tableFormats->at(c).name.size();
457 
458  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
459  {
460  for (int r = 0; r < m_tableManager->numberOfRows(); r++ )
461  {
462  textRenderer = (FWTextTableCellRenderer*) m_tableManager->cellRenderer(r, c); // setup cell renderer
463  size_t ss = textRenderer->data().size();
464  if (widths[c] < ss) widths[c] = ss;
465  }
466  }
467 
468  int rlen = 0;
469  for (size_t c = 0; c < (size_t)m_tableManager->numberOfColumns(); ++c )
470  rlen += widths[c];
471  rlen += (m_tableManager->numberOfColumns() -1 )*3 ;
472  rlen++;
473 
474 
475  // header
476  printf("\n");
477  TString headerFormat;
478  headerFormat.Form("%%%ds",ndheader +3);
479  data.Form(headerFormat, " ");
480  printf("%s", data.Data());
481 
482  int lastCol = m_tableManager->numberOfColumns() -1;
483 
484  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
485  {
486  format.Form("%%%ds", (int)widths[c]);
487  data.Form(format, m_tableManager->m_tableFormats->at(c).name.c_str());
488 
489  if (c == lastCol)
490  printf("%s", data.Data());
491  else
492  printf("%s | ", data.Data());
493  }
494  printf("\n");
495 
496  std::string splitter(rlen, '-');
497  std::cout << splitter << std::endl;
498 
499  // body
500  headerFormat.Form("[%%%dd] ",ndheader );
501  for (int r = 0; r < m_tableManager->numberOfRows(); r++ )
502  {
503  for (int c = 0; c < m_tableManager->numberOfColumns(); ++c )
504  {
505  if (!c) {
506  data.Form(headerFormat, m_tableManager->unsortedRowNumber(r));
507  printf("%s", data.Data());
508  }
509  format.Form("%%%ds", (int)widths[c]);
510  textRenderer = (FWTextTableCellRenderer*) m_tableManager->cellRenderer(r, c); // setup cell renderer
511  data.Form(format, textRenderer->data().c_str());
512  if (c == lastCol)
513  printf("%s", data.Data());
514  else
515  printf("%s | ", data.Data());
516  }
517  printf("\n");
518  }
519 }
520 
521 void
523 {
525  const TGPicture* picture = 0;
526  const TGPicture* down = 0;
527  const TGPicture* disabled = 0;
528  const bool bgIsBlack = m_manager->colorManager().background() == kBlack;
529  if (m_showColumnUI) {
530  picture = arrow_down(bgIsBlack);
531  down = arrow_down_disabled(bgIsBlack);
532  disabled = arrow_down_disabled(bgIsBlack);
533  m_vert->ShowFrame(m_column_control);
534  } else {
535  picture = arrow_right(bgIsBlack);
536  down = arrow_right_disabled(bgIsBlack);
537  disabled = arrow_right_disabled(bgIsBlack);
538  m_vert->HideFrame(m_column_control);
539  }
540  m_vert->Layout();
541  m_columnUIButton->swapIcons(picture,down,disabled);
542 }
543 
548 {
549  int selected = m_collection->GetSelected();
550  m_collection->RemoveAll();
551  int index = 0;
552 
553  for (size_t i = 0, e = m_manager->items().size(); i != e; ++i)
554  {
555  const FWEventItem *item = m_manager->items()[i];
556  if (item)
557  m_collection->AddEntry(item->name().c_str(), i);
558 
559  if (m_iColl == index && 0 == item)
560  {
561  //the collection we were showing is now gone
562  m_iColl = -1;
563  selected = -1;
564  }
565  }
566 
567  if (selected != -1 && selected < m_collection->GetNumberOfEntries())
568  m_collection->Select(selected, false);
569 
570  TGListBox *lb = m_collection->GetListBox();
571  lb->SetHeight(TMath::Min(lb->GetNumberOfEntries()*lb->GetItemVsize() + 2*lb->GetBorderWidth(), 200u));
572 }
573 
575 {
577 }
578 
580 {
581  if (m_iColl == -1)
582  return 0;
583  return m_manager->items()[m_iColl];
584 }
585 
587 {
588 // const FWEventItem *item = m_manager->items()[m_iColl];
591 // std::vector<FWExpressionEvaluator> &ev = m_evaluators;
592 // for (unsigned int i = 0; i < item->size(); ++i) {
593 // for (unsigned int j = 0; j < ev.size(); ++j) {
594 // printf("%s = %f\t", (*m_manager->tableFormats(item->modelType()->GetName())).second[j].name.c_str(),
595 // ev[j].evalExpression(item->modelData(i)));
596 // }
597 // printf("\n");
598 // }
599 // fflush(stdout);
600 }
601 
606 void
608 {
609 // printf("selected collection %d, ", i_coll);
610  const FWEventItem *item = m_manager->items()[i_coll];
611  assert(0!=item);
612 // printf("%s\n", item->modelType()->GetName());
613  m_iColl = i_coll;
614 // m_validator = new FWExpressionValidator;
615 // m_column_expr_field->setValidator(m_validator);
616  if (m_validator != 0) {
617 // std::cout << "setting validator to " << item->modelType()->GetName() << std::endl;
618  m_validator->setType(edm::TypeWithDict(*(item->modelType()->GetTypeInfo())));
619  } else {
620 // std::cout << "can't set null validator\n";
621  }
622  if (not m_useColumnsFromConfig) {
623  if (m_manager->tableFormats(*item->modelType()) == m_manager->m_tableFormats.end()) {
624  fwLog(fwlog::kInfo) << "No table format for objects of this type " << item->modelType()->GetName() << std::endl;
625  m_tableManager->m_tableFormats->clear();
626  } else {
628  }
629  }
630 // columnSelected(-1, 1, 0);
632  dataChanged();
633 }
634 
635 void FWTableView::modelSelected(Int_t iRow,Int_t iButton,Int_t iKeyMod,Int_t iGlobalX,Int_t iGlobalY)
636 {
637  if(iKeyMod & kKeyControlMask) {
638  item()->toggleSelect(iRow);
639  } else {
640  FWChangeSentry sentry(*(item()->changeManager()));
642  item()->select(iRow);
643  }
644  if(iButton == kButton3) {
645  openSelectedModelContextMenu_(iGlobalX,iGlobalY);
646  }
647 }
648 
649 void FWTableView::columnSelected (Int_t iCol, Int_t iButton, Int_t iKeyMod)
650 {
651  if (iButton == 1 || iButton == 3)
652  m_currentColumn = iCol;
653  // update contents of the column editor
654  if (m_currentColumn >= 0 &&
658  m_column_name_field->SetText(entry.name.c_str());
659  m_column_expr_field->SetText(entry.expression.c_str());
660  m_column_prec_field->SetText(Form("%d", entry.precision));
661  } else {
662  m_column_name_field->SetText("");
663  m_column_expr_field->SetText("");
664  m_column_prec_field->SetText("");
665  }
666 }
667 
669 {
670  std::string name = m_column_name_field->GetText();
671  std::string expr = m_column_expr_field->GetText();
672  // convert the precision to a long int
673  char *endptr = 0;
674  int prec = (int) strtol(m_column_prec_field->GetText(), &endptr, 0);
675  if (name == "" || expr == "" ||
676  m_column_prec_field->GetText() == 0 || *endptr != 0) {
677  fwLog(fwlog::kInfo) << "bad input\n";
678  fflush(stdout);
679  return;
680  }
681  fwLog(fwlog::kInfo) << "adding column "<< name << ": " << expr << ", precision " << prec << std::endl;
682  fflush(stdout);
683 // m_manager->tableFormats(*item->modelType())
684  FWTableViewManager::TableEntry e = { expr, name, prec };
685  m_tableManager->m_tableFormats->push_back(e);
686  m_currentColumn = (int)m_tableManager->m_tableFormats->size() + 1;
687  // change needs to be propagated to all tables, because all
688  // tables displaying objects of this type are affected
689  // MT -- this is NOT true!!! FIX
692 }
693 
695 {
696  if (m_currentColumn >= 0 &&
700  m_column_name_field->SetText("");
701  m_column_expr_field->SetText("");
702  m_column_prec_field->SetText("");
703  m_currentColumn = -1;
704  }
705  // change needs to be propagated to all tables, because all
706  // tables displaying objects of this type are affected
707  // MT -- this is NOT true!!! FIX
710 }
711 
713 {
714  std::string name = m_column_name_field->GetText();
715  std::string expr = m_column_expr_field->GetText();
716  // convert the precision to a long int
717  char *endptr = 0;
718  int prec = (int) strtol(m_column_prec_field->GetText(), &endptr, 0);
719  if (name == "" || expr == "" ||
720  m_column_prec_field->GetText() == 0 || *endptr != 0) {
721  fwLog(fwlog::kInfo) << "bad input\n";
722  fflush(stdout);
723  return;
724  }
725  fwLog(fwlog::kInfo) << "modify column "<< name << ": " << expr << ", precision " << prec << std::endl;
726  fflush(stdout);
727 // m_manager->tableFormats(*item->modelType())
728  FWTableViewManager::TableEntry e = { expr, name, prec };
730  // Change needs to be propagated to all tables, because all
731  // tables displaying objects of this type are affected
732  // MT -- this is NOT true!!! FIX
735 }
736 
static const std::string kDescendingSort
Definition: FWTableView.cc:202
virtual FWTableCellRendererBase * cellRenderer(int iSortedRowNumber, int iCol) const
int i
Definition: DBlmapReader.cc:9
void SetBackgroundColor(Pixel_t)
void addToImpl(FWConfiguration &) const
Color_t background() const
void updateEvaluators()
Definition: FWTableView.cc:574
void setType(const edm::TypeWithDict &)
FWTableViewManager * m_manager
Definition: FWTableView.h:91
void dataChanged()
Called if mouse button pressed in Row Header, defaults is to do nothing.
TGTextEntry * m_column_prec_field
Definition: FWTableView.h:99
static const TGPicture * arrow_down(bool iBackgroundIsBlack)
Definition: FWTableView.cc:174
virtual ~FWTableView()
Definition: FWTableView.cc:295
virtual int unsortedRowNumber(int iSortedRowNumber) const
virtual int numberOfRows() const
Number of rows in the table.
void columnSelected(Int_t iCol, Int_t iButton, Int_t iKeyMod)
Definition: FWTableView.cc:649
const std::string & name() const
Definition: FWEventItem.cc:501
void setFrom(const FWConfiguration &)
FWExpressionValidator * m_validator
Definition: FWTableView.h:98
void toggleShowHide()
Definition: FWTableView.cc:522
void addColumn()
Definition: FWTableView.cc:668
virtual void setFrom(const FWConfiguration &)
void selectCollection(Int_t)
Definition: FWTableView.cc:607
std::vector< FWTableViewManager::TableEntry > * m_tableFormats
void SetHeaderBackgroundColor(Pixel_t)
unsigned int version() const
FWTableViewTableManager * m_tableManager
Definition: FWTableView.h:92
void forceLayout()
Definition: FWTableWidget.h:84
FWColorManager & colorManager() const
virtual int numberOfColumns() const
Number of columns in the table.
TGTextEntry * m_column_name_field
Definition: FWTableView.h:96
void SetLineSeparatorColor(Pixel_t)
int main(int argc, char **argv)
def splitter
Definition: confdb.py:11
TGCompositeFrame * m_column_control
Definition: FWTableView.h:89
U second(std::pair< T, U > const &p)
static const TGPicture * arrow_right(bool iBackgroundIsBlack)
Definition: FWTableView.cc:152
TableSpecs::iterator tableFormats(const edm::TypeWithDict &key)
const Items & items() const
void sort(UInt_t iColumn, bool iDescendingSort)
void updateItems()
Definition: FWTableView.cc:547
std::string const collectionName[nCollections]
Definition: Collections.h:39
static const std::string kSortColumn
Definition: FWTableView.cc:201
bool descendingSort() const
Definition: FWTableWidget.h:91
static const std::string kCollection
Definition: FWTableView.cc:199
const FWEventItem * item() const
Definition: FWTableView.cc:579
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
bool m_showColumnUI
Definition: FWTableView.h:94
static const TString & coreIcondir()
Definition: FWTableView.cc:46
void setValidator(FWValidatorBase *)
FWTableWidget * m_tableWidget
Definition: FWTableView.h:93
static const std::string kColumns
Definition: FWTableView.cc:200
void setBackgroundColor(Color_t)
Definition: FWTableView.cc:308
FWTableView(TEveWindowSlot *, FWTableViewManager *)
Definition: FWTableView.cc:207
void resetColors(const class FWColorManager &)
Definition: FWTableView.cc:315
static const TGPicture * arrow_right_disabled(bool iBackgroundIsBlack)
Definition: FWTableView.cc:163
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
void modelSelected(Int_t iRow, Int_t iButton, Int_t iKeyMod, Int_t, Int_t)
Definition: FWTableView.cc:635
static const std::string kTableView
Definition: FWTableView.cc:198
const std::string & value(unsigned int iIndex=0) const
const std::string & data()
FWSelectionManager * selectionManager() const
Definition: FWEventItem.h:134
void toggleSelect(int iIndex) const
Definition: FWEventItem.cc:265
virtual void setFrom(const FWConfiguration &)
Definition: FWTableView.cc:378
#define fwLog(_level_)
Definition: fwLog.h:51
TGCompositeFrame * m_vert
Definition: FWTableView.h:89
TEveWindowFrame * m_eveWindow
Definition: FWTableView.h:87
virtual void saveImageTo(const std::string &iName) const
Definition: FWTableView.cc:444
static const TGPicture * arrow_down_disabled(bool iBackgroundIsBlack)
Definition: FWTableView.cc:185
int sortedColumn() const
Definition: FWTableWidget.h:90
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
int m_currentColumn
Definition: FWTableView.h:100
Color_t foreground() const
bool m_useColumnsFromConfig
Definition: FWTableView.h:101
const TClass * modelType() const
Definition: FWEventItem.cc:562
virtual void addTo(FWConfiguration &) const
Definition: FWTableView.cc:337
FWGUIValidatingTextEntry * m_column_expr_field
Definition: FWTableView.h:97
void select(int iIndex) const
Definition: FWEventItem.cc:251
tuple cout
Definition: gather_cfg.py:121
const FWConfiguration * valueForKey(const std::string &iKey) const
void swapIcons(const TGPicture *&iUpIcon, const TGPicture *&iDownIcon, const TGPicture *&iDisabledIcon)
FWCustomIconsButton * m_columnUIButton
Definition: FWTableView.h:95
TGComboBox * m_collection
Definition: FWTableView.h:88
void dataChanged()
Definition: FWTableView.cc:586
void modifyColumn()
Definition: FWTableView.cc:712
sigc::signal< void, Int_t, Int_t > openSelectedModelContextMenu_
Definition: FWViewBase.h:57
void deleteColumn()
Definition: FWTableView.cc:694
virtual void addTo(FWConfiguration &) const