|
From: James R. V. Z. <jr...@co...> - 2009-07-24 02:13:11
|
On Tuesday I wrote:
>In the mean time I've found a simpler approach:
>
> if (modifier_mask & Mod_Shift) {
> /* scroll left */
> xmin = AXIS_DE_LOG_VALUE(FIRST_X_AXIS,1.1*axis_array[FIRST_X_AXIS].min
> -.1*axis_array[FIRST_X_AXIS].max);
> ymin = AXIS_DE_LOG_VALUE(FIRST_Y_AXIS,axis_array[FIRST_Y_AXIS].min);
> x2min = AXIS_DE_LOG_VALUE(SECOND_X_AXIS,1.1*axis_array[SECOND_X_AXIS].min
> -.1*axis_array[SECOND_X_AXIS].max);
> y2min = AXIS_DE_LOG_VALUE(SECOND_Y_AXIS,axis_array[SECOND_Y_AXIS].min);
>
> xmax = AXIS_DE_LOG_VALUE(FIRST_X_AXIS,.1*axis_array[FIRST_X_AXIS].min
> +.9*axis_array[FIRST_X_AXIS].max);
> ymax = AXIS_DE_LOG_VALUE(FIRST_Y_AXIS,axis_array[FIRST_Y_AXIS].max);
> x2max = AXIS_DE_LOG_VALUE(SECOND_X_AXIS,.1*axis_array[SECOND_X_AXIS].min
> +.9*axis_array[SECOND_X_AXIS].max);
> y2max = AXIS_DE_LOG_VALUE(SECOND_Y_AXIS,axis_array[SECOND_Y_AXIS].max);
> do_zoom(xmin, ymin, x2min, y2min, xmax, ymax, x2max, y2max);
> if (display_ipc_commands()) {
> fprintf(stderr, "scroll left.\n");
> }
> }
>
>Since this doesn't involve MousePosToGraphPosReal(), it works even for
>splot. I don't know whether this change would affect the other terminals.
>
>I haven't checked in this change because I found a bug: If I plot a
>function defined only for certain values of Y, and set logscale Y, and
>scroll past the defined region, then it breaks. E.g.
>
> set logscale y;set xrange [0:5];set yrange [.01:10];
> splot sqrt(1.02-(1- x)**2 - (1-y)**2)
>
>I haven't diagnosed that problem yet.
I have zoom and pan with the mouse wheel working for 3D as well as 2D plots.
I found the problem mentioned above in this section of plot3d.c:
axis_checked_extend_empty_range(FIRST_X_AXIS, "All points x value undefined");
axis_checked_extend_empty_range(FIRST_Y_AXIS, "All points y value undefined");
if (splot_map)
axis_checked_extend_empty_range(FIRST_Z_AXIS, NULL); /* Suppress warning message */
else
axis_checked_extend_empty_range(FIRST_Z_AXIS, "All points z value undefined");
axis_revert_and_unlog_range(FIRST_X_AXIS);
axis_revert_and_unlog_range(FIRST_Y_AXIS);
axis_revert_and_unlog_range(FIRST_Z_AXIS);
The test function in the splot command above is defined only for -.01
< y < 2.01. With logscale y, if I scroll up far enough that all the
defined points are outside the plot range, then I get the "All points
z value undefined" message and it abandons the plot. The problem was
that axis_array[FIRST_Y_AXIS].min and .max almost always hold
transformed values (logs of the minimum and maximum values to be
plotted). The exception is that when mouse commands adjust the scale,
the untransformed values are stored there. They are supposed to be
converted back to logs by the call to axis_revert_and_unlog_range()
shown above. If the conversion never happens, then scaling is messed
up - e.g. instead of yrange [.01:20] you would get [10**.01 : 10**20],
and just turning the mouse wheel the other direction cannot fix it.
I revised plot3d.c to fix the X and Y limits before checking for valid
Z values:
axis_checked_extend_empty_range(FIRST_X_AXIS, "All points x value undefined");
axis_revert_and_unlog_range(FIRST_X_AXIS);
axis_checked_extend_empty_range(FIRST_Y_AXIS, "All points y value undefined");
axis_revert_and_unlog_range(FIRST_Y_AXIS);
if (splot_map)
axis_checked_extend_empty_range(FIRST_Z_AXIS, NULL); /* Suppress warning message */
else
axis_checked_extend_empty_range(FIRST_Z_AXIS, "All points z value undefined");
axis_revert_and_unlog_range(FIRST_Z_AXIS);
It works here. However, I'd appreciate someone with a better
understanding of the code checking for side effects.
- Jim Van Zandt
|