BOARD_COMMIT can be constructed using a PCB_BASE_FRAME*.
This commit is contained in:
parent
b25c407576
commit
497fb31ae0
|
@ -30,14 +30,21 @@
|
||||||
#include <view/view.h>
|
#include <view/view.h>
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#include <tools/pcb_tool.h>
|
#include <tools/pcb_tool.h>
|
||||||
|
|
||||||
BOARD_COMMIT::BOARD_COMMIT( PCB_TOOL* aTool )
|
BOARD_COMMIT::BOARD_COMMIT( PCB_TOOL* aTool )
|
||||||
{
|
{
|
||||||
m_tool = aTool;
|
m_toolMgr = aTool->GetManager();
|
||||||
|
m_editModules = aTool->EditingModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOARD_COMMIT::BOARD_COMMIT( PCB_BASE_FRAME* aFrame )
|
||||||
|
{
|
||||||
|
m_toolMgr = aFrame->GetToolManager();
|
||||||
|
m_editModules = aFrame->IsType( FRAME_PCB_MODULE_EDITOR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,29 +57,29 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
{
|
{
|
||||||
// Objects potentially interested in changes:
|
// Objects potentially interested in changes:
|
||||||
PICKED_ITEMS_LIST undoList;
|
PICKED_ITEMS_LIST undoList;
|
||||||
TOOL_MANAGER* toolMgr = m_tool->GetManager();
|
KIGFX::VIEW* view = m_toolMgr->GetView();
|
||||||
KIGFX::VIEW* view = toolMgr->GetView();
|
BOARD* board = (BOARD*) m_toolMgr->GetModel();
|
||||||
BOARD* board = (BOARD*) toolMgr->GetModel();
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame();
|
||||||
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) toolMgr->GetEditFrame();
|
|
||||||
RN_DATA* ratsnest = board->GetRatsnest();
|
RN_DATA* ratsnest = board->GetRatsnest();
|
||||||
|
|
||||||
bool editModules = m_tool->EditingModules();
|
if( Empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
// Module items need to be saved in the undo buffer before modification
|
for( COMMIT_LINE& ent : m_changes )
|
||||||
if( editModules )
|
|
||||||
{
|
{
|
||||||
frame->SaveCopyInUndoList( board->m_Modules, UR_CHANGED );
|
// Module items need to be saved in the undo buffer before modification
|
||||||
}
|
if( m_editModules )
|
||||||
|
{
|
||||||
|
frame->SaveCopyInUndoList( static_cast<BOARD_ITEM*>( ent.m_copy ), UR_CHANGED );
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_FOREACH( COMMIT_LINE& ent, m_changes )
|
|
||||||
{
|
|
||||||
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
|
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( ent.m_item );
|
||||||
|
|
||||||
switch( ent.m_type )
|
switch( ent.m_type )
|
||||||
{
|
{
|
||||||
case CHT_ADD:
|
case CHT_ADD:
|
||||||
{
|
{
|
||||||
if( !editModules )
|
if( !m_editModules )
|
||||||
{
|
{
|
||||||
ITEM_PICKER itemWrapper( boardItem, UR_NEW );
|
ITEM_PICKER itemWrapper( boardItem, UR_NEW );
|
||||||
undoList.PushItem( itemWrapper );
|
undoList.PushItem( itemWrapper );
|
||||||
|
@ -90,12 +97,13 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
}
|
}
|
||||||
|
|
||||||
view->Add( boardItem );
|
view->Add( boardItem );
|
||||||
|
//ratsnest->Add( boardItem ); // TODO currently done by BOARD::Add()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CHT_REMOVE:
|
case CHT_REMOVE:
|
||||||
{
|
{
|
||||||
if( !editModules )
|
if( !m_editModules )
|
||||||
{
|
{
|
||||||
ITEM_PICKER itemWrapper( boardItem, UR_DELETED );
|
ITEM_PICKER itemWrapper( boardItem, UR_DELETED );
|
||||||
undoList.PushItem( itemWrapper );
|
undoList.PushItem( itemWrapper );
|
||||||
|
@ -116,7 +124,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
|
|
||||||
case CHT_MODIFY:
|
case CHT_MODIFY:
|
||||||
{
|
{
|
||||||
if( !editModules )
|
if( !m_editModules )
|
||||||
{
|
{
|
||||||
ITEM_PICKER itemWrapper( boardItem, UR_CHANGED );
|
ITEM_PICKER itemWrapper( boardItem, UR_CHANGED );
|
||||||
itemWrapper.SetLink( ent.m_copy );
|
itemWrapper.SetLink( ent.m_copy );
|
||||||
|
@ -140,13 +148,13 @@ void BOARD_COMMIT::Push( const wxString& aMessage )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !editModules )
|
if( !m_editModules )
|
||||||
frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );
|
frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );
|
||||||
|
|
||||||
frame->OnModify();
|
frame->OnModify();
|
||||||
ratsnest->Recalculate();
|
ratsnest->Recalculate();
|
||||||
|
|
||||||
m_committed = true;
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,18 +30,22 @@
|
||||||
class BOARD_ITEM;
|
class BOARD_ITEM;
|
||||||
class PICKED_ITEMS_LIST;
|
class PICKED_ITEMS_LIST;
|
||||||
class PCB_TOOL;
|
class PCB_TOOL;
|
||||||
|
class PCB_BASE_FRAME;
|
||||||
|
class TOOL_MANAGER;
|
||||||
|
|
||||||
class BOARD_COMMIT : public COMMIT
|
class BOARD_COMMIT : public COMMIT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BOARD_COMMIT( PCB_TOOL* aTool );
|
BOARD_COMMIT( PCB_TOOL* aTool );
|
||||||
|
BOARD_COMMIT( PCB_BASE_FRAME* aFrame );
|
||||||
virtual ~BOARD_COMMIT();
|
virtual ~BOARD_COMMIT();
|
||||||
|
|
||||||
virtual void Push( const wxString& aMessage );
|
virtual void Push( const wxString& aMessage );
|
||||||
virtual void Revert();
|
virtual void Revert();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PCB_TOOL* m_tool;
|
TOOL_MANAGER* m_toolMgr;
|
||||||
|
bool m_editModules;
|
||||||
virtual EDA_ITEM* parentObject( EDA_ITEM* aItem ) const;
|
virtual EDA_ITEM* parentObject( EDA_ITEM* aItem ) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue