Commit 651fca7d authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

interim commit, continuing to document plot_vis

parent 2ed82246
......@@ -740,6 +740,26 @@ t_float glist_xtopixels(t_glist *x, t_float xval)
}
}
/* convert an x coordinate value to an x pixel location in window */
/* we don't need the translation step for GOPS so we remove it here. Once
this is working with everything we can get rid of the one above. */
t_float glist_xtopixels2(t_glist *x, t_float xval)
{
if (!x->gl_isgraph)
return ((xval - x->gl_x1) / (x->gl_x2 - x->gl_x1));
else if (x->gl_isgraph && x->gl_havewindow)
return (x->gl_screenx2 - x->gl_screenx1) *
(xval - x->gl_x1) / (x->gl_x2 - x->gl_x1);
else
{
int x1, y1, x2, y2;
if (!x->gl_owner)
bug("glist_pixelstox");
graph_graphrect(&x->gl_gobj, x->gl_owner, &x1, &y1, &x2, &y2);
return ((x2 - x1) * (xval - x->gl_x1) / (x->gl_x2 - x->gl_x1));
}
}
t_float glist_ytopixels(t_glist *x, t_float yval)
{
if (!x->gl_isgraph)
......@@ -757,6 +777,27 @@ t_float glist_ytopixels(t_glist *x, t_float yval)
}
}
t_float glist_ytopixels2(t_glist *x, t_float yval)
{
if (!x->gl_isgraph)
return ((yval - x->gl_y1) / (x->gl_y2 - x->gl_y1));
else if (x->gl_isgraph && x->gl_havewindow)
return (x->gl_screeny2 - x->gl_screeny1) *
(yval - x->gl_y1) / (x->gl_y2 - x->gl_y1);
else
{
int x1, y1, x2, y2;
if (!x->gl_owner)
bug("glist_pixelstoy");
graph_graphrect(&x->gl_gobj, x->gl_owner, &x1, &y1, &x2, &y2);
fprintf(stderr, "ytopixels: gl_y1 is %g\n", x->gl_y1);
fprintf(stderr, "ytopixels: gl_y2 is %g\n", x->gl_y2);
fprintf(stderr, "ytopixels: graph y1 is %d\n", y1);
fprintf(stderr, "ytopixels: graph y2 is %d\n", y2);
return ((y2 - y1) * yval / (x->gl_y2 - x->gl_y1));
}
}
/* convert an X screen distance to an X coordinate increment.
This is terribly inefficient;
but probably not a big enough CPU hog to warrant optimizing. */
......@@ -785,7 +826,7 @@ int text_xpix(t_text *x, t_glist *glist)
xpix = glist_xtopixels(glist, glist->gl_x1) +
x->te_xpix - glist->gl_xmargin;
else xpix = (glist_xtopixels(glist,
glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) *
glist->gl_x1 + (glist->gl_x2 - glist->gl_x1) *
x->te_xpix / (glist->gl_screenx2 - glist->gl_screenx1)));
if (x->te_iemgui == 1)
xpix += ((t_iemgui *)x)->legacy_x*sys_legacy;
......
......@@ -838,7 +838,7 @@ void scalar_doconfigure(t_gobj *xgobj, t_glist *owner)
glist_getcanvas(owner),
tagbuf,
glist_isselected(owner, &x->sc_gobj),
xscale, 0.0, 0.0, yscale,
1.0, 0.0, 0.0, 1.0,
(int)glist_xtopixels(owner, basex),
(int)glist_ytopixels(owner, basey));
......@@ -954,11 +954,14 @@ static void scalar_groupvis(t_scalar *x, t_glist *owner, t_template *template,
/* At present, scalars have a three-level hierarchy in the gui,
with two levels accessible by the user from within Pd:
scalar - ".scalar%lx", x->sc_vec
| <g> with matrix derived from x/y fields,
| gop basexy, and gop scaling values. This group is
| not configurable by the user. This means that the
| a [draw g] below can ignore basexy and gop junk
| when computing the transform matrix.
| <g> with matrix derived from x/y fields and GOP
| basex/y. This group is not configurable by the
| user. This means that the a [draw g] child
| object below it can ignore basexy and gop junk
| when computing the transform matrix. For backward-
| compatibility the old drawing instructions still
| have to do a transform to get the pixel values, but
| they were already using glist_xtopixel/etc. anyway.
v
dgroup - ".dgroup%lx.%lx", templatecanvas, x->sc_vec
| group used as parent for all the toplevel drawing
......@@ -979,6 +982,10 @@ static void scalar_groupvis(t_scalar *x, t_glist *owner, t_template *template,
The tag "blankscalar" is for scalars that don't have a visual
representation, but maybe this can just be merged with "scalar"
*/
t_float glist_xtopixels2(t_glist *x, t_float xval);
t_float glist_ytopixels2(t_glist *x, t_float yval);
static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
{
//fprintf(stderr,"scalar_vis %d %lx\n", vis, (t_int)z);
......@@ -1023,25 +1030,13 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis)
if (vis)
{
t_float xscale = glist_xtopixels(owner, 1) - glist_xtopixels(owner, 0);
t_float yscale = glist_ytopixels(owner, 1) - glist_ytopixels(owner, 0);
/* we translate the .scalar%lx group to displace it on the tk side.
This is the outermost group for the scalar, something like a
poor man's viewport.
Also:
* the default stroke is supposed to be "none"
* default fill is supposed to be black.
* stroke-linejoin should be "miter", not "round"
To fix these, we set the correct fill/stroke/strokelinjoin options
here on the .scalar%lx group. (Notice also that tkpath doesn't
understand "None"-- instead we must send an empty symbol.) */
char tagbuf[MAXPDSTRING];
sprintf(tagbuf, "scalar%lx", (long unsigned int)x->sc_vec);
gui_vmess("gui_scalar_new", "xsiffffiii",
glist_getcanvas(owner),
tagbuf,
glist_isselected(owner, &x->sc_gobj),
xscale, 0.0, 0.0, yscale,
1.0, 0.0, 0.0, 1.0,
(int)glist_xtopixels(owner, basex),
(int)glist_ytopixels(owner, basey),
glist_istoplevel(owner));
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment