diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index cd51a5a4f2..c060ab5041 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -147,6 +147,9 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) m_gal->BeginDrawing(); m_gal->ClearScreen( m_painter->GetSettings()->GetBackgroundColor() ); + KIGFX::COLOR4D gridColor = static_cast (m_painter->GetSettings())->GetLayerColor( ITEM_GAL_LAYER ( GRID_VISIBLE ) ); + m_gal->SetGridColor ( gridColor ); + if( m_view->IsDirty() ) { m_view->ClearTargets(); diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index b886741e7c..1867f94175 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -635,8 +635,11 @@ public: { gridOrigin = aGridOrigin; - gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x, - (long) gridOrigin.y % (long) gridSize.y ); + if( gridSize.x == 0.0 || gridSize.y == 0.0 ) + gridOffset = VECTOR2D(0.0, 0.0); + else + gridOffset = VECTOR2D( (long) gridOrigin.x % (long) gridSize.x, + (long) gridOrigin.y % (long) gridSize.y ); } /** diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp index 561648e820..feb2af2f91 100644 --- a/pcbnew/class_pcb_layer_widget.cpp +++ b/pcbnew/class_pcb_layer_widget.cpp @@ -480,6 +480,13 @@ void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor ) { myframe->GetBoard()->SetVisibleElementColor( aId, aColor ); + + if( myframe->GetGalCanvas() ) + { + KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView(); + view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->GetBoard()->GetColorsSettings() ); + } + myframe->GetCanvas()->Refresh(); } diff --git a/pcbnew/pcb_base_edit_frame.cpp b/pcbnew/pcb_base_edit_frame.cpp index fb73923eac..e0a3bcff4c 100644 --- a/pcbnew/pcb_base_edit_frame.cpp +++ b/pcbnew/pcb_base_edit_frame.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include void PCB_BASE_EDIT_FRAME::SetRotationAngle( int aRotationAngle ) @@ -73,6 +74,8 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard ) PCB_BASE_FRAME::SetBoard( aBoard ); + GetGalCanvas()->GetGAL()->SetGridOrigin( VECTOR2D( aBoard->GetGridOrigin() ) ); + // update the tool manager with the new board and its view. if( m_toolManager ) { @@ -86,4 +89,3 @@ void PCB_BASE_EDIT_FRAME::SetBoard( BOARD* aBoard ) m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); } } - diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 2cdb920282..7c72766c05 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -786,7 +786,19 @@ EDA_COLOR_T PCB_EDIT_FRAME::GetGridColor() const void PCB_EDIT_FRAME::SetGridColor( EDA_COLOR_T aColor ) { + GetBoard()->SetVisibleElementColor( GRID_VISIBLE, aColor ); + + if( IsGalCanvasActive() ) + { + StructColors c = g_ColorRefs[ aColor ]; + KIGFX::COLOR4D color( (double) c.m_Red / 255.0, + (double) c.m_Green / 255.0, + (double) c.m_Blue / 255.0, + 0.7 ); + + GetGalCanvas()->GetGAL()->SetGridColor( color ); + } }