Fix a bug introduced when UseGalCanvas() no longer switches.
We still need to setup the viewport the first time. Also removes some more legacy editing code.
This commit is contained in:
parent
9d9745b555
commit
718ad77891
|
@ -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__
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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.)
|
||||
|
|
|
@ -452,6 +452,12 @@ void SCH_BASE_FRAME::createCanvas()
|
|||
m_useSingleCanvasPane = true;
|
||||
|
||||
SetGalCanvas( static_cast<SCH_DRAW_PANEL*> (m_canvas) );
|
||||
|
||||
// Set up viewport
|
||||
KIGFX::VIEW* view = GetGalCanvas()->GetView();
|
||||
view->SetScale( GetZoomLevelCoeff() / m_canvas->GetZoom() );
|
||||
view->SetCenter( VECTOR2D( m_canvas->GetScreenCenterLogicalPosition() ) );
|
||||
|
||||
UseGalCanvas( true );
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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" ) );
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.)
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#include <class_zone.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/pcbnew_control.h>
|
||||
#include <tools/selection_tool.h>
|
||||
#include <tool/actions.h>
|
||||
|
||||
/* 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<SELECTION_TOOL>()->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:
|
||||
|
|
|
@ -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 <fctsys.h>
|
||||
#include <class_drawpanel.h>
|
||||
#include <confirm.h>
|
||||
#include <pcbnew.h>
|
||||
#include <pcb_edit_frame.h>
|
||||
|
||||
#include <pcbnew_id.h>
|
||||
#include <kicad_device_context.h>
|
||||
|
||||
|
||||
/* 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();
|
||||
}
|
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue