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

0001 /***************************************************************************
0002  *   Copyright (C) 2003-2004 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 "ecground.h"
0012 
0013 #include "ecnode.h"
0014 #include "libraryitem.h"
0015 #include "pin.h"
0016 
0017 #include <KLocalizedString>
0018 #include <QPainter>
0019 
0020 Item *ECGround::construct(ItemDocument *itemDocument, bool newItem, const char *id)
0021 {
0022     return new ECGround(static_cast<ICNDocument *>(itemDocument), newItem, id);
0023 }
0024 LibraryItem *ECGround::libraryItem()
0025 {
0026     return new LibraryItem(QStringList(QString("ec/ground")), i18n("Ground (0V)"), i18n("Sources"), "ground.png", LibraryItem::lit_component, ECGround::construct);
0027 }
0028 
0029 ECGround::ECGround(ICNDocument *icnDocument, bool newItem, const char *id)
0030     : Component(icnDocument, newItem, (id) ? id : "ground")
0031 {
0032     m_name = i18n("Ground");
0033     setSize(-8, -8, 16, 16);
0034     init1PinRight();
0035     m_pPNode[0]->pin()->setGroundType(Pin::gt_always);
0036     setAngleDegrees(270);
0037 }
0038 
0039 ECGround::~ECGround()
0040 {
0041 }
0042 
0043 void ECGround::drawShape(QPainter &p)
0044 {
0045     initPainter(p);
0046     int _x = int(x()) - 8;
0047     int _y = int(y()) - 8;
0048     QPen pen;
0049     pen.setWidth(2);
0050     pen.setColor(p.pen().color());
0051     p.setPen(pen);
0052     p.drawLine(_x + 15, _y, _x + 15, _y + 16);
0053     p.drawLine(_x + 10, _y + 3, _x + 10, _y + 13);
0054     p.drawLine(_x + 5, _y + 6, _x + 5, _y + 10);
0055     deinitPainter(p);
0056 }