Logo ROOT   6.14/05
Reference Guide
TFunctionParametersDialog.cxx
Go to the documentation of this file.
1 // @(#)root/ged:$Id$
2 // Author: Ilka Antcheva 08/05/06
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TFunctionParametersDialog //
15 // //
16 // This class is used for function parameter settings. //
17 // //
18 //////////////////////////////////////////////////////////////////////////
19 
21 #include "TTimer.h"
22 #include "TList.h"
23 #include "TF1.h"
24 #include "TGButton.h"
25 #include "TGFrame.h"
26 #include "TGLabel.h"
27 #include "TGLayout.h"
28 #include "TGTextEntry.h"
29 #include "TGMsgBox.h"
30 #include "TGNumberEntry.h"
31 #include "TGTripleSlider.h"
32 #include "TVirtualPad.h"
33 
34 
37  kFIX = 10,
38  kVAL = 20,
39  kMIN = 30,
40  kMAX = 40,
41  kSLD = 50,
42  kUPDATE = 8888,
45  kOK,
47 };
48 
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Create the parameters' dialog of currently selected function 'func'.
53 
55  const TGWindow *main,
56  TF1 *func,
57  TVirtualPad *pad,
58  Double_t rx, Double_t ry) :
59  TGTransientFrame(p, main, 10, 10, kVerticalFrame)
60 {
61  fFunc = func;
62  fFpad = pad;
63  fRXmin = rx;
64  fRXmax = ry;
66  fNP = fFunc->GetNpar();
68  fPmin = new Double_t[fNP];
69  fPmax = new Double_t[fNP];
70  fPval = new Double_t[fNP];
71  fPerr = new Double_t[fNP];
72 
73  for (Int_t i = 0; i < fNP; i++) {
74  fFunc->GetParLimits(i, fPmin[i], fPmax[i]);
75  fPval[i] = fFunc->GetParameter(i);
76  fPerr[i] = fFunc->GetParError(i);
77  }
78  fParNam = new TGTextEntry*[fNP];
79  fParFix = new TGCheckButton*[fNP];
80  fParVal = new TGNumberEntry*[fNP];
83  fParSld = new TGTripleHSlider*[fNP];
84 
85  memset(fParNam, 0, sizeof(TGTextEntry*)*fNP);
86  memset(fParFix, 0, sizeof(TGCheckButton*)*fNP);
87  memset(fParVal, 0, sizeof(TGNumberEntry*)*fNP);
88  memset(fParMin, 0, sizeof(TGNumberEntryField*)*fNP);
89  memset(fParMax, 0, sizeof(TGNumberEntryField*)*fNP);
90  memset(fParMax, 0, sizeof(TGTripleHSlider*)*fNP);
91 
93  AddFrame(f1, new TGLayoutHints(kLHintsTop, 1, 1, 1, 1));
94 
95  // column 'Name'
97  fContNam->AddFrame(new TGLabel(fContNam,"Name"),
98  new TGLayoutHints(kLHintsTop, 5, 0, 0, 0));
99  for (Int_t i = 0; i < fNP; i++ ) {
100  fParNam[i] = new TGTextEntry(fContNam, new TGTextBuffer(80), kNAME+i);
101  fParNam[i]->SetText(Form("%s", fFunc->GetParName(i)));
104  new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5));
105  }
106  f1->AddFrame(fContNam, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
107 
108  // column 'Fix'
110  fContFix->AddFrame(new TGLabel(fContFix,"Fix"),
111  new TGLayoutHints(kLHintsTop, 2, 0, 0, 0));
112  for (Int_t i = 0; i < fNP; i++ ) {
113  fParFix[i] = new TGCheckButton(fContFix, "", kFIX*fNP+i);
114  fParFix[i]->SetToolTipText(Form("Set %s to fixed", fFunc->GetParName(i)));
116  5, 5, 10, 7));
117  if ((fPmin[i] == fPmax[i]) && (fPmin[i] || fPmax[i]))
119  else
121  fParFix[i]->Connect("Toggled(Bool_t)", "TFunctionParametersDialog", this, "DoFix(Bool_t)");
122  }
123  f1->AddFrame(fContFix, new TGLayoutHints(kLHintsLeft, 5, 5, 5, 5));
124 
125  // column 'Value'
127  fContVal->AddFrame(new TGLabel(fContVal,"Value"),
128  new TGLayoutHints(kLHintsTop, 5, 0, 0, 0));
129  for (Int_t i = 0; i < fNP; i++ ) {
130  fParVal[i] = new TGNumberEntry(fContVal, 1.2E-12, 15, kVAL*fNP+i,
132  fParVal[i]->SetNumber(fPval[i]);
134  fContVal->AddFrame(fParVal[i], new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5));
135  (fParVal[i]->GetNumberEntry())->SetToolTipText(Form("%s", fFunc->GetParName(i)));
136  (fParVal[i]->GetNumberEntry())->Connect("ReturnPressed()", "TFunctionParametersDialog",
137  this, "DoParValue()");
138  fParVal[i]->Connect("ValueSet(Long_t)", "TFunctionParametersDialog", this, "DoParValue()");
139  }
140  f1->AddFrame(fContVal, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
141 
142  // column 'Min'
144  fContMin->AddFrame(new TGLabel(fContMin,"Min"),
145  new TGLayoutHints(kLHintsTop, 5, 0, 0, 0));
146  for (Int_t i = 0; i < fNP; i++ ) {
147  fParMin[i] = new TGNumberEntryField(fContMin, kMIN*fNP+i, 0.0,
150  ((TGTextEntry*)fParMin[i])->SetToolTipText(Form("Lower limit of %s",
151  fFunc->GetParName(i)));
152  fContMin->AddFrame(fParMin[i], new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5));
153  if (fPmin[i])
154  fParMin[i]->SetNumber(fPmin[i]);
155  else if (fPerr[i])
156  fParMin[i]->SetNumber(fPval[i]-3*fPerr[i]);
157  else if (fPval[i])
158  fParMin[i]->SetNumber(fPval[i]-0.1*fPval[i]);
159  else
160  fParMin[i]->SetNumber(1.0);
161  fParMin[i]->Connect("ReturnPressed()", "TFunctionParametersDialog", this, "DoParMinLimit()");
162  }
163  f1->AddFrame(fContMin, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
164 
165  // column 'Set Range'
166  fContSld = new TGCompositeFrame(f1, 120, 20, kVerticalFrame | kFixedWidth);
167  fContSld->AddFrame(new TGLabel(fContSld,"Set Range"),
168  new TGLayoutHints(kLHintsTop, 5, 0, 0, 0));
169  for (Int_t i = 0; i < fNP; i++ ) {
170  fParSld[i] = new TGTripleHSlider(fContSld, 100, kDoubleScaleBoth, kSLD*fNP+i,
173  fContSld->AddFrame(fParSld[i], new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
175  }
176  f1->AddFrame(fContSld, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
177 
178  // column 'Max'
179  fContMax = new TGCompositeFrame(f1, 80, 20, kVerticalFrame);
180  fContMax->AddFrame(new TGLabel(fContMax,"Max"),
181  new TGLayoutHints(kLHintsTop, 5, 0, 0, 0));
182  for (Int_t i = 0; i < fNP; i++ ) {
183  fParMax[i] = new TGNumberEntryField(fContMax, kMAX*fNP+i, 0.0,
186  ((TGTextEntry*)fParMax[i])->SetToolTipText(Form("Upper limit of %s",
187  fFunc->GetParName(i)));
188  fContMax->AddFrame(fParMax[i], new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 5));
189  if (fPmax[i])
190  fParMax[i]->SetNumber(fPmax[i]);
191  else if (fPerr[i])
192  fParMax[i]->SetNumber(fPval[i]+3*fPerr[i]);
193  else if (fPval[i])
194  fParMax[i]->SetNumber(fPval[i]+0.1*fPval[i]);
195  else
196  fParMax[i]->SetNumber(1.0);
197  if (fParMax[i]->GetNumber() < fParMin[i]->GetNumber()){
198  Double_t temp;
199  temp = fParMax[i]->GetNumber();
200  fParMax[i]->SetNumber(fParMin[i]->GetNumber());
201  fParMin[i]->SetNumber(temp);
202  }
203  fParMax[i]->Connect("ReturnPressed()", "TFunctionParametersDialog", this, "DoParMaxLimit()");
204  }
205  f1->AddFrame(fContMax, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
206 
207 
208  fUpdate = new TGCheckButton(this, "&Immediate preview", kUPDATE);
209  fUpdate->SetToolTipText("Immediate function redrawing");
211  fUpdate->Connect("Toggled(Bool_t)", "TFunctionParametersDialog", this, "HandleButtons(Bool_t)");
212 
214  AddFrame(f2, new TGLayoutHints(kLHintsRight, 20, 20, 5, 1));
215 
216  fReset = new TGTextButton(f2, "&Reset", kRESET);
218  fReset->SetToolTipText("Reset the parameter settings");
220  fReset->Connect("Clicked()", "TFunctionParametersDialog", this, "DoReset()");
221 
222  fApply = new TGTextButton(f2, "&Apply", kAPPLY);
225  fApply->Connect("Clicked()", "TFunctionParametersDialog", this, "DoApply()");
226  fApply->SetToolTipText("Apply parameter settings and redraw the function");
227 
228  fOK = new TGTextButton(f2, "&OK", kOK);
230  fOK->SetToolTipText("Apply parameter settings, redraw function and close this dialog");
231  fOK->Connect("Clicked()", "TFunctionParametersDialog", this, "DoOK()");
232 
233  fCancel = new TGTextButton(f2, "&Cancel", kCANCEL);
235  fCancel->SetToolTipText("Close this dialog with no parameter changes");
236  fCancel->Connect("Clicked()", "TFunctionParametersDialog", this, "DoCancel()");
237 
238  MapSubwindows();
241  SetWindowName(Form("Set Parameters of %s", fFunc->GetTitle()));
242  MapWindow();
243 
244  for (Int_t i = 0; i < fNP; i++ ) {
245  if (fParFix[i]->GetState() == kButtonDown) {
246  fParVal[i]->SetState(kFALSE);
249  fParSld[i]->UnmapWindow();
250  } else {
251  fParSld[i]->SetRange(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
252  fParSld[i]->SetPosition(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
254  fParSld[i]->Connect("PointerPositionChanged()", "TFunctionParametersDialog",
255  this, "DoSlider()");
256  fParSld[i]->Connect("PositionChanged()", "TFunctionParametersDialog",
257  this, "DoSlider()");
258  }
259  }
260 
261  gClient->WaitFor(this);
262 }
263 
264 ////////////////////////////////////////////////////////////////////////////////
265 /// Destructor.
266 
268 {
269  TGFrameElement *el;
270  TIter next(GetList());
271 
272  while ((el = (TGFrameElement *)next())) {
273  if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) {
274  TGFrameElement *el1;
275  TIter next1(((TGCompositeFrame *)el->fFrame)->GetList());
276  while ((el1 = (TGFrameElement *)next1())) {
277  if (!strcmp(el1->fFrame->ClassName(), "TGCompositeFrame"))
278  ((TGCompositeFrame *)el1->fFrame)->Cleanup();
279  }
280  ((TGCompositeFrame *)el->fFrame)->Cleanup();
281  }
282  }
283  Cleanup();
284  delete [] fPval;
285  delete [] fPmin;
286  delete [] fPmax;
287  delete [] fPerr;
288 }
289 
290 ////////////////////////////////////////////////////////////////////////////////
291 /// Close parameters' dialog.
292 
294 {
295  if (fHasChanges) {
296  Int_t ret;
297  const char *txt;
298  txt = "Do you want to apply last parameters' setting?";
300  "Parameters Have Been Changed", txt, kMBIconExclamation,
301  kMBYes | kMBNo | kMBCancel, &ret);
302  if (ret == kMBYes) {
303  DoOK();
304  return;
305  } else if (ret == kMBNo) {
306  DoReset();
307  } else return;
308  }
309  DeleteWindow();
310 }
311 
312 ////////////////////////////////////////////////////////////////////////////////
313 /// Slot related to the Cancel button.
314 
316 {
317  if (fHasChanges)
318  DoReset();
319  TTimer::SingleShot(50, "TFunctionParametersDialog", this, "CloseWindow()");
320 }
321 
322 ////////////////////////////////////////////////////////////////////////////////
323 /// Slot related to the Fix check button.
324 
326 {
328  TGButton *bt = (TGButton *) gTQSender;
329  Int_t id = bt->WidgetId();
330  fHasChanges = kTRUE;
331  for (Int_t i = 0; i < fNP; i++ ) {
332  if (id == kFIX*fNP+i) {
333  if (on) {
334  if (fParVal[i]->GetNumber() != 0) {
335  fParMin[i]->SetNumber(fParVal[i]->GetNumber());
337  fParMax[i]->SetNumber(fParVal[i]->GetNumber());
339  } else {
340  fParMin[i]->SetNumber(1.);
342  fParMax[i]->SetNumber(1.);
344  }
345  fParVal[i]->SetState(kFALSE);
346  fParSld[i]->Disconnect("PointerPositionChanged()");
347  fParSld[i]->Disconnect("PositionChanged()");
348  fParSld[i]->UnmapWindow();
349  fFunc->FixParameter(i, fParVal[i]->GetNumber());
350  } else if (!fParMin[i]->IsEnabled()) {
351  if (fPmin[i] != fPmax[i]) {
352  if (fPmin[i])
353  fParMin[i]->SetNumber(fPmin[i]);
354  else if (fPerr[i])
355  fParMin[i]->SetNumber(fPval[i]-3*fPerr[i]);
356  else if (fPval[i])
357  fParMin[i]->SetNumber(fPval[i]-0.1*fPval[i]);
358  else
359  fParMin[i]->SetNumber(1.0);
360  if (fPmax[i])
361  fParMax[i]->SetNumber(fPmax[i]);
362  else if (fPerr[i])
363  fParMax[i]->SetNumber(fPval[i]+3*fPerr[i]);
364  else if (fPval[i])
365  fParMax[i]->SetNumber(fPval[i]+0.1*fPval[i]);
366  else
367  fParMax[i]->SetNumber(1.0);
368  } else if (fPval[i]) {
369  fParMin[i]->SetNumber(fPval[i]-0.1*fPval[i]);
370  fParMax[i]->SetNumber(fPval[i]+0.1*fPval[i]);
371  } else {
372  fParMin[i]->SetNumber(1.0);
373  fParMax[i]->SetNumber(1.0);
374  }
375  if (fParMax[i]->GetNumber() < fParMin[i]->GetNumber()){
376  Double_t temp;
377  temp = fParMax[i]->GetNumber();
378  fParMax[i]->SetNumber(fParMin[i]->GetNumber());
379  fParMin[i]->SetNumber(temp);
380  }
381  fParMax[i]->SetEnabled(kTRUE);
382  fParMin[i]->SetEnabled(kTRUE);
383  fParSld[i]->MapWindow();
384  fParVal[i]->SetState(kTRUE);
385  fParSld[i]->SetRange(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
386  fParSld[i]->SetPosition(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
388  fParSld[i]->Connect("PointerPositionChanged()", "TFunctionParametersDialog",
389  this, "DoSlider()");
390  fParSld[i]->Connect("PositionChanged()", "TFunctionParametersDialog",
391  this, "DoSlider()");
392  fFunc->SetParLimits(i, fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
393  }
394  }
395  }
396  if (fUpdate->GetState() == kButtonDown)
397  RedrawFunction();
398  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges)
400 }
401 
402 ////////////////////////////////////////////////////////////////////////////////
403 /// Slot related to the OK button.
404 
406 {
407  if (fHasChanges)
408  RedrawFunction();
410  TTimer::SingleShot(50, "TFunctionParametersDialog", this, "CloseWindow()");
411 }
412 
413 ////////////////////////////////////////////////////////////////////////////////
414 /// Slot related to the Preview button.
415 
417 {
418  RedrawFunction();
420  if (fReset->GetState() == kButtonDisabled)
422 }
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 /// Slot related to the Reset button.
426 
428 {
429  fHasChanges = kTRUE;
430  Int_t k = fNP;
431  for (Int_t i = 0; i < fNP; i++) {
432  if (fParVal[i]->GetNumber() == fPval[i])
433  k--;
434  else
435  break;
436  }
437 
438  if (!k) {
439  if (fReset->GetState() == kButtonUp)
442  return;
443  }
444  for (Int_t i = 0; i < fNP; i++) {
445  fFunc->SetParameter(i, fPval[i]);
446  fFunc->SetParLimits(i, fPmin[i], fPmax[i]);
447  fFunc->SetParError(i, fPerr[i]);
448 
449  if (fPmin[i])
450  fParMin[i]->SetNumber(fPmin[i]);
451  else if (fPerr[i])
452  fParMin[i]->SetNumber(fPval[i]-3*fPerr[i]);
453  else if (fPval[i])
454  fParMin[i]->SetNumber(fPval[i]-0.1*fPval[i]);
455  else
456  fParMin[i]->SetNumber(1.0);
457 
458  if (fPmax[i])
459  fParMax[i]->SetNumber(fPmax[i]);
460  else if (fPerr[i])
461  fParMax[i]->SetNumber(fPval[i]+3*fPerr[i]);
462  else if (fPval[i])
463  fParMax[i]->SetNumber(fPval[i]+0.1*fPval[i]);
464  else
465  fParMax[i]->SetNumber(1.0);
466  if (fParMax[i]->GetNumber() < fParMin[i]->GetNumber()){
467  Double_t temp;
468  temp = fParMax[i]->GetNumber();
469  fParMax[i]->SetNumber(fParMin[i]->GetNumber());
470  fParMin[i]->SetNumber(temp);
471  }
472  if (fParMin[i]->GetNumber() == fParMax[i]->GetNumber()) {
473  fParVal[i]->SetState(kFALSE);
476  fParSld[i]->Disconnect("PointerPositionChanged()");
477  fParSld[i]->Disconnect("PositionChanged()");
478  fParSld[i]->UnmapWindow();
479  fFunc->FixParameter(i, fParVal[i]->GetNumber());
481  } else {
483  if (!fParMax[i]->IsEnabled()) {
484  fParMax[i]->SetEnabled(kTRUE);
485  fParMin[i]->SetEnabled(kTRUE);
486  fParVal[i]->SetState(kTRUE);
487  fParSld[i]->SetRange(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
488  fParSld[i]->SetPosition(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
490  fParSld[i]->MapWindow();
491  fParSld[i]->Connect("PointerPositionChanged()", "TFunctionParametersDialog",
492  this, "DoSlider()");
493  fParSld[i]->Connect("PositionChanged()", "TFunctionParametersDialog",
494  this, "DoSlider()");
495  }
496  }
497  fParVal[i]->SetNumber(fPval[i]);
498 
499  fParSld[i]->SetRange(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
500  fParSld[i]->SetPosition(fParMin[i]->GetNumber(), fParMax[i]->GetNumber());
502  }
503 
504  if (fUpdate->GetState() == kButtonDown)
505  RedrawFunction();
506  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges)
510 }
511 
512 ////////////////////////////////////////////////////////////////////////////////
513 /// Slot related to the parameters' value settings.
514 
516 {
518  Int_t id = sl->WidgetId();
519 
520  fHasChanges = kTRUE;
521  for (Int_t i = 0; i < fNP; i++ ) {
522  if (id == kSLD*fNP+i) {
523  fFunc->SetParameter(i,fParSld[i]->GetPointerPosition());
524  fFunc->SetParLimits(i,fParSld[i]->GetMinPosition(),
525  fParSld[i]->GetMaxPosition());
526  fParMin[i]->SetNumber(fParSld[i]->GetMinPosition());
527  fParMax[i]->SetNumber(fParSld[i]->GetMaxPosition());
528  fParVal[i]->SetNumber(fParSld[i]->GetPointerPosition());
529  }
530  }
531  if (fUpdate->GetState() == kButtonDown)
532  RedrawFunction();
533  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges)
535  if (fReset->GetState() == kButtonDisabled)
537 }
538 
539 ////////////////////////////////////////////////////////////////////////////////
540 /// Slot related to the parameter value settings.
541 
543 {
545  Int_t id = ne->WidgetId();
546 
547  for (Int_t i = 0; i < fNP; i++ ) {
548  if (id == kVAL*fNP+i) {
549  fParSld[i]->SetPointerPosition(fParVal[i]->GetNumber());
550  if (fParVal[i]->GetNumber() < fParMin[i]->GetNumber()) {
551  fParMin[i]->SetNumber(fParVal[i]->GetNumber());
553  fParSld[i]->SetRange(fParMin[i]->GetNumber(),
554  fParMax[i]->GetNumber());
555  fParSld[i]->SetPosition(fParMin[i]->GetNumber(),
556  fParMax[i]->GetNumber());
557  }
558  if (fParVal[i]->GetNumber() > fParMax[i]->GetNumber()) {
559  fParMax[i]->SetNumber(fParVal[i]->GetNumber());
561  fParSld[i]->SetRange(fParMin[i]->GetNumber(),
562  fParMax[i]->GetNumber());
563  fParSld[i]->SetPosition(fParMin[i]->GetNumber(),
564  fParMax[i]->GetNumber());
565  }
567  fFunc->SetParameter(i,fParSld[i]->GetPointerPosition());
568  fFunc->SetParLimits(i,fParSld[i]->GetMinPosition(),
569  fParSld[i]->GetMaxPosition());
570  }
571  }
572  fHasChanges = kTRUE;
573  if (fUpdate->GetState() == kButtonDown)
574  RedrawFunction();
575  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges)
577  if (fReset->GetState() == kButtonDisabled)
579 }
580 
581 ////////////////////////////////////////////////////////////////////////////////
582 /// Slot related to the minumum parameter limit settings.
583 
585 {
587  Int_t id = ne->WidgetId();
588 
589  for (Int_t i = 0; i < fNP; i++ ) {
590  if (id == kMIN*fNP+i) {
591  if (fParMin[i]->GetNumber() > fParMax[i]->GetNumber()) {
592  Int_t ret;
593  const char *txt;
594  txt = "The lower parameter bound cannot be bigger then the upper one.";
596  "Parameter Limits", txt, kMBIconExclamation,kMBOk,&ret);
597  fParMin[i]->SetNumber(fParVal[i]->GetNumber());
598  return;
599  }
600  fParSld[i]->SetRange(fParMin[i]->GetNumber(),
601  fParMax[i]->GetNumber());
602  fParSld[i]->SetPosition(fParMin[i]->GetNumber(),
603  fParMax[i]->GetNumber());
604  fParSld[i]->SetPointerPosition(fParVal[i]->GetNumber());
606  }
607  }
608  fHasChanges = kTRUE;
609  if (fUpdate->GetState() == kButtonDown)
610  RedrawFunction();
611  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges)
613  if (fReset->GetState() == kButtonDisabled)
615 }
616 
617 ////////////////////////////////////////////////////////////////////////////////
618 /// Slot related to the maximum parameter limit settings.
619 
621 {
623  Int_t id = ne->WidgetId();
624 
625  for (Int_t i = 0; i < fNP; i++ ) {
626  if (id == kMAX*fNP+i) {
627  if (fParMin[i]->GetNumber() > fParMax[i]->GetNumber()) {
628  Int_t ret;
629  const char *txt;
630  txt = "The lower parameter bound cannot be bigger then the upper one.";
632  "Parameter Limits", txt, kMBIconExclamation,kMBOk,&ret);
633  fParMax[i]->SetNumber(fParVal[i]->GetNumber());
634  return;
635  }
636  fParSld[i]->SetRange(fParMin[i]->GetNumber(),
637  fParMax[i]->GetNumber());
638  fParSld[i]->SetPosition(fParMin[i]->GetNumber(),
639  fParMax[i]->GetNumber());
640  fParSld[i]->SetPointerPosition(fParVal[i]->GetNumber());
642  }
643  }
644  fHasChanges = kTRUE;
645  if (fUpdate->GetState() == kButtonDown)
646  RedrawFunction();
647  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges)
649  if (fReset->GetState() == kButtonDisabled)
651 }
652 
653 ////////////////////////////////////////////////////////////////////////////////
654 /// Redraw function graphics.
655 
657 {
658  TString opt = fFunc->GetDrawOption();
659  opt.ToUpper();
660  if (!opt.Contains("SAME"))
661  opt += "SAME";
663  fFunc->Draw(opt);
664  fFpad->Modified();
665  fFpad->Update();
667 }
668 
669 ////////////////////////////////////////////////////////////////////////////////
670 /// Handle the button dependent states in this dialog.
671 
673 {
674  if (update && fHasChanges)
675  RedrawFunction();
676  else if ((fApply->GetState() == kButtonDisabled) && fHasChanges) {
678  }
679 }
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
Int_t GetState(TGFrame *f) const
Get state of sub frame.
Definition: TGFrame.cxx:1200
virtual ~TFunctionParametersDialog()
Destructor.
virtual void CenterOnParent(Bool_t croot=kTRUE, EPlacement pos=kCenter)
Position transient frame centered relative to the parent frame.
Definition: TGFrame.cxx:1913
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
R__EXTERN void * gTQSender
Definition: TQObject.h:45
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition: TGClient.cxx:222
virtual void Update()=0
Int_t WidgetId() const
Definition: TGWidget.h:80
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition: TF1.cxx:3425
virtual void SetNumber(Double_t val)
void ToUpper()
Change string to upper case.
Definition: TString.cxx:1113
virtual void DoOK()
Slot related to the OK button.
Basic string class.
Definition: TString.h:131
#define gClient
Definition: TGClient.h:166
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition: TTimer.cxx:256
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF1.cxx:1224
virtual void SetState(Bool_t enable=kTRUE)
Set the active state.
virtual Double_t GetParError(Int_t ipar) const
Return value of parameter number ipar.
Definition: TF1.cxx:1817
virtual void SetRange(Float_t min, Float_t max)
virtual void DoParMaxLimit()
Slot related to the maximum parameter limit settings.
TFunctionParametersDialog(const TGWindow *p, const TGWindow *main, TF1 *func, TVirtualPad *pad, Double_t rmin, Double_t rmax)
Create the parameters&#39; dialog of currently selected function &#39;func&#39;.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual void SetPointerPosition(Float_t pos)
Set pointer position in scaled (real) value.
virtual void RedrawFunction()
Redraw function graphics.
TGCompositeFrame(const TGCompositeFrame &)
virtual Double_t GetNumber() const
Get the numeric value (floating point representation).
int main(int argc, char **argv)
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition: TGWindow.cxx:133
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual EButtonState GetState() const
Definition: TGButton.h:112
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
Definition: TGMsgBox.h:43
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TObject.cxx:341
virtual const char * GetParName(Int_t ipar) const
Definition: TF1.h:513
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot...
Definition: TQObject.cxx:867
virtual void DoApply()
Slot related to the Preview button.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set limits for parameter ipar.
Definition: TF1.cxx:3404
virtual void DoParValue()
Slot related to the parameter value settings.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:375
virtual void SetParError(Int_t ipar, Double_t error)
Set error for parameter number ipar.
Definition: TF1.cxx:3379
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
char * Form(const char *fmt,...)
virtual void FixParameter(Int_t ipar, Double_t value)
Fix the value of a parameter The specified value will be used in a fit operation. ...
Definition: TF1.cxx:1449
TGFrame * fFrame
Definition: TGLayout.h:119
constexpr Double_t E()
Base of natural log: .
Definition: TMath.h:97
virtual void DoCancel()
Slot related to the Cancel button.
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void Modified(Bool_t flag=1)=0
virtual void SetFormat(EStyle style, EAttribute attr=TGNumberFormat::kNEAAnyNumber)
void SetEnabled(Bool_t flag=kTRUE)
Definition: TGTextEntry.h:164
#define ClassImp(name)
Definition: Rtypes.h:359
double Double_t
Definition: RtypesCore.h:55
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1025
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void SetConstrained(Bool_t on=kTRUE)
Set pointer position constrained in the slider range.
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
virtual void UnmapWindow()
Definition: TGFrame.h:253
virtual Int_t GetNpar() const
Definition: TF1.h:465
virtual void GetParLimits(Int_t ipar, Double_t &parmin, Double_t &parmax) const
Return limits for parameter ipar.
Definition: TF1.cxx:1827
virtual void SetNumber(Double_t val)
Set the numeric value (floating point representation).
TGNumberEntryField * GetNumberEntry() const
virtual void DoParMinLimit()
Slot related to the minumum parameter limit settings.
virtual void DoReset()
Slot related to the Reset button.
EParametersDialogWid
virtual Double_t GetParameter(Int_t ipar) const
Definition: TF1.h:496
virtual void MapWindow()
Definition: TGFrame.h:251
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
Definition: TF1.cxx:2170
TGClient * fClient
Definition: TGObject.h:37
1-Dim function class
Definition: TF1.h:211
virtual void CloseWindow()
Close parameters&#39; dialog.
TF1 * f1
Definition: legend1.C:11
virtual void SetPosition(Float_t min, Float_t max)
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
virtual void HandleButtons(Bool_t update)
Handle the button dependent states in this dialog.
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set check button state.
Definition: TGButton.cxx:1200
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:618
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
virtual void DoSlider()
Slot related to the parameters&#39; value settings.
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:949
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:395
virtual void DoFix(Bool_t on)
Slot related to the Fix check button.
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
Definition: TGMsgBox.h:44
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185