Honor hide attribute for texts in ps/pdf and svg exports
This commit is contained in:
parent
c1a92ab5dc
commit
00de54c582
|
|
@ -899,7 +899,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
|
|||
|
||||
case Expose:
|
||||
dbg(1, "callback: Expose, winpath=%s, %dx%d+%d+%d\n", winpath, button, aux, mx, my);
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my);
|
||||
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my);
|
||||
{
|
||||
XRectangle xr[1];
|
||||
xr[0].x=mx;
|
||||
|
|
@ -931,7 +931,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
|
|||
(xctx->ui_state & STARTCOPY) || (xctx->ui_state & STARTRECT) ||
|
||||
(xctx->ui_state & STARTPOLYGON) || (xctx->ui_state & STARTPAN) ||
|
||||
(xctx->ui_state & STARTSELECT)) {
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2513,7 +2513,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
|
|||
if( !(state & ShiftMask) && !(state & Mod1Mask) ) {
|
||||
unselect_all();
|
||||
#ifndef __unix__
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
60
src/draw.c
60
src/draw.c
|
|
@ -28,6 +28,37 @@
|
|||
#define xDashType LineDoubleDash
|
||||
#else
|
||||
#define xDashType LineOnOffDash
|
||||
#if defined(HAS_CAIRO)
|
||||
static void clear_cairo_surface(cairo_t *cr, double x, double y, double width, double height)
|
||||
{
|
||||
cairo_save(cr);
|
||||
cairo_set_source_rgba(cr, 0, 0, 0, 0);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
||||
cairo_rectangle(cr, x, y, width, height);
|
||||
cairo_fill(cr);
|
||||
/*cairo_paint(cr);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);*/
|
||||
cairo_restore(cr);
|
||||
}
|
||||
|
||||
static void my_cairo_fill(cairo_surface_t *src_surface, int x, int y, unsigned int width, unsigned int height)
|
||||
{
|
||||
HWND hwnd = Tk_GetHWND(xctx->window);
|
||||
HDC dc = GetDC(hwnd);
|
||||
cairo_surface_t *dest_surface = cairo_win32_surface_create(dc);
|
||||
if (cairo_surface_status(dest_surface) != CAIRO_STATUS_SUCCESS) {
|
||||
fprintf(errfp, "ERROR: invalid cairo surface to copy over\n");
|
||||
}
|
||||
cairo_t *ct = cairo_create(dest_surface);
|
||||
cairo_surface_flush(src_surface);
|
||||
cairo_set_source_surface(ct, src_surface, 0, 0);
|
||||
cairo_rectangle(ct, x, y, width, height);
|
||||
cairo_set_operator(ct, CAIRO_OPERATOR_ADD);
|
||||
cairo_fill(ct);
|
||||
cairo_destroy(ct); ct = NULL;
|
||||
cairo_surface_destroy(dest_surface); dest_surface = NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int textclip(int x1,int y1,int x2,int y2,
|
||||
|
|
@ -2469,6 +2500,12 @@ void draw_graph(int i, const int flags, Graph_ctx *gr)
|
|||
*/
|
||||
/* draw stuff */
|
||||
if(flags & 8) {
|
||||
#if !defined(__unix__) && defined(HAS_CAIRO)
|
||||
double sw = (gr->sx2 - gr->sx1);
|
||||
double sh = (gr->sy2 - gr->sy1);
|
||||
clear_cairo_surface(xctx->cairo_save_ctx, gr->sx1, gr->sy1, sw, sh);
|
||||
clear_cairo_surface(xctx->cairo_ctx, gr->sx1, gr->sy1, sw, sh);
|
||||
#endif
|
||||
/* graph box, gridlines and axes */
|
||||
draw_graph_grid(gr);
|
||||
/* get data to plot */
|
||||
|
|
@ -2639,7 +2676,7 @@ void draw_graph(int i, const int flags, Graph_ctx *gr)
|
|||
}
|
||||
if(flags & 1) { /* copy save buffer to screen */
|
||||
if(!xctx->draw_window) {
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
|
||||
}
|
||||
}
|
||||
|
|
@ -2925,6 +2962,12 @@ void draw(void)
|
|||
|
||||
#if HAS_CAIRO==1
|
||||
const char *textfont;
|
||||
#ifndef __unix__
|
||||
clear_cairo_surface(xctx->cairo_save_ctx,
|
||||
xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
clear_cairo_surface(xctx->cairo_ctx,
|
||||
xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
#endif
|
||||
#endif
|
||||
if(xctx->no_draw) return;
|
||||
rebuild_selected_array();
|
||||
|
|
@ -3078,9 +3121,13 @@ void draw(void)
|
|||
} /* !xctx->only_probes, 20110112 */
|
||||
draw_hilight_net(xctx->draw_window);
|
||||
if(!xctx->draw_window) {
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
MyXCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, xctx->xrect[0].x, xctx->xrect[0].y,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height, xctx->xrect[0].x, xctx->xrect[0].y);
|
||||
}
|
||||
#if !defined(__unix__) && defined(HAS_CAIRO)
|
||||
else
|
||||
my_cairo_fill(xctx->cairo_sfc, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
#endif
|
||||
draw_selection(xctx->gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
|
||||
} /* if(has_x) */
|
||||
}
|
||||
|
|
@ -3097,3 +3144,12 @@ int XSetTile(Display* display, GC gc, Pixmap s_pixmap)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void MyXCopyArea(Display* display, Drawable src, Drawable dest, GC gc, int src_x, int src_y, unsigned int width, unsigned int height, int dest_x, int dest_y)
|
||||
{
|
||||
XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y);
|
||||
#if !defined(__unix__) && defined(HAS_CAIRO)
|
||||
my_cairo_fill(xctx->cairo_save_sfc, dest_x, dest_y, width, height);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ static void ps_drawgrid()
|
|||
static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot, double xoffset, double yoffset)
|
||||
/* draws current layer only, should be called within */
|
||||
{ /* a "for(i=0;i<cadlayers;i++)" loop */
|
||||
int j;
|
||||
int j, hide = 0;
|
||||
double x0,y0,x1,y1,x2,y2;
|
||||
short flip;
|
||||
int textlayer;
|
||||
|
|
@ -510,6 +510,13 @@ static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot,
|
|||
|
||||
if(xctx->inst[n].ptr == -1) return;
|
||||
if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return;
|
||||
if( (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr &&
|
||||
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (xctx->hide_symbols == 2) ) {
|
||||
hide = 1;
|
||||
} else {
|
||||
hide = 0;
|
||||
}
|
||||
|
||||
if(layer==0)
|
||||
{
|
||||
x1=X_TO_PS(xctx->inst[n].x1);
|
||||
|
|
@ -606,6 +613,8 @@ static void ps_draw_symbol(int n,int layer, int what, short tmp_flip, short rot,
|
|||
{
|
||||
text = (xctx->inst[n].ptr+ xctx->sym)->text[j];
|
||||
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
if(text.flags & HIDE_TEXT) continue;
|
||||
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
|
||||
txtptr= translate(n, text.txt_ptr);
|
||||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
textlayer = layer;
|
||||
|
|
@ -810,6 +819,7 @@ void create_ps(char **psfile, int what)
|
|||
for(i=0;i<xctx->texts;i++)
|
||||
{
|
||||
textlayer = xctx->text[i].layer;
|
||||
if(xctx->text[i].flags & HIDE_TEXT) continue;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
|
||||
|
||||
my_snprintf(ps_font_family, S(ps_font_name), "Helvetica");
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
|
|||
double xoffset, double yoffset)
|
||||
/* draws current layer only, should be called within */
|
||||
{ /* a "for(i=0;i<cadlayers;i++)" loop */
|
||||
int j;
|
||||
int j, hide = 0;
|
||||
double x0,y0,x1,y1,x2,y2;
|
||||
short flip;
|
||||
int textlayer;
|
||||
|
|
@ -448,6 +448,13 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
|
|||
|
||||
if(xctx->inst[n].ptr == -1) return;
|
||||
if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return;
|
||||
if( (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr &&
|
||||
!strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (xctx->hide_symbols == 2) ) {
|
||||
hide = 1;
|
||||
} else {
|
||||
hide = 0;
|
||||
}
|
||||
|
||||
if(layer==0) {
|
||||
x1=X_TO_SVG(xctx->inst[n].x1);
|
||||
x2=X_TO_SVG(xctx->inst[n].x2);
|
||||
|
|
@ -529,6 +536,8 @@ static void svg_draw_symbol(int c, int n,int layer,short tmp_flip, short rot,
|
|||
for(j=0;j< symptr->texts;j++) {
|
||||
text = symptr->text[j];
|
||||
/* if(text.xscale*FONTWIDTH* xctx->mooz<1) continue; */
|
||||
if(symptr->text[j].flags & HIDE_TEXT) continue;
|
||||
if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue;
|
||||
txtptr= translate(n, text.txt_ptr);
|
||||
ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1);
|
||||
textlayer = c;
|
||||
|
|
@ -730,6 +739,7 @@ void svg_draw(void)
|
|||
for(i=0;i<xctx->texts;i++)
|
||||
{
|
||||
textlayer = xctx->text[i].layer;
|
||||
if(xctx->text[i].flags & HIDE_TEXT) continue;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
|
||||
my_snprintf(svg_font_family, S(svg_font_family), tclgetvar("svg_font_name"));
|
||||
my_snprintf(svg_font_style, S(svg_font_style), "normal");
|
||||
|
|
|
|||
|
|
@ -1536,9 +1536,7 @@ static void resetcairo(int create, int clear, int force_or_resize)
|
|||
xctx->cairo_save_sfc =
|
||||
cairo_xlib_surface_create(display, xctx->save_pixmap, visual, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
#else
|
||||
HWND hwnd = Tk_GetHWND(xctx->window);
|
||||
HDC dc = GetDC(hwnd);
|
||||
xctx->cairo_save_sfc = cairo_win32_surface_create(dc);
|
||||
xctx->cairo_save_sfc = cairo_win32_surface_create_with_dib(CAIRO_FORMAT_RGB24, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
#endif
|
||||
if(cairo_surface_status(xctx->cairo_save_sfc)!=CAIRO_STATUS_SUCCESS) {
|
||||
fprintf(errfp, "ERROR: invalid cairo xcb surface\n");
|
||||
|
|
@ -1559,7 +1557,7 @@ static void resetcairo(int create, int clear, int force_or_resize)
|
|||
xctx->cairo_sfc = cairo_xlib_surface_create(display, xctx->window, visual,
|
||||
xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
#else
|
||||
xctx->cairo_sfc = cairo_win32_surface_create(dc);
|
||||
xctx->cairo_sfc = cairo_win32_surface_create_with_dib(CAIRO_FORMAT_RGB24, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
#endif
|
||||
if(cairo_surface_status(xctx->cairo_sfc)!=CAIRO_STATUS_SUCCESS) {
|
||||
fprintf(errfp, "ERROR: invalid cairo surface\n");
|
||||
|
|
|
|||
|
|
@ -1391,5 +1391,5 @@ extern void del_object_table(void);
|
|||
extern const char *create_tmpdir(char *prefix);
|
||||
extern FILE *open_tmpfile(char *prefix, char **filename);
|
||||
extern void create_ps(char** psfile, int what);
|
||||
|
||||
extern void MyXCopyArea(Display* display, Drawable src, Drawable dest, GC gc, int src_x, int src_y, unsigned int width, unsigned int height, int dest_x, int dest_y);
|
||||
#endif /*CADGLOBALS */
|
||||
|
|
|
|||
Loading…
Reference in New Issue