File indexing completed on 2024-06-16 11:34:23

0001 //
0002 // C++ Implementation: junctionnode
0003 //
0004 // Description:
0005 //
0006 //
0007 //
0008 // Copyright: See COPYING file that comes with this distribution
0009 //
0010 //
0011 #include "junctionnode.h"
0012 
0013 #include "component.h"
0014 #include "pin.h"
0015 
0016 #include <QPainter>
0017 
0018 JunctionNode::JunctionNode(ICNDocument *icnDocument, int dir, const QPoint &pos, QString *id)
0019     : ECNode(icnDocument, Node::ec_junction, dir, pos, id)
0020 {
0021     QString name("JunctionNode");
0022     if (id) {
0023         name.append(QString("-%1").arg(*id));
0024     } else {
0025         name.append("-Unknown");
0026     }
0027     setObjectName(name.toLatin1().data());
0028 }
0029 
0030 JunctionNode::~JunctionNode()
0031 {
0032 }
0033 
0034 void JunctionNode::drawShape(QPainter &p)
0035 {
0036     initPainter(p);
0037 
0038     double v = pin() ? pin()->voltage() : 0.0;
0039     QColor voltageColor = Component::voltageColor(v);
0040 
0041     QPen pen = p.pen();
0042 
0043     if (isSelected())
0044         pen = m_selectedColor;
0045     else if (m_bShowVoltageColor)
0046         pen = voltageColor;
0047 
0048     p.setPen(pen);
0049     p.setBrush(pen.color());
0050     p.drawRect(-1, -1, 3, 3);
0051     deinitPainter(p);
0052 }
0053 
0054 void JunctionNode::initPoints()
0055 {
0056     setPoints(QPolygon(QRect(-4, -4, 8, 8)));
0057 }