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 = findobj("Tag", block.label + "#slider");
27 // calculate real value
28 value = (block.rpar(1) + block.rpar(2) - slider.value) / block.rpar(3);
32 w.info_message = string(value);
35 block.outptr(1) = value;
40 // if already exists (stopped) then reuse
41 f = findobj("Tag", block.label);
46 f = figure("Tag", block.label, "Figure_name", "TK Source: " + block.label);
48 // delete standard menus
49 delmenu(f.figure_id, gettext("&File"));
50 delmenu(f.figure_id, gettext("&Tools"));
51 delmenu(f.figure_id, gettext("&Edit"));
52 delmenu(f.figure_id, gettext("&?"));
53 toolbar(f.figure_id, "off");
55 f.position = [0 0 80 200];
58 bounds = block.rpar(1:2);
59 initial = mean(bounds);
60 uicontrol(f, "Style", "slider", "Tag", block.label + "#slider", ..
61 "Min", bounds(1), "Max", bounds(2), "Value", initial, ..
62 "Position", [0 0 20 200], "SliderStep", [block.rpar(3) 2*block.rpar(3)]);
65 labels = string([bounds(2) ;..
66 mean([bounds(2) initial]) ;..
68 mean([bounds(1) initial]) ;..
70 labels = strcat(labels, "<br /><br /><br />");
71 uicontrol(f, "Style", "text", "String", labels(1), ..
72 "Position", [30 0 50 200]);
74 // update default value
75 block.outptr(1) = initial / block.rpar(3);
78 f = findobj("Tag", block.label);