[Scilab-users] Callback in checkbox for multiple figures
Izabela Wójcik-Grząba
iwoj at il.pw.edu.pl
Thu Apr 19 16:16:42 CEST 2018
Thank you for your reply. I am not sure why, but your solution doesn't
work in my example. Maybe it's because the plot and the checkbox are in
different frames?
Here is my example code (which is a part of my whole programme):
// Definition of figure
f=figure("dockable","off","infobar_visible","off","toolbar_visible","off",..
"toolbar","none","menubar_visible","on","default_axes",..
"off","layout","border","figure_size",[900,750],"background",-2);
// Definition of left frame with the controler of visibility
r_lewa=uicontrol(f,"style","frame","constraints",createConstraints("border",..
"left",[200,0]),"border",createBorder("titled",..
createBorder("line","lightGray",1),("Kontrola rysunku"),..
"center","top"),"backgroundcolor",[1 1 1],"layout_options",..
createLayoutOptions("grid",[2,1]),"layout","grid");
// Definition of right frame with plot
r_prawa=uicontrol(f,"style","frame","constraints",createConstraints("border",..
"center"),"backgroundcolor",[1 1 1]);
newaxes(r_prawa);
drawlater;
// Drawing a plot
x_fix=[1 2 3];y_fix=[2 3 1];z_fix=[1 2 1];
param3d1(x_fix,y_fix,z_fix);
h1=gce();
h1.line_mode="off";
h1.mark_mode="on";
h1.mark_style=9;
h1.mark_foreground=5;
h1.mark_background=5;
// Numbering of points
xstring(x_fix,y_fix,string([1:3]));
num_w=gca().children(1).children;
for i=1:3
num_w(4-i).data(3)=z_fix(i);
num_w(i).font_size=3;
end
// Settings of the plot
a=gca();
a.data_bounds=[min(x_fix)-1,min(y_fix)-1,min(z_fix)-1;max(x_fix)+1,max(y_fix)+1,max(z_fix)+1];
a.box="back_half";
a.isoview="on";
a.hidden_axis_color=12;
a.rotation_angles=[-110,245];
title("Siatka ciegnowa w rownowadze","fontsize",4);
// Creating a frame inside the left frame for the controller of
visibility
przel=uicontrol(r_lewa,"style","frame","constraints",..
createConstraints("gridbag",[1 1 1 1],[0,0],"both","upper"),"border",..
createBorder("titled",createBorder("line","lightGray",1),..
("Widocznosc"),"center","top"),"backgroundcolor",[1 1 1],..
"layout_options",createLayoutOptions("grid",[1,1]),"layout","grid");
// Definition of checkbox which turns on/off the visibility of point
numbers
box_num_w=uicontrol(przel,"style","checkbox","backgroundcolor",..
[1 1 1],"value",1,"string","Numery wezlow","callback","cbfun");
// Callback function definition
function cbfun()
h=gcbo();
ax=h.parent.children(1).children(1);
ax.children(1).visible=h.value;
endfunction
W dniu 19.04.2018 14:35, Stéphane Mottelet napisał(a):
> Hello Iza,
>
> If your uicontrol and your Axes are children of the same Figure, you
> can recover the Axes relatively, like in this small example:
>
> function cbfun()
> h=gcbo();
> ax=h.parent.children(2);
> ax.children(1).visible=h.value;
> endfunction
>
> scf(0)
> clf
> uicontrol("style","checkbox","backgroundcolor",..
> [1 1 1],"value",1,"callback","cbfun");
> t=linspace(0,2*%pi,100);
> plot(t,sin(t))
> plot(t,cos(t))
>
> scf(1)
> clf
> uicontrol("style","checkbox","backgroundcolor",..
> [1 1 1],"value",1,"callback","cbfun");
> t=linspace(0,2*%pi,100);
> plot(t,sin(t))
> plot(t,cos(t))
> S.
>
> Le 19/04/2018 à 13:28, Izabela Wójcik-Grząba a écrit :
>
>> Hello,
>>
>> In my programme in Scilab I create a figure with one plot and a
>> checkbox which turns on/off the visibility of some parts of the
>> plot. The callback function of checkbox works fine when there is
>> only one figure, but when there are, for example, two figures the
>> callback works on the current figure not the one I want to change
>> (because I use gca). Here is the part with definition of the
>> checkbox and callback function:
>>
>> box_num_w=uicontrol(przel,"style","checkbox","backgroundcolor",..
>> [1 1 1],"value",1,"string","Numery
>> węzłów","callback","niewidoczne_num_w");
>>
>> function niewidoczne_num_w()
>> a=gca;
>> if get(gcbo,"value")==0 then
>> value=get(gcbo,"value")
>> a.children(7).visible="off";
>> else
>> a.children(7).visible="on";
>> end
>> endfunction
>>
>> I was trying to change the definition of a by using gcbo but none of
>> my versions works.
>> I would appreciate any help.
>>
>> Kind regards,
>> Iza
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>>
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users
>
> --
> Stéphane Mottelet
> Ingénieur de recherche
> EA 4297 Transformations Intégrées de la Matière Renouvelable
> Département Génie des Procédés Industriels
> Sorbonne Universités - Université de Technologie de Compiègne
> CS 60319, 60203 Compiègne cedex
> Tel : +33(0)344234688
> http://www.utc.fr/~mottelet
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
More information about the users
mailing list