Commit 85815260 authored by Jonathan Wilkes's avatar Jonathan Wilkes Committed by Albert Gräf
Browse files

clean up unused variables and old code

Also fix a type mismatch in dropdown widget (g_text.c) and add
an error check in ALSA audio (s_audio_alsamm.c).
parent 304c64f2
...@@ -428,7 +428,7 @@ void iemgui_shouldvis(t_iemgui *x, int mode) ...@@ -428,7 +428,7 @@ void iemgui_shouldvis(t_iemgui *x, int mode)
properties changed we'll adjust our layer position properties changed we'll adjust our layer position
to ensure that ordering is honored */ to ensure that ordering is honored */
t_canvas *canvas = glist_getcanvas(x->x_glist); t_canvas *canvas = glist_getcanvas(x->x_glist);
t_gobj *y = (t_gobj *)x->x_glist; //t_gobj *y = (t_gobj *)x->x_glist;
// this crashes when the label goes invisible and then // this crashes when the label goes invisible and then
// needs to be made visible again, so for the time being // needs to be made visible again, so for the time being
// we use the brute force redraw below for both the // we use the brute force redraw below for both the
...@@ -437,7 +437,6 @@ void iemgui_shouldvis(t_iemgui *x, int mode) ...@@ -437,7 +437,6 @@ void iemgui_shouldvis(t_iemgui *x, int mode)
//gobj_vis(y, canvas, 1); //gobj_vis(y, canvas, 1);
// reorder it visually // reorder it visually
glist_redraw(canvas); glist_redraw(canvas);
} }
} }
//fprintf(stderr,"draw move x->x_w=%d\n", x->x_w); //fprintf(stderr,"draw move x->x_w=%d\n", x->x_w);
...@@ -692,7 +691,8 @@ extern t_class *my_canvas_class; ...@@ -692,7 +691,8 @@ extern t_class *my_canvas_class;
// in 18 cases only, because canvas does not fit the pattern below. // in 18 cases only, because canvas does not fit the pattern below.
// canvas has no label handle and has a motion handle // canvas has no label handle and has a motion handle
// but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally) // but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally)
void scalehandle_draw_select(t_scalehandle *h, int px, int py) { void scalehandle_draw_select(t_scalehandle *h, int px, int py)
{
char tagbuf[MAXPDSTRING]; char tagbuf[MAXPDSTRING];
t_object *x = h->h_master; t_object *x = h->h_master;
t_canvas *canvas=glist_getcanvas(h->h_glist); t_canvas *canvas=glist_getcanvas(h->h_glist);
...@@ -710,7 +710,8 @@ void scalehandle_draw_select(t_scalehandle *h, int px, int py) { ...@@ -710,7 +710,8 @@ void scalehandle_draw_select(t_scalehandle *h, int px, int py) {
} }
} }
void scalehandle_draw_select2(t_iemgui *x) { void scalehandle_draw_select2(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
t_class *c = pd_class((t_pd *)x); t_class *c = pd_class((t_pd *)x);
int sx,sy; int sx,sy;
...@@ -735,29 +736,35 @@ void scalehandle_draw_select2(t_iemgui *x) { ...@@ -735,29 +736,35 @@ void scalehandle_draw_select2(t_iemgui *x) {
scalehandle_draw_select(x->x_lhandle,x->x_ldx,x->x_ldy); scalehandle_draw_select(x->x_lhandle,x->x_ldx,x->x_ldy);
} }
void scalehandle_draw_erase(t_scalehandle *h) { void scalehandle_draw_erase(t_scalehandle *h)
t_canvas *canvas = glist_getcanvas(h->h_glist); {
//t_canvas *canvas = glist_getcanvas(h->h_glist);
if (!h->h_vis) return; if (!h->h_vis) return;
gui_vmess("gui_iemgui_label_show_drag_handle", "xxiiii", gui_vmess("gui_iemgui_label_show_drag_handle", "xxiiii",
h->h_glist, h->h_master, 0, 0, 0, h->h_scale); h->h_glist, h->h_master, 0, 0, 0, h->h_scale);
h->h_vis = 0; h->h_vis = 0;
} }
void scalehandle_draw_erase2(t_iemgui *x) { void scalehandle_draw_erase2(t_iemgui *x)
{
t_scalehandle *sh = (t_scalehandle *)(x->x_handle); t_scalehandle *sh = (t_scalehandle *)(x->x_handle);
t_scalehandle *lh = (t_scalehandle *)(x->x_lhandle); t_scalehandle *lh = (t_scalehandle *)(x->x_lhandle);
if (sh->h_vis) scalehandle_draw_erase(sh); if (sh->h_vis) scalehandle_draw_erase(sh);
if (lh->h_vis) scalehandle_draw_erase(lh); if (lh->h_vis) scalehandle_draw_erase(lh);
} }
void scalehandle_draw(t_iemgui *x) { void scalehandle_draw(t_iemgui *x)
if (x->x_glist == glist_getcanvas(x->x_glist)) { {
if (x->x_glist == glist_getcanvas(x->x_glist))
{
if (x->x_selected == x->x_glist) scalehandle_draw_select2(x); if (x->x_selected == x->x_glist) scalehandle_draw_select2(x);
else scalehandle_draw_erase2(x); else scalehandle_draw_erase2(x);
} }
} }
t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickhandlefn chf, t_motionhandlefn mhf) { t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale,
t_clickhandlefn chf, t_motionhandlefn mhf)
{
t_scalehandle *h = (t_scalehandle *)pd_new(scalehandle_class); t_scalehandle *h = (t_scalehandle *)pd_new(scalehandle_class);
char buf[19]; // 3 + max size of %lx char buf[19]; // 3 + max size of %lx
h->h_master = x; h->h_master = x;
...@@ -784,7 +791,8 @@ t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickha ...@@ -784,7 +791,8 @@ t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickha
return h; return h;
} }
void scalehandle_free(t_scalehandle *h) { void scalehandle_free(t_scalehandle *h)
{
if (!h->h_scale || pd_class((t_pd *)(h->h_master)) == my_canvas_class) if (!h->h_scale || pd_class((t_pd *)(h->h_master)) == my_canvas_class)
{ /* only binding label handles and my_canvas resize handle */ { /* only binding label handles and my_canvas resize handle */
pd_unbind((t_pd *)h, h->h_bindsym); pd_unbind((t_pd *)h, h->h_bindsym);
...@@ -792,16 +800,18 @@ void scalehandle_free(t_scalehandle *h) { ...@@ -792,16 +800,18 @@ void scalehandle_free(t_scalehandle *h) {
pd_free((t_pd *)h); pd_free((t_pd *)h);
} }
void properties_set_field_int(long props, const char *gui_field, int value) { void properties_set_field_int(long props, const char *gui_field, int value)
{
char tagbuf[MAXPDSTRING]; char tagbuf[MAXPDSTRING];
sprintf(tagbuf, ".gfxstub%lx", props); sprintf(tagbuf, ".gfxstub%lx", props);
gui_vmess("gui_dialog_set_field", "ssi", gui_vmess("gui_dialog_set_field", "ssi",
tagbuf, tagbuf,
gui_field, gui_field,
value); value);
}; }
void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) { void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y)
{
if (h->h_dragon && !h->h_scale) if (h->h_dragon && !h->h_scale)
{ {
t_iemgui *x = (t_iemgui *)(h->h_master); t_iemgui *x = (t_iemgui *)(h->h_master);
...@@ -823,8 +833,8 @@ void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) { ...@@ -823,8 +833,8 @@ void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) {
if (glist_isvisible(x->x_glist)) if (glist_isvisible(x->x_glist))
{ {
int xpos=text_xpix(&x->x_obj, x->x_glist); //int xpos=text_xpix(&x->x_obj, x->x_glist);
int ypos=text_ypix(&x->x_obj, x->x_glist); //int ypos=text_ypix(&x->x_obj, x->x_glist);
//iemgui_getrect_legacy_label(x, &xpos, &ypos); //iemgui_getrect_legacy_label(x, &xpos, &ypos);
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
gui_vmess("gui_iemgui_label_coords", "xxii", gui_vmess("gui_iemgui_label_coords", "xxii",
...@@ -836,12 +846,13 @@ void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) { ...@@ -836,12 +846,13 @@ void scalehandle_dragon_label(t_scalehandle *h, float mouse_x, float mouse_y) {
} }
} }
void scalehandle_click_label(t_scalehandle *h) { void scalehandle_click_label(t_scalehandle *h)
{
t_iemgui *x = (t_iemgui *)h->h_master; t_iemgui *x = (t_iemgui *)h->h_master;
if (glist_isvisible(x->x_glist)) if (glist_isvisible(x->x_glist))
{ {
//sys_vgui("lower %s\n", h->h_pathname); //sys_vgui("lower %s\n", h->h_pathname);
t_scalehandle *othersh = x->x_handle; //t_scalehandle *othersh = x->x_handle;
//sys_vgui("lower .x%lx.h%lx\n", //sys_vgui("lower .x%lx.h%lx\n",
// (t_int)glist_getcanvas(x->x_glist), (t_int)othersh); // (t_int)glist_getcanvas(x->x_glist), (t_int)othersh);
} }
...@@ -965,10 +976,11 @@ void iemgui_label_draw_new(t_iemgui *x) { ...@@ -965,10 +976,11 @@ void iemgui_label_draw_new(t_iemgui *x) {
x->x_fontsize); x->x_fontsize);
} }
void iemgui_label_draw_move(t_iemgui *x) { void iemgui_label_draw_move(t_iemgui *x)
{
t_canvas *canvas=glist_getcanvas(x->x_glist); t_canvas *canvas=glist_getcanvas(x->x_glist);
int x1=text_xpix(&x->x_obj, x->x_glist)+x->legacy_x; //int x1=text_xpix(&x->x_obj, x->x_glist)+x->legacy_x;
int y1=text_ypix(&x->x_obj, x->x_glist)+x->legacy_y; //int y1=text_ypix(&x->x_obj, x->x_glist)+x->legacy_y;
//iemgui_getrect_legacy_label(x, &x1, &y1); //iemgui_getrect_legacy_label(x, &x1, &y1);
//sys_vgui(".x%lx.c coords %lxLABEL %d %d\n", //sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
// canvas, x, x1+x->x_ldx, y1+x->x_ldy); // canvas, x, x1+x->x_ldx, y1+x->x_ldy);
...@@ -977,7 +989,7 @@ void iemgui_label_draw_move(t_iemgui *x) { ...@@ -977,7 +989,7 @@ void iemgui_label_draw_move(t_iemgui *x) {
Ivica's legacy logic isn't affecting us. Quick fix below by Ivica's legacy logic isn't affecting us. Quick fix below by
just adding the legacy offsets... */ just adding the legacy offsets... */
gui_vmess("gui_iemgui_label_coords", "xxii", gui_vmess("gui_iemgui_label_coords", "xxii",
glist_getcanvas(x->x_glist), canvas,
x, x,
x->x_ldx + x->legacy_x, x->x_ldx + x->legacy_x,
x->x_ldy + x->legacy_y); x->x_ldy + x->legacy_y);
......
...@@ -286,7 +286,6 @@ static int garray_get_largest_array(t_garray *x) ...@@ -286,7 +286,6 @@ static int garray_get_largest_array(t_garray *x)
t_gobj *g; t_gobj *g;
t_array *a; t_array *a;
t_garray *tmp; t_garray *tmp;
int an = 0;
// checks if there is a PLOTSTYLE_POLY vs others // checks if there is a PLOTSTYLE_POLY vs others
// longest array uses has_*, total_* gives total number // longest array uses has_*, total_* gives total number
...@@ -442,7 +441,6 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, int argc, t_atom *argv) ...@@ -442,7 +441,6 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, int argc, t_atom *argv)
int n = fsize, zonset, ztype, saveit; int n = fsize, zonset, ztype, saveit;
t_symbol *zarraytype; t_symbol *zarraytype;
t_garray *x; t_garray *x;
t_pd *x2;
t_template *template, *ztemplate; t_template *template, *ztemplate;
t_symbol *templatesym; t_symbol *templatesym;
int flags = fflags; int flags = fflags;
...@@ -1081,14 +1079,14 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, ...@@ -1081,14 +1079,14 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
/* if it has more than 2000 points, just check 1000 of them. */ /* if it has more than 2000 points, just check 1000 of them. */
int incr = (array->a_n <= 2000 ? 1 : array->a_n / 1000); int incr = (array->a_n <= 2000 ? 1 : array->a_n / 1000);
t_float pxpix1 = 0.0, pxpix2 = 0.0, pypix = 0.0, pwpix = 0.0, t_float pxpix1 = 0.0, pxpix2 = 0.0, pypix = 0.0, pwpix = 0.0,
dx, dy, dy2, dy3; dy, dy2, dy3;
for (i = 0; i < array->a_n; i += incr) for (i = 0; i < array->a_n; i += incr)
{ {
array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize, array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize,
xonset, yonset, wonset, i, xloc, yloc, xinc, xonset, yonset, wonset, i, xloc, yloc, xinc,
xfield, yfield, wfield, &pxpix1, &pxpix2, &pypix, &pwpix, 1); xfield, yfield, wfield, &pxpix1, &pxpix2, &pypix, &pwpix, 1);
//fprintf(stderr," array_getcoordinate %d: pxpix1:%f pxpix2:%f pypix:%f pwpix:%f dx:%f dy:%f elemsize:%d yonset:%d wonset:%d xonset:%d xloc:%f yloc:%f xinc:%f\n", i, pxpix1, pxpix2, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, xloc, yloc, xinc); // increased following on 20140830 to 8 and updated
// increased following on 20140830 to 8 and updated array_getcoordinate // array_getcoordinate
// so that the smallest hitbox is always at least 8x8--check with // so that the smallest hitbox is always at least 8x8--check with
// all_about_arrays.pd inside custom scalars in an array // all_about_arrays.pd inside custom scalars in an array
if (pwpix < 8) if (pwpix < 8)
...@@ -1101,34 +1099,13 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, ...@@ -1101,34 +1099,13 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
best = i; best = i;
break; break;
} }
/*
if (pwpix < 4)
pwpix = 4;
dx = pxpix1 - xpix;
if (dx < 0) dx = -dx;
if (dx > pxpix2-pxpix1) //this is the arbitrary radius away from the actual object's center, originally 8
continue;
dy = pypix - ypix;
if (dy < 0) dy = -dy;
if (dx + dy < best)
best = dx + dy;
if (wonset >= 0)
{
dy = (pypix + pwpix) - ypix;
if (dy < 0) dy = -dy;
if (dx + dy < best)
best = dx + dy;
dy = (pypix - pwpix) - ypix;
if (dy < 0) dy = -dy;
if (dx + dy < best)
best = dx + dy;
}
//fprintf(stderr," 1st %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, i);*/
} }
//fprintf(stderr," best = %f\n", best); //fprintf(stderr," best = %f\n", best);
if (best == -1 && (array_joc == 0)) //this is the arbitrary radius away from the actual object's center, originally 8 /* this is the arbitrary radius away from the actual object's
center, originally 8 */
if (best == -1 && (array_joc == 0))
{ {
//fprintf(stderr," best > 8\n"); //fprintf(stderr,"best > 8\n");
if (scalarvis != 0) if (scalarvis != 0)
{ {
//fprintf(stderr," array_doclick_element\n"); //fprintf(stderr," array_doclick_element\n");
...@@ -1143,176 +1120,156 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap, ...@@ -1143,176 +1120,156 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
return (0); return (0);
} }
} }
//best += 0.001; /* add truncation error margin */ dy = pypix - ypix;
//for (i = 0; i < array->a_n; i += incr) if (dy < 0) dy = -dy;
//{ if (wonset >= 0)
//array_getcoordinate(glist, (char *)(array->a_vec) + i * elemsize, {
// xonset, yonset, wonset, i, xloc, yloc, xinc, dy2 = (pypix + pwpix) - ypix;
// xfield, yfield, wfield, &pxpix1, &pxpix2, &pypix, &pwpix, 1); if (dy2 < 0) dy2 = -dy2;
//dx = pxpix1 - xpix; dy3 = (pypix - pwpix) - ypix;
//if (dx < 0) dx = -dx; if (dy3 < 0) dy3 = -dy3;
dy = pypix - ypix; if (yonset < 0)
if (dy < 0) dy = -dy; dy = 100;
if (wonset >= 0) }
else dy2 = dy3 = 100;
#if 0 // this doesn't seem to be used anywhere -ag
int dx;
int hit = 0;
if(array_joc)
{
hit = (xpix >= pxpix1) && (xpix < pxpix2);
}
else
hit = dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best;
#endif
if (dy < dy2 && dy < dy3)
{
array_motion_fatten = 0;
//fprintf(stderr,"A\n");
}
else if (dy2 < dy3)
{
array_motion_fatten = -1;
//fprintf(stderr,"B\n");
}
else if (!array_joc)
{
array_motion_fatten = 1;
//fprintf(stderr,"C\n");
}
if (doit || (glob_lmclick && array_joc))
{
char *elem = (char *)array->a_vec;
array_motion_elemsize = elemsize;
array_motion_glist = glist;
array_motion_scalar = sc;
array_motion_array = ap;
array_motion_template = elemtemplate;
array_motion_xperpix = glist_dpixtodx(glist, 1);
array_motion_yperpix = glist_dpixtody(glist, 1);
if (alt) /* delete a point */
{ {
dy2 = (pypix + pwpix) - ypix; if (array->a_n <= 1)
if (dy2 < 0) dy2 = -dy2; return (0);
dy3 = (pypix - pwpix) - ypix; memmove((char *)(array->a_vec) + elemsize * i,
if (dy3 < 0) dy3 = -dy3; (char *)(array->a_vec) + elemsize * (i+1),
if (yonset < 0) (array->a_n - 1 - i) * elemsize);
dy = 100; //array_resize_and_redraw(array, glist, array->a_n - 1);
garray_resize(array_garray, array->a_n - 1);
canvas_setcursor(glist_getcanvas(glist), 0);
return (0);
} }
else dy2 = dy3 = 100; else if (shift)
//fprintf(stderr," 2nd %f %f %f %f %f %f %f %d %d %d %d %d\n", pxpix, pypix, pwpix, dx, dy, dy2, dy3, elemsize, yonset, wonset, xonset, i);
//if (dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best)
//{
//fprintf(stderr, "dy=%f dy2=%f dy3=%f\n", dy, dy2, dy3);
/* from array-rev */
#if 0 // this doesn't seem to be used anywhere -ag
int hit = 0;
if(array_joc)
{ {
hit = (xpix >= pxpix1) && (xpix < pxpix2); /* add a point (after the clicked-on one) */
//fprintf(stderr,"add a point\n");
//array_resize_and_redraw(array, glist, array->a_n + 1);
elem = (char *)array->a_vec;
memmove(elem + elemsize * (i+1),
elem + elemsize * i,
(array->a_n - i - 1) * elemsize);
i++;
garray_resize(array_garray, array->a_n + 1);
canvas_setcursor(glist_getcanvas(glist), 0);
}
if (xonset >= 0)
{
//fprintf(stderr, " xonset >=0\n");
array_motion_xfield = xfield;
array_motion_xcumulative =
fielddesc_getcoord(xfield, array_motion_template,
(t_word *)(elem + i * elemsize), 1);
array_motion_wp = (t_word *)(elem + i * elemsize);
if (shift)
array_motion_npoints = array->a_n - i;
else array_motion_npoints = 1;
} }
else else
hit = dx + dy <= best || dx + dy2 <= best || dx + dy3 <= best; {
#endif //fprintf(stderr, " !(xonset >=0)\n");
/* end array-rev */ array_motion_xfield = 0;
array_motion_xcumulative = 0;
if (dy < dy2 && dy < dy3) array_motion_wp = (t_word *)elem;
{ array_motion_npoints = array->a_n;
array_motion_fatten = 0;
//fprintf(stderr,"A\n"); array_motion_initx = i;
} array_motion_lastx = i;
else if (dy2 < dy3) array_motion_xperpix *= (xinc == 0 ? 1 : 1./xinc);
{ }
array_motion_fatten = -1; if (array_motion_fatten)
//fprintf(stderr,"B\n"); {
} //fprintf(stderr, " motion_fatten\n");
else if (!array_joc) array_motion_yfield = wfield;
{ array_motion_ycumulative =
array_motion_fatten = 1; fielddesc_getcoord(wfield, array_motion_template,
//fprintf(stderr,"C\n"); (t_word *)(elem + i * elemsize), 1);
} array_motion_yperpix *= -array_motion_fatten;
if (doit || (glob_lmclick && array_joc)) }
{ else if (yonset >= 0)
char *elem = (char *)array->a_vec; {
array_motion_elemsize = elemsize; //fprintf(stderr, " yonset >=0\n");
array_motion_glist = glist; array_motion_yfield = yfield;
array_motion_scalar = sc; array_motion_ycumulative =
array_motion_array = ap; fielddesc_getcoord(yfield, array_motion_template,
array_motion_template = elemtemplate; (t_word *)(elem + i * elemsize), 1);
array_motion_xperpix = glist_dpixtodx(glist, 1); /* *(t_float *)((elem + elemsize * i) + yonset); */
array_motion_yperpix = glist_dpixtody(glist, 1); // we do cursor detection based on the kind of a graph.
if (alt) /* delete a point */ // (e.g. 3-point PLOYSTYLE_POINTS creates a graph that has 4
{ // delimiting points, while a 3-point PLOTSTYLE_POLY creates
if (array->a_n <= 1) // a graph that has only 3 delimiting points)
return (0); // This, therefore takes into account whether we should count
memmove((char *)(array->a_vec) + elemsize * i, // the center point of a bar or the starting point (poly) as
(char *)(array->a_vec) + elemsize * (i+1), // our reference.
(array->a_n - 1 - i) * elemsize); // TODO: see if we can reimplement Bezier curves
//array_resize_and_redraw(array, glist, array->a_n - 1); if (array_garray != NULL &&
garray_resize(array_garray, array->a_n - 1); (array_garray->x_style == PLOTSTYLE_POLY ||
canvas_setcursor(glist_getcanvas(glist), 0); array_garray->x_style == PLOTSTYLE_BEZ))
return (0);
}
else if (shift)
{
/* add a point (after the clicked-on one) */
//fprintf(stderr,"add a point\n");
//array_resize_and_redraw(array, glist, array->a_n + 1);
elem = (char *)array->a_vec;
memmove(elem + elemsize * (i+1),
elem + elemsize * i,
(array->a_n - i - 1) * elemsize);
i++;
garray_resize(array_garray, array->a_n + 1);
canvas_setcursor(glist_getcanvas(glist), 0);
}
if (xonset >= 0)
{
//fprintf(stderr, " xonset >=0\n");
array_motion_xfield = xfield;
array_motion_xcumulative =
fielddesc_getcoord(xfield, array_motion_template,
(t_word *)(elem + i * elemsize), 1);
array_motion_wp = (t_word *)(elem + i * elemsize);
if (shift)
array_motion_npoints = array->a_n - i;
else array_motion_npoints = 1;
}
else
{
//fprintf(stderr, " !(xonset >=0)\n");
array_motion_xfield = 0;
array_motion_xcumulative = 0;
array_motion_wp = (t_word *)elem;
array_motion_npoints = array->a_n;
array_motion_initx = i;
array_motion_lastx = i;
array_motion_xperpix *= (xinc == 0 ? 1 : 1./xinc);
}
if (array_motion_fatten)
{
//fprintf(stderr, " motion_fatten\n");
array_motion_yfield = wfield;
array_motion_ycumulative =
fielddesc_getcoord(wfield, array_motion_template,
(t_word *)(elem + i * elemsize), 1);
array_motion_yperpix *= -array_motion_fatten;
}
else if (yonset >= 0)
{
//fprintf(stderr, " yonset >=0\n");
array_motion_yfield = yfield;
array_motion_ycumulative =
fielddesc_getcoord(yfield, array_motion_template,
(t_word *)(elem + i * elemsize), 1);
/* *(t_float *)((elem + elemsize * i) + yonset); */
//if (array_joc) {
// we do cursor detection based on the kind of a graph.
// (e.g. 3-point PLOYSTYLE_POINTS creates a graph that has 4 delimiting points,
// while a 3-point PLOTSTYLE_POLY creates a graph that has only 3 delimiting points)
// This, therefore takes into account whether we should count the center point
// of a bar or the starting point (poly) as our reference
// TODO: see if we can reimplement Bezier curves
if (array_garray != NULL && (array_garray->x_style == PLOTSTYLE_POLY || array_garray->x_style == PLOTSTYLE_BEZ))
array_motion(0, xpix - pxpix1, ypix - pypix);
else
array_motion(0, (xpix - (pxpix1 + (pxpix2 - pxpix1)/2)), ypix - pypix);
//}
//else {
// array_motion(0, (xpix - (pxpix1 + (pxpix2 - pxpix1)/2)), ypix - pypix);
//}
//fprintf(stderr, "xpix:%d pxpix1:%f half:%f result:%f\n", xpix, pxpix1, (pxpix2-pxpix1)/2, xpix - (pxpix1 + (pxpix2 - pxpix1)/2));
}
else
{
//fprintf(stderr, " else 0\n");
array_motion_yfield = 0;
array_motion_ycumulative = 0;
}
//fprintf(stderr," glist_grab %d %d\n", xpix, ypix);
glist_grab(glist, 0, array_motion, 0, xpix, ypix);
//fprintf(stderr," VALUES: array_motion_initx:%f array_motion_lastx:%d array_motion_xperpix:%f array_motion_xcumulative:%f\n", array_motion_initx, array_motion_lastx, array_motion_xperpix, array_motion_xcumulative);
//fprintf(stderr," array_getcoordinate %d: pxpix1:%f pxpix2:%f pypix:%f pwpix:%f dx:%f dy:%f elemsize:%d yonset:%d wonset:%d xonset:%d xloc:%f yloc:%f xinc:%f\n", i, pxpix1, pxpix2, pypix, pwpix, dx, dy, elemsize, yonset, wonset, xonset, xloc, yloc, xinc);
}
if (alt)
{
return (CURSOR_EDITMODE_DISCONNECT);
}
else if (shift)
{ {
return (CURSOR_RUNMODE_ADDPOINT); array_motion(0, xpix - pxpix1, ypix - pypix);
} }