|
|
@ -493,8 +493,6 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) |
|
|
|
SCH_SCREEN* screen = GetScreen(); |
|
|
|
SCH_ITEM* item = screen->GetCurItem(); |
|
|
|
|
|
|
|
wxLogDebug( wxT( "Command member m_commandInt = %d." ), aEvent.GetInt() ); |
|
|
|
|
|
|
|
if( item == NULL ) |
|
|
|
{ |
|
|
|
// If we didn't get here by a hot key, then something has gone wrong.
|
|
|
@ -532,6 +530,7 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) |
|
|
|
case SCH_TEXT_T: |
|
|
|
case SCH_COMPONENT_T: |
|
|
|
case SCH_SHEET_PIN_T: |
|
|
|
case SCH_FIELD_T: |
|
|
|
MoveItem( item, &dc ); |
|
|
|
break; |
|
|
|
|
|
|
@ -543,10 +542,6 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) |
|
|
|
StartMoveSheet( (SCH_SHEET*) item, &dc ); |
|
|
|
break; |
|
|
|
|
|
|
|
case SCH_FIELD_T: |
|
|
|
MoveField( (SCH_FIELD*) item, &dc ); |
|
|
|
break; |
|
|
|
|
|
|
|
case SCH_MARKER_T: |
|
|
|
default: |
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), |
|
|
@ -721,3 +716,99 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC ) |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) |
|
|
|
{ |
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); |
|
|
|
SCH_ITEM* item = screen->GetCurItem(); |
|
|
|
|
|
|
|
wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) ); |
|
|
|
|
|
|
|
// Erase the current item at its current position.
|
|
|
|
if( aErase ) |
|
|
|
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); |
|
|
|
|
|
|
|
item->SetPosition( screen->GetCrossHairPosition() ); |
|
|
|
|
|
|
|
// Draw the item item at it's new position.
|
|
|
|
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) |
|
|
|
{ |
|
|
|
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); |
|
|
|
SCH_ITEM* item = screen->GetCurItem(); |
|
|
|
SCH_EDIT_FRAME* parent = ( SCH_EDIT_FRAME* ) aPanel->GetParent(); |
|
|
|
|
|
|
|
parent->SetRepeatItem( NULL ); |
|
|
|
screen->SetCurItem( NULL ); |
|
|
|
|
|
|
|
if( item == NULL ) /* no current item */ |
|
|
|
return; |
|
|
|
|
|
|
|
if( item->IsNew() ) |
|
|
|
{ |
|
|
|
delete item; |
|
|
|
item = NULL; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
SCH_ITEM* oldItem = parent->GetUndoItem(); |
|
|
|
|
|
|
|
SCH_ITEM* currentItem; |
|
|
|
|
|
|
|
// Items that are children of other objects are undone by swapping the contents
|
|
|
|
// of the parent items.
|
|
|
|
if( (item->Type() == SCH_SHEET_PIN_T) || (item->Type() == SCH_FIELD_T) ) |
|
|
|
{ |
|
|
|
currentItem = (SCH_ITEM*) item->GetParent(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
currentItem = item; |
|
|
|
} |
|
|
|
|
|
|
|
wxCHECK_RET( oldItem != NULL && currentItem->Type() == oldItem->Type(), |
|
|
|
wxT( "Cannot restore undefined or bad last schematic item." ) ); |
|
|
|
|
|
|
|
// Never delete existing item, because it can be referenced by an undo/redo command
|
|
|
|
// Just restore its data
|
|
|
|
currentItem->SwapData( oldItem ); |
|
|
|
item->ClearFlags(); |
|
|
|
} |
|
|
|
|
|
|
|
aPanel->Refresh(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) |
|
|
|
{ |
|
|
|
wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) ); |
|
|
|
|
|
|
|
m_itemToRepeat = NULL; |
|
|
|
|
|
|
|
if( !aItem->IsNew() ) |
|
|
|
{ |
|
|
|
if( (aItem->Type() == SCH_SHEET_PIN_T) || (aItem->Type() == SCH_FIELD_T) ) |
|
|
|
SetUndoItem( (SCH_ITEM*) aItem->GetParent() ); |
|
|
|
else |
|
|
|
SetUndoItem( aItem ); |
|
|
|
} |
|
|
|
|
|
|
|
aItem->SetFlags( IS_MOVED ); |
|
|
|
|
|
|
|
DrawPanel->CrossHairOff( aDC ); |
|
|
|
|
|
|
|
if( aItem->Type() != SCH_SHEET_PIN_T ) |
|
|
|
GetScreen()->SetCrossHairPosition( aItem->GetPosition() ); |
|
|
|
|
|
|
|
DrawPanel->MoveCursorToCrossHair(); |
|
|
|
|
|
|
|
OnModify(); |
|
|
|
DrawPanel->SetMouseCapture( moveItem, abortMoveItem ); |
|
|
|
GetScreen()->SetCurItem( aItem ); |
|
|
|
moveItem( DrawPanel, aDC, wxDefaultPosition, true ); |
|
|
|
DrawPanel->CrossHairOn( aDC ); |
|
|
|
} |