Skip to content
This repository has been archived by the owner on Dec 26, 2019. It is now read-only.

Commit

Permalink
fairly major commit, deals with how pins are allocated in ecnodes.
Browse files Browse the repository at this point in the history
git-svn-id: https://ktechlab.svn.sourceforge.net/svnroot/ktechlab/trunk@557 76876f85-f02d-0410-881d-fd707285c4ba
  • Loading branch information
AlonzoTG authored and AlonzoTG committed Oct 19, 2009
1 parent 3b51d28 commit 00e7692
Show file tree
Hide file tree
Showing 35 changed files with 192 additions and 208 deletions.
4 changes: 1 addition & 3 deletions src/canvastip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "canvastip.h"
#include "icndocument.h"
#include "ecnode.h"
#include "pin.h"
#include "electronicconnector.h"
#include "circuitdocument.h"
#include "simulator.h"
Expand All @@ -45,7 +44,7 @@ void CanvasTip::displayVI(ECNode *node, const QPoint &pos) {
m_i.resize(num);

for (unsigned i = 0; i < num; i++) {
if (Pin *pin = node->pin(i)) {
if (Pin *pin = &node->pin(i)) {
m_v[i] = pin->voltage();
m_i[i] = pin->calculateCurrentFromWires();
}
Expand Down Expand Up @@ -149,7 +148,6 @@ void CanvasTip::setText(const QString & text) {
QRect r = QFontMetrics(qApp->font()).boundingRect(0, 0, 0, 0, 0, m_text);
setSize(r.width() + 4, r.height() - 1);
}

//END class CanvasTip


1 change: 0 additions & 1 deletion src/connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ int getSlope(float x1, float y1, float x2, float y2) {

if (x1 == x2) {
if (y1 == y2) return s_n;

return s_v;
} else if (y1 == y2) {
return s_h;
Expand Down
4 changes: 2 additions & 2 deletions src/connectorline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void ConnectorLine::drawShape(QPainter &p) {
return;
}

int ss = 3; // segment spacing
int sl = 13; // segment length (includes segment spacing)
const int ss = 3; // segment spacing
const int sl = 13; // segment length (includes segment spacing)

int offset = int(dynamic_cast<ElectronicConnector *>(m_pConnector)->currentAnimationOffset() - m_pixelOffset);
offset = ((offset % sl) - sl) % sl;
Expand Down
5 changes: 1 addition & 4 deletions src/electronics/circuitdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ecnode.h"
#include "itemdocumentdata.h"
#include "ktechlab.h"
#include "pin.h"
#include "simulator.h"
#include "subcircuits.h"

Expand Down Expand Up @@ -335,9 +334,7 @@ void CircuitDocument::getAllPins(PinSet &allPins)
for (ECNodeMap::const_iterator it = m_ecNodeList.begin(); it != nodeListEnd; ++it) {
ECNode *ecnode = it->second;
for (unsigned i = 0; i < ecnode->numPins(); i++) {
Pin *foo = ecnode->pin(i);
assert(foo);
allPins.insert(foo);
allPins.insert(&ecnode->pin(i));
}
}
}
Expand Down
84 changes: 42 additions & 42 deletions src/electronics/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,81 +263,81 @@ void Component::slotUpdateConfiguration() {
}
}

void Component::setup1pinElement(Element &ele, Pin *a) {
void Component::setup1pinElement(Element &ele, Pin &a) {
PinList pins;
pins.push_back(a);
pins.push_back(&a);
ElementMapList::iterator it = handleElement(&ele, pins);

PinSet pinz;
pinz.insert(a);
pinz.insert(&a);
setInterDependent(it, pinz);
}

void Component::setup2pinElement(Element &ele, Pin *a, Pin *b) {
void Component::setup2pinElement(Element &ele, Pin &a, Pin &b) {
PinList pins;
pins.push_back(a);
pins.push_back(b);
pins.push_back(&a);
pins.push_back(&b);
ElementMapList::iterator it = handleElement(&ele, pins);

PinSet pinz;
pinz.insert(a);
pinz.insert(b);
pinz.insert(&a);
pinz.insert(&b);
setInterDependent(it, pinz);
}

void Component::setup3pinElement(Element &ele, Pin *a, Pin *b, Pin *c) {
void Component::setup3pinElement(Element &ele, Pin &a, Pin &b, Pin &c) {
PinList pins;
pins.push_back(a);
pins.push_back(b);
pins.push_back(c);
pins.push_back(&a);
pins.push_back(&b);
pins.push_back(&c);
ElementMapList::iterator it = handleElement(&ele, pins);

PinSet pinz;
pinz.insert(a);
pinz.insert(b);
pinz.insert(c);
pinz.insert(&a);
pinz.insert(&b);
pinz.insert(&c);
setInterDependent(it, pinz);
}

void Component::setup4pinElement(Element &ele, Pin *a, Pin *b, Pin *c, Pin *d) {
void Component::setup4pinElement(Element &ele, Pin &a, Pin &b, Pin &c, Pin &d) {
PinList pins;
pins.push_back(a);
pins.push_back(b);
pins.push_back(c);
pins.push_back(d);
pins.push_back(&a);
pins.push_back(&b);
pins.push_back(&c);
pins.push_back(&d);
ElementMapList::iterator it = handleElement(&ele, pins);

PinSet pinz;
pinz.insert(a);
pinz.insert(b);
pinz.insert(c);
pinz.insert(d);
pinz.insert(&a);
pinz.insert(&b);
pinz.insert(&c);
pinz.insert(&d);
setInterDependent(it, pinz);
}

void Component::setupSpcl4pinElement(Element &ele, Pin *a, Pin *b, Pin *c, Pin *d) {
void Component::setupSpcl4pinElement(Element &ele, Pin &a, Pin &b, Pin &c, Pin &d) {

PinList pins;
pins.push_back(a);
pins.push_back(b);
pins.push_back(c);
pins.push_back(d);
pins.push_back(&a);
pins.push_back(&b);
pins.push_back(&c);
pins.push_back(&d);
ElementMapList::iterator it = handleElement(&ele, pins);

PinSet pinset;
pinset.insert(a);
pinset.insert(b);
pinset.insert(&a);
pinset.insert(&b);
setInterGroundDependent(pinset);
(*it).interGroundDependent.push_back(pinset);

pinset.insert(c);
pinset.insert(d);
pinset.insert(&c);
pinset.insert(&d);
setInterCircuitDependent(pinset);
(*it).interCircuitDependent.push_back(pinset);

pinset.clear();
pinset.insert(c);
pinset.insert(d);
pinset.insert(&c);
pinset.insert(&d);
setInterGroundDependent(pinset);
(*it).interGroundDependent.push_back(pinset);
}
Expand Down Expand Up @@ -391,7 +391,7 @@ void Component::setInterGroundDependent(PinSet &pins) {
}

void Component::rebuildPinInterDepedence() {
setAllPinsInterIndependent();
setAllPinsIndependent();

// Rebuild dependencies
ElementMapList::iterator emlEnd = m_elementMapList.end();
Expand All @@ -407,15 +407,15 @@ void Component::rebuildPinInterDepedence() {
}
}

void Component::setAllPinsInterIndependent() {
void Component::setAllPinsIndependent() {
NodeInfoMap::iterator nmEnd = m_nodeMap.end();
for(NodeInfoMap::iterator it = m_nodeMap.begin(); it != nmEnd; ++it) {
PinVector pins = (static_cast<ECNode*>(it.data().node))->pins();
PinVector::iterator pinsEnd = pins.end();

for(PinVector::iterator pinsIt = pins.begin(); pinsIt != pinsEnd; ++pinsIt) {
if (*pinsIt)
(*pinsIt)->removeDependentPins();
PinVector *pins = &(static_cast<ECNode*>(it.data().node))->pins();

PinVector::iterator pinsEnd = pins->end();
for(PinVector::iterator pinsIt = pins->begin(); pinsIt != pinsEnd; ++pinsIt) {
(*pinsIt).removeDependentPins();
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/electronics/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ class Component : public CNItem {
/// simplified element attachers
// TODO: look into feasibility for using variable argument arrays for these and other
// methods in this class.
void setup1pinElement(Element &ele, Pin *a);
void setup2pinElement(Element &ele, Pin *a, Pin *b);
void setup3pinElement(Element &ele, Pin *a, Pin *b, Pin *c);
void setup4pinElement(Element &ele, Pin *a, Pin *b, Pin *c, Pin *d);
void setupSpcl4pinElement(Element &ele, Pin *a, Pin *b, Pin *c, Pin *d);
void setup1pinElement(Element &ele, Pin &a);
void setup2pinElement(Element &ele, Pin &a, Pin &b);
void setup3pinElement(Element &ele, Pin &a, Pin &b, Pin &c);
void setup4pinElement(Element &ele, Pin &a, Pin &b, Pin &c, Pin &d);
void setupSpcl4pinElement(Element &ele, Pin &a, Pin &b, Pin &c, Pin &d);

ECNode *ecNodeWithID(const QString &ecNodeId);

Expand Down Expand Up @@ -176,7 +176,7 @@ public slots:
/**
* Sets all pins independent of each other.
*/
void setAllPinsInterIndependent();
void setAllPinsIndependent();

/**
* The given pins will affect the simulation of each other. Therefore, they
Expand Down
2 changes: 1 addition & 1 deletion src/electronics/components/addac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ADC::ADC( ICNDocument *icnDocument, bool newItem, const char *id )

void ADC::stepNonLogic()
{
double floatBitValue = m_realNode->pin()->voltage() * (std::pow( 2, double(m_numBits) )-1.) / m_range;
double floatBitValue = m_realNode->pin().voltage() * (std::pow( 2, double(m_numBits) )-1.) / m_range;
double roundBitValue = std::floor( floatBitValue + 0.5 );

if ( roundBitValue < 0 )
Expand Down
4 changes: 2 additions & 2 deletions src/electronics/components/bussplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ void BusSplitter::dataChanged() {
m_pWires.resize(busSize);

for (unsigned i = m_busSize; i < unsigned(busSize); i++) {
Pin *pin = createPin(16, 0, 180, outNodeID(i))->pin();
m_pWires[i] = new Wire(m_pInNode->pin(i), pin);
Pin *pin = &createPin(16, 0, 180, outNodeID(i))->pin();
m_pWires[i] = new Wire(&(m_pInNode->pin(i)), pin);
}
} else {
for (unsigned i = busSize; i < unsigned(m_busSize); i++) {
Expand Down
8 changes: 4 additions & 4 deletions src/electronics/components/dependentsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ECCCCS::ECCCCS(ICNDocument *icnDocument, bool newItem, const char *id)
setupSpcl4pinElement(m_cccs, m_pNNode[0]->pin(), m_pPNode[0]->pin(),
m_pNNode[1]->pin(), m_pPNode[1]->pin());

m_pNNode[1]->pin()->setGroundType(Pin::gt_medium);
m_pNNode[1]->pin().setGroundType(Pin::gt_medium);
}

ECCCCS::~ECCCCS() {}
Expand Down Expand Up @@ -183,7 +183,7 @@ ECCCVS::ECCCVS(ICNDocument *icnDocument, bool newItem, const char *id)
setupSpcl4pinElement(m_ccvs, m_pNNode[0]->pin(), m_pPNode[0]->pin(),
m_pNNode[1]->pin(), m_pPNode[1]->pin());

m_pNNode[1]->pin()->setGroundType(Pin::gt_medium);
m_pNNode[1]->pin().setGroundType(Pin::gt_medium);
}

ECCCVS::~ECCCVS() {}
Expand Down Expand Up @@ -228,7 +228,7 @@ ECVCCS::ECVCCS(ICNDocument *icnDocument, bool newItem, const char *id)
setupSpcl4pinElement(m_vccs, m_pNNode[0]->pin(), m_pPNode[0]->pin(),
m_pNNode[1]->pin(), m_pPNode[1]->pin());

m_pNNode[1]->pin()->setGroundType(Pin::gt_medium);
m_pNNode[1]->pin().setGroundType(Pin::gt_medium);
}

ECVCCS::~ECVCCS() {}
Expand Down Expand Up @@ -273,7 +273,7 @@ ECVCVS::ECVCVS(ICNDocument *icnDocument, bool newItem, const char *id)
setupSpcl4pinElement(m_vcvs, m_pNNode[0]->pin(), m_pPNode[0]->pin(),
m_pNNode[1]->pin(), m_pPNode[1]->pin());

m_pNNode[1]->pin()->setGroundType(Pin::gt_medium);
m_pNNode[1]->pin().setGroundType(Pin::gt_medium);
}

ECVCVS::~ECVCVS() {}
Expand Down
26 changes: 13 additions & 13 deletions src/electronics/components/ec555.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,38 @@ EC555::EC555(ICNDocument *icnDocument, bool newItem, const char *id)

// Pins down left
// Pin 7
discharge = createPin(-40, -16, 0, "Dis")->pin();
discharge = &createPin(-40, -16, 0, "Dis")->pin();
addDisplayText("dis", QRect(-32, -24, 24, 16), "Dis");

// Pin 6
threshold = createPin( -40, 0, 0, "Th" )->pin();
threshold = &createPin( -40, 0, 0, "Th" )->pin();
addDisplayText("th", QRect(-32, -8, 24, 16), "Th");

// Pin 2
trigger = createPin(-40, 16, 0, "Trg")->pin();
trigger = &createPin(-40, 16, 0, "Trg")->pin();
addDisplayText("trg", QRect(-32, 8, 24, 16), "Trg");

// Top two
// Pin 8
vcc = createPin(-16, -40, 90, "Vcc")->pin();
vcc = &createPin(-16, -40, 90, "Vcc")->pin();
addDisplayText("vcc", QRect(-24, -32, 16, 8), "+");

// Pin 4
reset = createPin(16, -40, 90, "Res")->pin();
reset = &createPin(16, -40, 90, "Res")->pin();
addDisplayText("res", QRect(8, -28, 16, 16), "Res");

// Bottom two
// Pin 1
ground = createPin(-16, 40, 270, "Gnd")->pin();
ground = &createPin(-16, 40, 270, "Gnd")->pin();
addDisplayText("gnd", QRect(-24, 20, 16, 8), "-");

// Pin 5
control = createPin(16, 40, 270, "CV")->pin();
control = &createPin(16, 40, 270, "CV")->pin();
addDisplayText("cv", QRect(8, 12, 16, 16), "CV");

// Output on right
// Pin 3
output = createPin(40, 0, 180, "Out")->pin();
output = &createPin(40, 0, 180, "Out")->pin();
addDisplayText("out", QRect(8, -8, 16, 16), "Out");

m_r1.setResistance(5e3);
Expand All @@ -85,11 +85,11 @@ EC555::EC555(ICNDocument *icnDocument, bool newItem, const char *id)
m_po_source.setConductance(0);
m_r_discharge.setResistance(0.0001);

setup2pinElement(m_r1, vcc, control);
setup2pinElement(m_r23, control, ground);
setup2pinElement(m_po_sink, output, ground);
setup2pinElement(m_po_source, output, vcc);
setup2pinElement(m_r_discharge, discharge, ground);
setup2pinElement(m_r1, *vcc, *control);
setup2pinElement(m_r23, *control, *ground);
setup2pinElement(m_po_sink, *output, *ground);
setup2pinElement(m_po_source, *output, *vcc);
setup2pinElement(m_r_discharge, *discharge, *ground);
}

EC555::~EC555() {}
Expand Down
2 changes: 1 addition & 1 deletion src/electronics/components/eccurrentsignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ECCurrentSignal::ECCurrentSignal(ICNDocument *icnDocument, bool newItem, const c
init1PinLeft();
init1PinRight();

m_pNNode[0]->pin()->setGroundType(Pin::gt_low);
m_pNNode[0]->pin().setGroundType(Pin::gt_low);
setup2pinElement(m_currentSignal, m_pNNode[0]->pin(), m_pPNode[0]->pin());
m_currentSignal.setStep(ElementSignal::st_sinusoidal, 50.);

Expand Down
2 changes: 1 addition & 1 deletion src/electronics/components/eccurrentsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ECCurrentSource::ECCurrentSource(ICNDocument *icnDocument, bool newItem, const c

init1PinLeft(8);
init1PinRight(8);
m_pNNode[0]->pin()->setGroundType(Pin::gt_low);
m_pNNode[0]->pin().setGroundType(Pin::gt_low);

setup2pinElement(m_currentSource, m_pNNode[0]->pin(), m_pPNode[0]->pin());

Expand Down
2 changes: 1 addition & 1 deletion src/electronics/components/ecground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ECGround::ECGround(ICNDocument *icnDocument, bool newItem, const char *id)
m_name = i18n("Ground");
setSize(-8, -8, 16, 16);
init1PinRight();
m_pPNode[0]->pin()->setGroundType(Pin::gt_always);
m_pPNode[0]->pin().setGroundType(Pin::gt_always);
setAngleDegrees(270);
}

Expand Down
4 changes: 2 additions & 2 deletions src/electronics/components/eckeypad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ void ECKeyPad::initPins(unsigned numCols) {
cols[j] = createPin(0, 64, 270, "col_" + QString::number(j));

for (unsigned i = 0; i < 4; i++) {
Pin *row = ecNodeWithID("row_" + QString::number(i))->pin();
Pin *row = &ecNodeWithID("row_" + QString::number(i))->pin();

for (unsigned j = m_numCols; j < numCols; j++)
m_switch[i][j] = new Switch(this, cols[j]->pin(), &(*row), Switch::Open);
m_switch[i][j] = new Switch(this, cols[j]->pin(), *row, Switch::Open);
}
} else {
// Remove columns
Expand Down
Loading

0 comments on commit 00e7692

Please sign in to comment.