Minor code cleaning and optimizations.

This commit is contained in:
Maciej Suminski 2014-02-24 14:31:55 +01:00
parent de637d2b8d
commit d583280bb0
2 changed files with 13 additions and 23 deletions

View File

@ -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<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 );

View File

@ -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();