本文整理汇总了C++中BOARD_ITEM::SwapData方法的典型用法代码示例。如果您正苦于以下问题:C++ BOARD_ITEM::SwapData方法的具体用法?C++ BOARD_ITEM::SwapData怎么用?C++ BOARD_ITEM::SwapData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOARD_ITEM
的用法示例。
在下文中一共展示了BOARD_ITEM::SwapData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Revert
void BOARD_COMMIT::Revert()
{
PICKED_ITEMS_LIST undoList;
KIGFX::VIEW* view = m_toolMgr->GetView();
BOARD* board = (BOARD*) m_toolMgr->GetModel();
auto connectivity = board->GetConnectivity();
for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
{
COMMIT_LINE& ent = *it;
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
int changeType = ent.m_type & CHT_TYPE;
int changeFlags = ent.m_type & CHT_FLAGS;
switch( changeType )
{
case CHT_ADD:
if( !( changeFlags & CHT_DONE ) )
break;
view->Remove( item );
connectivity->Remove( item );
board->Remove( item );
break;
case CHT_REMOVE:
if( !( changeFlags & CHT_DONE ) )
break;
if( item->Type() == PCB_MODULE_T )
{
MODULE* newModule = static_cast<MODULE*>( item );
newModule->RunOnChildren( std::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
}
view->Add( item );
connectivity->Add( item );
board->Add( item );
break;
case CHT_MODIFY:
{
view->Remove( item );
connectivity->Remove( item );
item->SwapData( copy );
item->ClearFlags( SELECTED );
// Update all pads/drawings/texts, as they become invalid
// for the VIEW after SwapData() called for modules
if( item->Type() == PCB_MODULE_T )
{
MODULE* newModule = static_cast<MODULE*>( item );
newModule->RunOnChildren( std::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
}
view->Add( item );
connectivity->Add( item );
delete copy;
break;
}
default:
wxASSERT( false );
break;
}
}
if ( !m_editModules )
connectivity->RecalculateRatsnest();
clear();
}
示例2: PutDataInPreviousState
void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand,
bool aRebuildRatsnet )
{
BOARD_ITEM* item;
bool not_found = false;
bool reBuild_ratsnest = false;
KIGFX::VIEW* view = GetGalCanvas()->GetView();
RN_DATA* ratsnest = GetBoard()->GetRatsnest();
// Undo in the reverse order of list creation: (this can allow stacked changes
// like the same item can be changes and deleted in the same complex command
bool build_item_list = true; // if true the list of existing items must be rebuilt
for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- )
{
item = (BOARD_ITEM*) aList->GetPickedItem( ii );
wxASSERT( item );
/* Test for existence of item on board.
* It could be deleted, and no more on board:
* - if a call to SaveCopyInUndoList was forgotten in Pcbnew
* - in zones outlines, when a change in one zone merges this zone with an other
* This test avoids a Pcbnew crash
* Obviously, this test is not made for deleted items
*/
UNDO_REDO_T status = aList->GetPickedItemStatus( ii );
if( status != UR_DELETED )
{
if( build_item_list )
// Build list of existing items, for integrity test
TestForExistingItem( GetBoard(), NULL );
build_item_list = false;
if( !TestForExistingItem( GetBoard(), item ) )
{
// Remove this non existent item
aList->RemovePicker( ii );
ii++; // the current item was removed, ii points now the next item
// decrement it because it will be incremented later
not_found = true;
continue;
}
}
item->ClearFlags();
// see if we must rebuild ratsnets and pointers lists
switch( item->Type() )
{
case PCB_MODULE_T:
case PCB_ZONE_AREA_T:
case PCB_TRACE_T:
case PCB_VIA_T:
reBuild_ratsnest = true;
break;
default:
break;
}
switch( aList->GetPickedItemStatus( ii ) )
{
case UR_CHANGED: /* Exchange old and new data for each item */
{
BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
// Remove all pads/drawings/texts, as they become invalid
// for the VIEW after SwapData() called for modules
if( item->Type() == PCB_MODULE_T )
{
MODULE* oldModule = static_cast<MODULE*>( item );
oldModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) );
}
ratsnest->Remove( item );
item->SwapData( image );
// Update all pads/drawings/texts, as they become invalid
// for the VIEW after SwapData() called for modules
if( item->Type() == PCB_MODULE_T )
{
MODULE* newModule = static_cast<MODULE*>( item );
newModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
}
ratsnest->Add( item );
item->ClearFlags( SELECTED );
item->ViewUpdate( KIGFX::VIEW_ITEM::LAYERS );
}
break;
case UR_NEW: /* new items are deleted */
aList->SetPickedItemStatus( UR_DELETED, ii );
GetBoard()->Remove( item );
if( item->Type() == PCB_MODULE_T )
{
//.........这里部分代码省略.........
示例3: Revert
void BOARD_COMMIT::Revert()
{
PICKED_ITEMS_LIST undoList;
KIGFX::VIEW* view = m_toolMgr->GetView();
BOARD* board = (BOARD*) m_toolMgr->GetModel();
RN_DATA* ratsnest = board->GetRatsnest();
for( auto it = m_changes.rbegin(); it != m_changes.rend(); ++it )
{
COMMIT_LINE& ent = *it;
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( ent.m_item );
BOARD_ITEM* copy = static_cast<BOARD_ITEM*>( ent.m_copy );
switch( ent.m_type )
{
case CHT_ADD:
if( item->Type() == PCB_MODULE_T )
{
MODULE* oldModule = static_cast<MODULE*>( item );
oldModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) );
}
view->Remove( item );
ratsnest->Remove( item );
break;
case CHT_REMOVE:
if( item->Type() == PCB_MODULE_T )
{
MODULE* newModule = static_cast<MODULE*>( item );
newModule->RunOnChildren( boost::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
newModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
}
view->Add( item );
ratsnest->Add( item );
break;
case CHT_MODIFY:
{
if( item->Type() == PCB_MODULE_T )
{
MODULE* oldModule = static_cast<MODULE*>( item );
oldModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) );
}
view->Remove( item );
ratsnest->Remove( item );
item->SwapData( copy );
item->ClearFlags( SELECTED );
// Update all pads/drawings/texts, as they become invalid
// for the VIEW after SwapData() called for modules
if( item->Type() == PCB_MODULE_T )
{
MODULE* newModule = static_cast<MODULE*>( item );
newModule->RunOnChildren( boost::bind( &EDA_ITEM::ClearFlags, _1, SELECTED ) );
newModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) );
}
view->Add( item );
ratsnest->Add( item );
delete copy;
break;
}
default:
assert( false );
break;
}
}
ratsnest->Recalculate();
clear();
}