Index: move.c =================================================================== --- move.c (revision 4583) +++ move.c (revision 4584) @@ -60,9 +60,6 @@ */ static void *MoveElementName(pcb_opctx_t *ctx, ElementTypePtr); static void *MoveElement(pcb_opctx_t *ctx, ElementTypePtr); -static void *MovePolygon(pcb_opctx_t *ctx, LayerTypePtr, PolygonTypePtr); -static void *MovePolygonPoint(pcb_opctx_t *ctx, LayerTypePtr, PolygonTypePtr, PointTypePtr); -static void *MovePolygonToLayer(pcb_opctx_t *ctx, LayerTypePtr, PolygonTypePtr); /* --------------------------------------------------------------------------- * some local identifiers @@ -204,131 +201,6 @@ } /* --------------------------------------------------------------------------- - * low level routine to move a polygon - */ -void MovePolygonLowLevel(PolygonTypePtr Polygon, Coord DX, Coord DY) -{ - POLYGONPOINT_LOOP(Polygon); - { - MOVE(point->X, point->Y, DX, DY); - } - END_LOOP; - MOVE_BOX_LOWLEVEL(&Polygon->BoundingBox, DX, DY); -} - -/* --------------------------------------------------------------------------- - * moves a polygon - */ -static void *MovePolygon(pcb_opctx_t *ctx, LayerTypePtr Layer, PolygonTypePtr Polygon) -{ - if (Layer->On) { - ErasePolygon(Polygon); - } - r_delete_entry(Layer->polygon_tree, (BoxType *) Polygon); - MovePolygonLowLevel(Polygon, ctx->move.dx, ctx->move.dy); - r_insert_entry(Layer->polygon_tree, (BoxType *) Polygon, 0); - InitClip(PCB->Data, Layer, Polygon); - if (Layer->On) { - DrawPolygon(Layer, Polygon); - Draw(); - } - return (Polygon); -} - -/* --------------------------------------------------------------------------- - * moves a polygon-point - */ -static void *MovePolygonPoint(pcb_opctx_t *ctx, LayerTypePtr Layer, PolygonTypePtr Polygon, PointTypePtr Point) -{ - if (Layer->On) { - ErasePolygon(Polygon); - } - r_delete_entry(Layer->polygon_tree, (BoxType *) Polygon); - MOVE(Point->X, Point->Y, ctx->move.dx, ctx->move.dy); - SetPolygonBoundingBox(Polygon); - r_insert_entry(Layer->polygon_tree, (BoxType *) Polygon, 0); - RemoveExcessPolygonPoints(Layer, Polygon); - InitClip(PCB->Data, Layer, Polygon); - if (Layer->On) { - DrawPolygon(Layer, Polygon); - Draw(); - } - return (Point); -} - -/* --------------------------------------------------------------------------- - * moves a polygon between layers; lowlevel routines - */ -static void *MovePolygonToLayerLowLevel(pcb_opctx_t *ctx, LayerType * Source, PolygonType * polygon, LayerType * Destination) -{ - r_delete_entry(Source->polygon_tree, (BoxType *) polygon); - - polylist_remove(polygon); - polylist_append(&Destination->Polygon, polygon); - - if (!Destination->polygon_tree) - Destination->polygon_tree = r_create_tree(NULL, 0, 0); - r_insert_entry(Destination->polygon_tree, (BoxType *) polygon, 0); - - return polygon; -} - -struct mptlc { - pcb_cardinal_t snum, dnum; - int type; - PolygonTypePtr polygon; -} mptlc; - -r_dir_t mptl_pin_callback(const BoxType * b, void *cl) -{ - struct mptlc *d = (struct mptlc *) cl; - PinTypePtr pin = (PinTypePtr) b; - if (!TEST_THERM(d->snum, pin) || !IsPointInPolygon(pin->X, pin->Y, pin->Thickness + pin->Clearance + 2, d->polygon)) - return R_DIR_NOT_FOUND; - if (d->type == PCB_TYPE_PIN) - AddObjectToFlagUndoList(PCB_TYPE_PIN, pin->Element, pin, pin); - else - AddObjectToFlagUndoList(PCB_TYPE_VIA, pin, pin, pin); - ASSIGN_THERM(d->dnum, GET_THERM(d->snum, pin), pin); - CLEAR_THERM(d->snum, pin); - return R_DIR_FOUND_CONTINUE; -} - -/* --------------------------------------------------------------------------- - * moves a polygon between layers - */ -static void *MovePolygonToLayer(pcb_opctx_t *ctx, LayerType * Layer, PolygonType * Polygon) -{ - PolygonTypePtr newone; - struct mptlc d; - - if (TEST_FLAG(PCB_FLAG_LOCK, Polygon)) { - Message(PCB_MSG_DEFAULT, _("Sorry, the object is locked\n")); - return NULL; - } - if (((long int) ctx->move.dst_layer == -1) || (Layer == ctx->move.dst_layer)) - return (Polygon); - AddObjectToMoveToLayerUndoList(PCB_TYPE_POLYGON, Layer, Polygon, Polygon); - if (Layer->On) - ErasePolygon(Polygon); - /* Move all of the thermals with the polygon */ - d.snum = GetLayerNumber(PCB->Data, Layer); - d.dnum = GetLayerNumber(PCB->Data, ctx->move.dst_layer); - d.polygon = Polygon; - d.type = PCB_TYPE_PIN; - r_search(PCB->Data->pin_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d, NULL); - d.type = PCB_TYPE_VIA; - r_search(PCB->Data->via_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d, NULL); - newone = (struct polygon_st *) MovePolygonToLayerLowLevel(ctx, Layer, Polygon, ctx->move.dst_layer); - InitClip(PCB->Data, ctx->move.dst_layer, newone); - if (ctx->move.dst_layer->On) { - DrawPolygon(ctx->move.dst_layer, newone); - Draw(); - } - return (newone); -} - -/* --------------------------------------------------------------------------- * moves the object identified by its data pointers and the type * not we don't bump the undo serial number */