Public Member Functions | Private Member Functions | Private Attributes | List of all members
evdb::ParameterSetEdit Class Reference

Dialog window to edit a parameter set. More...

#include <ParameterSetEdit.h>

Inheritance diagram for evdb::ParameterSetEdit:

Public Member Functions

 ParameterSetEdit (TGMainFrame *mf, const std::string &module, const std::string &label, const std::string &params, std::string *newpset)
 
 ~ParameterSetEdit ()
 
int Edit ()
 
void Apply ()
 
void Cancel ()
 
void Done ()
 
void CloseWindow ()
 
void HandleTab ()
 

Private Member Functions

 ClassDef (ParameterSetEdit, 0)
 

Private Attributes

TGCompositeFrame * fF1
 
ParamFramefParam
 
TGCanvas * fCanvas
 
TGCompositeFrame * fF3
 
TGLayoutHints * fLH1
 
TGLayoutHints * fLH2
 
TGLayoutHints * fLH3
 
TGLayoutHints * fLH4
 
TGLabel * fL1
 
TGTextButton * fB3
 
TGTextButton * fB4
 
TGTextButton * fB5
 
std::vector< TGTextEntry * > fT2
 
std::vector< std::stringfName
 
std::vector< std::stringfType
 
std::vector< std::stringfValue
 
std::stringfResult
 New parameter set. More...
 

Detailed Description

Dialog window to edit a parameter set.

Definition at line 52 of file ParameterSetEdit.h.

Constructor & Destructor Documentation

evdb::ParameterSetEdit::ParameterSetEdit ( TGMainFrame *  mf,
const std::string module,
const std::string label,
const std::string params,
std::string newpset 
)

Definition at line 161 of file ParameterSetEdit.cxx.

165  :
166  TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 4, 4),
167  fResult(newpset)
168  {
169  int h = 800;
170  int w = 500;
171 
172  // Convert the parameter set to a list of names, types, and values.
174 
175  fLH1 = new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,2,2);
176  fLH2 = new TGLayoutHints(kLHintsRight|kLHintsExpandX, 2,2,2,2);
177  fLH3 = new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,2,2,2,2);
178  fLH4 = new TGLayoutHints(kLHintsLeft|kLHintsExpandY, 4,4,4,4);
179 
180  // Add the heading at the top of the window
181  h = 0;
182  fF1 = new TGCompositeFrame(this, w, h, kVerticalFrame);
183  std::ostringstream lbl1;
184  lbl1 << "Module " << module << " - " << label;
185 
186  fL1 = new TGLabel(fF1, lbl1.str().c_str());
187 
188  fF1->AddFrame(fL1,fLH3);
189 
190  fL1->SetHeight(26);
191  this->AddFrame(fF1);
192  h = 30;
193 
194  // Add the parameter fields and edit boxes
195  fCanvas = new TGCanvas(this, w, h);
196  fParam = new ParamFrame(fCanvas->GetViewPort(),
197  fName,
198  fValue,
199  fT2);
201  fCanvas->SetContainer(fParam->GetFrame());
202  fParam->GetFrame()->SetCleanup(kDeepCleanup);
203 
204  for(unsigned int n = 0; n < fT2.size(); ++n){
205  // Pressing enter in a field applies the changes
206  fT2[n]->Connect("ReturnPressed()", "evdb::ParameterSetEdit", this,
207  "Apply()");
208  fT2[n]->Connect("TabPressed()", "evdb::ParameterSetEdit", this,
209  "HandleTab()");
210  }
211 
212  h = fParam->GetHeight();
213  if (h>800) h = 800;
214  fCanvas->Resize(w,h);
215 
216  this->AddFrame(fCanvas);
217 
218  // Button bar across the bottom
219  fF3 = new TGCompositeFrame(this, w, 16, kHorizontalFrame);
220  this->AddFrame(fF3);
221 
222  fB3 = new TGTextButton(fF3, " Apply ");
223  fB4 = new TGTextButton(fF3, " Cancel ");
224  fB5 = new TGTextButton(fF3, " Done ");
225  fF3->AddFrame(fB3, fLH1);
226  fF3->AddFrame(fB4, fLH1);
227  fF3->AddFrame(fB5, fLH1);
228 
229  fB3->Connect("Clicked()","evdb::ParameterSetEdit",this,"Apply()");
230  fB4->Connect("Clicked()","evdb::ParameterSetEdit",this,"Cancel()");
231  fB5->Connect("Clicked()","evdb::ParameterSetEdit",this,"Done()");
232 
233  this->Connect("CloseWindow()","evdb::ParameterSetEdit",this,"CloseWindow()");
234 
235  h += 50;
236 
237  this->Resize(w+8,h);
238  this->MapSubwindows();
239  this->MapWindow();
240 
241  if(!fT2.empty()){
242  // TRy to focus the first text field
243  fT2[0]->SetFocus();
244  fT2[0]->End();
245  }
246 
247  (*fResult) = "";
248  }
int GetHeight() const
TGGroupFrame * GetFrame() const
std::vector< TGTextEntry * > fT2
std::vector< std::string > fName
static void parse_pset_string(const std::string &pset, std::vector< std::string > &names, std::vector< std::string > &values)
TGCompositeFrame * fF3
void SetCanvas(TGCanvas *canvas)
std::void_t< T > n
std::vector< std::string > fValue
TGCompositeFrame * fF1
std::string * fResult
New parameter set.
h
training ###############################
Definition: train_cnn.py:186
evdb::ParameterSetEdit::~ParameterSetEdit ( )

Definition at line 271 of file ParameterSetEdit.cxx.

272  {
273  unsigned int i;
274  delete fB5;
275  delete fB4;
276  delete fB3;
277  for (i=0; i<fT2.size(); ++i) delete fT2[i];
278  delete fL1;
279  delete fF3;
280  delete fF1;
281  delete fLH4;
282  delete fLH3;
283  delete fLH2;
284  delete fLH1;
285  }
std::vector< TGTextEntry * > fT2
TGCompositeFrame * fF3
TGCompositeFrame * fF1

Member Function Documentation

void evdb::ParameterSetEdit::Apply ( )

Definition at line 309 of file ParameterSetEdit.cxx.

310  {
311  this->Edit();
313  }
static void Set(int which)
Definition: NavState.cxx:24
void evdb::ParameterSetEdit::Cancel ( )

Definition at line 293 of file ParameterSetEdit.cxx.

294  {
295  this->SendCloseMessage();
296  }
evdb::ParameterSetEdit::ClassDef ( ParameterSetEdit  ,
 
)
private
void evdb::ParameterSetEdit::CloseWindow ( )

Definition at line 289 of file ParameterSetEdit.cxx.

289 { delete this; }
void evdb::ParameterSetEdit::Done ( )

Definition at line 300 of file ParameterSetEdit.cxx.

301  {
302  this->Edit();
303  this->SendCloseMessage();
305  }
static void Set(int which)
Definition: NavState.cxx:24
int evdb::ParameterSetEdit::Edit ( )

Definition at line 252 of file ParameterSetEdit.cxx.

253  {
254  unsigned int i;
255  const char* values;
256  std::ostringstream pset;
257 
258  for (i=0; i<fName.size(); ++i) {
259  if(i < fT2.size() ) values = fT2[i]->GetText();
260  else values = fValue[i].c_str();
261  pset << fName[i] << ":" << values << " ";
262  }
263 
264  (*fResult) = pset.str();
265 
266  return 1;
267  }
std::vector< TGTextEntry * > fT2
std::vector< std::string > fName
Q_UINT16 values[128]
std::vector< std::string > fValue
void evdb::ParameterSetEdit::HandleTab ( )

Definition at line 317 of file ParameterSetEdit.cxx.

318  {
319  // Work out which text field has focus
320  Window_t focusId = gVirtualX->GetInputFocus();
321  int focusIdx = -1;
322  for(unsigned int n = 0; n < fT2.size(); ++n){
323  if(fT2[n]->GetId() == focusId) focusIdx = n;
324  }
325  // We don't know. Bail out
326  if(focusIdx == -1) return;
327 
328  // Move focus to the next field cyclically
329  ++focusIdx;
330  focusIdx %= fT2.size();
331  fT2[focusIdx]->SetFocus();
332  fT2[focusIdx]->End();
333  }
std::vector< TGTextEntry * > fT2
std::void_t< T > n

Member Data Documentation

TGTextButton* evdb::ParameterSetEdit::fB3
private

Definition at line 82 of file ParameterSetEdit.h.

TGTextButton* evdb::ParameterSetEdit::fB4
private

Definition at line 83 of file ParameterSetEdit.h.

TGTextButton* evdb::ParameterSetEdit::fB5
private

Definition at line 84 of file ParameterSetEdit.h.

TGCanvas* evdb::ParameterSetEdit::fCanvas
private

Definition at line 75 of file ParameterSetEdit.h.

TGCompositeFrame* evdb::ParameterSetEdit::fF1
private

Definition at line 73 of file ParameterSetEdit.h.

TGCompositeFrame* evdb::ParameterSetEdit::fF3
private

Definition at line 76 of file ParameterSetEdit.h.

TGLabel* evdb::ParameterSetEdit::fL1
private

Definition at line 81 of file ParameterSetEdit.h.

TGLayoutHints* evdb::ParameterSetEdit::fLH1
private

Definition at line 77 of file ParameterSetEdit.h.

TGLayoutHints* evdb::ParameterSetEdit::fLH2
private

Definition at line 78 of file ParameterSetEdit.h.

TGLayoutHints* evdb::ParameterSetEdit::fLH3
private

Definition at line 79 of file ParameterSetEdit.h.

TGLayoutHints* evdb::ParameterSetEdit::fLH4
private

Definition at line 80 of file ParameterSetEdit.h.

std::vector<std::string> evdb::ParameterSetEdit::fName
private

Definition at line 87 of file ParameterSetEdit.h.

ParamFrame* evdb::ParameterSetEdit::fParam
private

Definition at line 74 of file ParameterSetEdit.h.

std::string* evdb::ParameterSetEdit::fResult
private

New parameter set.

Definition at line 90 of file ParameterSetEdit.h.

std::vector<TGTextEntry*> evdb::ParameterSetEdit::fT2
private

Definition at line 85 of file ParameterSetEdit.h.

std::vector<std::string> evdb::ParameterSetEdit::fType
private

Definition at line 88 of file ParameterSetEdit.h.

std::vector<std::string> evdb::ParameterSetEdit::fValue
private

Definition at line 89 of file ParameterSetEdit.h.


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