~ubuntu-branches/ubuntu/precise/pcb/precise

« back to all changes in this revision

Viewing changes to src/remove.c

  • Committer: Bazaar Package Importer
  • Author(s): Hamish Moffatt
  • Date: 2005-02-20 13:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050220131400-pfz66g5vhx0azl8f
Tags: 1.99j+20050127-2
* Improved package description: (closes: #295405)
* Fixed dependency: tk84 -> tk8.4 (closes: #295404)
* Updated README.debian (closes: #269578)
* Applied patch to src/djopt.c to allow compilation with gcc-4.0
  (closes: #294319), thanks to Andreas Jochens for the patch.
* Prevent example files from being compressed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: remove.c,v 1.13 2004/08/30 02:52:04 danmc Exp $ */
 
2
 
1
3
/*
2
4
 *                            COPYRIGHT
3
5
 *
24
26
 *
25
27
 */
26
28
 
27
 
static  char    *rcsid = "$Id: remove.c,v 1.6 1998/02/24 22:54:47 cad Exp $";
28
29
 
29
30
/* functions used to remove vias, pins ...
30
31
 */
31
32
 
 
33
#ifdef HAVE_CONFIG_H
 
34
#include "config.h"
 
35
#endif
 
36
 
32
37
#include <memory.h>
33
38
 
34
39
#include "global.h"
42
47
#include "polygon.h"
43
48
#include "rats.h"
44
49
#include "remove.h"
 
50
#include "rtree.h"
45
51
#include "search.h"
46
52
#include "select.h"
47
53
#include "set.h"
48
54
#include "undo.h"
49
55
 
 
56
#ifdef HAVE_LIBDMALLOC
 
57
#include <dmalloc.h>
 
58
#endif
 
59
 
 
60
RCSID("$Id: remove.c,v 1.13 2004/08/30 02:52:04 danmc Exp $");
 
61
 
 
62
 
50
63
/* ---------------------------------------------------------------------------
51
64
 * some local prototypes
52
65
 */
53
 
static  void    *DestroyVia(PinTypePtr);
54
 
static  void    *DestroyRat(RatTypePtr);
55
 
static  void    *DestroyLine(LayerTypePtr, LineTypePtr);
56
 
static  void    *DestroyArc(LayerTypePtr, ArcTypePtr);
57
 
static  void    *DestroyText(LayerTypePtr, TextTypePtr);
58
 
static  void    *DestroyPolygon(LayerTypePtr, PolygonTypePtr);
59
 
static  void    *DestroyElement(ElementTypePtr);
60
 
static  void    *RemoveVia(PinTypePtr);
61
 
static  void    *RemoveRat(RatTypePtr);
62
 
static  void    *DestroyPolygonPoint(LayerTypePtr, PolygonTypePtr,
63
 
                                        PointTypePtr);
64
 
static  void    *RemovePolygonPoint(LayerTypePtr, PolygonTypePtr,
65
 
                                        PointTypePtr);
66
 
static  void    *RemoveLinePoint(LayerTypePtr, LineTypePtr,
67
 
                                        PointTypePtr);
 
66
static void *DestroyVia (PinTypePtr);
 
67
static void *DestroyRat (RatTypePtr);
 
68
static void *DestroyLine (LayerTypePtr, LineTypePtr);
 
69
static void *DestroyArc (LayerTypePtr, ArcTypePtr);
 
70
static void *DestroyText (LayerTypePtr, TextTypePtr);
 
71
static void *DestroyPolygon (LayerTypePtr, PolygonTypePtr);
 
72
static void *DestroyElement (ElementTypePtr);
 
73
static void *RemoveVia (PinTypePtr);
 
74
static void *RemoveRat (RatTypePtr);
 
75
static void *DestroyPolygonPoint (LayerTypePtr, PolygonTypePtr, PointTypePtr);
 
76
static void *RemovePolygonPoint (LayerTypePtr, PolygonTypePtr, PointTypePtr);
 
77
static void *RemoveLinePoint (LayerTypePtr, LineTypePtr, PointTypePtr);
68
78
 
69
79
/* ---------------------------------------------------------------------------
70
80
 * some local types
71
81
 */
72
 
static  ObjectFunctionType      RemoveFunctions = {
73
 
        RemoveLine,
74
 
        RemoveText,
75
 
        RemovePolygon,
76
 
        RemoveVia,
77
 
        RemoveElement,
78
 
        NULL,
79
 
        NULL,
80
 
        NULL,
81
 
        RemoveLinePoint,
82
 
        RemovePolygonPoint,
83
 
        RemoveArc,
84
 
        RemoveRat };
85
 
static  ObjectFunctionType      DestroyFunctions = {
86
 
        DestroyLine,
87
 
        DestroyText,
88
 
        DestroyPolygon,
89
 
        DestroyVia,
90
 
        DestroyElement,
91
 
        NULL,
92
 
        NULL,
93
 
        NULL,
94
 
        NULL,
95
 
        DestroyPolygonPoint,
96
 
        DestroyArc,
97
 
        DestroyRat };
98
 
static  DataTypePtr     DestroyTarget;
99
 
static  Boolean Bulk = False;
 
82
static ObjectFunctionType RemoveFunctions = {
 
83
  RemoveLine,
 
84
  RemoveText,
 
85
  RemovePolygon,
 
86
  RemoveVia,
 
87
  RemoveElement,
 
88
  NULL,
 
89
  NULL,
 
90
  NULL,
 
91
  RemoveLinePoint,
 
92
  RemovePolygonPoint,
 
93
  RemoveArc,
 
94
  RemoveRat
 
95
};
 
96
static ObjectFunctionType DestroyFunctions = {
 
97
  DestroyLine,
 
98
  DestroyText,
 
99
  DestroyPolygon,
 
100
  DestroyVia,
 
101
  DestroyElement,
 
102
  NULL,
 
103
  NULL,
 
104
  NULL,
 
105
  NULL,
 
106
  DestroyPolygonPoint,
 
107
  DestroyArc,
 
108
  DestroyRat
 
109
};
 
110
static DataTypePtr DestroyTarget;
 
111
static Boolean Bulk = False;
100
112
 
101
113
/* ---------------------------------------------------------------------------
102
114
 * remove PCB
103
115
 */
104
 
void RemovePCB(PCBTypePtr Ptr)
 
116
void
 
117
RemovePCB (PCBTypePtr Ptr)
105
118
{
106
 
        ClearUndoList(True);
107
 
        FreePCBMemory(Ptr);
108
 
        SaveFree(Ptr);
 
119
  ClearUndoList (True);
 
120
  FreePCBMemory (Ptr);
 
121
  SaveFree (Ptr);
109
122
}
110
123
 
111
124
/* ---------------------------------------------------------------------------
112
125
 * destroys a via
113
126
 */
114
 
static void *DestroyVia(PinTypePtr Via)
 
127
static void *
 
128
DestroyVia (PinTypePtr Via)
115
129
{
116
 
        *Via = DestroyTarget->Via[--DestroyTarget->ViaN];
117
 
        memset(&DestroyTarget->Via[DestroyTarget->ViaN], 0, sizeof(PinType));
118
 
        SaveFree(Via->Name);
119
 
        return(NULL);
 
130
  r_delete_entry (DestroyTarget->via_tree, (BoxTypePtr) Via);
 
131
  MyFree (&Via->Name);
 
132
  *Via = DestroyTarget->Via[--DestroyTarget->ViaN];
 
133
  r_substitute (DestroyTarget->via_tree, (BoxTypePtr)
 
134
                (BoxType *) & DestroyTarget->Via[DestroyTarget->ViaN],
 
135
                (BoxType *) Via);
 
136
  memset (&DestroyTarget->Via[DestroyTarget->ViaN], 0, sizeof (PinType));
 
137
  return (NULL);
120
138
}
121
139
 
122
140
/* ---------------------------------------------------------------------------
123
141
 * destroys a line from a layer 
124
142
 */
125
 
static void *DestroyLine(LayerTypePtr Layer, LineTypePtr Line)
 
143
static void *
 
144
DestroyLine (LayerTypePtr Layer, LineTypePtr Line)
126
145
{
127
 
        *Line = Layer->Line[--Layer->LineN];
128
 
        memset(&Layer->Line[Layer->LineN], 0, sizeof(LineType));
129
 
        return(NULL);
 
146
  r_delete_entry (Layer->line_tree, (BoxTypePtr) Line);
 
147
  MyFree (&Line->Number);
 
148
  *Line = Layer->Line[--Layer->LineN];
 
149
  /* tricky - line pointers are moved around */
 
150
  r_substitute (Layer->line_tree, (BoxType *) & Layer->Line[Layer->LineN],
 
151
                (BoxType *) Line);
 
152
  memset (&Layer->Line[Layer->LineN], 0, sizeof (LineType));
 
153
  return (NULL);
130
154
}
131
155
 
132
156
/* ---------------------------------------------------------------------------
133
157
 * destroys an arc from a layer 
134
158
 */
135
 
static void *DestroyArc(LayerTypePtr Layer, ArcTypePtr Arc)
 
159
static void *
 
160
DestroyArc (LayerTypePtr Layer, ArcTypePtr Arc)
136
161
{
137
 
        *Arc = Layer->Arc[--Layer->ArcN];
138
 
        memset(&Layer->Arc[Layer->ArcN], 0, sizeof(ArcType));
139
 
        return(NULL);
 
162
  r_delete_entry (Layer->arc_tree, (BoxTypePtr) Arc);
 
163
  *Arc = Layer->Arc[--Layer->ArcN];
 
164
  r_substitute (Layer->arc_tree, (BoxType *) & Layer->Arc[Layer->ArcN],
 
165
                (BoxType *) Arc);
 
166
  memset (&Layer->Arc[Layer->ArcN], 0, sizeof (ArcType));
 
167
  return (NULL);
140
168
}
141
169
 
142
170
/* ---------------------------------------------------------------------------
143
171
 * destroys a rectangle from a layer
144
172
 */
145
 
static void *DestroyPolygon(LayerTypePtr Layer, PolygonTypePtr Polygon)
 
173
static void *
 
174
DestroyPolygon (LayerTypePtr Layer, PolygonTypePtr Polygon)
146
175
{
147
 
        FreePolygonMemory(Polygon);
148
 
        *Polygon = Layer->Polygon[--Layer->PolygonN];
149
 
        memset(&Layer->Polygon[Layer->PolygonN], 0, sizeof(PolygonType));
150
 
        return(NULL);
 
176
  FreePolygonMemory (Polygon);
 
177
  *Polygon = Layer->Polygon[--Layer->PolygonN];
 
178
  memset (&Layer->Polygon[Layer->PolygonN], 0, sizeof (PolygonType));
 
179
  return (NULL);
151
180
}
152
181
 
153
182
/* ---------------------------------------------------------------------------
154
183
 * removes a polygon-point from a polygon and destroys the data
155
184
 */
156
 
static void *DestroyPolygonPoint(LayerTypePtr Layer,
157
 
        PolygonTypePtr Polygon, PointTypePtr Point)
 
185
static void *
 
186
DestroyPolygonPoint (LayerTypePtr Layer,
 
187
                     PolygonTypePtr Polygon, PointTypePtr Point)
158
188
{
159
 
        return(RemovePolygonPoint(Layer, Polygon, Point));
 
189
  PointTypePtr ptr;
 
190
 
 
191
  for (ptr = Point + 1; ptr != &Polygon->Points[Polygon->PointN]; ptr++)
 
192
    {
 
193
      *Point = *ptr;
 
194
      Point = ptr;
 
195
    }
 
196
  Polygon->PointN--;
 
197
  SetPolygonBoundingBox (Polygon);
 
198
  UpdatePIPFlags (NULL, NULL, Layer, True);
 
199
  return (Polygon);
160
200
}
161
201
 
162
202
/* ---------------------------------------------------------------------------
163
203
 * destroys a text from a layer
164
204
 */
165
 
static void *DestroyText(LayerTypePtr Layer, TextTypePtr Text)
 
205
static void *
 
206
DestroyText (LayerTypePtr Layer, TextTypePtr Text)
166
207
{
167
 
        SaveFree(Text->TextString);
168
 
        *Text = Layer->Text[--Layer->TextN];
169
 
        memset(&Layer->Text[Layer->TextN], 0, sizeof(TextType));
170
 
        return(NULL);
 
208
  MyFree (&Text->TextString);
 
209
  r_delete_entry (Layer->text_tree, (BoxTypePtr) Text);
 
210
  *Text = Layer->Text[--Layer->TextN];
 
211
  r_substitute (Layer->text_tree, (BoxType *) & Layer->Text[Layer->TextN],
 
212
                (BoxType *) Text);
 
213
  memset (&Layer->Text[Layer->TextN], 0, sizeof (TextType));
 
214
  return (NULL);
171
215
}
172
216
 
173
217
/* ---------------------------------------------------------------------------
174
218
 * destroys a element
175
219
 */
176
 
static void *DestroyElement(ElementTypePtr Element)
 
220
static void *
 
221
DestroyElement (ElementTypePtr Element)
177
222
{
178
 
        FreeElementMemory(Element);
179
 
        *Element = DestroyTarget->Element[--DestroyTarget->ElementN];
180
 
        memset(&DestroyTarget->Element[DestroyTarget->ElementN], 0, sizeof(ElementType));
181
 
        return(NULL);
 
223
  if (DestroyTarget->element_tree)
 
224
    r_delete_entry (DestroyTarget->element_tree, (BoxType *) Element);
 
225
  if (DestroyTarget->pin_tree)
 
226
    {
 
227
      PIN_LOOP (Element);
 
228
      {
 
229
        r_delete_entry (DestroyTarget->pin_tree, (BoxType *) pin);
 
230
      }
 
231
      END_LOOP;
 
232
    }
 
233
  if (DestroyTarget->pad_tree)
 
234
    {
 
235
      PAD_LOOP (Element);
 
236
      {
 
237
        r_delete_entry (DestroyTarget->pad_tree, (BoxType *) pad);
 
238
      }
 
239
      END_LOOP;
 
240
    }
 
241
  ELEMENTTEXT_LOOP (Element);
 
242
  {
 
243
    if (DestroyTarget->name_tree[n])
 
244
      r_delete_entry (DestroyTarget->name_tree[n], (BoxType *) text);
 
245
  }
 
246
  END_LOOP;
 
247
  FreeElementMemory (Element);
 
248
  *Element = DestroyTarget->Element[--DestroyTarget->ElementN];
 
249
  /* deal with changed element pointer */
 
250
  r_substitute (DestroyTarget->element_tree,
 
251
                (BoxType *) & DestroyTarget->Element[DestroyTarget->ElementN],
 
252
                (BoxType *) Element);
 
253
  PIN_LOOP (Element);
 
254
  {
 
255
    pin->Element = Element;
 
256
  }
 
257
  END_LOOP;
 
258
  PAD_LOOP (Element);
 
259
  {
 
260
    pad->Element = Element;
 
261
  }
 
262
  END_LOOP;
 
263
  ELEMENTTEXT_LOOP (Element);
 
264
  {
 
265
    r_substitute (DestroyTarget->name_tree[n],
 
266
                  (BoxType *) & DestroyTarget->Element[DestroyTarget->
 
267
                                                       ElementN].Name[n],
 
268
                  (BoxType *) text);
 
269
    text->Element = Element;
 
270
  }
 
271
  END_LOOP;
 
272
  memset (&DestroyTarget->Element[DestroyTarget->ElementN], 0,
 
273
          sizeof (ElementType));
 
274
  return (NULL);
182
275
}
183
276
 
184
277
/* ---------------------------------------------------------------------------
185
278
 * destroys a rat
186
279
 */
187
 
static void *DestroyRat(RatTypePtr Rat)
 
280
static void *
 
281
DestroyRat (RatTypePtr Rat)
188
282
{
189
 
        *Rat = DestroyTarget->Rat[--DestroyTarget->RatN];
190
 
        memset(&DestroyTarget->Rat[DestroyTarget->RatN], 0, sizeof(RatType));
191
 
        return(NULL);
 
283
  if (DestroyTarget->rat_tree)
 
284
    r_delete_entry (DestroyTarget->rat_tree, &Rat->BoundingBox);
 
285
  *Rat = DestroyTarget->Rat[--DestroyTarget->RatN];
 
286
  r_substitute (DestroyTarget->rat_tree,
 
287
                &DestroyTarget->Rat[DestroyTarget->RatN].BoundingBox,
 
288
                &Rat->BoundingBox);
 
289
  memset (&DestroyTarget->Rat[DestroyTarget->RatN], 0, sizeof (RatType));
 
290
  return (NULL);
192
291
}
193
292
 
194
293
 
195
294
/* ---------------------------------------------------------------------------
196
295
 * removes a via
197
296
 */
198
 
static void *RemoveVia(PinTypePtr Via)
 
297
static void *
 
298
RemoveVia (PinTypePtr Via)
199
299
{
200
 
                /* erase from screen and memory */
201
 
        if (PCB->ViaOn)
202
 
        {
203
 
                EraseVia(Via);
204
 
                if (!Bulk)
205
 
                        Draw();
206
 
        }
207
 
        MoveObjectToRemoveUndoList(VIA_TYPE, Via, Via, Via);
208
 
        return(NULL);
 
300
  /* erase from screen and memory */
 
301
  if (PCB->ViaOn)
 
302
    {
 
303
      EraseVia (Via);
 
304
      if (!Bulk)
 
305
        Draw ();
 
306
    }
 
307
  MoveObjectToRemoveUndoList (VIA_TYPE, Via, Via, Via);
 
308
  return (NULL);
209
309
}
210
310
 
211
311
/* ---------------------------------------------------------------------------
212
312
 * removes a rat
213
313
 */
214
 
static void *RemoveRat(RatTypePtr Rat)
 
314
static void *
 
315
RemoveRat (RatTypePtr Rat)
215
316
{
216
 
                /* erase from screen and memory */
217
 
        if (PCB->RatOn)
218
 
        {
219
 
                EraseRat(Rat);
220
 
                if (!Bulk)
221
 
                        Draw();
222
 
        }
223
 
        MoveObjectToRemoveUndoList(RATLINE_TYPE, Rat, Rat, Rat);
224
 
        return(NULL);
 
317
  /* erase from screen and memory */
 
318
  if (PCB->RatOn)
 
319
    {
 
320
      EraseRat (Rat);
 
321
      if (!Bulk)
 
322
        Draw ();
 
323
    }
 
324
  MoveObjectToRemoveUndoList (RATLINE_TYPE, Rat, Rat, Rat);
 
325
  return (NULL);
225
326
}
226
327
 
227
328
/* ---------------------------------------------------------------------------
228
329
 * removes a line point 
229
330
 */
230
 
static void *RemoveLinePoint(LayerTypePtr Layer, LineTypePtr Line, PointTypePtr Point)
 
331
static void *
 
332
RemoveLinePoint (LayerTypePtr Layer, LineTypePtr Line, PointTypePtr Point)
231
333
{
232
 
        PointType       oldPoint;
 
334
  PointType oldPoint;
233
335
 
234
 
        if (&Line->Point1 == Point)
235
 
                oldPoint = Line->Point2;
236
 
        else
237
 
                oldPoint = Line->Point1;
238
 
        LINE_LOOP(Layer, {
239
 
                if (line == Line)
240
 
                        continue;
241
 
                if ((line->Point1.X == Point->X) && (line->Point1.Y == Point->Y))
242
 
                {
243
 
                        SaveUndoSerialNumber();
244
 
                        MoveObject(LINEPOINT_TYPE, Layer, line, &line->Point1,
245
 
                                oldPoint.X - line->Point1.X, oldPoint.Y - line->Point1.Y);
246
 
                        RestoreUndoSerialNumber();
247
 
                        break;
248
 
                }
249
 
                if ((line->Point2.X == Point->X) && (line->Point2.Y == Point->Y))
250
 
                {
251
 
                        SaveUndoSerialNumber();
252
 
                        MoveObject(LINEPOINT_TYPE, Layer, line, &line->Point2,
253
 
                                oldPoint.X - line->Point2.X, oldPoint.Y - line->Point2.Y);
254
 
                        RestoreUndoSerialNumber();
255
 
                        break;
256
 
                }
257
 
        });
258
 
        return(RemoveLine(Layer, Line));
 
336
  if (&Line->Point1 == Point)
 
337
    oldPoint = Line->Point2;
 
338
  else
 
339
    oldPoint = Line->Point1;
 
340
  LINE_LOOP (Layer);
 
341
  {
 
342
    if (line == Line)
 
343
      continue;
 
344
    if ((line->Point1.X == Point->X) && (line->Point1.Y == Point->Y))
 
345
      {
 
346
        MoveObject (LINEPOINT_TYPE, Layer, line, &line->Point1,
 
347
                    oldPoint.X - line->Point1.X, oldPoint.Y - line->Point1.Y);
 
348
        break;
 
349
      }
 
350
    if ((line->Point2.X == Point->X) && (line->Point2.Y == Point->Y))
 
351
      {
 
352
        MoveObject (LINEPOINT_TYPE, Layer, line, &line->Point2,
 
353
                    oldPoint.X - line->Point2.X, oldPoint.Y - line->Point2.Y);
 
354
        break;
 
355
      }
 
356
  }
 
357
  END_LOOP;
 
358
  return (RemoveLine (Layer, Line));
259
359
}
260
360
 
261
361
/* ---------------------------------------------------------------------------
262
362
 * removes a line from a layer 
263
363
 */
264
 
void *RemoveLine(LayerTypePtr Layer, LineTypePtr Line)
 
364
void *
 
365
RemoveLine (LayerTypePtr Layer, LineTypePtr Line)
265
366
{
266
 
                /* erase from screen */
267
 
        if (Layer->On)
268
 
        {
269
 
                EraseLine(Line);
270
 
                if (!Bulk)
271
 
                        Draw();
272
 
        }
273
 
        MoveObjectToRemoveUndoList(LINE_TYPE, Layer, Line, Line);
274
 
        return(NULL);
 
367
  /* erase from screen */
 
368
  if (Layer->On)
 
369
    {
 
370
      EraseLine (Line);
 
371
      if (!Bulk)
 
372
        Draw ();
 
373
    }
 
374
  MoveObjectToRemoveUndoList (LINE_TYPE, Layer, Line, Line);
 
375
  return (NULL);
275
376
}
276
377
 
277
378
/* ---------------------------------------------------------------------------
278
379
 * removes an arc from a layer 
279
380
 */
280
 
void *RemoveArc(LayerTypePtr Layer, ArcTypePtr Arc)
 
381
void *
 
382
RemoveArc (LayerTypePtr Layer, ArcTypePtr Arc)
281
383
{
282
 
                /* erase from screen */
283
 
        if (Layer->On)
284
 
        {
285
 
                EraseArc(Arc);
286
 
                if (!Bulk)
287
 
                        Draw();
288
 
        }
289
 
        MoveObjectToRemoveUndoList(ARC_TYPE, Layer, Arc, Arc);
290
 
        return(NULL);
 
384
  /* erase from screen */
 
385
  if (Layer->On)
 
386
    {
 
387
      EraseArc (Arc);
 
388
      if (!Bulk)
 
389
        Draw ();
 
390
    }
 
391
  MoveObjectToRemoveUndoList (ARC_TYPE, Layer, Arc, Arc);
 
392
  return (NULL);
291
393
}
292
394
 
293
395
/* ---------------------------------------------------------------------------
294
396
 * removes a text from a layer
295
397
 */
296
 
void *RemoveText(LayerTypePtr Layer, TextTypePtr Text)
 
398
void *
 
399
RemoveText (LayerTypePtr Layer, TextTypePtr Text)
297
400
{
298
 
                /* erase from screen */
299
 
        if (Layer->On)
300
 
        {
301
 
                EraseText(Text);
302
 
                if (!Bulk)
303
 
                        Draw();
304
 
        }
305
 
        MoveObjectToRemoveUndoList(TEXT_TYPE, Layer, Text, Text);
306
 
        return(NULL);
 
401
  /* erase from screen */
 
402
  if (Layer->On)
 
403
    {
 
404
      EraseText (Text);
 
405
      if (!Bulk)
 
406
        Draw ();
 
407
    }
 
408
  MoveObjectToRemoveUndoList (TEXT_TYPE, Layer, Text, Text);
 
409
  return (NULL);
307
410
}
308
411
 
309
412
/* ---------------------------------------------------------------------------
310
413
 * removes a polygon from a layer
311
414
 */
312
 
void *RemovePolygon(LayerTypePtr Layer, PolygonTypePtr Polygon)
 
415
void *
 
416
RemovePolygon (LayerTypePtr Layer, PolygonTypePtr Polygon)
313
417
{
314
 
                /* erase from screen */
315
 
        if (Layer->On)
316
 
        {
317
 
                ErasePolygon(Polygon);
318
 
                if (!Bulk)
319
 
                        Draw();
320
 
        }
321
 
        MoveObjectToRemoveUndoList(POLYGON_TYPE, Layer, Polygon, Polygon);
322
 
        UpdatePIPFlags(NULL, NULL, Layer, NULL, True);
323
 
        return(NULL);
 
418
  /* erase from screen */
 
419
  if (Layer->On)
 
420
    {
 
421
      ErasePolygon (Polygon);
 
422
      if (!Bulk)
 
423
        Draw ();
 
424
    }
 
425
  MoveObjectToRemoveUndoList (POLYGON_TYPE, Layer, Polygon, Polygon);
 
426
  UpdatePIPFlags (NULL, NULL, Layer, True);
 
427
  return (NULL);
324
428
}
325
429
 
326
430
/* ---------------------------------------------------------------------------
327
431
 * removes a polygon-point from a polygon
328
432
 */
329
 
static void *RemovePolygonPoint(LayerTypePtr Layer,
330
 
        PolygonTypePtr Polygon, PointTypePtr Point)
 
433
static void *
 
434
RemovePolygonPoint (LayerTypePtr Layer,
 
435
                    PolygonTypePtr Polygon, PointTypePtr Point)
331
436
{
332
 
        PointTypePtr    ptr;
333
 
        Cardinal        index = 0;
334
 
 
335
 
                /* insert the polygon-point into the undo list */
336
 
        POLYGONPOINT_LOOP(Polygon,
337
 
                if (point == Point)
338
 
                {
339
 
                        index = n;
340
 
                        break;
341
 
                });
342
 
        AddObjectToRemovePointUndoList(POLYGONPOINT_TYPE, Layer, Polygon, index);
343
 
 
344
 
        if (Layer->On)
345
 
                ErasePolygon(Polygon);
346
 
 
347
 
                /* remove point from list, keep point order */
348
 
        for (ptr = Point+1; ptr != &Polygon->Points[Polygon->PointN]; ptr++)
349
 
        {
350
 
                *Point = *ptr;
351
 
                Point = ptr;
352
 
        }
353
 
        Polygon->PointN--;
354
 
        SetPolygonBoundingBox(Polygon);
355
 
        RemoveExcessPolygonPoints(Layer, Polygon);
356
 
 
357
 
                /* redraw polygon if necessary */
358
 
        if (Layer->On)
359
 
        {
360
 
                DrawPolygon(Layer, Polygon, 0);
361
 
                if (!Bulk)
362
 
                        Draw();
363
 
        }
364
 
        return(NULL);
 
437
  PointTypePtr ptr;
 
438
  Cardinal index = 0;
 
439
 
 
440
  /* insert the polygon-point into the undo list */
 
441
  POLYGONPOINT_LOOP (Polygon);
 
442
  {
 
443
    if (point == Point)
 
444
      {
 
445
        index = n;
 
446
        break;
 
447
      }
 
448
  }
 
449
  END_LOOP;
 
450
  AddObjectToRemovePointUndoList (POLYGONPOINT_TYPE, Layer, Polygon, index);
 
451
 
 
452
  if (Layer->On)
 
453
    ErasePolygon (Polygon);
 
454
 
 
455
  /* remove point from list, keep point order */
 
456
  for (ptr = Point + 1; ptr != &Polygon->Points[Polygon->PointN]; ptr++)
 
457
    {
 
458
      *Point = *ptr;
 
459
      Point = ptr;
 
460
    }
 
461
  Polygon->PointN--;
 
462
  SetPolygonBoundingBox (Polygon);
 
463
  RemoveExcessPolygonPoints (Layer, Polygon);
 
464
  UpdatePIPFlags (NULL, NULL, Layer, True);
 
465
  /* redraw polygon if necessary */
 
466
  if (Layer->On)
 
467
    {
 
468
      DrawPolygon (Layer, Polygon, 0);
 
469
      if (!Bulk)
 
470
        Draw ();
 
471
    }
 
472
  return (NULL);
365
473
}
366
474
 
367
475
/* ---------------------------------------------------------------------------
368
476
 * removes an element
369
477
 */
370
 
void *RemoveElement(ElementTypePtr Element)
 
478
void *
 
479
RemoveElement (ElementTypePtr Element)
371
480
{
372
 
                /* erase from screen */
373
 
        if ((PCB->ElementOn || PCB->PinOn) &&
374
 
                (FRONT(Element) || PCB->InvisibleObjectsOn))
375
 
        {
376
 
                EraseElement(Element);
377
 
                if (!Bulk)
378
 
                        Draw();
379
 
        }
380
 
        MoveObjectToRemoveUndoList(ELEMENT_TYPE, Element, Element, Element);
381
 
        return(NULL);
 
481
  /* erase from screen */
 
482
  if ((PCB->ElementOn || PCB->PinOn) &&
 
483
      (FRONT (Element) || PCB->InvisibleObjectsOn))
 
484
    {
 
485
      EraseElement (Element);
 
486
      if (!Bulk)
 
487
        Draw ();
 
488
    }
 
489
  MoveObjectToRemoveUndoList (ELEMENT_TYPE, Element, Element, Element);
 
490
  return (NULL);
382
491
}
383
492
 
384
493
/* ----------------------------------------------------------------------
385
494
 * removes all selected and visible objects
386
495
 * returns True if any objects have been removed
387
496
 */
388
 
Boolean RemoveSelected(void)
 
497
Boolean
 
498
RemoveSelected (void)
389
499
{
390
 
        Bulk = True;
391
 
        if (SelectedOperation(&RemoveFunctions, False))
392
 
        {
393
 
                IncrementUndoSerialNumber();
394
 
                Draw();
395
 
                Bulk = False;
396
 
                return(True);
397
 
        }
398
 
        Bulk = False;
399
 
        return(False);
 
500
  Bulk = True;
 
501
  if (SelectedOperation (&RemoveFunctions, False, ALL_TYPES))
 
502
    {
 
503
      IncrementUndoSerialNumber ();
 
504
      Draw ();
 
505
      Bulk = False;
 
506
      return (True);
 
507
    }
 
508
  Bulk = False;
 
509
  return (False);
400
510
}
401
511
 
402
512
/* ---------------------------------------------------------------------------
403
513
 * remove object as referred by pointers and type,
404
514
 * allocated memory is passed to the 'remove undo' list
405
515
 */
406
 
void *RemoveObject(int Type, void *Ptr1, void *Ptr2, void *Ptr3)
 
516
void *
 
517
RemoveObject (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
407
518
{
408
 
        void    *ptr = ObjectOperation(&RemoveFunctions, Type, Ptr1, Ptr2, Ptr3);
409
 
 
410
 
        IncrementUndoSerialNumber();
411
 
        return(ptr);
 
519
  void *ptr = ObjectOperation (&RemoveFunctions, Type, Ptr1, Ptr2, Ptr3);
 
520
  return (ptr);
412
521
}
413
522
 
414
523
/* ---------------------------------------------------------------------------
415
524
 * DeleteRats - deletes rat lines only
416
525
 * can delete all rat lines, or only selected one
417
526
 */
418
 
 
419
 
Boolean DeleteRats(Boolean selected)
420
 
 {
421
 
        Boolean changed = False;
422
 
        
423
 
        Bulk = True;
424
 
        RAT_LOOP(PCB->Data,
425
 
                if ((!selected) || TEST_FLAG(SELECTEDFLAG, line))
426
 
                {
427
 
                        changed = True;
428
 
                        RemoveRat(line);
429
 
                }
430
 
        );
431
 
        Bulk = False;
432
 
        if (changed)
433
 
        {
434
 
                Draw();
435
 
                IncrementUndoSerialNumber();
436
 
        }
437
 
        return(changed);
 
527
 
 
528
Boolean
 
529
DeleteRats (Boolean selected)
 
530
{
 
531
  Boolean changed = False;
 
532
 
 
533
  Bulk = True;
 
534
  RAT_LOOP (PCB->Data);
 
535
  {
 
536
    if ((!selected) || TEST_FLAG (SELECTEDFLAG, line))
 
537
      {
 
538
        changed = True;
 
539
        RemoveRat (line);
 
540
      }
 
541
  }
 
542
  END_LOOP;
 
543
  Bulk = False;
 
544
  if (changed)
 
545
    {
 
546
      Draw ();
 
547
      IncrementUndoSerialNumber ();
 
548
    }
 
549
  return (changed);
438
550
}
439
551
 
440
552
/* ---------------------------------------------------------------------------
441
553
 * remove object as referred by pointers and type
442
554
 * allocated memory is destroyed assumed to already be erased
443
555
 */
444
 
void *DestroyObject(DataTypePtr Target, int Type, void *Ptr1, void *Ptr2,
445
 
        void *Ptr3)
 
556
void *
 
557
DestroyObject (DataTypePtr Target, int Type, void *Ptr1, void *Ptr2,
 
558
               void *Ptr3)
446
559
{
447
 
        DestroyTarget = Target;
448
 
        return(ObjectOperation(&DestroyFunctions, Type, Ptr1, Ptr2, Ptr3));
 
560
  DestroyTarget = Target;
 
561
  return (ObjectOperation (&DestroyFunctions, Type, Ptr1, Ptr2, Ptr3));
449
562
}