ecdiode.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003,2005 by David Saxton                               *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #include "diode.h"
00012 #include "ecdiode.h"
00013 #include "ecnode.h"
00014 #include "libraryitem.h"
00015 
00016 #include <klocale.h>
00017 #include <qpainter.h>
00018 
00019 Item* ECDiode::construct( ItemDocument *itemDocument, bool newItem, const char *id )
00020 {
00021         return new ECDiode( (ICNDocument*)itemDocument, newItem, id );
00022 }
00023 
00024 LibraryItem* ECDiode::libraryItem()
00025 {
00026         return new LibraryItem(
00027                 "ec/diode",
00028                 i18n("Diode"),
00029                 i18n("Discrete"),
00030                 "diode.png",
00031                 LibraryItem::lit_component,
00032                 ECDiode::construct );
00033 }
00034 
00035 ECDiode::ECDiode( ICNDocument *icnDocument, bool newItem, const char *id )
00036         : Component( icnDocument, newItem, id ? id : "diode" )
00037 {
00038         m_name = i18n("Diode");
00039         m_desc = i18n("Allows current to flow in the direction indicated by the arrow when a certain voltage difference has been reached.");
00040         
00041         setSize( -8, -8, 16, 16 );
00042         
00043         init1PinLeft();
00044         init1PinRight();
00045         
00046         m_diode = createDiode( m_pNNode[0], m_pPNode[0] );
00047         
00048         DiodeSettings ds; // it will have the default properties that we use
00049         
00050         createProperty( "I_S", Variant::Type::Double );
00051         property("I_S")->setCaption("Saturation Current");
00052         property("I_S")->setUnit("A");
00053         property("I_S")->setMinValue(1e-20);
00054         property("I_S")->setMaxValue(1e-0);
00055         property("I_S")->setValue( ds.I_S );
00056         property("I_S")->setAdvanced(true);
00057         
00058         createProperty( "N", Variant::Type::Double );
00059         property("N")->setCaption( i18n("Emission Coefficient") );
00060         property("N")->setMinValue(1e0);
00061         property("N")->setMaxValue(1e1);
00062         property("N")->setValue( ds.N );
00063         property("N")->setAdvanced(true);
00064         
00065         createProperty( "V_B", Variant::Type::Double );
00066         property("V_B")->setCaption( i18n("Breakdown Voltage") );
00067         property("V_B")->setUnit("V");
00068         property("V_B")->setMinAbsValue(1e-5);
00069         property("V_B")->setMaxValue(1e10);
00070         property("V_B")->setValue( ds.V_B );
00071         property("V_B")->setAdvanced(true);
00072         
00073 //      createProperty( "R", Variant::Type::Double );
00074 //      property("R")->setCaption( i18n("Series Resistance") );
00075 //      property("R")->setUnit( QChar(0x3a9) );
00076 //      property("R")->setMinValue(1e-5);
00077 //      property("R")->setMaxValue(1e0);
00078 //      property("R")->setValue( ds.R );
00079 //      property("R")->setAdvanced(true);
00080 }
00081 
00082 
00083 ECDiode::~ECDiode()
00084 {
00085 }
00086 
00087 
00088 void ECDiode::dataChanged()
00089 {
00090         DiodeSettings ds;
00091         
00092         ds.I_S = dataDouble("I_S");
00093         ds.V_B = dataDouble("V_B");
00094         ds.N = dataDouble("N");
00095 //      ds.R = dataDouble("R");
00096         
00097         m_diode->setDiodeSettings( ds );
00098 }
00099 
00100 
00101 void ECDiode::drawShape( QPainter & p )
00102 {
00103         initPainter(p);
00104         
00105         int _x = int(x());
00106         int _y = int(y());
00107         
00108         QPointArray pa(3);
00109         pa[0] = QPoint( 8, 0 );
00110         pa[1] = QPoint( -8, -8 );
00111         pa[2] = QPoint( -8, 8 );
00112         pa.translate( _x, _y );
00113         p.drawPolygon(pa);
00114         p.drawPolyline(pa);
00115         
00116         p.drawLine( _x+8, _y-8, _x+8, _y+8 );
00117         
00118         deinitPainter(p);
00119 }
00120 

Generated on Tue May 8 17:05:29 2007 for KTechLab by  doxygen 1.5.1