void hoa_scope_deprecated(t_hoa_scope* x, t_symbol *s, long ac, t_atom* av) { if(atoms_has_attribute(ac, av, gensym("@drawcircle")) || (s && s == gensym("drawcircle"))) object_error(x, "%s attribute @drawcircle is deprecated.", eobj_getclassname(x)->s_name); if(atoms_has_attribute(ac, av, gensym("@drawangles")) || (s && s == gensym("drawangles"))) object_error(x, "%s attribute @drawangles is deprecated.", eobj_getclassname(x)->s_name); if(atoms_has_attribute(ac, av, gensym("@drawcontrib")) || (s && s == gensym("drawcontrib"))) object_error(x, "%s attribute @drawcontrib is deprecated.", eobj_getclassname(x)->s_name); }
static void blackboard_text(t_blackboard *x, t_symbol *s, int argc, t_atom *argv) { int i; char buffer[MAXPDSTRING]; size_t length; if(x->f_ninstructions >= _blackboard::maxcmd) { pd_error(x, "%s too many drawing commands.", eobj_getclassname(x)->s_name); return; } if(argc > 2 && argv) { if (atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT) { sprintf(x->f_instructions[x->f_ninstructions], "create text %d %d -anchor nw -text {", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1)); for(i = 2; i < argc; i++) { atom_string(argv+i, buffer, MAXPDSTRING); length = strlen(buffer); strncat(x->f_instructions[x->f_ninstructions], " ", 1); strncat(x->f_instructions[x->f_ninstructions], buffer, length); } sprintf(buffer, "} -font {%s %d %s} -fill %s", x->j_box.b_font.c_family->s_name, (int)x->j_box.b_font.c_size, x->j_box.b_font.c_weight->s_name, x->f_color->s_name); length = strlen(buffer); strncat(x->f_instructions[x->f_ninstructions], buffer, length); x->f_ninstructions++; ebox_redraw((t_ebox *)x); } } }
static void blackboard_image(t_blackboard *x, t_symbol *s, int argc, t_atom *argv) { int fd; char path[MAXPDSTRING]; char name[MAXPDSTRING]; char *nameptr; if(x->f_ninstructions >= _blackboard::maxcmd) { pd_error(x, "%s too many drawing commands.", eobj_getclassname(x)->s_name); return; } if(argc > 2 && argv) { if(atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT && atom_gettype(argv+2) == A_SYMBOL) { sprintf(path, "%s",atom_getsymbol(argv+2)->s_name); if(access(path, O_RDONLY) != -1) { sprintf(x->f_instructions[x->f_ninstructions], "create image %d %d -anchor nw -image [image create photo -file %s]", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), path); x->f_ninstructions++; ebox_redraw((t_ebox *)x); return; } sprintf(path, "%s/%s", canvas_getdir(x->j_box.b_obj.o_canvas)->s_name, atom_getsymbol(argv+2)->s_name); if(access(path, O_RDONLY) != -1) { sprintf(x->f_instructions[x->f_ninstructions], "create image %d %d -anchor nw -image [image create photo -file %s]", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), path); x->f_ninstructions++; ebox_redraw((t_ebox *)x); return; } sprintf(name, "%s", atom_getsymbol(argv+2)->s_name); if(!strncmp(name+strlen(name)-4, ".gif", 4)) { strncpy(name+strlen(name)-4, "\0", 4); } fd = open_via_path(canvas_getdir(x->j_box.b_obj.o_canvas)->s_name, name, ".gif", path, &nameptr, MAXPDSTRING, 0); if(fd >= 0) { sprintf(x->f_instructions[x->f_ninstructions], "create image %d %d -anchor nw -image [image create photo -file %s/%s.gif]", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), path, name); x->f_ninstructions++; ebox_redraw((t_ebox *)x); return; } } } }
static void blackboard_line(t_blackboard *x, t_symbol *s, int argc, t_atom *argv) { if(x->f_ninstructions >= _blackboard::maxcmd) { pd_error(x, "%s too many drawing commands.", eobj_getclassname(x)->s_name); return; } if(argc > 3 && argv) { if (atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT && atom_gettype(argv+2) == A_FLOAT && atom_gettype(argv+3) == A_FLOAT) { sprintf(x->f_instructions[x->f_ninstructions], "create line %d %d %d %d -fill %s -width %d", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), (int)atom_getfloat(argv+2), (int)atom_getfloat(argv+3), x->f_color->s_name, (int)x->f_width); x->f_ninstructions++; } ebox_redraw((t_ebox *)x); } }
static void blackboard_path(t_blackboard *x, t_symbol *s, int argc, t_atom *argv) { int i; char text[MAXPDSTRING]; size_t lenght; if(x->f_ninstructions >= _blackboard::maxcmd) { pd_error(x, "%s too many drawing commands.", eobj_getclassname(x)->s_name); return; } if(argc > 3 && argv) { if (atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT && atom_gettype(argv+2) == A_FLOAT && atom_gettype(argv+3) == A_FLOAT) { if(x->f_fill) sprintf(x->f_instructions[x->f_ninstructions], "create polygon %d %d %d %d ", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), (int)atom_getfloat(argv+2), (int)atom_getfloat(argv+3)); else sprintf(x->f_instructions[x->f_ninstructions], "create line %d %d %d %d", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), (int)atom_getfloat(argv+2), (int)atom_getfloat(argv+3)); for(i = 4; i < argc; i += 2) { if(argc > i+1 && atom_gettype(argv+i) == A_FLOAT && atom_gettype(argv+i+1) == A_FLOAT) { sprintf(text, "%d %d ", (int)atom_getfloat(argv+i), (int)atom_getfloat(argv+i+1)); lenght = strlen(text); strncat(x->f_instructions[x->f_ninstructions], text, lenght); } } if(x->f_fill) sprintf(text, "-fill %s -width 0 ", x->f_color->s_name); else sprintf(text, "-fill %s -width %d", x->f_color->s_name, (int)x->f_width); lenght = strlen(text); strncat(x->f_instructions[x->f_ninstructions], text, lenght); x->f_ninstructions++; ebox_redraw((t_ebox *)x); } } }
static void blackboard_arc(t_blackboard *x, t_symbol *s, int argc, t_atom *argv) { if(x->f_ninstructions >= _blackboard::maxcmd) { pd_error(x, "%s too many drawing commands.", eobj_getclassname(x)->s_name); return; } if(argc > 5 && argv) { if (atom_gettype(argv) == A_FLOAT && atom_gettype(argv+1) == A_FLOAT && atom_gettype(argv+2) == A_FLOAT && atom_gettype(argv+3) == A_FLOAT && atom_gettype(argv+4) == A_FLOAT && atom_gettype(argv+5) == A_FLOAT) { if(x->f_fill) sprintf(x->f_instructions[x->f_ninstructions], "create arc %d %d %d %d -start %d -extent %d -style pieslice -fill %s -width 0", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), (int)atom_getfloat(argv+2), (int)atom_getfloat(argv+3), (int)atom_getfloat(argv+4), (int)atom_getfloat(argv+5), x->f_color->s_name); else sprintf(x->f_instructions[x->f_ninstructions], "create arc %d %d %d %d -start %d -extent %d -style arc -outline %s -width %d", (int)atom_getfloat(argv), (int)atom_getfloat(argv+1), (int)atom_getfloat(argv+2), (int)atom_getfloat(argv+3), (int)atom_getfloat(argv+4), (int)atom_getfloat(argv+5), x->f_color->s_name, (int)x->f_width); x->f_ninstructions++; ebox_redraw((t_ebox *)x); } } }
void hoa_meter_deprecated(t_hoa_meter* x, t_symbol *s, long ac, t_atom* av) { t_atom* argv; long argc; if(s && s == gensym("loudspeakers") && ac && av) { object_error(x, "%s attribute @loudspeakers is deprecated, please use @channels.", eobj_getclassname(x)->s_name); channels_set(x, NULL, ac, av); } if(s && s == gensym("bordercolor") && ac && av) { object_attr_setvalueof((t_object *)x, gensym("bdcolor"), ac, av); object_error(x, "%s attribute @bordercolor is deprecated, please use @bdcolor.", eobj_getclassname(x)->s_name); } atoms_get_attribute(ac, av, gensym("@loudspeakers"), &argc, &argv); if(argc && argv) { object_error(x, "%s attribute @loudspeakers is deprecated, please use @channels.", eobj_getclassname(x)->s_name); channels_set(x, NULL, argc, argv); argc = 0;free(argv);argv = NULL; } atoms_get_attribute(ac, av, gensym("@bordercolor"), &argc, &argv); if(argc && argv) { object_attr_setvalueof((t_object *)x, gensym("bdcolor"), argc, argv); object_error(x, "%s attribute @bordercolor is deprecated, please use @bdcolor.", eobj_getclassname(x)->s_name); argc = 0;free(argv);argv = NULL; } if((s && s == gensym("mbgcolor")) || atoms_has_attribute(ac, av, gensym("@mbgcolor"))) { object_error(x, "%s attribute @mbgcolor is deprecated.", eobj_getclassname(x)->s_name); argc = 0;free(argv);argv = NULL; } }
void eobj_save(t_gobj* x, t_binbuf *b) { int i, state; int argc = 0; t_atom* argv = NULL; t_binbuf* d; t_object* z = (t_object *)x; t_ebox* y = (t_ebox *)z; t_eclass* c = eobj_getclass(x); char buffer[MAXPDSTRING]; if(x && b) { if(eobj_isbox(x)) { if(c && b) { state = canvas_suspend_dsp(); binbuf_addv(b, (char *)"ssiis", &s__X, s_cream_obj, (t_int)z->te_xpix, (t_int)z->te_ypix, eobj_getclassname(x)); for(i = 0; i < c->c_nattr; i++) { if(c->c_attr[i] && c->c_attr[i]->save && c->c_attr[i]->name) { eobj_attr_getvalueof(x, c->c_attr[i]->name, &argc, &argv); if(argc && argv) { if(!(argc == 1 && atom_gettype(argv) == A_SYMBOL && !is_valid_symbol(atom_getsymbol(argv)))) { snprintf(buffer, MAXPDSTRING, "@%s", c->c_attr[i]->name->s_name); binbuf_append_attribute(b, gensym(buffer), argc, argv); } argc = 0; free(argv); argv = NULL; } } } argv = (t_atom *)malloc(3 * sizeof(t_atom)); if(argv) { for(i = 0; i < y->b_nparams; i++) { if(y->b_params[i]) { snprintf(buffer, MAXPDSTRING, "@param%i", i); atom_setsym(argv, y->b_params[i]->p_name); atom_setsym(argv+1, y->b_params[i]->p_label); atom_setfloat(argv+2, y->b_params[i]->p_index); binbuf_append_attribute(b, gensym(buffer), 3, argv); } } } if(c->c_widget.w_save != NULL) { c->c_widget.w_save(x, b); } binbuf_addv(b, (char *)";"); canvas_resume_dsp(state); } } else { binbuf_addv(b, (char *)"ssii", &s__X, s_cream_obj, (t_int)z->te_xpix, (t_int)z->te_ypix); d = z->te_binbuf; if(d) { binbuf_addbinbuf(b, d); } if(c->c_widget.w_save != NULL) { c->c_widget.w_save(x, b); } binbuf_addv(b, (char *)";"); } } }
void hoa_optim_deprecated(t_hoa_optim* x, t_symbol *s, long ac, t_atom* av) { t_atom* argv; long argc; if(s && s == gensym("mode") && ac && av) { if(atom_gettype(av) == A_SYM) { if(atom_getsym(av) == gensym("maxRe")) x->f_optim->setMode(Hoa2D::Optim::MaxRe); else if(atom_getsym(av) == gensym("basic")) x->f_optim->setMode(Hoa2D::Optim::Basic); else x->f_optim->setMode(Hoa2D::Optim::InPhase); } else { if(atom_getlong(av) == 1) x->f_optim->setMode(Hoa2D::Optim::MaxRe); else if(atom_getlong(av) == 0) x->f_optim->setMode(Hoa2D::Optim::Basic); else x->f_optim->setMode(Hoa2D::Optim::InPhase); } object_error(x, "%s attribute @mode is deprecated, please use it as an argument.", eobj_getclassname(x)->s_name); } atoms_get_attribute(ac, av, gensym("@mode"), &argc, &argv); if(argc && argv) { if(atom_gettype(argv) == A_SYM) { if(atom_getsym(argv) == gensym("maxRe")) x->f_optim->setMode(Hoa2D::Optim::MaxRe); else if(atom_getsym(argv) == gensym("basic")) x->f_optim->setMode(Hoa2D::Optim::Basic); else x->f_optim->setMode(Hoa2D::Optim::InPhase); } else { if(atom_getlong(argv) == 1) x->f_optim->setMode(Hoa2D::Optim::MaxRe); else if(atom_getlong(argv) == 0) x->f_optim->setMode(Hoa2D::Optim::Basic); else x->f_optim->setMode(Hoa2D::Optim::InPhase); } object_error(x, "%s attribute @mode is deprecated, please use it as an argument.", eobj_getclassname(x)->s_name); argc = 0;free(argv);argv = NULL; } }