ParameterSetEditDialog.h
Go to the documentation of this file.
1 ///
2 /// \file ParameterSetEditDialog.h
3 /// \brief Pop-up window for editing parameter sets
4 /// \author messier@indiana.edu
5 ///
6 /// These classes build a dialog window for parameter sets. It can
7 /// handle "standard" parameter sets like this:
8 ///
9 /// ServiceConfig {
10 //// A: 0
11 /// B: 2
12 /// C: [0,1]
13 /// D:"String"
14 /// E:["String","Strung"]
15 /// }
16 ///
17 /// for which it will set up a set of text edit boxes. It can also
18 /// handle parameter sets that have been made "gui-aware" and follow
19 /// this format:
20 ///
21 /// ServiceConfig {
22 /// A:{val:0 gui:"rb:Choice 1, Choice 2" doc:"Choose one or two"}
23 /// B:{val:2 gui:"cb:Choice A, Choice B" doc:"Select A or B or both"}
24 /// }
25 ///
26 /// In these cases, "val" is the set value of the parameter, and "doc"
27 /// explains what the parameter is or does. Instructions for building
28 /// the gui are contained in "gui". Valid tags are:
29 ///
30 /// gui:"te" : Text entry box
31 /// gui:"lbs:opt1,opt2,opt3" : A list box, single selection allowed
32 /// gui:"lbm:opt1,opt2,opt3" : A list box, multiple selections allowed
33 /// gui:"rb:opt1,opt2,opt3" : A set of radio buttons
34 /// gui:"cb:opt1,opt2,opt3" : A set of check boxes
35 /// gui:"sl:v1,v2 : A slider to choose values between v1 and v2
36 /// gui:"sli:v1,v2 : A slider for int values between v1 and v2
37 ///
38 /// When retreiving parameters note that:
39 ///
40 /// o List boxes will give results which are a single, or possibly
41 /// multiple, strings representing all the choices the user has made.
42 ///
43 /// o Radio buttons will give a single integer result showing the index
44 /// of the option selected (0,1,2,...)
45 ///
46 /// o Check boxes will give a single integer with bits set indicating
47 /// which options were selected (opt1 = 0x01, opt2=0x02, opt3=0x03,
48 /// etc.)
49 ///
50 /// o Sliders will give one or two floats depending on how they are
51 /// configured. If its one float, it will be the center value
52 /// selected. If two it will be the low and high values selected. To
53 /// configure for low and high values initialize the slider with two
54 /// values like this example:
55 ///
56 /// TimeWindow {
57 /// val:[210,230]
58 /// gui:"sl:-50,550"
59 /// doc:"Select low and high values between -50 and 550" }
60 /// }
61 ///
62 #ifndef EVDB_PARAMETERSETEDITDIALOG_H
63 #define EVDB_PARAMETERSETEDITDIALOG_H
64 #include "RQ_OBJECT.h"
65 #include "TGFrame.h"
66 #include "TQObject.h"
67 class TGTab;
68 class TGCanvas;
69 class TGTableLayout;
70 class TGTableLayoutHints;
71 class TGListBox;
72 class TGDoubleSlider;
73 class TGTextEntry;
74 class TGRadioButton;
75 class TGCheckButton;
76 namespace fhicl {
77  class ParameterSet;
78 }
79 
80 namespace evdb {
81  class ParameterSetEditFrame;
82  ///===================================================================
83  ///
84  /// \brief A single row for editing a single parameter in a set
85  ///
87  RQ_OBJECT("evdb::ParameterSetEditRow")
88  public:
90  TGHorizontalFrame* lhs,
91  TGHorizontalFrame* rhs,
92  const fhicl::ParameterSet& ps,
93  const std::string& key);
95 
96  void Finalize();
97  std::string AsFHICL() const;
98 
99  void TextEntryReturnPressed();
100  void ListBoxSelectionChanged();
101  void ListBoxSelected(int id);
102  void RadioButtonClicked();
103  void CheckButtonClicked();
104  void SliderPositionChanged();
105 
106  private:
107  void SetupTextEntry(TGCompositeFrame* f,
108  unsigned int flags,
109  const std::vector<std::string>& value);
110 
111  void SetupListBox(TGCompositeFrame* f,
112  const std::vector<std::string>& choice,
113  const std::vector<std::string>& value,
114  bool ismulti);
115 
116  void SetupRadioButtons(TGCompositeFrame* f,
117  const std::vector<std::string>& choice,
118  const std::vector<std::string>& value);
119 
120  void SetupCheckButton(TGCompositeFrame* f,
121  const std::vector<std::string>& choice,
122  const std::vector<std::string>& value);
123 
124  void SetupSlider(TGCompositeFrame* f,
125  const std::vector<std::string>& choice,
126  const std::vector<std::string>& value);
127 
128  private:
129  static bool IsLegalGUItag(const std::string& s);
130  static void ParseGUItag(const std::string& guitag,
131  std::string& frame,
132  std::vector<std::string>& choice);
133  static void UnpackParameter(const fhicl::ParameterSet& ps,
134  const std::string& key,
135  unsigned int& flags,
136  std::string& tag,
137  std::vector<std::string>& choice,
138  std::vector<std::string>& value,
139  std::string& gui,
140  std::string& doc);
141 
142  public:
143  ParameterSetEditFrame* fFrame; ///< The parent frame
144  public:
145  TGHorizontalFrame* fMother; ///< Top level frame
146  TGLayoutHints* fRightLH{nullptr}; ///< Align to right
147  TGLayoutHints* fLeftLH{nullptr}; ///< Align to left
148  TGTextButton* fLabel{nullptr}; ///< Label on the left
149  public:
150  TGTextEntry* fTextEntry{nullptr};
151  TGListBox* fListBox{nullptr};
152  TGDoubleSlider* fSlider{nullptr};
153  std::vector<TGRadioButton*> fRadioButton;
154  std::vector<TGCheckButton*> fCheckButton;
155 
156  public:
157  unsigned int fParamFlags;
161  std::vector<std::string> fChoice;
163  };
164 
165  ///===================================================================
166  ///
167  /// \brief A frame for editing a single paramter set
168  ///
170  RQ_OBJECT("evdb:ParameterSetEditFrame")
171  public:
172  ParameterSetEditFrame(TGCompositeFrame* mother, unsigned int psetid);
174 
175  std::string AsFHICL() const;
176 
177  void HandleMouseWheel(Event_t* event);
178  void Modified();
179  void Finalize();
180 
181  public:
182  TGCompositeFrame* fTopFrame;
183  TGCanvas* fCanvas;
184  TGLayoutHints* fCanvasH;
185  TGCompositeFrame* fContainer;
186  TGTableLayout* fLayout;
187  std::vector<TGHorizontalFrame*> fLHS;
188  std::vector<TGHorizontalFrame*> fRHS;
189  std::vector<TGTableLayoutHints*> fLHSHints;
190  std::vector<TGTableLayoutHints*> fRHSHints;
191  std::vector<ParameterSetEditRow*> fRow;
192 
193  public:
194  unsigned int fParameterSetID;
196  };
197 
198  ///===================================================================
199  ///
200  /// \brief Top-level interface to all parameter sets
201  ///
202  class ParameterSetEditDialog : public TGTransientFrame {
203  RQ_OBJECT("evdb::ParameterSetEditDialog")
204  public:
205  ParameterSetEditDialog(unsigned int psetid);
207 
208  void Apply();
209  void Cancel();
210  void Done();
211  void CloseWindow();
212  std::string TabName(const std::string& s);
213 
214  private:
215  TGTab* fTGTab;
216  TGHorizontalFrame* fButtons;
217  TGTextButton* fApply;
218  TGTextButton* fCancel;
219  TGTextButton* fDone;
220 
221  private:
222  unsigned int fParameterSetID;
223  std::vector<ParameterSetEditFrame*> fFrames;
224 
225  ClassDef(ParameterSetEditDialog, 0);
226  };
227 }
228 
229 #endif
230 ////////////////////////////////////////////////////////////////////////
std::vector< TGRadioButton * > fRadioButton
::xsd::cxx::tree::flags flags
Definition: Database.h:214
std::vector< ParameterSetEditRow * > fRow
Manage all things related to colors for the event display.
Definition: Display3DPad.h:11
ParameterSetEditFrame * fFrame
The parent frame.
std::vector< std::string > fChoice
const XML_Char * s
Definition: expat.h:262
std::vector< TGTableLayoutHints * > fRHSHints
Top-level interface to all parameter sets.
std::vector< TGHorizontalFrame * > fLHS
const XML_Char int const XML_Char * value
Definition: expat.h:331
TGHorizontalFrame * fMother
Top level frame.
A frame for editing a single paramter set.
std::vector< TGTableLayoutHints * > fLHSHints
std::vector< TGHorizontalFrame * > fRHS
A single row for editing a single parameter in a set.
std::vector< ParameterSetEditFrame * > fFrames
void Finalize()
Write the final lines of the html file.
Definition: HtmlCosmic.C:230
std::vector< TGCheckButton * > fCheckButton
c1 Modified()
enum BeamMode string