Index: move.c =================================================================== --- move.c (revision 11848) +++ move.c (revision 11849) @@ -105,60 +105,104 @@ */ void *pcb_move_obj_and_rubberband(int Type, void *Ptr1, void *Ptr2, void *Ptr3, pcb_coord_t DX, pcb_coord_t DY) { - pcb_opctx_t ctx1; - pcb_opctx_t ctx2; + pcb_opctx_t ctx; void *ptr2; - ctx1.move.pcb = ctx2.move.pcb = PCB; - ctx1.move.dx = ctx2.move.dx = DX; - ctx1.move.dy = ctx2.move.dy = DY; + if ((DX == 0) && (DY == 0) && (conf_core.editor.move_linepoint_uses_route == 0)) + return NULL; - pcb_event(PCB_EVENT_RUBBER_MOVE, "ipp", Type, &ctx1, &ctx2); + ctx.move.dx = DX; + ctx.move.dy = DY; - if (DX == 0 && DY == 0) - return NULL; - pcb_draw_inhibit_inc(); - if (Type == PCB_TYPE_ARC_POINT) { - /* moving the endpoint of an arc is not really a move, but a change of arc properties */ - if (pcb_crosshair.AttachedObject.radius == 0) - pcb_arc_set_angles((pcb_layer_t *)Ptr1, (pcb_arc_t *)Ptr2, - pcb_crosshair.AttachedObject.start_angle, - pcb_crosshair.AttachedObject.delta_angle); - else - pcb_arc_set_radii((pcb_layer_t *)Ptr1, (pcb_arc_t *)Ptr2, - pcb_crosshair.AttachedObject.radius, - pcb_crosshair.AttachedObject.radius); - pcb_crosshair.AttachedObject.radius = 0; - } - else { - /* If rubberband has adapted movement, move accordingly */ - if (Type == PCB_TYPE_LINE && - (ctx1.move.dx != ctx2.move.dx || ctx1.move.dy != ctx2.move.dy)) { - pcb_line_t *line = (pcb_line_t*) Ptr2; + switch(Type) { + case PCB_TYPE_ARC_POINT : + { + /* Get the initial arc point positions */ + pcb_arc_t * p_arc = ((pcb_arc_t *)pcb_crosshair.AttachedObject.Ptr2); + pcb_coord_t ox1,ox2,oy1,oy2; + pcb_coord_t nx1,nx2,ny1,ny2; - /* Move point1 form line */ - pcb_undo_add_obj_to_move(PCB_TYPE_LINE_POINT, - Ptr1, line, &line->Point1, - ctx1.move.dx, ctx1.move.dy); - pcb_lineop_move_point(&ctx1, Ptr1, line, &line->Point1); + pcb_arc_get_end(p_arc,0, &ox1, &oy1); + pcb_arc_get_end(p_arc,1, &ox2, &oy2); - /* Move point2 form line */ - pcb_undo_add_obj_to_move(PCB_TYPE_LINE_POINT, - Ptr1, line, &line->Point2, - ctx2.move.dx, ctx2.move.dy); - ptr2 = pcb_lineop_move_point(&ctx2, Ptr1, line, &line->Point2); - } - /* Otherwise make a normal move */ - else if(Type == PCB_TYPE_LINE_POINT) { - ptr2 = pcb_lineop_move_point_with_route(&ctx1, Ptr1, Ptr2, Ptr3); - } - else { + /* moving the endpoint of an arc is not really a move, but a change of arc properties */ + if (pcb_crosshair.AttachedObject.radius == 0) + pcb_arc_set_angles((pcb_layer_t *)Ptr1, (pcb_arc_t *)Ptr2, + pcb_crosshair.AttachedObject.start_angle, + pcb_crosshair.AttachedObject.delta_angle); + else + pcb_arc_set_radii((pcb_layer_t *)Ptr1, (pcb_arc_t *)Ptr2, + pcb_crosshair.AttachedObject.radius, + pcb_crosshair.AttachedObject.radius); + pcb_crosshair.AttachedObject.radius = 0; + + /* Get the new arc point positions so that we can calculate the position deltas */ + pcb_arc_get_end(p_arc,0, &nx1, &ny1); + pcb_arc_get_end(p_arc,1, &nx2, &ny2); + pcb_event(PCB_EVENT_RUBBER_MOVE, "icccc", 0, nx1-ox1, ny1-oy1, nx2-ox2, ny2-oy2); + } + break; + + case PCB_TYPE_ARC : + pcb_event(PCB_EVENT_RUBBER_MOVE, "icccc", 0, DX, DY, DX, DY); pcb_undo_add_obj_to_move(Type, Ptr1, Ptr2, Ptr3, DX, DY); - ptr2 = pcb_object_operation(&MoveFunctions, &ctx1, Type, Ptr1, Ptr2, Ptr3); - } + ptr2 = pcb_object_operation(&MoveFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3); + break; + + case PCB_TYPE_LINE_POINT : + pcb_event(PCB_EVENT_RUBBER_MOVE, "icc", 0, DX, DY); + ptr2 = pcb_lineop_move_point_with_route(&ctx, Ptr1, Ptr2, Ptr3); + break; + + case PCB_TYPE_LINE : + { + pcb_coord_t dx1 = DX; + pcb_coord_t dy1 = DY; + pcb_coord_t dx2 = DX; + pcb_coord_t dy2 = DY; + pcb_line_t *line = (pcb_line_t*) Ptr2; + int constrained = 0; + + if(conf_core.editor.rubber_band_keep_midlinedir) + pcb_event(PCB_EVENT_RUBBER_CONSTRAIN_MAIN_LINE, "pppppp", line, &constrained, &dx1, &dy1, &dx2, &dy2); + pcb_event(PCB_EVENT_RUBBER_MOVE, "icccc", constrained, dx1, dy1, dx2, dy2); + + ctx.move.dx = dx1; + ctx.move.dy = dy1; + + /* If the line ends have moved indpendently then move the individual points */ + if((dx1 != dx2) || (dy1 != dy2)) { + /* Move point1 form line */ + pcb_undo_add_obj_to_move(PCB_TYPE_LINE_POINT, + Ptr1, line, &line->Point1, + dx1, dy1); + pcb_lineop_move_point(&ctx, Ptr1, line, &line->Point1); + + /* Move point2 form line */ + pcb_undo_add_obj_to_move(PCB_TYPE_LINE_POINT, + Ptr1, line, &line->Point2, + dx2, dy2); + ctx.move.dx = dx2; + ctx.move.dy = dy2; + ptr2 = pcb_lineop_move_point(&ctx, Ptr1, line, &line->Point2); + } + /* Otherwise make a normal move */ + else { + pcb_undo_add_obj_to_move(Type, Ptr1, Ptr2, Ptr3, dx1, dy1); + ptr2 = pcb_object_operation(&MoveFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3); + } + } + break; + + default : + pcb_event(PCB_EVENT_RUBBER_MOVE, "icc", 0, DX, DY); + pcb_undo_add_obj_to_move(Type, Ptr1, Ptr2, Ptr3, DX, DY); + ptr2 = pcb_object_operation(&MoveFunctions, &ctx, Type, Ptr1, Ptr2, Ptr3); + break; } + pcb_undo_inc_serial(); pcb_draw_inhibit_dec();