void LIB_EDIT_FRAME::CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bool aDeMorgan ) { int ii; LIB_PIN* NewPin; if( !SynchronizePins() ) return; // Create "convert" pin at the current position. if( aDeMorgan && ( aPin->GetConvert() != 0 ) ) { NewPin = (LIB_PIN*) aPin->Clone(); if( aPin->GetConvert() > 1 ) NewPin->SetConvert( 1 ); else NewPin->SetConvert( 2 ); aPin->GetParent()->AddDrawItem( NewPin ); } for( ii = 1; ii <= aPin->GetParent()->GetUnitCount(); ii++ ) { if( ii == aUnit || aPin->GetUnit() == 0 ) continue; // Pin common to all units. NewPin = (LIB_PIN*) aPin->Clone(); // To avoid mistakes, gives this pin a new pin number because // it does no have the save pin number as the master pin // Because we do not know the actual number, give it '??' wxString unknownNum( wxT( "??" ) ); NewPin->SetPinNumFromString( unknownNum ); if( aConvert != 0 ) NewPin->SetConvert( 1 ); NewPin->SetUnit( ii ); aPin->GetParent()->AddDrawItem( NewPin ); if( !( aDeMorgan && ( aPin->GetConvert() != 0 ) ) ) continue; NewPin = (LIB_PIN*) aPin->Clone(); NewPin->SetConvert( 2 ); // Gives this pin a new pin number // Because we do not know the actual number, give it '??' NewPin->SetPinNumFromString( unknownNum ); if( aPin->GetUnit() != 0 ) NewPin->SetUnit( ii ); aPin->GetParent()->AddDrawItem( NewPin ); } }
// Create a new pin based on the previous pin with an incremented pin number. void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) { wxString msg; LIB_PART* part = GetCurPart(); if( !part || !SourcePin || SourcePin->Type() != LIB_PIN_T ) return; LIB_PIN* pin = (LIB_PIN*) SourcePin->Clone(); pin->ClearFlags(); pin->SetFlags( IS_NEW ); wxPoint step; switch( pin->GetOrientation() ) { case PIN_UP: step.x = GetRepeatPinStep(); break; case PIN_DOWN: step.x = GetRepeatPinStep(); break; case PIN_LEFT: step.y = - GetRepeatPinStep(); break; case PIN_RIGHT: step.y = - GetRepeatPinStep(); break; } pin->Move( pin->GetPosition() + step ); wxString nextName = pin->GetName(); IncrementLabelMember( nextName, GetRepeatDeltaLabel() ); pin->SetName( nextName ); pin->PinStringNum( msg ); IncrementLabelMember( msg, GetRepeatDeltaLabel() ); pin->SetPinNumFromString( msg ); m_drawItem = pin; if( SynchronizePins() ) pin->SetFlags( IS_LINKED ); wxPoint savepos = GetCrossHairPosition(); m_canvas->CrossHairOff( DC ); SetCrossHairPosition( wxPoint( pin->GetPosition().x, -pin->GetPosition().y ) ); // Add this new pin in list, and creates pins for others parts if needed m_drawItem = pin; ClearTempCopyComponent(); PlacePin(); m_lastDrawItem = pin; SetCrossHairPosition( savepos ); m_canvas->CrossHairOn( DC ); MSG_PANEL_ITEMS items; pin->GetMsgPanelInfo( items ); SetMsgPanel( items ); OnModify( ); }