kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #27891
[PATCH] Setup PCB painter in the PCB draw class rather than the base class
Hi all,
Patch attached for the issue I mentioned in the GerbView thread.
This will allow creation of other derived classes of EDA_DRAW_PANEL_GAL.
Best,
Jon
From c0b68d55bac543cdd10cffe9a82650c6d2259349 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Wed, 15 Feb 2017 21:06:05 -0500
Subject: [PATCH] Setup painter in PCB_DRAW_PANEL_GAL instead of
EDA_DRAW_PANEL_GAL
---
common/draw_panel_gal.cpp | 6 ++----
pcbnew/pcb_draw_panel_gal.cpp | 4 ++++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp
index 614a068..e14181d 100644
--- a/common/draw_panel_gal.cpp
+++ b/common/draw_panel_gal.cpp
@@ -73,10 +73,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
#endif
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
- m_painter = new KIGFX::PCB_PAINTER( m_gal );
-
m_view = new KIGFX::VIEW( true );
- m_view->SetPainter( m_painter );
m_view->SetGAL( m_gal );
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), NULL, this );
@@ -131,7 +128,6 @@ EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
assert( !m_drawing );
- delete m_painter;
delete m_viewControls;
delete m_view;
delete m_gal;
@@ -165,6 +161,8 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
PROF_COUNTER totalRealTime;
#endif /* PROFILE */
+ wxASSERT( m_painter );
+
m_drawing = true;
KIGFX::PCB_RENDER_SETTINGS* settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_painter->GetSettings() );
diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp
index 422a5a4..efa3dd9 100644
--- a/pcbnew/pcb_draw_panel_gal.cpp
+++ b/pcbnew/pcb_draw_panel_gal.cpp
@@ -107,6 +107,9 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
setDefaultLayerOrder();
setDefaultLayerDeps();
+ m_painter = new KIGFX::PCB_PAINTER( m_gal );
+ m_view->SetPainter( m_painter );
+
// Load display options (such as filled/outline display of items).
// Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
// which is not always the case (namely when it is used from a wxDialog like the pad editor)
@@ -122,6 +125,7 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
PCB_DRAW_PANEL_GAL::~PCB_DRAW_PANEL_GAL()
{
+ delete m_painter;
delete m_worksheet;
delete m_ratsnest;
}
--
2.7.4
Follow ups