File indexing completed on 2024-05-05 05:46:05

0001 /***************************************************************************
0002  *   Copyright (C) 2005 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #include "ecopamp.h"
0012 
0013 #include "ecnode.h"
0014 #include "libraryitem.h"
0015 
0016 #include <KLocalizedString>
0017 #include <QPainter>
0018 
0019 Item *ECOpAmp::construct(ItemDocument *itemDocument, bool newItem, const char *id)
0020 {
0021     return new ECOpAmp(static_cast<ICNDocument *>(itemDocument), newItem, id);
0022 }
0023 
0024 LibraryItem *ECOpAmp::libraryItem()
0025 {
0026     return new LibraryItem(QStringList(QString("ec/opamp")), i18n("Op Amp"), i18n("Integrated Circuits"), "opamp.png", LibraryItem::lit_component, ECOpAmp::construct);
0027 }
0028 
0029 ECOpAmp::ECOpAmp(ICNDocument *icnDocument, bool newItem, const char *id)
0030     : Component(icnDocument, newItem, id ? id : "opamp")
0031 {
0032     m_name = i18n("Operational Amplifier");
0033 
0034     QPolygon pa(3);
0035     pa[0] = QPoint(-16, -16);
0036     pa[1] = QPoint(16, 0);
0037     pa[2] = QPoint(-16, 16);
0038     setItemPoints(pa, true);
0039 
0040     init2PinLeft(-8, 8);
0041     init1PinRight();
0042     createOpAmp(m_pNNode[0], m_pPNode[0], m_pNNode[1]);
0043 }
0044 
0045 ECOpAmp::~ECOpAmp()
0046 {
0047 }
0048 
0049 void ECOpAmp::drawShape(QPainter &p)
0050 {
0051     initPainter(p);
0052 
0053     int _x = int(x());
0054     int _y = int(y());
0055 
0056     QPolygon pa(3);
0057     pa[0] = QPoint(_x - 16, _y - 16);
0058     pa[1] = QPoint(_x + 16, _y);
0059     pa[2] = QPoint(_x - 16, _y + 16);
0060 
0061     p.drawPolygon(pa);
0062     p.drawPolyline(pa);
0063 
0064     // Plus symbol
0065     p.drawLine(_x - 9, _y - 8, _x - 9, _y - 2);
0066     p.drawLine(_x - 12, _y - 5, _x - 6, _y - 5);
0067 
0068     // Minus symbol
0069     p.drawLine(_x - 11, _y + 6, _x - 7, _y + 6);
0070 
0071     deinitPainter(p);
0072 }