本文整理汇总了C++中BOARD_ITEM::ClearFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ BOARD_ITEM::ClearFlags方法的具体用法?C++ BOARD_ITEM::ClearFlags怎么用?C++ BOARD_ITEM::ClearFlags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BOARD_ITEM
的用法示例。
在下文中一共展示了BOARD_ITEM::ClearFlags方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Block_Move
void PCB_EDIT_FRAME::Block_Move()
{
OnModify();
wxPoint MoveVector = GetScreen()->m_BlockLocate.GetMoveVector();
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
itemsList->m_Status = UR_MOVED;
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
itemsList->SetPickedItemStatus( UR_MOVED, ii );
item->Move( MoveVector );
GetBoard()->GetConnectivity()->Update( item );
item->ClearFlags( IS_MOVED );
switch( item->Type() )
{
case PCB_MODULE_T:
m_Pcb->m_Status_Pcb = 0;
item->ClearFlags();
break;
// Move track segments
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like a track segment on a copper layer)
m_Pcb->m_Status_Pcb = 0;
break;
case PCB_ZONE_AREA_T:
case PCB_LINE_T:
case PCB_TEXT_T:
case PCB_TARGET_T:
case PCB_DIMENSION_T:
break;
// This item is not put in undo list
case PCB_ZONE_T: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii );
ii--;
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Move( ) error: unexpected type" ) );
break;
}
}
SaveCopyInUndoList( *itemsList, UR_MOVED, MoveVector );
Compile_Ratsnest( NULL, true );
m_canvas->Refresh( true );
}
示例2: CopyMarkedItems
/* Copy marked items, at new position = old position + offset
*/
void CopyMarkedItems( MODULE* module, wxPoint offset )
{
if( module == NULL )
return;
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->ClearFlags( SELECTED );
D_PAD* NewPad = new D_PAD( *pad );
NewPad->SetParent( module );
NewPad->SetFlags( SELECTED );
module->Pads().PushFront( NewPad );
}
BOARD_ITEM* newItem;
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
{
if( !item->IsSelected() )
continue;
item->ClearFlags( SELECTED );
newItem = (BOARD_ITEM*)item->Clone();
newItem->SetParent( module );
newItem->SetFlags( SELECTED );
module->GraphicalItems().PushFront( newItem );
}
MoveMarkedItems( module, offset );
}
示例3: Block_Flip
void PCB_EDIT_FRAME::Block_Flip()
{
#define INVERT( pos ) (pos) = center.y - ( (pos) - center.y )
wxPoint memo;
wxPoint center; // Position of the axis for inversion of all elements
OnModify();
PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems();
itemsList->m_Status = UR_FLIPPED;
memo = GetCrossHairPosition();
center = GetScreen()->m_BlockLocate.Centre();
for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ )
{
BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii );
wxASSERT( item );
itemsList->SetPickedItemStatus( UR_FLIPPED, ii );
item->Flip( center );
switch( item->Type() )
{
case PCB_MODULE_T:
item->ClearFlags();
m_Pcb->m_Status_Pcb = 0;
break;
// Move and rotate the track segments
case PCB_TRACE_T: // a track segment (segment on a copper layer)
case PCB_VIA_T: // a via (like track segment on a copper layer)
m_Pcb->m_Status_Pcb = 0;
break;
case PCB_ZONE_AREA_T:
case PCB_LINE_T:
case PCB_TEXT_T:
case PCB_TARGET_T:
case PCB_DIMENSION_T:
break;
// This item is not put in undo list
case PCB_ZONE_T: // SEG_ZONE items are now deprecated
itemsList->RemovePicker( ii );
ii--;
break;
default:
wxMessageBox( wxT( "PCB_EDIT_FRAME::Block_Flip( ) error: unexpected type" ) );
break;
}
}
SaveCopyInUndoList( *itemsList, UR_FLIPPED, center );
Compile_Ratsnest( NULL, true );
m_canvas->Refresh( true );
}
示例4: Properties
int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
// Shall the selection be cleared at the end?
bool unselect = selection.Empty();
if( !hoverSelection( false ) )
return 0;
// Tracks & vias are treated in a special way:
if( ( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) )( selection ) )
{
DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection );
if( dlg.ShowModal() )
{
dlg.Apply( *m_commit );
m_commit->Push( _( "Edit track/via properties" ) );
}
}
else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
{
// Display properties dialog
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );
// Some of properties dialogs alter pointers, so we should deselect them
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
// Store flags, so they can be restored later
STATUS_FLAGS flags = item->GetFlags();
item->ClearFlags();
// Do not handle undo buffer, it is done by the properties dialogs @todo LEGACY
// Display properties dialog provided by the legacy canvas frame
editFrame->OnEditItemRequest( NULL, item );
m_toolMgr->RunAction( COMMON_ACTIONS::editModifiedSelection, true );
item->SetFlags( flags );
}
if( unselect )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return 0;
}
示例5: Properties
int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
if( !hoverSelection( selection, false ) )
return 0;
// Properties are displayed when there is only one item selected
if( selection.Size() == 1 )
{
// Display properties dialog
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );
std::vector<PICKED_ITEMS_LIST*>& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList;
// Some of properties dialogs alter pointers, so we should deselect them
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
STATUS_FLAGS flags = item->GetFlags();
item->ClearFlags();
// It is necessary to determine if anything has changed
PICKED_ITEMS_LIST* lastChange = undoList.empty() ? NULL : undoList.back();
// Display properties dialog
editFrame->OnEditItemRequest( NULL, item );
PICKED_ITEMS_LIST* currentChange = undoList.empty() ? NULL : undoList.back();
if( lastChange != currentChange ) // Something has changed
{
processChanges( currentChange );
updateRatsnest( true );
getModel<BOARD>()->GetRatsnest()->Recalculate();
item->ViewUpdate();
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
}
item->SetFlags( flags );
}
return 0;
}
示例6: CopyMarkedItems
/* Copy marked items, at new position = old position + offset
*/
void CopyMarkedItems( MODULE* module, wxPoint offset, bool aIncrement )
{
if( module == NULL )
return;
// Reference and value cannot be copied, they are unique.
// Ensure they are not selected
module->Reference().ClearFlags();
module->Value().ClearFlags();
for( D_PAD* pad = module->Pads(); pad; pad = pad->Next() )
{
if( !pad->IsSelected() )
continue;
pad->ClearFlags( SELECTED );
D_PAD* NewPad = new D_PAD( *pad );
NewPad->SetParent( module );
NewPad->SetFlags( SELECTED );
module->Pads().PushFront( NewPad );
if( aIncrement )
NewPad->IncrementPadName( true, true );
}
BOARD_ITEM* newItem;
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
{
if( !item->IsSelected() )
continue;
item->ClearFlags( SELECTED );
newItem = (BOARD_ITEM*)item->Clone();
newItem->SetParent( module );
newItem->SetFlags( SELECTED );
module->GraphicalItems().PushFront( newItem );
}
MoveMarkedItems( module, offset );
}
示例7: Properties
int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
// Shall the selection be cleared at the end?
bool unselect = selection.Empty();
if( !hoverSelection( selection, false ) )
return 0;
// Tracks & vias are treated in a special way:
if( ( SELECTION_CONDITIONS::OnlyTypes( m_tracksViasType ) )( selection ) )
{
DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection );
if( dlg.ShowModal() )
{
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
editFrame->OnModify();
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
dlg.Apply();
selection.ForAll<KIGFX::VIEW_ITEM>( boost::bind( &KIGFX::VIEW_ITEM::ViewUpdate, _1,
KIGFX::VIEW_ITEM::ALL ) );
selection.ForAll<BOARD_ITEM>( boost::bind( &RN_DATA::Update, ratsnest, _1 ) );
ratsnest->Recalculate();
}
}
else if( selection.Size() == 1 ) // Properties are displayed when there is only one item selected
{
// Display properties dialog
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );
// Store the head of the undo list to compare if anything has changed
std::vector<PICKED_ITEMS_LIST*>& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList;
// Some of properties dialogs alter pointers, so we should deselect them
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
STATUS_FLAGS flags = item->GetFlags();
item->ClearFlags();
// It is necessary to determine if anything has changed, so store the current undo save point
PICKED_ITEMS_LIST* undoSavePoint = undoList.empty() ? NULL : undoList.back();
// Display properties dialog provided by the legacy canvas frame
editFrame->OnEditItemRequest( NULL, item );
if( !undoList.empty() && undoList.back() != undoSavePoint ) // Undo buffer has changed
{
// Process changes stored after undoSavePoint
processUndoBuffer( undoSavePoint );
// Update the modified item
item->ViewUpdate();
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
ratsnest->Recalculate();
// TODO OBSERVER! I miss you so much..
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
}
item->SetFlags( flags );
}
if( unselect )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return 0;
}
示例8: Properties
int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
{
const SELECTION& selection = m_selectionTool->GetSelection();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
if( !makeSelection( selection ) )
{
setTransitions();
return 0;
}
// Properties are displayed when there is only one item selected
if( selection.Size() == 1 )
{
// Display properties dialog
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );
// Check if user wants to edit pad or module properties
if( item->Type() == PCB_MODULE_T )
{
VECTOR2D cursor = getViewControls()->GetCursorPosition();
for( D_PAD* pad = static_cast<MODULE*>( item )->Pads(); pad; pad = pad->Next() )
{
if( pad->ViewBBox().Contains( cursor ) )
{
// Turns out that user wants to edit a pad properties
item = pad;
break;
}
}
}
std::vector<PICKED_ITEMS_LIST*>& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList;
// Some of properties dialogs alter pointers, so we should deselect them
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
STATUS_FLAGS flags = item->GetFlags();
item->ClearFlags();
// It is necessary to determine if anything has changed
PICKED_ITEMS_LIST* lastChange = undoList.empty() ? NULL : undoList.back();
// Display properties dialog
editFrame->OnEditItemRequest( NULL, item );
PICKED_ITEMS_LIST* currentChange = undoList.empty() ? NULL : undoList.back();
if( lastChange != currentChange ) // Something has changed
{
processChanges( currentChange );
updateRatsnest( true );
getModel<BOARD>()->GetRatsnest()->Recalculate();
item->ViewUpdate();
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate, true );
}
item->SetFlags( flags );
}
setTransitions();
return 0;
}
示例9: GetGalCanvas
void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand,
bool aRebuildRatsnet )
{
BOARD_ITEM* item;
bool not_found = false;
bool reBuild_ratsnest = false;
bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
auto view = GetGalCanvas()->GetView();
auto connectivity = GetBoard()->GetConnectivity();
// 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
// Restore changes in reverse order
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
&& status != UR_DRILLORIGIN // origin markers never on board
&& status != UR_GRIDORIGIN ) // origin markers never on board
{
if( build_item_list )
// Build list of existing items, for integrity test
TestForExistingItem( GetBoard(), NULL );
build_item_list = false;
if( !TestForExistingItem( GetBoard(), item ) )
{
// Checking if it ever happens
wxASSERT_MSG( false, "Item in the undo buffer does not exist" );
// 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:
deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
// Fall through
case PCB_ZONE_AREA_T:
case PCB_TRACE_T:
case PCB_VIA_T:
reBuild_ratsnest = true;
break;
case PCB_NETINFO_T:
reBuild_ratsnest = true;
deep_reBuild_ratsnest = true;
break;
default:
break;
}
// It is possible that we are going to replace the selected item, so clear it
SetCurItem( NULL );
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
view->Remove( item );
connectivity->Remove( item );
SwapItemData( item, 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( std::bind( &BOARD_ITEM::ClearFlags, _1, EDA_ITEM_ALL_FLAGS ));
//.........这里部分代码省略.........
示例10: OnLeftClick
void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
BOARD_ITEM* item = GetCurItem();
m_canvas->CrossHairOff( DC );
if( GetToolId() == ID_NO_TOOL_SELECTED )
{
if( item && item->GetFlags() ) // Move item command in progress
{
switch( item->Type() )
{
case PCB_MODULE_TEXT_T:
PlaceTexteModule( static_cast<TEXTE_MODULE*>( item ), DC );
break;
case PCB_MODULE_EDGE_T:
SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );
Place_EdgeMod( static_cast<EDGE_MODULE*>( item ) );
break;
case PCB_PAD_T:
PlacePad( static_cast<D_PAD*>( item ), DC );
break;
default:
{
wxString msg;
msg.Printf( wxT( "WinEDA_ModEditFrame::OnLeftClick err:Struct %d, m_Flag %X" ),
item->Type(), item->GetFlags() );
DisplayError( this, msg );
item->ClearFlags();
break;
}
}
}
else
{
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) )
item = ModeditLocateAndDisplay();
SetCurItem( item );
}
}
item = GetCurItem();
bool no_item_edited = item == NULL || item->GetFlags() == 0;
switch( GetToolId() )
{
case ID_NO_TOOL_SELECTED:
break;
case ID_MODEDIT_CIRCLE_TOOL:
case ID_MODEDIT_ARC_TOOL:
case ID_MODEDIT_LINE_TOOL:
if( no_item_edited )
{
STROKE_T shape = S_SEGMENT;
if( GetToolId() == ID_MODEDIT_CIRCLE_TOOL )
shape = S_CIRCLE;
if( GetToolId() == ID_MODEDIT_ARC_TOOL )
shape = S_ARC;
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) NULL, DC, shape ) );
}
else if( item->IsNew() )
{
if( ( (EDGE_MODULE*) item )->GetShape() == S_CIRCLE )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
m_canvas->Refresh();
}
else if( ( (EDGE_MODULE*) item )->GetShape() == S_ARC )
{
End_Edge_Module( (EDGE_MODULE*) item );
SetCurItem( NULL );
m_canvas->Refresh();
}
else if( ( (EDGE_MODULE*) item )->GetShape() == S_SEGMENT )
{
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) item, DC, S_SEGMENT ) );
}
else
{
wxMessageBox( wxT( "ProcessCommand error: unknown shape" ) );
}
}
break;
case ID_MODEDIT_DELETE_TOOL:
if( ! no_item_edited ) // Item in edit, cannot delete it
break;
item = ModeditLocateAndDisplay();
//.........这里部分代码省略.........
示例11: 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 )
{
//.........这里部分代码省略.........
示例12: 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();
}
示例13: 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();
}
示例14: PutDataInPreviousState
/**
* Function PutDataInPreviousState
* Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorised by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
* @param aRebuildRatsnet = a bool: true to rebuid ratsnet (normal use, and default), false
* to just retrieve las state (used in abort commands that do not need to rebuild ratsnest)
*/
void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand,
bool aRebuildRatsnet )
{
BOARD_ITEM* item;
bool not_found = false;
bool reBuild_ratsnest = false;
// 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 esiting 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
* Obviouly, 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 existant 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 );
SwapData( item, image );
}
break;
case UR_NEW: /* new items are deleted */
aList->SetPickedItemStatus( UR_DELETED, ii );
GetBoard()->Remove( item );
break;
case UR_DELETED: /* deleted items are put in List, as new items */
aList->SetPickedItemStatus( UR_NEW, ii );
GetBoard()->Add( item );
build_item_list = true;
break;
case UR_MOVED:
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
break;
case UR_ROTATED:
item->Rotate( aList->m_TransformPoint, aRedoCommand ? 900 : -900 );
break;
case UR_ROTATED_CLOCKWISE:
item->Rotate( aList->m_TransformPoint, aRedoCommand ? -900 : 900 );
break;
case UR_FLIPPED:
//.........这里部分代码省略.........