Fix some issues with undo.
Also fixes the baseline being visible while placing the meander.
This commit is contained in:
parent
d10b0b053e
commit
44e0821e13
|
@ -210,6 +210,8 @@ public:
|
||||||
void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
void EditStart( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||||
BOARD_COMMIT* aCommit ) override
|
BOARD_COMMIT* aCommit ) override
|
||||||
{
|
{
|
||||||
|
m_removedItems.clear();
|
||||||
|
|
||||||
if( aCommit )
|
if( aCommit )
|
||||||
aCommit->Modify( this );
|
aCommit->Modify( this );
|
||||||
|
|
||||||
|
@ -345,7 +347,7 @@ public:
|
||||||
wxASSERT( startItem );
|
wxASSERT( startItem );
|
||||||
wxASSERT( endItem );
|
wxASSERT( endItem );
|
||||||
|
|
||||||
if( !startItem || !endItem )
|
if( !startItem || !endItem || startSnapPoint == endSnapPoint )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PNS::LINE line = world->AssembleLine( startItem, nullptr, false, true );
|
PNS::LINE line = world->AssembleLine( startItem, nullptr, false, true );
|
||||||
|
@ -575,8 +577,11 @@ public:
|
||||||
// LINE does not have a separate remover, as LINEs are never truly a member of the tree
|
// LINE does not have a separate remover, as LINEs are never truly a member of the tree
|
||||||
for( PNS::LINKED_ITEM* li : line->Links() )
|
for( PNS::LINKED_ITEM* li : line->Links() )
|
||||||
{
|
{
|
||||||
if( li->Parent() && aCommit )
|
if( li->Parent() )
|
||||||
aCommit->Remove( li->Parent() );
|
{
|
||||||
|
aFrame->GetCanvas()->GetView()->Hide( li->Parent(), true );
|
||||||
|
m_removedItems.insert( li->Parent() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
world->Remove( *line );
|
world->Remove( *line );
|
||||||
|
@ -649,6 +654,14 @@ public:
|
||||||
std::set<BOARD_ITEM*> routerRemovedItems = aTool->GetRouterCommitRemovedItems();
|
std::set<BOARD_ITEM*> routerRemovedItems = aTool->GetRouterCommitRemovedItems();
|
||||||
std::set<BOARD_ITEM*> routerAddedItems = aTool->GetRouterCommitAddedItems();
|
std::set<BOARD_ITEM*> routerAddedItems = aTool->GetRouterCommitAddedItems();
|
||||||
|
|
||||||
|
for( BOARD_ITEM* item : m_removedItems )
|
||||||
|
{
|
||||||
|
item->ClearSelected();
|
||||||
|
aCommit->Remove( item );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_removedItems.clear();
|
||||||
|
|
||||||
for( BOARD_ITEM* item : routerRemovedItems )
|
for( BOARD_ITEM* item : routerRemovedItems )
|
||||||
{
|
{
|
||||||
item->ClearSelected();
|
item->ClearSelected();
|
||||||
|
@ -665,6 +678,18 @@ public:
|
||||||
aCommit->Push( aCommitMsg, aCommitFlags );
|
aCommit->Push( aCommitMsg, aCommitFlags );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditRevert( GENERATOR_TOOL* aTool, BOARD* aBoard, PCB_BASE_EDIT_FRAME* aFrame,
|
||||||
|
BOARD_COMMIT* aCommit ) override
|
||||||
|
{
|
||||||
|
for( BOARD_ITEM* item : m_removedItems )
|
||||||
|
aFrame->GetCanvas()->GetView()->Hide( item, false );
|
||||||
|
|
||||||
|
m_removedItems.clear();
|
||||||
|
|
||||||
|
if( aCommit )
|
||||||
|
aCommit->Revert();
|
||||||
|
}
|
||||||
|
|
||||||
bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> points ) const override
|
bool MakeEditPoints( std::shared_ptr<EDIT_POINTS> points ) const override
|
||||||
{
|
{
|
||||||
points->AddPoint( m_origin );
|
points->AddPoint( m_origin );
|
||||||
|
@ -1019,6 +1044,9 @@ protected:
|
||||||
|
|
||||||
PNS::MEANDER_PLACER_BASE::TUNING_STATUS m_tuningStatus =
|
PNS::MEANDER_PLACER_BASE::TUNING_STATUS m_tuningStatus =
|
||||||
PNS::MEANDER_PLACER_BASE::TUNING_STATUS::TUNED;
|
PNS::MEANDER_PLACER_BASE::TUNING_STATUS::TUNED;
|
||||||
|
|
||||||
|
// Temp storage during editing
|
||||||
|
std::set<BOARD_ITEM*> m_removedItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
const wxString PCB_GENERATOR_MEANDERS::DISPLAY_NAME = _HKI( "Meanders" );
|
const wxString PCB_GENERATOR_MEANDERS::DISPLAY_NAME = _HKI( "Meanders" );
|
||||||
|
@ -1133,11 +1161,15 @@ int DRAWING_TOOL::PlaceMeander( const TOOL_EVENT& aEvent )
|
||||||
picker->SetCancelHandler(
|
picker->SetCancelHandler(
|
||||||
[this]()
|
[this]()
|
||||||
{
|
{
|
||||||
if( m_pickerItem )
|
GENERATOR_TOOL* generatorTool = m_toolMgr->GetTool<GENERATOR_TOOL>();
|
||||||
m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->UnbrightenItem( m_pickerItem );
|
|
||||||
|
|
||||||
delete m_meander;
|
if( m_meander )
|
||||||
m_meander = nullptr;
|
{
|
||||||
|
m_meander->EditRevert( generatorTool, m_board, m_frame, nullptr );
|
||||||
|
|
||||||
|
delete m_meander;
|
||||||
|
m_meander = nullptr;
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetFinalizeHandler(
|
picker->SetFinalizeHandler(
|
||||||
|
|
Loading…
Reference in New Issue