Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REveTableProxyBuilder.cxx
Go to the documentation of this file.
1 #include "TClass.h"
3 #include <ROOT/REveTableInfo.hxx>
6 #include <ROOT/REveManager.hxx>
7 
8 using namespace ROOT::Experimental;
9 
10 REveTableProxyBuilder::REveTableProxyBuilder() : REveDataProxyBuilderBase("Table"), fTable(nullptr)
11 {
12  fTable = new REveDataTable("ProxyTable");
13 }
14 
15 REveTableProxyBuilder::~REveTableProxyBuilder()
16 {
17  fTable->Destroy();
18  fTable = nullptr;
19 }
20 
21 // reuse table product
22 void REveTableProxyBuilder::Clean()
23 {
24 }
25 
26 void REveTableProxyBuilder::Build(const REveDataCollection* collection, REveElement* product, const REveViewContext* context)
27 {
28  REveTableViewInfo* info = context->GetTableViewInfo();
29  if (info->GetDisplayedCollection() != Collection()->GetElementId())
30  {
31  return;
32  }
33 
34  if (product->NumChildren() == 0) {
35  product->AddElement(fTable);
36  }
37 
38  // printf("-----REveTableProxyBuilder::Build() body for %s (%p, %p)\n",collection->GetCName(), collection, Collection() );
39 
40  if (info->GetConfigChanged() || fTable->NumChildren() == 0) {
41  fTable->DestroyElements();
42  auto tableEntries = context->GetTableViewInfo()->RefTableEntries(collection->GetItemClass()->GetName());
43  for (const REveTableEntry& spec : tableEntries) {
44  auto c = new REveDataColumn(spec.fName.c_str());
45  fTable->AddElement(c);
46  using namespace std::string_literals;
47  std::string exp = spec.fExpression;
48  c->SetExpressionAndType(exp.c_str(), spec.fType);
49  c->SetPrecision(spec.fPrecision);
50  }
51  }
52  fTable->StampObjProps();
53 }
54 
55 
56 
57 void REveTableProxyBuilder::SetCollection(REveDataCollection* collection)
58 {
59  REveDataProxyBuilderBase::SetCollection(collection);
60  fTable->SetCollection(collection);
61 }
62 
63 void REveTableProxyBuilder::ModelChanges(const REveDataCollection::Ids_t&, REveDataProxyBuilderBase::Product*)
64 {
65  // printf("REveTableProxyBuilder::ModelChanges\n");
66  if (fTable) fTable->StampObjProps();
67 }
68 
69 void REveTableProxyBuilder::ConfigChanged() {
70  Build();
71 }