LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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::string > fName
 
std::vector< std::string > fType
 
std::vector< std::string > fValue
 
std::string * fResult
 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 162 of file ParameterSetEdit.cxx.

References fB3, fB4, fB5, fCanvas, fF1, fF3, fL1, fLH1, fLH2, fLH3, fLH4, fName, fParam, fT2, fValue, evdb::ParamFrame::GetFrame(), evdb::ParamFrame::GetHeight(), n, evdb::parse_pset_string(), evdb::ParamFrame::SetCanvas(), and w.

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

Definition at line 272 of file ParameterSetEdit.cxx.

References fB3, fB4, fB5, fF1, fF3, fL1, fLH1, fLH2, fLH3, fLH4, and fT2.

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

Member Function Documentation

void evdb::ParameterSetEdit::Apply ( )

Definition at line 310 of file ParameterSetEdit.cxx.

References Edit(), evdb::kRELOAD_EVENT, and evdb::NavState::Set().

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

Definition at line 294 of file ParameterSetEdit.cxx.

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

Definition at line 290 of file ParameterSetEdit.cxx.

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

Definition at line 301 of file ParameterSetEdit.cxx.

References Edit(), evdb::kRELOAD_EVENT, and evdb::NavState::Set().

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

Definition at line 253 of file ParameterSetEdit.cxx.

References fName, fT2, fValue, and util::values().

Referenced by Apply(), and Done().

254  {
255  unsigned int i;
256  const char* values;
257  std::ostringstream pset;
258 
259  for (i=0; i<fName.size(); ++i) {
260  if(i < fT2.size() ) values = fT2[i]->GetText();
261  else values = fValue[i].c_str();
262  pset << fName[i] << ":" << values << " ";
263  }
264 
265  (*fResult) = pset.str();
266 
267  return 1;
268  }
std::vector< TGTextEntry * > fT2
std::vector< std::string > fName
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::vector< std::string > fValue
void evdb::ParameterSetEdit::HandleTab ( )

Definition at line 318 of file ParameterSetEdit.cxx.

References fT2, and n.

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

Member Data Documentation

TGTextButton* evdb::ParameterSetEdit::fB3
private

Definition at line 82 of file ParameterSetEdit.h.

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

TGTextButton* evdb::ParameterSetEdit::fB4
private

Definition at line 83 of file ParameterSetEdit.h.

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

TGTextButton* evdb::ParameterSetEdit::fB5
private

Definition at line 84 of file ParameterSetEdit.h.

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

TGCanvas* evdb::ParameterSetEdit::fCanvas
private

Definition at line 75 of file ParameterSetEdit.h.

Referenced by ParameterSetEdit().

TGCompositeFrame* evdb::ParameterSetEdit::fF1
private

Definition at line 73 of file ParameterSetEdit.h.

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

TGCompositeFrame* evdb::ParameterSetEdit::fF3
private

Definition at line 76 of file ParameterSetEdit.h.

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

TGLabel* evdb::ParameterSetEdit::fL1
private

Definition at line 81 of file ParameterSetEdit.h.

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

TGLayoutHints* evdb::ParameterSetEdit::fLH1
private

Definition at line 77 of file ParameterSetEdit.h.

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

TGLayoutHints* evdb::ParameterSetEdit::fLH2
private

Definition at line 78 of file ParameterSetEdit.h.

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

TGLayoutHints* evdb::ParameterSetEdit::fLH3
private

Definition at line 79 of file ParameterSetEdit.h.

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

TGLayoutHints* evdb::ParameterSetEdit::fLH4
private

Definition at line 80 of file ParameterSetEdit.h.

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

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

Definition at line 87 of file ParameterSetEdit.h.

Referenced by Edit(), and ParameterSetEdit().

ParamFrame* evdb::ParameterSetEdit::fParam
private

Definition at line 74 of file ParameterSetEdit.h.

Referenced by ParameterSetEdit().

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.

Referenced by Edit(), HandleTab(), ParameterSetEdit(), and ~ParameterSetEdit().

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.

Referenced by Edit(), and ParameterSetEdit().


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