cleanup in preview code
This commit is contained in:
parent
a64d69ed7a
commit
9588a859da
|
|
@ -194,7 +194,8 @@ const char *add_ext(const char *f, const char *ext)
|
|||
dbg(1, "add_ext(): 3: ff=%s\n", ff);
|
||||
return ff;
|
||||
}
|
||||
static void reset_cairo(void)
|
||||
|
||||
static void reset_cairo(int create, int clear)
|
||||
{
|
||||
#ifdef HAS_CAIRO
|
||||
/* save_sfc is based on pixmap and pixmaps are not resizeable, so on resize
|
||||
|
|
@ -256,14 +257,14 @@ void resetwin(int create_pixmap, int clear_pixmap, int preview_window)
|
|||
|
||||
/* if no preview_window or create_pixmap==1 avoid unnecessary work if no resize */
|
||||
/* !create_pixmap ensures the XSetTile is executed when done with the preview */
|
||||
if( preview_window || !create_pixmap || xctx->xschem_w !=xrect[0].width || xctx->xschem_h !=xrect[0].height) {
|
||||
if( preview_window || xctx->xschem_w !=xctx->xrect[0].width || xctx->xschem_h !=xctx->xrect[0].height) {
|
||||
dbg(1, "resetwin(): x=%d y=%d xctx->xschem_w=%d xctx->xschem_h=%d\n",
|
||||
wattr.x, wattr.y, xctx->xschem_w,xctx->xschem_h);
|
||||
dbg(1, "resetwin(): changing size\n\n");
|
||||
xrect[0].x = 0;
|
||||
xrect[0].y = 0;
|
||||
xrect[0].width = xctx->xschem_w;
|
||||
xrect[0].height = xctx->xschem_h;
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
xctx->xrect[0].width = xctx->xschem_w;
|
||||
xctx->xrect[0].height = xctx->xschem_h;
|
||||
if(clear_pixmap) XFreePixmap(display,xctx->save_pixmap);
|
||||
/*
|
||||
{
|
||||
|
|
@ -277,8 +278,8 @@ void resetwin(int create_pixmap, int clear_pixmap, int preview_window)
|
|||
xctx->save_pixmap = XCreatePixmap(display, xctx->window, xctx->xschem_w, xctx->xschem_h, depth);
|
||||
}
|
||||
XSetTile(display,gctiled, xctx->save_pixmap);
|
||||
reset_cairo();
|
||||
}
|
||||
reset_cairo(create_pixmap, clear_pixmap);
|
||||
#else
|
||||
HWND hwnd;
|
||||
if (preview_window) {
|
||||
|
|
@ -303,22 +304,22 @@ void resetwin(int create_pixmap, int clear_pixmap, int preview_window)
|
|||
xctx->areah = xctx->areay2 - xctx->areay1;
|
||||
/* if no preview_window or create_pixmap==1 avoid unnecessary work if no resize */
|
||||
/* !create_pixmap ensures the XSetTile is executed when done with the preview */
|
||||
if( preview_window || !create_pixmap || xctx->xschem_w !=xrect[0].width ||
|
||||
xctx->xschem_h !=xrect[0].height) {
|
||||
if( preview_window || xctx->xschem_w !=xctx->xrect[0].width ||
|
||||
xctx->xschem_h !=xctx->xrect[0].height) {
|
||||
dbg(1, "resetwin(): x=%d y=%d xctx->xschem_w=%d xctx->xschem_h=%d\n",
|
||||
rct.right, rct.bottom, xctx->xschem_w, xctx->xschem_h);
|
||||
dbg(1, "resetwin(): changing size\n\n");
|
||||
xrect[0].x = 0;
|
||||
xrect[0].y = 0;
|
||||
xrect[0].width = xctx->xschem_w;
|
||||
xrect[0].height = xctx->xschem_h;
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
xctx->xrect[0].width = xctx->xschem_w;
|
||||
xctx->xrect[0].height = xctx->xschem_h;
|
||||
if(clear_pixmap) Tk_FreePixmap(display, xctx->save_pixmap);
|
||||
if(create_pixmap) {
|
||||
xctx->save_pixmap = Tk_GetPixmap(display, xctx->window, xctx->xschem_w, xctx->xschem_h, depth);
|
||||
}
|
||||
XSetTile(display, gctiled, xctx->save_pixmap);
|
||||
}
|
||||
reset_cairo();
|
||||
reset_cairo(create_pixmap, clear_pixmap);
|
||||
}
|
||||
#endif
|
||||
if(pending_fullzoom) {
|
||||
|
|
@ -1325,8 +1326,8 @@ void change_linewidth(double w)
|
|||
}
|
||||
xctx->areax1 = -2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay1 = -2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax2 = xrect[0].width+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = xrect[0].height+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax2 = xctx->xrect[0].width+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = xctx->xrect[0].height+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areaw = xctx->areax2-xctx->areax1;
|
||||
xctx->areah = xctx->areay2 - xctx->areay1;
|
||||
}
|
||||
|
|
@ -1504,8 +1505,8 @@ void zoom_full(int dr, int sel)
|
|||
}
|
||||
xctx->areax1 = -2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay1 = -2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax2 = xrect[0].width+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = xrect[0].height+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax2 = xctx->xrect[0].width+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = xctx->xrect[0].height+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areaw = xctx->areax2-xctx->areax1;
|
||||
xctx->areah = xctx->areay2 - xctx->areay1;
|
||||
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
(xctx->ui_state & STARTCOPY) || (xctx->ui_state & STARTRECT) ||i
|
||||
(xctx->ui_state & STARTPOLYGON) || (xctx->ui_state & STARTPAN2) ||
|
||||
(xctx->ui_state & STARTPAN) || (xctx->ui_state & STARTSELECT)) {
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, gctiled, xrect[0].x, xrect[0].y,
|
||||
xrect[0].width, xrect[0].height, xrect[0].x, xrect[0].y);
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, 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
|
||||
if(xctx->ui_state & STARTPAN2) pan2(RUBBER, mx, my); /* 20121123 - 20160425 moved up */
|
||||
|
|
@ -205,7 +205,7 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
#ifdef TURBOX_FIX
|
||||
/* fix Exceed TurboX bugs when drawing with pixmap tiled fill pattern */
|
||||
/* *NOT* a solution but at least makes the program useable. 20171130 */
|
||||
XSetClipRectangles(display, gctiled, 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gctiled, 0,0, xctx->xrect, 1, Unsorted);
|
||||
#endif
|
||||
my_snprintf(str, S(str), "mouse = %.16g %.16g - selected: %d w=%.16g h=%.16g",
|
||||
xctx->mousex_snap, xctx->mousey_snap,
|
||||
|
|
@ -1625,8 +1625,8 @@ int callback(int event, int mx, int my, KeySym key,
|
|||
if( !(state & ShiftMask) && !(state & Mod1Mask) ) {
|
||||
unselect_all();
|
||||
#ifndef __unix__
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, gctiled, xrect[0].x, xrect[0].y,
|
||||
xrect[0].width, xrect[0].height, xrect[0].x, xrect[0].y);
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, 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
|
||||
}
|
||||
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
|
|
|
|||
26
src/draw.c
26
src/draw.c
|
|
@ -83,10 +83,10 @@ void print_image()
|
|||
|
||||
XUnmapWindow(display, xctx->window);
|
||||
|
||||
xrect[0].x = 0;
|
||||
xrect[0].y = 0;
|
||||
xctx->xschem_w = xrect[0].width = w;
|
||||
xctx->xschem_h = xrect[0].height = h;
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
xctx->xschem_w = xctx->xrect[0].width = w;
|
||||
xctx->xschem_h = xctx->xrect[0].height = h;
|
||||
xctx->areax2 = w+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = h+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax1 = -2*INT_WIDTH(xctx->lw);
|
||||
|
|
@ -135,10 +135,10 @@ void print_image()
|
|||
#endif /*HAS_CAIRO */
|
||||
for(tmp=0;tmp<cadlayers;tmp++)
|
||||
{
|
||||
XSetClipRectangles(display, gc[tmp], 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gcstipple[tmp], 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gc[tmp], 0,0, xctx->xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gcstipple[tmp], 0,0, xctx->xrect, 1, Unsorted);
|
||||
}
|
||||
XSetClipRectangles(display, gctiled, 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gctiled, 0,0, xctx->xrect, 1, Unsorted);
|
||||
save_draw_grid = draw_grid;
|
||||
draw_grid=0;
|
||||
draw_pixmap=1;
|
||||
|
|
@ -159,10 +159,10 @@ void print_image()
|
|||
xctx->modified=modified_save;
|
||||
|
||||
w=ww;h=hh;
|
||||
xrect[0].x = 0;
|
||||
xrect[0].y = 0;
|
||||
xctx->xschem_w = xrect[0].width = w;
|
||||
xctx->xschem_h = xrect[0].height = h;
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
xctx->xschem_w = xctx->xrect[0].width = w;
|
||||
xctx->xschem_h = xctx->xrect[0].height = h;
|
||||
xctx->areax2 = w+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = h+2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax1 = -2*INT_WIDTH(xctx->lw);
|
||||
|
|
@ -1761,8 +1761,8 @@ void draw(void)
|
|||
} /* !only_probes, 20110112 */
|
||||
draw_hilight_net(draw_window);
|
||||
if(!draw_window) {
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, gctiled, xrect[0].x, xrect[0].y,
|
||||
xrect[0].width, xrect[0].height, xrect[0].x, xrect[0].y);
|
||||
XCopyArea(display, xctx->save_pixmap, xctx->window, 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);
|
||||
}
|
||||
draw_selection(gc[SELLAYER], 0); /* 20181009 moved outside of cadlayers loop */
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ unsigned char pixdata_init[22][32]={ /* fill patterns... indexed by laynumb.
|
|||
GC *gcstipple,*gc, gctiled;
|
||||
Pixmap *pixmap = NULL;
|
||||
Display *display;
|
||||
XRectangle xrect[1] = {{0,0,0,0}};
|
||||
Pixmap cad_icon_pixmap=0, cad_icon_mask=0;
|
||||
XPoint *gridpoint; /* pointer to array of gridpoints, used in draw() */
|
||||
XColor xcolor_array[256];
|
||||
|
|
|
|||
26
src/select.c
26
src/select.c
|
|
@ -438,10 +438,10 @@ void bbox(int what,double x1,double y1, double x2, double y2)
|
|||
xctx->areay2 = savey2;
|
||||
xctx->areaw = savew;
|
||||
xctx->areah = saveh;
|
||||
xrect[0].x = 0;
|
||||
xrect[0].y = 0;
|
||||
xrect[0].width = xctx->areaw-4*INT_WIDTH(xctx->lw);
|
||||
xrect[0].height = xctx->areah-4*INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
xctx->xrect[0].width = xctx->areaw-4*INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].height = xctx->areah-4*INT_WIDTH(xctx->lw);
|
||||
|
||||
XSetClipMask(display, gctiled, None); /* 20171110 optimization, clipping already done in software */
|
||||
|
||||
|
|
@ -468,21 +468,21 @@ void bbox(int what,double x1,double y1, double x2, double y2)
|
|||
xctx->areaw = (xctx->areax2-xctx->areax1);
|
||||
xctx->areah = (xctx->areay2-xctx->areay1);
|
||||
|
||||
xrect[0].x = bbx1-INT_WIDTH(xctx->lw);
|
||||
xrect[0].y = bby1-INT_WIDTH(xctx->lw);
|
||||
xrect[0].width = bbx2-bbx1+2*INT_WIDTH(xctx->lw);
|
||||
xrect[0].height = bby2-bby1+2*INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].x = bbx1-INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].y = bby1-INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].width = bbx2-bbx1+2*INT_WIDTH(xctx->lw);
|
||||
xctx->xrect[0].height = bby2-bby1+2*INT_WIDTH(xctx->lw);
|
||||
for(i=0;i<cadlayers;i++)
|
||||
{
|
||||
XSetClipRectangles(display, gc[i], 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gcstipple[i], 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gc[i], 0,0, xctx->xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gcstipple[i], 0,0, xctx->xrect, 1, Unsorted);
|
||||
}
|
||||
XSetClipRectangles(display, gctiled, 0,0, xrect, 1, Unsorted);
|
||||
XSetClipRectangles(display, gctiled, 0,0, xctx->xrect, 1, Unsorted);
|
||||
dbg(1, "bbox(): bbox= %d %d %d %d\n",xctx->areax1,xctx->areay1,xctx->areax2,xctx->areay2);
|
||||
#ifdef HAS_CAIRO
|
||||
cairo_rectangle(cairo_ctx, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height);
|
||||
cairo_rectangle(cairo_ctx, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
cairo_clip(cairo_ctx);
|
||||
cairo_rectangle(cairo_save_ctx, xrect[0].x, xrect[0].y, xrect[0].width, xrect[0].height);
|
||||
cairo_rectangle(cairo_save_ctx, xctx->xrect[0].x, xctx->xrect[0].y, xctx->xrect[0].width, xctx->xrect[0].height);
|
||||
cairo_clip(cairo_save_ctx);
|
||||
#endif
|
||||
break;
|
||||
|
|
|
|||
28
src/xinit.c
28
src/xinit.c
|
|
@ -364,11 +364,6 @@ void free_xschem_data()
|
|||
my_free(1133, &xctx->maxl);
|
||||
my_free(1108, &xctx->sel_array);
|
||||
for(i=0;i<CADMAXHIER;i++) my_free(1139, &xctx->sch_path[i]);
|
||||
#ifdef __unix__
|
||||
XFreePixmap(display,xctx->save_pixmap);
|
||||
#else
|
||||
Tk_FreePixmap(display, xctx->save_pixmap);
|
||||
#endif
|
||||
my_free(269, &xctx);
|
||||
|
||||
}
|
||||
|
|
@ -403,6 +398,7 @@ void alloc_xschem_data()
|
|||
xctx->modified = 0;
|
||||
xctx->semaphore = 0;
|
||||
xctx->netlist_name[0] = '\0';
|
||||
xctx->xrect[0].width = xctx->xrect[0].height = xctx->xrect[0].x = xctx->xrect[0].y = 0;
|
||||
|
||||
for(i=0;i<CADMAXHIER;i++) xctx->sch_path[i]=NULL;
|
||||
my_strdup(1187, &xctx->sch_path[0],".");
|
||||
|
|
@ -861,7 +857,7 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
|
|||
/* if not set heuristics is done in xschem.tcl to ensure it is an xschem file */
|
||||
load_schematic(1,filename, 0);
|
||||
xctx->window = pre_window;
|
||||
resetwin(1, 0, 1); /* resetwin( create_pixmap, clear_pixmap, preview_window) */
|
||||
resetwin(1, 0, 1); /* create preview pixmap resetwin(create_pixmap, clear_pixmap, preview_window) */
|
||||
zoom_full(1, 0); /* draw */
|
||||
check_version = 0;
|
||||
|
||||
|
|
@ -869,17 +865,15 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen
|
|||
unselect_all();
|
||||
remove_symbols();
|
||||
clear_drawing();
|
||||
free_xschem_data();
|
||||
|
||||
show_pin_net_names = save_show_pin;
|
||||
/* free the pixmap (if a different one) used for preview */
|
||||
resetwin(0, 1, 1); /* delete preview pixmap */
|
||||
free_xschem_data();
|
||||
xctx = save_xctx; /* restore schematic */
|
||||
|
||||
resetwin(0, 0, 0); /* set window size info back to original value */
|
||||
|
||||
set_modify(xctx->modified);
|
||||
/* reset window (back to main xctx->window), but don't delete and create a pixmap since we
|
||||
have preserved the main window pixmap and already erased the preview pixmap
|
||||
the goal of this complicated pixmap saving is to avoid a draw() call in the main window
|
||||
to regenerate the save_pixmap every time user browses a new symbol */
|
||||
resetwin(0, 0, 0); /* preview save_pixmap already deleted in free_xschem_data() */
|
||||
change_linewidth(-1.);
|
||||
/* not needed: event loop takes care of this and don't need to regenerate xctx->save_pixmap. */
|
||||
/* draw(); */
|
||||
|
|
@ -1248,10 +1242,10 @@ int Tcl_AppInit(Tcl_Interp *inter)
|
|||
xctx->areay1 = -2*INT_WIDTH(xctx->lw);
|
||||
xctx->areax2 = xctx->areaw-2*INT_WIDTH(xctx->lw);
|
||||
xctx->areay2 = xctx->areah-2*INT_WIDTH(xctx->lw);
|
||||
xrect[0].x = 0;
|
||||
xrect[0].y = 0;
|
||||
xrect[0].width = CADWIDTH;
|
||||
xrect[0].height = CADHEIGHT;
|
||||
xctx->xrect[0].x = 0;
|
||||
xctx->xrect[0].y = 0;
|
||||
xctx->xrect[0].width = CADWIDTH;
|
||||
xctx->xrect[0].height = CADHEIGHT;
|
||||
|
||||
|
||||
my_strncpy(xctx->file_version, XSCHEM_FILE_VERSION, S(xctx->file_version));
|
||||
|
|
|
|||
|
|
@ -532,6 +532,7 @@ typedef struct {
|
|||
struct instentry *insttable[NBOXES][NBOXES];
|
||||
Window window;
|
||||
Pixmap save_pixmap;
|
||||
XRectangle xrect[1];
|
||||
} Xschem_ctx;
|
||||
|
||||
struct Lcc { /* used for symbols containing schematics as instances (LCC, Local Custom Cell) */
|
||||
|
|
@ -674,7 +675,6 @@ extern char *xschem_executable;
|
|||
extern int depth;
|
||||
extern int *fill_type; /* 20171117 for every layer: 0: no fill, 1, solid fill, 2: stipple fill */
|
||||
extern Tcl_Interp *interp;
|
||||
extern XRectangle xrect[];
|
||||
extern double cadsnap;
|
||||
extern int horizontal_move;
|
||||
extern int vertical_move;
|
||||
|
|
|
|||
Loading…
Reference in New Issue