← Back to team overview

kicad-developers team mailing list archive

[Patch] Update common preview items

 

Some preview items were still static casting into PCB_RENDER_SETTINGS while
others were using the base class version to get the layer colors. This
patch updates it so all calls are to the base class version, this also
removes the need to have pcb_painter (and any pcbnew includes) in these
files.

-Ian
From 362f4bba2379c64bc8455d5b857face5f5d1d76f Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Sat, 31 Aug 2019 16:35:33 +0200
Subject: [PATCH] Switch preview items to use abstract render settings

---
 common/preview_items/arc_assistant.cpp  | 1 -
 common/preview_items/polygon_item.cpp   | 4 ++--
 common/preview_items/preview_utils.cpp  | 4 ++--
 common/preview_items/ruler_item.cpp     | 6 +++---
 common/preview_items/selection_area.cpp | 2 +-
 5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp
index d1377028d..98016a643 100644
--- a/common/preview_items/arc_assistant.cpp
+++ b/common/preview_items/arc_assistant.cpp
@@ -28,7 +28,6 @@
 
 #include <gal/graphics_abstraction_layer.h>
 #include <view/view.h>
-#include <pcb_painter.h>
 
 #include <common.h>
 #include <base_units.h>
diff --git a/common/preview_items/polygon_item.cpp b/common/preview_items/polygon_item.cpp
index 3802b186c..21973e5e9 100644
--- a/common/preview_items/polygon_item.cpp
+++ b/common/preview_items/polygon_item.cpp
@@ -26,8 +26,8 @@
 #include <preview_items/preview_utils.h>
 
 #include <gal/graphics_abstraction_layer.h>
+#include <painter.h>
 #include <view/view.h>
-#include <pcb_painter.h>
 
 using namespace KIGFX::PREVIEW;
 
@@ -58,7 +58,7 @@ void POLYGON_ITEM::SetPoints( const SHAPE_LINE_CHAIN& aLockedInPts,
 void POLYGON_ITEM::drawPreviewShape( KIGFX::VIEW* aView ) const
 {
     auto& gal = *aView->GetGAL();
-    auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
+    auto rs = aView->GetPainter()->GetSettings();
 
     gal.DrawPolyline( m_lockedChain );
     gal.DrawPolygon( m_polyfill );
diff --git a/common/preview_items/preview_utils.cpp b/common/preview_items/preview_utils.cpp
index ff70fd6d4..323a93eef 100644
--- a/common/preview_items/preview_utils.cpp
+++ b/common/preview_items/preview_utils.cpp
@@ -20,7 +20,7 @@
 #include <preview_items/preview_utils.h>
 #include <gal/graphics_abstraction_layer.h>
 #include <base_units.h>
-#include <pcb_painter.h>
+#include <painter.h>
 #include <view/view.h>
 
 double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha( bool aDeemph )
@@ -99,7 +99,7 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView,
 {
     auto gal = aView->GetGAL();
     auto glyphSize = gal->GetGlyphSize();
-    auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
+    auto rs = aView->GetPainter()->GetSettings();
 
     const auto lineSpace = glyphSize.y * 0.2;
     auto linePitch = glyphSize.y + lineSpace;
diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp
index 2e3d36161..638483a86 100644
--- a/common/preview_items/ruler_item.cpp
+++ b/common/preview_items/ruler_item.cpp
@@ -26,8 +26,8 @@
 #include <preview_items/preview_utils.h>
 #include <gal/graphics_abstraction_layer.h>
 #include <layers_id_colors_and_visibility.h>
+#include <painter.h>
 #include <view/view.h>
-#include <pcb_painter.h>
 
 #include <base_units.h>
 #include <common.h>
@@ -122,7 +122,7 @@ void drawTicksAlongLine( KIGFX::VIEW *aView, const VECTOR2D& aOrigin,
     auto gal = aView->GetGAL();
     double tickSpace;
     TICK_FORMAT tickF = getTickFormatForScale( gal->GetWorldScale(), tickSpace, aUnits );
-    auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
+    auto rs = aView->GetPainter()->GetSettings();
 
     // number of ticks in whole ruler
     int numTicks = (int) std::ceil( aLine.EuclideanNorm() / tickSpace );
@@ -226,7 +226,7 @@ void RULER_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
 void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
 {
     auto& gal = *aView->GetGAL();
-    auto rs = static_cast<KIGFX::RENDER_SETTINGS*>( aView->GetPainter()->GetSettings() );
+    auto rs = aView->GetPainter()->GetSettings();
 
     VECTOR2D origin = m_geomMgr.GetOrigin();
     VECTOR2D end = m_geomMgr.GetEnd();
diff --git a/common/preview_items/selection_area.cpp b/common/preview_items/selection_area.cpp
index e647ef25c..511a7b68d 100644
--- a/common/preview_items/selection_area.cpp
+++ b/common/preview_items/selection_area.cpp
@@ -25,8 +25,8 @@
 #include <preview_items/selection_area.h>
 
 #include <gal/graphics_abstraction_layer.h>
+#include <painter.h>
 #include <view/view.h>
-#include <pcb_painter.h>
 
 using namespace KIGFX::PREVIEW;
 
-- 
2.21.0


Follow ups