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


C++ EDA_RECT::GetLeft方法代码示例

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


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

示例1: GetTopLeftItem

EDA_ITEM* SELECTION::GetTopLeftItem( bool onlyModules ) const
{
    WS_DRAW_ITEM_BASE* topLeftItem = nullptr;
    EDA_RECT           topLeftItemBB;

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

        if( topLeftItem == nullptr )
        {
            topLeftItem = currentItem;
            topLeftItemBB = currentItemBB;
        }
        else if( currentItemBB.GetLeft() < topLeftItemBB.GetLeft() )
        {
            topLeftItem = currentItem;
            topLeftItemBB = currentItemBB;
        }
        else if( topLeftItemBB.GetLeft() == currentItemBB.GetLeft()
                    && currentItemBB.GetTop() < topLeftItemBB.GetTop() )
        {
            topLeftItem = currentItem;
            topLeftItemBB = currentItemBB;
        }
    }

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

示例2: HitTest

bool D_PAD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
    EDA_RECT arect = aRect;
    arect.Normalize();
    arect.Inflate( aAccuracy );

    wxPoint shapePos = ShapePos();

    EDA_RECT shapeRect;

    int r;

    EDA_RECT bb = GetBoundingBox();

    wxPoint endCenter;
    int radius;

    if( !arect.Intersects( bb ) )
        return false;

    // This covers total containment for all test cases
    if( arect.Contains( bb ) )
        return true;

    switch( GetShape() )
    {
    case PAD_SHAPE_CIRCLE:
        return arect.IntersectsCircle( GetPosition(), GetBoundingRadius() );
    case PAD_SHAPE_RECT:
        shapeRect.SetOrigin( shapePos );
        shapeRect.Inflate( m_Size.x / 2, m_Size.y / 2 );
        return arect.Intersects( shapeRect, m_Orient );
    case PAD_SHAPE_OVAL:

        // Circlular test if dimensions are equal
        if( m_Size.x == m_Size.y )
            return arect.IntersectsCircle( shapePos, GetBoundingRadius() );

        shapeRect.SetOrigin( shapePos );

        // Horizontal dimension is greater
        if( m_Size.x > m_Size.y )
        {
            radius = m_Size.y / 2;

            shapeRect.Inflate( m_Size.x / 2 - radius, radius );

            endCenter = wxPoint( m_Size.x / 2 - radius, 0 );
            RotatePoint( &endCenter, m_Orient );

            // Test circular ends
            if( arect.IntersectsCircle( shapePos + endCenter, radius ) ||
                arect.IntersectsCircle( shapePos - endCenter, radius ) )
            {
                return true;
            }
        }
        else
        {
            radius = m_Size.x / 2;

            shapeRect.Inflate( radius, m_Size.y / 2 - radius );

            endCenter = wxPoint( 0, m_Size.y / 2 - radius );
            RotatePoint( &endCenter, m_Orient );

            // Test circular ends
            if( arect.IntersectsCircle( shapePos + endCenter, radius ) ||
                arect.IntersectsCircle( shapePos - endCenter, radius ) )
            {
                return true;
            }
        }

        // Test rectangular portion between rounded ends
        if( arect.Intersects( shapeRect, m_Orient ) )
        {
            return true;
        }

        break;
    case PAD_SHAPE_TRAPEZOID:
        /* Trapezoid intersection tests:
         * A) Any points of rect inside trapezoid
         * B) Any points of trapezoid inside rect
         * C) Any sides of trapezoid cross rect
         */
        {

        wxPoint poly[4];
        BuildPadPolygon( poly, wxSize( 0, 0 ), 0 );

        wxPoint corners[4];

        corners[0] = wxPoint( arect.GetLeft(),  arect.GetTop() );
        corners[1] = wxPoint( arect.GetRight(), arect.GetTop() );
        corners[2] = wxPoint( arect.GetRight(), arect.GetBottom() );
        corners[3] = wxPoint( arect.GetLeft(),  arect.GetBottom() );

        for( int i=0; i<4; i++ )
//.........这里部分代码省略.........
开发者ID:cpavlina,项目名称:kicad,代码行数:101,代码来源:class_pad.cpp


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