void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { switch( transform ) { case ID_MODEDIT_MODULE_ROTATE: RotateMarkedItems( module, wxPoint(0,0), true ); break; case ID_MODEDIT_MODULE_MIRROR: MirrorMarkedItems( module, wxPoint(0,0), true ); break; case ID_MODEDIT_MODULE_MOVE_EXACT: { wxPoint translation; double rotation = 0; DIALOG_MOVE_EXACT dialog( this, translation, rotation ); int ret = dialog.ShowModal(); if( ret == wxID_OK ) { MoveMarkedItemsExactly( module, wxPoint(0, 0), translation, rotation, true ); } break; } default: DisplayInfoMessage( this, wxT( "Not available" ) ); break; } module->CalculateBoundingBox(); OnModify(); }
void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) { MODULE* currentModule = GetBoard()->m_Modules; if( !m_canvas->IsMouseCaptured() ) { DisplayError( this, wxT( "HandleBlockPLace : m_mouseCaptureCallback = NULL" ) ); } GetScreen()->m_BlockLocate.SetState( STATE_BLOCK_STOP ); switch( GetScreen()->m_BlockLocate.GetCommand() ) { case BLOCK_IDLE: break; case BLOCK_DRAG: // Drag case BLOCK_MOVE: // Move case BLOCK_PRESELECT_MOVE: // Move with preselection list GetScreen()->m_BlockLocate.ClearItemsList(); SaveCopyInUndoList( currentModule, UR_MODEDIT ); MoveMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() ); m_canvas->Refresh( true ); break; case BLOCK_COPY: // Copy GetScreen()->m_BlockLocate.ClearItemsList(); SaveCopyInUndoList( currentModule, UR_MODEDIT ); CopyMarkedItems( currentModule, GetScreen()->m_BlockLocate.GetMoveVector() ); break; case BLOCK_PASTE: // Paste GetScreen()->m_BlockLocate.ClearItemsList(); break; case BLOCK_MIRROR_X: case BLOCK_MIRROR_Y: case BLOCK_FLIP: // Mirror by popup menu, from block move SaveCopyInUndoList( currentModule, UR_MODEDIT ); MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_ROTATE: SaveCopyInUndoList( currentModule, UR_MODEDIT ); RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() ); break; case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_DELETE: case BLOCK_SAVE: case BLOCK_ABORT: default: break; } OnModify(); GetScreen()->m_BlockLocate.SetState( STATE_NO_BLOCK ); GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE ); SetCurItem( NULL ); m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString, false ); m_canvas->Refresh( true ); }
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; }
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform ) { TEXTE_MODULE* textmod; wxPoint pos; double angle = 900; // Necessary +- 900 (+- 90 degrees). // Be prudent: because RotateMarkedItems is used to rotate some items // used the same value as RotateMarkedItems switch( transform ) { case ID_MODEDIT_MODULE_ROTATE: #define ROTATE( z ) RotatePoint( (&z), angle ) RotateMarkedItems( module, wxPoint(0,0), true ); pos = module->m_Reference->GetPosition(); ROTATE( pos ); module->m_Reference->SetPosition( pos ); module->m_Reference->SetPos0( module->m_Reference->GetPosition() ); module->m_Reference->m_Orient += angle; if( module->m_Reference->m_Orient >= 1800 ) module->m_Reference->m_Orient -= 1800; pos = module->m_Value->GetPosition(); ROTATE( pos ); module->m_Value->SetPosition( pos ); module->m_Value->SetPos0( module->m_Value->m_Pos ); module->m_Value->m_Orient += angle; if( module->m_Value->m_Orient >= 1800 ) module->m_Value->m_Orient -= 1800; break; case ID_MODEDIT_MODULE_MIRROR: // Mirror reference. textmod = module->m_Reference; NEGATE( textmod->m_Pos.x ); NEGATE( textmod->m_Pos0.x ); if( textmod->m_Orient ) textmod->m_Orient = 3600 - textmod->m_Orient; // Mirror value. textmod = module->m_Value; NEGATE( textmod->m_Pos.x ); NEGATE( textmod->m_Pos0.x ); if( textmod->m_Orient ) textmod->m_Orient = 3600 - textmod->m_Orient; // Mirror pads and graphic items of the footprint: MirrorMarkedItems( module, wxPoint(0,0), true ); break; default: DisplayInfoMessage( this, wxT( "Not available" ) ); break; } module->CalculateBoundingBox(); OnModify(); }
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; }