From 374b15ff9e4b67ba0f1c9f1e555d4c8805c287f7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 24 Feb 2014 14:31:55 +0100 Subject: [PATCH] Minor code cleaning and optimizations. --- common/view/view.cpp | 24 ++++++++++-------------- pcbnew/pcbframe.cpp | 12 +++--------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index 38051b094e..428dd7e594 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -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,13 +198,9 @@ 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 ); - } } @@ -214,13 +209,9 @@ 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 ); - } } @@ -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( aItem ), aLayer ); + + if( !m_painter->Draw( static_cast( 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 ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index f87ae2e959..4ec121c99e 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -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();