/* * Traces the outline of the search block structures * The entire block follows the cursor */ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) { SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel ); LIB_EDIT_FRAME* frame = (LIB_EDIT_FRAME*) aPanel->GetParent(); KIGFX::SCH_VIEW* view = panel->GetView(); KIGFX::VIEW_GROUP* preview = view->GetPreview(); BASE_SCREEN* screen = aPanel->GetScreen(); BLOCK_SELECTOR* block = &screen->m_BlockLocate; LIB_PART* component = frame->GetCurPart(); if( component == NULL ) return; block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() ); preview->Clear(); view->SetVisible( preview, true ); for( unsigned ii = 0; ii < block->GetCount(); ii++ ) { LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii ); LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() ); copy->Move( copy->GetPosition() + block->GetMoveVector() ); copy->SetFlags( IS_MOVED ); preview->Add( copy ); view->Hide( libItem ); } view->Update( preview ); }
void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock ) { PICKED_ITEMS_LIST& aItemsList = aBlock->GetItems(); LIB_ITEM* oldItem; LIB_ITEM* newItem; for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) { oldItem = static_cast<LIB_ITEM*>( aItemsList.GetPickedItem( ii ) ); // We *do not* copy fields because they are unique for the whole component // so skip them (do not duplicate) if they are flagged selected. if( oldItem->Type() == LIB_FIELD_T ) oldItem->ClearFlags( SELECTED ); if( !oldItem->IsSelected() ) continue; newItem = (LIB_ITEM*) oldItem->Clone(); newItem->SetFlags( SELECTED ); oldItem->ClearFlags( SELECTED ); newItem->SetOffset( aBlock->GetMoveVector() ); aItemsList.SetPickedItem( newItem, ii ); aItemsList.SetPickedItemStatus( UR_NEW, ii ); aPart->GetDrawItems().push_back( newItem ); } }