TGraphPolar SetEditable(kFALSE)

Hi everybody,
I have a problem with TGraphPolar when I use SetEditable(kFALSE), automatically it opens a white TCanvas and the graph remains in the TCanvas zone without the diagram (see picture in attachment).
I tried differents codes, and the last was that:

[code]TGraphPolar * grP1 = new TGraphPolar(1000,r1,theta);
TGraphPolar * grP2 = new TGraphPolar(1000,r1,theta2);

grP1->SetLineColor(kRed);
grP1->SetLineWidth(3);
grP2->SetLineColor(kBlue+3);
grP2->SetLineWidth(3);

ec->GetCanvas()->cd(2);
grP1->Draw(“AOL”);
ec->GetCanvas()->Update();
grP1->SetMinRadial(0);

ec->GetCanvas()->cd(4);
grP2->Draw(“AOL”);
ec->GetCanvas()->Update();
grP2->SetMinRadial(0);

ec->GetCanvas()->Update();
ec->GetCanvas()->SetEditable(kFALSE);
ec->GetCanvas()->cd(3)->SetEditable(kTRUE);[/code]

So, help you in advance.




It would be nice if you could send a running macro. ie: with r1,theta,theta2 defined.

Hi couet,
Thanks for your reply in the two posts, so in attachment there is my full macro (that uses a TEmbeddedCanvas). To load, it’s necessary to have in the same folder transfer.dat and g3.dat, and you must have to use ACLiC, so the commands are:

[quote].L HRS.cpp+O
HRS()[/quote]
The Polar problem is in the HRS.cpp line 477.
The multiple TGraph2D problem is in HRS.cpp line 341. I tried Draw(“P same”), but it didn’t work.
Thank you very much for your help.

does not work at all for me:

root [1] .L HRS.cpp++
Info in <TUnixSystem::ACLiC>: creating shared library /home/couet/Desktop/MyProblem/./HRS_cpp.so
In file included from /home/couet/Desktop/MyProblem/./HRS.cpp:1,
                 from /tmp/rootcint_K0T9VV.h:3,
                 from /tmp/aQ7Amn_cint.cxx:1:
/home/couet/Desktop/MyProblem/./HRS.h:7:23: w32pragma.h: No such file or directory
In file included from /tmp/rootcint_K0T9VV.h:3,
                 from /tmp/aQ7Amn_cint.cxx:1:
/home/couet/Desktop/MyProblem/./HRS.cpp:755:2: warning: no newline at end of file
Error: external preprocessing failed. :0:
!!!Removing /home/couet/Desktop/MyProblem/./HRS_cpp_ACLiC_dict.cxx /home/couet/Desktop/MyProblem/./HRS_cpp_ACLiC_dict.h !!!
Error: /home/couet/root/bin/rootcint: error loading headers...
Error in <ACLiC>: Dictionary generation failed!
Info in <ACLiC>: Invoking compiler to check macro's validity
In file included from /home/couet/Desktop/MyProblem/./HRS.cpp:1:
/home/couet/Desktop/MyProblem/./HRS.h:1: warning: ignoring #pragma warning 
/home/couet/Desktop/MyProblem/./HRS.h:2: warning: ignoring #pragma warning 
/home/couet/Desktop/MyProblem/./HRS.h:3: warning: ignoring #pragma warning 
/home/couet/Desktop/MyProblem/./HRS.h:4: warning: ignoring #pragma warning 
/home/couet/Desktop/MyProblem/./HRS.h:5: warning: ignoring #pragma warning 
In file included from /home/couet/Desktop/MyProblem/./HRS.cpp:1:
/home/couet/Desktop/MyProblem/./HRS.h:7:23: w32pragma.h: No such file or directory
/home/couet/Desktop/MyProblem/./HRS.cpp: In constructor `MyMainFrame::MyMainFrame(const TGWindow*, UInt_t, UInt_t)':
/home/couet/Desktop/MyProblem/./HRS.cpp:566: warning: converting to `int' from `double'
/home/couet/Desktop/MyProblem/./HRS.cpp:180: warning: unused variable 'but'
/home/couet/Desktop/MyProblem/./HRS.cpp:755:2: warning: no newline at end of file
root [2] HRS()       
Error: Function HRS() is not defined in current scope  (tmpfile):1:
*** Interpreter error recovered ***
root [3] 

Remove the lines from HRS.h:

[code]#pragma warning (disable: 4248)
#pragma warning (disable: 4005)
#pragma warning (disable: 4244)
#pragma warning (disable: 4482)
#pragma warning (disable: 4101)

#include <w32pragma.h>[/code]

You are working under linux, I’m working under windows. :slight_smile:

note you have 2 warnings. before going further I fixed them.

/home/couet/Desktop/MyProblem/./HRS.cpp:566: warning: converting to `int' from `double'
/home/couet/Desktop/MyProblem/./HRS.cpp:180: warning: unused variable 'but'

Ok I see the big window subdivided in 5 parts and an extra white canvas shows up also. What is wrong with that ?

in line 478 of HRS.cpp I set ec->GetCanvas()->SetEditable(kFALSE) and automatically, I don’t understand why, there is 2 white canvas and the Polars graphs don’t have the axis.
I only would like to set my embeddedcanvas -> SetEditable (kFALSE) and have all elements showed correctly as a photo.

Ok I see what you mean. I have no idea yet why SetEditable(kFALSE) does that. I need to debug. Meanwhile I would recommend you to not use it… Is it important for you to have SetEditable(kFALSE) ? seems to me you can leave it that way. Anyway I will check.

I see the problem with a simple macro also. I do not need your example to check it. That will make it easier to debug.

I think I found what the problem is. In two places in TGraphPolargram.cxx there is the line:

   if (!gPad->IsEditable()) gROOT->MakeDefCanvas();

These two lines make no sense to me. If I remove them it is fine. But before removing them I need first to understand why they have been put there. I will let you know

Great, thank you for your help, and for your patience.
I have only another question:

  • Is it possible to eliminate the TEmbeddedCavas menu strip, in other words, don’t show anything when I click it with the right mouse button?
    Looking forward your answer.

you mean the context menu ? I do not think it has something to do with the embedded canvas. It is for any canvas. If it is what you mean I do not think it is possible … At least I do not know it right away. I will have to check on Monday.

Hi couet,
I removed the line if (!gPad->IsEditable()) gROOT->MakeDefCanvas(); from TGraphPolargram.cxx (them I recompiled root), but the problem persists. Is there somenthing else to do?

This line is in two places. I will investigate closely today. Why it was put there and fix it.

This is fixed now in the SVN trunk.

Great, thank you very much! Now it’s perfect!

There is no simple way to do that.