本文整理汇总了C++中PICKED_ITEMS_LIST::GetItemWrapper方法的典型用法代码示例。如果您正苦于以下问题:C++ PICKED_ITEMS_LIST::GetItemWrapper方法的具体用法?C++ PICKED_ITEMS_LIST::GetItemWrapper怎么用?C++ PICKED_ITEMS_LIST::GetItemWrapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PICKED_ITEMS_LIST
的用法示例。
在下文中一共展示了PICKED_ITEMS_LIST::GetItemWrapper方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateCopyOfZonesList
//.........这里部分代码省略.........
for( unsigned kk = 0; kk < aPickList.GetCount(); kk++ )
{
UNDO_REDO_T status = aPickList.GetPickedItemStatus( kk );
ZONE_CONTAINER* ref = (ZONE_CONTAINER*) aPickList.GetPickedItem( kk );
for( unsigned ii = 0; ; ii++ ) // analyse the main picked list
{
ZONE_CONTAINER* zone = aPcb->GetArea( ii );
if( zone == NULL )
{
/* End of list: the stored item is not found:
* it must be in aDeletedList:
* search it and restore initial values
* or
* if flagged UR_NEW: remove it definitively
*/
if( status == UR_NEW )
{
delete ref;
ref = NULL;
aPickList.RemovePicker( kk );
kk--;
}
else
{
ZONE_CONTAINER* zcopy = (ZONE_CONTAINER*) aPickList.GetPickedItemLink( kk );
aPickList.SetPickedItemStatus( UR_DELETED, kk );
wxASSERT_MSG( zcopy != NULL,
wxT( "UpdateCopyOfZonesList() error: link = NULL" ) );
ref->Copy( zcopy );
// the copy was deleted; the link does not exists now.
aPickList.SetPickedItemLink( NULL, kk );
delete zcopy;
}
// Remove this item from aAuxiliaryList, mainly for tests purpose
bool notfound = true;
for( unsigned nn = 0; nn < aAuxiliaryList.GetCount(); nn++ )
{
if( ref != NULL && aAuxiliaryList.GetPickedItem( nn ) == ref )
{
aAuxiliaryList.RemovePicker( nn );
notfound = false;
break;
}
}
wxASSERT_MSG( notfound != true,
wxT( "UpdateCopyOfZonesList() error: item not found in "
"aAuxiliaryList" ) );
break;
}
if( zone == ref ) // picked zone found
{
if( aPickList.GetPickedItemStatus( kk ) != UR_NEW )
{
ZONE_CONTAINER* zcopy = (ZONE_CONTAINER*) aPickList.GetPickedItemLink( kk );
if( zone->IsSame( *zcopy ) ) // Remove picked, because no changes
{
delete zcopy; // Delete copy
aPickList.RemovePicker( kk );
kk--;
}
}
break;
}
}
}
// Add new zones in main pick list, and remove pickers from Auxiliary List
for( unsigned ii = 0; ii < aAuxiliaryList.GetCount(); )
{
if( aAuxiliaryList.GetPickedItemStatus( ii ) == UR_NEW )
{
ITEM_PICKER picker = aAuxiliaryList.GetItemWrapper( ii );
aPickList.PushItem( picker );
aAuxiliaryList.RemovePicker( ii );
}
else if( aAuxiliaryList.GetPickedItemStatus( ii ) == UR_DELETED )
{
delete aAuxiliaryList.GetPickedItemLink( ii );
aAuxiliaryList.RemovePicker( ii );
}
else
ii++;
}
// Should not occur:
wxASSERT_MSG( aAuxiliaryList.GetCount() == 0,
wxT( "UpdateCopyOfZonesList() error: aAuxiliaryList not empty." ) );
}
示例2: ZoneMerge
int PCB_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent )
{
SELECTION selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
BOARD* board = getModel<BOARD>();
RN_DATA* ratsnest = board->GetRatsnest();
KIGFX::VIEW* view = getView();
if( selection.Size() < 2 )
return 0;
PICKED_ITEMS_LIST changes;
int netcode = -1;
// Loop through all combinations
for( int ia1 = 0; ia1 < selection.Size() - 1; ++ia1 )
{
ZONE_CONTAINER* curr_area = dynamic_cast<ZONE_CONTAINER*>( selection.Item<EDA_ITEM>( ia1 ) );
if( !curr_area )
continue;
netcode = curr_area->GetNetCode();
EDA_RECT b1 = curr_area->Outline()->GetBoundingBox();
bool mod_ia1 = false;
for( int ia2 = selection.Size() - 1; ia2 > ia1; --ia2 )
{
ZONE_CONTAINER* area2 = dynamic_cast<ZONE_CONTAINER*>( selection.Item<EDA_ITEM>( ia2 ) );
if( !area2 )
continue;
if( area2->GetNetCode() != netcode )
continue;
if( curr_area->GetPriority() != area2->GetPriority() )
continue;
if( curr_area->GetIsKeepout() != area2->GetIsKeepout() )
continue;
if( curr_area->GetLayer() != area2->GetLayer() )
continue;
EDA_RECT b2 = area2->Outline()->GetBoundingBox();
if( b1.Intersects( b2 ) )
{
EDA_ITEM* backup = curr_area->Clone();
bool ret = board->TestAreaIntersection( curr_area, area2 );
if( ret && board->CombineAreas( &changes, curr_area, area2 ) )
{
mod_ia1 = true;
selection.items.RemovePicker( ia2 );
ITEM_PICKER picker( curr_area, UR_CHANGED );
picker.SetLink( backup );
changes.PushItem( picker );
}
else
{
delete backup;
}
}
}
if( mod_ia1 )
--ia1; // if modified, we need to check it again
}
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_frame->SaveCopyInUndoList( changes, UR_UNSPECIFIED );
for( unsigned i = 0; i < changes.GetCount(); ++i )
{
ITEM_PICKER picker = changes.GetItemWrapper( i );
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( picker.GetItem() );
if( picker.GetStatus() == UR_DELETED )
{
view->Remove( item );
ratsnest->Remove( item );
}
else if( picker.GetStatus() == UR_CHANGED )
{
item->ViewUpdate( KIGFX::VIEW_ITEM::ALL );
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, item );
}
}
return 0;
}
示例3: SaveCopyInUndoList
void PCB_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
// First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified),
// take the first occurence of the module.
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
ITEM_PICKER picker = aItemsList.GetItemWrapper(ii);
BOARD_ITEM* item = (BOARD_ITEM*) aItemsList.GetPickedItem( ii );
// For texts belonging to modules, we need to save state of the parent module
if( item->Type() == PCB_MODULE_TEXT_T || item->Type() == PCB_PAD_T )
{
item = item->GetParent();
wxASSERT( item->Type() == PCB_MODULE_T );
if( item == NULL )
continue;
bool found = false;
for( unsigned j = 0; j < commandToUndo->GetCount(); j++ )
{
if( commandToUndo->GetPickedItem( j ) == item && commandToUndo->GetPickedItemStatus( j ) == UR_CHANGED )
{
found = true;
break;
}
}
if( !found )
commandToUndo->PushItem( ITEM_PICKER(item, UR_CHANGED ) );
else
continue;
} else {
commandToUndo->PushItem( picker );
}
}
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii );
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED )
{
command = aTypeCommand;
commandToUndo->SetPickedItemStatus( command, ii );
}
wxASSERT( item );
switch( command )
{
case UR_CHANGED:
/* If needed, create a copy of item, and put in undo list
* in the picker, as link
* If this link is not null, the copy is already done
*/
if( commandToUndo->GetPickedItemLink( ii ) == NULL )
{
EDA_ITEM* cloned = item->Clone();
commandToUndo->SetPickedItemLink( cloned, ii );
}
break;
case UR_MOVED:
case UR_ROTATED:
case UR_ROTATED_CLOCKWISE:
case UR_FLIPPED:
case UR_NEW:
case UR_DELETED:
break;
default:
{
wxString msg;
msg.Printf( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), command );
wxMessageBox( msg );
}
break;
}
}
if( commandToUndo->GetCount() )
{
/* Save the copy in undo list */
GetScreen()->PushCommandToUndoList( commandToUndo );
/* Clear redo list, because after a new command one cannot redo a command */
//.........这里部分代码省略.........
示例4: SaveCopyInUndoList
void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint )
{
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
// First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified),
// take the first occurence of the module (we save copies of modules when one of its subitems
// is changed).
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
ITEM_PICKER curr_picker = aItemsList.GetItemWrapper(ii);
BOARD_ITEM* item = (BOARD_ITEM*) aItemsList.GetPickedItem( ii );
// For items belonging to modules, we need to save state of the parent module
if( item->Type() == PCB_MODULE_TEXT_T || item->Type() == PCB_MODULE_EDGE_T
|| item->Type() == PCB_PAD_T )
{
// Item to be stored in the undo buffer is the parent module
item = item->GetParent();
wxASSERT( item && item->Type() == PCB_MODULE_T );
if( item == NULL )
continue;
// Check if the parent module has already been saved in another entry
bool found = false;
for( unsigned j = 0; j < commandToUndo->GetCount(); j++ )
{
if( commandToUndo->GetPickedItem( j ) == item && commandToUndo->GetPickedItemStatus( j ) == UR_CHANGED )
{
found = true;
break;
}
}
if( !found )
{
// Create a clean copy of the parent module
MODULE* orig = static_cast<MODULE*>( item );
MODULE* clone = new MODULE( *orig );
clone->SetParent( GetBoard() );
// Clear current flags (which can be temporary set by a current edit command)
for( EDA_ITEM* loc_item = clone->GraphicalItemsList(); loc_item;
loc_item = loc_item->Next() )
loc_item->ClearFlags();
for( D_PAD* pad = clone->PadsList(); pad; pad = pad->Next() )
pad->ClearFlags();
clone->Reference().ClearFlags();
clone->Value().ClearFlags();
ITEM_PICKER picker( item, UR_CHANGED );
picker.SetLink( clone );
commandToUndo->PushItem( picker );
orig->SetLastEditTime();
}
else
{
continue;
}
}
else
{
// Normal case: all other BOARD_ITEMs, are simply copied to the new list
commandToUndo->PushItem( curr_picker );
}
}
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii );
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED )
{
command = aTypeCommand;
commandToUndo->SetPickedItemStatus( command, ii );
}
wxASSERT( item );
switch( command )
{
case UR_CHANGED:
case UR_DRILLORIGIN:
case UR_GRIDORIGIN:
/* If needed, create a copy of item, and put in undo list
* in the picker, as link
* If this link is not null, the copy is already done
*/
if( commandToUndo->GetPickedItemLink( ii ) == NULL )
{
EDA_ITEM* cloned = item->Clone();
//.........这里部分代码省略.........
示例5: RunActionPlugin
//.........这里部分代码省略.........
// If item has a list it's mean that the element is on the board
if( item->GetList() == NULL )
{
deletedItemsList.PushItem( picker );
}
break;
case PCB_ZONE_AREA_T:
{
bool zoneFound = false;
for( int ii = 0; ii < currentPcb->GetAreaCount(); ii++ )
zoneFound |= currentPcb->GetArea( ii ) == item;
if( !zoneFound )
{
deletedItemsList.PushItem( picker );
}
break;
}
default:
wxString msg;
msg.Printf( _( "(PCB_EDIT_FRAME::OnActionPlugin) needs work: "
"BOARD_ITEM type (%d) not handled" ),
item->Type() );
wxFAIL_MSG( msg );
break;
}
}
// Mark deleted elements in undolist
for( unsigned int i = 0; i < deletedItemsList.GetCount(); i++ )
{
oldBuffer->PushItem( deletedItemsList.GetItemWrapper( i ) );
}
// Find new modules
for( BOARD_ITEM* item = currentPcb->m_Modules; item != NULL; item = item->Next() )
{
if( !oldBuffer->ContainsItem( item ) )
{
ITEM_PICKER picker( item, UR_NEW );
oldBuffer->PushItem( picker );
}
}
for( BOARD_ITEM* item = currentPcb->m_Track; item != NULL; item = item->Next() )
{
if( !oldBuffer->ContainsItem( item ) )
{
ITEM_PICKER picker( item, UR_NEW );
oldBuffer->PushItem( picker );
}
}
for( BOARD_ITEM* item = currentPcb->m_Drawings; item != NULL; item = item->Next() )
{
if( !oldBuffer->ContainsItem( item ) )
{
ITEM_PICKER picker( item, UR_NEW );
oldBuffer->PushItem( picker );
}
}
for( BOARD_ITEM* item = currentPcb->m_SegZoneDeprecated; item != NULL; item = item->Next() )
{
if( !oldBuffer->ContainsItem( item ) )
{
ITEM_PICKER picker( item, UR_NEW );
oldBuffer->PushItem( picker );
}
}
for( int ii = 0; ii < currentPcb->GetAreaCount(); ii++ )
{
if( !oldBuffer->ContainsItem( (EDA_ITEM*) currentPcb->GetArea( ii ) ) )
{
ITEM_PICKER picker( (EDA_ITEM*) currentPcb->GetArea(
ii ), UR_NEW );
oldBuffer->PushItem( picker );
}
}
GetScreen()->PushCommandToUndoList( oldBuffer );
if( IsGalCanvasActive() )
{
UseGalCanvas( GetGalCanvas() );
}
else
{
UpdateUserInterface();
GetScreen()->SetModify();
Refresh();
}
}