summaryrefslogtreecommitdiffstats
path: root/src/electronics/components/ecopamp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/electronics/components/ecopamp.cpp')
-rw-r--r--src/electronics/components/ecopamp.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/electronics/components/ecopamp.cpp b/src/electronics/components/ecopamp.cpp
new file mode 100644
index 0000000..dbb7457
--- /dev/null
+++ b/src/electronics/components/ecopamp.cpp
@@ -0,0 +1,85 @@
+/***************************************************************************
+ * Copyright (C) 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 "ecopamp.h"
+
+#include "ecnode.h"
+#include "libraryitem.h"
+
+#include <klocale.h>
+#include <qpainter.h>
+
+Item* ECOpAmp::construct( ItemDocument *itemDocument, bool newItem, const char *id )
+{
+ return new ECOpAmp( (ICNDocument*)itemDocument, newItem, id );
+}
+
+
+LibraryItem* ECOpAmp::libraryItem()
+{
+ return new LibraryItem(
+ "ec/opamp",
+ i18n("Op Amp"),
+ i18n("Integrated Circuits"),
+ "opamp.png",
+ LibraryItem::lit_component,
+ ECOpAmp::construct );
+}
+
+
+ECOpAmp::ECOpAmp( ICNDocument *icnDocument, bool newItem, const char *id )
+ : Component( icnDocument, newItem, id ? id : "opamp" )
+{
+ m_name = i18n("Operational Amplifier");
+ m_desc = i18n("Ideal amplifier");
+
+ QPointArray pa(3);
+ pa[0] = QPoint( -16, -16 );
+ pa[1] = QPoint( 16, 0 );
+ pa[2] = QPoint( -16, 16 );
+ setItemPoints( pa, true );
+
+ init2PinLeft( -8, 8 );
+ init1PinRight();
+ createOpAmp( m_pNNode[0], m_pPNode[0], m_pNNode[1] );
+}
+
+
+ECOpAmp::~ECOpAmp()
+{
+}
+
+
+void ECOpAmp::drawShape( QPainter & p )
+{
+ initPainter(p);
+
+ int _x = int(x());
+ int _y = int(y());
+
+ QPointArray pa(3);
+ pa[0] = QPoint( _x-16, _y-16 );
+ pa[1] = QPoint( _x+16, _y );
+ pa[2] = QPoint( _x-16, _y+16 );
+
+ p.drawPolygon(pa);
+ p.drawPolyline(pa);
+
+ // Plus symbol
+ p.drawLine( _x-9, _y-8, _x-9, _y-2 );
+ p.drawLine( _x-12, _y-5, _x-6, _y-5 );
+
+ // Minus symbol
+ p.drawLine( _x-11, _y+6, _x-7, _y+6 );
+
+ deinitPainter(p);
+}
+
+