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


C++ PCB_EDIT_FRAME::GetToolManager方法代码示例

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


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

示例1: Process_Special_Functions


//.........这里部分代码省略.........
            // Because this source could be deleted when editing the main board...
            if( module_in_edit->GetLink() )        // this is not a new module ...
            {
                source_module = mainpcb->m_Modules;

                for( ; source_module != NULL; source_module = source_module->Next() )
                {
                    if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
                        break;
                }
            }

            if( ( source_module == NULL )
              && ( id == ID_MODEDIT_UPDATE_MODULE_IN_BOARD ) ) // source not found
            {
                wxString msg;
                msg.Printf( _( "Unable to find the footprint source on the main board" ) );
                msg << _( "\nCannot update the footprint" );
                DisplayError( this, msg );
                break;
            }

            if( ( source_module != NULL )
              && ( id == ID_MODEDIT_INSERT_MODULE_IN_BOARD ) ) // source not found
            {
                wxString msg;
                msg.Printf( _( "A footprint source was found on the main board" ) );
                msg << _( "\nCannot insert this footprint" );
                DisplayError( this, msg );
                break;
            }

            m_toolManager->RunAction( PCB_ACTIONS::selectionClear, true );
            pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
            BOARD_COMMIT commit( pcbframe );

            // Create the "new" module
            MODULE* newmodule = new MODULE( *module_in_edit );
            newmodule->SetParent( mainpcb );
            newmodule->SetLink( 0 );

            if( source_module )         // this is an update command
            {
                // In the main board,
                // the new module replace the old module (pos, orient, ref, value
                // and connexions are kept)
                // and the source_module (old module) is deleted
                pcbframe->Exchange_Module( source_module, newmodule, commit );
                newmodule->SetTimeStamp( module_in_edit->GetLink() );
                commit.Push( wxT( "Update module" ) );
            }
            else        // This is an insert command
            {
                wxPoint cursor_pos = pcbframe->GetCrossHairPosition();

                commit.Add( newmodule );
                pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
                pcbframe->PlaceModule( newmodule, NULL );
                newmodule->SetPosition( wxPoint( 0, 0 ) );
                pcbframe->SetCrossHairPosition( cursor_pos );
                newmodule->SetTimeStamp( GetNewTimeStamp() );
                commit.Push( wxT( "Insert module" ) );
            }

            newmodule->ClearFlags();
            GetScreen()->ClrModify();
开发者ID:hyOzd,项目名称:kicad-source-mirror,代码行数:67,代码来源:modedit.cpp

示例2: SaveFootprintToBoard

bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
{
    // update module in the current board,
    // not just add it to the board with total disregard for the netlist...
    PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, false );

    if( pcbframe == NULL )      // happens when the board editor is not active (or closed)
    {
        DisplayErrorMessage( this, _("No board currently open." ) );
        return false;
    }

    BOARD*  mainpcb  = pcbframe->GetBoard();
    MODULE* source_module  = NULL;
    MODULE* module_in_edit = GetBoard()->m_Modules;

    // Search the old module (source) if exists
    // Because this source could be deleted when editing the main board...
    if( module_in_edit->GetLink() )        // this is not a new module ...
    {
        source_module = mainpcb->m_Modules;

        for( ; source_module != NULL; source_module = source_module->Next() )
        {
            if( module_in_edit->GetLink() == source_module->GetTimeStamp() )
                break;
        }
    }

    if( !aAddNew && source_module == NULL ) // source not found
    {
        DisplayError( this, _( "Unable to find the footprint on the main board.\nCannot save." ) );
        return false;
    }

    if( aAddNew && source_module != NULL )
    {
        DisplayError( this, _( "Footprint already exists on board." ) );
        return false;
    }

    m_toolManager->RunAction( PCB_ACTIONS::selectionClear, true );
    pcbframe->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
    BOARD_COMMIT commit( pcbframe );

    // Create the "new" module
    MODULE* newmodule = new MODULE( *module_in_edit );
    newmodule->SetParent( mainpcb );
    newmodule->SetLink( 0 );

    if( source_module )         // this is an update command
    {
        // In the main board,
        // the new module replace the old module (pos, orient, ref, value
        // and connexions are kept)
        // and the source_module (old module) is deleted
        pcbframe->Exchange_Module( source_module, newmodule, commit );
        newmodule->SetTimeStamp( module_in_edit->GetLink() );
        commit.Push( wxT( "Update module" ) );
    }
    else        // This is an insert command
    {
        wxPoint cursor_pos = pcbframe->GetCrossHairPosition();

        commit.Add( newmodule );
        pcbframe->SetCrossHairPosition( wxPoint( 0, 0 ) );
        pcbframe->PlaceModule( newmodule, NULL );
        newmodule->SetPosition( wxPoint( 0, 0 ) );
        pcbframe->SetCrossHairPosition( cursor_pos );
        newmodule->SetTimeStamp( GetNewTimeStamp() );
        commit.Push( wxT( "Insert module" ) );
    }

    newmodule->ClearFlags();
    pcbframe->SetCurItem( NULL );
    // @todo LEGACY should be unnecessary
    mainpcb->m_Status_Pcb = 0;

    return true;
}
开发者ID:johnbeard,项目名称:kicad,代码行数:80,代码来源:footprint_libraries_utils.cpp


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