Finish up remaining block operation inconsistencies.

In particular, don't move block back to start when duplicating,
and don't move crosshair back to start when doing a cut, copy, or
paste.

Also fixes undo for libEdit block duplicate.

Fixes: lp:1740138
* https://bugs.launchpad.net/kicad/+bug/1740138
This commit is contained in:
Jeff Young 2018-11-14 21:54:53 +00:00
parent 350a6052c0
commit d65bb73d4e
7 changed files with 37 additions and 48 deletions

View File

@ -209,10 +209,16 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->SetState( state );
block->SetCommand( command );
m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
SetCrossHairPosition( block->GetEnd() );
if( block->GetCommand() != BLOCK_ABORT )
if( block->GetCommand() != BLOCK_ABORT
&& block->GetCommand() != BLOCK_DUPLICATE
&& block->GetCommand() != BLOCK_COPY
&& block->GetCommand() != BLOCK_CUT
&& block->GetCommand() != BLOCK_DELETE )
{
SetCrossHairPosition( block->GetEnd() );
m_canvas->MoveCursorToCrossHair();
}
}
if( m_canvas->IsMouseCaptured() )
@ -250,6 +256,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
if( block->GetCommand() == BLOCK_DUPLICATE )
{
DuplicateItemsInList( GetScreen(), block->GetItems(), block->GetMoveVector() );
block->SetLastCursorPosition( GetCrossHairPosition() );
SaveCopyInUndoList( block->GetItems(), UR_NEW );
}

View File

@ -453,6 +453,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
settings->m_ShowHiddenText = false;
settings->m_ShowHiddenPins = m_showAllPins;
settings->SetShowPageLimits( m_showPageLimits );
settings->m_ShowUmbilicals = true;
}
@ -554,6 +555,7 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
// Hidden elements must be editable
settings->m_ShowHiddenText = true;
settings->m_ShowHiddenPins = true;
settings->m_ShowUmbilicals = false;
}

View File

@ -154,6 +154,8 @@ void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* a
newItem->SetFlags( SELECTED );
oldItem->ClearFlags( SELECTED );
newItem->SetOffset( aBlock->GetMoveVector() );
aItemsList.SetPickedItem( newItem, ii );
aItemsList.SetPickedItemStatus( UR_NEW, ii );
@ -162,45 +164,6 @@ void LIB_EDIT_FRAME::BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* a
}
void LIB_EDIT_FRAME::BlockMirrorSelectedItemsH( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
{
for( LIB_ITEM& item : aPart->GetDrawItems() )
{
if( !item.IsSelected() )
continue;
item.MirrorHorizontal( aCenter );
item.ClearFlags();
}
}
void LIB_EDIT_FRAME::BlockMirrorSelectedItemsV( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
{
for( LIB_ITEM& item : aPart->GetDrawItems() )
{
if( !item.IsSelected() )
continue;
item.MirrorVertical( aCenter );
item.ClearFlags();
}
}
void LIB_EDIT_FRAME::BlockRotateSelectedItems( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock )
{
for( LIB_ITEM& item : aPart->GetDrawItems() )
{
if( !item.IsSelected() )
continue;
item.Rotate( aCenter );
item.ClearFlags();
}
}
int LIB_EDIT_FRAME::BlockCommand( EDA_KEY key )
{
int cmd = BLOCK_IDLE;
@ -281,10 +244,16 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->SetState( state );
block->SetCommand( command );
m_canvas->SetMouseCapture( DrawAndSizingBlockOutlines, AbortBlockCurrentCommand );
SetCrossHairPosition( wxPoint( block->GetRight(), block->GetBottom() ) );
if( block->GetCommand() != BLOCK_ABORT )
if( block->GetCommand() != BLOCK_ABORT
&& block->GetCommand() != BLOCK_DUPLICATE
&& block->GetCommand() != BLOCK_COPY
&& block->GetCommand() != BLOCK_CUT
&& block->GetCommand() != BLOCK_DELETE )
{
SetCrossHairPosition( block->GetEnd() );
m_canvas->MoveCursorToCrossHair();
}
}
if( m_canvas->IsMouseCaptured() )
@ -308,7 +277,18 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
block->SetState( STATE_BLOCK_MOVE );
if( block->GetCommand() == BLOCK_DUPLICATE )
{
if( block->AppendUndo() )
; // UR_LIBEDIT saves entire state, so no need to append anything more
else
{
SaveCopyInUndoList( GetCurPart(), UR_LIBEDIT );
block->SetAppendUndo();
}
BlockCopySelectedItems( pt, GetCurPart(), block );
block->SetLastCursorPosition( GetCrossHairPosition( true ) );
}
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );

View File

@ -749,9 +749,6 @@ public:
void BlockMoveSelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock );
void BlockDeleteSelectedItems( LIB_PART* aPart, BLOCK_SELECTOR* aBlock );
void BlockCopySelectedItems( const wxPoint& aOffset, LIB_PART* aPart, BLOCK_SELECTOR* aBlock );
void BlockMirrorSelectedItemsH( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock );
void BlockMirrorSelectedItemsV( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock );
void BlockRotateSelectedItems( const wxPoint& aCenter, LIB_PART* aPart, BLOCK_SELECTOR* aBlock );
void KiwayMailIn( KIWAY_EXPRESS& mail ) override;

View File

@ -229,7 +229,7 @@ void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST
if( aItemsList.GetCount() == 0 )
return;
// Keep trace of existing sheet paths. Duplicate block can modify this list
// Keep track of existing sheet paths. Duplicate block can modify this list
bool hasSheetCopied = false;
SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
@ -238,6 +238,7 @@ void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST
{
olditem = static_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
newitem = DuplicateStruct( olditem );
newitem->Move( aMoveVector );
aItemsList.SetPickedItem( newitem, ii );
aItemsList.SetPickedItemStatus( UR_NEW, ii );

View File

@ -406,7 +406,7 @@ void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
m_gal->StrokeText( aField->GetText(), pos, orient );
// Draw the umbilical line
if( aField->IsMoving() )
if( aField->IsMoving() && m_schSettings->m_ShowUmbilicals )
{
m_gal->SetLineWidth( m_schSettings.m_outlineWidth );
m_gal->SetStrokeColor( COLOR4D( 0.0, 0.0, 1.0, 1.0 ) );

View File

@ -100,6 +100,8 @@ public:
bool m_ShowHiddenText;
bool m_ShowHiddenPins;
bool m_ShowPinsElectricalType;
bool m_ShowUmbilicals;
};