From 30809d41b8499bcb12d1245f1b34ec25eb8de2dc Mon Sep 17 00:00:00 2001 From: "N.N." Date: Tue, 30 Mar 2004 04:11:42 +0000 Subject: grid 0.5 svn path=/trunk/externals/unauthorized/; revision=1514 --- grid/CHANGES.LOG | 2 + grid/Makefile | 2 +- grid/grid.c | 28 +++----- grid/grid.tk2c | 164 ++++++++++++++++++++++++++++++++++++++++++++ grid/help-grid.pd | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ grid/tk2c.bash | 24 +++++++ 6 files changed, 399 insertions(+), 19 deletions(-) create mode 100644 grid/grid.tk2c create mode 100644 grid/help-grid.pd create mode 100755 grid/tk2c.bash diff --git a/grid/CHANGES.LOG b/grid/CHANGES.LOG index c4d8211..339b742 100644 --- a/grid/CHANGES.LOG +++ b/grid/CHANGES.LOG @@ -1,3 +1,5 @@ +0.5 + Adapted for pd 0.37 0.4 Added functions bang, values, valuemotion, xvalues, xvaluemotion made by Maurizio Umberto Puxeddu Integrated patch from Joseph A. Sarlo for connections diff --git a/grid/Makefile b/grid/Makefile index 115dcc6..7412ac0 100644 --- a/grid/Makefile +++ b/grid/Makefile @@ -67,7 +67,7 @@ LINUXCFLAGS = -DPD -DUNIX -DICECAST -O2 -funroll-loops -fomit-frame-pointer \ LINUXINCLUDE = -I../../src .c.pd_linux: - ../tk2c.bash < $*.tk > $*.tk2c + ./tk2c.bash < $*.tk > $*.tk2c cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm strip --strip-unneeded $*.pd_linux diff --git a/grid/grid.c b/grid/grid.c index 2b3149b..e982027 100644 --- a/grid/grid.c +++ b/grid/grid.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include "m_pd.h" #include "m_imp.h" #include "g_canvas.h" #include "t_tk.h" @@ -35,7 +35,7 @@ static int gridcount=0; static int guidebug=0; static int pointsize = 5; -static char *grid_version = "grid: version 0.4, written by Yves Degoyon (ydegoyon@free.fr)"; +static char *grid_version = "grid: version 0.5, written by Yves Degoyon (ydegoyon@free.fr)"; #define GRID_SYS_VGUI2(a,b) if (guidebug) \ post(a,b);\ @@ -94,12 +94,7 @@ static void grid_draw_new(t_grid *x, t_glist *glist) t_canvas *canvas=glist_getcanvas(glist); char *tagRoot; -/* rtext_new(); in g_canvas.h changed in 0.37 */ -#if PD_MINOR_VERSION >= 37 - rtext_new(glist, (t_text *)x); -#else - rtext_new(glist, (t_text *)x, glist->gl_editor->e_rtext, 0); -#endif + rtext_new(glist, (t_text *)x ); tagRoot = rtext_gettag(glist_findrtext(glist,(t_text *)x)); GRID_SYS_VGUI7(".x%x.c create rectangle %d %d %d %d -fill #124392 -tags %xGRID\n", canvas, x->x_obj.te_xpix, x->x_obj.te_ypix, @@ -669,18 +664,15 @@ void grid_setup(void) grid_widgetbehavior.w_deletefn = grid_delete; grid_widgetbehavior.w_visfn = grid_vis; grid_widgetbehavior.w_clickfn = grid_click; - /* - * : As of 0.37, pd does not have these last - * two elements in t_widgetbehavoir anymore. - * see pd/src/notes.txt: - * savefunction and dialog into class structure - */ -#if PD_MINOR_VERSION < 37 || !defined(PD_MINOR_VERSION) + +#if PD_MINOR_VERSION >= 37 + class_setpropertiesfn(grid_class, grid_properties); + class_setsavefn(grid_class, grid_save); +#else grid_widgetbehavior.w_propertiesfn = grid_properties; grid_widgetbehavior.w_savefn = grid_save; -#else - class_setsavefn(grid_class, &grid_save); - class_setpropertiesfn(grid_class, &grid_properties); #endif + class_setwidget(grid_class, &grid_widgetbehavior); + class_sethelpsymbol(grid_class, gensym("grid.pd")); } diff --git a/grid/grid.tk2c b/grid/grid.tk2c new file mode 100644 index 0000000..3e8f18f --- /dev/null +++ b/grid/grid.tk2c @@ -0,0 +1,164 @@ +// ########### grid procedures -- ydegoyon@free.fr ######### +sys_gui("proc grid_apply {id} {\n"); +// strip "." from the TK id to make a variable name suffix +sys_gui("set vid [string trimleft $id .]\n"); +// for each variable, make a local variable to hold its name... +sys_gui("set var_graph_name [concat graph_name_$vid]\n"); +sys_gui("global $var_graph_name\n"); +sys_gui("set var_graph_width [concat graph_width_$vid]\n"); +sys_gui("global $var_graph_width\n"); +sys_gui("set var_graph_xmin [concat graph_xmin_$vid]\n"); +sys_gui("global $var_graph_xmin\n"); +sys_gui("set var_graph_xmax [concat graph_xmax_$vid]\n"); +sys_gui("global $var_graph_xmax\n"); +sys_gui("set var_graph_height [concat graph_height_$vid]\n"); +sys_gui("global $var_graph_height\n"); +sys_gui("set var_graph_ymin [concat graph_ymin_$vid]\n"); +sys_gui("global $var_graph_ymin\n"); +sys_gui("set var_graph_ymax [concat graph_ymax_$vid]\n"); +sys_gui("global $var_graph_ymax\n"); +sys_gui("set var_graph_grid [concat graph_grid_$vid]\n"); +sys_gui("global $var_graph_grid\n"); +sys_gui("set var_graph_xstep [concat graph_xstep_$vid]\n"); +sys_gui("global $var_graph_xstep\n"); +sys_gui("set var_graph_ystep [concat graph_ystep_$vid]\n"); +sys_gui("global $var_graph_ystep\n"); +sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); +sys_gui("global $var_graph_xlines\n"); +sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); +sys_gui("global $var_graph_ylines\n"); +sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_name] [eval concat $$var_graph_width] [eval concat $$var_graph_xmin] [eval concat $$var_graph_xmax] [eval concat $$var_graph_height] [eval concat $$var_graph_ymin] [eval concat $$var_graph_ymax] [eval concat $$var_graph_grid] [eval concat $$var_graph_xstep] [eval concat $$var_graph_ystep] [eval concat $$var_graph_xlines] [eval concat $$var_graph_ylines] \\;]\n"); +// puts stderr $cmd +sys_gui("pd $cmd\n"); +sys_gui("}\n"); +sys_gui("proc grid_cancel {id} {\n"); +sys_gui("set cmd [concat $id cancel \\;]\n"); +// puts stderr $cmd +sys_gui("pd $cmd\n"); +sys_gui("}\n"); +sys_gui("proc grid_ok {id} {\n"); +sys_gui("grid_apply $id\n"); +sys_gui("grid_cancel $id\n"); +sys_gui("}\n"); +sys_gui("proc pdtk_grid_dialog {id name width xmin xmax height ymin ymax grid xstep ystep xlines ylines} {\n"); +sys_gui("set vid [string trimleft $id .]\n"); +sys_gui("set var_graph_name [concat graph_name_$vid]\n"); +sys_gui("global $var_graph_name\n"); +sys_gui("set var_graph_width [concat graph_width_$vid]\n"); +sys_gui("global $var_graph_width\n"); +sys_gui("set var_graph_xmin [concat graph_xmin_$vid]\n"); +sys_gui("global $var_graph_xmin\n"); +sys_gui("set var_graph_xmax [concat graph_xmax_$vid]\n"); +sys_gui("global $var_graph_xmax\n"); +sys_gui("set var_graph_height [concat graph_height_$vid]\n"); +sys_gui("global $var_graph_height\n"); +sys_gui("set var_graph_ymin [concat graph_ymin_$vid]\n"); +sys_gui("global $var_graph_ymin\n"); +sys_gui("set var_graph_ymax [concat graph_ymax_$vid]\n"); +sys_gui("global $var_graph_ymax\n"); +sys_gui("set var_graph_grid [concat graph_grid_$vid]\n"); +sys_gui("global $var_graph_grid\n"); +sys_gui("set var_graph_xstep [concat graph_xstep_$vid]\n"); +sys_gui("global $var_graph_xstep\n"); +sys_gui("set var_graph_ystep [concat graph_ystep_$vid]\n"); +sys_gui("global $var_graph_ystep\n"); +sys_gui("set var_graph_xlines [concat graph_xlines_$vid]\n"); +sys_gui("global $var_graph_xlines\n"); +sys_gui("set var_graph_ylines [concat graph_ylines_$vid]\n"); +sys_gui("global $var_graph_ylines\n"); +sys_gui("set $var_graph_name $name\n"); +sys_gui("set $var_graph_width $width\n"); +sys_gui("set $var_graph_xmin $xmin\n"); +sys_gui("set $var_graph_xmax $xmax\n"); +sys_gui("set $var_graph_height $height\n"); +sys_gui("set $var_graph_ymin $ymin\n"); +sys_gui("set $var_graph_ymax $ymax\n"); +sys_gui("set $var_graph_grid $grid\n"); +sys_gui("set $var_graph_xstep $xstep\n"); +sys_gui("set $var_graph_ystep $ystep\n"); +sys_gui("set $var_graph_xlines $xlines\n"); +sys_gui("set $var_graph_ylines $ylines\n"); +sys_gui("toplevel $id\n"); +sys_gui("wm title $id {grid}\n"); +sys_gui("wm protocol $id WM_DELETE_WINDOW [concat grid_cancel $id]\n"); +sys_gui("label $id.label -text {GRID PROPERTIES}\n"); +sys_gui("pack $id.label -side top\n"); +sys_gui("frame $id.buttonframe\n"); +sys_gui("pack $id.buttonframe -side bottom -fill x -pady 2m\n"); +sys_gui("button $id.buttonframe.cancel -text {Cancel} -command \"grid_cancel $id\"\n"); +sys_gui("button $id.buttonframe.apply -text {Apply} -command \"grid_apply $id\"\n"); +sys_gui("button $id.buttonframe.ok -text {OK} -command \"grid_ok $id\"\n"); +sys_gui("pack $id.buttonframe.cancel -side left -expand 1\n"); +sys_gui("pack $id.buttonframe.apply -side left -expand 1\n"); +sys_gui("pack $id.buttonframe.ok -side left -expand 1\n"); +sys_gui("frame $id.1rangef\n"); +sys_gui("pack $id.1rangef -side top\n"); +sys_gui("label $id.1rangef.lname -text \"Name :\"\n"); +sys_gui("entry $id.1rangef.name -textvariable $var_graph_name -width 7\n"); +sys_gui("pack $id.1rangef.lname $id.1rangef.name -side left\n"); +sys_gui("frame $id.2rangef\n"); +sys_gui("pack $id.2rangef -side top\n"); +sys_gui("label $id.2rangef.lwidth -text \"Width :\"\n"); +sys_gui("entry $id.2rangef.width -textvariable $var_graph_width -width 7\n"); +sys_gui("pack $id.2rangef.lwidth $id.2rangef.width -side left\n"); +sys_gui("frame $id.3rangef\n"); +sys_gui("pack $id.3rangef -side top\n"); +sys_gui("label $id.3rangef.lxmin -text \"X min :\"\n"); +sys_gui("entry $id.3rangef.xmin -textvariable $var_graph_xmin -width 7\n"); +sys_gui("pack $id.3rangef.lxmin $id.3rangef.xmin -side left\n"); +sys_gui("frame $id.4rangef\n"); +sys_gui("pack $id.4rangef -side top\n"); +sys_gui("label $id.4rangef.lxmax -text \"X max :\"\n"); +sys_gui("entry $id.4rangef.xmax -textvariable $var_graph_xmax -width 7\n"); +sys_gui("pack $id.4rangef.lxmax $id.4rangef.xmax -side left\n"); +sys_gui("frame $id.41rangef\n"); +sys_gui("pack $id.41rangef -side top\n"); +sys_gui("label $id.41rangef.lxstep -text \"X step :\"\n"); +sys_gui("entry $id.41rangef.xstep -textvariable $var_graph_xstep -width 7\n"); +sys_gui("pack $id.41rangef.lxstep $id.41rangef.xstep -side left\n"); +sys_gui("frame $id.42rangef\n"); +sys_gui("pack $id.42rangef -side top\n"); +sys_gui("label $id.42rangef.lxlines -text \"X sections :\"\n"); +sys_gui("entry $id.42rangef.xlines -textvariable $var_graph_xlines -width 7\n"); +sys_gui("pack $id.42rangef.lxlines $id.42rangef.xlines -side left\n"); +sys_gui("frame $id.5rangef\n"); +sys_gui("pack $id.5rangef -side top\n"); +sys_gui("label $id.5rangef.lheight -text \"Height :\"\n"); +sys_gui("entry $id.5rangef.height -textvariable $var_graph_height -width 7\n"); +sys_gui("pack $id.5rangef.lheight $id.5rangef.height -side left\n"); +sys_gui("frame $id.6rangef\n"); +sys_gui("pack $id.6rangef -side top\n"); +sys_gui("label $id.6rangef.lymin -text \"Y min :\"\n"); +sys_gui("entry $id.6rangef.ymin -textvariable $var_graph_ymin -width 7\n"); +sys_gui("pack $id.6rangef.lymin $id.6rangef.ymin -side left\n"); +sys_gui("frame $id.7rangef\n"); +sys_gui("pack $id.7rangef -side top\n"); +sys_gui("label $id.7rangef.lymax -text \"Y max :\"\n"); +sys_gui("entry $id.7rangef.ymax -textvariable $var_graph_ymax -width 7\n"); +sys_gui("pack $id.7rangef.lymax $id.7rangef.ymax -side left\n"); +sys_gui("frame $id.71rangef\n"); +sys_gui("pack $id.71rangef -side top\n"); +sys_gui("label $id.71rangef.lystep -text \"Y step :\"\n"); +sys_gui("entry $id.71rangef.ystep -textvariable $var_graph_ystep -width 7\n"); +sys_gui("pack $id.71rangef.lystep $id.71rangef.ystep -side left\n"); +sys_gui("frame $id.72rangef\n"); +sys_gui("pack $id.72rangef -side top\n"); +sys_gui("label $id.72rangef.lylines -text \"Y sections :\"\n"); +sys_gui("entry $id.72rangef.ylines -textvariable $var_graph_ylines -width 7\n"); +sys_gui("pack $id.72rangef.lylines $id.72rangef.ylines -side left\n"); +sys_gui("checkbutton $id.showgrid -text {Show Grid} -variable $var_graph_grid -anchor w\n"); +sys_gui("pack $id.showgrid -side top\n"); +sys_gui("bind $id.1rangef.name [concat grid_ok $id]\n"); +sys_gui("bind $id.2rangef.width [concat grid_ok $id]\n"); +sys_gui("bind $id.3rangef.xmin [concat grid_ok $id]\n"); +sys_gui("bind $id.4rangef.xmax [concat grid_ok $id]\n"); +sys_gui("bind $id.41rangef.xstep [concat grid_ok $id]\n"); +sys_gui("bind $id.42rangef.xlines [concat grid_ok $id]\n"); +sys_gui("bind $id.5rangef.height [concat grid_ok $id]\n"); +sys_gui("bind $id.6rangef.ymin [concat grid_ok $id]\n"); +sys_gui("bind $id.7rangef.ymax [concat grid_ok $id]\n"); +sys_gui("bind $id.71rangef.ystep [concat grid_ok $id]\n"); +sys_gui("bind $id.72rangef.ylines [concat grid_ok $id]\n"); +sys_gui("focus $id.1rangef.name\n"); +sys_gui("}\n"); +// ########### grid procedures END -- ydegoyon@free.fr ######### diff --git a/grid/help-grid.pd b/grid/help-grid.pd new file mode 100644 index 0000000..b31c29e --- /dev/null +++ b/grid/help-grid.pd @@ -0,0 +1,198 @@ +#N canvas 26 1 763 647 10; +#X obj 71 76 grid grid1 200 0 199 200 0 199 1 1 1 10 10 188 197; +#X floatatom 72 293 5 0 0; +#X floatatom 257 282 5 0 0; +#X text 41 21 Grid is a 2-dimensional control object; +#X text 319 449 (invoke with Properties ); +#X text 322 439 You can set the following properties :; +#X text 347 468 * Name; +#X text 346 480 * Width : graphical x size; +#X text 346 491 * X min : minimum value delivered by left outlet ( +X ); +#X text 346 503 * X max : maximum value delivered by left outlet ( +X ); +#X text 347 513 * X step : X delta for an X update; +#X text 346 524 * X sections : number of vertical lines of the inner +grid; +#X text 347 534 * Height : graphical y size; +#X text 346 546 * Y min : minimum value delivered by right outlet ( +Y ); +#X text 347 558 * Y max : maximum value delivered by right outlet ( +Y ); +#X text 346 579 * Y sections : number of horizontal lines of the inner +grid; +#X text 347 591 * Show Grid : option to draw an inner grid; +#X text 328 609 bugs and comments @ ydegoyon@free.fr; +#X text 120 292 X value; +#X text 303 281 Y value; +#X msg 587 271 \; pd dsp 0; +#X msg 653 271 \; pd dsp 1; +#X obj 276 417 *~; +#X floatatom 276 360 0 0 0; +#X obj 357 397 line~; +#X floatatom 188 380 0 0 0; +#X obj 188 494 cos~; +#X obj 188 450 +~; +#X floatatom 228 506 0 0 100; +#N canvas 159 26 495 270 output 0; +#X obj 338 160 t b; +#X obj 338 110 f; +#X obj 338 60 inlet; +#X text 344 29 mute; +#X obj 338 185 f; +#X msg 425 178 0; +#X msg 338 85 bang; +#X obj 338 135 moses 1; +#X obj 425 153 t b f; +#X obj 397 117 moses 1; +#X obj 83 148 dbtorms; +#X obj 397 92 r master-lvl; +#X obj 83 42 r master-lvl; +#X obj 338 210 s master-lvl; +#X obj 22 182 inlet~; +#X obj 199 41 inlet; +#X text 199 18 level; +#X obj 199 100 s master-lvl; +#X msg 96 65 set \$1; +#X obj 96 89 outlet; +#X msg 214 64 \; pd dsp 1; +#X obj 83 194 line~; +#X obj 22 212 *~; +#X obj 22 241 dac~; +#X obj 83 171 pack 0 50; +#X text 20 159 audio; +#X text 93 110 show level; +#X connect 0 0 4 0; +#X connect 1 0 7 0; +#X connect 2 0 6 0; +#X connect 4 0 13 0; +#X connect 5 0 13 0; +#X connect 6 0 1 0; +#X connect 7 0 0 0; +#X connect 7 1 8 0; +#X connect 8 0 5 0; +#X connect 9 1 4 1; +#X connect 10 0 24 0; +#X connect 11 0 1 1; +#X connect 11 0 9 0; +#X connect 12 0 10 0; +#X connect 12 0 18 0; +#X connect 14 0 22 0; +#X connect 15 0 17 0; +#X connect 15 0 20 0; +#X connect 18 0 19 0; +#X connect 21 0 22 1; +#X connect 22 0 23 0; +#X connect 22 0 23 1; +#X connect 24 0 21 0; +#X restore 190 533 pd output; +#X msg 266 506 MUTE; +#X obj 276 385 osc~ 0; +#X obj 357 371 pack 0 50; +#X floatatom 357 318 0 0 0; +#X obj 357 345 / 100; +#X text 188 345 carrier; +#X text 184 355 frequency; +#X text 261 336 frequency; +#X text 262 319 modulation; +#X obj 188 407 phasor~; +#X msg 39 350 250; +#X obj 39 328 loadbang; +#X text 17 377 3-dimensional control; +#X text 16 389 would be nice :-); +#X text 393 310 modulation index; +#X text 393 325 in hundredths; +#X text 40 32 It was inspired by the chaospad device; +#X text 346 568 * Y step : Y delta for an Y update; +#X floatatom 474 85 5 0 0; +#X floatatom 586 84 5 0 0; +#X obj 411 82 pack f f; +#X msg 332 81 goto \$1 \$2; +#X msg 546 83 bang; +#X text 524 84 X; +#X text 333 63 Set position :; +#X text 631 85 Y; +#X floatatom 486 120 5 0 0; +#X floatatom 586 121 5 0 0; +#X obj 423 119 pack f f; +#X msg 546 120 bang; +#X text 530 120 X; +#X text 634 121 Y; +#X floatatom 528 156 5 0 0; +#X floatatom 633 156 5 0 0; +#X obj 465 153 pack f f; +#X msg 593 154 bang; +#X text 578 155 X; +#X text 679 156 Y; +#X floatatom 503 191 5 0 0; +#X floatatom 607 190 5 0 0; +#X obj 440 188 pack f f; +#X msg 568 189 bang; +#X text 553 190 X; +#X text 656 191 Y; +#X floatatom 539 224 5 0 0; +#X floatatom 638 226 5 0 0; +#X obj 472 223 pack f f; +#X msg 600 224 bang; +#X text 585 225 X; +#X text 685 225 Y; +#X msg 109 49 bang; +#X msg 332 118 values \$1 \$2; +#X text 333 100 Set values :; +#X text 331 135 Set deltas for values :; +#X msg 333 152 valuemotion \$1 \$2; +#X msg 333 187 xvalues \$1 \$2; +#X text 334 170 Set values without changing output :; +#X text 332 205 Set deltas for values without changing output:; +#X msg 334 223 xvaluemotion \$1 \$2; +#X connect 0 0 1 0; +#X connect 0 1 2 0; +#X connect 1 0 23 0; +#X connect 2 0 33 0; +#X connect 22 0 27 1; +#X connect 23 0 31 0; +#X connect 24 0 22 1; +#X connect 25 0 39 0; +#X connect 26 0 29 0; +#X connect 27 0 26 0; +#X connect 28 0 29 1; +#X connect 29 0 28 0; +#X connect 30 0 29 2; +#X connect 31 0 22 0; +#X connect 32 0 24 0; +#X connect 33 0 34 0; +#X connect 34 0 32 0; +#X connect 39 0 27 0; +#X connect 40 0 25 0; +#X connect 41 0 40 0; +#X connect 48 0 50 0; +#X connect 49 0 50 1; +#X connect 49 0 52 0; +#X connect 50 0 51 0; +#X connect 51 0 0 0; +#X connect 52 0 48 0; +#X connect 56 0 58 0; +#X connect 57 0 58 1; +#X connect 57 0 59 0; +#X connect 58 0 81 0; +#X connect 59 0 56 0; +#X connect 62 0 64 0; +#X connect 63 0 64 1; +#X connect 63 0 65 0; +#X connect 64 0 84 0; +#X connect 65 0 62 0; +#X connect 68 0 70 0; +#X connect 69 0 70 1; +#X connect 69 0 71 0; +#X connect 70 0 85 0; +#X connect 71 0 68 0; +#X connect 74 0 76 0; +#X connect 75 0 76 1; +#X connect 75 0 77 0; +#X connect 76 0 88 0; +#X connect 77 0 74 0; +#X connect 80 0 0 0; +#X connect 81 0 0 0; +#X connect 84 0 0 0; +#X connect 85 0 0 0; +#X connect 88 0 0 0; diff --git a/grid/tk2c.bash b/grid/tk2c.bash new file mode 100755 index 0000000..9dfeb03 --- /dev/null +++ b/grid/tk2c.bash @@ -0,0 +1,24 @@ +#!/bin/bash + +#set -x + +while read line +do + for word in $line + do + if [ "X"$word != "X"${word#\#} ] + then + echo // ${line#\#} + break + else + line=${line//\'/\\\'} +#useless, slashes never gets in + line=${line//\\/\\\\} +#this one's dirty, i know + line=${line//;/\\\\;} + line=${line//\"/\\\"} + echo 'sys_gui("'$line'\n");' + break + fi + done +done -- cgit v1.2.1