← Back to team overview

kicad-developers team mailing list archive

[PATCH] Add DRC items when reloading board view (Fixes lp:1542420)

 

Hi all,

I figured out why DRC markers were disappearing... The call to SetBoard()
erases the view and repopulates it from the board objects, but didn't
include the DRC markers.

I'm not actually sure why we need to call DisplayBoard() on canvas switch,
but that optimization seems like a bit more effort than necessary right
before release.

-Jon
From ead8fbb2cddbb85a6151a4fec276839bf3f749db Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Tue, 28 Nov 2017 21:57:28 -0500
Subject: [PATCH] Add DRC items when reloading board view (Fixes lp:1542420)

---
 pcbnew/pcb_draw_panel_gal.cpp |  7 +++++++
 pcbnew/pcb_painter.cpp        | 16 +++++-----------
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp
index 1e970049c..f7f12d5ff 100644
--- a/pcbnew/pcb_draw_panel_gal.cpp
+++ b/pcbnew/pcb_draw_panel_gal.cpp
@@ -35,6 +35,7 @@
 #include <class_board.h>
 #include <class_module.h>
 #include <class_track.h>
+#include <class_marker_pcb.h>
 #include <wxBasePcbFrame.h>
 
 #include <gal/graphics_abstraction_layer.h>
@@ -159,6 +160,12 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( const BOARD* aBoard )
     for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
         m_view->Add( zone );
 
+    // DRC markers
+    for( int marker_idx = 0; marker_idx < aBoard->GetMARKERCount(); ++marker_idx )
+    {
+        m_view->Add( aBoard->GetMARKER( marker_idx ) );
+    }
+
     // Ratsnest
     m_ratsnest.reset( new KIGFX::RATSNEST_VIEWITEM( aBoard->GetConnectivity() ) );
     m_view->Add( m_ratsnest.get() );
diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp
index 8f56d1baa..0d969204b 100644
--- a/pcbnew/pcb_painter.cpp
+++ b/pcbnew/pcb_painter.cpp
@@ -1249,21 +1249,15 @@ void PCB_PAINTER::draw( const MARKER_PCB* aMarker )
         VECTOR2D(  9 * scale,   9 * scale ),
         VECTOR2D(  8 * scale,  13 * scale ),
         VECTOR2D(  3 * scale,   4 * scale ),
-        VECTOR2D(  1 * scale,   8 * scale )
+        VECTOR2D(  1 * scale,   8 * scale ),
+        VECTOR2D(  0 * scale,   0 * scale )
     };
 
+    auto strokeColor = m_pcbSettings.GetColor( aMarker, LAYER_DRC );
+
     m_gal->Save();
     m_gal->Translate( aMarker->GetPosition() );
-
-    if( aMarker->IsSelected() )
-    {
-        m_gal->SetFillColor( COLOR4D( 1.0, 0.5, 0.5, 1.0 ) );
-    }
-    else
-    {
-        m_gal->SetFillColor( COLOR4D( 1.0, 0.0, 0.0, 1.0 ) );
-    }
-
+    m_gal->SetFillColor( strokeColor );
     m_gal->SetIsFill( true );
     m_gal->SetIsStroke( false );
     m_gal->DrawPolygon( arrow, sizeof( arrow ) / sizeof( VECTOR2D ) );
-- 
2.14.1


Follow ups