#include "TROOT.h"
#include "TFitPanelGraph.h"
#include "TGroupButton.h"
#include "TSlider.h"
#include "TText.h"
#include "TGraph.h"
#include "TF1.h"
#include <stdio.h>
ClassImp(TFitPanelGraph)
//Begin_Html
/*
<img src="gif/fitpanel.gif">
*/
//End_Html
TFitPanelGraph::TFitPanelGraph() : TFitPanel()
{
}
TFitPanelGraph::TFitPanelGraph(const char *name, const char *title, UInt_t ww, UInt_t wh, const TVirtualPad *pad, const TObject *obj)
: TFitPanel(name, title,ww,wh,pad,obj)
{
}
TFitPanelGraph::~TFitPanelGraph()
{
}
void TFitPanelGraph::Apply(const char *action)
{
if (!fRefPad) return;
fRefPad->cd();
SetCursor(kWatch);
if (!strcmp(action,"Defaults")) {
SetDefaults();
return;
}
TObject *obj;
TGroupButton *button;
TIter next(fPrimitives);
while ((obj = next())) {
if (obj->InheritsFrom(TGroupButton::Class())) {
button = (TGroupButton*)obj;
if (button->GetBorderMode() < 0) button->ExecuteAction();
}
}
TGraph *gr = (TGraph*)fObjectFit;
Int_t npoints = gr->GetN();
Double_t *gx = gr->GetX();
TF1 *f1 = (TF1*)gROOT->GetFunction(fFunction.Data());
if (!f1) return;
Float_t xgrmin = gx[0];
Float_t xgrmax = gx[0];
for (Int_t i=0;i<npoints;i++) {
if (gx[i] < xgrmin) xgrmin = gx[i];
if (gx[i] > xgrmax) xgrmax = gx[i];
}
Float_t smin = fSlider->GetMinimum();
Float_t smax = fSlider->GetMaximum();
Float_t xpmin = fRefPad->GetUxmin();
Float_t xpmax = fRefPad->GetUxmax();
Float_t xmin = xpmin + (xpmax-xpmin)*smin;
Float_t xmax = xpmin + (xpmax-xpmin)*smax;
if (smin <= 0) xmin = xgrmin;
if (smax >= 1) xmax = xgrmax;
f1->SetRange(xmin,xmax);
gr->Fit((char*)fFunction.Data(), (char*)fOption.Data(), (char*)fSame.Data());
fOption = "r";
fFunction = "gaus";
fSame = "";
fRefPad->Modified();
fRefPad->Update();
}
void TFitPanelGraph::SavePrimitive(ostream &, Option_t * )
{
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.