Hi,
I've just started to try and use root, but come across a simple problem
with example.C from the "Writing a Graphical User Interface" tutorial
(file is shown at end of email). The following command sequence
illustrates the problem:
ROOT 5.22/00 (trunk_at_26997, Jan 05 2009, 10:56:00 on win32)
CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }.
root [0] .cd D:\root\fading root [1] .L example.c root [2] example()
root [3] .U example.c root [4] .L example.c root [5] example()
Is it something to do with me closing the example the first time using the normal window closure mechanism? Why does it work after loading the first time, but not the second?
The reason I want to use such a sequence is because I'm editing in gvim
outside of root and so want to unload and reload the file frequently.
(If anyone has any suggestions for a better working methodology, that
would be appreciated).
Thanks
Ashley Mills
// example.C
#include <TGClient.h> #include <TCanvas.h> #include <TF1.h> #include <TRandom.h> #include <TGButton.h> #include <TGFrame.h> #include <TRootEmbeddedCanvas.h> #include <RQ_OBJECT.h>
RQ_OBJECT("MyMainFrame")
private:
TGMainFrame *fMain; TRootEmbeddedCanvas *fEcanvas; public: MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h); virtual ~MyMainFrame(); void DoDraw();
MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) {
// Create a main frame
fMain = new TGMainFrame(p,w,h);
// Create canvas widget
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,200,200);
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX|
kLHintsExpandY,
10,10,10,1));
// Create a horizontal frame widget with buttons
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
TGTextButton *draw = new TGTextButton(hframe,"&Draw");
draw->Connect("Clicked()","MyMainFrame",this,"DoDraw()");
hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
TGTextButton *exit = new TGTextButton(hframe,"&Exit",
"gApplication->Terminate(0)");
hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,5,5,3,4));
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
// Set a name to the main frame
fMain->SetWindowName("Simple Example");
// Map all subwindows of main frame
fMain->MapSubwindows();
// Initialize the layout algorithm
fMain->Resize(fMain->GetDefaultSize());
// Map main frame
fMain->MapWindow();
}
void MyMainFrame::DoDraw() {
// Draws function graphics in randomly choosen interval TF1 *f1 = new TF1("f1","sin(x)/x",0,gRandom->Rndm()*10);
f1->SetFillColor(19); f1->SetFillStyle(1); f1->SetLineWidth(3); f1->Draw();
MyMainFrame::~MyMainFrame() {
// Clean up used widgets: frames, buttons, layouthints
fMain->Cleanup();
delete fMain;
}
void example() {
// Popup the GUI...
new MyMainFrame(gClient->GetRoot(),200,200);
}
<mailto:ashley.mills_at_vodafone.com>
Received on Tue Jun 30 2009 - 14:19:29 CEST
This archive was generated by hypermail 2.2.0 : Mon Oct 12 2009 - 17:50:04 CEST