summaryrefslogtreecommitdiffstats
path: root/src/electronics/components/ecopamp.cpp
blob: 341bd82d65479d4e3de419b9519fd1c48d7cd78a (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
76
77
78
79
80
81
82
83
84
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 <tdelocale.h>
#include <tqpainter.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");
	
	TQPointArray pa(3);
	pa[0] = TQPoint( -16, -16 );
	pa[1] = TQPoint( 16, 0 );
	pa[2] = TQPoint( -16, 16 );
	setItemPoints( pa, true );
	
	init2PinLeft( -8, 8 );
	init1PinRight();
	createOpAmp( m_pNNode[0], m_pPNode[0], m_pNNode[1] );
}


ECOpAmp::~ECOpAmp()
{
}


void ECOpAmp::drawShape( TQPainter & p )
{
	initPainter(p);
	
	int _x = int(x());
	int _y = int(y());
	
	TQPointArray pa(3);
	pa[0] = TQPoint( _x-16, _y-16 );
	pa[1] = TQPoint( _x+16, _y );
	pa[2] = TQPoint( _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);
}