Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

void PICComponent::initPackage ( MicroInfo info  ) 

Sets up the pins, text, etc for the given PIC type. If info is null, then a generic rectangle is displayed (used when no file has been loaded yet).

Definition at line 192 of file piccomponent.cpp.

References CNItem::addDisplayText(), MicroInfo::id(), Component::initDIP(), Component::initDIPSymbol(), m_bCreatedInitialPackage, MicroInfo::package(), MicroPackage::pinIDs(), MicroPackage::pins(), CNItem::removeDisplayText(), Component::removeElements(), CNItem::removeNode(), Item::setSize(), Item::sizeRect(), and Component::updateAttachedPositioning().

Referenced by initPIC().

{
      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
            NodeMap nodeMapCopy = m_nodeMap;
            const NodeMap::iterator nodeMapEnd = nodeMapCopy.end();
            for ( NodeMap::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.data() );
            //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
}


Generated by  Doxygen 1.6.0   Back to index