/*************************************************************************** * 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 "libraryitem.h" #include "node.h" #include "resistance.h" #include "resistordip.h" #include #include #include Item* ResistorDIP::construct( ItemDocument *itemDocument, bool newItem, const char *id ) { return new ResistorDIP( (ICNDocument*)itemDocument, newItem, id ); } LibraryItem* ResistorDIP::libraryItem() { return new LibraryItem( "ec/resistordip", i18n("Resistor DIP"), i18n("Discrete"), "resistordip.png", LibraryItem::lit_component, ResistorDIP::construct ); } ResistorDIP::ResistorDIP( ICNDocument *icnDocument, bool newItem, const char *id ) : Component( icnDocument, newItem, id ? id : "multiplexer" ) { m_name = i18n("Resistor DIP"); m_desc = i18n("Set of resistors with identical values in a Dual Inline Package."); m_resistorCount = 0; for ( int i=0; isetCaption( i18n("Resistance") ); property("resistance")->setUnit( TQChar(0x3a9) ); property("resistance")->setValue(1e4); property("resistance")->setMinValue(1e-6); createProperty( "count", Variant::Type::Int ); property("count")->setCaption( i18n("Count") ); property("count")->setMinValue(2); property("count")->setMaxValue(maxCount); property("count")->setValue(8); } ResistorDIP::~ResistorDIP() { } void ResistorDIP::dataChanged() { initPins(); const double resistance = dataDouble("resistance"); for ( int i=0; isetResistance(resistance); const TQString display = TQString::number( resistance / getMultiplier(resistance), 'g', 3 ) + getNumberMag(resistance) + TQChar(0x3a9); addDisplayText( "res", TQRect( offsetX(), offsetY()-16, 32, 12 ), display ); } void ResistorDIP::initPins() { const int count = dataInt("count"); const double resistance = dataDouble("resistance"); if ( count == m_resistorCount ) return; if ( count < m_resistorCount ) { for ( int i=count; i