LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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
 Align to right. More...
 
TGLayoutHints * fLeftLH
 Align to left. More...
 
TGTextButton * fLabel
 Label on the left. More...
 
TGTextEntry * fTextEntry
 
TGListBox * fListBox
 
TGDoubleSlider * fSlider
 
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 85 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 71 of file ParameterSetEditDialog.cxx.

References fChoice, fDOC, fGUI, fLabel, fLeftLH, fParamFlags, fRightLH, fValue, kCHECK_BOX, kINTEGER_PARAM, kLIST_BOX_MULTI, kLIST_BOX_SINGLE, kPARAMETER_SET_PARAM, kRADIO_BUTTONS, kSLIDER, kSLIDER_INT, kTEXT_ENTRY, kVECTOR_PARAM, SetupCheckButton(), SetupListBox(), SetupRadioButtons(), SetupSlider(), SetupTextEntry(), and UnpackParameter().

75  :
76  fFrame(frame),
77  fRightLH(0),
78  fLeftLH(0),
79  fLabel(0),
80  fTextEntry(0),
81  fListBox(0),
82  fSlider(0),
83  fKEY(key)
84 {
85  //
86  // Extract information about the parameter for which we are building
87  // the GUI
88  //
89  std::string tag; // What sort of frame to build?
90  std::vector<std::string> values; // What is the current value?
91  this->UnpackParameter(ps, key, fParamFlags, tag, fChoice, values, fGUI, fDOC);
92  if (values.empty()){
93  // What happened here? We'll crash if we continue though, so bail out.
94  return;
95  }
96 
98  fValue = "[";
99  for (unsigned int i=0; i<values.size(); ++i) {
100  fValue += values[i];
101  if (i+1<values.size()) fValue += ",";
102  else fValue += "]";
103  }
104  }
106  fValue = "{";
107  fValue += values[0];
108  fValue += "}";
109  }
110  else {
111  fValue = values[0];
112  }
113 
114  fLeftLH = new TGLayoutHints(kLHintsLeft, 1,1,0,0);
115  fRightLH = new TGLayoutHints(kLHintsRight,1,1,0,0);
116 
117  fLabel = new TGTextButton(lhs,
118  key.c_str(),
119  -1,
120  TGButton::GetDefaultGC()(),
121  TGTextButton::GetDefaultFontStruct(),
122  0);
123  lhs->AddFrame(fLabel);
124  fLabel->SetToolTipText(fDOC.c_str());
125  fLabel->SetTextJustify(kTextRight);
126 
127  if (tag==kTEXT_ENTRY) {
128  this->SetupTextEntry(rhs, fParamFlags, values);
129  }
130  if (tag==kLIST_BOX_SINGLE) {
131  this->SetupListBox(rhs, fChoice, values, false);
132  }
133  if (tag==kLIST_BOX_MULTI) {
134  this->SetupListBox(rhs, fChoice, values, true);
135  }
136  if (tag==kRADIO_BUTTONS) {
137  this->SetupRadioButtons(rhs, fChoice, values);
138  }
139  if (tag==kCHECK_BOX) {
140  this->SetupCheckButton(rhs, fChoice, values);
141  }
142  if (tag==kSLIDER) {
143  this->SetupSlider(rhs, fChoice, values);
144  }
145  if (tag==kSLIDER_INT) {
147  this->SetupSlider(rhs, fChoice, values);
148  }
149 }
void SetupListBox(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value, bool ismulti)
GUITAG kRADIO_BUTTONS
TGLayoutHints * fRightLH
Align to right.
GUITAG kLIST_BOX_SINGLE
GUITAG kLIST_BOX_MULTI
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
void SetupTextEntry(TGCompositeFrame *f, unsigned int flags, const std::vector< std::string > &value)
TGLayoutHints * fLeftLH
Align to left.
GUITAG kCHECK_BOX
static const int kINTEGER_PARAM
static const int kPARAMETER_SET_PARAM
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)
static const int kVECTOR_PARAM
GUITAG kSLIDER
void SetupRadioButtons(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
GUITAG kTEXT_ENTRY
GUITAG kSLIDER_INT
void SetupCheckButton(TGCompositeFrame *f, const std::vector< std::string > &choice, const std::vector< std::string > &value)
TGTextButton * fLabel
Label on the left.
ParameterSetEditRow::~ParameterSetEditRow ( )

Definition at line 153 of file ParameterSetEditDialog.cxx.

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

154 {
155  unsigned int i;
156  for (i=0; i<fCheckButton.size(); ++i) {
157  if (fCheckButton[i]) delete fCheckButton[i];
158  }
159  for (i=0; i<fRadioButton.size(); ++i) {
160  if (fRadioButton[i]) delete fRadioButton[i];
161  }
162  if (fSlider) delete fSlider;
163  if (fListBox) delete fListBox;
164  if (fTextEntry) delete fTextEntry;
165  if (fLeftLH) delete fLeftLH;
166  if (fRightLH) delete fRightLH;
167  if (fLabel) delete fLabel;
168 }
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 632 of file ParameterSetEditDialog.cxx.

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

633 {
634  std::ostringstream s;
635  if (fParamFlags & kNO_GUI_TAGS) {
636  s << fKEY << ":" << fValue << " ";
637  }
638  else {
639  s << fKEY
640  << ": { "
641  << "val:" << fValue << " "
642  << "gui:\"" << fGUI << "\" "
643  << "doc:\"" << fDOC << "\" "
644  << "}";
645  }
646  return s.str();
647 }
Float_t s
Definition: plot.C:23
static const int kNO_GUI_TAGS
void ParameterSetEditRow::CheckButtonClicked ( )

Definition at line 573 of file ParameterSetEditDialog.cxx.

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

574 {
575  int value = 0;
576  for (unsigned int i=0; i<fCheckButton.size(); ++i) {
577  if (fCheckButton[i]->IsDown()) value |= 1<<i;
578  }
579  char buff[256];
580  sprintf(buff, "%d", value);
581  fValue = buff;
582  fFrame->Modified();
583 }
ParameterSetEditFrame * fFrame
The parent frame.
std::string value(boost::any const &)
std::vector< TGCheckButton * > fCheckButton
void ParameterSetEditRow::Finalize ( )

Definition at line 621 of file ParameterSetEditDialog.cxx.

References fTextEntry, fValue, and TextEntryReturnPressed().

622 {
623  if (fTextEntry) {
624  if (fValue != fTextEntry->GetBuffer()->GetString()) {
625  this->TextEntryReturnPressed();
626  }
627  }
628 }
bool ParameterSetEditRow::IsLegalGUItag ( const std::string &  s)
staticprivate

Definition at line 320 of file ParameterSetEditDialog.cxx.

References LOG_ERROR.

Referenced by ParseGUItag().

321 {
322  for(unsigned int i=0; i<gsGUITAG.size(); ++i) {
323  if (s==gsGUITAG[i]) return true;
324  }
325  LOG_ERROR("ParameterSetEditDialog") << s << " is not a legal GUI tag.";
326  return false;
327 }
Float_t s
Definition: plot.C:23
#define LOG_ERROR(category)
static const std::vector< std::string > gsGUITAG
void ParameterSetEditRow::ListBoxSelected ( int  id)

Definition at line 543 of file ParameterSetEditDialog.cxx.

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

544 {
545  //
546  // Only handle single selection list boxes here
547  //
548  if (fListBox->GetMultipleSelections()) return;
549  fValue = fChoice[id];
550  fFrame->Modified();
551 }
ParameterSetEditFrame * fFrame
The parent frame.
std::vector< std::string > fChoice
void ParameterSetEditRow::ListBoxSelectionChanged ( )

Definition at line 517 of file ParameterSetEditDialog.cxx.

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

518 {
519  //
520  // Only need to handle list boxes where multiple selections are
521  // allowed here.
522  //
523  if (fListBox->GetMultipleSelections()==0) return;
524 
525  fValue = "[";
526  TList selections;
527  fListBox->GetSelectedEntries(&selections);
528  TGLBEntry* sel;
529  bool isfirst = true;
530  for (unsigned int i=0;;++i) {
531  sel = (TGLBEntry*)selections.At(i);
532  if (sel==0) break;
533  if (!isfirst) fValue += ",";
534  fValue += fChoice[sel->EntryId()];
535  isfirst = false;
536  }
537  fValue += "]";
538  fFrame->Modified();
539 }
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 291 of file ParameterSetEditDialog.cxx.

References IsLegalGUItag(), kTEXT_ENTRY, and s.

Referenced by UnpackParameter().

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

Definition at line 554 of file ParameterSetEditDialog.cxx.

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

555 {
556  unsigned int value = 0;
557  TGButton* b = (TGButton*)gTQSender;
558  int id = b->WidgetId();
559  for (size_t i=0; i<fRadioButton.size(); ++i) {
560  if (fRadioButton[i]->WidgetId() != id) {
561  fRadioButton[i]->SetState(kButtonUp);
562  }
563  else value = i;
564  }
565  char buff[256];
566  sprintf(buff, "%d", value);
567  fValue = buff;
568  fFrame->Modified();
569 }
std::vector< TGRadioButton * > fRadioButton
ParameterSetEditFrame * fFrame
The parent frame.
std::string value(boost::any const &)
void ParameterSetEditRow::SetupCheckButton ( TGCompositeFrame *  f,
const std::vector< std::string > &  choice,
const std::vector< std::string > &  value 
)
private

Definition at line 417 of file ParameterSetEditDialog.cxx.

References fCheckButton.

Referenced by ParameterSetEditRow().

420 {
421  unsigned int mask;
422  unsigned int v = atoi(value[0].c_str());
423  for (size_t i=0; i<choice.size(); ++i) {
424  TGCheckButton* b = new TGCheckButton(f, choice[i].c_str(), i);
425  f->AddFrame(b);
426  b->Connect("Clicked()",
427  "evdb::ParameterSetEditRow",
428  this,
429  "CheckButtonClicked()");
430 
431  mask = (0x1)<<i;
432  if (v&mask) b->SetState(kButtonDown);
433 
434  fCheckButton.push_back(b);
435  }
436 }
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 361 of file ParameterSetEditDialog.cxx.

References fListBox, kRowH, and kRowW.

Referenced by ParameterSetEditRow().

365 {
366  fListBox = new TGListBox(f);
367  f->AddFrame(fListBox);
368  if (ismulti) fListBox->SetMultipleSelections();
369 
370  for (size_t i=0; i<choice.size(); ++i) {
371  fListBox->AddEntry(choice[i].c_str(), i);
372  for (size_t j=0; j<value.size(); ++j) {
373  if (value[j]==choice[i]) fListBox->Select(i);
374  }
375  }
376 
377  fListBox->Connect("SelectionChanged()",
378  "evdb::ParameterSetEditRow",
379  this,
380  "ListBoxSelectionChanged()");
381  fListBox->Connect("Selected(Int_t)",
382  "evdb::ParameterSetEditRow",
383  this,
384  "ListBoxSelected(int)");
385 
386  size_t h = kRowH*choice.size();
387  if (h>3*kRowH) h = 3*kRowH;
388  fListBox->Resize(kRowW,h);
389 }
TFile f
Definition: plotHisto.C:6
static const unsigned int kRowH
static const unsigned int kRowW
void ParameterSetEditRow::SetupRadioButtons ( TGCompositeFrame *  f,
const std::vector< std::string > &  choice,
const std::vector< std::string > &  value 
)
private

Definition at line 393 of file ParameterSetEditDialog.cxx.

References fRadioButton.

Referenced by ParameterSetEditRow().

396 {
397  unsigned int v = atoi(value[0].c_str());
398 
399  for (size_t i=0; i<choice.size(); ++i) {
400  TGRadioButton* b = new TGRadioButton(f, choice[i].c_str(), i);
401  f->AddFrame(b);
402 
403  b->SetTextJustify(kTextLeft);
404  b->Connect("Clicked()",
405  "evdb::ParameterSetEditRow",
406  this,
407  "RadioButtonClicked()");
408 
409  if (i==v) b->SetState(kButtonDown);
410 
411  fRadioButton.push_back(b);
412  }
413 }
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 438 of file ParameterSetEditDialog.cxx.

References fSlider, fTextEntry, kRowH, kRowW, max, and min.

Referenced by ParameterSetEditRow().

441 {
442  fTextEntry = new TGTextEntry(f);
443  f->AddFrame(fTextEntry);
444 
445  std::string t;
446  if (value.size()==1) { t = value[0]; }
447  if (value.size()==2) {
448  t = "["; t += value[0]; t += ","; t += value[1]; t += "]";
449  }
450  fTextEntry->SetText(t.c_str());
451 
452  fTextEntry->Connect("ReturnPressed()",
453  "evdb::ParameterSetEditRow",
454  this,
455  "TextEntryReturnPressed()");
456 
457  fSlider = new TGDoubleHSlider(f, 100, kDoubleScaleBoth);
458  f->AddFrame(fSlider);
459 
460  float min = atof(choice[0].c_str());
461  float max = atof(choice[1].c_str());
462 
463  float pos1 = 0;
464  float pos2 = 0;
465  if (value.size()==1) {
466  pos1 = atof(value[0].c_str());
467  pos2 = pos1;
468  }
469  if (value.size()==2) {
470  pos1 = atof(value[0].c_str());
471  pos2 = atof(value[1].c_str());
472  }
473 
474  fSlider->SetRange(min, max);
475  fSlider->SetPosition(pos1, pos2);
476 
477  fSlider->Connect("PositionChanged()",
478  "evdb::ParameterSetEditRow",
479  this,
480  "SliderPositionChanged()");
481 
482  fTextEntry->Resize(kRowW*1/5, kRowH);
483  fSlider-> Resize(kRowW*4/5,10*kRowH);
484 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
static const unsigned int kRowH
static const unsigned int kRowW
Int_t min
Definition: plot.C:26
void ParameterSetEditRow::SetupTextEntry ( TGCompositeFrame *  f,
unsigned int  flags,
const std::vector< std::string > &  value 
)
private

Definition at line 331 of file ParameterSetEditDialog.cxx.

References fTextEntry, kPARAMETER_SET_PARAM, kRowH, kRowW, and kVECTOR_PARAM.

Referenced by ParameterSetEditRow().

334 {
335  static TColor* c = gROOT->GetColor(41);
336 
337  fTextEntry = new TGTextEntry(f);
338  f->AddFrame(fTextEntry);
339  fTextEntry->SetTextColor(c);
340 
341  fTextEntry->Connect("ReturnPressed()",
342  "evdb::ParameterSetEditRow",
343  this,
344  "TextEntryReturnPressed()");
345 
346  std::string buff;
347  if (flags&kVECTOR_PARAM) buff += "[";
348  if (flags&kPARAMETER_SET_PARAM) buff += "{";
349  for (unsigned int i=0; i<value.size(); ++i) {
350  buff += value[i];
351  if ((i+1)!=value.size()) buff += ",";
352  }
353  if (flags&kVECTOR_PARAM) buff += "]";
354  if (flags&kPARAMETER_SET_PARAM) buff += "}";
355  fTextEntry->SetText(buff.c_str(), 0);
356  fTextEntry->Resize(kRowW,kRowH);
357 }
TFile f
Definition: plotHisto.C:6
static const unsigned int kRowH
static const int kPARAMETER_SET_PARAM
static const unsigned int kRowW
static const int kVECTOR_PARAM
void ParameterSetEditRow::SliderPositionChanged ( )

Definition at line 587 of file ParameterSetEditDialog.cxx.

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

588 {
589  char buff[1024];
590  float mn, mx, ave;
591  fSlider->GetPosition(mn, mx);
592 
593  ave = 0.5*(mn+mx);
594 
595  if (fParamFlags & kINTEGER_PARAM) {
596  int mni = rint(mn);
597  int mxi = rint(mx);
598  int avei = rint(ave);
599  if (fParamFlags & kVECTOR_PARAM) {
600  sprintf(buff, "[%d, %d]",mni,mxi);
601  }
602  else {
603  sprintf(buff, "%d",avei);
604  }
605  }
606  else {
607  if (fParamFlags & kVECTOR_PARAM) {
608  sprintf(buff, "[%.1f, %.1f]",mn,mx);
609  }
610  else {
611  sprintf(buff, "%.1f",ave);
612  }
613  }
614  fTextEntry->SetText(buff);
615  fValue = buff;
616  fFrame->Modified();
617 }
ParameterSetEditFrame * fFrame
The parent frame.
static const int kINTEGER_PARAM
static const int kVECTOR_PARAM
void ParameterSetEditRow::TextEntryReturnPressed ( )

Definition at line 488 of file ParameterSetEditDialog.cxx.

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

Referenced by Finalize().

489 {
490  if (fTextEntry==0) return;
491 
492  const char* text = fTextEntry->GetBuffer()->GetString();
493 
494  static TColor* c = gROOT->GetColor(1);
495  fTextEntry->SetTextColor(c);
496 
497  //
498  // If we also have a slider connected to this frame, make sure its
499  // state is updated
500  //
501  if (fSlider) {
502  int n=0;
503  float f1=0, f2=0;
504  n = sscanf(text, "[%f, %f]", &f1, &f2);
505  if (n!=2) {
506  n = sscanf(text, "%f", &f1);
507  f2 = f1;
508  }
509  fSlider->SetPosition(f1, f2);
510  }
511  fValue = text;
512  fFrame->Modified();
513 }
SynchrotronAndGN f2
ParameterSetEditFrame * fFrame
The parent frame.
EmPhysicsFactory 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 172 of file ParameterSetEditDialog.cxx.

References fhicl::ParameterSet::get(), kHAVE_GUI_TAGS, kNO_GUI_TAGS, kPARAMETER_SET_PARAM, kSINGLE_VALUED_PARAM, kTEXT_ENTRY, kVECTOR_PARAM, LOG_ERROR, ParseGUItag(), s, and fhicl::ParameterSet::to_string().

Referenced by ParameterSetEditRow().

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

Member Data Documentation

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

Definition at line 158 of file ParameterSetEditDialog.h.

Referenced by AsFHICL(), and ParameterSetEditRow().

std::string evdb::ParameterSetEditRow::fGUI

Definition at line 157 of file ParameterSetEditDialog.h.

Referenced by AsFHICL(), and ParameterSetEditRow().

std::string evdb::ParameterSetEditRow::fKEY

Definition at line 156 of file ParameterSetEditDialog.h.

Referenced by AsFHICL().

TGTextButton* evdb::ParameterSetEditRow::fLabel

Label on the left.

Definition at line 147 of file ParameterSetEditDialog.h.

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

TGLayoutHints* evdb::ParameterSetEditRow::fLeftLH

Align to left.

Definition at line 146 of file ParameterSetEditDialog.h.

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

TGListBox* evdb::ParameterSetEditRow::fListBox
TGHorizontalFrame* evdb::ParameterSetEditRow::fMother

Top level frame.

Definition at line 144 of file ParameterSetEditDialog.h.

unsigned int evdb::ParameterSetEditRow::fParamFlags

Definition at line 155 of file ParameterSetEditDialog.h.

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

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

Align to right.

Definition at line 145 of file ParameterSetEditDialog.h.

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

TGDoubleSlider* evdb::ParameterSetEditRow::fSlider
TGTextEntry* evdb::ParameterSetEditRow::fTextEntry

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