fix setting pdfmarks with directories in hierarchical pdf exports

This commit is contained in:
Stefan Frederik 2021-12-31 11:58:28 +01:00
parent 7600985557
commit 06e84deb96
4 changed files with 46 additions and 43 deletions

View File

@ -190,6 +190,8 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
cairo_select_font_face(xctx->cairo_save_ctx, "Sans-Serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
#endif
/* save mouse position when doing pan operations */
if(
(
(event == ButtonPress && (button == Button1 || button == Button3)) ||
@ -201,7 +203,6 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
xctx->mx_double_save = xctx->mousex_snap;
xctx->my_double_save = xctx->mousey_snap;
}
here(1234);
for(i=0; i < xctx->rects[GRIDLAYER]; i++) {
/* process only graph boxes */
xRect *r;
@ -251,22 +252,34 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
zoom_m = (xctx->mousex - x1) / ( x2 - x1);
/* dragging cursors when mouse is very close */
if(event == ButtonPress && button == Button1) {
if( (xctx->graph_flags & 2) && fabs(xctx->mousex - W_X(xctx->graph_cursor1_x)) < 10) {
xctx->graph_flags |= 16; /* move cursor1 */
xctx->graph_flags |= 16; /* Start move cursor1 */
}
if( (xctx->graph_flags & 4) && fabs(xctx->mousex - W_X(xctx->graph_cursor2_x)) < 10) {
xctx->graph_flags |= 32; /* move cursor2 */
xctx->graph_flags |= 32; /* Start move cursor2 */
}
}
/* move cursor1 */
/* set cursor position from master graph x-axis */
if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 16 )) {
xctx->graph_cursor1_x = G_X(xctx->mousex);
}
/* move cursor2 */
/* set cursor position from master graph x-axis */
else if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 32 )) {
xctx->graph_cursor2_x = G_X(xctx->mousex);
}
/* x-cursor set */
/* x cursor1 toggle */
if((key == 'a') ) {
xctx->graph_flags ^= 2;
need_redraw = 1;
xctx->graph_flags |= 1; /* apply to all graphs */
if(xctx->graph_flags & 2) xctx->graph_cursor1_x = G_X(xctx->mousex);
}
/* x cursor2 toggle */
else if((key == 'b') ) {
xctx->graph_flags ^= 4;
need_redraw = 1;
@ -289,6 +302,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
if(val[0]) wx2 = atof(val);
else wx2 = 1e-6;
/* second loop: after having determined the master graph do the others */
for(i=0; i< ((xctx->graph_flags & 1) ? xctx->rects[GRIDLAYER] : xctx->lastsel); i++) {
c = (xctx->graph_flags & 1) ? GRIDLAYER : xctx->sel_array[i].col;
/* process only graph boxes */
@ -323,23 +337,17 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
cy = (y1 - y2) / (wy2 - wy1);
dy = y2 - wy1 * cy;
dbg(1, "%g %g %g %g - %d %d\n", wx1, wy1, wx2, wy2, divx, divy);
if( event == KeyPress || event == ButtonPress || event == MotionNotify ) {
/* move cursor1 */
if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 16 )) {
xctx->graph_cursor1_x = G_X(xctx->mousex);
need_redraw = 1;
}
/* move cursor2 */
else if(event == MotionNotify && (state & Button1Mask) && (xctx->graph_flags & 32 )) {
xctx->graph_cursor2_x = G_X(xctx->mousex);
need_redraw = 1;
}
else if(event == MotionNotify && (state & Button1Mask) && !xctx->graph_bottom) {
else
if(event == MotionNotify && (state & Button1Mask) && !xctx->graph_bottom) {
double delta;
if(xctx->graph_left) {
if(n == xctx->graph_master) {
@ -358,7 +366,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
} else {
delta = (wx2 - wx1);
delta_threshold = 0.02;
delta_threshold = 0.01;
if(fabs(xctx->mx_double_save - xctx->mousex_snap) > fabs(cx * delta) * delta_threshold) {
xx1 = wx1 + (xctx->mx_double_save - xctx->mousex_snap) / cx;
xx2 = wx2 + (xctx->mx_double_save - xctx->mousex_snap) / cx;
@ -391,7 +399,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
} else {
delta = (wx2 - wx1);
delta_threshold = 0.02;
delta_threshold = 0.05;
xx1 = wx1 - delta * delta_threshold;
xx2 = wx2 - delta * delta_threshold;
my_snprintf(s, S(s), "%g", xx1);
@ -420,7 +428,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
} else {
delta = (wx2 - wx1);
delta_threshold = 0.02;
delta_threshold = 0.05;
xx1 = wx1 - delta * delta_threshold;
xx2 = wx2 - delta * delta_threshold;
my_snprintf(s, S(s), "%g", xx1);
@ -446,7 +454,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
} else {
delta = (wx2 - wx1);
delta_threshold = 0.02;
delta_threshold = 0.05;
xx1 = wx1 + delta * delta_threshold;
xx2 = wx2 + delta * delta_threshold;
my_snprintf(s, S(s), "%g", xx1);
@ -475,7 +483,7 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
}
} else {
delta = (wx2 - wx1);
delta_threshold = 0.02;
delta_threshold = 0.05;
xx1 = wx1 + delta * delta_threshold;
xx2 = wx2 + delta * delta_threshold;
my_snprintf(s, S(s), "%g", xx1);
@ -675,14 +683,6 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
draw_graph(GRIDLAYER, n, 1 + 8 + (xctx->graph_flags & 6) ); /* draw data in each graph box */
}
} /* for(i=0; i<xctx->lastsel; i++) */
draw_selection(xctx->gc[SELLAYER], 0);
#if HAS_CAIRO==1
cairo_restore(xctx->cairo_ctx);
@ -1742,6 +1742,10 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
if(key=='l' && state == 0) /* start line */
{
int prev_state = xctx->ui_state;
if( waves_selected(event, key, state, button)) {
waves_callback(event, mx, my, key, button, aux, state);
break;
}
start_line(mx, my);
if(prev_state == STARTLINE) {
tcleval("set constrained_move 0" );

View File

@ -2020,8 +2020,6 @@ static void draw_graph_grid(
* 2: draw x-cursor1
* 4: draw x-cursor2
* 8: all drawing, if not set do only XCopyArea / x-cursor if specified
* 16: move cursor1
* 32: move cursor2
*/
void draw_graph(int c, int i, int flags)
{
@ -2293,6 +2291,7 @@ void draw_graph(int c, int i, int flags)
double txtsize = txtsizex;
int flip = (xctx->graph_cursor2_x > xctx->graph_cursor1_x) ? 1 : 0;
int xoffs = flip ? 2 : -2;
if(xx >= x1 && xx <= x2) {
drawline(3, NOW, xx, ry1, xx, ry2, 1);
if(unitx != 1.0)

View File

@ -522,7 +522,7 @@ static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot,
"/Subtype /Link "
"/ANN pdfmark\n",
x1, y1, x2, y2,
add_ext(xctx->inst[n].name, ".sch"));
add_ext(skip_dir(xctx->inst[n].name), ".sch"));
}
else if(xctx->inst[n].flags&1)
{
@ -777,7 +777,7 @@ void create_ps(char **psfile, int what)
fprintf(fd,
"[ "
"/Dest /%s "
"/DEST pdfmark\n", xctx->current_name);
"/DEST pdfmark\n", get_cell_w_ext(xctx->current_name, 0));
scaley = scale = (pagey-2 * margin) / dy;
dbg(1, "scale=%g pagex=%g pagey=%g dx=%g dy=%g\n", scale, pagex, pagey, dx, dy);

View File

@ -32,8 +32,8 @@ y1 = -0.0039
y2 = 0.87
divy = 3
subdivy=1
x1=2.32785e-07
x2=3.23559e-07 divx=10
x1=1.13977e-07
x2=2.1517e-07 divx=10
node="
v(ldbl[0]) v(ldbl[16]) v(ldbl[32])
v(ldbl[1]) v(ldbl[17]) v(ldbl[33])
@ -46,8 +46,8 @@ y1 = -0.021
y2 = 1.5
subdivy=1
divy = 4
x1=2.32785e-07
x2=3.23559e-07
x1=1.13977e-07
x2=2.1517e-07
divx=10
subdivx=4
node="v(ldcp) v(ldyms[4]) v(ldyms[5]) v(ldyms[6]) v(ldymsref)"
@ -59,8 +59,8 @@ y2 = 1.6
divy = 3
subdivy=0
subdivx = 1
x1=2.32785e-07
x2=3.23559e-07 divx=10
x1=1.13977e-07
x2=2.1517e-07 divx=10
node="
v(ldwl[0]) v(ldwl[1]) v(ldwl[2]) v(ldwl[3])
v(ldwl[4]) v(ldwl[5]) v(ldwl[6]) v(ldwl[16])
@ -69,11 +69,11 @@ color="4 5 4 5 4 5 4 5 4 5 4 5"
unitx=n
}
B 2 1840 -120 2890 -20 {flags=1
y1 = 0.9
y2 = 1.821
y1 = -0.021
y2 = 0.9
divy = 1
x1=2.32785e-07
x2=3.23559e-07 divx=10
x1=1.13977e-07
x2=2.1517e-07 divx=10
node="v(ldymsref)"
color=3 unitx=n subdivy=4}
B 2 1840 -880 2890 -420 {flags=1
@ -82,8 +82,8 @@ dig_max_waves=12
y1 = -0.024
y2 = 1.6
divy = 1
x1=2.32785e-07
x2=3.23559e-07
x1=1.13977e-07
x2=2.1517e-07
divx=12
subdivx=4
node="
@ -106,8 +106,8 @@ B 2 1840 -1280 2890 -1090 {flags=1
y1 = -0.022
y2 = 1.6
divy = 4
x1=2.32785e-07
x2=3.23559e-07
x1=1.13977e-07
x2=2.1517e-07
divx=8
unitx=n
node="v(xsa[0].ldqib) v(xsa[5].ldqib) v(xsa[0].ldsali) v(xctrl.ldq_b)"