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


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

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


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

示例1: Show_Zone_Corner_Or_Outline_While_Move_Mouse

/// Redraws the zone outline when moving a corner according to the cursor position
void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                                                   const wxPoint& aPosition, bool aErase )
{
    PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
    ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();

    if( aErase )    // Undraw edge in old position
    {
        zone->Draw( aPanel, aDC, GR_XOR );
    }

    wxPoint pos = pcbframe->GetCrossHairPosition();

    if( zone->IsMoving() )
    {
        wxPoint offset;
        offset = pos - s_CursorLastPosition;
        zone->Move( offset );
        s_CursorLastPosition = pos;
    }
    else if( zone->IsDragging() )
    {
        wxPoint offset;
        offset = pos - s_CursorLastPosition;
        zone->MoveEdge( offset );
        s_CursorLastPosition = pos;
    }
    else
    {
        zone->Outline()->MoveCorner( zone->GetSelectedCorner(), pos.x, pos.y );
    }

    zone->Draw( aPanel, aDC, GR_XOR );
}
开发者ID:jerkey,项目名称:kicad,代码行数:35,代码来源:zones_by_polygon.cpp

示例2: Show_New_Edge_While_Move_Mouse

/* Redraws the zone outlines when moving mouse
 */
static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                                            const wxPoint& aPosition, bool aErase )
{
    PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
    wxPoint         c_pos    = pcbframe->GetCrossHairPosition();
    ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;

    if( !zone )
        return;

    int icorner = zone->GetNumCorners() - 1;

    if( icorner < 1 )
        return;     // We must have 2 (or more) corners

    if( aErase )    // Undraw edge in old position
    {
        zone->DrawWhileCreateOutline( aPanel, aDC );
    }

    // Redraw the current edge in its new position
    if( pcbframe->GetZoneSettings().m_Zone_45_Only )
    {
        // calculate the new position as allowed
        wxPoint StartPoint = zone->GetCornerPosition( icorner - 1 );
        CalculateSegmentEndPoint( c_pos, StartPoint.x, StartPoint.y, &c_pos.x, &c_pos.y );
    }

    zone->SetCornerPosition( icorner, c_pos );

    zone->DrawWhileCreateOutline( aPanel, aDC );
}
开发者ID:jerkey,项目名称:kicad,代码行数:34,代码来源:zones_by_polygon.cpp

示例3: Process_Special_Functions


//.........这里部分代码省略.........
            }

            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();
            pcbframe->SetCurItem( NULL );
            // @todo LEGACY should be unnecessary
            mainpcb->m_Status_Pcb = 0;
        }
        break;

    case ID_MODEDIT_IMPORT_PART:
        if( ! Clear_Pcb( true ) )
            break;                  // //this command is aborted

        SetCrossHairPosition( wxPoint( 0, 0 ) );
        Import_Module();

        if( GetBoard()->m_Modules )
            GetBoard()->m_Modules->ClearFlags();

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

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