TGraph in TRootEmbeddedCanvas

Hi,

when I run the following code the update of the TGraph gets slower and slower.

On windows there even occurs finaly an error and the program dies.

#include <TRint.h>
#include <TGFrame.h>
#include <TRootEmbeddedCanvas.h>
#include <TGraph.h>
#include <TCanvas.h>
#include <Riostream.h>

class TestFrame : public TGMainFrame
{
public:
TestFrame():TGMainFrame(0,700,700)
{
int j;

	TRootEmbeddedCanvas *fCanvas = new TRootEmbeddedCanvas("Canvas", this, 800, 400);

	AddFrame(fCanvas,new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 1, 1));

	TGraph *fGraph = new TGraph(1024);

	SetSize(GetDefaultSize());

	while (true) {
		for (j=0 ; j<1024 ; j++) {
			fGraph->SetPoint(j, j,rand());
		}
		fGraph->Draw("AL");
		fCanvas->GetCanvas()->Modified();
		fCanvas->GetCanvas()->Update();
		MapSubwindows();
		MapWindow();
	}
}

};

int main(int argc, char *argv[])
{
TApplication theApp(“TestFrame”, &argc, argv);

TestFrame *frame = new TestFrame();

theApp.Run();

return 0;
}

Matthias

Hi Matthias,

Please try the attached code. (your modified code)

HTH,
Cheers,
Bertrand.
test.cxx (1.56 KB)