Commit 5659dd47 authored by Maciej Suminski's avatar Maciej Suminski

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

PCB items are refreshed on GAL switching (changes made using default renderer are displayed by GAL).
parent 4f0aa1c0
...@@ -981,18 +981,18 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) ...@@ -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
{ {
......
...@@ -174,6 +174,8 @@ public: ...@@ -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: ...@@ -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()
}; };
......
...@@ -903,7 +903,7 @@ public: ...@@ -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
......
...@@ -136,31 +136,44 @@ void PCB_BASE_FRAME::SetBoard( BOARD* aBoard ) ...@@ -136,31 +136,44 @@ 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();
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();
view->Clear(); view->Clear();
// All of PCB drawing elements should be added to the VIEW // All of PCB drawing elements should be added to the VIEW
// 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 ) ...@@ -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 ) ...@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment