diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 8ed3e9795a..da01d56491 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -214,19 +214,11 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) ) { constexpr auto GAL_FALLBACK = GAL_TYPE_CAIRO; - if( m_edaFrame ) - { - bool use_gal = m_edaFrame->SwitchCanvas( GAL_FALLBACK ); - m_edaFrame->UseGalCanvas( use_gal ); - } - else - { - SwitchBackend( GAL_FALLBACK ); - } + SwitchBackend( GAL_FALLBACK ); DisplayInfoMessage( m_parent, - _( "Could not use OpenGL, falling back to software rendering" ), - wxString( err.what() ) ); + _( "Could not use OpenGL, falling back to software rendering" ), + wxString( err.what() ) ); } #ifdef __WXDEBUG__ diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp index 850b097aa3..84e777a2a5 100644 --- a/common/legacy_gal/eda_draw_frame.cpp +++ b/common/legacy_gal/eda_draw_frame.cpp @@ -656,6 +656,7 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable ) bool EDA_DRAW_FRAME::SwitchCanvas( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType ) { + // JEY TODO: unravel this... auto galCanvas = GetGalCanvas(); wxCHECK( galCanvas, false ); bool use_gal = galCanvas->SwitchBackend( aCanvasType ); diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index d7dc6d5a71..d855f10edb 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -167,6 +167,12 @@ DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aPa auto& galOpts = GetGalDisplayOptions(); galOpts.m_axesEnabled = true; + + // Set up viewport + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( true ); // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.) diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 8506f6ec6c..dcf02230f2 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -452,6 +452,12 @@ void SCH_BASE_FRAME::createCanvas() m_useSingleCanvasPane = true; SetGalCanvas( static_cast (m_canvas) ); + + // Set up viewport + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( true ); } diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index 86c1882b69..f00e9ca46d 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -175,6 +175,11 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() ); m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() ); + // Set up viewport + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( true ); m_auimgr.Update(); diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index e07f959d5f..5300e3ce86 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -280,7 +280,6 @@ set( PCBNEW_CLASS_SRCS minimun_spanning_tree.cpp move-drag_pads.cpp move_or_drag_track.cpp - muwave_command.cpp netlist.cpp onleftclick.cpp pad_edit_functions.cpp diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h index b4f6d777c3..31a211cb88 100644 --- a/pcbnew/collectors.h +++ b/pcbnew/collectors.h @@ -262,7 +262,7 @@ protected: public: /** - * A scan list for all editable board items, like PcbGeneralLocateAndDisplay() + * A scan list for all editable board items */ static const KICAD_T AllBoardItems[]; @@ -354,8 +354,7 @@ public: /** * The examining function within the INSPECTOR which is passed to the Iterate function. * - * Searches and collects all the objects that the old function PcbGeneralLocateAndDisplay() - * would find, except that it keeps all that it finds and does not do any displaying. + * Searches and collects all the objects which match the test data. * * @param testItem An EDA_ITEM to examine. * @param testData is not used in this class. diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 5b8f88f3ef..c8e21c7346 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -99,6 +99,7 @@ static BOARD_ITEM* AllAreModulesAndReturnSmallestIfSo( GENERAL_COLLECTOR* aColle } +// JEY TODO: RETIRE THIS BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) { BOARD_ITEM* item; diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index 07b897380c..fdf79ff3e1 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -544,10 +544,6 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) Compile_Ratsnest( &dc, true ); break; - case ID_PCB_MODULE_BUTT: - SetToolID( id, wxCURSOR_PENCIL, _( "Add footprint" ) ); - break; - case ID_PCB_ZONES_BUTT: SetToolID( id, wxCURSOR_PENCIL, _( "Add zones" ) ); diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 7362b38672..3099c1b9fa 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -285,6 +285,12 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() ); GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); + + // Set up viewport + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); m_auimgr.Update(); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index dd402a745e..c827bc2822 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -233,6 +233,12 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent m_auimgr.Update(); GetGalCanvas()->GetGAL()->SetAxesEnabled( true ); + + // Set up viewport + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( true ); // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.) diff --git a/pcbnew/footprint_wizard_frame.cpp b/pcbnew/footprint_wizard_frame.cpp index e74e941bf9..adb3579516 100644 --- a/pcbnew/footprint_wizard_frame.cpp +++ b/pcbnew/footprint_wizard_frame.cpp @@ -231,6 +231,11 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway, wxWindow* aParent galOpts.m_forceDisplayCursor = true; galOpts.m_axesEnabled = true; + // Set up viewport + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE ); updateView(); diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index 224a4810ae..e997ac8e7c 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -45,6 +45,8 @@ #include #include #include +#include +#include /* How to add a new hotkey: * see hotkeys.cpp @@ -68,11 +70,12 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( aHotkeyCode == 0 ) return false; - bool itemCurrentlyEdited = GetCurItem() && GetCurItem()->GetEditFlags(); - MODULE* module = NULL; - int evt_type = 0; //Used to post a wxCommandEvent on demand + SELECTION& selection = GetToolManager()->GetTool()->GetSelection(); + bool itemCurrentlyEdited = selection.Front() && selection.Front()->GetEditFlags(); + MODULE* module = NULL; + int evt_type = 0; //Used to post a wxCommandEvent on demand PCB_SCREEN* screen = GetScreen(); - auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); + auto displ_opts = (PCB_DISPLAY_OPTIONS*) GetDisplayOptions(); /* Convert lower to upper case * (the usual toupper function has problem with non ascii codes like function keys @@ -253,35 +256,7 @@ bool PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_BACK_SPACE: - if( IsCopperLayer( GetActiveLayer() ) ) - { - if( !itemCurrentlyEdited ) - { - // no track is currently being edited - select a segment and remove it. - // @todo: possibly? pass the HK command code to PcbGeneralLocateAndDisplay() - // so it can restrict its search to specific item types. - BOARD_ITEM * item = PcbGeneralLocateAndDisplay(); - - // don't let backspace delete modules!! - if( item && item->IsTrack() ) - { - Delete_Segment( aDC, (TRACK*) item ); - SetCurItem( NULL ); - } - - OnModify(); - } - else if( GetCurItem()->IsTrack() ) - { - // then an element is being edited - remove the last segment. - // simple lines for debugger: - TRACK* track = (TRACK*) GetCurItem(); - track = Delete_Segment( aDC, track ); - SetCurItem( track ); - OnModify(); - } - } - + m_toolManager->RunAction( ACTIONS::doDelete ); break; case HK_GET_AND_MOVE_FOOTPRINT: diff --git a/pcbnew/muwave_command.cpp b/pcbnew/muwave_command.cpp deleted file mode 100644 index 19b32196bb..0000000000 --- a/pcbnew/muwave_command.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2007-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include -#include -#include -#include -#include - -#include -#include - - -/* Handle microwave commands. - */ -void PCB_EDIT_FRAME::ProcessMuWaveFunctions( wxCommandEvent& event ) -{ - int id = event.GetId(); - wxPoint pos; - INSTALL_UNBUFFERED_DC( dc, m_canvas ); - - wxGetMousePosition( &pos.x, &pos.y ); - - pos.y += 20; - - switch( id ) - { - case ID_PCB_MUWAVE_TOOL_SELF_CMD: - SetToolID( id, wxCURSOR_PENCIL, _( "Add Line" ) ); - break; - - case ID_PCB_MUWAVE_TOOL_GAP_CMD: - SetToolID( id, wxCURSOR_PENCIL, _( "Add Gap" ) ); - break; - - case ID_PCB_MUWAVE_TOOL_STUB_CMD: - SetToolID( id, wxCURSOR_PENCIL, _( "Add Stub" ) ); - break; - - case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: - SetToolID( id, wxCURSOR_PENCIL, _( "Add Arc Stub" ) ); - break; - - case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: - SetToolID( id, wxCURSOR_PENCIL, _( "Add Polynomial Shape" ) ); - break; - - default: - wxLogDebug( wxT( "id %d error" ), id ); - break; - } -} - - -void PCB_EDIT_FRAME::MuWaveCommand( wxDC* DC, const wxPoint& MousePos ) -{ - MODULE* module = NULL; - - switch( GetToolId() ) - { - case ID_PCB_MUWAVE_TOOL_SELF_CMD: - Begin_Self( DC ); - break; - - case ID_PCB_MUWAVE_TOOL_GAP_CMD: - module = Create_MuWaveComponent( 0 ); - break; - - case ID_PCB_MUWAVE_TOOL_STUB_CMD: - module = Create_MuWaveComponent( 1 ); - break; - - case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: - module = Create_MuWaveComponent( 2 ); - break; - - case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: - module = Create_MuWavePolygonShape(); - break; - - default: - m_canvas->SetCursor( wxCURSOR_ARROW ); - wxLogDebug( wxT( "id %d error" ), GetToolId() ); - SetNoToolSelected(); - break; - } - - if( module ) - { - StartMoveModule( module, DC, false ); - } - - m_canvas->MoveCursorToCrossHair(); -} diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 7d06279b25..dadfe36589 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -191,14 +191,6 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) case ID_ZOOM_SELECTION: break; - case ID_PCB_MUWAVE_TOOL_SELF_CMD: - case ID_PCB_MUWAVE_TOOL_GAP_CMD: - case ID_PCB_MUWAVE_TOOL_STUB_CMD: - case ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD: - case ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD: - MuWaveCommand( aDC, aPosition ); - break; - case ID_PCB_HIGHLIGHT_BUTT: { int netcode = SelectHighLight( aDC ); @@ -358,38 +350,6 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) break; - case ID_PCB_MODULE_BUTT: - if( curr_item == NULL || curr_item->GetEditFlags() == 0 ) - { - m_canvas->MoveCursorToCrossHair(); - MODULE* module = SelectFootprintFromLibTree(); - - SetCurItem( (BOARD_ITEM*) module ); - - if( module ) - { - m_canvas->MoveCursorToCrossHair(); - module->SetLink( 0 ); - AddModuleToBoard( module ); - - if( aDC ) - module->Draw( m_canvas, aDC, GR_OR ); - - StartMoveModule( module, aDC, false ); - } - } - else if( curr_item->Type() == PCB_MODULE_T ) - { - PlaceModule( (MODULE*) curr_item, aDC ); - m_canvas->SetAutoPanRequest( false ); - } - else - { - wxLogDebug( wxT( "Internal err: Struct not PCB_MODULE_T" ) ); - } - - break; - case ID_PCB_DIMENSION_BUTT: if( IsCopperLayer( GetActiveLayer() ) || GetActiveLayer() == Edge_Cuts ) { diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index cfa0c31e60..913b23a2fd 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -227,9 +227,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL, PCB_EDIT_FRAME::OnSelectTool ) - EVT_TOOL_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD, - PCB_EDIT_FRAME::ProcessMuWaveFunctions ) - EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE, PCB_EDIT_FRAME::Process_Special_Functions ) @@ -408,6 +405,12 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : } GetGalCanvas()->SwitchBackend( m_canvasType ); + + // Set up viewport + KIGFX::VIEW* view = galCanvas->GetView(); + view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() ); + view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) ); + UseGalCanvas( true ); // disable Export STEP item if kicad2step does not exist diff --git a/pcbnew/pcb_edit_frame.h b/pcbnew/pcb_edit_frame.h index 3bc8974975..a4dfc5f374 100644 --- a/pcbnew/pcb_edit_frame.h +++ b/pcbnew/pcb_edit_frame.h @@ -520,9 +520,6 @@ public: */ void OnEditTracksAndVias( wxCommandEvent& event ); - void ProcessMuWaveFunctions( wxCommandEvent& event ); - void MuWaveCommand( wxDC* DC, const wxPoint& MousePos ); - void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override; void ReCreateHToolbar() override; void ReCreateAuxiliaryToolbar() override;