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 "TQObject.h"
65 #include "RQ_OBJECT.h"
66 #include "TGFrame.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 { class ParameterSet; }
77 
78 namespace evdb
79 {
80  class ParameterSetEditFrame;
81  ///===================================================================
82  ///
83  /// \brief A single row for editing a single parameter in a set
84  ///
86  {
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  public:
142  ParameterSetEditFrame* fFrame; ///< The parent frame
143  public:
144  TGHorizontalFrame* fMother; ///< Top level frame
145  TGLayoutHints* fRightLH;///< Align to right
146  TGLayoutHints* fLeftLH; ///< Align to left
147  TGTextButton* fLabel; ///< Label on the left
148  public:
149  TGTextEntry* fTextEntry;
150  TGListBox* fListBox;
151  TGDoubleSlider* fSlider;
152  std::vector<TGRadioButton*> fRadioButton;
153  std::vector<TGCheckButton*> fCheckButton;
154  public:
155  unsigned int fParamFlags;
159  std::vector<std::string> fChoice;
161  };
162 
163  ///===================================================================
164  ///
165  /// \brief A frame for editing a single paramter set
166  ///
168  {
169  RQ_OBJECT("evdb:ParameterSetEditFrame")
170  public:
171 
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  public:
193  unsigned int fParameterSetID;
195  };
196 
197  ///===================================================================
198  ///
199  /// \brief Top-level interface to all parameter sets
200  ///
201  class ParameterSetEditDialog : public TGTransientFrame
202  {
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  private:
221  unsigned int fParameterSetID;
222  std::vector<ParameterSetEditFrame*> fFrames;
223 
225  };
226 }
227 
228 #endif
229 ////////////////////////////////////////////////////////////////////////
std::vector< TGRadioButton * > fRadioButton
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12
std::vector< ParameterSetEditRow * > fRow
TGLayoutHints * fRightLH
Align to right.
Manage all things related to colors for the event display.
ParameterSetEditFrame * fFrame
The parent frame.
std::vector< std::string > fChoice
TGLayoutHints * fLeftLH
Align to left.
std::vector< TGTableLayoutHints * > fRHSHints
Top-level interface to all parameter sets.
std::vector< TGHorizontalFrame * > fLHS
def key(type, name=None)
Definition: graph.py:13
parameter set interface
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
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
QCString doc
std::vector< TGCheckButton * > fCheckButton
static QCString * s
Definition: config.cpp:1042
Event finding and building.
TGTextButton * fLabel
Label on the left.