3 // Copyright (C) DIGITEO - Clément DAVID <clement.david@scilab.org>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 // See the file ../license.txt
22 function block=tkscaleblk(block,flag)
25 slider = get(block.uid + "#slider");
28 // calculate real value
29 value = (block.rpar(1) + block.rpar(2) + get(slider,"value")) / block.rpar(3);
33 set(w, "info_message", string(value));
36 block.outptr(1) = value;
41 // if already exists (stopped) then reuse
47 f = figure("Figure_name", "TK Source: " + block.label, ...
48 "dockable", "off", ...
49 "infobar_visible" , "on", ...
50 "toolbar", "none", ...
51 "menubar_visible", "off", ...
52 "menubar", "none", ...
53 "backgroundcolor", [1 1 1], ...
54 "default_axes", "off", ...
55 "figure_size", [180 350], ...
56 "layout", "border", ...
57 "figure_position", [40 40], ...
60 frame_slider = uicontrol(f, ...
62 "constraints", createConstraints("border", "left", [180, 0]), ...
63 "border", createBorder("line", "lightGray", 1), ...
64 "backgroundcolor", [1 1 1], ...
68 bounds = block.rpar(1:2);
69 initial = mean(bounds);
70 uicontrol(frame_slider, ...
71 "Style", "slider", ...
72 "Tag", block.uid + "#slider", ...
76 "Position", [0 0 10 20], ...
77 "SliderStep", [block.rpar(3) 2*block.rpar(3)]);
79 frame_label = uicontrol(frame_slider, ...
81 "constraints", createConstraints("border", "right"), ...
82 "backgroundcolor", [1 1 1], ...
86 labels = string([bounds(2) ; ...
87 mean([bounds(2) initial]) ; ...
89 mean([bounds(1) initial]) ; ...
91 labels = "<html>" + strcat(labels, "<br /><br /><br />") + "</html>";
93 uicontrol(frame_label, ...
95 "String", labels(1), ...
96 "FontWeight", "bold", ...
97 "backgroundcolor", [1 1 1]);
99 // update default value
100 block.outptr(1) = initial / block.rpar(3);
101 elseif flag == 5 then