当前位置: 首页>>代码示例>>C++>>正文


C++ PCB_BASE_EDIT_FRAME::GetBoard方法代码示例

本文整理汇总了C++中PCB_BASE_EDIT_FRAME::GetBoard方法的典型用法代码示例。如果您正苦于以下问题:C++ PCB_BASE_EDIT_FRAME::GetBoard方法的具体用法?C++ PCB_BASE_EDIT_FRAME::GetBoard怎么用?C++ PCB_BASE_EDIT_FRAME::GetBoard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PCB_BASE_EDIT_FRAME的用法示例。


在下文中一共展示了PCB_BASE_EDIT_FRAME::GetBoard方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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


注:本文中的PCB_BASE_EDIT_FRAME::GetBoard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。