MCPcopy Create free account
hub / github.com/Qucs/qucs / insertComponentNodes

Method insertComponentNodes

qucs/schematic_element.cpp:2482–2518  ·  view source on GitHub ↗

---------------------------------------------------

Source from the content-addressed store, hash-verified

2480
2481// ---------------------------------------------------
2482void Schematic::insertComponentNodes(Component *c, bool noOptimize)
2483{
2484 // simulation components do not have ports
2485 if (c->Ports.empty()) return;
2486
2487 // connect every node of the component to corresponding schematic node
2488 foreach(Port *pp, c->Ports)
2489 pp->Connection = insertNode(pp->x+c->cx, pp->y+c->cy, c);
2490
2491 if(noOptimize) return;
2492
2493 Node *pn;
2494 Element *pe, *pe1;
2495 Q3PtrList<Element> *pL;
2496 // if component over wire then delete this wire
2497 QListIterator<Port *> iport(c->Ports);
2498 // omit the first element
2499 Port *pp = iport.next();
2500 while (iport.hasNext())
2501 {
2502 pp = iport.next();
2503 pn = pp->Connection;
2504 for(pe = pn->Connections.first(); pe!=0; pe = pn->Connections.next())
2505 if(pe->Type == isWire)
2506 {
2507 if(((Wire*)pe)->Port1 == pn) pL = &(((Wire*)pe)->Port2->Connections);
2508 else pL = &(((Wire*)pe)->Port1->Connections);
2509
2510 for(pe1 = pL->first(); pe1!=0; pe1 = pL->next())
2511 if(pe1 == c)
2512 {
2513 deleteWire((Wire*)pe);
2514 break;
2515 }
2516 }
2517 }
2518}
2519
2520// ---------------------------------------------------
2521// Used for example in moving components.

Callers

nothing calls this directly

Calls 2

nextMethod · 0.80
foreachFunction · 0.70

Tested by

no test coverage detected