PCB items are refreshed on GAL switching (changes made using default renderer are displayed by GAL).

This commit is contained in:
Maciej Suminski 2013-09-10 13:57:28 +02:00
parent 4f0aa1c07c
commit 5659dd479e
4 changed files with 85 additions and 65 deletions

View File

@ -981,18 +981,18 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
// Switch to GAL rendering // Switch to GAL rendering
if( !m_galCanvasActive ) if( !m_galCanvasActive )
{ {
// Change view settings only if GAL was not active previously
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
}
// Set up grid settings // Set up grid settings
gal->SetGridVisibility( IsGridVisible() ); gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) ); gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) ); gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 ); gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 ); gal->SetGridDrawThreshold( 10 );
// Set up viewport
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
}
} }
else else
{ {

View File

@ -174,6 +174,8 @@ public:
return m_Pcb; return m_Pcb;
} }
void ViewReloadBoard( const BOARD* aBoard ) const;
// General // General
virtual void OnCloseWindow( wxCloseEvent& Event ) = 0; virtual void OnCloseWindow( wxCloseEvent& Event ) = 0;
virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { } virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { }
@ -671,6 +673,8 @@ public:
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ); void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent ); void OnUpdateSelectZoom( wxUpdateUIEvent& aEvent );
virtual void UseGalCanvas( bool aEnable );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -903,7 +903,7 @@ public:
* *
* @param aEnable True for GAL-based canvas, false for standard canvas. * @param aEnable True for GAL-based canvas, false for standard canvas.
*/ */
void UseGalCanvas( bool aEnable ); virtual void UseGalCanvas( bool aEnable );
/** /**
* Function IsNewCanvasActive * Function IsNewCanvasActive

View File

@ -134,6 +134,19 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
m_Pcb = aBoard; m_Pcb = aBoard;
if( m_galCanvas ) if( m_galCanvas )
{
KiGfx::VIEW* view = m_galCanvas->GetView();
ViewReloadBoard( m_Pcb );
// update the tool manager with the new board and its view.
if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this );
}
}
void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
{ {
KiGfx::VIEW* view = m_galCanvas->GetView(); KiGfx::VIEW* view = m_galCanvas->GetView();
view->Clear(); view->Clear();
@ -142,25 +155,25 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
// in order to be displayed // in order to be displayed
// Load zones // Load zones
for( int i = 0; i < m_Pcb->GetAreaCount(); ++i ) for( int i = 0; i < aBoard->GetAreaCount(); ++i )
{ {
view->Add( (KiGfx::VIEW_ITEM*) ( m_Pcb->GetArea( i ) ) ); view->Add( (KiGfx::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
} }
// Load drawings // Load drawings
for( BOARD_ITEM* drawing = m_Pcb->m_Drawings; drawing; drawing = drawing->Next() ) for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() )
{ {
view->Add( drawing ); view->Add( drawing );
} }
// Load tracks // Load tracks
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() ) for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{ {
view->Add( track ); view->Add( track );
} }
// Load modules and its additional elements // Load modules and its additional elements
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() ) for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{ {
// Load module's pads // Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() ) for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
@ -184,20 +197,15 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
} }
// Segzones (equivalent of ZONE_CONTAINER for legacy boards) // Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() ) for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
{ {
view->Add( zone ); view->Add( zone );
} }
view->RecacheAllItems( true ); view->RecacheAllItems( true );
if( m_galCanvasActive ) if( m_galCanvasActive )
m_galCanvas->Refresh(); m_galCanvas->Refresh();
// update the tool manager with the new board and its view.
if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this );
}
} }
@ -523,6 +531,14 @@ void PCB_BASE_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
} }
void PCB_BASE_FRAME::UseGalCanvas( bool aEnable )
{
EDA_DRAW_FRAME::UseGalCanvas( aEnable );
ViewReloadBoard( m_Pcb );
}
void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent ) void PCB_BASE_FRAME::ProcessItemSelection( wxCommandEvent& aEvent )
{ {
int id = aEvent.GetId(); int id = aEvent.GetId();