summaryrefslogtreecommitdiffstats
path: root/src/electronics/ecnode.h
blob: 04665f5e349c6a0ddf3931d1c9b3400a98687a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/***************************************************************************
 *   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.                                   *
 ***************************************************************************/

#ifndef ECNODE_H
#define ECNODE_H

#include "node.h"

#include <tqvaluevector.h>

class ECNode;
class Element;
class Pin;
class Switch;
class TQTimer;

typedef TQValueList<ECNode*> ECNodeList;
typedef TQValueList<Element*> ElementList;
typedef TQValueVector<Pin*> PinVector;

/**
@short Electrical node with voltage / current / etc properties
@author David Saxton
*/
class ECNode : public Node
{
	TQ_OBJECT
  
	public:
		ECNode( ICNDocument *icnDocument, Node::node_type type, node_dir dir, const TQPoint &pos, TQString *id = 0L );
		~ECNode();
	
		virtual void setParentItem( CNItem *parentItem );
		virtual void drawShape( TQPainter &p );
		/**
		 * Set the number of pins "contained" in this node.
		 */
		void setNumPins( unsigned num );
		/**
		 * @return the number of pins in this node.
		 * @see setNumPins
		 */
		unsigned numPins() const { return m_pins.size(); }
		PinVector pins() const { return m_pins; }
		Pin * pin( unsigned num = 0 ) const { return (num < m_pins.size()) ? m_pins[num] : 0l; }
		bool showVoltageBars() const { return m_bShowVoltageBars; }
		void setShowVoltageBars( bool show ) { m_bShowVoltageBars = show; }
		void setNodeChanged();
		
	signals:
		void numPinsChanged( unsigned newNum );
	
	protected slots:
		void removeElement( Element * e );
		void removeSwitch( Switch * sw );
	
	protected:
		bool m_bShowVoltageBars;
		double m_prevV;
		double m_prevI;
		TQCanvasRectangle * m_pinPoint;
		PinVector m_pins;
};

#endif