bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { int itemsCount = 0; bool nextcmd = false; MODULE* currentModule = GetBoard()->m_Modules; if( GetScreen()->m_BlockLocate.GetCount() ) { BLOCK_STATE_T state = GetScreen()->m_BlockLocate.GetState(); BLOCK_COMMAND_T command = GetScreen()->m_BlockLocate.GetCommand(); m_canvas->CallEndMouseCapture( DC ); GetScreen()->m_BlockLocate.SetState( state ); GetScreen()->m_BlockLocate.SetCommand( command ); m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); SetCrossHairPosition( wxPoint( GetScreen()->m_BlockLocate.GetRight(), GetScreen()->m_BlockLocate.GetBottom() ) ); m_canvas->MoveCursorToCrossHair(); } switch( GetScreen()->m_BlockLocate.GetCommand() ) { case BLOCK_IDLE: DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); break; case BLOCK_DRAG: // Drag case BLOCK_MOVE: // Move case BLOCK_COPY: // Copy itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) { nextcmd = true; if( m_canvas->IsMouseCaptured() ) { m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); } GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); m_canvas->Refresh( true ); } break; case BLOCK_PRESELECT_MOVE: // Move with preselection list nextcmd = true; m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); break; case BLOCK_DELETE: // Delete itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); DeleteMarkedItems( currentModule ); break; case BLOCK_SAVE: // Save case BLOCK_PASTE: break; case BLOCK_ROTATE: itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: case BLOCK_FLIP: // mirror itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_ZOOM: // Window Zoom Window_Zoom( GetScreen()->m_BlockLocate ); break; case BLOCK_ABORT: break; case BLOCK_SELECT_ITEMS_ONLY: break; } if( !nextcmd ) { if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY ) { ClearMarkItems( currentModule ); } GetScreen()->ClearBlockCommand(); SetCurItem( NULL ); m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); m_canvas->Refresh( true ); } return nextcmd; }
bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { int itemsCount = 0; bool nextcmd = false; MODULE* currentModule = GetBoard()->m_Modules; if( GetScreen()->m_BlockLocate.GetCount() ) { // Set the SELECTED flag of all preselected items, and clear preselect list ClearMarkItems( currentModule ); PICKED_ITEMS_LIST* list = &GetScreen()->m_BlockLocate.GetItems(); for( unsigned ii = 0, e = list->GetCount(); ii < e; ++ii ) { BOARD_ITEM* item = (BOARD_ITEM*) list->GetPickedItem( ii ); item->SetFlags( SELECTED ); ++itemsCount; } GetScreen()->m_BlockLocate.ClearItemsList(); } switch( GetScreen()->m_BlockLocate.GetCommand() ) { case BLOCK_IDLE: DisplayError( this, wxT( "Error in HandleBlockPLace" ) ); break; case BLOCK_DRAG: // Drag case BLOCK_DRAG_ITEM: // Drag a given item (not used here) case BLOCK_MOVE: // Move case BLOCK_COPY: // Copy case BLOCK_COPY_AND_INCREMENT: // Specific to duplicate with increment command // Find selected items if we didn't already set them manually if( itemsCount == 0 ) itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) { nextcmd = true; if( m_canvas->IsMouseCaptured() ) { m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); } GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); m_canvas->Refresh( true ); } break; case BLOCK_MOVE_EXACT: itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) { wxPoint translation; double rotation = 0; DIALOG_MOVE_EXACT dialog( this, translation, rotation ); int ret = dialog.ShowModal(); if( ret == wxID_OK ) { SaveCopyInUndoList( currentModule, UR_MODEDIT ); const wxPoint blockCentre = GetScreen()->m_BlockLocate.Centre(); MoveMarkedItemsExactly( currentModule, blockCentre, translation, rotation ); } } break; case BLOCK_PRESELECT_MOVE: // Move with preselection list nextcmd = true; m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_MOVE ); break; case BLOCK_DELETE: // Delete itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); DeleteMarkedItems( currentModule ); break; case BLOCK_SAVE: // Save case BLOCK_PASTE: break; case BLOCK_ROTATE: itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: case BLOCK_FLIP: // mirror itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate ); if( itemsCount ) SaveCopyInUndoList( currentModule, UR_MODEDIT ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_ZOOM: // Window Zoom Window_Zoom( GetScreen()->m_BlockLocate ); break; case BLOCK_ABORT: break; case BLOCK_SELECT_ITEMS_ONLY: break; } if( !nextcmd ) { if( GetScreen()->m_BlockLocate.GetCommand() != BLOCK_SELECT_ITEMS_ONLY ) { ClearMarkItems( currentModule ); } GetScreen()->ClearBlockCommand(); SetCurItem( NULL ); m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); m_canvas->Refresh( true ); } return nextcmd; }