2011-10-15 13:25:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-17 14:36:04 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2020-12-20 18:23:50 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2023-03-13 16:03:48 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2022-12-05 22:36:44 +00:00
|
|
|
* Copyright (C) 2022 CERN
|
2011-10-15 13:25:57 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-12-21 13:41:05 +00:00
|
|
|
/// @todo The Boost entropy exception does not exist prior to 1.67. Once the minimum Boost
|
|
|
|
/// version is raise to 1.67 or greater, this version check can be removed.
|
|
|
|
#include <boost/version.hpp>
|
|
|
|
|
|
|
|
#if BOOST_VERSION >= 106700
|
2020-12-20 18:23:50 +00:00
|
|
|
#include <boost/uuid/entropy_error.hpp>
|
2020-12-21 13:41:05 +00:00
|
|
|
#endif
|
|
|
|
|
2021-08-05 12:03:59 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer_frame.h> // To include VIEWER3D_FRAMENAME
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <advanced_config.h>
|
|
|
|
#include <base_units.h>
|
|
|
|
#include <board.h>
|
|
|
|
#include <cleanup_item.h>
|
|
|
|
#include <collectors.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <footprint.h>
|
2020-05-06 01:45:48 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <fp_lib_table.h>
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <kiface_base.h>
|
|
|
|
#include <pcb_group.h>
|
|
|
|
#include <pcb_painter.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbnew_id.h>
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <pcbnew_settings.h>
|
|
|
|
#include <pcb_base_frame.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <pgm_base.h>
|
2023-05-31 20:37:58 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <zoom_defines.h>
|
|
|
|
|
2013-03-28 16:30:09 +00:00
|
|
|
#include <math/vector2d.h>
|
2023-02-19 03:40:07 +00:00
|
|
|
#include <math/vector2wx.h>
|
2023-04-07 17:08:43 +00:00
|
|
|
#include <widgets/msgpanel.h>
|
2020-10-02 11:18:16 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2022-07-24 22:40:47 +00:00
|
|
|
#include <settings/cvpcb_settings.h>
|
2013-08-02 14:53:50 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tool/tool_dispatcher.h>
|
2018-07-22 23:53:05 +00:00
|
|
|
#include <tools/pcb_actions.h>
|
2020-06-12 10:58:56 +00:00
|
|
|
#include <tool/grid_menu.h>
|
2022-02-13 13:06:35 +00:00
|
|
|
#include <ratsnest/ratsnest_view_item.h>
|
2020-12-01 19:27:42 +00:00
|
|
|
|
2021-10-25 12:18:48 +00:00
|
|
|
#include <navlib/nl_pcbnew_plugin.h>
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
using KIGFX::RENDER_SETTINGS;
|
|
|
|
using KIGFX::PCB_RENDER_SETTINGS;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
wxDEFINE_EVENT( EDA_EVT_BOARD_CHANGED, wxCommandEvent );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2014-04-19 18:47:20 +00:00
|
|
|
PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
2020-09-30 22:02:05 +00:00
|
|
|
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
|
2021-10-25 12:18:48 +00:00
|
|
|
long aStyle, const wxString& aFrameName ) :
|
2023-03-13 16:03:48 +00:00
|
|
|
EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName,
|
|
|
|
pcbIUScale ),
|
2022-07-24 15:49:46 +00:00
|
|
|
m_pcb( nullptr ),
|
|
|
|
m_originTransforms( *this ),
|
|
|
|
m_spaceMouse( nullptr )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2023-05-31 20:37:58 +00:00
|
|
|
m_watcherDebounceTimer.Bind( wxEVT_TIMER, &PCB_BASE_FRAME::OnFpChangeDebounceTimer, this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
PCB_BASE_FRAME::~PCB_BASE_FRAME()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2023-01-18 01:30:40 +00:00
|
|
|
delete m_spaceMouse;
|
2023-04-07 17:08:43 +00:00
|
|
|
m_spaceMouse = nullptr;
|
2021-10-25 12:18:48 +00:00
|
|
|
|
2019-01-11 12:19:46 +00:00
|
|
|
// Ensure m_canvasType is up to date, to save it in config
|
2019-06-13 17:28:55 +00:00
|
|
|
m_canvasType = GetCanvas()->GetBackend();
|
2019-01-11 12:19:46 +00:00
|
|
|
|
2020-09-30 22:02:05 +00:00
|
|
|
delete m_pcb;
|
2023-01-18 01:30:40 +00:00
|
|
|
m_pcb = nullptr;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-17 11:21:06 +00:00
|
|
|
bool PCB_BASE_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Close modeless dialogs. They're trouble when they get destroyed after the frame and/or
|
|
|
|
// board.
|
|
|
|
wxWindow* viewer3D = Get3DViewerFrame();
|
|
|
|
|
|
|
|
if( viewer3D )
|
|
|
|
viewer3D->Close( true );
|
|
|
|
|
2022-12-05 22:36:44 +00:00
|
|
|
// Similarly, wxConvBrokenFileNames uses some statically allocated variables that make it
|
|
|
|
// crash when run later from a d'tor.
|
|
|
|
Prj().Cleanup3DCache();
|
|
|
|
|
2021-06-17 11:21:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-25 12:18:48 +00:00
|
|
|
void PCB_BASE_FRAME::handleActivateEvent( wxActivateEvent& aEvent )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::handleActivateEvent( aEvent );
|
|
|
|
|
2023-06-13 16:44:22 +00:00
|
|
|
if( m_spaceMouse )
|
2021-10-25 12:18:48 +00:00
|
|
|
m_spaceMouse->SetFocus( aEvent.GetActive() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-03-31 19:03:41 +00:00
|
|
|
void PCB_BASE_FRAME::handleIconizeEvent( wxIconizeEvent& aEvent )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::handleIconizeEvent( aEvent );
|
|
|
|
|
2023-06-13 16:44:22 +00:00
|
|
|
if( m_spaceMouse != nullptr && aEvent.IsIconized() )
|
2022-03-31 19:03:41 +00:00
|
|
|
m_spaceMouse->SetFocus( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* PCB_BASE_FRAME::Get3DViewerFrame()
|
2015-12-21 11:52:00 +00:00
|
|
|
{
|
2021-06-19 17:28:45 +00:00
|
|
|
wxWindow* frame = FindWindowByName( QUALIFIED_VIEWER3D_FRAMENAME( this ) );
|
|
|
|
return dynamic_cast<EDA_3D_VIEWER_FRAME*>( frame );
|
2015-12-21 11:52:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-09 02:09:06 +00:00
|
|
|
void PCB_BASE_FRAME::Update3DView( bool aMarkDirty, bool aRefresh, const wxString* aTitle )
|
2018-05-10 10:49:20 +00:00
|
|
|
{
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
|
2018-05-10 10:49:20 +00:00
|
|
|
|
2019-06-04 10:28:05 +00:00
|
|
|
if( draw3DFrame )
|
|
|
|
{
|
|
|
|
if( aTitle )
|
|
|
|
draw3DFrame->SetTitle( *aTitle );
|
2018-05-10 10:49:20 +00:00
|
|
|
|
2021-04-09 02:09:06 +00:00
|
|
|
if( aMarkDirty )
|
2020-11-29 20:03:05 +00:00
|
|
|
draw3DFrame->ReloadRequest();
|
2018-05-10 10:49:20 +00:00
|
|
|
|
2021-04-09 02:09:06 +00:00
|
|
|
if( aRefresh )
|
|
|
|
draw3DFrame->Redraw();
|
2020-09-02 16:54:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
FP_LIB_TABLE* PROJECT::PcbFootprintLibs()
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
// This is a lazy loading function, it loads the project specific table when
|
|
|
|
// that table is asked for, not before.
|
|
|
|
|
|
|
|
FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL );
|
|
|
|
|
|
|
|
// its gotta be NULL or a FP_LIB_TABLE, or a bug.
|
2018-09-15 11:05:54 +00:00
|
|
|
wxASSERT( !tbl || tbl->Type() == FP_LIB_TABLE_T );
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
if( !tbl )
|
|
|
|
{
|
2014-03-21 01:24:35 +00:00
|
|
|
// Stack the project specific FP_LIB_TABLE overlay on top of the global table.
|
|
|
|
// ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may
|
|
|
|
// stack this way, all using the same global fallback table.
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
tbl = new FP_LIB_TABLE( &GFootprintTable );
|
2014-03-21 01:24:35 +00:00
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
SetElem( ELEM_FPTBL, tbl );
|
|
|
|
|
|
|
|
wxString projectFpLibTableFileName = FootprintLibTblName();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
tbl->Load( projectFpLibTableFileName );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
2021-06-26 11:33:37 +00:00
|
|
|
DisplayErrorMessage( nullptr, _( "Error loading project footprint libraries." ),
|
2017-07-20 14:06:41 +00:00
|
|
|
ioe.What() );
|
2014-05-09 18:35:48 +00:00
|
|
|
}
|
2021-06-29 11:45:02 +00:00
|
|
|
catch( ... )
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
DisplayErrorMessage( nullptr, _( "Error loading project footprint library table." ) );
|
2021-06-29 11:45:02 +00:00
|
|
|
}
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-25 16:19:03 +00:00
|
|
|
void PCB_BASE_FRAME::SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
if( m_pcb != aBoard )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
delete m_pcb;
|
|
|
|
m_pcb = aBoard;
|
2020-04-13 01:27:47 +00:00
|
|
|
|
2023-03-05 13:27:22 +00:00
|
|
|
if( GetBoard() )
|
|
|
|
GetBoard()->SetUserUnits( GetUserUnits() );
|
|
|
|
|
2021-08-25 23:14:36 +00:00
|
|
|
if( GetBoard() && GetCanvas() )
|
|
|
|
{
|
|
|
|
RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
|
|
|
|
|
|
|
|
if( rs )
|
|
|
|
{
|
|
|
|
rs->SetDashLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineDashRatio() );
|
|
|
|
rs->SetGapLengthRatio( GetBoard()->GetPlotOptions().GetDashedLineGapRatio() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
wxCommandEvent e( EDA_EVT_BOARD_CHANGED );
|
2020-04-13 01:27:47 +00:00
|
|
|
ProcessEventLocally( e );
|
2023-03-13 16:03:48 +00:00
|
|
|
|
|
|
|
for( wxEvtHandler* listener : m_boardChangeListeners )
|
|
|
|
{
|
|
|
|
wxCHECK2( listener, continue );
|
|
|
|
|
2023-03-13 17:59:01 +00:00
|
|
|
// Use the windows variant when handling event messages in case there is any special
|
|
|
|
// event handler pre and/or post processing specific to windows.
|
2023-03-13 16:03:48 +00:00
|
|
|
wxWindow* win = dynamic_cast<wxWindow*>( listener );
|
|
|
|
|
|
|
|
if( win )
|
|
|
|
win->HandleWindowEvent( e );
|
|
|
|
else
|
|
|
|
listener->SafelyProcessEvent( e );
|
|
|
|
}
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
void PCB_BASE_FRAME::AddBoardChangeListener( wxEvtHandler* aListener )
|
|
|
|
{
|
|
|
|
auto it = std::find( m_boardChangeListeners.begin(), m_boardChangeListeners.end(), aListener );
|
|
|
|
|
|
|
|
// Don't add duplicate listeners.
|
|
|
|
if( it == m_boardChangeListeners.end() )
|
|
|
|
m_boardChangeListeners.push_back( aListener );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::RemoveBoardChangeListener( wxEvtHandler* aListener )
|
|
|
|
{
|
|
|
|
auto it = std::find( m_boardChangeListeners.begin(), m_boardChangeListeners.end(), aListener );
|
|
|
|
|
|
|
|
// Don't add duplicate listeners.
|
|
|
|
if( it != m_boardChangeListeners.end() )
|
|
|
|
m_boardChangeListeners.erase( it );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
void PCB_BASE_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint )
|
2018-09-25 14:23:38 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
if( aFootprint )
|
2018-09-25 14:23:38 +00:00
|
|
|
{
|
2020-11-13 02:57:11 +00:00
|
|
|
GetBoard()->Add( aFootprint, ADD_MODE::APPEND );
|
2018-09-25 14:23:38 +00:00
|
|
|
|
2021-01-26 14:55:38 +00:00
|
|
|
aFootprint->SetFlags( IS_NEW );
|
2023-02-19 03:40:07 +00:00
|
|
|
aFootprint->SetPosition( VECTOR2I( 0, 0 ) ); // cursor in GAL may not be initialized yet
|
2018-09-25 14:23:38 +00:00
|
|
|
|
2019-09-05 15:24:51 +00:00
|
|
|
// Put it on FRONT layer (note that it might be stored flipped if the lib is an archive
|
|
|
|
// built from a board)
|
2020-11-13 02:57:11 +00:00
|
|
|
if( aFootprint->IsFlipped() )
|
2022-07-24 15:49:46 +00:00
|
|
|
aFootprint->Flip( aFootprint->GetPosition(), GetPcbNewSettings()->m_FlipLeftRight );
|
2018-09-25 14:23:38 +00:00
|
|
|
|
2019-09-05 15:24:51 +00:00
|
|
|
// Place it in orientation 0 even if it is not saved with orientation 0 in lib (note that
|
|
|
|
// it might be stored in another orientation if the lib is an archive built from a board)
|
2022-01-13 17:27:36 +00:00
|
|
|
aFootprint->SetOrientation( ANGLE_0 );
|
2023-01-02 12:39:07 +00:00
|
|
|
|
2023-03-13 20:25:27 +00:00
|
|
|
GetBoard()->UpdateUserUnits( aFootprint, GetCanvas()->GetView() );
|
2023-01-02 19:49:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
EDA_ITEM* PCB_BASE_FRAME::GetItem( const KIID& aId ) const
|
2020-04-24 13:36:10 +00:00
|
|
|
{
|
|
|
|
return GetBoard()->GetItem( aId );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-25 14:31:19 +00:00
|
|
|
void PCB_BASE_FRAME::FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer )
|
2020-02-24 17:18:23 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
std::vector<BOARD_ITEM*> items;
|
2020-02-24 17:18:23 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
if( aItem )
|
|
|
|
items.push_back( aItem );
|
2020-12-20 18:23:50 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
FocusOnItems( items, aLayer );
|
|
|
|
}
|
2020-02-24 17:18:23 +00:00
|
|
|
|
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID aLayer )
|
|
|
|
{
|
|
|
|
static std::vector<KIID> lastBrightenedItemIDs;
|
|
|
|
|
|
|
|
BOARD_ITEM* lastItem = nullptr;
|
|
|
|
|
|
|
|
for( KIID lastBrightenedItemID : lastBrightenedItemIDs )
|
|
|
|
{
|
|
|
|
/// @todo The Boost entropy exception does not exist prior to 1.67. Once the minimum Boost
|
|
|
|
/// version is raise to 1.67 or greater, this version check can be removed.
|
|
|
|
#if BOOST_VERSION >= 106700
|
|
|
|
try
|
2020-02-24 17:18:23 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
lastItem = GetBoard()->GetItem( lastBrightenedItemID );
|
2020-02-24 17:18:23 +00:00
|
|
|
}
|
2022-04-08 10:37:27 +00:00
|
|
|
catch( const boost::uuids::entropy_error& )
|
2020-08-11 19:37:07 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
wxLogError( wxT( "A Boost UUID entropy exception was thrown in %s:%s." ),
|
|
|
|
__FILE__, __FUNCTION__ );
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
2022-04-08 10:37:27 +00:00
|
|
|
#else
|
|
|
|
lastItem = GetBoard()->GetItem( lastBrightenedItemID );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( lastItem && lastItem != DELETED_BOARD_ITEM::GetInstance() )
|
|
|
|
{
|
|
|
|
lastItem->ClearBrightened();
|
|
|
|
|
|
|
|
if( lastItem->Type() == PCB_FOOTPRINT_T )
|
|
|
|
{
|
|
|
|
static_cast<FOOTPRINT*>( lastItem )->RunOnChildren(
|
|
|
|
[&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
child->ClearBrightened();
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
else if( lastItem->Type() == PCB_GROUP_T )
|
|
|
|
{
|
|
|
|
static_cast<PCB_GROUP*>( lastItem )->RunOnChildren(
|
|
|
|
[&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
child->ClearBrightened();
|
|
|
|
} );
|
|
|
|
}
|
2020-02-24 17:18:23 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
GetCanvas()->GetView()->Update( lastItem );
|
|
|
|
lastBrightenedItemID = niluuid;
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
}
|
2020-02-24 17:18:23 +00:00
|
|
|
}
|
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
lastBrightenedItemIDs.clear();
|
|
|
|
|
|
|
|
if( aItems.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
VECTOR2I focusPt;
|
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
|
|
|
SHAPE_POLY_SET viewportPoly( view->GetViewport() );
|
|
|
|
|
|
|
|
for( wxWindow* dialog : findDialogs() )
|
2020-02-24 17:18:23 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
wxPoint dialogPos = GetCanvas()->ScreenToClient( dialog->GetScreenPosition() );
|
2023-02-19 03:40:07 +00:00
|
|
|
SHAPE_POLY_SET dialogPoly( BOX2D( view->ToWorld( ToVECTOR2D( dialogPos ), true ),
|
|
|
|
view->ToWorld( ToVECTOR2D( dialog->GetSize() ), false ) ) );
|
2020-02-24 17:18:23 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
try
|
2020-02-24 17:18:23 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
|
2020-02-24 17:18:23 +00:00
|
|
|
}
|
2023-06-03 11:28:03 +00:00
|
|
|
catch( const std::exception& exc )
|
2020-08-11 19:37:07 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
// This may be overkill and could be an assertion but we are more likely to
|
|
|
|
// find any clipper errors this way.
|
|
|
|
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
|
2020-08-11 19:37:07 +00:00
|
|
|
}
|
2022-04-08 10:37:27 +00:00
|
|
|
}
|
2020-02-24 17:18:23 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
SHAPE_POLY_SET itemPoly, clippedPoly;
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
for( BOARD_ITEM* item : aItems )
|
|
|
|
{
|
|
|
|
if( item && item != DELETED_BOARD_ITEM::GetInstance() )
|
2021-09-25 14:31:19 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
item->SetBrightened();
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
if( item->Type() == PCB_FOOTPRINT_T )
|
2021-11-13 16:38:19 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
static_cast<FOOTPRINT*>( item )->RunOnChildren(
|
|
|
|
[&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
child->SetBrightened();
|
|
|
|
});
|
2021-11-13 16:38:19 +00:00
|
|
|
}
|
2022-04-08 10:37:27 +00:00
|
|
|
else if( item->Type() == PCB_GROUP_T )
|
2021-11-13 16:38:19 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
static_cast<PCB_GROUP*>( item )->RunOnChildren(
|
|
|
|
[&]( BOARD_ITEM* child )
|
|
|
|
{
|
|
|
|
child->SetBrightened();
|
|
|
|
});
|
2021-11-13 16:38:19 +00:00
|
|
|
}
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
GetCanvas()->GetView()->Update( item );
|
|
|
|
lastBrightenedItemIDs.push_back( item->m_Uuid );
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
// Focus on the object's location. Prefer a visible part of the object to its anchor
|
|
|
|
// in order to keep from scrolling around.
|
|
|
|
|
|
|
|
focusPt = item->GetPosition();
|
|
|
|
|
|
|
|
if( aLayer == UNDEFINED_LAYER )
|
|
|
|
aLayer = item->GetLayerSet().Seq()[0];
|
|
|
|
|
|
|
|
switch( item->Type() )
|
|
|
|
{
|
|
|
|
case PCB_FOOTPRINT_T:
|
|
|
|
try
|
|
|
|
{
|
|
|
|
itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
|
|
|
|
}
|
2023-06-03 11:28:03 +00:00
|
|
|
catch( const std::exception& exc )
|
2022-04-08 10:37:27 +00:00
|
|
|
{
|
|
|
|
// This may be overkill and could be an assertion but we are more likely to
|
|
|
|
// find any clipper errors this way.
|
|
|
|
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_PAD_T:
|
|
|
|
case PCB_MARKER_T:
|
|
|
|
case PCB_VIA_T:
|
|
|
|
FocusOnLocation( item->GetFocusPosition() );
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
return;
|
|
|
|
|
|
|
|
case PCB_SHAPE_T:
|
2023-06-06 15:09:34 +00:00
|
|
|
case PCB_FIELD_T:
|
2022-04-08 10:37:27 +00:00
|
|
|
case PCB_TEXT_T:
|
|
|
|
case PCB_TEXTBOX_T:
|
|
|
|
case PCB_TRACE_T:
|
|
|
|
case PCB_ARC_T:
|
|
|
|
case PCB_DIM_ALIGNED_T:
|
|
|
|
case PCB_DIM_LEADER_T:
|
|
|
|
case PCB_DIM_CENTER_T:
|
|
|
|
case PCB_DIM_RADIAL_T:
|
|
|
|
case PCB_DIM_ORTHOGONAL_T:
|
2022-10-21 12:48:45 +00:00
|
|
|
item->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
|
|
|
|
ERROR_INSIDE );
|
2022-04-08 10:37:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCB_ZONE_T:
|
|
|
|
{
|
|
|
|
ZONE* zone = static_cast<ZONE*>( item );
|
|
|
|
#if 0
|
|
|
|
// Using the filled area shapes to find a Focus point can give good results, but
|
|
|
|
// unfortunately the calculations are highly time consuming, even for not very
|
|
|
|
// large areas (can be easily a few minutes for large areas).
|
|
|
|
// so we used only the zone outline that usually do not have too many vertices.
|
2022-10-21 12:48:45 +00:00
|
|
|
zone->TransformShapeToPolygon( itemPoly, aLayer, 0, pcbIUScale.mmToIU( 0.1 ),
|
|
|
|
ERROR_INSIDE );
|
2022-04-08 10:37:27 +00:00
|
|
|
|
|
|
|
if( itemPoly.IsEmpty() )
|
|
|
|
itemPoly = *zone->Outline();
|
|
|
|
#else
|
|
|
|
// much faster calculation time when using only the zone outlines
|
|
|
|
itemPoly = *zone->Outline();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
BOX2I item_bbox = item->GetBoundingBox();
|
|
|
|
itemPoly.NewOutline();
|
|
|
|
itemPoly.Append( item_bbox.GetOrigin() );
|
|
|
|
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(), 0 ) );
|
|
|
|
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( 0, item_bbox.GetHeight() ) );
|
|
|
|
itemPoly.Append( item_bbox.GetOrigin() + VECTOR2I( item_bbox.GetWidth(),
|
|
|
|
item_bbox.GetHeight() ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2021-11-15 19:02:28 +00:00
|
|
|
try
|
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
clippedPoly.BooleanIntersection( itemPoly, viewportPoly, SHAPE_POLY_SET::PM_FAST );
|
2021-11-15 19:02:28 +00:00
|
|
|
}
|
2023-06-03 11:28:03 +00:00
|
|
|
catch( const std::exception& exc )
|
2021-11-15 19:02:28 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
// This may be overkill and could be an assertion but we are more likely to
|
|
|
|
// find any clipper errors this way.
|
2021-11-15 19:02:28 +00:00
|
|
|
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
|
|
|
|
}
|
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
if( !clippedPoly.IsEmpty() )
|
|
|
|
itemPoly = clippedPoly;
|
|
|
|
}
|
|
|
|
}
|
2021-09-29 23:18:33 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
/*
|
|
|
|
* Perform a step-wise deflate to find the visual-center-of-mass
|
|
|
|
*/
|
2022-01-10 17:14:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
BOX2I bbox = itemPoly.BBox();
|
|
|
|
int step = std::min( bbox.GetWidth(), bbox.GetHeight() ) / 10;
|
2022-01-10 17:14:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
while( !itemPoly.IsEmpty() )
|
|
|
|
{
|
2022-08-30 14:13:51 +00:00
|
|
|
focusPt = itemPoly.BBox().Centre();
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2021-11-17 17:28:23 +00:00
|
|
|
try
|
|
|
|
{
|
2023-05-29 15:22:06 +00:00
|
|
|
itemPoly.Deflate( step, SHAPE_POLY_SET::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
|
2021-11-17 17:28:23 +00:00
|
|
|
}
|
2023-06-03 11:28:03 +00:00
|
|
|
catch( const std::exception& exc )
|
2021-11-17 17:28:23 +00:00
|
|
|
{
|
2022-04-08 10:37:27 +00:00
|
|
|
// This may be overkill and could be an assertion but we are more likely to
|
|
|
|
// find any clipper errors this way.
|
2021-11-17 17:28:23 +00:00
|
|
|
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
|
|
|
|
}
|
2022-04-08 10:37:27 +00:00
|
|
|
}
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
FocusOnLocation( focusPt );
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-04-08 10:37:27 +00:00
|
|
|
GetCanvas()->Refresh();
|
2020-02-24 17:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-12 16:58:30 +00:00
|
|
|
void PCB_BASE_FRAME::HideSolderMask()
|
|
|
|
{
|
|
|
|
KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
|
|
|
|
|
|
|
|
if( view && GetBoard()->m_SolderMask && view->HasItem( GetBoard()->m_SolderMask ) )
|
|
|
|
view->Remove( GetBoard()->m_SolderMask );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::ShowSolderMask()
|
|
|
|
{
|
|
|
|
KIGFX::PCB_VIEW* view = GetCanvas()->GetView();
|
|
|
|
|
|
|
|
if( view && GetBoard()->m_SolderMask )
|
|
|
|
{
|
|
|
|
if( view->HasItem( GetBoard()->m_SolderMask ) )
|
|
|
|
view->Remove( GetBoard()->m_SolderMask );
|
|
|
|
|
|
|
|
view->Add( GetBoard()->m_SolderMask );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
void PCB_BASE_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
m_pcb->SetPageSettings( aPageSettings );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
|
|
|
if( GetScreen() )
|
2022-09-16 23:25:07 +00:00
|
|
|
GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( pcbIUScale.IU_PER_MILS ) );
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PAGE_INFO& PCB_BASE_FRAME::GetPageSettings() const
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
return m_pcb->GetPageSettings();
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
const VECTOR2I PCB_BASE_FRAME::GetPageSizeIU() const
|
2011-12-22 21:57:50 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
// this function is only needed because EDA_DRAW_FRAME is not compiled
|
|
|
|
// with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
|
|
|
|
// into an application specific source file.
|
2022-09-16 23:25:07 +00:00
|
|
|
return m_pcb->GetPageSettings().GetSizeIU( pcbIUScale.IU_PER_MILS );
|
2011-12-31 05:44:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
const VECTOR2I& PCB_BASE_FRAME::GetGridOrigin() const
|
2013-08-03 05:15:23 +00:00
|
|
|
{
|
2021-11-09 03:36:40 +00:00
|
|
|
return m_pcb->GetDesignSettings().GetGridOrigin();
|
2013-08-03 05:15:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
void PCB_BASE_FRAME::SetGridOrigin( const VECTOR2I& aPoint )
|
2013-08-03 05:15:23 +00:00
|
|
|
{
|
2021-11-09 03:36:40 +00:00
|
|
|
m_pcb->GetDesignSettings().SetGridOrigin( aPoint );
|
2011-12-22 21:57:50 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
const VECTOR2I& PCB_BASE_FRAME::GetAuxOrigin() const
|
2020-07-05 01:59:29 +00:00
|
|
|
{
|
2021-11-09 03:36:40 +00:00
|
|
|
return m_pcb->GetDesignSettings().GetAuxOrigin();
|
2020-07-05 01:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-29 21:30:11 +00:00
|
|
|
const VECTOR2I PCB_BASE_FRAME::GetUserOrigin() const
|
2020-07-05 01:59:29 +00:00
|
|
|
{
|
2021-12-29 21:30:11 +00:00
|
|
|
VECTOR2I origin( 0, 0 );
|
2020-07-05 01:59:29 +00:00
|
|
|
|
2022-07-24 15:49:46 +00:00
|
|
|
switch( GetPcbNewSettings()->m_Display.m_DisplayOrigin )
|
2020-07-05 01:59:29 +00:00
|
|
|
{
|
2021-12-26 00:36:12 +00:00
|
|
|
case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_PAGE: break;
|
|
|
|
case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_AUX: origin = GetAuxOrigin(); break;
|
|
|
|
case PCB_DISPLAY_ORIGIN::PCB_ORIGIN_GRID: origin = GetGridOrigin(); break;
|
|
|
|
default: wxASSERT( false ); break;
|
2020-07-05 01:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return origin;
|
|
|
|
}
|
|
|
|
|
|
|
|
ORIGIN_TRANSFORMS& PCB_BASE_FRAME::GetOriginTransforms()
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
return m_originTransforms;
|
2020-07-05 01:59:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
const TITLE_BLOCK& PCB_BASE_FRAME::GetTitleBlock() const
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
return m_pcb->GetTitleBlock();
|
2012-01-09 08:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
m_pcb->SetTitleBlock( aTitleBlock );
|
2012-01-09 08:35:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& PCB_BASE_FRAME::GetDesignSettings() const
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
return m_pcb->GetDesignSettings();
|
2012-02-02 17:45:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void PCB_BASE_FRAME::SetDrawBgColor( const COLOR4D& aColor )
|
2018-08-11 16:04:46 +00:00
|
|
|
{
|
|
|
|
m_drawBgColor= aColor;
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-06 05:44:19 +00:00
|
|
|
const ZONE_SETTINGS& PCB_BASE_FRAME::GetZoneSettings() const
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
return m_pcb->GetDesignSettings().GetDefaultZoneSettings();
|
2012-02-06 05:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::SetZoneSettings( const ZONE_SETTINGS& aSettings )
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
m_pcb->GetDesignSettings().SetDefaultZoneSettings( aSettings );
|
2012-02-06 05:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
const PCB_PLOT_PARAMS& PCB_BASE_FRAME::GetPlotSettings() const
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
return m_pcb->GetPlotOptions();
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::SetPlotSettings( const PCB_PLOT_PARAMS& aSettings )
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
m_pcb->SetPlotOptions( aSettings );
|
2012-04-05 18:27:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
{
|
2022-08-30 23:28:18 +00:00
|
|
|
BOX2I area = aBoardEdgesOnly ? m_pcb->GetBoardEdgesBoundingBox() : m_pcb->GetBoundingBox();
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
|
|
|
if( area.GetWidth() == 0 && area.GetHeight() == 0 )
|
|
|
|
{
|
2023-02-19 03:40:07 +00:00
|
|
|
VECTOR2I pageSize = GetPageSizeIU();
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2011-12-14 20:03:15 +00:00
|
|
|
if( m_showBorderAndTitleBlock )
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
{
|
|
|
|
area.SetOrigin( 0, 0 );
|
2011-12-22 21:57:50 +00:00
|
|
|
area.SetEnd( pageSize.x, pageSize.y );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-12-22 21:57:50 +00:00
|
|
|
area.SetOrigin( -pageSize.x / 2, -pageSize.y / 2 );
|
|
|
|
area.SetEnd( pageSize.x / 2, pageSize.y / 2 );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return area;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 16:16:48 +00:00
|
|
|
// Virtual function
|
2022-12-16 21:37:32 +00:00
|
|
|
void PCB_BASE_FRAME::doReCreateMenuBar()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-03 22:55:13 +00:00
|
|
|
void PCB_BASE_FRAME::ShowChangedLanguage()
|
|
|
|
{
|
|
|
|
// call my base class
|
|
|
|
EDA_DRAW_FRAME::ShowChangedLanguage();
|
|
|
|
|
|
|
|
// tooltips in toolbars
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2023-08-23 13:04:31 +00:00
|
|
|
|
|
|
|
EDA_3D_VIEWER_FRAME* viewer3D = Get3DViewerFrame();
|
|
|
|
|
|
|
|
if( viewer3D )
|
|
|
|
viewer3D->ShowChangedLanguage();
|
2018-02-03 22:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* PCB_BASE_FRAME::CreateAndShow3D_Frame()
|
2018-05-10 10:49:20 +00:00
|
|
|
{
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* draw3DFrame = Get3DViewerFrame();
|
2018-05-10 10:49:20 +00:00
|
|
|
|
|
|
|
if( !draw3DFrame )
|
2021-06-19 17:28:45 +00:00
|
|
|
draw3DFrame = new EDA_3D_VIEWER_FRAME( &Kiway(), this, _( "3D Viewer" ) );
|
2018-05-10 10:49:20 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
// Raising the window does not show the window on Windows if iconized. This should work
|
|
|
|
// on any platform.
|
2018-05-10 10:49:20 +00:00
|
|
|
if( draw3DFrame->IsIconized() )
|
|
|
|
draw3DFrame->Iconize( false );
|
|
|
|
|
|
|
|
draw3DFrame->Raise();
|
2019-06-02 14:34:19 +00:00
|
|
|
draw3DFrame->Show( true );
|
2018-05-10 10:49:20 +00:00
|
|
|
|
|
|
|
// Raising the window does not set the focus on Linux. This should work on any platform.
|
|
|
|
if( wxWindow::FindFocus() != draw3DFrame )
|
|
|
|
draw3DFrame->SetFocus();
|
|
|
|
|
2021-07-18 15:44:54 +00:00
|
|
|
// Allocate a slice of time to display the 3D frame
|
2021-07-19 08:10:25 +00:00
|
|
|
// a call to wxSafeYield() should be enough (and better), but on Linux we need
|
|
|
|
// to call wxYield()
|
|
|
|
// otherwise the activity messages are not displayed during the first board loading
|
|
|
|
wxYield();
|
|
|
|
|
|
|
|
// Note, the caller is responsible to load/update the board 3D view.
|
|
|
|
// after frame creation the board is not automatically created.
|
2021-07-18 15:44:54 +00:00
|
|
|
|
2019-06-02 14:34:19 +00:00
|
|
|
return draw3DFrame;
|
2018-05-10 10:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-12-09 18:14:11 +00:00
|
|
|
void PCB_BASE_FRAME::SwitchLayer( PCB_LAYER_ID layer )
|
2007-06-15 12:04:24 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID preslayer = GetActiveLayer();
|
2019-11-07 14:23:09 +00:00
|
|
|
auto& displ_opts = GetDisplayOptions();
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2007-10-10 21:35:41 +00:00
|
|
|
// Check if the specified layer matches the present layer
|
|
|
|
if( layer == preslayer )
|
2007-09-05 04:48:47 +00:00
|
|
|
return;
|
2007-10-07 18:24:15 +00:00
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
// Copper layers cannot be selected unconditionally; how many of those layers are
|
|
|
|
// currently enabled needs to be checked.
|
2013-04-09 16:00:46 +00:00
|
|
|
if( IsCopperLayer( layer ) )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
2019-05-28 23:23:58 +00:00
|
|
|
// If only one copper layer is enabled, the only such layer that can be selected to
|
|
|
|
// is the "Copper" layer (so the selection of any other copper layer is disregarded).
|
2020-09-30 22:02:05 +00:00
|
|
|
if( m_pcb->GetCopperLayerCount() < 2 )
|
2007-10-10 21:35:41 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( layer != B_Cu )
|
2007-10-10 21:35:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
// If more than one copper layer is enabled, the "Copper" and "Component" layers
|
|
|
|
// can be selected, but the total number of copper layers determines which internal
|
2007-10-10 21:35:41 +00:00
|
|
|
// layers are also capable of being selected.
|
|
|
|
else
|
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
if( layer != B_Cu && layer != F_Cu && layer >= ( m_pcb->GetCopperLayerCount() - 1 ) )
|
2007-10-10 21:35:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-28 23:23:58 +00:00
|
|
|
// Is yet more checking required? E.g. when the layer to be selected is a non-copper
|
|
|
|
// layer, or when switching between a copper layer and a non-copper layer, or vice-versa?
|
2007-10-10 21:35:41 +00:00
|
|
|
// ...
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2019-08-28 04:27:39 +00:00
|
|
|
SetActiveLayer( layer );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
2020-07-11 17:40:23 +00:00
|
|
|
if( displ_opts.m_ContrastModeDisplay != HIGH_CONTRAST_MODE::NORMAL )
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2007-06-15 12:04:24 +00:00
|
|
|
}
|
|
|
|
|
2007-09-12 02:14:07 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE PCB_BASE_FRAME::GetCollectorsGuide()
|
2007-09-05 04:48:47 +00:00
|
|
|
{
|
2020-09-30 22:02:05 +00:00
|
|
|
GENERAL_COLLECTORS_GUIDE guide( m_pcb->GetVisibleLayers(), GetActiveLayer(),
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView() );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
// account for the globals
|
2023-08-04 10:13:20 +00:00
|
|
|
guide.SetIgnoreMTextsMarkedNoShow( ! m_pcb->IsElementVisible( LAYER_HIDDEN_TEXT ) );
|
|
|
|
guide.SetIgnoreMTextsOnBack( ! m_pcb->IsElementVisible( LAYER_FP_TEXT ) );
|
|
|
|
guide.SetIgnoreMTextsOnFront( ! m_pcb->IsElementVisible( LAYER_FP_TEXT ) );
|
|
|
|
guide.SetIgnoreModulesOnBack( ! m_pcb->IsElementVisible( LAYER_FOOTPRINTS_BK ) );
|
|
|
|
guide.SetIgnoreModulesOnFront( ! m_pcb->IsElementVisible( LAYER_FOOTPRINTS_FR ) );
|
|
|
|
guide.SetIgnorePadsOnBack( ! m_pcb->IsElementVisible( LAYER_PADS_SMD_BK ) );
|
|
|
|
guide.SetIgnorePadsOnFront( ! m_pcb->IsElementVisible( LAYER_PADS_SMD_FR ) );
|
2020-09-30 22:02:05 +00:00
|
|
|
guide.SetIgnoreThroughHolePads( ! m_pcb->IsElementVisible( LAYER_PADS_TH ) );
|
2023-08-04 10:13:20 +00:00
|
|
|
guide.SetIgnoreModulesVals( ! m_pcb->IsElementVisible( LAYER_FP_VALUES ) );
|
|
|
|
guide.SetIgnoreModulesRefs( ! m_pcb->IsElementVisible( LAYER_FP_REFERENCES ) );
|
2020-09-30 22:02:05 +00:00
|
|
|
guide.SetIgnoreThroughVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
|
|
|
|
guide.SetIgnoreBlindBuriedVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
|
|
|
|
guide.SetIgnoreMicroVias( ! m_pcb->IsElementVisible( LAYER_VIAS ) );
|
|
|
|
guide.SetIgnoreTracks( ! m_pcb->IsElementVisible( LAYER_TRACKS ) );
|
2007-09-05 04:48:47 +00:00
|
|
|
|
|
|
|
return guide;
|
|
|
|
}
|
2008-12-19 13:51:48 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::UpdateStatusBar()
|
2008-12-19 13:51:48 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
EDA_DRAW_FRAME::UpdateStatusBar();
|
|
|
|
|
|
|
|
BASE_SCREEN* screen = GetScreen();
|
2012-04-13 18:51:24 +00:00
|
|
|
|
|
|
|
if( !screen )
|
|
|
|
return;
|
2011-02-05 02:21:11 +00:00
|
|
|
|
2012-04-13 18:51:24 +00:00
|
|
|
wxString line;
|
2019-06-13 17:28:55 +00:00
|
|
|
VECTOR2D cursorPos = GetCanvas()->GetViewControls()->GetCursorPosition();
|
2015-01-06 07:38:58 +00:00
|
|
|
|
2019-05-17 11:52:38 +00:00
|
|
|
if( GetShowPolarCoords() ) // display polar coordinates
|
2012-04-13 18:51:24 +00:00
|
|
|
{
|
2019-06-13 13:34:38 +00:00
|
|
|
double dx = cursorPos.x - screen->m_LocalOrigin.x;
|
|
|
|
double dy = cursorPos.y - screen->m_LocalOrigin.y;
|
|
|
|
double theta = RAD2DEG( atan2( -dy, dx ) );
|
|
|
|
double ro = hypot( dx, dy );
|
2010-07-12 14:07:09 +00:00
|
|
|
|
2020-12-17 10:21:24 +00:00
|
|
|
line.Printf( wxT( "r %s theta %.3f" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( ro, false ),
|
|
|
|
theta );
|
2009-04-09 18:16:16 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
SetStatusText( line, 3 );
|
2008-12-19 13:51:48 +00:00
|
|
|
}
|
2012-04-13 18:51:24 +00:00
|
|
|
|
2020-07-05 01:59:29 +00:00
|
|
|
// Transform absolute coordinates for user origin preferences
|
2020-09-30 22:02:05 +00:00
|
|
|
double userXpos = m_originTransforms.ToDisplayAbsX( static_cast<double>( cursorPos.x ) );
|
|
|
|
double userYpos = m_originTransforms.ToDisplayAbsY( static_cast<double>( cursorPos.y ) );
|
2020-07-05 01:59:29 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
// Display absolute coordinates:
|
2020-10-06 10:47:01 +00:00
|
|
|
line.Printf( wxT( "X %s Y %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( userXpos, false ),
|
|
|
|
MessageTextFromValue( userYpos, false ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
SetStatusText( line, 2 );
|
2012-04-13 18:51:24 +00:00
|
|
|
|
2019-05-17 11:52:38 +00:00
|
|
|
if( !GetShowPolarCoords() ) // display relative cartesian coordinates
|
2012-04-13 18:51:24 +00:00
|
|
|
{
|
2020-07-05 01:59:29 +00:00
|
|
|
// Calculate relative coordinates
|
|
|
|
double relXpos = cursorPos.x - screen->m_LocalOrigin.x;
|
|
|
|
double relYpos = cursorPos.y - screen->m_LocalOrigin.y;
|
|
|
|
|
|
|
|
// Transform relative coordinates for user origin preferences
|
2020-09-30 22:02:05 +00:00
|
|
|
userXpos = m_originTransforms.ToDisplayRelX( relXpos );
|
|
|
|
userYpos = m_originTransforms.ToDisplayRelY( relYpos );
|
2020-07-05 01:59:29 +00:00
|
|
|
|
2020-10-06 10:47:01 +00:00
|
|
|
line.Printf( wxT( "dx %s dy %s dist %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( userXpos, false ),
|
|
|
|
MessageTextFromValue( userYpos, false ),
|
|
|
|
MessageTextFromValue( hypot( userXpos, userYpos ), false ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
SetStatusText( line, 3 );
|
|
|
|
}
|
2019-05-24 13:55:33 +00:00
|
|
|
|
|
|
|
DisplayGridMsg();
|
2008-12-19 13:51:48 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_BASE_FRAME::unitsChangeRefresh()
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::unitsChangeRefresh(); // Update the status bar.
|
|
|
|
|
2023-03-05 13:27:22 +00:00
|
|
|
if( GetBoard() )
|
|
|
|
GetBoard()->SetUserUnits( GetUserUnits() );
|
|
|
|
|
2018-11-23 23:33:02 +00:00
|
|
|
UpdateGridSelectBox();
|
2011-03-01 19:26:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PCB_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2023-08-30 15:21:56 +00:00
|
|
|
if( aCfg->m_Window.grid.grids.empty() )
|
|
|
|
aCfg->m_Window.grid.grids = aCfg->DefaultGridSizeList();
|
2015-03-03 14:53:47 +00:00
|
|
|
|
2023-08-24 15:41:08 +00:00
|
|
|
// Move legacy user grids to grid list
|
|
|
|
if( !aCfg->m_Window.grid.user_grid_x.empty() )
|
|
|
|
{
|
2023-08-30 15:21:56 +00:00
|
|
|
aCfg->m_Window.grid.grids.emplace_back( GRID{ "User Grid", aCfg->m_Window.grid.user_grid_x,
|
|
|
|
aCfg->m_Window.grid.user_grid_y } );
|
2023-08-24 15:41:08 +00:00
|
|
|
aCfg->m_Window.grid.user_grid_x = wxEmptyString;
|
|
|
|
aCfg->m_Window.grid.user_grid_y = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
2020-12-01 19:27:42 +00:00
|
|
|
// Currently values read from config file are not used because the user cannot
|
|
|
|
// change this config
|
|
|
|
// if( aCfg->m_Window.zoom_factors.empty() )
|
2020-06-13 21:09:02 +00:00
|
|
|
{
|
2023-06-20 13:15:56 +00:00
|
|
|
if( ADVANCED_CFG::GetCfg().m_HyperZoom )
|
|
|
|
aCfg->m_Window.zoom_factors = { ZOOM_LIST_PCBNEW_HYPER };
|
|
|
|
else
|
|
|
|
aCfg->m_Window.zoom_factors = { ZOOM_LIST_PCBNEW };
|
2020-06-13 21:09:02 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 20:32:10 +00:00
|
|
|
// Some, but not all, derived classes have a PCBNEW_SETTINGS.
|
|
|
|
if( PCBNEW_SETTINGS* pcbnew_cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg ) )
|
|
|
|
m_polarCoords = pcbnew_cfg->m_PolarCoords;
|
2020-08-19 00:44:01 +00:00
|
|
|
|
2020-09-01 07:32:05 +00:00
|
|
|
wxASSERT( GetCanvas() );
|
2020-08-19 00:44:01 +00:00
|
|
|
|
2020-09-01 07:32:05 +00:00
|
|
|
if( GetCanvas() )
|
2020-08-19 00:44:01 +00:00
|
|
|
{
|
2020-09-01 07:32:05 +00:00
|
|
|
RENDER_SETTINGS* rs = GetCanvas()->GetView()->GetPainter()->GetSettings();
|
|
|
|
|
|
|
|
if( rs )
|
|
|
|
{
|
|
|
|
rs->SetHighlightFactor( aCfg->m_Graphics.highlight_factor );
|
|
|
|
rs->SetSelectFactor( aCfg->m_Graphics.select_factor );
|
2022-10-22 20:32:10 +00:00
|
|
|
rs->SetDefaultFont( wxEmptyString ); // Always the KiCad font for PCBs
|
2020-09-01 07:32:05 +00:00
|
|
|
}
|
2020-08-19 00:44:01 +00:00
|
|
|
}
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
2018-02-24 11:24:00 +00:00
|
|
|
|
2011-04-02 16:14:07 +00:00
|
|
|
|
2020-12-14 13:33:51 +00:00
|
|
|
SEVERITY PCB_BASE_FRAME::GetSeverity( int aErrorCode ) const
|
2020-06-17 12:46:50 +00:00
|
|
|
{
|
|
|
|
if( aErrorCode >= CLEANUP_FIRST )
|
|
|
|
return RPT_SEVERITY_ACTION;
|
|
|
|
|
|
|
|
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
|
|
|
|
|
|
|
|
return bds.m_DRCSeverities[ aErrorCode ];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PCB_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
// Some, but not all derived classes have a PCBNEW_SETTINGS.
|
|
|
|
PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( aCfg );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-06-12 10:58:56 +00:00
|
|
|
if( cfg )
|
2020-11-14 18:11:28 +00:00
|
|
|
cfg->m_PolarCoords = m_polarCoords;
|
2020-01-13 01:44:19 +00:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2015-03-03 14:53:47 +00:00
|
|
|
|
2020-12-23 23:18:02 +00:00
|
|
|
PCBNEW_SETTINGS* PCB_BASE_FRAME::GetPcbNewSettings() const
|
2020-01-13 01:44:19 +00:00
|
|
|
{
|
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2010-02-19 13:23:58 +00:00
|
|
|
|
|
|
|
|
2020-12-23 23:18:02 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* PCB_BASE_FRAME::GetFootprintEditorSettings() const
|
2020-05-06 01:43:37 +00:00
|
|
|
{
|
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
|
|
|
}
|
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2022-07-24 15:49:46 +00:00
|
|
|
PCB_VIEWERS_SETTINGS_BASE* PCB_BASE_FRAME::GetViewerSettingsBase() const
|
|
|
|
{
|
2022-07-24 22:40:47 +00:00
|
|
|
switch( GetFrameType() )
|
|
|
|
{
|
|
|
|
case FRAME_PCB_EDITOR:
|
|
|
|
case FRAME_FOOTPRINT_EDITOR:
|
|
|
|
case FRAME_FOOTPRINT_WIZARD:
|
|
|
|
case FRAME_PCB_DISPLAY3D:
|
|
|
|
default:
|
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
|
|
|
|
|
|
|
case FRAME_FOOTPRINT_VIEWER:
|
|
|
|
case FRAME_FOOTPRINT_VIEWER_MODAL:
|
|
|
|
case FRAME_FOOTPRINT_PREVIEW:
|
|
|
|
case FRAME_CVPCB:
|
|
|
|
case FRAME_CVPCB_DISPLAY:
|
|
|
|
return Pgm().GetSettingsManager().GetAppSettings<CVPCB_SETTINGS>();
|
|
|
|
}
|
2022-07-24 15:49:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-22 18:27:05 +00:00
|
|
|
MAGNETIC_SETTINGS* PCB_BASE_FRAME::GetMagneticItemsSettings()
|
|
|
|
{
|
2022-07-24 15:49:46 +00:00
|
|
|
return &GetPcbNewSettings()->m_MagneticItems;
|
2020-05-22 18:27:05 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 01:43:37 +00:00
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-09-25 19:23:54 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2018-09-25 19:23:54 +00:00
|
|
|
|
2023-08-20 16:08:51 +00:00
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
|
|
|
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
|
|
|
|
PCB_RENDER_SETTINGS* settings = painter->GetSettings();
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2023-08-20 16:08:51 +00:00
|
|
|
settings->LoadColors( GetColorSettings( true ) );
|
|
|
|
settings->LoadDisplayOptions( GetDisplayOptions() );
|
|
|
|
settings->m_ForceShowFieldsWhenFPSelected = GetPcbNewSettings()->m_Display.m_ForceShowFieldsWhenFPSelected;
|
2022-02-13 13:06:35 +00:00
|
|
|
|
2022-12-24 17:04:34 +00:00
|
|
|
// Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
|
|
|
|
// they won't be found in the view layer's itemset for re-painting.
|
|
|
|
GetCanvas()->GetView()->UpdateAllItemsConditionally(
|
|
|
|
[&]( KIGFX::VIEW_ITEM* aItem ) -> int
|
2022-02-13 13:06:35 +00:00
|
|
|
{
|
|
|
|
if( dynamic_cast<RATSNEST_VIEW_ITEM*>( aItem ) )
|
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
return KIGFX::ALL; // ratsnest display
|
2022-02-13 13:06:35 +00:00
|
|
|
}
|
|
|
|
else if( dynamic_cast<PCB_TRACK*>( aItem ) )
|
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
return KIGFX::REPAINT; // track, arc & via clearance display
|
2022-02-13 13:06:35 +00:00
|
|
|
}
|
|
|
|
else if( dynamic_cast<PAD*>( aItem ) )
|
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
return KIGFX::REPAINT; // pad clearance display
|
2022-02-13 13:06:35 +00:00
|
|
|
}
|
|
|
|
|
2022-12-24 17:04:34 +00:00
|
|
|
return 0;
|
2022-02-13 13:06:35 +00:00
|
|
|
} );
|
|
|
|
|
2023-08-20 16:08:51 +00:00
|
|
|
view->UpdateAllItems( KIGFX::COLOR );
|
2020-09-20 23:11:44 +00:00
|
|
|
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2018-09-25 19:23:54 +00:00
|
|
|
|
2019-06-04 10:28:05 +00:00
|
|
|
// The 3D viewer isn't in the Kiway, so send its update manually
|
2021-06-19 17:28:45 +00:00
|
|
|
EDA_3D_VIEWER_FRAME* viewer = Get3DViewerFrame();
|
2018-09-25 19:23:54 +00:00
|
|
|
|
|
|
|
if( viewer )
|
2020-07-17 20:04:14 +00:00
|
|
|
viewer->CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2018-09-25 19:23:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-09 08:35:06 +00:00
|
|
|
void PCB_BASE_FRAME::OnModify()
|
2010-02-19 13:23:58 +00:00
|
|
|
{
|
2022-10-10 13:03:10 +00:00
|
|
|
EDA_BASE_FRAME::OnModify();
|
|
|
|
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified();
|
2022-10-10 13:03:10 +00:00
|
|
|
m_autoSaveRequired = true;
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2021-02-26 13:49:40 +00:00
|
|
|
GetBoard()->IncrementTimeStamp();
|
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
UpdateStatusBar();
|
|
|
|
UpdateMsgPanel();
|
2010-02-19 13:23:58 +00:00
|
|
|
}
|
2011-02-21 13:54:29 +00:00
|
|
|
|
|
|
|
|
2022-11-30 12:18:58 +00:00
|
|
|
void PCB_BASE_FRAME::rebuildConnectivity()
|
|
|
|
{
|
|
|
|
GetBoard()->BuildConnectivity();
|
|
|
|
GetToolManager()->PostEvent( EVENTS::ConnectivityChangedEvent );
|
|
|
|
GetCanvas()->RedrawRatsnest();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
PCB_DRAW_PANEL_GAL* PCB_BASE_FRAME::GetCanvas() const
|
|
|
|
{
|
|
|
|
return static_cast<PCB_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
void PCB_BASE_FRAME::ActivateGalCanvas()
|
2015-08-07 17:15:36 +00:00
|
|
|
{
|
2019-05-30 12:25:08 +00:00
|
|
|
EDA_DRAW_FRAME::ActivateGalCanvas();
|
2015-08-07 17:15:36 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
|
2021-11-09 11:59:25 +00:00
|
|
|
KIGFX::VIEW* view = canvas->GetView();
|
2015-08-07 17:15:36 +00:00
|
|
|
|
|
|
|
if( m_toolManager )
|
2019-05-28 23:23:58 +00:00
|
|
|
{
|
2021-11-09 11:59:25 +00:00
|
|
|
m_toolManager->SetEnvironment( m_pcb, view, canvas->GetViewControls(), config(), this );
|
2015-08-07 17:15:36 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
|
2021-11-09 11:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( view->GetPainter() );
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
|
|
|
|
const PCB_DISPLAY_OPTIONS& displ_opts = GetDisplayOptions();
|
2017-06-13 09:25:05 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
settings->LoadDisplayOptions( displ_opts );
|
2020-05-16 17:15:43 +00:00
|
|
|
settings->LoadColors( GetColorSettings() );
|
2023-08-20 16:08:51 +00:00
|
|
|
settings->m_ForceShowFieldsWhenFPSelected = GetPcbNewSettings()->m_Display.m_ForceShowFieldsWhenFPSelected;
|
2015-08-07 17:15:36 +00:00
|
|
|
|
2021-11-09 11:59:25 +00:00
|
|
|
view->RecacheAllItems();
|
2019-06-13 17:28:55 +00:00
|
|
|
canvas->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
canvas->StartDrawing();
|
2021-10-25 12:18:48 +00:00
|
|
|
|
2023-06-13 16:44:22 +00:00
|
|
|
try
|
2023-04-07 17:08:43 +00:00
|
|
|
|
2023-06-13 16:44:22 +00:00
|
|
|
{
|
|
|
|
if( m_spaceMouse == nullptr )
|
2021-10-25 12:18:48 +00:00
|
|
|
{
|
2023-06-13 16:44:22 +00:00
|
|
|
m_spaceMouse = new NL_PCBNEW_PLUGIN( GetCanvas() );
|
2021-10-25 12:18:48 +00:00
|
|
|
}
|
|
|
|
}
|
2023-06-13 16:44:22 +00:00
|
|
|
catch( const std::system_error& e )
|
|
|
|
{
|
|
|
|
wxLogTrace( wxT( "KI_TRACE_NAVLIB" ), e.what() );
|
|
|
|
}
|
2015-08-07 17:15:36 +00:00
|
|
|
}
|
2015-08-07 17:15:47 +00:00
|
|
|
|
2020-07-11 17:40:23 +00:00
|
|
|
|
2021-03-14 15:29:24 +00:00
|
|
|
void PCB_BASE_FRAME::SetDisplayOptions( const PCB_DISPLAY_OPTIONS& aOptions, bool aRefresh )
|
2020-07-11 17:40:23 +00:00
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
bool hcChanged = m_displayOptions.m_ContrastModeDisplay != aOptions.m_ContrastModeDisplay;
|
|
|
|
bool hcVisChanged = m_displayOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN
|
|
|
|
|| aOptions.m_ContrastModeDisplay == HIGH_CONTRAST_MODE::HIDDEN;
|
|
|
|
m_displayOptions = aOptions;
|
2020-07-11 17:40:23 +00:00
|
|
|
|
|
|
|
EDA_DRAW_PANEL_GAL* canvas = GetCanvas();
|
|
|
|
KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( canvas->GetView() );
|
|
|
|
|
|
|
|
view->UpdateDisplayOptions( aOptions );
|
|
|
|
canvas->SetHighContrastLayer( GetActiveLayer() );
|
|
|
|
OnDisplayOptionsChanged();
|
|
|
|
|
2020-10-13 02:47:20 +00:00
|
|
|
// Vias on a restricted layer set must be redrawn when high contrast mode is changed
|
|
|
|
if( hcChanged )
|
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
// Note: KIGFX::REPAINT isn't enough for things that go from invisible to visible as
|
|
|
|
// they won't be found in the view layer's itemset for re-painting.
|
|
|
|
GetCanvas()->GetView()->UpdateAllItemsConditionally(
|
2022-12-26 14:11:28 +00:00
|
|
|
[&]( KIGFX::VIEW_ITEM* aItem ) -> int
|
2020-10-13 02:47:20 +00:00
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
if( PCB_VIA* via = dynamic_cast<PCB_VIA*>( aItem ) )
|
2021-02-09 12:25:17 +00:00
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
if( via->GetViaType() == VIATYPE::BLIND_BURIED
|
2022-10-18 12:00:37 +00:00
|
|
|
|| via->GetViaType() == VIATYPE::MICROVIA
|
2022-12-24 17:04:34 +00:00
|
|
|
|| via->GetRemoveUnconnected() )
|
|
|
|
{
|
|
|
|
return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
|
|
|
|
}
|
2022-10-18 12:00:37 +00:00
|
|
|
}
|
|
|
|
else if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
|
|
|
|
{
|
2022-12-24 17:04:34 +00:00
|
|
|
if( pad->GetRemoveUnconnected() )
|
|
|
|
return hcVisChanged ? KIGFX::ALL : KIGFX::REPAINT;
|
2021-02-09 12:25:17 +00:00
|
|
|
}
|
2020-10-13 02:47:20 +00:00
|
|
|
|
2022-12-24 17:04:34 +00:00
|
|
|
return 0;
|
2020-10-13 02:47:20 +00:00
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2021-03-14 15:29:24 +00:00
|
|
|
if( aRefresh )
|
|
|
|
canvas->Refresh();
|
2020-07-11 17:40:23 +00:00
|
|
|
}
|
2023-05-31 20:37:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::setFPWatcher( FOOTPRINT* aFootprint )
|
|
|
|
{
|
2023-07-12 21:27:41 +00:00
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "setFPWatcher" );
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
Unbind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
|
|
|
|
|
2023-07-14 18:29:14 +00:00
|
|
|
if( m_watcher )
|
2023-05-31 20:37:58 +00:00
|
|
|
{
|
2023-07-12 21:27:41 +00:00
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Remove watch" );
|
2023-07-14 18:29:14 +00:00
|
|
|
m_watcher->RemoveAll();
|
|
|
|
m_watcher->SetOwner( nullptr );
|
|
|
|
m_watcher.reset();
|
2023-05-31 20:37:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString libfullname;
|
|
|
|
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
|
|
|
|
|
|
|
if( !aFootprint || !tbl )
|
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const FP_LIB_TABLE_ROW* row = tbl->FindRow( aFootprint->GetFPID().GetLibNickname() );
|
|
|
|
|
|
|
|
if( !row )
|
|
|
|
return;
|
|
|
|
|
|
|
|
libfullname = row->GetFullURI( true );
|
|
|
|
}
|
|
|
|
catch( const std::exception& e )
|
|
|
|
{
|
|
|
|
DisplayInfoMessage( this, e.what() );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& error )
|
|
|
|
{
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Error: %s", error.What() );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_watcherFileName.Assign( libfullname, aFootprint->GetFPID().GetLibItemName(),
|
|
|
|
KiCadFootprintFileExtension );
|
|
|
|
|
|
|
|
if( !m_watcherFileName.FileExists() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_watcherLastModified = m_watcherFileName.GetModificationTime();
|
|
|
|
|
|
|
|
Bind( wxEVT_FSWATCHER, &PCB_BASE_FRAME::OnFPChange, this );
|
|
|
|
m_watcher = std::make_unique<wxFileSystemWatcher>();
|
|
|
|
m_watcher->SetOwner( this );
|
|
|
|
|
|
|
|
wxFileName fn;
|
|
|
|
fn.AssignDir( m_watcherFileName.GetPath() );
|
|
|
|
fn.DontFollowLink();
|
|
|
|
|
2023-07-12 21:27:41 +00:00
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Add watch: %s", fn.GetPath() );
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
m_watcher->AddTree( fn );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::OnFPChange( wxFileSystemWatcherEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetPath() != m_watcherFileName.GetFullPath() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Start the debounce timer (set to 1 second)
|
|
|
|
if( !m_watcherDebounceTimer.StartOnce( 1000 ) )
|
|
|
|
{
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "Failed to start the debounce timer" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_BASE_FRAME::OnFpChangeDebounceTimer( wxTimerEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxLogTrace( "KICAD_LIB_WATCH", "OnFpChangeDebounceTimer" );
|
|
|
|
|
|
|
|
// Disable logging to avoid spurious messages and check if the file has changed
|
|
|
|
wxLog::EnableLogging( false );
|
|
|
|
wxDateTime lastModified = m_watcherFileName.GetModificationTime();
|
|
|
|
wxLog::EnableLogging( true );
|
|
|
|
|
|
|
|
if( lastModified == m_watcherLastModified || !lastModified.IsValid() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_watcherLastModified = lastModified;
|
|
|
|
|
|
|
|
FOOTPRINT* fp = GetBoard()->GetFirstFootprint();
|
|
|
|
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
|
|
|
|
2023-07-07 21:16:06 +00:00
|
|
|
// When loading a footprint from a library in the footprint editor
|
|
|
|
// the items UUIDs must be keep and not reinitialized
|
|
|
|
bool keepUUID = IsType( FRAME_FOOTPRINT_EDITOR );
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
if( !fp || !tbl )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( !GetScreen()->IsContentModified()
|
|
|
|
|| IsOK( this, _( "The library containing the current footprint has changed.\n"
|
|
|
|
"Do you want to reload the footprint?" ) ) )
|
|
|
|
{
|
|
|
|
wxString fpname = fp->GetFPID().GetLibItemName();
|
|
|
|
wxString nickname = fp->GetFPID().GetLibNickname();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2023-07-07 21:16:06 +00:00
|
|
|
FOOTPRINT* newfp = tbl->FootprintLoad( nickname, fpname, keepUUID );
|
2023-05-31 20:37:58 +00:00
|
|
|
|
|
|
|
if( newfp )
|
2023-06-27 00:03:03 +00:00
|
|
|
{
|
2023-07-07 21:16:06 +00:00
|
|
|
std::vector<KIID> selectedItems;
|
|
|
|
|
|
|
|
for( const EDA_ITEM* item : GetCurrentSelection() )
|
|
|
|
{
|
|
|
|
wxString uuidStr = item->m_Uuid.AsString();
|
|
|
|
selectedItems.emplace_back( item->m_Uuid );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_toolManager->RunAction( PCB_ACTIONS::selectionClear );
|
|
|
|
|
2023-05-31 20:37:58 +00:00
|
|
|
ReloadFootprint( newfp );
|
2023-06-27 00:03:03 +00:00
|
|
|
|
|
|
|
newfp->ClearAllNets();
|
|
|
|
GetCanvas()->UpdateColors();
|
|
|
|
GetCanvas()->DisplayBoard( GetBoard() );
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
2023-07-07 21:16:06 +00:00
|
|
|
|
|
|
|
std::vector<EDA_ITEM*> sel;
|
|
|
|
|
|
|
|
for( const KIID& uuid : selectedItems )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* item = GetBoard()->GetItem( uuid );
|
|
|
|
|
|
|
|
if( item != DELETED_BOARD_ITEM::GetInstance() )
|
|
|
|
sel.push_back( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !sel.empty() )
|
|
|
|
m_toolManager->RunAction( PCB_ACTIONS::selectItems, &sel );
|
2023-06-27 00:03:03 +00:00
|
|
|
}
|
2023-05-31 20:37:58 +00:00
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
DisplayError( this, ioe.What() );
|
|
|
|
}
|
|
|
|
}
|
2023-06-03 11:28:03 +00:00
|
|
|
}
|