I try to paint pads with some primitives on a canvas. The following code really paint the primitives, but menus bar appears only after finishing the execution of a script. Also I can’t open the context menu on primitives and axes (although if I try to change axes range before execution finishing, the changing appears after finishing).
Can I open the context menu and other things before execution finishing?
Also, why if I do “p1->Update” instead of “c->Update()”, p2 painted too?
Summarizing: I want too see on my screen the pad with the primitives when I want, but not after finishing the execution of a script.
The Paint method Paint() of any primitive a not meant to be used by users’. programs except in some special cases. I your case I would suggest you replace:
Indeed I do not really understand why you want to block your macro execution with this getchar(). The following macro works fine for me and you get the attached plot.
void canvas()
{
TCanvas *c;
TPad *p1, *p2;
TList *list;
TF1 *f1, *f2;
int k;
char strb[32];
k = 1;
f1 = new TF1("f1", "[0] * sin(x)", 0, 10);
f1->SetParameter(0, k);
f2 = new TF1("f1", "[0] * cos(x)", 0, 10);
f2->SetParameter(0, k);
sprintf(strb, "%s_%d", "canva", k);
c = new TCanvas(strb, strb);
p1 = new TPad("p1", "p1", 0.01, 0.01, 0.49, 0.99);
p2 = new TPad("p2", "p2", 0.51, 0.01, 0.99, 0.99);
p1->SetNumber(1);
p2->SetNumber(2);
p1->SetFrameFillColor(30);
p2->SetFrameFillColor(29);
p1->Draw();
p2->Draw();
c->cd(1);
f1->DrawCopy();
delete f1;
c->cd(2);
f2->DrawCopy();
delete f2;
list = p1->GetListOfPrimitives();
{
TIter next(list);
TObject *obj;
while ( (obj = next()) ) {
sprintf(strb, "%s", obj->GetName());
printf("primitive name: %s\n", strb);
}
}
}
I have some database with many entries. I don’t want to call the function, that paint single entry, over and over again. So If I will have some mechanism to see an entry not finishing macro, It’s just easier to work for me.