Overhaul block logic to support rotate/mirror on the fly.
The old code delayed duplicating till the end which means the rotate/mirror would affect the original, and then be duplicated leaving the original incorrectly rotated/mirrored.
This commit is contained in:
parent
906c52deff
commit
4161bb6756
|
@ -121,6 +121,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
case BLOCK_DRAG: // Drag from mouse
|
case BLOCK_DRAG: // Drag from mouse
|
||||||
case BLOCK_DRAG_ITEM: // Drag from a component selection and drag command
|
case BLOCK_DRAG_ITEM: // Drag from a component selection and drag command
|
||||||
case BLOCK_MOVE:
|
case BLOCK_MOVE:
|
||||||
|
case BLOCK_DUPLICATE: /* Duplicate */
|
||||||
if( m_canvas->IsMouseCaptured() )
|
if( m_canvas->IsMouseCaptured() )
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
||||||
|
|
||||||
|
@ -132,22 +133,19 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_CHANGED, block->AppendUndo(), block->GetMoveVector() );
|
if( block->GetCommand() != BLOCK_DUPLICATE )
|
||||||
block->SetAppendUndo();
|
SaveCopyInUndoList( block->GetItems(), UR_CHANGED, block->AppendUndo(), block->GetMoveVector() );
|
||||||
|
|
||||||
MoveItemsInList( block->GetItems(), block->GetMoveVector() );
|
MoveItemsInList( block->GetItems(), block->GetMoveVector() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
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() );
|
||||||
|
|
||||||
UNDO_REDO_T operation = block->GetCommand() == BLOCK_PRESELECT_MOVE ? UR_CHANGED : UR_NEW;
|
SaveCopyInUndoList( block->GetItems(), UR_CHANGED, block->AppendUndo() );
|
||||||
SaveCopyInUndoList( block->GetItems(), operation, block->AppendUndo() );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_PASTE:
|
case BLOCK_PASTE:
|
||||||
|
@ -188,7 +186,6 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
{
|
{
|
||||||
bool nextcmd = false;
|
bool nextcmd = false;
|
||||||
bool zoom_command = false;
|
|
||||||
bool append = false;
|
bool append = false;
|
||||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||||
|
|
||||||
|
@ -226,32 +223,39 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
case BLOCK_DRAG_ITEM: // Drag from a drag command
|
case BLOCK_DRAG_ITEM: // Drag from a drag command
|
||||||
case BLOCK_MOVE:
|
case BLOCK_MOVE:
|
||||||
case BLOCK_DUPLICATE:
|
case BLOCK_DUPLICATE:
|
||||||
if( block->GetCommand() == BLOCK_DRAG_ITEM && GetScreen()->GetCurItem() != NULL )
|
case BLOCK_PRESELECT_MOVE:
|
||||||
|
if( block->GetCommand() == BLOCK_DRAG_ITEM )
|
||||||
{
|
{
|
||||||
// This is a drag command, not a mouse block command
|
// This is a drag command, not a mouse block command
|
||||||
// Only this item is put in list
|
// Only this item is put in list
|
||||||
ITEM_PICKER picker;
|
if( GetScreen()->GetCurItem() )
|
||||||
picker.SetItem( GetScreen()->GetCurItem() );
|
{
|
||||||
block->PushItem( picker );
|
ITEM_PICKER picker;
|
||||||
|
picker.SetItem( GetScreen()->GetCurItem() );
|
||||||
|
block->PushItem( picker );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if( block->GetCommand() != BLOCK_PRESELECT_MOVE )
|
||||||
{
|
{
|
||||||
// Collect all items in the locate block
|
// Collect all items in the locate block
|
||||||
GetScreen()->UpdatePickList();
|
GetScreen()->UpdatePickList();
|
||||||
}
|
}
|
||||||
// fall through
|
|
||||||
|
|
||||||
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
GetScreen()->SelectBlockItems();
|
||||||
|
|
||||||
|
if( block->GetCommand() == BLOCK_DUPLICATE )
|
||||||
|
{
|
||||||
|
DuplicateItemsInList( GetScreen(), block->GetItems(), block->GetMoveVector() );
|
||||||
|
SaveCopyInUndoList( block->GetItems(), UR_NEW );
|
||||||
|
}
|
||||||
|
|
||||||
if( block->GetCount() )
|
if( block->GetCount() )
|
||||||
{
|
{
|
||||||
nextcmd = true;
|
nextcmd = true;
|
||||||
GetScreen()->SelectBlockItems();
|
block->SetState( STATE_BLOCK_MOVE );
|
||||||
block->SetFlags( IS_MOVED );
|
|
||||||
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -302,12 +306,8 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
block->ClearItemsList();
|
block->ClearItemsList();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_PASTE:
|
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_ZOOM:
|
case BLOCK_ZOOM:
|
||||||
zoom_command = true;
|
Window_Zoom( GetScreen()->m_BlockLocate );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -315,26 +315,18 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( block->GetCommand() == BLOCK_ABORT )
|
|
||||||
{
|
|
||||||
GetScreen()->ClearDrawingState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !nextcmd )
|
if( !nextcmd )
|
||||||
{
|
{
|
||||||
block->SetState( STATE_NO_BLOCK );
|
block->SetState( STATE_NO_BLOCK );
|
||||||
block->SetCommand( BLOCK_IDLE );
|
block->SetCommand( BLOCK_IDLE );
|
||||||
|
GetScreen()->ClearDrawingState();
|
||||||
GetScreen()->SetCurItem( NULL );
|
GetScreen()->SetCurItem( NULL );
|
||||||
m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString,
|
m_canvas->EndMouseCapture( GetToolId(), GetGalCanvas()->GetCurrentCursor(), wxEmptyString,
|
||||||
false );
|
false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( zoom_command )
|
|
||||||
Window_Zoom( GetScreen()->m_BlockLocate );
|
|
||||||
|
|
||||||
view->ShowPreview( false );
|
|
||||||
view->ShowSelectionArea( false );
|
view->ShowSelectionArea( false );
|
||||||
view->ClearHiddenFlags();
|
view->ShowPreview( nextcmd );
|
||||||
|
|
||||||
return nextcmd;
|
return nextcmd;
|
||||||
}
|
}
|
||||||
|
@ -363,11 +355,12 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
|
||||||
{
|
{
|
||||||
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() );
|
||||||
|
copy->SetFlags( IS_MOVED );
|
||||||
preview->Add( copy );
|
preview->Add( copy );
|
||||||
|
|
||||||
if( block->GetCommand() != BLOCK_DUPLICATE )
|
view->Hide( schitem );
|
||||||
view->Hide( schitem );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view->Update( preview );
|
view->Update( preview );
|
||||||
|
|
|
@ -79,6 +79,7 @@ int LIB_EDIT_FRAME::BlockSelectItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock, i
|
||||||
return itemCount;
|
return itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::BlockClearSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
void LIB_EDIT_FRAME::BlockClearSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||||
{
|
{
|
||||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||||
|
@ -88,6 +89,7 @@ void LIB_EDIT_FRAME::BlockClearSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* a
|
||||||
aBlock->ClearItemsList();
|
aBlock->ClearItemsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::BlockMoveSelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
void LIB_EDIT_FRAME::BlockMoveSelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||||
{
|
{
|
||||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
||||||
|
@ -102,6 +104,7 @@ void LIB_EDIT_FRAME::BlockMoveSelectedItems( const wxPoint& aOffset, LIB_PART* a
|
||||||
// view update
|
// view update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::BlockDeleteSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
void LIB_EDIT_FRAME::BlockDeleteSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||||
{
|
{
|
||||||
LIB_ITEMS_CONTAINER::ITERATOR item = aPart->GetDrawItems().begin();
|
LIB_ITEMS_CONTAINER::ITERATOR item = aPart->GetDrawItems().begin();
|
||||||
|
@ -131,32 +134,31 @@ void LIB_EDIT_FRAME::BlockDeleteSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR*
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
|
||||||
{
|
{
|
||||||
std::vector< LIB_ITEM* > tmp;
|
PICKED_ITEMS_LIST& aItemsList = aBlock->GetItems();
|
||||||
|
LIB_ITEM* oldItem;
|
||||||
|
LIB_ITEM* newItem;
|
||||||
|
|
||||||
for( LIB_ITEM& item : aPart->GetDrawItems() )
|
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
|
oldItem = dynamic_cast<LIB_ITEM*>( aItemsList.GetPickedItem( ii ) );
|
||||||
|
|
||||||
// We *do not* copy fields because they are unique for the whole component
|
// We *do not* copy fields because they are unique for the whole component
|
||||||
// so skip them (do not duplicate) if they are flagged selected.
|
// so skip them (do not duplicate) if they are flagged selected.
|
||||||
if( item.Type() == LIB_FIELD_T )
|
if( oldItem->Type() == LIB_FIELD_T )
|
||||||
item.ClearFlags( SELECTED );
|
oldItem->ClearFlags( SELECTED );
|
||||||
|
|
||||||
if( !item.IsSelected() )
|
if( !oldItem->IsSelected() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item.ClearFlags( SELECTED );
|
newItem = (LIB_ITEM*) oldItem->Clone();
|
||||||
LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
|
|
||||||
newItem->SetFlags( SELECTED );
|
newItem->SetFlags( SELECTED );
|
||||||
|
oldItem->ClearFlags( SELECTED );
|
||||||
|
|
||||||
// When push_back elements in buffer, a memory reallocation can happen
|
aItemsList.SetPickedItem( newItem, ii );
|
||||||
// and will break pointers.
|
aItemsList.SetPickedItemStatus( UR_NEW, ii );
|
||||||
// So, push_back later.
|
|
||||||
tmp.push_back( newItem );
|
aPart->GetDrawItems().push_back( newItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( auto item : tmp )
|
|
||||||
aPart->GetDrawItems().push_back( item );
|
|
||||||
|
|
||||||
BlockMoveSelectedItems( aOffset, aPart, aBlock );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -303,12 +305,13 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
if( ItemCount )
|
if( ItemCount )
|
||||||
{
|
{
|
||||||
nextCmd = true;
|
nextCmd = true;
|
||||||
block->SetFlags( IS_MOVED );
|
block->SetState( STATE_BLOCK_MOVE );
|
||||||
|
|
||||||
|
if( block->GetCommand() == BLOCK_DUPLICATE )
|
||||||
|
BlockCopySelectedItems( pt, GetCurPart(), block );
|
||||||
|
|
||||||
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -384,6 +387,7 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
case BLOCK_SELECT_ITEMS_ONLY:
|
case BLOCK_SELECT_ITEMS_ONLY:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BLOCK_PRESELECT_MOVE: // not used in LibEdit
|
||||||
case BLOCK_DUPLICATE_AND_INCREMENT: // not used in Eeschema
|
case BLOCK_DUPLICATE_AND_INCREMENT: // not used in Eeschema
|
||||||
case BLOCK_MOVE_EXACT: // not used in Eeschema
|
case BLOCK_MOVE_EXACT: // not used in Eeschema
|
||||||
break;
|
break;
|
||||||
|
@ -407,9 +411,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
false );
|
false );
|
||||||
}
|
}
|
||||||
|
|
||||||
view->ShowPreview( false );
|
|
||||||
view->ShowSelectionArea( false );
|
view->ShowSelectionArea( false );
|
||||||
view->ClearHiddenFlags();
|
view->ShowPreview( nextCmd );
|
||||||
|
|
||||||
return nextCmd;
|
return nextCmd;
|
||||||
}
|
}
|
||||||
|
@ -435,7 +438,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
case BLOCK_DRAG: // Drag
|
case BLOCK_DRAG: // Drag
|
||||||
case BLOCK_DRAG_ITEM:
|
case BLOCK_DRAG_ITEM:
|
||||||
case BLOCK_MOVE: // Move
|
case BLOCK_MOVE: // Move
|
||||||
case BLOCK_PRESELECT_MOVE: // Move with preselection list
|
case BLOCK_DUPLICATE: // Duplicate
|
||||||
block->ClearItemsList();
|
block->ClearItemsList();
|
||||||
|
|
||||||
if( GetCurPart() && !block->AppendUndo() )
|
if( GetCurPart() && !block->AppendUndo() )
|
||||||
|
@ -450,20 +453,6 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
m_canvas->Refresh( true );
|
m_canvas->Refresh( true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_DUPLICATE: // Duplicate
|
|
||||||
block->ClearItemsList();
|
|
||||||
|
|
||||||
if( GetCurPart() && !block->AppendUndo() )
|
|
||||||
SaveCopyInUndoList( GetCurPart() );
|
|
||||||
|
|
||||||
pt = block->GetMoveVector();
|
|
||||||
//pt.y = -pt.y;
|
|
||||||
|
|
||||||
if( GetCurPart() )
|
|
||||||
BlockCopySelectedItems( pt, GetCurPart(), block );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_PASTE: // Paste (recopy the last block saved)
|
case BLOCK_PASTE: // Paste (recopy the last block saved)
|
||||||
block->ClearItemsList();
|
block->ClearItemsList();
|
||||||
|
|
||||||
|
@ -591,12 +580,12 @@ void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
|
||||||
{
|
{
|
||||||
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() );
|
||||||
|
|
||||||
copy->Move( copy->GetPosition() + block->GetMoveVector() );
|
copy->Move( copy->GetPosition() + block->GetMoveVector() );
|
||||||
copy->SetFlags( IS_MOVED );
|
copy->SetFlags( IS_MOVED );
|
||||||
preview->Add( copy );
|
preview->Add( copy );
|
||||||
|
|
||||||
if( block->GetCommand() != BLOCK_DUPLICATE )
|
view->Hide( libItem );
|
||||||
view->Hide( libItem );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view->Update( preview );
|
view->Update( preview );
|
||||||
|
|
|
@ -641,7 +641,9 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
switch( id ) // Stop placement commands before handling new command.
|
switch( id ) // Stop placement commands before handling new command.
|
||||||
{
|
{
|
||||||
case wxID_COPY:
|
case wxID_COPY:
|
||||||
|
case ID_POPUP_COPY_BLOCK:
|
||||||
case wxID_CUT:
|
case wxID_CUT:
|
||||||
|
case ID_POPUP_CUT_BLOCK:
|
||||||
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
case ID_POPUP_LIBEDIT_END_CREATE_ITEM:
|
||||||
case ID_LIBEDIT_EDIT_PIN:
|
case ID_LIBEDIT_EDIT_PIN:
|
||||||
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
case ID_POPUP_LIBEDIT_BODY_EDIT_ITEM:
|
||||||
|
@ -850,6 +852,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxID_COPY:
|
case wxID_COPY:
|
||||||
|
case ID_POPUP_COPY_BLOCK:
|
||||||
block.SetCommand( BLOCK_COPY );
|
block.SetCommand( BLOCK_COPY );
|
||||||
block.SetMessageBlock( this );
|
block.SetMessageBlock( this );
|
||||||
HandleBlockEnd( nullptr );
|
HandleBlockEnd( nullptr );
|
||||||
|
@ -860,6 +863,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxID_CUT:
|
case wxID_CUT:
|
||||||
|
case ID_POPUP_CUT_BLOCK:
|
||||||
if( block.GetCommand() != BLOCK_MOVE )
|
if( block.GetCommand() != BLOCK_MOVE )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -344,25 +344,30 @@ void AddMenusForBlock( wxMenu* PopMenu, LIB_EDIT_FRAME* frame )
|
||||||
{
|
{
|
||||||
AddMenuItem( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _( "Select Items" ),
|
AddMenuItem( PopMenu, ID_POPUP_SELECT_ITEMS_BLOCK, _( "Select Items" ),
|
||||||
KiBitmap( green_xpm ) );
|
KiBitmap( green_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Cut Block" ), g_Schematic_Hokeys_Descr,
|
|
||||||
HK_EDIT_CUT );
|
msg = AddHotkeyName( _( "Cut Block" ), g_Schematic_Hokeys_Descr, HK_EDIT_CUT );
|
||||||
AddMenuItem( PopMenu, wxID_CUT, msg, KiBitmap( cut_xpm ) );
|
AddMenuItem( PopMenu, ID_POPUP_CUT_BLOCK, msg, KiBitmap( cut_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Copy Block" ), g_Schematic_Hokeys_Descr,
|
|
||||||
HK_EDIT_COPY );
|
msg = AddHotkeyName( _( "Copy Block" ), g_Schematic_Hokeys_Descr, HK_EDIT_COPY );
|
||||||
AddMenuItem( PopMenu, wxID_COPY, msg, KiBitmap( copy_xpm ) );
|
AddMenuItem( PopMenu, ID_POPUP_COPY_BLOCK, msg,
|
||||||
|
KiBitmap( copy_xpm ) );
|
||||||
|
|
||||||
AddMenuItem( PopMenu, ID_POPUP_DUPLICATE_BLOCK, _( "Duplicate Block" ),
|
AddMenuItem( PopMenu, ID_POPUP_DUPLICATE_BLOCK, _( "Duplicate Block" ),
|
||||||
KiBitmap( duplicate_xpm ) );
|
KiBitmap( duplicate_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Mirror Block Around Horizontal(X) Axis" ), g_Libedit_Hokeys_Descr,
|
|
||||||
HK_MIRROR_X );
|
msg = AddHotkeyName( _( "Mirror Block Around Horizontal(X) Axis" ), g_Libedit_Hokeys_Descr, HK_MIRROR_X );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, msg,
|
AddMenuItem( PopMenu, ID_POPUP_MIRROR_X_BLOCK, msg,
|
||||||
KiBitmap( mirror_v_xpm ) );
|
KiBitmap( mirror_v_xpm ) );
|
||||||
msg = AddHotkeyName( _( "Mirror Block Around Vertical(Y) Axis" ), g_Libedit_Hokeys_Descr,
|
|
||||||
HK_MIRROR_Y );
|
msg = AddHotkeyName( _( "Mirror Block Around Vertical(Y) Axis" ), g_Libedit_Hokeys_Descr, HK_MIRROR_Y );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, msg,
|
AddMenuItem( PopMenu, ID_POPUP_MIRROR_Y_BLOCK, msg,
|
||||||
KiBitmap( mirror_h_xpm ) );
|
KiBitmap( mirror_h_xpm ) );
|
||||||
|
|
||||||
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Libedit_Hokeys_Descr, HK_ROTATE );
|
msg = AddHotkeyName( _( "Rotate Counterclockwise" ), g_Libedit_Hokeys_Descr, HK_ROTATE );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, msg,
|
AddMenuItem( PopMenu, ID_POPUP_ROTATE_BLOCK, msg,
|
||||||
KiBitmap( rotate_ccw_xpm ) );
|
KiBitmap( rotate_ccw_xpm ) );
|
||||||
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ), KiBitmap( delete_xpm ) );
|
|
||||||
|
AddMenuItem( PopMenu, ID_POPUP_DELETE_BLOCK, _( "Delete Block" ),
|
||||||
|
KiBitmap( delete_xpm ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,6 +234,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend )
|
||||||
void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
|
void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
|
||||||
const wxPoint& aMoveVector )
|
const wxPoint& aMoveVector )
|
||||||
{
|
{
|
||||||
|
SCH_ITEM* olditem;
|
||||||
SCH_ITEM* newitem;
|
SCH_ITEM* newitem;
|
||||||
|
|
||||||
if( aItemsList.GetCount() == 0 )
|
if( aItemsList.GetCount() == 0 )
|
||||||
|
@ -246,32 +247,34 @@ 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( dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) ) );
|
olditem = dynamic_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
|
||||||
|
newitem = DuplicateStruct( olditem );
|
||||||
|
|
||||||
aItemsList.SetPickedItem( newitem, ii );
|
aItemsList.SetPickedItem( newitem, ii );
|
||||||
aItemsList.SetPickedItemStatus( UR_NEW, ii );
|
aItemsList.SetPickedItemStatus( UR_NEW, ii );
|
||||||
{
|
|
||||||
switch( newitem->Type() )
|
|
||||||
{
|
|
||||||
case SCH_JUNCTION_T:
|
|
||||||
case SCH_LINE_T:
|
|
||||||
case SCH_BUS_BUS_ENTRY_T:
|
|
||||||
case SCH_BUS_WIRE_ENTRY_T:
|
|
||||||
case SCH_TEXT_T:
|
|
||||||
case SCH_LABEL_T:
|
|
||||||
case SCH_GLOBAL_LABEL_T:
|
|
||||||
case SCH_HIERARCHICAL_LABEL_T:
|
|
||||||
case SCH_SHEET_PIN_T:
|
|
||||||
case SCH_MARKER_T:
|
|
||||||
case SCH_NO_CONNECT_T:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCH_SHEET_T:
|
switch( newitem->Type() )
|
||||||
{
|
{
|
||||||
SCH_SHEET* sheet = (SCH_SHEET*) newitem;
|
case SCH_JUNCTION_T:
|
||||||
// Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
|
case SCH_LINE_T:
|
||||||
// based sheet name and update the time stamp for each sheet in the block.
|
case SCH_BUS_BUS_ENTRY_T:
|
||||||
timestamp_t timeStamp = GetNewTimeStamp();
|
case SCH_BUS_WIRE_ENTRY_T:
|
||||||
|
case SCH_TEXT_T:
|
||||||
|
case SCH_LABEL_T:
|
||||||
|
case SCH_GLOBAL_LABEL_T:
|
||||||
|
case SCH_HIERARCHICAL_LABEL_T:
|
||||||
|
case SCH_SHEET_PIN_T:
|
||||||
|
case SCH_MARKER_T:
|
||||||
|
case SCH_NO_CONNECT_T:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_SHEET_T:
|
||||||
|
{
|
||||||
|
SCH_SHEET* sheet = (SCH_SHEET*) newitem;
|
||||||
|
// Duplicate sheet names and sheet time stamps are not valid. Use a time stamp
|
||||||
|
// based sheet name and update the time stamp for each sheet in the block.
|
||||||
|
timestamp_t timeStamp = GetNewTimeStamp();
|
||||||
|
|
||||||
sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)timeStamp ) );
|
sheet->SetName( wxString::Format( wxT( "sheet%8.8lX" ), (unsigned long)timeStamp ) );
|
||||||
sheet->SetTimeStamp( timeStamp );
|
sheet->SetTimeStamp( timeStamp );
|
||||||
|
@ -279,17 +282,14 @@ void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCH_COMPONENT_T:
|
case SCH_COMPONENT_T:
|
||||||
( (SCH_COMPONENT*) newitem )->SetTimeStamp( GetNewTimeStamp() );
|
( (SCH_COMPONENT*) newitem )->SetTimeStamp( GetNewTimeStamp() );
|
||||||
( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL );
|
( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
newitem->Move( aMoveVector );
|
|
||||||
|
|
||||||
SetSchItemParent( newitem, screen );
|
|
||||||
AddToScreen( newitem );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetSchItemParent( newitem, screen );
|
||||||
|
AddToScreen( newitem );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( hasSheetCopied )
|
if( hasSheetCopied )
|
||||||
|
|
|
@ -526,6 +526,7 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
block->SetState( STATE_BLOCK_MOVE );
|
||||||
block->SetFlags( IS_MOVED );
|
block->SetFlags( IS_MOVED );
|
||||||
m_canvas->CallMouseCapture( aDC, aPosition, false );
|
m_canvas->CallMouseCapture( aDC, aPosition, false );
|
||||||
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -851,8 +851,12 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
||||||
rotationPoint = GetNearestGridPosition( rotationPoint );
|
rotationPoint = GetNearestGridPosition( rotationPoint );
|
||||||
SetCrossHairPosition( rotationPoint );
|
SetCrossHairPosition( rotationPoint );
|
||||||
|
|
||||||
SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
|
if( block.GetCommand() != BLOCK_DUPLICATE )
|
||||||
block.SetAppendUndo();
|
{
|
||||||
|
SaveCopyInUndoList( block.GetItems(), UR_ROTATED, block.AppendUndo(), rotationPoint );
|
||||||
|
block.SetAppendUndo();
|
||||||
|
}
|
||||||
|
|
||||||
RotateListOfItems( block.GetItems(), rotationPoint );
|
RotateListOfItems( block.GetItems(), rotationPoint );
|
||||||
|
|
||||||
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
||||||
|
@ -1193,13 +1197,17 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||||
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
||||||
{
|
{
|
||||||
// Compute the mirror center and put it on grid.
|
// Compute the mirror center and put it on grid.
|
||||||
wxPoint mirrorPoint = block.Centre();
|
wxPoint mirrorPt = block.Centre();
|
||||||
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
mirrorPt = GetNearestGridPosition( mirrorPt );
|
||||||
SetCrossHairPosition( mirrorPoint );
|
SetCrossHairPosition( mirrorPt );
|
||||||
|
|
||||||
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPoint );
|
if( block.GetCommand() != BLOCK_DUPLICATE )
|
||||||
block.SetAppendUndo();
|
{
|
||||||
MirrorX( block.GetItems(), mirrorPoint );
|
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_X, block.AppendUndo(), mirrorPt );
|
||||||
|
block.SetAppendUndo();
|
||||||
|
}
|
||||||
|
|
||||||
|
MirrorX( block.GetItems(), mirrorPt );
|
||||||
|
|
||||||
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
||||||
return;
|
return;
|
||||||
|
@ -1207,13 +1215,17 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||||
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
||||||
{
|
{
|
||||||
// Compute the mirror center and put it on grid.
|
// Compute the mirror center and put it on grid.
|
||||||
wxPoint mirrorPoint = block.Centre();
|
wxPoint mirrorPt = block.Centre();
|
||||||
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
mirrorPt = GetNearestGridPosition( mirrorPt );
|
||||||
SetCrossHairPosition( mirrorPoint );
|
SetCrossHairPosition( mirrorPt );
|
||||||
|
|
||||||
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPoint );
|
if( block.GetCommand() != BLOCK_DUPLICATE )
|
||||||
block.SetAppendUndo();
|
{
|
||||||
MirrorY( block.GetItems(), mirrorPoint );
|
SaveCopyInUndoList( block.GetItems(), UR_MIRRORED_Y, block.AppendUndo(), mirrorPt );
|
||||||
|
block.SetAppendUndo();
|
||||||
|
}
|
||||||
|
|
||||||
|
MirrorY( block.GetItems(), mirrorPt );
|
||||||
|
|
||||||
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( nullptr, wxDefaultPosition, false );
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue