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 // Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 );
// Set up viewport
double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() ); double zoom = 1.0 / ( zoomFactor * m_canvas->GetZoom() );
view->SetScale( zoom ); view->SetScale( zoom );
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
} }
// Set up grid settings
gal->SetGridVisibility( IsGridVisible() );
gal->SetGridSize( VECTOR2D( screen->GetGridSize().x, screen->GetGridSize().y ) );
gal->SetGridOrigin( VECTOR2D( screen->GetGridOrigin() ) );
gal->SetGridOriginMarkerSize( 15 );
gal->SetGridDrawThreshold( 10 );
} }
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

@ -136,71 +136,79 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard )
if( m_galCanvas ) if( m_galCanvas )
{ {
KiGfx::VIEW* view = m_galCanvas->GetView(); KiGfx::VIEW* view = m_galCanvas->GetView();
view->Clear();
// All of PCB drawing elements should be added to the VIEW ViewReloadBoard( m_Pcb );
// in order to be displayed
// Load zones
for( int i = 0; i < m_Pcb->GetAreaCount(); ++i )
{
view->Add( (KiGfx::VIEW_ITEM*) ( m_Pcb->GetArea( i ) ) );
}
// Load drawings
for( BOARD_ITEM* drawing = m_Pcb->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load tracks
for( TRACK* track = m_Pcb->m_Track; track; track = track->Next() )
{
view->Add( track );
}
// Load modules and its additional elements
for( MODULE* module = m_Pcb->m_Modules; module; module = module->Next() )
{
// Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
view->Add( pad );
}
// Load module's drawing (mostly silkscreen)
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load module's texts (name and value)
view->Add( &module->Reference() );
view->Add( &module->Value() );
// Add the module itself
view->Add( module );
}
// Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone );
}
view->RecacheAllItems( true );
if( m_galCanvasActive )
m_galCanvas->Refresh();
// update the tool manager with the new board and its view. // update the tool manager with the new board and its view.
if( m_toolManager ) if( m_toolManager )
m_toolManager->SetEnvironment( m_Pcb, view, m_galCanvas->GetViewControls(), this ); 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();
view->Clear();
// All of PCB drawing elements should be added to the VIEW
// in order to be displayed
// Load zones
for( int i = 0; i < aBoard->GetAreaCount(); ++i )
{
view->Add( (KiGfx::VIEW_ITEM*) ( aBoard->GetArea( i ) ) );
}
// Load drawings
for( BOARD_ITEM* drawing = aBoard->m_Drawings; drawing; drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load tracks
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
{
view->Add( track );
}
// Load modules and its additional elements
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
{
// Load module's pads
for( D_PAD* pad = module->Pads().GetFirst(); pad; pad = pad->Next() )
{
view->Add( pad );
}
// Load module's drawing (mostly silkscreen)
for( BOARD_ITEM* drawing = module->GraphicalItems().GetFirst(); drawing;
drawing = drawing->Next() )
{
view->Add( drawing );
}
// Load module's texts (name and value)
view->Add( &module->Reference() );
view->Add( &module->Value() );
// Add the module itself
view->Add( module );
}
// Segzones (equivalent of ZONE_CONTAINER for legacy boards)
for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
{
view->Add( zone );
}
view->RecacheAllItems( true );
if( m_galCanvasActive )
m_galCanvas->Refresh();
}
void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
{ {
wxASSERT( m_Pcb ); wxASSERT( m_Pcb );
@ -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();