Batch undo for Convert To...

Also repairs drawing of dangling symbols for global labels.
This commit is contained in:
Jeff Young 2023-08-07 18:35:51 +01:00
parent 713d4fc593
commit a7dc720271
2 changed files with 39 additions and 41 deletions

View File

@ -2696,6 +2696,18 @@ void SCH_PAINTER::draw( const SCH_GLOBALLABEL* aLabel, int aLayer )
COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows ); COLOR4D color = getRenderColor( aLabel, LAYER_GLOBLABEL, drawingShadows );
if( drawingDangling )
{
if( aLabel->IsDangling() )
{
drawDanglingSymbol( aLabel->GetTextPos(), color,
schIUScale.MilsToIU( DANGLING_SYMBOL_SIZE / 2 ), true,
drawingShadows, aLabel->IsBrightened() );
}
return;
}
std::vector<VECTOR2I> pts; std::vector<VECTOR2I> pts;
std::deque<VECTOR2D> pts2; std::deque<VECTOR2D> pts2;
@ -2714,7 +2726,7 @@ void SCH_PAINTER::draw( const SCH_GLOBALLABEL* aLabel, int aLayer )
m_gal->SetFillColor( color ); m_gal->SetFillColor( color );
m_gal->DrawPolygon( pts2 ); m_gal->DrawPolygon( pts2 );
} }
else if( !drawingDangling ) else
{ {
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->DrawPolyline( pts2 ); m_gal->DrawPolyline( pts2 );

View File

@ -1826,8 +1826,9 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
DIALOG_CHANGE_SYMBOLS dlg( m_frame, symbol, DIALOG_CHANGE_SYMBOLS::MODE::CHANGE ); DIALOG_CHANGE_SYMBOLS dlg( m_frame, symbol, DIALOG_CHANGE_SYMBOLS::MODE::CHANGE );
dlg.ShowQuasiModal(); dlg.ShowQuasiModal();
} }
}
break; break;
}
case SCH_SHEET_T: case SCH_SHEET_T:
{ {
@ -1875,11 +1876,10 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
// QuasiModal required for help dialog // QuasiModal required for help dialog
if( dlg.ShowQuasiModal() == wxID_OK ) if( dlg.ShowQuasiModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
}
break; break;
}
case SCH_TEXT_T: case SCH_TEXT_T:
case SCH_TEXTBOX_T: case SCH_TEXTBOX_T:
@ -1888,9 +1888,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
// QuasiModal required for syntax help and Scintilla auto-complete // QuasiModal required for syntax help and Scintilla auto-complete
if( dlg.ShowQuasiModal() == wxID_OK ) if( dlg.ShowQuasiModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
} }
break; break;
@ -1903,11 +1901,10 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
// Must be quasi modal for syntax help // Must be quasi modal for syntax help
if( dlg.ShowQuasiModal() == wxID_OK ) if( dlg.ShowQuasiModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
}
break; break;
}
case SCH_FIELD_T: case SCH_FIELD_T:
{ {
@ -1917,19 +1914,19 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
if( !field->IsVisible() ) if( !field->IsVisible() )
clearSelection = true; clearSelection = true;
}
break; break;
}
case SCH_SHAPE_T: case SCH_SHAPE_T:
{ {
DIALOG_SHAPE_PROPERTIES dlg( m_frame, static_cast<SCH_SHAPE*>( curr_item ) ); DIALOG_SHAPE_PROPERTIES dlg( m_frame, static_cast<SCH_SHAPE*>( curr_item ) );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
}
break; break;
}
case SCH_BITMAP_T: case SCH_BITMAP_T:
{ {
@ -1942,8 +1939,9 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
getView()->RecacheAllItems(); getView()->RecacheAllItems();
m_frame->OnModify(); m_frame->OnModify();
} }
}
break; break;
}
case SCH_LINE_T: case SCH_LINE_T:
case SCH_BUS_WIRE_ENTRY_T: case SCH_BUS_WIRE_ENTRY_T:
@ -1963,9 +1961,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
DIALOG_LINE_PROPERTIES dlg( m_frame, lines ); DIALOG_LINE_PROPERTIES dlg( m_frame, lines );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
} }
else if( std::all_of( selection.Items().begin(), selection.Items().end(), else if( std::all_of( selection.Items().begin(), selection.Items().end(),
[&]( const EDA_ITEM* item ) [&]( const EDA_ITEM* item )
@ -1981,9 +1977,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
DIALOG_JUNCTION_PROPS dlg( m_frame, junctions ); DIALOG_JUNCTION_PROPS dlg( m_frame, junctions );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
} }
else if( std::all_of( selection.Items().begin(), selection.Items().end(), else if( std::all_of( selection.Items().begin(), selection.Items().end(),
[&]( const EDA_ITEM* item ) [&]( const EDA_ITEM* item )
@ -2004,9 +1998,7 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, items ); DIALOG_WIRE_BUS_PROPERTIES dlg( m_frame, items );
if( dlg.ShowModal() == wxID_OK ) if( dlg.ShowModal() == wxID_OK )
{
m_frame->OnModify(); m_frame->OnModify();
}
} }
else else
{ {
@ -2038,10 +2030,11 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
EE_SELECTION selection = m_selectionTool->RequestSelection( { SCH_LABEL_LOCATE_ANY_T, EE_SELECTION selection = m_selectionTool->RequestSelection( { SCH_LABEL_LOCATE_ANY_T,
SCH_TEXT_T, SCH_TEXT_T,
SCH_TEXTBOX_T } ); SCH_TEXTBOX_T } );
SCH_COMMIT commit( m_toolMgr );
for( unsigned int i = 0; i < selection.GetSize(); ++i ) for( unsigned int i = 0; i < selection.GetSize(); ++i )
{ {
SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( selection.GetItem( i ) ); SCH_ITEM* item = dynamic_cast<SCH_ITEM*>( selection.GetItem( i ) );
if( item && item->Type() != convertTo ) if( item && item->Type() != convertTo )
{ {
@ -2337,8 +2330,6 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
if( selected ) if( selected )
m_toolMgr->RunAction<EDA_ITEM*>( EE_ACTIONS::removeItemFromSel, item ); m_toolMgr->RunAction<EDA_ITEM*>( EE_ACTIONS::removeItemFromSel, item );
SCH_COMMIT commit( m_toolMgr );
if( !item->IsNew() ) if( !item->IsNew() )
{ {
m_frame->RemoveFromScreen( item, m_frame->GetScreen() ); m_frame->RemoveFromScreen( item, m_frame->GetScreen() );
@ -2348,29 +2339,18 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent )
commit.Added( newtext, m_frame->GetScreen() ); commit.Added( newtext, m_frame->GetScreen() );
} }
commit.Push( _( "Change Item Type" ) );
if( selected ) if( selected )
m_toolMgr->RunAction<EDA_ITEM*>( EE_ACTIONS::addItemToSel, newtext ); m_toolMgr->RunAction<EDA_ITEM*>( EE_ACTIONS::addItemToSel, newtext );
// Otherwise, pointer is owned by the undo stack // Otherwise, pointer is owned by the undo stack
if( item->IsNew() ) if( item->IsNew() )
delete item; delete item;
if( convertTo == SCH_TEXT_T || convertTo == SCH_TEXTBOX_T )
{
if( newtext->IsDangling() )
getView()->Update( newtext, KIGFX::REPAINT );
}
else
{
m_frame->TestDanglingEnds();
}
m_frame->OnModify();
} }
} }
if( !commit.Empty() )
commit.Push( _( "Change To" ) );
if( selection.IsHover() ) if( selection.IsHover() )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection ); m_toolMgr->RunAction( EE_ACTIONS::clearSelection );
@ -2573,7 +2553,9 @@ int SCH_EDIT_TOOL::SetAttribute( const TOOL_EVENT& aEvent )
} }
} }
commit.Push( _( "Set Attribute" ) ); if( !commit.Empty() )
commit.Push( _( "Set Attribute" ) );
return 0; return 0;
} }
@ -2608,7 +2590,9 @@ int SCH_EDIT_TOOL::UnsetAttribute( const TOOL_EVENT& aEvent )
} }
} }
commit.Push( _( "Clear Attribute" ) ); if( !commit.Empty() )
commit.Push( _( "Clear Attribute" ) );
return 0; return 0;
} }
@ -2643,7 +2627,9 @@ int SCH_EDIT_TOOL::ToggleAttribute( const TOOL_EVENT& aEvent )
} }
} }
commit.Push( _( "Toggle Attribute" ) ); if( !commit.Empty() )
commit.Push( _( "Toggle Attribute" ) );
return 0; return 0;
} }