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


C++ BOARD_ITEM::GetPosition方法代码示例

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


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

示例1: GetTopLeftItem

EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
{
    BOARD_ITEM* topLeftItem = nullptr;
    BOARD_ITEM* currentItem;

    wxPoint pnt;

    // find the leftmost (smallest x coord) and highest (smallest y with the smallest x) item in the selection
    for( auto item : m_items )
    {
        currentItem = static_cast<BOARD_ITEM*>( item );
        pnt = currentItem->GetPosition();

        if( ( currentItem->Type() != PCB_MODULE_T ) && onlyModules )
        {
            continue;
        }
        else
        {
            if( topLeftItem == nullptr )
            {
                topLeftItem = currentItem;
            }
            else if( ( pnt.x < topLeftItem->GetPosition().x ) ||
                     ( ( topLeftItem->GetPosition().x == pnt.x ) &&
                     ( pnt.y < topLeftItem->GetPosition().y ) ) )
            {
                topLeftItem = currentItem;
            }
        }
    }

    return static_cast<EDA_ITEM*>( topLeftItem );
}
开发者ID:KiCad,项目名称:kicad-source-mirror,代码行数:34,代码来源:selection.cpp

示例2: moveExact

void FOOTPRINT_EDIT_FRAME::moveExact()
{
    MOVE_PARAMETERS params;
    params.allowOverride = false;
    params.editingFootprint = true;

    DIALOG_MOVE_EXACT dialog( this, params );
    int ret = dialog.ShowModal();

    if( ret == wxID_OK )
    {
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );

        BOARD_ITEM* item = GetScreen()->GetCurItem();

        wxPoint anchorPoint = item->GetPosition();
        wxPoint origin;

        switch( params.origin )
        {
        case RELATIVE_TO_USER_ORIGIN:
            origin = GetScreen()->m_O_Curseur;
            break;

        case RELATIVE_TO_GRID_ORIGIN:
            origin = GetGridOrigin();
            break;

        case RELATIVE_TO_DRILL_PLACE_ORIGIN:
            origin = GetAuxOrigin();
            break;

        case RELATIVE_TO_SHEET_ORIGIN:
            origin = wxPoint( 0, 0 );
            break;

        case RELATIVE_TO_CURRENT_POSITION:
            // relative movement means that only the translation values should be used:
            // -> set origin and anchor to zero
            origin = wxPoint( 0, 0 );
            anchorPoint = wxPoint( 0, 0 );
            break;
        }

        wxPoint finalMoveVector = params.translation + origin - anchorPoint;

        item->Move( finalMoveVector );
        item->Rotate( item->GetPosition(), params.rotation );
        m_canvas->Refresh();
    }

    m_canvas->MoveCursorToCrossHair();
}
开发者ID:hyOzd,项目名称:kicad-source-mirror,代码行数:53,代码来源:modedit.cpp

示例3: doSelectionMenu

void DIALOG_DRC_CONTROL::doSelectionMenu( const DRC_ITEM* aItem )
{
    // popup menu to go to either of the items listed in the DRC_ITEM.

    BOARD_ITEM* first = aItem->GetMainItem( m_brdEditor->GetBoard() );
    BOARD_ITEM* second = nullptr;

    GENERAL_COLLECTOR items;

    items.Append( first );

    if( aItem->HasSecondItem() )
    {
        second = aItem->GetAuxiliaryItem( m_brdEditor->GetBoard() );
        items.Append( second );
    }

    WINDOW_THAWER thawer( m_brdEditor );
    m_brdEditor->GetToolManager()->VetoContextMenuMouseWarp();
    m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items );

    // If we got an item, focus on it
    BOARD_ITEM* selection = m_brdEditor->GetCurItem();

    if( selection && ( selection == first || selection == second ) )
        m_brdEditor->GetToolManager()->GetView()->SetCenter( selection->GetPosition() );

    m_brdEditor->GetCanvas()->Refresh();
}
开发者ID:johnbeard,项目名称:kicad,代码行数:29,代码来源:dialog_drc.cpp

示例4: CrossProbeSchToPcb

int PCB_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent )
{
    BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();

    if( item )
    {
        m_probingSchToPcb = true;
        getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );

        // If it is a pad and the net highlighting tool is enabled, highlight the net
        if( item->Type() == PCB_PAD_T && m_frame->GetToolId() == ID_PCB_HIGHLIGHT_BUTT )
        {
            int net = static_cast<D_PAD*>( item )->GetNetCode();
            m_toolMgr->RunAction( COMMON_ACTIONS::highlightNet, false, net );
        }
        else
        // Otherwise simply select the corresponding item
        {
            m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, item );
        }
    }

    return 0;
}
开发者ID:reportingsjr,项目名称:kicad-source-mirror,代码行数:25,代码来源:pcb_editor_control.cpp

示例5: CrossProbeSchToPcb

int PCB_EDITOR_CONTROL::CrossProbeSchToPcb( const TOOL_EVENT& aEvent )
{
    BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();

    if( item )
    {
        m_probingSchToPcb = true;
        getView()->SetCenter( VECTOR2D( item->GetPosition() ) );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
        m_toolMgr->RunAction( COMMON_ACTIONS::selectItem, true, item );
    }

    return 0;
}
开发者ID:grtwall,项目名称:kicad-source-mirror,代码行数:14,代码来源:pcb_editor_control.cpp

示例6: moveExact

void FOOTPRINT_EDIT_FRAME::moveExact()
{
    wxPoint translation;
    double rotation = 0;

    DIALOG_MOVE_EXACT dialog( this, translation, rotation );
    int ret = dialog.ShowModal();

    if( ret == wxID_OK )
    {
        SaveCopyInUndoList( GetBoard()->m_Modules, UR_MODEDIT );

        BOARD_ITEM* item = GetScreen()->GetCurItem();

        item->Move( translation );
        item->Rotate( item->GetPosition(), rotation );
        m_canvas->Refresh();
    }

    m_canvas->MoveCursorToCrossHair();
}
开发者ID:JOE-JOE-NGIGI,项目名称:kicad,代码行数:21,代码来源:modedit.cpp

示例7: Main

int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
    KIGFX::VIEW_CONTROLS* controls = getViewControls();
    PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();

    VECTOR2I originalCursorPos = controls->GetCursorPosition();
    const SELECTION& selection = m_selectionTool->GetSelection();

    // Shall the selection be cleared at the end?
    bool unselect = selection.Empty();

    // Be sure that there is at least one item that we can modify. If nothing was selected before,
    // try looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection)
    if( !hoverSelection( selection ) )
        return 0;

    Activate();

    m_dragging = false;         // Are selected items being dragged?
    bool restore = false;       // Should items' state be restored when finishing the tool?
    bool lockOverride = false;

    // By default, modified items need to update their geometry
    m_updateFlag = KIGFX::VIEW_ITEM::GEOMETRY;

    controls->ShowCursor( true );

    // cumulative translation
    wxPoint totalMovement( 0, 0 );

    GRID_HELPER grid( editFrame );
    OPT_TOOL_EVENT evt = aEvent;

    // Main loop: keep receiving events
    do
    {
        if( evt->IsCancel() )
        {
            restore = true; // Cancelling the tool means that items have to be restored
            break;          // Finish
        }

        else if( evt->Action() == TA_UNDO_REDO )
        {
            unselect = true;
            break;
        }

        else if( evt->IsAction( &COMMON_ACTIONS::editActivate )
                 || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
        {
            BOARD_ITEM* item = selection.Item<BOARD_ITEM>( 0 );

            if( m_dragging && evt->Category() == TC_MOUSE )
            {
                m_cursor = grid.BestSnapAnchor( evt->Position(), item );
                controls->ForceCursorPosition( true, m_cursor );

                wxPoint movement = wxPoint( m_cursor.x, m_cursor.y ) - item->GetPosition();
                totalMovement += movement;

                // Drag items to the current cursor position
                for( unsigned int i = 0; i < selection.items.GetCount(); ++i )
                    selection.Item<BOARD_ITEM>( i )->Move( movement + m_offset );

                updateRatsnest( true );
            }
            else if( !m_dragging )    // Prepare to start dragging
            {
                if( !invokeInlineRouter() )
                {
                    m_selectionTool->SanitizeSelection();

                    if( selection.Empty() )
                        break;

                    // deal with locked items (override lock or abort the operation)
                    SELECTION_LOCK_FLAGS lockFlags = m_selectionTool->CheckLock();

                    if( lockFlags == SELECTION_LOCKED )
                        break;
                    else if( lockFlags == SELECTION_LOCK_OVERRIDE )
                        lockOverride = true;

                    // Save items, so changes can be undone
                    if( !isUndoInhibited() )
                    {
                        editFrame->OnModify();
                        editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
                    }

                    m_cursor = controls->GetCursorPosition();

                    if( selection.Size() == 1 )
                    {
                        // Set the current cursor position to the first dragged item origin, so the
                        // movement vector could be computed later
                        m_cursor = grid.BestDragOrigin( originalCursorPos, item );
                        grid.SetAuxAxes( true, m_cursor );
                    }
//.........这里部分代码省略.........
开发者ID:OpenEE,项目名称:micad,代码行数:101,代码来源:edit_tool.cpp

示例8: PutDataInPreviousState


//.........这里部分代码省略.........
        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 ));
            }

            view->Add( item );
            connectivity->Add( item );
            item->ClearFlags();

        }
        break;

        case UR_NEW:        /* new items are deleted */
            aList->SetPickedItemStatus( UR_DELETED, ii );
            GetModel()->Remove( item );
            view->Remove( item );
            break;

        case UR_DELETED:    /* deleted items are put in List, as new items */
            aList->SetPickedItemStatus( UR_NEW, ii );
            GetModel()->Add( item );
            view->Add( item );
            build_item_list = true;
            break;

        case UR_MOVED:
            item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
            view->Update( item, KIGFX::GEOMETRY );
            connectivity->Update( item );
            break;

        case UR_ROTATED:
            item->Rotate( aList->m_TransformPoint,
                          aRedoCommand ? m_rotationAngle : -m_rotationAngle );
            view->Update( item, KIGFX::GEOMETRY );
            connectivity->Update( item );
            break;

        case UR_ROTATED_CLOCKWISE:
            item->Rotate( aList->m_TransformPoint,
                          aRedoCommand ? -m_rotationAngle : m_rotationAngle );
            view->Update( item, KIGFX::GEOMETRY );
            connectivity->Update( item );
            break;

        case UR_FLIPPED:
            item->Flip( aList->m_TransformPoint );
            view->Update( item, KIGFX::LAYERS );
            connectivity->Update( item );
            break;

        case UR_DRILLORIGIN:
        case UR_GRIDORIGIN:
        {
            BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
            VECTOR2D origin = image->GetPosition();
            image->SetPosition( item->GetPosition() );

            if( aList->GetPickedItemStatus( ii ) == UR_DRILLORIGIN )
                PCB_EDITOR_CONTROL::DoSetDrillOrigin( view, this, item, origin );
            else
                PCBNEW_CONTROL::DoSetGridOrigin( view, this, item, origin );
        }
        break;

        default:
        {
            wxLogDebug( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
                        aList->GetPickedItemStatus( ii ) );
        }
        break;
        }
    }

    if( not_found )
        wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) );
    
    // Rebuild pointers and connectivity that can be changed.
    // connectivity can be rebuilt only in the board editor frame
    if( IsType( FRAME_PCB ) && ( reBuild_ratsnest || deep_reBuild_ratsnest ) )
    {
        Compile_Ratsnest( NULL, false );
    }

    GetBoard()->SanitizeNetcodes();
}
开发者ID:johnbeard,项目名称:kicad,代码行数:101,代码来源:undo_redo.cpp

示例9: PlaceDXF

int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
{
    if( m_editModules && !m_board->m_Modules )
        return 0;

    DIALOG_DXF_IMPORT dlg( m_frame );
    int dlgResult = dlg.ShowModal();

    const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();

    if( dlgResult != wxID_OK || list.empty() )
        return 0;

    VECTOR2I cursorPos = m_controls->GetCursorPosition();
    VECTOR2I delta = cursorPos - (*list.begin())->GetPosition();

    // Add a VIEW_GROUP that serves as a preview for the new item
    KIGFX::VIEW_GROUP preview( m_view );

    // Build the undo list & add items to the current view
    std::list<BOARD_ITEM*>::const_iterator it, itEnd;
    for( it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
    {
        KICAD_T type = (*it)->Type();
        assert( type == PCB_LINE_T || type == PCB_TEXT_T );

        if( type == PCB_LINE_T || type == PCB_TEXT_T )
            preview.Add( *it );
    }

    BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( *preview.Begin() );
    m_view->Add( &preview );

    m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
    m_controls->ShowCursor( true );
    m_controls->SetSnapping( true );

    Activate();

    // Main loop: keep receiving events
    while( OPT_TOOL_EVENT evt = Wait() )
    {
        cursorPos = m_controls->GetCursorPosition();

        if( evt->IsMotion() )
        {
            delta = cursorPos - firstItem->GetPosition();

            for( KIGFX::VIEW_GROUP::iter it = preview.Begin(), end = preview.End(); it != end; ++it )
                static_cast<BOARD_ITEM*>( *it )->Move( wxPoint( delta.x, delta.y ) );

            preview.ViewUpdate();
        }

        else if( evt->Category() == TC_COMMAND )
        {
            if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
            {
                for( KIGFX::VIEW_GROUP::iter it = preview.Begin(), end = preview.End(); it != end; ++it )
                    static_cast<BOARD_ITEM*>( *it )->Rotate( wxPoint( cursorPos.x, cursorPos.y ),
                                                             m_frame->GetRotationAngle() );

                preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
            }
            else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
            {
                for( KIGFX::VIEW_GROUP::iter it = preview.Begin(), end = preview.End(); it != end; ++it )
                    static_cast<BOARD_ITEM*>( *it )->Flip( wxPoint( cursorPos.x, cursorPos.y ) );

                preview.ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
            }
            else if( evt->IsCancel() || evt->IsActivate() )
            {
                preview.FreeItems();
                break;
            }
        }

        else if( evt->IsClick( BUT_LEFT ) )
        {
            // Place the drawing
            if( m_editModules )
            {
                assert( m_board->m_Modules );
                m_frame->SaveCopyInUndoList( m_board->m_Modules, UR_MODEDIT );
                m_board->m_Modules->SetLastEditTime();

                for( KIGFX::VIEW_GROUP::iter it = preview.Begin(), end = preview.End(); it != end; ++it )
                {
                    BOARD_ITEM* item = static_cast<BOARD_ITEM*>( *it );
                    BOARD_ITEM* converted = NULL;

                    // Modules use different types for the same things,
                    // so we need to convert imported items to appropriate classes.
                    switch( item->Type() )
                    {
                    case PCB_TEXT_T:
                        converted = new TEXTE_MODULE( m_board->m_Modules );
                        // Copy coordinates, layer, etc.
                        *static_cast<TEXTE_PCB*>( converted ) = *static_cast<TEXTE_PCB*>( item );
//.........这里部分代码省略.........
开发者ID:hzeller,项目名称:kicad-source-mirror,代码行数:101,代码来源:drawing_tool.cpp


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