How To Update TEmbedded Canvas

Hi,

I am writing a GUI that utilizes a TEmbeddedCanvas in a TGMainFrame object. When I create and draw my graph to the TEmbeddedCanvas, it is not displayed. However, when I resize the window (by dragging the sizing controls), the window is updated and I see the graph. How do I force the display of the graph in the TEmbeddedCanvas automatically. I tried DoRedraw and that didn’t seem to have any effect.

Thanks in advance.

Jon

Hi Jon,

What you need is to update the canvas. Please find below an example where fEcan is the embedded canvas pointer.

Best regards, Ilka

TCanvas *c1 = fEcan->GetCanvas(); // fEcan is the embedded canvas pointer
c1->SetFillColor(42);
c1->SetGrid();

const Int_t n = 20;
Double_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i0.1;
y[i] = 10
sin(x[i]+0.2);
printf(" i %i %f %f \n",i,x[i],y[i]);
}
gr = new TGraph(n,x,y);
gr->SetLineColor(2);
gr->SetLineWidth(4);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->SetTitle(“a simple graph”);
gr->GetXaxis()->SetTitle(“X title”);
gr->GetYaxis()->SetTitle(“Y title”);
gr->Draw(“ACP”);

// TCanvas::Update() draws the frame, after which it can be changed
c1->Update();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
c1->Modified();
c1->Update();

Thanks. This helped and worked. I am wondering whether you know whether using QT provides any enhancements to creating GUIs that is not available in ROOT itself?

Thanks.

[quote=“jon149”]Thanks. This helped and worked. I am wondering whether you know whether using QT provides any enhancements to creating GUIs that is not available in ROOT itself?

Thanks.[/quote]

Yes, my believe Qt does provide a lot of enhancements and what is essential it rather stable and robust environment

The main advantage of working with Qt is the time saving:

  1. Qt-based GUI code is generally much shorter hence less time to write, less chances to make a mistake
  2. Qt provides a lot of ready-to-use Widget. Some of them are included in the distribution others can be downloaded form the various Web sites.
    If you are going to work on Linux then you can enjoy the KDE environment that comes with hundreds of well designed and thoroughly debugged widgets.
    kde.org/
    kde-redhat.sourceforge.net/
    kde.org/whatiskde/qt.php
    see examples
    kde-apps.org/
  3. You can use Qt Designer (or KDesinger kdevelop.org/graphics/screen … signer.png in case of the KDE env) as result the most complex part of the code will be written for automatically and you can devote your time to polish your concrete algorithm you are create the GUI for.

As result as soon as you have a clear idea how your GUI should look and behave like you can create an working inter4face in a day.
To prove that I am willing to create one for you. If you havegot a clear idea about your GUI and can describe this idea the can have created a Qt project and generate the working version of GUI. So you will have something you can start to work with.

You can find the further information on root.bnl.gov Web site

Look for
root.bnl.gov/QtRoot/QtRoot.html#features
root.bnl.gov/QtRoot/QtRoot.html#designer
root.bnl.gov/QtRoot/QtRoot.html#publications

I would advice to download and install the Windows version of ROOT with Qt layer.
root.bnl.gov/QtRoot/downloads/root.4.00.08.exe
It should take you about 5 min to download and play with the several examples that distribution contains.
(for example root.bnl.gov/QtRoot/GeomBrowserMain.png )

Don’t hesitate asking me any further information you may have got.

The Web page
www4.rcf.bnl.gov/~fine/EventDisplay/
contains another example of the complex Qt-based application.

Hope this help

Feell free to send me the questions you may have directly roottalk@root.cern.ch

I did highlihg some additions those ROOT with Qt layer has benefit just because of the Qt layer involved.

Hi,

Thanks for your very informative response. I am trying to understand the best solution. What is the difference between KDE and Qt? Are they based on the same engine. I am hoping to develop a solution that will run under Linux as well as MacOS 10.x. I understand that Qt is available for boh platforms. However, is KDE only Linux specific? Is there any way that I can take advantage of the Aqua interface under MacOs?

By the way, i have really started to get into the intrinsics of Root and am very impressed with the framework you have developed. It is absolutely fantastic.

Thanks.

Best Regards,

Jon