← Back to team overview

kicad-developers team mailing list archive

Re: GAL canvas strategy - testers needed!

 

Le 12/09/2018 à 17:01, Jeff Young a écrit :
> I just pushed a fix for a segfault while routing.  (https://bugs.launchpad.net/kicad/+bug/1792037)
> 
> Cheers,
> Jeff.

Hi Jeff,

Attached 2 other patches for Eeschema GAL.

The first allows switching between Cairo and Opengl.
The second fixes Zoom issues (with hotkeys and popup menu).

I am seeing an other annoying issue: the scroll bars are not shown in
Gal Canvas (both in Eeschema and Pcbnew), but I have no idea why they
are not displayed (although they are displayed in the pad properties
dialog).

Perhaps a GAL guru could have a look into this issue.

I also saw a few minor other issues, depending on the selected canvas.

Cheers,

-- 
Jean-Pierre CHARRAS
From 57be4f24ad098a97fdbff920d43ca6f3b7fb6c64 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@xxxxxxxxxx>
Date: Mon, 10 Sep 2018 15:37:28 +0200
Subject: [PATCH 1/2] add option to switch between opengl and cairo in eeschema
 (step 1)

---
 common/draw_panel_gal.cpp            |  4 +--
 common/gal/cairo/cairo_gal.cpp       |  8 +++--
 common/gal/opengl/opengl_gal.cpp     | 11 ++++--
 common/legacy_gal/eda_draw_frame.cpp | 11 +++---
 eeschema/hotkeys.cpp                 | 19 +++++++++-
 eeschema/hotkeys.h                   |  4 ++-
 eeschema/menubar.cpp                 | 14 ++++++++
 eeschema/onrightclick.cpp            |  2 +-
 eeschema/sch_base_frame.cpp          | 54 +++++++++++++++++++++++++---
 eeschema/sch_base_frame.h            | 12 +++++++
 eeschema/sch_draw_panel.cpp          | 20 +++++++----
 eeschema/sch_edit_frame.cpp          |  5 +++
 eeschema/sch_preview_panel.cpp       |  8 +++--
 include/class_draw_panel_gal.h       |  4 +--
 include/draw_frame.h                 |  5 +--
 pcbnew/pcb_draw_panel_gal.cpp        |  1 +
 16 files changed, 147 insertions(+), 35 deletions(-)

diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp
index 9d49ff26c..adb45b0db 100644
--- a/common/draw_panel_gal.cpp
+++ b/common/draw_panel_gal.cpp
@@ -360,7 +360,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
             break;
 
         default:
-            assert( false );
+            wxASSERT( false );
             // warn about unhandled GAL canvas type, but continue with the fallback option
 
         case GAL_TYPE_NONE:
@@ -383,7 +383,7 @@ bool EDA_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
     // from the defaults
     m_options.NotifyChanged();
 
-    assert( new_gal );
+    wxASSERT( new_gal );
     delete m_gal;
     m_gal = new_gal;
 
diff --git a/common/gal/cairo/cairo_gal.cpp b/common/gal/cairo/cairo_gal.cpp
index b5f3e4f67..d9834b469 100644
--- a/common/gal/cairo/cairo_gal.cpp
+++ b/common/gal/cairo/cairo_gal.cpp
@@ -351,7 +351,11 @@ void CAIRO_GAL::DrawCurve( const VECTOR2D& aStartPoint, const VECTOR2D& aControl
 void CAIRO_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
 {
     int ppi = aBitmap.GetPPI();
-    double worldIU_per_mm = 1/(worldUnitLength/2.54)/1000;
+    // We have to calculate the pixel size in users units to draw the image.
+    // worldUnitLength is the user unit in GAL unit value
+    // (GAL unit = 0.1 inch in nanometer = 2.54/1000 in mm).
+    // worldUnitLength * 1000 / 2.54 is the user unit in mm
+    double worldIU_per_mm = 1/( worldUnitLength / 0.00254 );
     double pix_size_iu =  worldIU_per_mm * ( 25.4 / ppi );
     int w = aBitmap.GetSizePixels().x;
     int h = aBitmap.GetSizePixels().y;
@@ -1202,5 +1206,5 @@ unsigned int CAIRO_GAL::getNewGroupNumber()
 
 void CAIRO_GAL::EnableDepthTest( bool aEnabled )
 {
-    
+
 }
diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp
index 409047bca..62c567d52 100644
--- a/common/gal/opengl/opengl_gal.cpp
+++ b/common/gal/opengl/opengl_gal.cpp
@@ -1001,8 +1001,15 @@ void OPENGL_GAL::DrawBitmap( const BITMAP_BASE& aBitmap )
 {
     int ppi = aBitmap.GetPPI();
 
-    double w = (double) aBitmap.GetSizePixels().x / (double) ppi / worldUnitLength * 10.0; // no idea where the factor 10 comes from...
-    double h = (double) aBitmap.GetSizePixels().y / (double) ppi / worldUnitLength * 10.0;
+    // We have to calculate the pixel size in users units to draw the image.
+    // worldUnitLength is the user unit in GAL unit value
+    // (GAL unit = 2.54/1e9 in meter).
+    // worldUnitLength * 1000 / 2.54 is the user unit in mm
+    double worldIU_per_mm = 1.0 / ( worldUnitLength / 0.00254 );
+    double pix_size_iu = worldIU_per_mm * ( 25.4 / ppi );
+
+    double w = (double) aBitmap.GetSizePixels().x * pix_size_iu;
+    double h = (double) aBitmap.GetSizePixels().y * pix_size_iu;
 
     auto xform = currentManager->GetTransformation();
 
diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index fa4fbb50f..75fd45c7e 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -221,16 +221,13 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
     m_FramePos.x   = m_FramePos.y = 0;
     m_FrameSize.y -= m_MsgFrameHeight;
 
-    printf("calling createCanvas\n");
-    createCanvas();
-    printf("Canvas %p\n", m_canvas);
-
     m_messagePanel  = new EDA_MSG_PANEL( this, -1, wxPoint( 0, m_FrameSize.y ),
                                          wxSize( m_FrameSize.x, m_MsgFrameHeight ) );
 
     m_messagePanel->SetBackgroundColour( COLOR4D( LIGHTGRAY ).ToColour() );
 }
 
+
 EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
 {
     delete m_socketServer;
@@ -652,7 +649,7 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
     // Change GAL canvas cursor if requested.
     if( IsGalCanvasActive() )
         defaultCursor = GetGalCanvas()->GetDefaultCursor();
-    
+
     SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
 }
 
@@ -1045,7 +1042,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
 
     GetGalCanvas()->SetEvtHandlerEnabled( aEnable );
 
-   
+
     // Reset current tool on switch();
     SetNoToolSelected();
 
@@ -1067,7 +1064,7 @@ bool EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType )
 }
 
 
-EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting() 
+EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting()
 {
     EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
     wxConfigBase* cfg = Kiface().KifaceSettings();
diff --git a/eeschema/hotkeys.cpp b/eeschema/hotkeys.cpp
index 6e0ce204f..b6c43f3d0 100644
--- a/eeschema/hotkeys.cpp
+++ b/eeschema/hotkeys.cpp
@@ -237,6 +237,18 @@ static EDA_HOTKEY HkEditCut( _HKI( "Cut" ), HK_EDIT_CUT, GR_KB_CTRL + 'X', (int)
 static EDA_HOTKEY HkEditCopy( _HKI( "Copy" ), HK_EDIT_COPY, GR_KB_CTRL + 'C', (int) wxID_COPY );
 static EDA_HOTKEY HkEditPaste( _HKI( "Paste" ), HK_EDIT_PASTE, GR_KB_CTRL + 'V', (int) wxID_PASTE );
 
+static EDA_HOTKEY HkCanvasOpenGL( _HKI( "Switch to Modern Toolset with hardware-accelerated graphics (recommended)" ),
+                                  HK_CANVAS_OPENGL,
+#ifdef __WXMAC__
+                                  GR_KB_ALT +
+#endif
+                                  WXK_F11, ID_MENU_CANVAS_OPENGL );
+static EDA_HOTKEY HkCanvasCairo( _HKI( "Switch to Modern Toolset with software graphics (fall-back)" ),
+                                 HK_CANVAS_CAIRO,
+#ifdef __WXMAC__
+                                 GR_KB_ALT +
+#endif
+                                 WXK_F12, ID_MENU_CANVAS_CAIRO );
 
 // List of common hotkey descriptors
 static EDA_HOTKEY* common_Hotkey_List[] =
@@ -314,6 +326,8 @@ static EDA_HOTKEY* schematic_Hotkey_List[] =
     &HkLeaveSheet,
     &HkDeleteNode,
     &HkHighlightConnection,
+    &HkCanvasCairo,
+    &HkCanvasOpenGL,
     NULL
 };
 
@@ -616,12 +630,15 @@ bool SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
     case HK_ROTATE:                         // Rotate schematic item.
     case HK_EDIT_COMPONENT_WITH_LIBEDIT:    // Call Libedit and load the current component
     case HK_AUTOPLACE_FIELDS:               // Autoplace all fields around component
+    case HK_CANVAS_CAIRO:
+    case HK_CANVAS_OPENGL:
         {
-            // force a new item search on hot keys at current position,
+           // force a new item search on hot keys at current position,
             // if there is no currently edited item,
             // to avoid using a previously selected item
             if( ! itemInEdit )
                 screen->SetCurItem( NULL );
+
             EDA_HOTKEY_CLIENT_DATA data( aPosition );
             cmd.SetInt( hotKey->m_Idcommand );
             cmd.SetClientObject( &data );
diff --git a/eeschema/hotkeys.h b/eeschema/hotkeys.h
index 6b497ec6d..2d00cd353 100644
--- a/eeschema/hotkeys.h
+++ b/eeschema/hotkeys.h
@@ -77,7 +77,9 @@ enum hotkey_id_commnand {
     HK_DELETE_NODE,
     HK_AUTOPLACE_FIELDS,
     HK_UPDATE_PCB_FROM_SCH,
-    HK_SELECT_ITEMS_ON_PCB
+    HK_SELECT_ITEMS_ON_PCB,
+    HK_CANVAS_OPENGL,
+    HK_CANVAS_CAIRO,
 };
 
 // List of hotkey descriptors for Eeschema
diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp
index e3bea4742..fe8efc114 100644
--- a/eeschema/menubar.cpp
+++ b/eeschema/menubar.cpp
@@ -664,6 +664,20 @@ static void preparePreferencesMenu( SCH_EDIT_FRAME* aFrame, wxMenu* aParentMenu
 
     aParentMenu->AppendSeparator();
 
+    wxString text = AddHotkeyName( _( "Modern Toolset (&Accelerated)" ), g_Eeschema_Hokeys_Descr,
+                          HK_CANVAS_OPENGL );
+    AddMenuItem( aParentMenu, ID_MENU_CANVAS_OPENGL, text,
+                 _( "Use Modern Toolset with hardware-accelerated graphics (recommended)" ),
+                 KiBitmap( tools_xpm ), wxITEM_RADIO );
+
+    text = AddHotkeyName( _( "Modern Toolset (Fallba&ck)" ), g_Eeschema_Hokeys_Descr,
+                          HK_CANVAS_CAIRO );
+    AddMenuItem( aParentMenu, ID_MENU_CANVAS_CAIRO, text,
+                 _( "Use Modern Toolset with software graphics (fall-back)" ),
+                 KiBitmap( tools_xpm ), wxITEM_RADIO );
+
+    aParentMenu->AppendSeparator();
+
     // Import/export
     AddMenuItem( aParentMenu, ID_CONFIG_SAVE, _( "&Save Project File..." ),
                  _( "Save project preferences into a project file" ),
diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp
index 39b44de45..73c8656e8 100644
--- a/eeschema/onrightclick.cpp
+++ b/eeschema/onrightclick.cpp
@@ -143,7 +143,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
         item = LocateAndShowItem( aPosition, SCH_COLLECTOR::AllItemsButPins, 0, &actionCancelled );
 
         printf("Locateandshow %d %d item %p type %d\n", aPosition.x, aPosition.y,
-                item, item ? item->Type() : 0 ); fflush(0);
+                    item, item ? item->Type() : 0 ); fflush(0);
 
         // If the clarify item selection context menu is aborted, don't show the context menu.
         if( item == NULL && actionCancelled )
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index df780456d..b355eea69 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -91,6 +91,10 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
     EDA_DRAW_FRAME( aKiway, aParent, aWindowType, aTitle, aPosition,
             aSize, aStyle, aFrameName )
 {
+    printf("calling createCanvas\n");
+    createCanvas();
+    printf("Canvas %p\n", m_canvas);
+
     m_zoomLevelCoeff = 11.0;    // Adjusted to roughly displays zoom level = 1
                                 // when the screen shows a 1:1 image
                                 // obviously depends on the monitor,
@@ -100,12 +104,48 @@ SCH_BASE_FRAME::SCH_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent,
 }
 
 
-
 SCH_BASE_FRAME::~SCH_BASE_FRAME()
 {
 }
 
 
+void SCH_BASE_FRAME::OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent )
+{
+    wxMenuBar* menuBar = GetMenuBar();
+    EDA_DRAW_PANEL_GAL* gal_canvas = GetGalCanvas();
+    EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = gal_canvas->GetBackend();
+
+    struct { int menuId; int galType; } menuList[] =
+    {
+        { ID_MENU_CANVAS_OPENGL,    EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL },
+        { ID_MENU_CANVAS_CAIRO,     EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO },
+    };
+
+    for( auto ii: menuList )
+    {
+        wxMenuItem* item = menuBar->FindItem( ii.menuId );
+        if( ii.galType == canvasType )
+        {
+            item->Check( true );
+        }
+    }
+}
+
+
+void SCH_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
+{
+    auto new_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
+
+    if( aEvent.GetId() == ID_MENU_CANVAS_CAIRO )
+        new_type = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
+
+    if( m_canvasType == new_type )
+        return;
+
+    GetGalCanvas()->SwitchBackend( new_type );
+}
+
+
 void SCH_BASE_FRAME::OnOpenLibraryViewer( wxCommandEvent& event )
 {
     LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, true );
@@ -554,11 +594,17 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
     return true;
 }
 
-
-void EDA_DRAW_FRAME::createCanvas()
+void SCH_BASE_FRAME::createCanvas()
 {
+    EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
+
+    // Allows only a CAIRO or OPENGL canvas:
+    if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL &&
+        canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO )
+        canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
+
     m_canvas = new SCH_DRAW_PANEL( this, wxID_ANY, wxPoint( 0, 0 ), m_FrameSize,
-                                   m_galDisplayOptions, EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL );
+                                   GetGalDisplayOptions(), canvasType );
 
     m_useSingleCanvasPane = true;
 
diff --git a/eeschema/sch_base_frame.h b/eeschema/sch_base_frame.h
index fca8e7094..ceba7b5ef 100644
--- a/eeschema/sch_base_frame.h
+++ b/eeschema/sch_base_frame.h
@@ -102,11 +102,23 @@ public:
 
     virtual ~SCH_BASE_FRAME();
 
+    void createCanvas();
+
     SCH_DRAW_PANEL* GetCanvas() const override;
     SCH_SCREEN* GetScreen() const override;
 
     KIGFX::SCH_RENDER_SETTINGS* GetRenderSettings();
 
+    /**
+     * switches currently used canvas ( Cairo / OpenGL).
+     */
+    void OnSwitchCanvas( wxCommandEvent& aEvent );
+
+    /**
+     * Update UI called when switches currently used canvas (Cairo / OpenGL).
+     */
+    void OnUpdateSwitchCanvas( wxUpdateUIEvent& aEvent );
+
     /**
      * @return the increment value of the position of an item
      * for the repeat command
diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp
index 348f54ca2..4aa36700e 100644
--- a/eeschema/sch_draw_panel.cpp
+++ b/eeschema/sch_draw_panel.cpp
@@ -60,6 +60,9 @@ BEGIN_EVENT_TABLE( SCH_DRAW_PANEL, wxScrolledWindow )
 //    EVT_MENU_RANGE( ID_PAN_UP, ID_PAN_RIGHT, EDA_DRAW_PANEL::OnPan )
 END_EVENT_TABLE()
 
+// define our user unit value for GAL ( given in GAL unit = 2.54/(IU per meter))
+// TODO: move in a header common to sch_preview_panel.cpp
+#define IU_2_GAL_WORLD_UNIT 2.54/(IU_PER_MM*1000)
 
 SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
                                 const wxPoint& aPosition, const wxSize& aSize,
@@ -74,16 +77,15 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
     m_defaultCursor = m_currentCursor = wxCURSOR_ARROW;
     m_showCrossHair = true;
 #endif
-
     m_view = new KIGFX::SCH_VIEW( true );
     m_view->SetGAL( m_gal );
 
-    m_gal->SetWorldUnitLength( 0.01 ); // 1 unit = 0.01 inch
+    m_gal->SetWorldUnitLength( IU_2_GAL_WORLD_UNIT );
 
     m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) );
 
     m_view->SetPainter( m_painter.get() );
-    m_view->SetScaleLimits( 2000000.0, 0.002 ); 
+    m_view->SetScaleLimits( 2000.0, 0.002 );
     m_view->SetMirror( false, false );
 
     setDefaultLayerOrder();
@@ -134,7 +136,7 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
 
     m_doubleClickInterval = 250;
 
-    m_gal->SetGridColor( COLOR4D(0.0, 0.0, 0.0, 1.0) );
+    m_gal->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) );
     m_gal->SetCursorColor( COLOR4D(0.0, 0.0, 0.0, 1.0) );
 
     m_viewControls->SetSnapping( true );
@@ -195,8 +197,12 @@ void SCH_DRAW_PANEL::setDefaultLayerOrder()
 
 bool SCH_DRAW_PANEL::SwitchBackend( GAL_TYPE aGalType )
 {
+    VECTOR2D grid_size = m_gal->GetGridSize();
     bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
     setDefaultLayerDeps();
+    m_gal->SetWorldUnitLength( IU_2_GAL_WORLD_UNIT );
+    m_gal->SetGridSize( grid_size );
+    m_gal->SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) );
     return rv;
 }
 
@@ -375,6 +381,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
 
     if( event.MiddleIsDown() )
     {
+/* Not used in GAL canvas
         wxPoint currentPosition = event.GetPosition();
 
         double scale = GetParent()->GetScreen()->GetScalingFactor();
@@ -384,6 +391,8 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
                 KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
 
         GetParent()->RedrawScreen( wxPoint( x, y ), false );
+*/
+        return;
     }
 
     // Calling the general function on mouse changes (and pseudo key commands)
@@ -679,7 +688,6 @@ void SCH_DRAW_PANEL::onPaint( wxPaintEvent& aEvent )
 {
     if( m_painter )
         static_cast<KIGFX::SCH_PAINTER*>(m_painter.get())->GetSettings()->ImportLegacyColors( nullptr );
-    
+
     EDA_DRAW_PANEL_GAL::onPaint( aEvent );
 }
-    
\ No newline at end of file
diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp
index fc0fc873e..e28435f74 100644
--- a/eeschema/sch_edit_frame.cpp
+++ b/eeschema/sch_edit_frame.cpp
@@ -320,6 +320,9 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
     EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
                     SCH_EDIT_FRAME::Process_Special_Functions )
 
+    EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
+    EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
+
     // Tools and buttons options toolbar
     EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
     EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnSelectOptionToolbar )
@@ -347,6 +350,8 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
     EVT_UPDATE_UI( ID_UPDATE_ONE_SHEET, SCH_EDIT_FRAME::OnUpdateSaveSheet )
     EVT_UPDATE_UI( ID_POPUP_SCH_LEAVE_SHEET, SCH_EDIT_FRAME::OnUpdateHierarchySheet )
     EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
+    EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
+    EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
 
     /* Search dialog events. */
     EVT_FIND_CLOSE( wxID_ANY, SCH_EDIT_FRAME::OnFindDialogClose )
diff --git a/eeschema/sch_preview_panel.cpp b/eeschema/sch_preview_panel.cpp
index 3d7162938..0d9b46b79 100644
--- a/eeschema/sch_preview_panel.cpp
+++ b/eeschema/sch_preview_panel.cpp
@@ -40,6 +40,9 @@
 
 using namespace std::placeholders;
 
+// define our user unit value for GAL ( given in GAL unit = 2.54/(IU per meter))
+// TODO: move in a header common to sch_draw_panel.cpp
+#define IU_2_GAL_WORLD_UNIT 2.54/(IU_PER_MM*1000)
 
 SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
                                       const wxPoint& aPosition, const wxSize& aSize,
@@ -50,12 +53,12 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
     m_view = new KIGFX::SCH_VIEW( true );
     m_view->SetGAL( m_gal );
 
-    m_gal->SetWorldUnitLength( 0.01 ); // 1 unit = 0.01 inch
+    m_gal->SetWorldUnitLength( IU_2_GAL_WORLD_UNIT );
 
     m_painter.reset( new KIGFX::SCH_PAINTER( m_gal ) );
 
     m_view->SetPainter( m_painter.get() );
-    m_view->SetScaleLimits( 2000000.0, 0.002 ); 
+    m_view->SetScaleLimits( 20000.0, 0.002 );
     m_view->SetMirror( false, false );
 
     setDefaultLayerOrder();
@@ -139,4 +142,3 @@ void SCH_PREVIEW_PANEL::onPaint( wxPaintEvent& aEvent )
     if( IsShown() )
         EDA_DRAW_PANEL_GAL::onPaint( aEvent );
 }
-    
\ No newline at end of file
diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h
index 2626c4bc7..ded6c7499 100644
--- a/include/class_draw_panel_gal.h
+++ b/include/class_draw_panel_gal.h
@@ -162,7 +162,7 @@ public:
 
     virtual void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector<MSG_PANEL_ITEM>& aList )
     {
-        assert( false );
+        wxASSERT( false );
     }
 
     /**
@@ -210,7 +210,7 @@ public:
      * Set the current cursor shape for this panel
      */
     virtual void SetCurrentCursor( int aCursor );
-    
+
     /**
      * Function GetDefaultCursor
      * @return the default cursor shape
diff --git a/include/draw_frame.h b/include/draw_frame.h
index e5c000d34..d110cd2b5 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -78,10 +78,9 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER
 
     ///< GAL display options - this is the frame's interface to setting GAL display options
     KIGFX::GAL_DISPLAY_OPTIONS  m_galDisplayOptions;
-    bool m_useSingleCanvasPane;
-
 
 protected:
+    bool m_useSingleCanvasPane;
 
     wxSocketServer*                          m_socketServer;
     std::vector<wxSocketBase*>               m_sockets;         ///< interprocess communication
@@ -221,8 +220,6 @@ protected:
     ///> Key in KifaceSettings to store the canvas type.
     static const wxChar CANVAS_TYPE_KEY[];
 
-    void createCanvas();
-
 public:
     EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
                     FRAME_T aFrameType,
diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp
index a7510666f..292ab94fb 100644
--- a/pcbnew/pcb_draw_panel_gal.cpp
+++ b/pcbnew/pcb_draw_panel_gal.cpp
@@ -394,6 +394,7 @@ bool PCB_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
 {
     bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
     setDefaultLayerDeps();
+    m_gal->SetWorldUnitLength( 2.54/(IU_PER_MM*1000) ); // world unit is in internal units per inch * 1000
     return rv;
 }
 
-- 
2.17.0.windows.1

From 73922406082b48b763b96b8b251bf9221eb140c4 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@xxxxxxxxxx>
Date: Fri, 14 Sep 2018 10:15:10 +0200
Subject: [PATCH 2/2] Fix zoom issues in Eeschema (F1 to F4 and popup zoom
 commands) Fix also not saving the Gal Canvas type on eeschema exit.

---
 common/legacy_gal/eda_draw_frame.cpp | 102 +++++++++++++++++++--------
 eeschema/sch_base_frame.cpp          |   4 +-
 eeschema/sch_draw_panel.cpp          |  15 +---
 include/draw_frame.h                 |  18 ++++-
 include/legacy_gal/class_drawpanel.h |  52 +++++++-------
 5 files changed, 122 insertions(+), 69 deletions(-)

diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index 75fd45c7e..9d8718c52 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -237,7 +237,7 @@ EDA_DRAW_FRAME::~EDA_DRAW_FRAME()
         socket->Destroy();
     }
 
-    if( m_canvasTypeDirty )
+    if( m_canvasTypeDirty )     // the canvas type has changed: save the new type
         saveCanvasTypeSetting( m_canvasType );
 
     delete m_actions;
@@ -1076,7 +1076,7 @@ EDA_DRAW_PANEL_GAL::GAL_TYPE EDA_DRAW_FRAME::LoadCanvasTypeSetting()
     if( canvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
             || canvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
     {
-        assert( false );
+        wxASSERT( false );
         canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE;
     }
 
@@ -1089,7 +1089,7 @@ bool EDA_DRAW_FRAME::saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvas
     if( aCanvasType < EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE
             || aCanvasType >= EDA_DRAW_PANEL_GAL::GAL_TYPE_LAST )
     {
-        assert( false );
+        wxASSERT( false );
         return false;
     }
 
@@ -1364,9 +1364,9 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
         return;
 
     int          id = event.GetId();
-    bool         zoom_at_cursor = false;
-    BASE_SCREEN* screen = GetScreen();
-    wxPoint      center = GetScrollCenterPosition();
+    bool         warp_cursor = false;
+    VECTOR2D cpos = GetCrossHairPosition();//GetGalCanvas()->GetViewControls()->GetCursorPosition();
+    wxPoint zoom_center( (int)cpos.x, (int)cpos.y );
 
     if ( id == ID_KEY_ZOOM_IN )
     {
@@ -1382,39 +1382,27 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
     switch( id )
     {
     case ID_OFFCENTER_ZOOM_IN:
-        center = m_canvas->ToDeviceXY( GetCrossHairPosition() );
-
-        if( screen->SetPreviousZoom() )
-            RedrawScreen2( center );
+        SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
         break;
 
     case ID_POPUP_ZOOM_IN:
-        zoom_at_cursor = true;
-        center = GetCrossHairPosition();
-
-    // fall thru
+        warp_cursor = true;
+        // fall thru
     case ID_VIEWER_ZOOM_IN:
     case ID_ZOOM_IN:
-        if( screen->SetPreviousZoom() )
-            RedrawScreen( center, zoom_at_cursor );
+        SetPreviousZoomAndRedraw( zoom_center,warp_cursor );
         break;
 
     case ID_OFFCENTER_ZOOM_OUT:
-        center = m_canvas->ToDeviceXY( GetCrossHairPosition() );
-
-        if( screen->SetNextZoom() )
-            RedrawScreen2( center );
+        SetNextZoomAndRedraw( zoom_center, warp_cursor );
         break;
 
     case ID_POPUP_ZOOM_OUT:
-        zoom_at_cursor = true;
-        center = GetCrossHairPosition();
-
-    // fall thru
+        warp_cursor = true;
+        // fall thru
     case ID_VIEWER_ZOOM_OUT:
     case ID_ZOOM_OUT:
-        if( screen->SetNextZoom() )
-            RedrawScreen( center, zoom_at_cursor );
+        SetNextZoomAndRedraw( zoom_center, warp_cursor );
         break;
 
     case ID_VIEWER_ZOOM_REDRAW:
@@ -1425,8 +1413,8 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
         break;
 
     case ID_POPUP_ZOOM_CENTER:
-        center = GetCrossHairPosition();
-        RedrawScreen( center, true );
+        GetGalCanvas()->GetView()->SetScale( GetGalCanvas()->GetView()->GetScale(), zoom_center );
+        GetGalCanvas()->GetViewControls()->CenterOnCursor();
         break;
 
     case ID_POPUP_ZOOM_PAGE:
@@ -1462,6 +1450,64 @@ void EDA_DRAW_FRAME::SetPrevZoom()
 }
 
 
+void EDA_DRAW_FRAME::SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
+{
+    double zoom = GetGalCanvas()->GetLegacyZoom();
+    zoom *= 1.3;
+
+    // Now look for the next closest menu step
+    std::vector<double>& zoomList = GetScreen()->m_ZoomList;
+    int idx;
+
+    for( idx = 0; idx < (int)zoomList.size(); ++idx )
+    {
+        if( zoomList[idx] > zoom )
+            break;
+    }
+
+    if( idx >= (int)zoomList.size() )
+        return;
+
+    VECTOR2D cpos = GetGalCanvas()->GetViewControls()->GetCursorPosition();
+    wxPoint center( (int)cpos.x, (int)cpos.y );
+
+    if( m_zoomSelectBox )
+        m_zoomSelectBox->SetSelection( idx );
+
+    if( GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] ) )
+        RedrawScreen( aCenterPoint, true );
+}
+
+
+void EDA_DRAW_FRAME::SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer )
+{
+    double zoom = GetGalCanvas()->GetLegacyZoom();
+    zoom /= 1.3;
+
+    // Now look for the next closest menu step
+    std::vector<double>& zoomList = GetScreen()->m_ZoomList;
+    int idx;
+
+    for( idx = zoomList.size() - 1; idx >= 0; --idx )
+    {
+        if( zoomList[idx] < zoom )
+            break;
+    }
+
+    if( idx < 0 )
+        return;
+
+    VECTOR2D cpos = GetGalCanvas()->GetViewControls()->GetCursorPosition();
+    wxPoint center( (int)cpos.x, (int)cpos.y );
+
+    if( m_zoomSelectBox )
+        m_zoomSelectBox->SetSelection( idx );
+
+    if( GetScreen()->SetZoom( GetScreen()->m_ZoomList[idx] ) )
+        RedrawScreen( aCenterPoint, aWarpPointer );
+}
+
+
 void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
 {
     BASE_SCREEN* screen = GetScreen();
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index b355eea69..3a71df32b 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -143,6 +143,8 @@ void SCH_BASE_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
         return;
 
     GetGalCanvas()->SwitchBackend( new_type );
+    m_canvasTypeDirty = true;   // force saving new canvas type in config
+    m_canvasType = new_type;
 }
 
 
@@ -461,7 +463,7 @@ void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
         GetCanvas()->GetView()->SetScale( scale );
 
     if( aWarpPointer )
-        GetCanvas()->GetViewControls()->WarpCursor( aCenterPoint );
+        GetCanvas()->GetViewControls()->CenterOnCursor();
 
     GetCanvas()->Refresh();
 }
diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp
index 4aa36700e..95d593664 100644
--- a/eeschema/sch_draw_panel.cpp
+++ b/eeschema/sch_draw_panel.cpp
@@ -40,10 +40,9 @@
 
 using namespace std::placeholders;
 
-
 // Events used by EDA_DRAW_PANEL
 // GAL TODO: some (most?) of these need to be implemented...
-BEGIN_EVENT_TABLE( SCH_DRAW_PANEL, wxScrolledWindow )
+BEGIN_EVENT_TABLE( SCH_DRAW_PANEL, wxScrolledCanvas )
 //    EVT_LEAVE_WINDOW( EDA_DRAW_PANEL::OnMouseLeaving )
 //    EVT_ENTER_WINDOW( EDA_DRAW_PANEL::OnMouseEntering )
 //    EVT_MOUSEWHEEL( EDA_DRAW_PANEL::OnMouseWheel )
@@ -381,17 +380,7 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
 
     if( event.MiddleIsDown() )
     {
-/* Not used in GAL canvas
-        wxPoint currentPosition = event.GetPosition();
-
-        double scale = GetParent()->GetScreen()->GetScalingFactor();
-        int x = m_PanStartCenter.x +
-                KiROUND( (double) ( m_PanStartEventPosition.x - currentPosition.x ) / scale );
-        int y = m_PanStartCenter.y +
-                KiROUND( (double) ( m_PanStartEventPosition.y - currentPosition.y ) / scale );
-
-        GetParent()->RedrawScreen( wxPoint( x, y ), false );
-*/
+        // already managed by EDA_DRAW_PANEL_GAL mouse event handler.
         return;
     }
 
diff --git a/include/draw_frame.h b/include/draw_frame.h
index d110cd2b5..11cfff0dc 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -72,7 +72,6 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER
     BASE_SCREEN*        m_currentScreen;      ///< current used SCREEN
 
     bool                m_snapToGrid;         ///< Indicates if cursor should be snapped to grid.
-    bool                m_galCanvasActive;    ///< whether to use new GAL engine
 
     EDA_DRAW_PANEL_GAL* m_galCanvas;
 
@@ -80,6 +79,7 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER
     KIGFX::GAL_DISPLAY_OPTIONS  m_galDisplayOptions;
 
 protected:
+    bool m_galCanvasActive;    ///< whether to use new GAL engine
     bool m_useSingleCanvasPane;
 
     wxSocketServer*                          m_socketServer;
@@ -651,12 +651,28 @@ public:
      */
     void SetNextZoom();
 
+    /**
+     * changes the zoom to the next one available redraws the screen
+     * and warp the mouse pointer on request.
+     * @param aCenterPoint is the reference point for zooming
+     * @param aWarpPointer = true to move the pointer to the aCenterPoint
+     */
+    void SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer );
+
     /**
      * Function SetPrevZoom()
      * changes the zoom to the previous one available.
      */
     void SetPrevZoom();
 
+    /**
+     * changes the zoom to the previous one available redraws the screen
+     * and warp the mouse pointer on request.
+     * @param aCenterPoint is the reference point for zooming
+     * @param aWarpPointer = true to move the pointer to the aCenterPoint
+     */
+    void SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer );
+
     /**
      * Function SetPresetZoom()
      * changes zoom to one of the preset values.
diff --git a/include/legacy_gal/class_drawpanel.h b/include/legacy_gal/class_drawpanel.h
index 0f2ef13d5..c0564d04a 100644
--- a/include/legacy_gal/class_drawpanel.h
+++ b/include/legacy_gal/class_drawpanel.h
@@ -94,7 +94,7 @@ public:
      * A way to pass info to draw functions.
      * this is just an accessor to the GetDisplayOptions() parent frame function.
      */
-    virtual void* GetDisplayOptions() { printf("Unimplemented\n"); assert(false); return nullptr; };
+    virtual void* GetDisplayOptions() { printf("EDA_DRAW_PANEL:Unimplemented\n"); wxASSERT(false); return nullptr; };
 
     virtual BASE_SCREEN* GetScreen() = 0;
 
@@ -143,7 +143,7 @@ public:
      * X and Y axis
      * X and Y auxiliary axis
      */
-    virtual void DrawBackGround( wxDC* DC ) { printf("Unimplemented\n"); };
+    virtual void DrawBackGround( wxDC* DC ) { printf("EDA_DRAW_PANEL:Unimplemented1\n"); };
 
     /**
      * Function DrawGrid
@@ -153,7 +153,7 @@ public:
      * @see EDA_DRAW_FRAME::GetGridColor() for the color of the grid.
      * @param aDC The device context to draw the grid.
      */
-    virtual void DrawGrid( wxDC* aDC ) { printf("Unimplemented\n"); };
+    virtual void DrawGrid( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented2\n"); };
 
     /**
      * Function DrawAuxiliaryAxis
@@ -162,7 +162,7 @@ public:
      * @param aDC = current Device Context
      * @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
      */
-    virtual void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) { printf("Unimplemented\n");};
+    virtual void DrawAuxiliaryAxis( wxDC* aDC, GR_DRAWMODE aDrawMode ) { printf("EDA_DRAW_PANEL:Unimplemented2\n");};
 
     /**
      * Function DrawGridAxis
@@ -172,7 +172,7 @@ public:
      * @param aDrawMode = draw mode (GR_COPY, GR_OR ..)
      * @param aGridOrigin = the absolute coordinate of grid origin for snap.
      */
-    virtual void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { printf("Unimplemented\n");  };
+    virtual void DrawGridAxis( wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aGridOrigin ) { printf("EDA_DRAW_PANEL:Unimplemented4\n");  };
 
         /**
      * Function DeviceToLogical
@@ -184,7 +184,7 @@ public:
      * @param aDC The device context used for the conversion.
      * @return A rectangle converted to drawing units.
      */
-    virtual wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC ) { printf("Unimplemented\n");assert(false); return wxRect(); };
+    virtual wxRect DeviceToLogical( const wxRect& aRect, wxDC& aDC ) { printf("EDA_DRAW_PANEL:Unimplemented5\n");wxASSERT(false); return wxRect(); };
 
     /* Mouse and keys events */
 
@@ -198,13 +198,13 @@ public:
      *</p>
      */
 
-     virtual void EraseScreen( wxDC* DC ) { printf("Unimplemented\n");  };;
+     virtual void EraseScreen( wxDC* DC ) { printf("EDA_DRAW_PANEL:Unimplemented6\n");  };;
 
-    virtual void SetZoom( double mode ) { printf("Unimplemented\n");  };;
-    virtual double GetZoom() { printf("Unimplemented\n"); return 1.0; };;
+    virtual void SetZoom( double mode ) { printf("EDA_DRAW_PANEL:Unimplemented7\n");  };;
+    virtual double GetZoom() { printf("EDA_DRAW_PANEL:Unimplemented8\n"); return 1.0; };;
 
-    //virtual void SetGrid( const wxRealPoint& size ) { printf("Unimplemented\n");  };;
-    //virtual wxRealPoint GetGrid() { printf("Unimplemented\n"); return wxRealPoint(1.0, 1.0); };;
+    //virtual void SetGrid( const wxRealPoint& size ) { printf("EDA_DRAW_PANEL:Unimplemented\n");  };;
+    //virtual wxRealPoint GetGrid() { printf("EDA_DRAW_PANEL:Unimplemented\n"); return wxRealPoint(1.0, 1.0); };;
 
 
     /**
@@ -213,7 +213,7 @@ public:
      * @return true if \a aPosition is visible on the screen.
      *         false if \a aPosition is not visible on the screen.
      */
-    virtual bool IsPointOnDisplay( const wxPoint& aPosition ) { printf("Unimplemented\n"); return false; };;
+    virtual bool IsPointOnDisplay( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented9\n"); return false; };;
 
     /**
      * Function SetClipBox
@@ -231,9 +231,9 @@ public:
      * @param aRect The clip rectangle in device units or NULL for the entire visible area
      *              of the screen.
      */
-    virtual void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ) { printf("Unimplemented\n"); };;
+    virtual void SetClipBox( wxDC& aDC, const wxRect* aRect = NULL ) { printf("EDA_DRAW_PANEL:Unimplemented10\n"); };;
 
-    virtual void ReDraw( wxDC* aDC, bool aEraseBackground = true ) { printf("Unimplemented\n");  };;
+    virtual void ReDraw( wxDC* aDC, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented11\n");  };;
 
     /**
      * Function RefreshDrawingRect
@@ -242,7 +242,7 @@ public:
      * @param aRect The rectangle to repaint.
      * @param aEraseBackground Erases the background if true.
      */
-    virtual void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ) { printf("Unimplemented\n"); };;
+    virtual void RefreshDrawingRect( const EDA_RECT& aRect, bool aEraseBackground = true ) { printf("EDA_DRAW_PANEL:Unimplemented12\n"); };;
 
     /// @copydoc wxWindow::Refresh()
     //virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL );
@@ -251,32 +251,32 @@ public:
      * Function GetScreenCenterLogicalPosition
      * @return The current screen center position in logical (drawing) units.
      */
-    virtual wxPoint GetScreenCenterLogicalPosition() { printf("Unimplemented\n"); return wxPoint(0, 0); };;
+    virtual wxPoint GetScreenCenterLogicalPosition() { printf("EDA_DRAW_PANEL:Unimplemented13\n"); return wxPoint(0, 0); };;
 
     /**
      * Function MoveCursorToCrossHair
      * warps the cursor to the current cross hair position.
      */
-    virtual void MoveCursorToCrossHair() { printf("Unimplemented\n"); };;
+    virtual void MoveCursorToCrossHair() { printf("EDA_DRAW_PANEL:Unimplemented14\n"); };;
 
     /**
      * Function ToDeviceXY
      * transforms logical to device coordinates
      */
-    virtual wxPoint ToDeviceXY( const wxPoint& pos ) { printf("Unimplemented\n"); return wxPoint(0, 0); };;
+    virtual wxPoint ToDeviceXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented15\n"); return wxPoint(0, 0); };;
 
     /**
      * Function ToLogicalXY
      * transforms device to logical coordinates
      */
-    virtual wxPoint ToLogicalXY( const wxPoint& pos ) { printf("Unimplemented\n"); return wxPoint(0, 0); };;
+    virtual wxPoint ToLogicalXY( const wxPoint& pos ) { printf("EDA_DRAW_PANEL:Unimplemented16\n"); return wxPoint(0, 0); };;
 
     /**
      * Function MoveCursor
      * moves the mouse pointer to \a aPosition in logical (drawing) units.
      * @param aPosition The position in logical units to move the cursor.
      */
-    virtual void MoveCursor( const wxPoint& aPosition ) { printf("Unimplemented\n");  };;
+    virtual void MoveCursor( const wxPoint& aPosition ) { printf("EDA_DRAW_PANEL:Unimplemented17\n");  };;
 
     /* Cursor functions */
     /**
@@ -291,13 +291,13 @@ public:
      * @param aDC - the device context to draw the cursor
      * @param aColor - the color to draw the cursor
      */
-    virtual void DrawCrossHair( wxDC* aDC=nullptr, COLOR4D aColor = COLOR4D::WHITE ) { printf("Unimplemented\n"); };;
+    virtual void DrawCrossHair( wxDC* aDC=nullptr, COLOR4D aColor = COLOR4D::WHITE ) { printf("EDA_DRAW_PANEL:Unimplemented18\n"); };;
 
     // Hide the cross hair.
-    virtual void CrossHairOff( wxDC* DC=nullptr ) { printf("Unimplemented\n");  };;
+    virtual void CrossHairOff( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented19\n");  };;
 
     // Show the cross hair.
-    virtual void CrossHairOn( wxDC* DC=nullptr ) { printf("Unimplemented\n");  };;
+    virtual void CrossHairOn( wxDC* DC=nullptr ) { printf("EDA_DRAW_PANEL:Unimplemented20\n");  };;
 
     /**
      * Function SetMouseCapture
@@ -332,7 +332,7 @@ public:
      */
     virtual void EndMouseCapture( int aId = -1, int aCursorId = -1,
                           const wxString& aTitle = wxEmptyString,
-                          bool aCallEndFunc = true ) { printf("Unimplemented\n"); assert(false); };;
+                          bool aCallEndFunc = true ) { printf("EDA_DRAW_PANEL:Unimplemented21\n"); wxASSERT(false); };;
 
     inline bool IsMouseCaptured() const { return m_mouseCaptureCallback != NULL; }
 
@@ -346,7 +346,7 @@ public:
      * @param aErase True indicates the item being drawn should be erase before drawing
      *               it a \a aPosition.
      */
-    virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) { printf("Unimplemented\n"); assert(false); };;
+    virtual void CallMouseCapture( wxDC* aDC, const wxPoint& aPosition, bool aErase ) { printf("EDA_DRAW_PANEL:Unimplemented22\n"); wxASSERT(false); };;
 
     /**
      * Function CallEndMouseCapture
@@ -354,7 +354,7 @@ public:
      *
      * @param aDC A point to a wxDC object to perform any drawing upon.
      */
-    virtual void CallEndMouseCapture( wxDC* aDC ) { printf("Unimplemented\n"); assert(false); };;
+    virtual void CallEndMouseCapture( wxDC* aDC ) { printf("EDA_DRAW_PANEL:Unimplemented23\n"); wxASSERT(false); };;
 
     virtual void Refresh( bool eraseBackground = true, const wxRect* rect = NULL ) {}
 
-- 
2.17.0.windows.1


Follow ups

References