various improvements in intuitive_interface and shape point selection
This commit is contained in:
parent
2bd8be9dec
commit
99e2c9e503
|
|
@ -298,7 +298,7 @@ void set_snap(double newsnap) /* 20161212 set new snap factor and just notify n
|
|||
tclvareval(xctx->top_path, ".statusbar.3 configure -background OrangeRed", NULL);
|
||||
}
|
||||
}
|
||||
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 10. ? cs : 10.) / 10.;
|
||||
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
|
||||
tclsetdoublevar("cadsnap", cs);
|
||||
}
|
||||
|
||||
|
|
@ -2606,8 +2606,7 @@ void zoom_full(int dr, int sel, int flags, double shrink)
|
|||
dbg(1, "zoom_full(): dr=%d sel=%d flags=%d areaw=%d, areah=%d\n", sel, dr, flags, xctx->areaw, xctx->areah);
|
||||
if(flags & 1) change_linewidth(-1.);
|
||||
/* we do this here since change_linewidth may not be called if flags & 1 == 0*/
|
||||
/* xctx->cadhalfdotsize = CADHALFDOTSIZE + 0.04 * (tclgetdoublevar("cadsnap")-10); */
|
||||
xctx->cadhalfdotsize = 4.0 * (cs < 10. ? cs : 10.) / 10.;
|
||||
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
|
||||
if(dr && has_x) {
|
||||
draw();
|
||||
redraw_w_a_l_r_p_rubbers();
|
||||
|
|
|
|||
116
src/callback.c
116
src/callback.c
|
|
@ -1347,19 +1347,19 @@ static int edit_rect_point(int state)
|
|||
xRect *p = &xctx->rect[rect_c][rect_n];
|
||||
|
||||
xctx->need_reb_sel_arr=1;
|
||||
if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x1, p->y1, p->x1 + ds, p->y1 + ds)) {
|
||||
if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x1, p->y1, p->x1 + ds, p->y1 + ds)) {
|
||||
xctx->shape_point_selected = 1;
|
||||
p->sel = SELECTED1;
|
||||
}
|
||||
else if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x2 - ds, p->y1, p->x2, p->y1 + ds)) {
|
||||
else if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x2 - ds, p->y1, p->x2, p->y1 + ds)) {
|
||||
xctx->shape_point_selected = 1;
|
||||
p->sel = SELECTED2;
|
||||
}
|
||||
else if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x1, p->y2 - ds, p->x1 + ds, p->y2)) {
|
||||
else if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x1, p->y2 - ds, p->x1 + ds, p->y2)) {
|
||||
xctx->shape_point_selected = 1;
|
||||
p->sel = SELECTED3;
|
||||
}
|
||||
else if(POINTINSIDE(xctx->mousex_snap, xctx->mousey_snap, p->x2 - ds, p->y2 - ds, p->x2, p->y2)) {
|
||||
else if(POINTINSIDE(xctx->mousex, xctx->mousey, p->x2 - ds, p->y2 - ds, p->x2, p->y2)) {
|
||||
xctx->shape_point_selected = 1;
|
||||
p->sel = SELECTED4;
|
||||
}
|
||||
|
|
@ -1625,6 +1625,45 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void end_shape_point_edit()
|
||||
{
|
||||
if(xctx->lastsel == 1 && xctx->sel_array[0].type==POLYGON) {
|
||||
int k;
|
||||
int n = xctx->sel_array[0].n;
|
||||
int c = xctx->sel_array[0].col;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->poly[c][n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
for(k=0; k<xctx->poly[c][n].points; ++k) {
|
||||
xctx->poly[c][n].selected_point[k] = 0;
|
||||
}
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
else if(xctx->lastsel == 1 && xctx->sel_array[0].type==xRECT) {
|
||||
int n = xctx->sel_array[0].n;
|
||||
int c = xctx->sel_array[0].col;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->rect[c][n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
else if(xctx->lastsel == 1 && xctx->sel_array[0].type==LINE) {
|
||||
int n = xctx->sel_array[0].n;
|
||||
int c = xctx->sel_array[0].col;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->line[c][n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
else if(xctx->lastsel == 1 && xctx->sel_array[0].type==WIRE) {
|
||||
int n = xctx->sel_array[0].n;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->wire[n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
}
|
||||
|
||||
/* main window callback */
|
||||
/* mx and my are set to the mouse coord. relative to window */
|
||||
/* winpath: set to .drw or sub windows .x1.drw, .x2.drw, ... */
|
||||
|
|
@ -3339,7 +3378,7 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
rebuild_selected_array();
|
||||
}
|
||||
}
|
||||
else if(button==Button1)
|
||||
else if(button==Button1) /* MOD button is not pressed here. Processed above */
|
||||
{
|
||||
xctx->drag_elements = 0;
|
||||
if(tclgetboolvar("persistent_command") && xctx->last_command) {
|
||||
|
|
@ -3361,21 +3400,10 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
xctx->mx_double_save=xctx->mousex_snap;
|
||||
xctx->my_double_save=xctx->mousey_snap;
|
||||
|
||||
|
||||
/* If no shift was pressed while Button1Press delete selection */
|
||||
if( !(state & (ShiftMask | ControlMask)) && !(SET_MODMASK) ) {
|
||||
if(xctx->intuitive_interface) {
|
||||
/* here we need to check if there is something under the mouse. */
|
||||
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
if(!sel.type) unselect_all(1);
|
||||
} else {
|
||||
/* if no intuitive_interface is set always unselect all existing objects
|
||||
* (unshifted) on mouse click */
|
||||
unselect_all(1);
|
||||
}
|
||||
}
|
||||
select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
if(!(state & (ShiftMask | ControlMask) ) ) unselect_all(1);
|
||||
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
rebuild_selected_array();
|
||||
|
||||
if(xctx->lastsel == 1 && xctx->sel_array[0].type==POLYGON)
|
||||
if(edit_polygon_point(state)) break; /* sets xctx->shape_point_selected */
|
||||
|
||||
|
|
@ -3388,15 +3416,6 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
if(xctx->lastsel == 1 && xctx->sel_array[0].type==WIRE)
|
||||
if(edit_wire_point(state)) break; /* sets xctx->shape_point_selected */
|
||||
|
||||
#if 0
|
||||
/* no single polygon was selected */
|
||||
/* Button1 click selects object here */
|
||||
if(!xctx->shape_point_selected) {
|
||||
sel = select_object(xctx->mousex, xctx->mousey, SELECTED, 0);
|
||||
}
|
||||
rebuild_selected_array();
|
||||
#endif
|
||||
|
||||
/* intuitive interface: directly drag elements */
|
||||
if(sel.type && xctx->intuitive_interface && xctx->lastsel >= 1 &&
|
||||
!xctx->shape_point_selected) {
|
||||
|
|
@ -3417,7 +3436,7 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
if(sel.type && state == ControlMask && !xctx->shape_point_selected) {
|
||||
int savesem = xctx->semaphore;
|
||||
xctx->semaphore = 0;
|
||||
launcher();
|
||||
launcher(); /* works only if lastsel == 1 */
|
||||
xctx->semaphore = savesem;
|
||||
}
|
||||
if(tclgetboolvar("auto_hilight") && !xctx->shape_point_selected) {
|
||||
|
|
@ -3455,44 +3474,7 @@ int rstate; /* (reduced state, without ShiftMask) */
|
|||
/* if a polygon/bezier/rectangle control point was clicked, end point move operation
|
||||
* and set polygon state back to SELECTED from SELECTED1 */
|
||||
else if((xctx->ui_state & (STARTMOVE | SELECTION)) && xctx->shape_point_selected) {
|
||||
if(xctx->lastsel == 1 && xctx->sel_array[0].type==POLYGON) {
|
||||
int k;
|
||||
int n = xctx->sel_array[0].n;
|
||||
int c = xctx->sel_array[0].col;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->poly[c][n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
for(k=0; k<xctx->poly[c][n].points; ++k) {
|
||||
xctx->poly[c][n].selected_point[k] = 0;
|
||||
}
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
else if(xctx->lastsel == 1 && xctx->sel_array[0].type==xRECT) {
|
||||
int n = xctx->sel_array[0].n;
|
||||
int c = xctx->sel_array[0].col;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->rect[c][n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
else if(xctx->lastsel == 1 && xctx->sel_array[0].type==LINE) {
|
||||
int n = xctx->sel_array[0].n;
|
||||
int c = xctx->sel_array[0].col;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->line[c][n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
else if(xctx->lastsel == 1 && xctx->sel_array[0].type==WIRE) {
|
||||
int n = xctx->sel_array[0].n;
|
||||
move_objects(END,0,0,0);
|
||||
xctx->wire[n].sel = SELECTED;
|
||||
xctx->shape_point_selected = 0;
|
||||
xctx->need_reb_sel_arr=1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
end_shape_point_edit();
|
||||
}
|
||||
|
||||
if(xctx->ui_state & STARTPAN) {
|
||||
|
|
|
|||
|
|
@ -4145,7 +4145,7 @@ void draw(void)
|
|||
|
||||
if(!xctx || xctx->no_draw) return;
|
||||
cs = tclgetdoublevar("cadsnap");
|
||||
xctx->cadhalfdotsize = 4.0 * (cs < 10. ? cs : 10.) / 10.;
|
||||
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
|
||||
xctx->crosshair_layer = tclgetintvar("crosshair_layer");
|
||||
if(xctx->crosshair_layer < 0 ) xctx->crosshair_layer = 2;
|
||||
if(xctx->crosshair_layer >= cadlayers ) xctx->crosshair_layer = 2;
|
||||
|
|
|
|||
|
|
@ -118,17 +118,26 @@ static void find_closest_polygon(double mx,double my)
|
|||
if(!xctx->enable_layer[c]) continue;
|
||||
for(i=0;i<xctx->polygons[c]; ++i)
|
||||
{
|
||||
bezier = !strboolcmp(get_tok_value(xctx->poly[c][i].prop_ptr, "bezier", 0), "true");
|
||||
bezier = bezier && (xctx->poly[c][i].points > 2);
|
||||
xPoly *p = &xctx->poly[c][i];
|
||||
bezier = !strboolcmp(get_tok_value(p->prop_ptr, "bezier", 0), "true");
|
||||
bezier = bezier && (p->points > 2);
|
||||
|
||||
if(bezier) {
|
||||
find_closest_bezier(mx, my, c, i, &l, &col);
|
||||
double ds = xctx->cadhalfdotsize;
|
||||
|
||||
find_closest_bezier(mx, my, c, i, &l, &col);
|
||||
for(j = 0; j < p->points; j++) {
|
||||
if( POINTINSIDE(mx, my, p->x[j] - ds, p->y[j] - ds, p->x[j] + ds, p->y[j] + ds)) {
|
||||
l = i; distance = 0.0;col = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(j=0; j<xctx->poly[c][i].points-1; ++j) {
|
||||
x1 = xctx->poly[c][i].x[j];
|
||||
y1 = xctx->poly[c][i].y[j];
|
||||
x2 = xctx->poly[c][i].x[j+1];
|
||||
y2 = xctx->poly[c][i].y[j+1];
|
||||
x1 = p->x[j];
|
||||
y1 = p->y[j];
|
||||
x2 = p->x[j+1];
|
||||
y2 = p->y[j+1];
|
||||
ORDER(x1,y1,x2,y2);
|
||||
if( (tmp = dist(x1, y1, x2, y2, mx, my)) < distance )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2002,8 +2002,7 @@ void change_linewidth(double w)
|
|||
double cs = tclgetdoublevar("cadsnap");
|
||||
if(tclgetboolvar("change_lw")) {
|
||||
xctx->lw=xctx->mooz * 0.09 * cs;
|
||||
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 10. ? cs : 10.) / 10.;
|
||||
/* xctx->cadhalfdotsize = CADHALFDOTSIZE + 0.04 * (cs-10); */
|
||||
xctx->cadhalfdotsize = CADHALFDOTSIZE * (cs < 20. ? cs : 20.) / 10.;
|
||||
}
|
||||
/* explicitly set line width */
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue