From 2005cba607270a0e176d739361cb6327fab061f7 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Wed, 26 Jul 2006 17:01:23 +0000 Subject: fixed coordinates for GOP svn path=/trunk/externals/unauthorized/; revision=5416 --- probalizer/CHANGES.LOG | 2 + probalizer/help-probalizer.pd | 53 ++++++++++++++++++++++++++ probalizer/probalizer.c | 9 ++--- probalizer/probalizer.tk2c | 87 +++++++++++++++++++++++++++++++++++++++++++ probalizer/tk2c.bash | 24 ++++++++++++ 5 files changed, 170 insertions(+), 5 deletions(-) create mode 100644 probalizer/help-probalizer.pd create mode 100755 probalizer/probalizer.tk2c create mode 100755 probalizer/tk2c.bash (limited to 'probalizer') diff --git a/probalizer/CHANGES.LOG b/probalizer/CHANGES.LOG index 497eaaa..e6b7307 100644 --- a/probalizer/CHANGES.LOG +++ b/probalizer/CHANGES.LOG @@ -1,3 +1,5 @@ +0.4 + fixed coordinates for GOP support 0.3 added GOP support 0.2 diff --git a/probalizer/help-probalizer.pd b/probalizer/help-probalizer.pd new file mode 100644 index 0000000..1b3a0f0 --- /dev/null +++ b/probalizer/help-probalizer.pd @@ -0,0 +1,53 @@ +#N canvas 191 -6 970 685 10; +#X text 374 167 (invoke with Properties ); +#X text 375 156 You can set the following properties :; +#X text 395 188 * Width : graphical x size; +#X text 395 200 * Height : graphical y size; +#X text 442 506 bugs and comments @ ydegoyon@free.fr; +#X msg 404 603 \; pd dsp 0; +#X msg 470 603 \; pd dsp 1; +#X text 376 110 Probalizer output serial of integers according to the +probability curve; +#X obj 470 581 loadbang; +#X obj 64 92 probalizer 200 200 10 100 1 0 53 1 61 2 8 3 39 4 9 5 40 +6 6 7 6 8 14 9 24; +#X text 395 213 * Values : number of values ( range is [ 1 \, nvalues +] ); +#X msg 93 54 bang; +#X msg 93 4 bang; +#X text 389 458 but without repetitions; +#X msg 295 16 zero; +#X msg 294 40 equi; +#X text 389 433 Note = If the probabilities are all equal to 1 \,; +#X msg 293 64 reset; +#X text 338 63 Reset output; +#X text 396 227 * Max Occurrences : max number of occurences in a serial +; +#X obj 68 358 probalizer 200 200 10 100 1 0 19 1 15 2 4 3 17 4 5 5 +14 6 1 7 0 8 4 9 7; +#X obj 193 331 loadbang; +#X msg 145 331 zero; +#X text 306 345 The output of first probalizer; +#X text 306 357 is stored in the second one; +#X floatatom 187 30 5 0 0; +#X msg 187 5 bang; +#X text 276 281 End of the serial; +#X text 390 445 probalizer behaves as a random object; +#X obj 276 308 print probalizer::end; +#X text 47 6 Start; +#X text 332 42 Set equal probabilities; +#X obj 93 29 metro 10; +#X connect 8 0 6 0; +#X connect 9 0 20 0; +#X connect 9 1 22 0; +#X connect 9 1 29 0; +#X connect 11 0 9 0; +#X connect 12 0 32 0; +#X connect 14 0 9 0; +#X connect 15 0 9 0; +#X connect 17 0 9 0; +#X connect 21 0 22 0; +#X connect 22 0 20 0; +#X connect 25 0 9 0; +#X connect 26 0 25 0; +#X connect 32 0 11 0; diff --git a/probalizer/probalizer.c b/probalizer/probalizer.c index 96a225b..0169285 100644 --- a/probalizer/probalizer.c +++ b/probalizer/probalizer.c @@ -42,12 +42,11 @@ #include "t_tk.h" #include "probalizer.h" -#ifdef _WIN32 +#ifdef NT #include -#define random rand #else #include -#endif /* _WIN32 */ +#endif #define DEFAULT_PROBALIZER_WIDTH 200 #define DEFAULT_PROBALIZER_HEIGHT 200 @@ -55,7 +54,7 @@ #define DEFAULT_PROBALIZER_NBOCCURRENCES 100 #define DEFAULT_PROB_VALUE 10 -static char *probalizer_version = "probalizer : outputs integer values according to a drawn probability curve , version 0.3 (ydegoyon@free.fr)"; +static char *probalizer_version = "probalizer : outputs integer values according to a drawn probability curve , version 0.4 (ydegoyon@free.fr)"; t_widgetbehavior probalizer_widgetbehavior; static t_class *probalizer_class; @@ -276,7 +275,7 @@ static void probalizer_save(t_gobj *z, t_binbuf *b) int ei,gi; binbuf_addv(b, "ssiisiiiii", gensym("#X"),gensym("obj"), - (t_int)text_xpix(&x->x_obj, x->x_glist), (t_int)text_ypix(&x->x_obj, x->x_glist), + (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, gensym("probalizer"), x->x_width, x->x_height, x->x_nvalues, x->x_noccurrences, x->x_save ); if ( x->x_save ) diff --git a/probalizer/probalizer.tk2c b/probalizer/probalizer.tk2c new file mode 100755 index 0000000..b4a608c --- /dev/null +++ b/probalizer/probalizer.tk2c @@ -0,0 +1,87 @@ +// ########### probalizer procedures -- ydegoyon@free.fr ######### +sys_gui("proc probalizer_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_width [concat graph_width_$vid]\n"); +sys_gui("global $var_graph_width\n"); +sys_gui("set var_graph_height [concat graph_height_$vid]\n"); +sys_gui("global $var_graph_height\n"); +sys_gui("set var_graph_nvalues [concat graph_nvalues_$vid]\n"); +sys_gui("global $var_graph_nvalues\n"); +sys_gui("set var_graph_noccurrences [concat graph_noccurrences_$vid]\n"); +sys_gui("global $var_graph_noccurrences\n"); +sys_gui("set var_graph_save [concat graph_save_$vid]\n"); +sys_gui("global $var_graph_save\n"); +sys_gui("set cmd [concat $id dialog [eval concat $$var_graph_width] [eval concat $$var_graph_height] [eval concat $$var_graph_nvalues] [eval concat $$var_graph_noccurrences] [eval concat $$var_graph_save] \\;]\n"); +// puts stderr $cmd +sys_gui("pd $cmd\n"); +sys_gui("}\n"); +sys_gui("proc probalizer_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 probalizer_ok {id} {\n"); +sys_gui("probalizer_apply $id\n"); +sys_gui("probalizer_cancel $id\n"); +sys_gui("}\n"); +sys_gui("proc pdtk_probalizer_dialog {id width height nvalues noccurrences save } {\n"); +sys_gui("set vid [string trimleft $id .]\n"); +sys_gui("set var_graph_width [concat graph_width_$vid]\n"); +sys_gui("global $var_graph_width\n"); +sys_gui("set var_graph_height [concat graph_height_$vid]\n"); +sys_gui("global $var_graph_height\n"); +sys_gui("set var_graph_nvalues [concat graph_nvalues_$vid]\n"); +sys_gui("global $var_graph_nvalues\n"); +sys_gui("set var_graph_noccurrences [concat graph_noccurrences_$vid]\n"); +sys_gui("global $var_graph_noccurrences\n"); +sys_gui("set var_graph_save [concat graph_save_$vid]\n"); +sys_gui("global $var_graph_save\n"); +sys_gui("set $var_graph_width $width\n"); +sys_gui("set $var_graph_height $height\n"); +sys_gui("set $var_graph_nvalues $nvalues\n"); +sys_gui("set $var_graph_noccurrences $noccurrences\n"); +sys_gui("set $var_graph_save $save\n"); +sys_gui("toplevel $id\n"); +sys_gui("wm title $id {probalizer}\n"); +sys_gui("wm protocol $id WM_DELETE_WINDOW [concat probalizer_cancel $id]\n"); +sys_gui("label $id.label -text {PROBALIZER 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 \"probalizer_cancel $id\"\n"); +sys_gui("button $id.buttonframe.apply -text {Apply} -command \"probalizer_apply $id\"\n"); +sys_gui("button $id.buttonframe.ok -text {OK} -command \"probalizer_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.lwidth -text \"Width :\"\n"); +sys_gui("entry $id.1rangef.width -textvariable $var_graph_width -width 7\n"); +sys_gui("pack $id.1rangef.lwidth $id.1rangef.width -side left\n"); +sys_gui("frame $id.2rangef\n"); +sys_gui("pack $id.2rangef -side top\n"); +sys_gui("label $id.2rangef.lheight -text \"Height :\"\n"); +sys_gui("entry $id.2rangef.height -textvariable $var_graph_height -width 7\n"); +sys_gui("pack $id.2rangef.lheight $id.2rangef.height -side left\n"); +sys_gui("frame $id.3rangef\n"); +sys_gui("pack $id.3rangef -side top\n"); +sys_gui("label $id.3rangef.lnvalues -text \"Values :\"\n"); +sys_gui("entry $id.3rangef.nvalues -textvariable $var_graph_nvalues -width 7\n"); +sys_gui("pack $id.3rangef.lnvalues $id.3rangef.nvalues -side left\n"); +sys_gui("frame $id.4rangef\n"); +sys_gui("pack $id.4rangef -side top\n"); +sys_gui("label $id.4rangef.lnoccurrences -text \"Max Occurrences :\"\n"); +sys_gui("entry $id.4rangef.noccurrences -textvariable $var_graph_noccurrences -width 7\n"); +sys_gui("pack $id.4rangef.lnoccurrences $id.4rangef.noccurrences -side left\n"); +sys_gui("checkbutton $id.save -text {Save contents} -variable $var_graph_save -anchor w\n"); +sys_gui("pack $id.save -side top\n"); +sys_gui("bind $id.1rangef.width [concat probalizer_ok $id]\n"); +sys_gui("bind $id.2rangef.height [concat probalizer_ok $id]\n"); +sys_gui("bind $id.3rangef.nvalues [concat probalizer_ok $id]\n"); +sys_gui("bind $id.4rangef.noccurrences [concat probalizer_ok $id]\n"); +sys_gui("focus $id.1rangef.width\n"); +sys_gui("}\n"); +// ########### probalizer procedures END -- ydegoyon@free.fr ######### diff --git a/probalizer/tk2c.bash b/probalizer/tk2c.bash new file mode 100755 index 0000000..9dfeb03 --- /dev/null +++ b/probalizer/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