Hi Rogger,
I think you need something like this
( Let me know whether I should elaborate further )
class MyFitButton : public TGTextButton { private:
TGraph *fGraph; TF1 *fF1;
public:
MyFitButton( <repeat here TGButton class signature> )
: TGTextButton ( . . . ) , fGraph(0), fF1(0) {}
void SetGraph(TGraph *g) { fGraph = g;} void SetFun1(TF1 *f) { fF1 = f;}
TGraph *Graph() const {return fGraph;}
TF1 *Fun1() const { return fF1;}
};
class MyMainFrame {
private:
MyFitButton *fFitButton;
...
public:
void Fit(TGraph*, TF1*);
...
}
MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { ...
fFitButton = new MyFitButton(fHframe2, "&Fit");
fFitButton->SetGraph(myGraph); fFitButton->SetGraph(myFun1); fFitButton->Connect("Clicked()","MyMainFrame",this,"Fit()");fHframe2->AddFrame(fit, fLbutton);
void MyMainFrame::Fit()
{
// Since you use the TGraph object *name* // you do not need any retrieving of TF1 object. // The proper object is to be found by name with Fit method alone // TF1 all = *fFitButton->Fun1();
Best Regards
Valeri Fine
> -----Original Message----- > From: Roger Mason [mailto:rmason_at_esd.mun.ca] > Sent: Thursday, January 25, 2007 4:20 PM > To: Fine, Valeri > Cc: roottalk_at_pcroot.cern.ch > Subject: Re: [ROOT] connecting signals & slots > > Hi Valeri, > > "Fine, Valeri" <fine_at_bnl.gov> writes: > > > That has a few states like "pressed" "clicked" etc, all of those canbe
> > reported via Signal / Slot mechanism. > > It is the "Clicked" state for which I need a response. > > > I would like to call your attention the only thing *you* want toknow
> > > The user can do only TWO things with the GUI component like button. > > He/she either press it or release it. That's all and this *is*signaled.
> > all information it needs. There is no need to pass all parameters > > through the signal / slot. > > OK, that parameter passing is what I have been trying to do. > > > The only thing you should pass via this > > channel is the flag that is to notify you about the user intentionand
> > whether the information is ready to be fetched. > > So, I need to define a (global?) flag and, when (in this case) the > starting parameters for my fit are entered, set it to "True" then test > for "True" in the slot? > > > Yes, the code should "know" where the information should be > > "phishing". Have you problem with the "phishing"? > > Yes. > > > Do you want to > > pass the object pointer? > > Well, I need some way for the TF1 and the TGraph to which it is to be > fitted to be dispatched to the slot (I think). > > > You can send such pointer from the signal > > to the slot too. The later is simple and it should be sufficient. > > > > Well, that is what have been trying to do: > > class MyMainFrame { > ... > public: > void Fit(TGraph*, TF1*); > ... > } > > MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { > ... > fit = new TGTextButton(fHframe2, "&Fit"); > fit->Connect("Clicked()","MyMainFrame",this,"Fit(TGraph&, TF1&)"); > fHframe2->AddFrame(fit, fLbutton); > ... > } > > void MyMainFrame::Fit(TGraph *graph, TF1 *thefit){ > TF1 all = *thefit; > graph->Fit("all"); > } > > When I compile, with ACLiC, compilation works but this error results: > > Error in <TQObject::CheckConnectArgs>: slot > MyMainFrame::Fit(TGraph&,TF1&) does not exist > > I assume this is because the signature for Fit() does'nt correspond to > that in the Connect() method. The present bodge is just one of > several I have tried. > > Thanks for your help. > > RogerReceived on Thu Jan 25 2007 - 23:40:35 CET
This archive was generated by hypermail 2.2.0 : Fri Jan 26 2007 - 23:50:00 CET