Finish up the block rotate/mirror fixes.

Block rotate and mirror now work like they do in Pcbnew (that is
they're treated as part of the block move/duplicate/whatever
rather than finishing it).

Fixes: lp:1780794
* https://bugs.launchpad.net/kicad/+bug/1780794
This commit is contained in:
Jeff Young 2018-09-06 15:26:00 +01:00
parent 924e56e076
commit 3c82ad3220
15 changed files with 292 additions and 371 deletions

View File

@ -42,9 +42,11 @@
BLOCK_SELECTOR::BLOCK_SELECTOR() : BLOCK_SELECTOR::BLOCK_SELECTOR() :
EDA_RECT() EDA_RECT()
{ {
m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block. m_state = STATE_NO_BLOCK; // State (enum BLOCK_STATE_T) of block.
m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation. m_command = BLOCK_IDLE; // Type (enum BLOCK_COMMAND_T) of operation.
m_color = BROWN; m_color = BROWN;
m_appendUndo = false; // Indicates at least one undo record has been saved and
// any additional undo records should be appended.
} }
@ -97,19 +99,10 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
msg = _( "Zoom to selection" ); msg = _( "Zoom to selection" );
break; break;
case BLOCK_ROTATE: // Rotate 90 deg
msg = _( "Block Rotate" );
break;
case BLOCK_FLIP: // Flip case BLOCK_FLIP: // Flip
msg = _( "Block Flip" ); msg = _( "Block Flip" );
break; break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: // mirror
msg = _( "Block Mirror" );
break;
case BLOCK_ABORT: case BLOCK_ABORT:
break; break;

View File

@ -943,11 +943,8 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
case BLOCK_DELETE: // Delete case BLOCK_DELETE: // Delete
case BLOCK_COPY: // Copy case BLOCK_COPY: // Copy
case BLOCK_ROTATE: // Rotate 90 deg
case BLOCK_FLIP: // Flip case BLOCK_FLIP: // Flip
case BLOCK_ZOOM: // Window Zoom case BLOCK_ZOOM: // Window Zoom
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: // mirror
case BLOCK_PRESELECT_MOVE: // Move with preselection list case BLOCK_PRESELECT_MOVE: // Move with preselection list
block->InitData( m_canvas, aPosition ); block->InitData( m_canvas, aPosition );
break; break;

View File

@ -97,19 +97,10 @@ void BLOCK_SELECTOR::SetMessageBlock( EDA_DRAW_FRAME* frame )
msg = _( "Zoom to selection" ); msg = _( "Zoom to selection" );
break; break;
case BLOCK_ROTATE: // Rotate 90 deg
msg = _( "Block Rotate" );
break;
case BLOCK_FLIP: // Flip case BLOCK_FLIP: // Flip
msg = _( "Block Flip" ); msg = _( "Block Flip" );
break; break;
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: // mirror
msg = _( "Block Mirror" );
break;
case BLOCK_ABORT: case BLOCK_ABORT:
break; break;

View File

@ -950,11 +950,8 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
case BLOCK_DELETE: // Delete case BLOCK_DELETE: // Delete
case BLOCK_COPY: // Copy case BLOCK_COPY: // Copy
case BLOCK_ROTATE: // Rotate 90 deg
case BLOCK_FLIP: // Flip case BLOCK_FLIP: // Flip
case BLOCK_ZOOM: // Window Zoom case BLOCK_ZOOM: // Window Zoom
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y: // mirror
case BLOCK_PRESELECT_MOVE: // Move with preselection list case BLOCK_PRESELECT_MOVE: // Move with preselection list
block->InitData( m_canvas, aPosition ); block->InitData( m_canvas, aPosition );
break; break;

View File

@ -74,10 +74,6 @@ int SCH_EDIT_FRAME::BlockCommand( EDA_KEY key )
cmd = BLOCK_DUPLICATE; cmd = BLOCK_DUPLICATE;
break; break;
case GR_KB_ALT:
cmd = BLOCK_ROTATE;
break;
case GR_KB_CTRL: case GR_KB_CTRL:
cmd = BLOCK_DRAG; cmd = BLOCK_DRAG;
break; break;
@ -136,19 +132,22 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
return; return;
} }
SaveCopyInUndoList( block->GetItems(), UR_CHANGED, false, block->GetMoveVector() ); SaveCopyInUndoList( block->GetItems(), UR_CHANGED, block->AppendUndo(), block->GetMoveVector() );
block->SetAppendUndo();
MoveItemsInList( block->GetItems(), block->GetMoveVector() ); MoveItemsInList( block->GetItems(), block->GetMoveVector() );
break; break;
case BLOCK_DUPLICATE: /* Duplicate */ case BLOCK_DUPLICATE: /* Duplicate */
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
{
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
DuplicateItemsInList( GetScreen(), block->GetItems(), block->GetMoveVector() ); DuplicateItemsInList( GetScreen(), block->GetItems(), block->GetMoveVector() );
SaveCopyInUndoList( block->GetItems(), UNDO_REDO_T operation = block->GetCommand() == BLOCK_PRESELECT_MOVE ? UR_CHANGED : UR_NEW;
( block->GetCommand() == BLOCK_PRESELECT_MOVE ) ? UR_CHANGED : UR_NEW ); SaveCopyInUndoList( block->GetItems(), operation, block->AppendUndo() );
}
break; break;
case BLOCK_PASTE: case BLOCK_PASTE:
@ -195,7 +194,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
auto panel =static_cast<SCH_DRAW_PANEL*>(m_canvas); auto panel =static_cast<SCH_DRAW_PANEL*>(m_canvas);
auto view = panel->GetView(); auto view = panel->GetView();
auto area = view->GetSelectionArea();
view->ShowSelectionArea( false ); view->ShowSelectionArea( false );
view->ClearHiddenFlags(); view->ClearHiddenFlags();
@ -224,27 +222,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
DisplayError( this, wxT( "Error in HandleBlockPLace()" ) ); DisplayError( this, wxT( "Error in HandleBlockPLace()" ) );
break; break;
case BLOCK_ROTATE:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
// Compute the rotation center and put it on grid:
wxPoint rotationPoint = block->Centre();
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, false, rotationPoint );
RotateListOfItems( block->GetItems(), rotationPoint );
CheckListConnections( block->GetItems(), true );
SchematicCleanUp( true );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
break;
case BLOCK_DRAG: case BLOCK_DRAG:
case BLOCK_DRAG_ITEM: // Drag from a drag command case BLOCK_DRAG_ITEM: // Drag from a drag command
case BLOCK_MOVE: case BLOCK_MOVE:
@ -333,46 +310,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
zoom_command = true; zoom_command = true;
break; break;
case BLOCK_MIRROR_X:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
// Compute the mirror center and put it on grid.
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, false, mirrorPoint );
MirrorX( block->GetItems(), mirrorPoint );
SchematicCleanUp( true );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
break;
case BLOCK_MIRROR_Y:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
if( block->GetCount() )
{
// Compute the mirror center and put it on grid.
wxPoint mirrorPoint = block->Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, false, mirrorPoint );
MirrorY( block->GetItems(), mirrorPoint );
SchematicCleanUp( true );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds();
break;
default: default:
break; break;
} }
@ -409,14 +346,13 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel); SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
auto view = panel->GetView(); KIGFX::SCH_VIEW* view = panel->GetView();
KIGFX::VIEW_GROUP* preview = view->GetPreview();
auto preview = view->GetPreview(); BASE_SCREEN* screen = aPanel->GetScreen();
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
BASE_SCREEN* screen = aPanel->GetScreen(); SCH_ITEM* schitem;
BLOCK_SELECTOR* block = &screen->m_BlockLocate;
SCH_ITEM* schitem;
block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() ); block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
@ -426,7 +362,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->GetItem( ii ); schitem = (SCH_ITEM*) block->GetItem( ii );
SCH_ITEM *copy = static_cast<SCH_ITEM*>( schitem->Clone() ); SCH_ITEM* copy = static_cast<SCH_ITEM*>( schitem->Clone() );
copy->Move( block->GetMoveVector() ); copy->Move( block->GetMoveVector() );
preview->Add( copy ); preview->Add( copy );

View File

@ -769,21 +769,13 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
break; break;
case HK_ROTATE: case HK_ROTATE:
if( blocInProgress ) if ( !itemInEdit && !blocInProgress )
{ SetDrawItem( LocateItemUsingCursor( aPosition ) );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
HandleBlockPlace( aDC );
}
else
{
if ( !itemInEdit )
SetDrawItem( LocateItemUsingCursor( aPosition ) );
if( GetDrawItem() ) if( blocInProgress || GetDrawItem() )
{ {
cmd.SetId( ID_LIBEDIT_ROTATE_ITEM ); cmd.SetId( ID_LIBEDIT_ROTATE_ITEM );
GetEventHandler()->ProcessEvent( cmd ); OnRotate( cmd );
}
} }
break; break;
@ -847,7 +839,7 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( blocInProgress || GetDrawItem() ) if( blocInProgress || GetDrawItem() )
{ {
cmd.SetId( ID_LIBEDIT_MIRROR_Y ); cmd.SetId( ID_LIBEDIT_MIRROR_Y );
GetEventHandler()->ProcessEvent( cmd ); OnOrient( cmd );
} }
break; break;
@ -858,7 +850,7 @@ bool LIB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
if( blocInProgress || GetDrawItem() ) if( blocInProgress || GetDrawItem() )
{ {
cmd.SetId( ID_LIBEDIT_MIRROR_X ); cmd.SetId( ID_LIBEDIT_MIRROR_X );
GetEventHandler()->ProcessEvent( cmd ); OnOrient( cmd );
} }
break; break;
} }

View File

@ -273,137 +273,126 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
{ {
BLOCK_STATE_T state = block->GetState(); BLOCK_STATE_T state = block->GetState();
BLOCK_COMMAND_T command = block->GetCommand(); BLOCK_COMMAND_T command = block->GetCommand();
m_canvas->CallEndMouseCapture( aDC ); m_canvas->CallEndMouseCapture( aDC );
block->SetState( state ); block->SetState( state );
block->SetCommand( command ); block->SetCommand( command );
m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand ); m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
SetCrossHairPosition( wxPoint( block->GetRight(), SetCrossHairPosition( wxPoint( block->GetRight(), block->GetBottom() ) );
block->GetBottom() ) );
m_canvas->MoveCursorToCrossHair(); if( block->GetCommand() != BLOCK_ABORT )
m_canvas->MoveCursorToCrossHair();
} }
switch( block->GetCommand() ) if( m_canvas->IsMouseCaptured() )
{ {
case BLOCK_IDLE: switch( block->GetCommand() )
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break;
case BLOCK_DRAG: // Drag
case BLOCK_DRAG_ITEM:
case BLOCK_MOVE: // Move
case BLOCK_DUPLICATE: // Duplicate
if( GetCurPart() )
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
if( ItemCount )
{ {
nextCmd = true; case BLOCK_IDLE:
DisplayError( this, wxT( "Error in HandleBlockPLace" ) );
break;
if( m_canvas->IsMouseCaptured() ) case BLOCK_DRAG: // Drag
case BLOCK_DRAG_ITEM:
case BLOCK_MOVE: // Move
case BLOCK_DUPLICATE: // Duplicate
if( GetCurPart() )
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
if( ItemCount )
{ {
nextCmd = true;
block->SetFlags( IS_MOVED );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines ); m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
block->SetState( STATE_BLOCK_MOVE );
}
else
{
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->SetMouseCapture( NULL, NULL );
}
break;
case BLOCK_COPY: // Save a copy of items in the clipboard buffer
case BLOCK_CUT:
if( GetCurPart() )
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
if( ItemCount )
{
copySelectedItems();
auto cmd = block->GetCommand();
if( cmd == BLOCK_COPY )
{
BlockClearSelectedItems( GetCurPart(), block );
block->ClearItemsList();
}
else if( cmd == BLOCK_CUT )
{
if( block->AppendUndo() )
; // UR_LIBEDIT saves entire state, so no need to append anything more
else
{
SaveCopyInUndoList( GetCurPart(), UR_LIBEDIT );
block->SetAppendUndo();
}
BlockDeleteSelectedItems( GetCurPart(), block );
OnModify();
}
}
break;
case BLOCK_DELETE: // Delete
if( GetCurPart() )
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
if( block->AppendUndo() )
; // UR_LIBEDIT saves entire state, so no need to append anything more
else if( ItemCount )
{
SaveCopyInUndoList( GetCurPart(), UR_LIBEDIT );
block->SetAppendUndo();
} }
block->SetState( STATE_BLOCK_MOVE ); if( GetCurPart() )
m_canvas->Refresh( true );
}
break;
case BLOCK_PRESELECT_MOVE: // Move with preselection list
nextCmd = true;
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
block->SetState( STATE_BLOCK_MOVE );
break;
case BLOCK_COPY: // Save a copy of items in the clipboard buffer
case BLOCK_CUT:
if( GetCurPart() )
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
if( ItemCount )
{
copySelectedItems();
auto cmd = block->GetCommand();
if( cmd == BLOCK_COPY )
{ {
BlockClearSelectedItems( GetCurPart(), block );
block->ClearItemsList();
}
else if( cmd == BLOCK_CUT )
{
SaveCopyInUndoList( GetCurPart() );
BlockDeleteSelectedItems( GetCurPart(), block ); BlockDeleteSelectedItems( GetCurPart(), block );
OnModify(); OnModify();
} }
break;
case BLOCK_PASTE:
wxFAIL; // should not happen
break;
case BLOCK_FLIP:
break;
case BLOCK_ZOOM: // Window Zoom
Window_Zoom( *block );
break;
case BLOCK_ABORT:
break;
case BLOCK_SELECT_ITEMS_ONLY:
break;
case BLOCK_DUPLICATE_AND_INCREMENT: // not used in Eeschema
case BLOCK_MOVE_EXACT: // not used in Eeschema
break;
} }
break; }
case BLOCK_DELETE: // Delete if( block->GetCommand() == BLOCK_ABORT )
if( GetCurPart() ) {
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit ); GetScreen()->ClearDrawingState();
if( ItemCount )
SaveCopyInUndoList( GetCurPart() );
if( GetCurPart() )
{
BlockDeleteSelectedItems( GetCurPart(), block );
OnModify();
}
break;
case BLOCK_PASTE:
wxFAIL; // should not happen
break;
case BLOCK_FLIP:
break;
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
if( GetCurPart() )
ItemCount = BlockSelectItems( GetCurPart(), block, m_unit, m_convert, m_syncPinEdit );
if( ItemCount )
SaveCopyInUndoList( GetCurPart() );
pt = block->Centre();
pt = GetNearestGridPosition( pt );
pt.y = -pt.y;
if( GetCurPart() )
{
OnModify();
int block_cmd = block->GetCommand();
if( block_cmd == BLOCK_MIRROR_Y)
BlockMirrorSelectedItemsH( pt, GetCurPart(), block );
else if( block_cmd == BLOCK_MIRROR_X)
BlockMirrorSelectedItemsV( pt, GetCurPart(), block );
else if( block_cmd == BLOCK_ROTATE )
BlockRotateSelectedItems( pt, GetCurPart(), block );
}
break;
case BLOCK_ZOOM: // Window Zoom
Window_Zoom( *block );
break;
case BLOCK_ABORT:
break;
case BLOCK_SELECT_ITEMS_ONLY:
break;
case BLOCK_DUPLICATE_AND_INCREMENT: // not used in Eeschema
case BLOCK_MOVE_EXACT: // not used in Eeschema
break;
} }
if( !nextCmd ) if( !nextCmd )
@ -416,7 +405,6 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString, m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString,
false ); false );
m_canvas->Refresh( true );
} }
view->ShowPreview( false ); view->ShowPreview( false );
@ -450,7 +438,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_PRESELECT_MOVE: // Move with preselection list case BLOCK_PRESELECT_MOVE: // Move with preselection list
block->ClearItemsList(); block->ClearItemsList();
if( GetCurPart() ) if( GetCurPart() && !block->AppendUndo() )
SaveCopyInUndoList( GetCurPart() ); SaveCopyInUndoList( GetCurPart() );
pt = block->GetMoveVector(); pt = block->GetMoveVector();
@ -465,7 +453,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
case BLOCK_DUPLICATE: // Duplicate case BLOCK_DUPLICATE: // Duplicate
block->ClearItemsList(); block->ClearItemsList();
if( GetCurPart() ) if( GetCurPart() && !block->AppendUndo() )
SaveCopyInUndoList( GetCurPart() ); SaveCopyInUndoList( GetCurPart() );
pt = block->GetMoveVector(); pt = block->GetMoveVector();
@ -488,30 +476,6 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
pasteClipboard( pt ); pasteClipboard( pt );
break; break;
case BLOCK_ROTATE: // Invert by popup menu, from block move
case BLOCK_MIRROR_X: // Invert by popup menu, from block move
case BLOCK_MIRROR_Y: // Invert by popup menu, from block move
if( GetCurPart() )
SaveCopyInUndoList( GetCurPart() );
pt = block->Centre();
pt = GetNearestGridPosition( pt );
//pt.y = -pt.y;
if( GetCurPart() )
{
int block_cmd = block->GetCommand();
if( block_cmd == BLOCK_MIRROR_Y)
BlockMirrorSelectedItemsH( pt, GetCurPart(), block );
else if( block_cmd == BLOCK_MIRROR_X)
BlockMirrorSelectedItemsV( pt, GetCurPart(), block );
else if( block_cmd == BLOCK_ROTATE )
BlockRotateSelectedItems( pt, GetCurPart(), block );
}
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd case BLOCK_ZOOM: // Handled by HandleBlockEnd
case BLOCK_DELETE: case BLOCK_DELETE:
case BLOCK_COPY: case BLOCK_COPY:
@ -606,43 +570,34 @@ void LIB_EDIT_FRAME::pasteClipboard( const wxPoint& aOffset )
void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
auto panel = static_cast<SCH_DRAW_PANEL*>(aPanel); SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
auto view = panel->GetView(); LIB_EDIT_FRAME* frame = (LIB_EDIT_FRAME*) aPanel->GetParent();
auto preview = view->GetPreview(); KIGFX::SCH_VIEW* view = panel->GetView();
KIGFX::VIEW_GROUP* preview = view->GetPreview();
BASE_SCREEN* screen = aPanel->GetScreen(); BASE_SCREEN* screen = aPanel->GetScreen();
BLOCK_SELECTOR* block = &screen->m_BlockLocate; BLOCK_SELECTOR* block = &screen->m_BlockLocate;
LIB_PART* component = frame->GetCurPart();
LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
wxASSERT( parent != NULL );
LIB_PART* component = parent->GetCurPart();
if( component == NULL ) if( component == NULL )
return; return;
auto cp = parent->GetCrossHairPosition( true ); block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() );
auto lcp = block->GetLastCursorPosition();
printf("cp %d %d\n", cp.x, cp.y);
printf("lcp %d %d\n", lcp.x, lcp.y);
block->SetMoveVector( cp - lcp );
preview->Clear(); preview->Clear();
view->SetVisible( preview, true );
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii ); LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() ); LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() );
// if( copy->Type() != LIB_PIN_T ) copy->Move( copy->GetPosition() + block->GetMoveVector() );
copy->Move( copy->GetPosition() + block->GetMoveVector() ); copy->SetFlags( IS_MOVED );
preview->Add( copy ); preview->Add( copy );
view->Hide( libItem );
if( block->GetCommand() != BLOCK_DUPLICATE )
view->Hide( libItem );
} }
view->SetVisible( preview, true );
view->Hide( preview, false );
view->Update( preview ); view->Update( preview );
} }

View File

@ -53,7 +53,7 @@
#include <widgets/symbol_tree_pane.h> #include <widgets/symbol_tree_pane.h>
#include <widgets/lib_tree.h> #include <widgets/lib_tree.h>
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
#include <list_operations.h>
#include <kicad_device_context.h> #include <kicad_device_context.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <eeschema_config.h> #include <eeschema_config.h>
@ -157,7 +157,7 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
// Context menu events and commands. // Context menu events and commands.
EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin ) EVT_MENU( ID_LIBEDIT_EDIT_PIN, LIB_EDIT_FRAME::OnEditPin )
EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotateItem ) EVT_MENU( ID_LIBEDIT_ROTATE_ITEM, LIB_EDIT_FRAME::OnRotate )
EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM, EVT_MENU_RANGE( ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_ITEM,
ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT, ID_POPUP_LIBEDIT_DELETE_CURRENT_POLY_SEGMENT,
@ -263,8 +263,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
.Caption( _( "Libraries" ) ).MinSize( 250, -1 ).Resizable() ); .Caption( _( "Libraries" ) ).MinSize( 250, -1 ).Resizable() );
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) ); m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
m_auimgr.AddPane( m_canvas->GetWindow(), m_auimgr.AddPane( m_canvas->GetWindow(), wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
wxAuiPaneInfo().Name( "DrawFrame" ).CentrePane() );
m_auimgr.Update(); m_auimgr.Update();
@ -835,25 +834,13 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
HandleBlockEnd( nullptr ); HandleBlockEnd( nullptr );
break; break;
case ID_POPUP_MIRROR_Y_BLOCK:
m_canvas->SetAutoPanRequest( false );
block.SetCommand( BLOCK_MIRROR_Y );
m_canvas->MoveCursorToCrossHair();
HandleBlockPlace( nullptr );
break;
case ID_POPUP_MIRROR_X_BLOCK: case ID_POPUP_MIRROR_X_BLOCK:
m_canvas->SetAutoPanRequest( false ); case ID_POPUP_MIRROR_Y_BLOCK:
block.SetCommand( BLOCK_MIRROR_X ); OnOrient( event );
m_canvas->MoveCursorToCrossHair();
HandleBlockPlace( nullptr );
break; break;
case ID_POPUP_ROTATE_BLOCK: case ID_POPUP_ROTATE_BLOCK:
m_canvas->SetAutoPanRequest( false ); OnRotate( event );
block.SetCommand( BLOCK_ROTATE );
m_canvas->MoveCursorToCrossHair();
HandleBlockPlace( nullptr );
break; break;
case ID_POPUP_PLACE_BLOCK: case ID_POPUP_PLACE_BLOCK:
@ -882,7 +869,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
default: default:
DisplayError( this, "LIB_EDIT_FRAME::Process_Special_Functions error" ); wxFAIL_MSG( "LIB_EDIT_FRAME::Process_Special_Functions error" );
break; break;
} }
@ -1161,67 +1148,111 @@ void LIB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
} }
void LIB_EDIT_FRAME::OnRotateItem( wxCommandEvent& aEvent ) void LIB_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
{ {
LIB_ITEM* item = GetDrawItem(); LIB_PART* part = GetCurPart();
BLOCK_SELECTOR& block = GetScreen()->m_BlockLocate;
LIB_ITEM* item = GetDrawItem();
if( item == NULL ) // Allows block rotate operation on hot key.
return; if( block.GetState() != STATE_NO_BLOCK )
if( !item->InEditMode() )
{ {
LIB_PART* part = GetCurPart(); // Compute the rotation center and put it on grid:
wxPoint rotationPoint = block.Centre();
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( part ); if( block.AppendUndo() )
item->SetUnit( m_unit ); ; // UR_LIBEDIT saves entire state, so no need to append anything more
else
{
SaveCopyInUndoList( part, UR_LIBEDIT );
block.SetAppendUndo();
}
for( unsigned ii = 0; ii < block.GetCount(); ii++ )
{
item = dynamic_cast<LIB_ITEM*>( block.GetItem( ii ) );
item->Rotate( rotationPoint );
}
GetCanvas()->CallMouseCapture( nullptr, wxDefaultPosition, false );
} }
else if( item )
{
wxPoint rotationPoint = item->GetBoundingBox().Centre();
rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint );
item->Rotate(); if( !item->InEditMode() )
OnModify(); SaveCopyInUndoList( part, UR_LIBEDIT );
if( !item->InEditMode() ) item->Rotate( rotationPoint );
item->ClearFlags(); OnModify();
if( GetToolId() == ID_NO_TOOL_SELECTED ) if( !item->InEditMode() )
m_lastDrawItem = NULL; item->ClearFlags();
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL;
}
} }
void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent ) void LIB_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
{ {
SCH_SCREEN* screen = GetScreen(); LIB_PART* part = GetCurPart();
BLOCK_SELECTOR& block = screen->m_BlockLocate; BLOCK_SELECTOR& block = GetScreen()->m_BlockLocate;
LIB_ITEM* item = GetDrawItem();
// Change the current item to a block selection, if there were no items in the block selector
if( screen->GetCurItem() && block.GetState() == STATE_NO_BLOCK )
{
ITEM_PICKER picker( screen->GetCurItem() );
block.PushItem( picker );
block.SetState( STATE_BLOCK_INIT );
const wxPoint& cursorPos = GetCrossHairPosition();
block.SetLastCursorPosition( cursorPos );
block.SetOrigin( cursorPos );
block.SetEnd( cursorPos );
}
// Allows block rotate operation on hot key. // Allows block rotate operation on hot key.
if( block.GetState() != STATE_NO_BLOCK ) if( block.GetState() != STATE_NO_BLOCK )
{ {
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X ) // Compute the mirror center and put it on grid.
wxPoint mirrorPoint = block.Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
if( block.AppendUndo() )
; // UR_LIBEDIT saves entire state, so no need to append anything more
else
{ {
m_canvas->MoveCursorToCrossHair(); SaveCopyInUndoList( part, UR_LIBEDIT );
block.SetMessageBlock( this ); block.SetAppendUndo();
block.SetCommand( BLOCK_MIRROR_X );
HandleBlockEnd( nullptr );
} }
else if( aEvent.GetId() == ID_LIBEDIT_MIRROR_Y )
for( unsigned ii = 0; ii < block.GetCount(); ii++ )
{ {
m_canvas->MoveCursorToCrossHair(); item = dynamic_cast<LIB_ITEM*>( block.GetItem( ii ) );
block.SetMessageBlock( this );
block.SetCommand( BLOCK_MIRROR_Y ); if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X || aEvent.GetId() == ID_POPUP_MIRROR_X_BLOCK )
HandleBlockEnd( nullptr ); item->MirrorHorizontal( mirrorPoint );
else
item->MirrorVertical( mirrorPoint );
} }
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
}
else if( item )
{
wxPoint mirrorPoint = item->GetBoundingBox().Centre();
mirrorPoint = GetNearestGridPosition( mirrorPoint );
SetCrossHairPosition( mirrorPoint );
if( !item->InEditMode() )
SaveCopyInUndoList( part, UR_LIBEDIT );
if( aEvent.GetId() == ID_LIBEDIT_MIRROR_X || aEvent.GetId() == ID_POPUP_MIRROR_X_BLOCK )
item->MirrorHorizontal( mirrorPoint );
else
item->MirrorVertical( mirrorPoint );
OnModify();
if( !item->InEditMode() )
item->ClearFlags();
if( GetToolId() == ID_NO_TOOL_SELECTED )
m_lastDrawItem = NULL;
} }
} }

View File

@ -528,7 +528,7 @@ private:
/** /**
* Rotates the current item. * Rotates the current item.
*/ */
void OnRotateItem( wxCommandEvent& aEvent ); void OnRotate( wxCommandEvent& aEvent );
/** /**
* Handles the ID_LIBEDIT_MIRROR_X and ID_LIBEDIT_MIRROR_Y events. * Handles the ID_LIBEDIT_MIRROR_X and ID_LIBEDIT_MIRROR_Y events.

View File

@ -76,7 +76,7 @@ void RotateListOfItems( PICKED_ITEMS_LIST& aItemsList, const wxPoint& rotationPo
{ {
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
item->Rotate( rotationPoint ); // Place it in its new position. item->Rotate( rotationPoint ); // Place it in its new position.
item->ClearFlags(); item->ClearFlags();
} }
@ -87,7 +87,7 @@ void MirrorY( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMirrorPoint )
{ {
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
item->MirrorY( aMirrorPoint.x ); // Place it in its new position. item->MirrorY( aMirrorPoint.x ); // Place it in its new position.
item->ClearFlags(); item->ClearFlags();
} }
@ -98,7 +98,7 @@ void MirrorX( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMirrorPoint )
{ {
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
item->MirrorX( aMirrorPoint.y ); // Place it in its new position. item->MirrorX( aMirrorPoint.y ); // Place it in its new position.
item->ClearFlags(); item->ClearFlags();
} }
@ -109,7 +109,7 @@ void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, const wxPoint& aMoveVector
{ {
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
item->Move( aMoveVector ); item->Move( aMoveVector );
} }
} }
@ -123,7 +123,7 @@ void SCH_EDIT_FRAME::CheckListConnections( PICKED_ITEMS_LIST& aItemsList, bool a
GetSchematicConnections( connections ); GetSchematicConnections( connections );
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
std::vector< wxPoint > new_pts; std::vector< wxPoint > new_pts;
if( !item->IsConnectable() ) if( !item->IsConnectable() )
@ -175,7 +175,7 @@ void SCH_EDIT_FRAME::DeleteItemsInList( PICKED_ITEMS_LIST& aItemsList, bool aApp
{ {
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
if( item->GetFlags() & STRUCT_DELETED ) if( item->GetFlags() & STRUCT_DELETED )
continue; continue;
@ -246,7 +246,7 @@ void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) ); newitem = DuplicateStruct( dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) ) );
aItemsList.SetPickedItem( newitem, ii ); aItemsList.SetPickedItem( newitem, ii );
aItemsList.SetPickedItemStatus( UR_NEW, ii ); aItemsList.SetPickedItemStatus( UR_NEW, ii );
{ {

View File

@ -486,7 +486,6 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references case BLOCK_DUPLICATE_AND_INCREMENT: // Duplicate and increment relevant references
case BLOCK_DELETE: // Delete case BLOCK_DELETE: // Delete
case BLOCK_COPY: // Copy case BLOCK_COPY: // Copy
case BLOCK_ROTATE: // Rotate 90 deg
case BLOCK_FLIP: // Flip case BLOCK_FLIP: // Flip
case BLOCK_ZOOM: // Window Zoom case BLOCK_ZOOM: // Window Zoom
case BLOCK_MIRROR_X: case BLOCK_MIRROR_X:

View File

@ -516,6 +516,9 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling, bool isMovin
if( !isUnitAndConversionShown( aPin ) ) if( !isUnitAndConversionShown( aPin ) )
return; return;
if( aPin->IsMoving() )
isMoving = true;
COLOR4D color = m_schSettings.GetLayerColor( LAYER_PIN ); COLOR4D color = m_schSettings.GetLayerColor( LAYER_PIN );
if( !aPin->IsVisible() ) if( !aPin->IsVisible() )
@ -718,6 +721,11 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling, bool isMovin
for( COLOR4D& c : colour ) for( COLOR4D& c : colour )
c = m_schSettings.GetLayerColor( LAYER_HIDDEN ); c = m_schSettings.GetLayerColor( LAYER_HIDDEN );
} }
else if( isMoving )
{
for( COLOR4D& c : colour )
c = selectedBrightening( c );
}
int insideOffset = textOffset; int insideOffset = textOffset;
int outsideOffset = 10; int outsideOffset = 10;

View File

@ -839,19 +839,21 @@ void SCH_EDIT_FRAME::SelectAllFromSheet( wxCommandEvent& aEvent )
void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent ) void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
{ {
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
BLOCK_SELECTOR& block = screen->m_BlockLocate;
// Allows block rotate operation on hot key. // Allows block rotate operation on hot key.
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK ) if( block.GetState() != STATE_NO_BLOCK )
{ {
// Compute the rotation center and put it on grid: // Compute the rotation center and put it on grid:
wxPoint rotationPoint = screen->m_BlockLocate.Centre(); wxPoint rotationPoint = block.Centre();
rotationPoint = GetNearestGridPosition( rotationPoint ); rotationPoint = GetNearestGridPosition( rotationPoint );
SetCrossHairPosition( rotationPoint ); SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( screen->m_BlockLocate.GetItems(), UR_ROTATED, false, rotationPoint ); SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
RotateListOfItems( screen->m_BlockLocate.GetItems(), rotationPoint ); block.SetAppendUndo();
RotateListOfItems( block.GetItems(), rotationPoint );
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false ); m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
return; return;
@ -1162,8 +1164,6 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK ) if( screen->m_BlockLocate.GetState() == STATE_NO_BLOCK )
{ {
// INSTALL_UNBUFFERED_DC( dc, m_canvas );
//
if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) ) if( !HandleBlockBegin( nullptr, dragType, GetCrossHairPosition() ) )
break; break;
@ -1183,27 +1183,40 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent )
void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent ) void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
{ {
SCH_SCREEN* screen = GetScreen(); SCH_SCREEN* screen = GetScreen();
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
BLOCK_SELECTOR& block = screen->m_BlockLocate;
// INSTALL_UNBUFFERED_DC( dc, m_canvas );
// Allows block rotate operation on hot key. // Allows block rotate operation on hot key.
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK ) if( block.GetState() != STATE_NO_BLOCK )
{ {
if( aEvent.GetId() == ID_SCH_MIRROR_X ) if( aEvent.GetId() == ID_SCH_MIRROR_X )
{ {
m_canvas->MoveCursorToCrossHair(); // Compute the mirror center and put it on grid.
screen->m_BlockLocate.SetMessageBlock( this ); wxPoint mirrorPoint = block.Centre();
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_X ); mirrorPoint = GetNearestGridPosition( mirrorPoint );
HandleBlockEnd( nullptr ); SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPoint );
block.SetAppendUndo();
MirrorX( block.GetItems(), mirrorPoint );
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
return;
} }
else if( aEvent.GetId() == ID_SCH_MIRROR_Y ) else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
{ {
m_canvas->MoveCursorToCrossHair(); // Compute the mirror center and put it on grid.
screen->m_BlockLocate.SetMessageBlock( this ); wxPoint mirrorPoint = block.Centre();
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y ); mirrorPoint = GetNearestGridPosition( mirrorPoint );
HandleBlockEnd( nullptr ); SetCrossHairPosition( mirrorPoint );
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPoint );
block.SetAppendUndo();
MirrorY( block.GetItems(), mirrorPoint );
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
return;
} }
else else
{ {

View File

@ -82,6 +82,9 @@ class BLOCK_SELECTOR : public EDA_RECT
wxPoint m_lastCursorPosition; //< Last Mouse position in block command wxPoint m_lastCursorPosition; //< Last Mouse position in block command
//< last cursor position in move commands //< last cursor position in move commands
//< 0,0 in paste command. //< 0,0 in paste command.
bool m_appendUndo; //< indicates that at least one undo record
//< has been saved and further undo records
//< should be appended
public: public:
BLOCK_SELECTOR(); BLOCK_SELECTOR();
@ -99,6 +102,10 @@ public:
COLOR4D GetColor() const { return m_color; } COLOR4D GetColor() const { return m_color; }
bool AppendUndo() const { return m_appendUndo; }
void SetAppendUndo() { m_appendUndo = true; }
/** /**
* Function SetLastCursorPosition * Function SetLastCursorPosition
* sets the last cursor position to \a aPosition. * sets the last cursor position to \a aPosition.

View File

@ -588,6 +588,8 @@ void PCB_EDIT_FRAME::Block_Delete()
void PCB_EDIT_FRAME::Block_Rotate() void PCB_EDIT_FRAME::Block_Rotate()
{ {
// 6.0 TODO: This is the legacy toolset version
wxPoint centre; // rotation cent-re for the rotation transform wxPoint centre; // rotation cent-re for the rotation transform
int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg. int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg.