Commit d583280b authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Minor code cleaning and optimizations.

parent de637d2b
Loading
Loading
Loading
Loading
+10 −14
Original line number Diff line number Diff line
@@ -127,11 +127,10 @@ void VIEW::Remove( VIEW_ITEM* aItem )
        int prevGroup = aItem->getGroup( layers[i] );

        if( prevGroup >= 0 )
        {
            m_gal->DeleteGroup( prevGroup );
            aItem->setGroup( layers[i], -1 );
        }
    }

    aItem->deleteGroups();
}


@@ -199,14 +198,10 @@ VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const
    const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();

    if( aAbsolute )
    {
        return VECTOR2D( matrix * aCoord );
    }
    else
    {
        return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
}
}


VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
@@ -214,14 +209,10 @@ VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
    const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();

    if( aAbsolute )
    {
        return VECTOR2D( matrix * aCoord );
    }
    else
    {
        return VECTOR2D( matrix.GetScale().x * aCoord.x, matrix.GetScale().y * aCoord.y );
}
}


double VIEW::ToScreen( double aCoord, bool aAbsolute ) const
@@ -699,6 +690,7 @@ struct VIEW::recacheItem
        }
        else
        {
            aItem->ViewUpdate( VIEW_ITEM::ALL );
            aItem->setGroup( layer, -1 );
        }

@@ -730,6 +722,7 @@ void VIEW::Clear()
    }

    m_gal->ClearCache();
    m_needsUpdate.clear();
}


@@ -889,7 +882,10 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )

    group = m_gal->BeginGroup();
    aItem->setGroup( aLayer, group );
    m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer );

    if( !m_painter->Draw( static_cast<EDA_ITEM*>( aItem ), aLayer ) );
        aItem->ViewDraw( aLayer, m_gal ); // Alternative drawing method

    m_gal->EndGroup();
}

@@ -900,7 +896,7 @@ void VIEW::updateBbox( VIEW_ITEM* aItem )

    aItem->ViewGetLayers( layers, layers_count );

    for( int i = 0; i < layers_count; i++ )
    for( int i = 0; i < layers_count; ++i )
    {
        VIEW_LAYER& l = m_layers[layers[i]];
        l.items->Remove( aItem );
@@ -917,7 +913,7 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
    // Remove the item from previous layer set
    aItem->getLayers( layers, layers_count );

    for( int i = 0; i < layers_count; i++ )
    for( int i = 0; i < layers_count; ++i )
    {
        VIEW_LAYER& l = m_layers[layers[i]];
        l.items->Remove( aItem );
+3 −9
Original line number Diff line number Diff line
@@ -578,13 +578,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
                                            std::string( aBoard->GetFileName().mb_str() ),
                                            std::string( GetScreenDesc().mb_str() ),
                                            &GetPageSettings(), &GetTitleBlock() );
    BASE_SCREEN* screen = GetScreen();
    if( screen != NULL )
    {
        worksheet->SetSheetNumber( GetScreen()->m_ScreenNumber );
        worksheet->SetSheetCount( GetScreen()->m_NumberOfScreens );
    }

    worksheet->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
    view->Add( worksheet );

    // Add an entry for the ratsnest
@@ -715,10 +709,10 @@ void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
{
    EDA_DRAW_FRAME::UseGalCanvas( aEnable );

    ViewReloadBoard( m_Pcb );

    if( aEnable )
    {
        ViewReloadBoard( m_Pcb );

        // Update potential changes in the ratsnest
        m_Pcb->GetRatsnest()->Recalculate();