void PIC_IC::initPackage( MicroInfo * microInfo ) { // The code in this function is a stripped down version of that in PICComponent::initPackage if (!microInfo) return; MicroPackage * microPackage = microInfo->package(); if (!microPackage) return; //BEGIN Get pin IDs QStringList allPinIDs = microPackage->pinIDs(); QStringList ioPinIDs = microPackage->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open ); // Now, we make the unwanted pin ids blank, so a pin is not created for them const QStringList::iterator allPinIDsEnd = allPinIDs.end(); for ( QStringList::iterator it = allPinIDs.begin(); it != allPinIDsEnd; ++it ) { if ( !ioPinIDs.contains(*it) ) *it = ""; } //END Get pin IDs //BEGIN Remove old stuff // Remove old text TextMap textMapCopy = m_textMap; const TextMap::iterator textMapEnd = textMapCopy.end(); for ( TextMap::iterator it = textMapCopy.begin(); it != textMapEnd; ++it ) removeDisplayText(it.key()); // Remove old nodes NodeInfoMap nodeMapCopy = m_nodeMap; const NodeInfoMap::iterator nodeMapEnd = nodeMapCopy.end(); for ( NodeInfoMap::iterator it = nodeMapCopy.begin(); it != nodeMapEnd; ++it ) { if ( !ioPinIDs.contains(it.key()) ) removeNode( it.key() ); } //END Remove old stuff //BEGIN Create new stuff initDIPSymbol( allPinIDs, 80 ); initDIP(allPinIDs); //END Create new stuff addDisplayText( "picid", QRect(offsetX(), offsetY()-16, width(), 16), microInfo->id() ); }
void PICComponent::initPackage( MicroInfo * microInfo ) { MicroPackage * microPackage = microInfo ? microInfo->package() : 0l; if ( microPackage ) { m_bCreatedInitialPackage = true; //BEGIN Get pin IDs QStringList allPinIDs = microPackage->pinIDs(); QStringList ioPinIDs = microPackage->pinIDs( PicPin::type_bidir | PicPin::type_input | PicPin::type_open ); // Now, we make the unwanted pin ids blank, so a pin is not created for them const QStringList::iterator allPinIDsEnd = allPinIDs.end(); for ( QStringList::iterator it = allPinIDs.begin(); it != allPinIDsEnd; ++it ) { if ( !ioPinIDs.contains(*it) ) *it = ""; } //END Get pin IDs //BEGIN Remove old stuff // Remove old text TextMap textMapCopy = m_textMap; const TextMap::iterator textMapEnd = textMapCopy.end(); for ( TextMap::iterator it = textMapCopy.begin(); it != textMapEnd; ++it ) removeDisplayText(it.key()); // Remove the old pins deletePICComponentPins(); // Remove old nodes NodeInfoMap nodeMapCopy = m_nodeMap; const NodeInfoMap::iterator nodeMapEnd = nodeMapCopy.end(); for ( NodeInfoMap::iterator it = nodeMapCopy.begin(); it != nodeMapEnd; ++it ) { if ( !ioPinIDs.contains(it.key()) ) removeNode( it.key() ); } removeElements(); //END Remove old stuff //BEGIN Create new stuff initDIPSymbol( allPinIDs, 80 ); initDIP(allPinIDs); PicPinMap picPinMap = microPackage->pins( PicPin::type_bidir | PicPin::type_input | PicPin::type_open ); const PicPinMap::iterator picPinMapEnd = picPinMap.end(); for ( PicPinMap::iterator it = picPinMap.begin(); it != picPinMapEnd; ++it ) m_picComponentPinMap[it.key()] = new PICComponentPin( this, it.value() ); //END Create new stuff removeDisplayText( "no_file" ); addDisplayText( "picid", QRect(offsetX(), offsetY()-16, width(), 16), microInfo->id() ); } else { setSize( -48, -72, 96, 144 ); removeDisplayText( "picid" ); addDisplayText( "no_file", sizeRect(), i18n("(No\nprogram\nloaded)") ); } //BEGIN Update button positions int leftpos = (width()-88)/2+offsetX(); button("run")->setOriginalRect( QRect( leftpos, height()+4+offsetY(), 20, 20 ) ); button("pause")->setOriginalRect( QRect( leftpos+23, height()+4+offsetY(), 20, 20 ) ); button("reset")->setOriginalRect( QRect( leftpos+46, height()+4+offsetY(), 20, 20 ) ); button("reload")->setOriginalRect( QRect( leftpos+69, height()+4+offsetY(), 20, 20 ) ); updateAttachedPositioning(); //END Update button positions }