Jspice3
cutwire.c File Reference
#include "spice.h"
#include "sced.h"
Include dependency graph for cutwire.c:

Go to the source code of this file.

Functions

static int do_break ()
 
static int break_wire ()
 
static struct pintersect_y ()
 
static struct pintersect_x ()
 
void Break (int *LookedAhead)
 
struct pCopyPath (struct p *path)
 
static int do_break (long RefX, long RefY, int Flag)
 
static int break_wire (long RefX, long RefY, struct o *Pointer, int Flag)
 
static struct pintersect_y (struct p *p1, struct p *p2, long X)
 
static struct pintersect_x (struct p *p1, struct p *p2, long Y)
 

Variables

char * MenuBREAK
 
char * MenuUNDO
 

Function Documentation

void Break ( int *  LookedAhead)

Definition at line 32 of file cutwire.c.

35 {
36  int GotOne = False;
37  int Undo = False;
38  int FirstTime = True;
39  int Modified = 0;
40  struct ka BB, OldSelectQBB;
41  long OldX, OldY;
42  char Types[4];
43 
45 
46  Types[0] = CDWIRE;
47  Types[1] = '\0';
48 
49  if (AreTypesInQ(Types))
50  GotOne = True;
51 top:
52 
53  if (Not GotOne) {
54  ShowPrompt("Point to wire to break.");
55  switch (PointLoop(LookedAhead)) {
56  case PL_ESC:
57  case PL_CMD:
58  goto quit;
59  case PL_UND:
60  if (FirstTime) goto quit;
62  SQRestore(True);
63  EraseBox(&OldSelectQBB);
64  Redisplay(&OldSelectQBB);
65  Modified--;
66  Undo = True;
68  break;
69  case PL_PCW:
70  SelectTypes(Types);
71  if (Not AreTypesInQ(Types))
72  goto top;;
73  }
74  }
75 
76  ShowPrompt("Point on the break line.");
77 
78 next:
79  switch (PointLoop(LookedAhead)) {
80  case PL_ESC:
81  case PL_CMD:
82  goto quit;
83  case PL_UND:
85  if (Not GotOne) {
86  if (Undo == False) {
87  SQDesel(Types);
88  EraseBox(&OldSelectQBB);
89  Redisplay(&OldSelectQBB);
91  }
92  else {
93  (void) do_break(OldX,OldY,True);
94  EraseBox(&OldSelectQBB);
95  Redisplay(&OldSelectQBB);
96  Modified++;
97  Undo = False;
98  }
99  goto top;
100  }
101  if (FirstTime)
102  goto quit;
103  if (Undo == False) {
105  ShowPrompt("Point on the break line.");
106  SQRestore(True);
107  EraseBox(&OldSelectQBB);
108  Redisplay(&OldSelectQBB);
109  Modified--;
110  Undo = True;
111  }
112  else {
113  (void) do_break(OldX,OldY,True);
114  EraseBox(&OldSelectQBB);
115  Redisplay(&OldSelectQBB);
116  ErasePrompt();
118  Modified++;
119  Undo = False;
120  }
122  goto next;
123  case PL_PCW:
124  if (Not FirstTime And GotOne And Not Undo) goto next;
126  SQRestore(False);
128  OldX = SCursor.kcX;
129  OldY = SCursor.kcY;
130  OldSelectQBB = SelectQBB;
131  EraseBox(&OldSelectQBB);
132  Redisplay(&OldSelectQBB);
133  FirstTime = False;
134  Modified++;
135  Undo = False;
136  if (Not GotOne)
137  goto top;
138  ErasePrompt();
140  goto next;
141  }
142  }
143 
144 quit:
145  SQRestore(False);
146  if (Not GotOne And AreTypesInQ(Types)) {
147  SQComputeBB();
148  SQDesel(Types);
151  }
152  if (Modified)
154  ErasePrompt();
157 }
#define PL_ESC
Definition: sced.h:62
void ErasePrompt()
Definition: viewport.c:538
void Redisplay()
char * MenuBREAK
Definition: scedintr.c:67
int AreTypesInQ()
#define PL_UND
Definition: sced.h:63
int kpModified
Definition: sced.h:261
int PointLoop()
struct kc SCursor
Definition: init.c:21
void SQRestore()
#define Not
Definition: cdmacs.h:16
#define PL_PCW
Definition: sced.h:65
Definition: sced.h:111
long kcY
Definition: sced.h:102
static int do_break()
void Undo()
Definition: bascmd.c:43
void MenuDeselect()
struct kp Parameters
Definition: init.c:19
#define True
Definition: scedstub.c:16
void EraseBox()
void SQDesel()
void SelectTypes()
#define CDWIRE
Definition: cddefs.h:47
long kcX
Definition: sced.h:102
#define And
Definition: cdmacs.h:14
#define False
Definition: scedstub.c:15
#define PL_CMD
Definition: sced.h:64
char * MenuUNDO
Definition: scedintr.c:108
void MenuSelect()
void ShowPrompt(char *str)
Definition: scedstub.c:71
struct ka SelectQBB
Definition: scedext.h:65
void SQComputeBB()
Definition: choose.c:749
static int break_wire ( )
static
static int break_wire ( long  RefX,
long  RefY,
struct o Pointer,
int  Flag 
)
static

Definition at line 208 of file cutwire.c.

213 {
214  struct p *pp,*px,*pTemp,*pNew,*pInt;
215  struct o *NewPointer;
216  struct ka BB;
217  int VertCut;
218  long *InPath();
219 
220  if (InPath(20,((struct w *)Pointer->oRep)->wPath,RefX,RefY) != NULL) {
221  if (Not Flag) return (True);
222  px = CopyPath(((struct w *)Pointer->oRep)->wPath);
223  for (pNew = pp = px; pp And pp->pSucc; pp = pTemp) {
224  pTemp = pp->pSucc;
225  if (
226  ( pp->pX == pp->pSucc->pX && RefX == pp->pX And
227  ((pp->pY <= RefY And pp->pSucc->pY > RefY) Or
228  (pp->pY >= RefY And pp->pSucc->pY < RefY)) )
229  Or
230  ( pp->pY == pp->pSucc->pY && RefY == pp->pY And
231  ((pp->pX <= RefX And pp->pSucc->pX > RefX) Or
232  (pp->pX >= RefX And pp->pSucc->pX < RefX)) )) {
233 
234  pp->pSucc = NULL;
235  pInt = alloc(p);
236  if (pInt == NULL) MallocFailed();
237  pInt->pX = RefX;
238  pInt->pY = RefY;
239 
240  if (pp->pX != pInt->pX Or pp->pY != pInt->pY) {
241  pp->pSucc = pInt;
242  pInt->pSucc = NULL;
243  pInt = CopyPath(pInt);
244  }
246  ((struct w *)Pointer->oRep)->wWidth,pNew,&NewPointer))
247  MallocFailed();
248  AssignWireProperties(NewPointer);
249  NewPointer->oInfo = SQ_NEW;
250  SQInsert(NewPointer);
251  pInt->pSucc = pTemp;
252  pNew = pInt;
253  }
254  }
255  }
256  else {
257 
258  CDStatusInt = CDBB(Parameters.kpCellDesc,Pointer,&BB.kaLeft,
259  &BB.kaBottom,&BB.kaRight,&BB.kaTop);
260 
261  VertCut = False;
262  if (Parameters.kpRotationAngle == 0 ||
263  Parameters.kpRotationAngle == 180) VertCut = True;
264 
265  if (VertCut && (RefX <= BB.kaLeft || RefX >= BB.kaRight))
266  return (False);
267  if (!VertCut && (RefY <= BB.kaBottom Or RefY >= BB.kaTop))
268  return (False);
269 
270  if (Not Flag) return (True);
271  px = CopyPath(((struct w *)Pointer->oRep)->wPath);
272  for (pNew = pp = px; pp And pp->pSucc; pp = pTemp) {
273  pTemp = pp->pSucc;
274  if (
275  ( VertCut And
276  ((pp->pX <= RefX And pp->pSucc->pX > RefX) Or
277  (pp->pX >= RefX And pp->pSucc->pX < RefX)) )
278  Or
279  ( !VertCut And
280  ((pp->pY <= RefY And pp->pSucc->pY > RefY) Or
281  (pp->pY >= RefY And pp->pSucc->pY < RefY)) )) {
282 
283  pp->pSucc = NULL;
284 
285  if (VertCut)
286  pInt = intersect_y(pp,pTemp,RefX);
287  else
288  pInt = intersect_x(pp,pTemp,RefY);
289 
290  if (pp->pX != pInt->pX Or pp->pY != pInt->pY) {
291  pp->pSucc = pInt;
292  pInt->pSucc = NULL;
293  pInt = CopyPath(pInt);
294  }
296  ((struct w *)Pointer->oRep)->wWidth,
297  pNew,&NewPointer)) MallocFailed();
298  AssignWireProperties(NewPointer);
299  NewPointer->oInfo = SQ_NEW;
300  SQInsert(NewPointer);
301  pInt->pSucc = pTemp;
302  pNew = pInt;
303  }
304  }
305  }
307  ((struct w *)Pointer->oRep)->wWidth,pNew,&NewPointer))
308  MallocFailed();
309  AssignWireProperties(NewPointer);
310  NewPointer->oInfo = SQ_NEW;
311  SQInsert(NewPointer);
312  Pointer->oInfo = SQ_GONE;
313  return (True);
314 }
#define Or
Definition: cdmacs.h:15
#define SQ_GONE
Definition: sced.h:347
void SQInsert()
Definition: objects.c:1183
struct s * kpCellDesc
Definition: sced.h:207
#define Not
Definition: cdmacs.h:16
int CDStatusInt
Definition: cd.c:75
static struct p * intersect_x()
Definition: cddefs.h:169
int CDMakeWire()
Definition: sced.h:111
Definition: cddefs.h:215
#define alloc(type)
Definition: cdmacs.h:21
long pY
Definition: cddefs.h:216
void MallocFailed()
Definition: scedintr.c:857
char oLayer
Definition: cddefs.h:149
#define SQ_NEW
Definition: sced.h:350
#define NULL
Definition: spdefs.h:121
struct kp Parameters
Definition: init.c:19
long * InPath()
#define True
Definition: scedstub.c:16
int kpRotationAngle
Definition: sced.h:282
struct o * oRep
Definition: cddefs.h:144
Definition: cddefs.h:142
static struct p * intersect_y()
long pX
Definition: cddefs.h:216
void AssignWireProperties()
#define And
Definition: cdmacs.h:14
struct p * CopyPath(struct p *path)
Definition: cutwire.c:161
int CDBB()
#define False
Definition: scedstub.c:15
struct p * pSucc
Definition: cddefs.h:217
short oInfo
Definition: cddefs.h:147
struct p* CopyPath ( struct p path)

Definition at line 161 of file cutwire.c.

164 {
165  struct p *pcopy,*pc = NULL,*pp = path;
166 
167  if (path == NULL) return (NULL);
168  pcopy = pc = alloc(p);
169  pc->pX = pp->pX;
170  pc->pY = pp->pY;
171  pp = pp->pSucc;
172  while (pp) {
173  pc->pSucc = alloc(p);
174  pc = pc->pSucc;
175  pc->pX = pp->pX;
176  pc->pY = pp->pY;
177  pp = pp->pSucc;
178  }
179  pc->pSucc = NULL;
180  return (pcopy);
181 }
Definition: objects.c:1183
Definition: cddefs.h:215
#define alloc(type)
Definition: cdmacs.h:21
long pY
Definition: cddefs.h:216
#define NULL
Definition: spdefs.h:121
long pX
Definition: cddefs.h:216
struct mfbpc pc
Definition: mfbopen.c:14
static char * path
Definition: paths.c:13
struct p * pSucc
Definition: cddefs.h:217
static int do_break ( )
static
static int do_break ( long  RefX,
long  RefY,
int  Flag 
)
static

Definition at line 185 of file cutwire.c.

189 {
190  struct ks *SQDesc;
191  int DidBreak = False;
192 
193  /* If Flag is False, returns True if a break would be performed,
194  * but operation is not done.
195  */
196  for (SQDesc = SelectQHead; SQDesc; SQDesc = SQDesc->ksSucc) {
197  if (SQDesc->ksPointer->oInfo == SQ_GONE) continue;
198  if (SQDesc->ksPointer->oType == CDWIRE) {
199  DidBreak = break_wire(RefX,RefY,SQDesc->ksPointer,Flag);
200  continue;
201  }
202  }
203  return (DidBreak);
204 }
#define SQ_GONE
Definition: sced.h:347
struct o * ksPointer
Definition: sced.h:335
char oType
Definition: cddefs.h:148
struct ks * ksSucc
Definition: sced.h:334
struct ks * SelectQHead
Definition: scedext.h:64
#define CDWIRE
Definition: cddefs.h:47
Definition: sced.h:333
#define False
Definition: scedstub.c:15
static int break_wire()
short oInfo
Definition: cddefs.h:147
static struct p* intersect_x ( )
static
static struct p* intersect_x ( struct p p1,
struct p p2,
long  Y 
)
static

Definition at line 333 of file cutwire.c.

337 {
338  struct p *pp;
339 
340  pp = alloc(p);
341  pp->pX = p1->pX + ((Y - p1->pY)*(p2->pX - p1->pX))/(p2->pY - p1->pY);
342  pp->pY = Y;
343  return (pp);
344 }
Definition: objects.c:1183
Definition: cddefs.h:215
#define alloc(type)
Definition: cdmacs.h:21
long pY
Definition: cddefs.h:216
long pX
Definition: cddefs.h:216
long Y
Definition: actions.c:450
static struct p* intersect_y ( )
static
static struct p* intersect_y ( struct p p1,
struct p p2,
long  X 
)
static

Definition at line 318 of file cutwire.c.

322 {
323  struct p *pp;
324 
325  pp = alloc(p);
326  pp->pX = X;
327  pp->pY = p1->pY + ((X - p1->pX)*(p2->pY - p1->pY))/(p2->pX - p1->pX);
328  return (pp);
329 }
Definition: objects.c:1183
Definition: cddefs.h:215
#define alloc(type)
Definition: cdmacs.h:21
long pY
Definition: cddefs.h:216
long X
Definition: actions.c:450
long pX
Definition: cddefs.h:216

Variable Documentation

char* MenuBREAK

Definition at line 67 of file scedintr.c.

char* MenuUNDO

Definition at line 108 of file scedintr.c.