本文整理汇总了C++中SELECTION_TOOL类的典型用法代码示例。如果您正苦于以下问题:C++ SELECTION_TOOL类的具体用法?C++ SELECTION_TOOL怎么用?C++ SELECTION_TOOL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SELECTION_TOOL类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: update
void update() override
{
SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
// enable zone actions that act on a single zone
bool singleZoneActionsEnabled = ( SELECTION_CONDITIONS::Count( 1 )
&& SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T )
)( selTool->GetSelection() );
Enable( getMenuId( PCB_ACTIONS::zoneDuplicate ), singleZoneActionsEnabled );
Enable( getMenuId( PCB_ACTIONS::drawZoneCutout ), singleZoneActionsEnabled );
Enable( getMenuId( PCB_ACTIONS::drawSimilarZone ), singleZoneActionsEnabled );
// enable zone actions that ably to a specific set of zones (as opposed to all of them)
bool nonGlobalActionsEnabled = ( SELECTION_CONDITIONS::MoreThan( 0 ) )( selTool->GetSelection() );
Enable( getMenuId( PCB_ACTIONS::zoneFill ), nonGlobalActionsEnabled );
Enable( getMenuId( PCB_ACTIONS::zoneUnfill ), nonGlobalActionsEnabled );
// lines like this make me really think about a better name for SELECTION_CONDITIONS class
bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
/*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
PCB_SELECTION_CONDITIONS::SameNet( true ) &&
PCB_SELECTION_CONDITIONS::SameLayer() )( selTool->GetSelection() );
Enable( getMenuId( PCB_ACTIONS::zoneMerge ), mergeEnabled );
}
开发者ID:hyOzd,项目名称:kicad-source-mirror,代码行数:27,代码来源:pcb_editor_control.cpp
示例2: SelectionCrossProbe
int PCB_EDITOR_CONTROL::SelectionCrossProbe( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
if( selection.Size() == 1 )
m_frame->SendMessageToEESCHEMA( selection.Item<BOARD_ITEM>( 0 ) );
setTransitions();
return 0;
}
开发者ID:Elphel,项目名称:kicad-source-mirror,代码行数:12,代码来源:pcb_editor_control.cpp
示例3: update
void update()
{
SELECTION_TOOL* selTool = getToolManager()->GetTool<SELECTION_TOOL>();
// lines like this make me really think about a better name for SELECTION_CONDITIONS class
bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
/*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
SELECTION_CONDITIONS::SameNet( true ) &&
SELECTION_CONDITIONS::SameLayer() )( selTool->GetSelection() );
Enable( getMenuId( COMMON_ACTIONS::zoneMerge ), mergeEnabled );
}
开发者ID:grtwall,项目名称:kicad-source-mirror,代码行数:12,代码来源:pcb_editor_control.cpp
示例4: Init
bool PCB_EDITOR_CONTROL::Init()
{
auto zoneMenu = std::make_shared<ZONE_CONTEXT_MENU>();
zoneMenu->SetTool( this );
auto lockMenu = std::make_shared<LOCK_CONTEXT_MENU>();
lockMenu->SetTool( this );
// Add the PCB control menus to relevant other tools
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
if( selTool )
{
auto& toolMenu = selTool->GetToolMenu();
auto& menu = toolMenu.GetMenu();
toolMenu.AddSubMenu( zoneMenu );
toolMenu.AddSubMenu( lockMenu );
menu.AddMenu( zoneMenu.get(), false,
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
menu.AddMenu( lockMenu.get(), false,
SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) );
}
DRAWING_TOOL* drawingTool = m_toolMgr->GetTool<DRAWING_TOOL>();
if( drawingTool )
{
auto& toolMenu = drawingTool->GetToolMenu();
auto& menu = toolMenu.GetMenu();
toolMenu.AddSubMenu( zoneMenu );
// Functor to say if the PCB_EDIT_FRAME is in a given mode
// Capture the tool pointer and tool mode by value
auto toolActiveFunctor = [=]( DRAWING_TOOL::MODE aMode )
{
return [=]( const SELECTION& sel )
{
return drawingTool->GetDrawingMode() == aMode;
};
};
menu.AddMenu( zoneMenu.get(), false, toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ) );
}
return true;
}
开发者ID:hyOzd,项目名称:kicad-source-mirror,代码行数:51,代码来源:pcb_editor_control.cpp
示例5: Init
bool PCB_EDITOR_CONTROL::Init()
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
if( selTool )
{
selTool->AddSubMenu( new ZONE_CONTEXT_MENU, wxT( "Zones" ),
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
}
setTransitions();
return true;
}
开发者ID:LDavis4559,项目名称:kicad-source-mirror,代码行数:14,代码来源:pcb_editor_control.cpp
示例6: Init
bool PCB_EDITOR_CONTROL::Init()
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
if( selTool )
{
m_zoneMenu = new ZONE_CONTEXT_MENU;
m_zoneMenu->SetTool( this );
selTool->GetMenu().AddMenu( m_zoneMenu, _( "Zones" ), false,
SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) );
}
return true;
}
开发者ID:grtwall,项目名称:kicad-source-mirror,代码行数:14,代码来源:pcb_editor_control.cpp
示例7: CrossProbePcbToSch
int PCB_EDITOR_CONTROL::CrossProbePcbToSch( const TOOL_EVENT& aEvent )
{
if( m_probingSchToPcb )
{
m_probingSchToPcb = false;
return 0;
}
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
if( selection.Size() == 1 )
m_frame->SendMessageToEESCHEMA( selection.Item<BOARD_ITEM>( 0 ) );
return 0;
}
开发者ID:grtwall,项目名称:kicad-source-mirror,代码行数:16,代码来源:pcb_editor_control.cpp
示例8: CreateArray
int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
{
// first, check if we have a selection, or try to get one
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
// pick up items under the cursor if needed
if( !hoverSelection() )
return 0;
// we have a selection to work on now, so start the tool process
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection );
array_creator.Invoke();
return 0;
}
开发者ID:nikgul,项目名称:kicad-source-mirror,代码行数:17,代码来源:edit_tool.cpp
示例9: UpdateSelectionRatsnest
int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
// Update "simple" ratsnest, computed for currently modified items
ratsnest->ClearSimple();
for( auto item : selection )
{
ratsnest->Update( static_cast<BOARD_ITEM*>( item ) );
ratsnest->AddSimple( static_cast<BOARD_ITEM*>( item ) );
}
return 0;
}
开发者ID:hyOzd,项目名称:kicad-source-mirror,代码行数:17,代码来源:pcb_editor_control.cpp
示例10: ZoneUnfill
int PCB_EDITOR_CONTROL::ZoneUnfill( TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
for( int i = 0; i < selection.Size(); ++i )
{
assert( selection.Item<BOARD_ITEM>( i )->Type() == PCB_ZONE_AREA_T );
ZONE_CONTAINER* zone = selection.Item<ZONE_CONTAINER>( i );
zone->SetIsFilled( false );
zone->ClearFilledPolysList();
zone->ViewUpdate();
}
setTransitions();
return 0;
}
开发者ID:LDavis4559,项目名称:kicad-source-mirror,代码行数:19,代码来源:pcb_editor_control.cpp
示例11: deleteItem
static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
{
SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
assert( selectionTool );
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
aToolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
selectionTool->SanitizeSelection();
if( selectionTool->GetSelection().Empty() )
return true;
if( IsOK( aToolMgr->GetEditFrame(), _( "Are you sure you want to delete item?" ) ) )
aToolMgr->RunAction( COMMON_ACTIONS::remove, true );
else
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return true;
}
开发者ID:OpenEE,项目名称:micad,代码行数:19,代码来源:pcbnew_control.cpp
示例12: ZoneUnfill
int PCB_EDITOR_CONTROL::ZoneUnfill( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
for( int i = 0; i < selection.Size(); ++i )
{
assert( selection.Item<BOARD_ITEM>( i )->Type() == PCB_ZONE_AREA_T );
ZONE_CONTAINER* zone = selection.Item<ZONE_CONTAINER>( i );
zone->SetIsFilled( false );
zone->ClearFilledPolysList();
ratsnest->Update( zone );
zone->ViewUpdate();
}
ratsnest->Recalculate();
return 0;
}
开发者ID:grtwall,项目名称:kicad-source-mirror,代码行数:21,代码来源:pcb_editor_control.cpp
示例13: modifyLockSelected
int PCB_EDITOR_CONTROL::modifyLockSelected( MODIFY_MODE aMode )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
if( selection.Empty() )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
bool modified = false;
for( int i = 0; i < selection.Size(); ++i )
{
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
bool prevState = item->IsLocked();
switch( aMode )
{
case ON:
item->SetLocked( true );
break;
case OFF:
item->SetLocked( false );
break;
case TOGGLE:
item->SetLocked( !prevState );
break;
}
// Check if we really modified an item
if( !modified && prevState != item->IsLocked() )
modified = true;
}
if( modified )
m_frame->OnModify();
return 0;
}
开发者ID:reportingsjr,项目名称:kicad-source-mirror,代码行数:40,代码来源:pcb_editor_control.cpp
示例14: deleteItem
static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
{
SELECTION_TOOL* selectionTool = aToolMgr->GetTool<SELECTION_TOOL>();
assert( selectionTool );
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
aToolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
selectionTool->SanitizeSelection();
const SELECTION& selection = selectionTool->GetSelection();
if( selection.Empty() )
return true;
bool canBeRemoved = ( selection.Item<EDA_ITEM>( 0 )->Type() != PCB_MODULE_T );
if( canBeRemoved || IsOK( aToolMgr->GetEditFrame(), _( "Are you sure you want to delete item?" ) ) )
aToolMgr->RunAction( COMMON_ACTIONS::remove, true );
else
aToolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return true;
}
开发者ID:PatMart,项目名称:kicad-source-mirror,代码行数:23,代码来源:pcbnew_control.cpp
示例15: ToggleLockModule
int PCB_EDITOR_CONTROL::ToggleLockModule( const TOOL_EVENT& aEvent )
{
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
bool clearSelection = selection.Empty();
if( clearSelection )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionCursor, true );
for( int i = 0; i < selection.Size(); ++i )
{
if( selection.Item<BOARD_ITEM>( i )->Type() == PCB_MODULE_T )
{
MODULE* module = selection.Item<MODULE>( i );
module->SetLocked( !module->IsLocked() );
}
}
if( clearSelection )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
return 0;
}
开发者ID:grtwall,项目名称:kicad-source-mirror,代码行数:23,代码来源:pcb_editor_control.cpp
示例16: Duplicate
int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
// Note: original items are no more modified.
bool increment = aEvent.IsAction( &COMMON_ACTIONS::duplicateIncrement );
// first, check if we have a selection, or try to get one
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
// Be sure that there is at least one item that we can modify
if( !hoverSelection() )
return 0;
// we have a selection to work on now, so start the tool process
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
std::vector<BOARD_ITEM*> old_items;
for( int i = 0; i < selection.Size(); ++i )
{
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
if( item )
old_items.push_back( item );
}
for( unsigned i = 0; i < old_items.size(); ++i )
{
BOARD_ITEM* item = old_items[i];
// Unselect the item, so we won't pick it up again
// Do this first, so a single-item duplicate will correctly call
// SetCurItem and show the item properties
m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, item );
BOARD_ITEM* new_item = NULL;
if( m_editModules )
new_item = editFrame->GetBoard()->m_Modules->Duplicate( item, increment );
else
{
#if 0
// @TODO: see if we allow zone duplication here
// Duplicate zones is especially tricky (overlaping zones must be merged)
// so zones are not duplicated
if( item->Type() != PCB_ZONE_AREA_T )
#endif
new_item = editFrame->GetBoard()->Duplicate( item );
}
if( new_item )
{
m_commit->Add( new_item );
// Select the new item, so we can pick it up
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, new_item );
}
}
// record the new items as added
if( !selection.Empty() )
{
editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
(int) old_items.size() ) );
// If items were duplicated, pick them up
// this works well for "dropping" copies around and pushes the commit
TOOL_EVENT evt = COMMON_ACTIONS::editActivate.MakeEvent();
Main( evt );
}
return 0;
};
开发者ID:nikgul,项目名称:kicad-source-mirror,代码行数:74,代码来源:edit_tool.cpp
示例17: commit
//.........这里部分代码省略.........
// Load the data
try
{
PROPERTIES props;
char xbuf[30];
char ybuf[30];
// EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet.
sprintf( xbuf, "%d", editFrame->GetPageSizeIU().x );
sprintf( ybuf, "%d", editFrame->GetPageSizeIU().y );
props["page_width"] = xbuf;
props["page_height"] = ybuf;
editFrame->GetDesignSettings().m_NetClasses.Clear();
pi->Load( fileName, board, &props );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() ));
DisplayError( editFrame, msg );
return 0;
}
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
// Process the new items
for( TRACK* track = board->m_Track; track; track = track->Next() )
{
if( track->GetFlags() & FLAG0 )
{
track->ClearFlags( FLAG0 );
continue;
}
commit.Added( track );
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, track );
}
module = module ? module->Next() : board->m_Modules;
for( ; module; module = module->Next() )
{
commit.Added( module );
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, module );
}
drawing = drawing ? drawing->Next() : board->m_Drawings;
for( ; drawing; drawing = drawing->Next() )
{
commit.Added( drawing );
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, drawing );
}
for( ZONE_CONTAINER* zone = board->GetArea( zonescount ); zone;
zone = board->GetArea( zonescount ) )
{
++zonescount;
commit.Added( zone );
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, zone );
}
if( commit.Empty() )
return 0;
commit.Push( _( "Append a board" ) );
// Synchronize layers
// we should not ask PLUGINs to do these items:
int copperLayerCount = board->GetCopperLayerCount();
if( copperLayerCount > initialCopperLayerCount )
board->SetCopperLayerCount( copperLayerCount );
// Enable all used layers, and make them visible:
LSET enabledLayers = board->GetEnabledLayers();
enabledLayers |= initialEnabledLayers;
board->SetEnabledLayers( enabledLayers );
board->SetVisibleLayers( enabledLayers );
editFrame->ReCreateLayerBox();
editFrame->ReFillLayerWidget();
static_cast<PCB_DRAW_PANEL_GAL*>( editFrame->GetGalCanvas() )->SyncLayersVisibility( board );
// Ratsnest
board->BuildListOfNets();
board->SynchronizeNetsAndNetClasses();
board->GetRatsnest()->ProcessBoard();
// Start dragging the appended board
SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selectionTool->GetSelection();
VECTOR2D v( selection.Item<BOARD_ITEM>( 0 )->GetPosition() );
getViewControls()->WarpCursor( v, true, true );
m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
return 0;
}
开发者ID:reportingsjr,项目名称:kicad-source-mirror,代码行数:101,代码来源:pcbnew_control.cpp
示例18: CreateArray
int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
{
// first, check if we have a selection, or try to get one
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
// Be sure that there is at least one item that we can modify
if( !hoverSelection( selection ) )
return 0;
bool originalItemsModified = false;
// we have a selection to work on now, so start the tool process
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
editFrame->OnModify();
if( m_editModules )
{
// Module editors do their undo point upfront for the whole module
editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT );
}
else
{
// We may also change the original item
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
}
DIALOG_CREATE_ARRAY::ARRAY_OPTIONS* array_opts = NULL;
VECTOR2I rp = selection.GetCenter();
const wxPoint rotPoint( rp.x, rp.y );
DIALOG_CREATE_ARRAY dialog( editFrame, rotPoint, &array_opts );
int ret = dialog.ShowModal();
if( ret == wxID_OK && array_opts != NULL )
{
PICKED_ITEMS_LIST newItemList;
for( int i = 0; i < selection.Size(); ++i )
{
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
if( !item )
continue;
wxString cachedString;
if( item->Type() == PCB_MODULE_T )
{
cachedString = static_cast<MODULE*>( item )->GetReferencePrefix();
}
else if( EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item ) )
{
// Copy the text (not just take a reference
cachedString = text->GetText();
}
// iterate across the array, laying out the item at the
// correct position
const unsigned nPoints = array_opts->GetArraySize();
for( unsigned ptN = 0; ptN < nPoints; ++ptN )
{
BOARD_ITEM* newItem = NULL;
if( ptN == 0 )
newItem = item;
else
{
// if renumbering, no need to increment
const bool increment = !array_opts->ShouldRenumberItems();
// Some items cannot be duplicated
// i.e. the ref and value fields of a footprint or zones
// therefore newItem can be null
if( m_editModules )
newItem = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else
{
#if 0
// @TODO: see if we allow zone duplication here
// Duplicate zones is especially tricky (overlaping zones must be merged)
// so zones are not duplicated
if( item->Type() == PCB_ZONE_AREA_T )
newItem = NULL;
else
#endif
newItem = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
}
if( newItem )
{
array_opts->TransformItem( ptN, newItem, rotPoint );
m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, newItem );
newItemList.PushItem( newItem );
//.........这里部分代码省略.........
开发者ID:OpenEE,项目名称:micad,代码行数:101,代码来源:edit_tool.cpp
示例19: Duplicate
int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
{
bool increment = aEvent.IsAction( &COMMON_ACTIONS::duplicateIncrement );
// first, check if we have a selection, or try to get one
SELECTION_TOOL* selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
const SELECTION& selection = selTool->GetSelection();
// Be sure that there is at least one item that we can modify
if( !hoverSelection( selection ) )
return 0;
// we have a selection to work on now, so start the tool process
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
editFrame->OnModify();
// prevent other tools making undo points while the duplicate is going on
// so that if you cancel, you don't get a duplicate object hiding over
// the original
incUndoInhibit();
if( m_editModules )
editFrame->SaveCopyInUndoList( editFrame->GetBoard()->m_Modules, UR_MODEDIT );
std::vector<BOARD_ITEM*> old_items;
for( int i = 0; i < selection.Size(); ++i )
{
BOARD_ITEM* item = selection.Item<BOARD_ITEM>( i );
if( item )
old_items.push_back( item );
}
for( unsigned i = 0; i < old_items.size(); ++i )
{
BOARD_ITEM* item = old_items[i];
// Unselect the item, so we won't pick it up again
// Do this first, so a single-item duplicate will correctly call
// SetCurItem and show the item properties
m_toolMgr->RunAction( COMMON_ACTIONS::unselectItem, true, item );
BOARD_ITEM* new_item = NULL;
if( m_editModules )
new_item = editFrame->GetBoard()->m_Modules->DuplicateAndAddItem( item, increment );
else
{
#if 0
// @TODO: see if we allow zone duplication here
// Duplicate zones is especially tricky (overlaping zones must be merged)
// so zones are not duplicated
if( item->Type() != PCB_ZONE_AREA_T )
#endif
new_item = editFrame->GetBoard()->DuplicateAndAddItem( item, increment );
}
if( new_item )
{
if( new_item->Type() == PCB_MODULE_T )
{
static_cast<MODULE*>( new_item )->RunOnChildren( boost::bind( &KIGFX::VIEW::Add,
getView(), _1 ) );
}
editFrame->GetGalCanvas()->GetView()->Add( new_item );
// Select the new item, so we can pick it up
m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, new_item );
}
}
// record the new items as added
if( !m_editModules )
editFrame->SaveCopyInUndoList( selection.items, UR_NEW );
editFrame->DisplayToolMsg( wxString::Format( _( "Duplicated %d item(s)" ),
(int) old_items.size() ) );
// pick up the selected item(s) and start moving
// this works well for "dropping" copies around
TOOL_EVENT evt = COMMON_ACTIONS::editActivate.MakeEvent();
Main( evt );
// and re-enable undos
decUndoInhibit();
return 0;
}
开发者ID:OpenEE,项目名称:micad,代码行数:91,代码来源:edit_tool.cpp
注:本文中的SELECTION_TOOL类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论