summaryrefslogtreecommitdiffstats
path: root/src/electronics/components/ecdiode.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 01:49:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 01:49:02 +0000
commit5de3dd4762ca33a0f92e79ffa4fe2ff67069d531 (patch)
treebad482b7afa4cdf47422d60a5dd2c61c7e333b09 /src/electronics/components/ecdiode.cpp
downloadktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.tar.gz
ktechlab-5de3dd4762ca33a0f92e79ffa4fe2ff67069d531.zip
Added KDE3 version of ktechlab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1095338 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/electronics/components/ecdiode.cpp')
-rw-r--r--src/electronics/components/ecdiode.cpp120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/electronics/components/ecdiode.cpp b/src/electronics/components/ecdiode.cpp
new file mode 100644
index 0000000..1d63bce
--- /dev/null
+++ b/src/electronics/components/ecdiode.cpp
@@ -0,0 +1,120 @@
+/***************************************************************************
+ * Copyright (C) 2003,2005 by David Saxton *
+ * david@bluehaze.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ ***************************************************************************/
+
+#include "diode.h"
+#include "ecdiode.h"
+#include "ecnode.h"
+#include "libraryitem.h"
+
+#include <klocale.h>
+#include <qpainter.h>
+
+Item* ECDiode::construct( ItemDocument *itemDocument, bool newItem, const char *id )
+{
+ return new ECDiode( (ICNDocument*)itemDocument, newItem, id );
+}
+
+LibraryItem* ECDiode::libraryItem()
+{
+ return new LibraryItem(
+ "ec/diode",
+ i18n("Diode"),
+ i18n("Discrete"),
+ "diode.png",
+ LibraryItem::lit_component,
+ ECDiode::construct );
+}
+
+ECDiode::ECDiode( ICNDocument *icnDocument, bool newItem, const char *id )
+ : Component( icnDocument, newItem, id ? id : "diode" )
+{
+ m_name = i18n("Diode");
+ m_desc = i18n("Allows current to flow in the direction indicated by the arrow when a certain voltage difference has been reached.");
+
+ setSize( -8, -8, 16, 16 );
+
+ init1PinLeft();
+ init1PinRight();
+
+ m_diode = createDiode( m_pNNode[0], m_pPNode[0] );
+
+ DiodeSettings ds; // it will have the default properties that we use
+
+ createProperty( "I_S", Variant::Type::Double );
+ property("I_S")->setCaption("Saturation Current");
+ property("I_S")->setUnit("A");
+ property("I_S")->setMinValue(1e-20);
+ property("I_S")->setMaxValue(1e-0);
+ property("I_S")->setValue( ds.I_S );
+ property("I_S")->setAdvanced(true);
+
+ createProperty( "N", Variant::Type::Double );
+ property("N")->setCaption( i18n("Emission Coefficient") );
+ property("N")->setMinValue(1e0);
+ property("N")->setMaxValue(1e1);
+ property("N")->setValue( ds.N );
+ property("N")->setAdvanced(true);
+
+ createProperty( "V_B", Variant::Type::Double );
+ property("V_B")->setCaption( i18n("Breakdown Voltage") );
+ property("V_B")->setUnit("V");
+ property("V_B")->setMinAbsValue(1e-5);
+ property("V_B")->setMaxValue(1e10);
+ property("V_B")->setValue( ds.V_B );
+ property("V_B")->setAdvanced(true);
+
+// createProperty( "R", Variant::Type::Double );
+// property("R")->setCaption( i18n("Series Resistance") );
+// property("R")->setUnit( QChar(0x3a9) );
+// property("R")->setMinValue(1e-5);
+// property("R")->setMaxValue(1e0);
+// property("R")->setValue( ds.R );
+// property("R")->setAdvanced(true);
+}
+
+
+ECDiode::~ECDiode()
+{
+}
+
+
+void ECDiode::dataChanged()
+{
+ DiodeSettings ds;
+
+ ds.I_S = dataDouble("I_S");
+ ds.V_B = dataDouble("V_B");
+ ds.N = dataDouble("N");
+// ds.R = dataDouble("R");
+
+ m_diode->setDiodeSettings( ds );
+}
+
+
+void ECDiode::drawShape( QPainter & p )
+{
+ initPainter(p);
+
+ int _x = int(x());
+ int _y = int(y());
+
+ QPointArray pa(3);
+ pa[0] = QPoint( 8, 0 );
+ pa[1] = QPoint( -8, -8 );
+ pa[2] = QPoint( -8, 8 );
+ pa.translate( _x, _y );
+ p.drawPolygon(pa);
+ p.drawPolyline(pa);
+
+ p.drawLine( _x+8, _y-8, _x+8, _y+8 );
+
+ deinitPainter(p);
+}
+