LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb::ParameterSetEditRow Class Reference

A single row for editing a single parameter in a set. More...

#include "ParameterSetEditDialog.h"

Public Member Functions

 ParameterSetEditRow (ParameterSetEditFrame *frame, TGHorizontalFrame *lhs, TGHorizontalFrame *rhs, const fhicl::ParameterSet &ps, const std::string &key)
 
 ~ParameterSetEditRow ()
 
void Finalize ()
 
std::string AsFHICL () const
 
void TextEntryReturnPressed ()
 
void ListBoxSelectionChanged ()
 
void ListBoxSelected (int id)
 
void RadioButtonClicked ()
 
void CheckButtonClicked ()
 
void SliderPositionChanged ()
 

Public Attributes

ParameterSetEditFramefFrame
 The parent frame. More...
 
TGHorizontalFrame * fMother
 Top level frame. More...
 
TGLayoutHints * fRightLH {nullptr}
 Align to right. More...
 
TGLayoutHints * fLeftLH {nullptr}
 Align to left. More...
 
TGTextButton * fLabel {nullptr}
 Label on the left. More...
 
TGTextEntry * fTextEntry {nullptr}
 
TGListBox * fListBox {nullptr}
 
TGDoubleSlider * fSlider {nullptr}
 
std::vector< TGRadioButton * > fRadioButton
 
std::vector< TGCheckButton * > fCheckButton
 
unsigned int fParamFlags
 
std::string fKEY
 
std::string fGUI
 
std::string fDOC
 
std::vector< std::string > fChoice
 
std::string fValue
 

Private Member Functions

void SetupTextEntry (TGCompositeFrame *f, unsigned int flags, const std::vector< std::string > &value)
 
void SetupListBox (TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value, bool ismulti)
 
void SetupRadioButtons (TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
 
void SetupCheckButton (TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
 
void SetupSlider (TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
 

Static Private Member Functions

static bool IsLegalGUItag (const std::string &s)
 
static void ParseGUItag (const std::string &guitag, std::string &frame, std::vector< std::string > &choice)
 
static void UnpackParameter (const fhicl::ParameterSet &ps, const std::string &key, unsigned int &flags, std::string &tag, std::vector< std::string > &choice, std::vector< std::string > &value, std::string &gui, std::string &doc)
 

Detailed Description

A single row for editing a single parameter in a set.

===================================================================

Definition at line 86 of file ParameterSetEditDialog.h.

Constructor & Destructor Documentation

ParameterSetEditRow::ParameterSetEditRow ( ParameterSetEditFrame frame,
TGHorizontalFrame *  lhs,
TGHorizontalFrame *  rhs,
const fhicl::ParameterSet ps,
const std::string &  key 
)

Definition at line 84 of file ParameterSetEditDialog.cxx.

References util::empty(), fChoice, fDOC, fGUI, fLabel, fLeftLH, fParamFlags, fRightLH, fValue, n, SetupCheckButton(), SetupListBox(), SetupRadioButtons(), SetupSlider(), SetupTextEntry(), util::size(), UnpackParameter(), and util::values().

89  : fFrame(frame), fKEY(key)
90 {
91  //
92  // Extract information about the parameter for which we are building
93  // the GUI
94  //
95  std::string tag; // What sort of frame to build?
96  std::vector<std::string> values; // What is the current value?
97  this->UnpackParameter(ps, key, fParamFlags, tag, fChoice, values, fGUI, fDOC);
98  if (empty(values)) {
99  // What happened here? We'll crash if we continue though, so bail out.
100  return;
101  }
102 
103  if (fParamFlags & kVECTOR_PARAM) {
104  fValue = "[";
105  auto const n = size(values);
106  for (std::size_t i = 0; i < n; ++i) {
107  fValue += values[i];
108  if (i + 1 < n)
109  fValue += ",";
110  else
111  fValue += "]";
112  }
113  } else if (fParamFlags & kPARAMETER_SET_PARAM) {
114  fValue = "{";
115  fValue += values[0];
116  fValue += "}";
117  } else {
118  fValue = values[0];
119  }
120 
121  fLeftLH = new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0);
122  fRightLH = new TGLayoutHints(kLHintsRight, 1, 1, 0, 0);
123 
124  fLabel = new TGTextButton(lhs,
125  key.c_str(),
126  -1,
127  TGButton::GetDefaultGC()(),
128  TGTextButton::GetDefaultFontStruct(),
129  0);
130  lhs->AddFrame(fLabel);
131  fLabel->SetToolTipText(fDOC.c_str());
132  fLabel->SetTextJustify(kTextRight);
133 
134  if (tag == kTEXT_ENTRY) {
135  this->SetupTextEntry(rhs, fParamFlags, values);
136  }
137  if (tag == kLIST_BOX_SINGLE) {
138  this->SetupListBox(rhs, fChoice, values, false);
139  }
140  if (tag == kLIST_BOX_MULTI) {
141  this->SetupListBox(rhs, fChoice, values, true);
142  }
143  if (tag == kRADIO_BUTTONS) {
144  this->SetupRadioButtons(rhs, fChoice, values);
145  }
146  if (tag == kCHECK_BOX) {
147  this->SetupCheckButton(rhs, fChoice, values);
148  }
149  if (tag == kSLIDER) {
150  this->SetupSlider(rhs, fChoice, values);
151  }
152  if (tag == kSLIDER_INT) {
153  fParamFlags |= kINTEGER_PARAM;
154  this->SetupSlider(rhs, fChoice, values);
155  }
156 }
void SetupListBox(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value, bool ismulti)
TGLayoutHints * fRightLH
Align to right.
ParameterSetEditFrame * fFrame
The parent frame.
void SetupSlider(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
std::vector< std::string > fChoice
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void SetupTextEntry(TGCompositeFrame *f, unsigned int flags, const std::vector< std::string > &value)
TGLayoutHints * fLeftLH
Align to left.
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
static void UnpackParameter(const fhicl::ParameterSet &ps, const std::string &key, unsigned int &flags, std::string &tag, std::vector< std::string > &choice, std::vector< std::string > &value, std::string &gui, std::string &doc)
void SetupRadioButtons(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
Char_t n[5]
void SetupCheckButton(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109
TGTextButton * fLabel
Label on the left.
ParameterSetEditRow::~ParameterSetEditRow ( )

Definition at line 160 of file ParameterSetEditDialog.cxx.

References fCheckButton, fLabel, fLeftLH, fListBox, fRadioButton, fRightLH, fSlider, and fTextEntry.

161 {
162  cet::for_all(fCheckButton, std::default_delete<TGCheckButton>{});
163  cet::for_all(fRadioButton, std::default_delete<TGRadioButton>{});
164  delete fSlider;
165  delete fListBox;
166  delete fTextEntry;
167  delete fLeftLH;
168  delete fRightLH;
169  delete fLabel;
170 }
std::vector< TGRadioButton * > fRadioButton
TGLayoutHints * fRightLH
Align to right.
TGLayoutHints * fLeftLH
Align to left.
std::vector< TGCheckButton * > fCheckButton
TGTextButton * fLabel
Label on the left.

Member Function Documentation

std::string ParameterSetEditRow::AsFHICL ( ) const

Definition at line 656 of file ParameterSetEditDialog.cxx.

References fDOC, fGUI, fKEY, fParamFlags, and fValue.

657 {
658  std::ostringstream s;
659  if (fParamFlags & kNO_GUI_TAGS) {
660  s << fKEY << ":" << fValue << " ";
661  } else {
662  s << fKEY << ": { "
663  << "val:" << fValue << " "
664  << "gui:\"" << fGUI << "\" "
665  << "doc:\"" << fDOC << "\" "
666  << "}";
667  }
668  return s.str();
669 }
void ParameterSetEditRow::CheckButtonClicked ( )

Definition at line 598 of file ParameterSetEditDialog.cxx.

References fCheckButton, fFrame, fValue, evdb::ParameterSetEditFrame::Modified(), and value.

599 {
600  int value = 0;
601  for (std::size_t i = 0; i < fCheckButton.size(); ++i) {
602  if (fCheckButton[i]->IsDown())
603  value |= 1 << i;
604  }
605  char buff[256];
606  sprintf(buff, "%d", value);
607  fValue = buff;
608  fFrame->Modified();
609 }
ParameterSetEditFrame * fFrame
The parent frame.
double value
Definition: spectrum.C:18
std::vector< TGCheckButton * > fCheckButton
void ParameterSetEditRow::Finalize ( )

Definition at line 646 of file ParameterSetEditDialog.cxx.

References fTextEntry, fValue, and TextEntryReturnPressed().

647 {
648  if (fTextEntry && fValue != fTextEntry->GetBuffer()->GetString()) {
649  this->TextEntryReturnPressed();
650  }
651 }
bool ParameterSetEditRow::IsLegalGUItag ( const std::string &  s)
staticprivate

Definition at line 321 of file ParameterSetEditDialog.cxx.

References MF_LOG_ERROR.

Referenced by ParseGUItag().

322 {
323  for (std::size_t i = 0; i < gsGUITAG.size(); ++i) {
324  if (s == gsGUITAG[i])
325  return true;
326  }
327  MF_LOG_ERROR("ParameterSetEditDialog") << s << " is not a legal GUI tag.";
328  return false;
329 }
#define MF_LOG_ERROR(category)
void ParameterSetEditRow::ListBoxSelected ( int  id)

Definition at line 565 of file ParameterSetEditDialog.cxx.

References fChoice, fFrame, fListBox, fValue, and evdb::ParameterSetEditFrame::Modified().

566 {
567  //
568  // Only handle single selection list boxes here
569  //
570  if (fListBox->GetMultipleSelections())
571  return;
572  fValue = fChoice[id];
573  fFrame->Modified();
574 }
ParameterSetEditFrame * fFrame
The parent frame.
std::vector< std::string > fChoice
void ParameterSetEditRow::ListBoxSelectionChanged ( )

Definition at line 537 of file ParameterSetEditDialog.cxx.

References fChoice, fFrame, fListBox, fValue, and evdb::ParameterSetEditFrame::Modified().

538 {
539  // Only need to handle list boxes where multiple selections are
540  // allowed here.
541  if (fListBox->GetMultipleSelections() == false)
542  return;
543 
544  fValue = "[";
545  TList selections;
546  fListBox->GetSelectedEntries(&selections);
547  TGLBEntry* sel;
548  bool isfirst = true;
549  for (unsigned int i = 0;; ++i) {
550  sel = (TGLBEntry*)selections.At(i);
551  if (sel == 0)
552  break;
553  if (!isfirst)
554  fValue += ",";
555  fValue += fChoice[sel->EntryId()];
556  isfirst = false;
557  }
558  fValue += "]";
559  fFrame->Modified();
560 }
ParameterSetEditFrame * fFrame
The parent frame.
std::vector< std::string > fChoice
void ParameterSetEditRow::ParseGUItag ( const std::string &  guitag,
std::string &  frame,
std::vector< std::string > &  choice 
)
staticprivate

Definition at line 293 of file ParameterSetEditDialog.cxx.

References IsLegalGUItag().

Referenced by UnpackParameter().

296 {
297  // Get the frame name. Should be piece just before the ":"
298  choice.clear();
299  size_t icolon = guitag.find(':');
300  if (icolon == std::string::npos)
301  frame = guitag;
302  else
303  frame = guitag.substr(0, icolon);
304  if (!IsLegalGUItag(frame))
305  frame = kTEXT_ENTRY;
306 
307  // Get the list of choices. Should be comma separated.
308  size_t icomma = icolon;
309  while (icomma != std::string::npos) {
310  size_t spos = icomma + 1;
311  size_t epos = guitag.find(',', spos);
312  std::string s = guitag.substr(spos, epos - spos);
313  choice.push_back(s);
314  icomma = epos;
315  }
316 }
static bool IsLegalGUItag(const std::string &s)
void ParameterSetEditRow::RadioButtonClicked ( )

Definition at line 578 of file ParameterSetEditDialog.cxx.

References fFrame, fRadioButton, fValue, evdb::ParameterSetEditFrame::Modified(), and value.

579 {
580  unsigned int value = 0;
581  TGButton* b = (TGButton*)gTQSender;
582  int id = b->WidgetId();
583  for (size_t i = 0; i < fRadioButton.size(); ++i) {
584  if (fRadioButton[i]->WidgetId() != id) {
585  fRadioButton[i]->SetState(kButtonUp);
586  } else
587  value = i;
588  }
589  char buff[256];
590  sprintf(buff, "%d", value);
591  fValue = buff;
592  fFrame->Modified();
593 }
std::vector< TGRadioButton * > fRadioButton
ParameterSetEditFrame * fFrame
The parent frame.
double value
Definition: spectrum.C:18
void ParameterSetEditRow::SetupCheckButton ( TGCompositeFrame *  f,
const std::vector< std::string > &  choice,
const std::vector< std::string > &  value 
)
private

Definition at line 430 of file ParameterSetEditDialog.cxx.

References fCheckButton.

Referenced by ParameterSetEditRow().

433 {
434  unsigned int mask;
435  unsigned int v = atoi(value[0].c_str());
436  for (size_t i = 0; i < choice.size(); ++i) {
437  TGCheckButton* b = new TGCheckButton(f, choice[i].c_str(), i);
438  f->AddFrame(b);
439  b->Connect(
440  "Clicked()", "evdb::ParameterSetEditRow", this, "CheckButtonClicked()");
441 
442  mask = (0x1) << i;
443  if (v & mask)
444  b->SetState(kButtonDown);
445 
446  fCheckButton.push_back(b);
447  }
448 }
TFile f
Definition: plotHisto.C:6
std::vector< TGCheckButton * > fCheckButton
void ParameterSetEditRow::SetupListBox ( TGCompositeFrame *  f,
const std::vector< std::string > &  choice,
const std::vector< std::string > &  value,
bool  ismulti 
)
private

Definition at line 370 of file ParameterSetEditDialog.cxx.

References fListBox, and util::size().

Referenced by ParameterSetEditRow().

374 {
375  fListBox = new TGListBox(f);
376  f->AddFrame(fListBox);
377  if (ismulti)
378  fListBox->SetMultipleSelections();
379 
380  for (size_t i = 0; i < choice.size(); ++i) {
381  fListBox->AddEntry(choice[i].c_str(), i);
382  for (size_t j = 0; j < size(value); ++j) {
383  if (value[j] == choice[i])
384  fListBox->Select(i);
385  }
386  }
387 
388  fListBox->Connect("SelectionChanged()",
389  "evdb::ParameterSetEditRow",
390  this,
391  "ListBoxSelectionChanged()");
392  fListBox->Connect("Selected(Int_t)",
393  "evdb::ParameterSetEditRow",
394  this,
395  "ListBoxSelected(int)");
396 
397  size_t h = kRowH * choice.size();
398  if (h > 3 * kRowH)
399  h = 3 * kRowH;
400  fListBox->Resize(kRowW, h);
401 }
TFile f
Definition: plotHisto.C:6
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void ParameterSetEditRow::SetupRadioButtons ( TGCompositeFrame *  f,
const std::vector< std::string > &  choice,
const std::vector< std::string > &  value 
)
private

Definition at line 406 of file ParameterSetEditDialog.cxx.

References fRadioButton.

Referenced by ParameterSetEditRow().

409 {
410  unsigned int v = atoi(value[0].c_str());
411 
412  for (size_t i = 0; i < choice.size(); ++i) {
413  TGRadioButton* b = new TGRadioButton(f, choice[i].c_str(), i);
414  f->AddFrame(b);
415 
416  b->SetTextJustify(kTextLeft);
417  b->Connect(
418  "Clicked()", "evdb::ParameterSetEditRow", this, "RadioButtonClicked()");
419 
420  if (i == v)
421  b->SetState(kButtonDown);
422 
423  fRadioButton.push_back(b);
424  }
425 }
std::vector< TGRadioButton * > fRadioButton
TFile f
Definition: plotHisto.C:6
void ParameterSetEditRow::SetupSlider ( TGCompositeFrame *  f,
const std::vector< std::string > &  choice,
const std::vector< std::string > &  value 
)
private

Definition at line 451 of file ParameterSetEditDialog.cxx.

References fSlider, fTextEntry, and util::size().

Referenced by ParameterSetEditRow().

454 {
455  fTextEntry = new TGTextEntry(f);
456  f->AddFrame(fTextEntry);
457 
458  std::string t;
459  if (size(value) == 1) {
460  t = value[0];
461  }
462  if (size(value) == 2) {
463  t = "[";
464  t += value[0];
465  t += ",";
466  t += value[1];
467  t += "]";
468  }
469  fTextEntry->SetText(t.c_str());
470 
471  fTextEntry->Connect("ReturnPressed()",
472  "evdb::ParameterSetEditRow",
473  this,
474  "TextEntryReturnPressed()");
475 
476  fSlider = new TGDoubleHSlider(f, 100, kDoubleScaleBoth);
477  f->AddFrame(fSlider);
478 
479  float min = atof(choice[0].c_str());
480  float max = atof(choice[1].c_str());
481 
482  float pos1 = 0;
483  float pos2 = 0;
484  if (size(value) == 1) {
485  pos1 = atof(value[0].c_str());
486  pos2 = pos1;
487  }
488  if (size(value) == 2) {
489  pos1 = atof(value[0].c_str());
490  pos2 = atof(value[1].c_str());
491  }
492 
493  fSlider->SetRange(min, max);
494  fSlider->SetPosition(pos1, pos2);
495 
496  fSlider->Connect("PositionChanged()",
497  "evdb::ParameterSetEditRow",
498  this,
499  "SliderPositionChanged()");
500 
501  fTextEntry->Resize(kRowW * 1 / 5, kRowH);
502  fSlider->Resize(kRowW * 4 / 5, 10 * kRowH);
503 }
TFile f
Definition: plotHisto.C:6
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void ParameterSetEditRow::SetupTextEntry ( TGCompositeFrame *  f,
unsigned int  flags,
const std::vector< std::string > &  value 
)
private

Definition at line 334 of file ParameterSetEditDialog.cxx.

References fTextEntry, and util::size().

Referenced by ParameterSetEditRow().

337 {
338  static TColor* c = gROOT->GetColor(41);
339 
340  fTextEntry = new TGTextEntry(f);
341  f->AddFrame(fTextEntry);
342  fTextEntry->SetTextColor(c);
343 
344  fTextEntry->Connect("ReturnPressed()",
345  "evdb::ParameterSetEditRow",
346  this,
347  "TextEntryReturnPressed()");
348 
349  std::string buff;
350  if (flags & kVECTOR_PARAM)
351  buff += "[";
352  if (flags & kPARAMETER_SET_PARAM)
353  buff += "{";
354  for (std::size_t i = 0; i < size(value); ++i) {
355  buff += value[i];
356  if ((i + 1) != size(value))
357  buff += ",";
358  }
359  if (flags & kVECTOR_PARAM)
360  buff += "]";
361  if (flags & kPARAMETER_SET_PARAM)
362  buff += "}";
363  fTextEntry->SetText(buff.c_str(), 0);
364  fTextEntry->Resize(kRowW, kRowH);
365 }
TFile f
Definition: plotHisto.C:6
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
void ParameterSetEditRow::SliderPositionChanged ( )

Definition at line 614 of file ParameterSetEditDialog.cxx.

References fFrame, fParamFlags, fSlider, fTextEntry, fValue, and evdb::ParameterSetEditFrame::Modified().

615 {
616  char buff[1024];
617  float mn, mx;
618  fSlider->GetPosition(mn, mx);
619 
620  float const ave = 0.5 * (mn + mx);
621 
622  if (fParamFlags & kINTEGER_PARAM) {
623  int const mni = rint(mn);
624  int const mxi = rint(mx);
625  int const avei = rint(ave);
626  if (fParamFlags & kVECTOR_PARAM) {
627  sprintf(buff, "[%d, %d]", mni, mxi);
628  } else {
629  sprintf(buff, "%d", avei);
630  }
631  } else {
632  if (fParamFlags & kVECTOR_PARAM) {
633  sprintf(buff, "[%.1f, %.1f]", mn, mx);
634  } else {
635  sprintf(buff, "%.1f", ave);
636  }
637  }
638  fTextEntry->SetText(buff);
639  fValue = buff;
640  fFrame->Modified();
641 }
ParameterSetEditFrame * fFrame
The parent frame.
void ParameterSetEditRow::TextEntryReturnPressed ( )

Definition at line 508 of file ParameterSetEditDialog.cxx.

References f1, f2, fFrame, fSlider, fTextEntry, fValue, evdb::ParameterSetEditFrame::Modified(), and n.

Referenced by Finalize().

509 {
510  if (fTextEntry == nullptr)
511  return;
512 
513  const char* text = fTextEntry->GetBuffer()->GetString();
514 
515  static TColor* c = gROOT->GetColor(1);
516  fTextEntry->SetTextColor(c);
517 
518  // If we also have a slider connected to this frame, make sure its
519  // state is updated
520  if (fSlider) {
521  int n = 0;
522  float f1 = 0, f2 = 0;
523  n = sscanf(text, "[%f, %f]", &f1, &f2);
524  if (n != 2) {
525  n = sscanf(text, "%f", &f1);
526  f2 = f1;
527  }
528  fSlider->SetPosition(f1, f2);
529  }
530  fValue = text;
531  fFrame->Modified();
532 }
Float_t f2
ParameterSetEditFrame * fFrame
The parent frame.
Float_t f1
Char_t n[5]
void ParameterSetEditRow::UnpackParameter ( const fhicl::ParameterSet ps,
const std::string &  key,
unsigned int &  flags,
std::string &  tag,
std::vector< std::string > &  choice,
std::vector< std::string > &  value,
std::string &  gui,
std::string &  doc 
)
staticprivate

Definition at line 175 of file ParameterSetEditDialog.cxx.

References util::empty(), fhicl::ParameterSet::get(), MF_LOG_ERROR, ParseGUItag(), util::size(), tmp, and fhicl::ParameterSet::to_string().

Referenced by ParameterSetEditRow().

183 {
184  flag = 0;
185 
186  // Try to extract GUI tags
187  try {
188  gui = p.get<std::string>(key + ".gui");
189  doc = p.get<std::string>(key + ".doc");
190  flag |= kHAVE_GUI_TAGS;
191  }
192  catch (...) {
193  // If they aren't there, try extracting it as a normal
194  // parameter. Default to providing the user with a text entry box.
195  gui = kTEXT_ENTRY;
196  doc = "See .fcl file for documentation...";
197  flag |= kNO_GUI_TAGS;
198  }
199 
200  // Parse out the GUI string to find out what type of frame to build
201  // and the choices we should present to the user
202  ParseGUItag(gui, tag, choice);
203 
204  // Now extract the assigned value(s) of the parameter
205  //
206  // The key is either just the key, or in the case of GUI-enabled
207  // parameters the key name with ".val" appended
208  std::string valkey = key;
209  if (flag & kHAVE_GUI_TAGS)
210  valkey += ".val";
211 
212  // Try first to extract a single value.
213  try {
214  auto const v = p.get<std::string>(valkey);
215  value.push_back(maybe_quoted(v));
216  flag |= kSINGLE_VALUED_PARAM;
217  return;
218  }
219  catch (...) {
220  }
221 
222  // Could not extract as single value; try extracting multiple values
223  try {
224  auto tmp = p.get<std::vector<std::string>>(valkey);
225  for (auto& element : tmp) {
226  element = maybe_quoted(element);
227  }
228  value = move(tmp);
229  flag |= kVECTOR_PARAM;
230  if (empty(value))
231  value.push_back("");
232  return;
233  }
234  catch (...) {
235  }
236 
237  // Yikes - extracting multiple values failed; try vector of vectors, perhaps?
238  try {
239  std::vector<std::vector<std::string>> vv;
240  vv = p.get<std::vector<std::vector<std::string>>>(valkey);
241 
242  // Vectors of vectors are treated as vectors of
243  // std::strings. The strings assigned to the values are
244  // strings that FHiCL will parse as vectors. So, this:
245  //
246  // [ [0,0], [1,1] ]
247  //
248  // is represented as:
249  //
250  // size(value)=2, value[0]="[0,0]", value[1]="[1,1]"
251 
252  flag |= kVECTOR_PARAM;
253  for (std::size_t i = 0; i < size(vv); ++i) {
254  std::string s{"["};
255  auto const m = size(vv[i]);
256  for (std::size_t j = 0; j < m; ++j) {
257  s += maybe_quoted(vv[i][j]);
258  if (j + 2 < m)
259  s += ",";
260  else
261  s += "]";
262  }
263  value.push_back(s);
264  }
265  if (empty(vv))
266  value.push_back("[[]]");
267  return;
268  }
269  catch (...) {
270  }
271 
272  // Above failed; what about another fhicl::ParameterSet?
273  try {
274  auto const v = p.get<fhicl::ParameterSet>(valkey);
275  flag |= kPARAMETER_SET_PARAM;
276  value.push_back(v.to_string());
277  return;
278  }
279  catch (...) {
280  }
281 
282  // Now we are very stuck.
283  MF_LOG_ERROR("ParameterSetEditDialog") << "Failed to parse " << key << "\n"
284  << p.to_string();
285 }
#define MF_LOG_ERROR(category)
Float_t tmp
Definition: plot.C:35
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
static void ParseGUItag(const std::string &guitag, std::string &frame, std::vector< std::string > &choice)
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:109

Member Data Documentation

std::vector<TGCheckButton*> evdb::ParameterSetEditRow::fCheckButton
std::vector<std::string> evdb::ParameterSetEditRow::fChoice
std::string evdb::ParameterSetEditRow::fDOC

Definition at line 160 of file ParameterSetEditDialog.h.

Referenced by AsFHICL(), and ParameterSetEditRow().

std::string evdb::ParameterSetEditRow::fGUI

Definition at line 159 of file ParameterSetEditDialog.h.

Referenced by AsFHICL(), and ParameterSetEditRow().

std::string evdb::ParameterSetEditRow::fKEY

Definition at line 158 of file ParameterSetEditDialog.h.

Referenced by AsFHICL().

TGTextButton* evdb::ParameterSetEditRow::fLabel {nullptr}

Label on the left.

Definition at line 148 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditRow(), and ~ParameterSetEditRow().

TGLayoutHints* evdb::ParameterSetEditRow::fLeftLH {nullptr}

Align to left.

Definition at line 147 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditRow(), and ~ParameterSetEditRow().

TGListBox* evdb::ParameterSetEditRow::fListBox {nullptr}
TGHorizontalFrame* evdb::ParameterSetEditRow::fMother

Top level frame.

Definition at line 145 of file ParameterSetEditDialog.h.

unsigned int evdb::ParameterSetEditRow::fParamFlags

Definition at line 157 of file ParameterSetEditDialog.h.

Referenced by AsFHICL(), ParameterSetEditRow(), and SliderPositionChanged().

std::vector<TGRadioButton*> evdb::ParameterSetEditRow::fRadioButton
TGLayoutHints* evdb::ParameterSetEditRow::fRightLH {nullptr}

Align to right.

Definition at line 146 of file ParameterSetEditDialog.h.

Referenced by ParameterSetEditRow(), and ~ParameterSetEditRow().

TGDoubleSlider* evdb::ParameterSetEditRow::fSlider {nullptr}
TGTextEntry* evdb::ParameterSetEditRow::fTextEntry {nullptr}

The documentation for this class was generated from the following files: