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() ); }
FlowPartList FlowPart::outputParts() { FlowPartList list; const NodeInfoMap::iterator end = m_nodeMap.end(); for (NodeInfoMap::iterator it = m_nodeMap.begin(); it != end; ++it) { FlowPart *part = outputPart(it.key()); if (part) list.append(part); } return list; }
FlowPart* FlowPart::endPart(QStringList ids, FlowPartList *previousParts) { if (ids.empty()) { const NodeInfoMap::iterator end = m_nodeMap.end(); for (NodeInfoMap::iterator it = m_nodeMap.begin(); it != end; ++it) { ids.append(it.key()); } filterEndPartIDs(&ids); } const bool createdList = (!previousParts); if (createdList) { previousParts = new FlowPartList; } else if (previousParts->contains(this)) { return 0l; } previousParts->append(this); if (ids.empty()) { return 0; } if (ids.size() == 1) { return outputPart(*(ids.begin())); } typedef QValueList<FlowPartList> ValidPartsList; ValidPartsList validPartsList; const QStringList::iterator idsEnd = ids.end(); for (QStringList::iterator it = ids.begin(); it != idsEnd; ++it) { int prevLevel = level(); FlowPartList validParts; FlowPart *part = outputPart(*it); while (part) { if (!validParts.contains(part)) { validParts.append(part); // if ( part->level() >= level() ) { const int _l = part->level(); part = part->endPart(QStringList(), previousParts); prevLevel = _l; // } else { // part = 0l; // } } else { part = 0; } } if (!validParts.empty()) { validPartsList.append(validParts); } } if (createdList) { delete previousParts; previousParts = 0; } if (validPartsList.empty()) return 0; FlowPartList firstList = *(validPartsList.begin()); const FlowPartList::iterator flEnd = firstList.end(); const ValidPartsList::iterator vplEnd = validPartsList.end(); for (FlowPartList::iterator it = firstList.begin(); it != flEnd; ++it) { bool ok = true; for (ValidPartsList::iterator vplit = validPartsList.begin(); vplit != vplEnd; ++vplit) { if (!(*vplit).contains(*it)) ok = false; } if (ok) return *it; } return 0l; }
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 }