2013-04-26 15:11:52 +00:00
|
|
|
|
2012-12-18 17:50:00 +00:00
|
|
|
/**
|
2013-01-03 20:21:40 +00:00
|
|
|
* @file pcbnew/dialogs/dialog_netlist.cpp
|
2012-12-18 17:50:00 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-11-12 00:31:38 +00:00
|
|
|
* Copyright (C) 1992-2017 KiCad Developers, see change_log.txt for contributors.
|
2012-12-18 17:50:00 +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
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.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 <project.h>
|
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2013-09-14 20:33:22 +00:00
|
|
|
#include <macros.h>
|
2012-12-18 17:50:00 +00:00
|
|
|
#include <dialog_helpers.h>
|
|
|
|
#include <html_messagebox.h>
|
|
|
|
#include <base_units.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2013-09-14 20:33:22 +00:00
|
|
|
#include <pcb_netlist.h>
|
2013-04-25 16:29:35 +00:00
|
|
|
#include <netlist_reader.h>
|
|
|
|
#include <reporter.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2018-02-02 20:57:12 +00:00
|
|
|
#include <board_design_settings.h>
|
2012-08-29 16:59:50 +00:00
|
|
|
#include <class_board.h>
|
2012-12-18 17:50:00 +00:00
|
|
|
#include <class_module.h>
|
2017-11-15 17:33:06 +00:00
|
|
|
#include <connectivity_data.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_netlist.h>
|
2015-06-16 12:20:42 +00:00
|
|
|
#include <wx_html_report_panel.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-06-19 16:11:12 +00:00
|
|
|
#define NETLIST_SILENTMODE_KEY wxT("SilentMode")
|
2015-07-24 18:49:47 +00:00
|
|
|
#define NETLIST_FILTER_MESSAGES_KEY wxT("NetlistReportFilterMsg")
|
2013-08-24 08:08:55 +00:00
|
|
|
#define NETLIST_DELETESINGLEPADNETS_KEY wxT("NetlistDeleteSinglePadNets")
|
2013-02-02 17:39:59 +00:00
|
|
|
|
2011-05-03 12:57:44 +00:00
|
|
|
void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2013-02-02 17:39:59 +00:00
|
|
|
/* Setup the netlist file name to the last netlist file read,
|
|
|
|
* or the board file name if the last filename is empty or last file not existing.
|
2010-04-23 14:46:00 +00:00
|
|
|
*/
|
2015-07-24 18:49:47 +00:00
|
|
|
wxString netlistName = GetLastNetListRead();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-07-24 18:49:47 +00:00
|
|
|
wxFileName fn = netlistName;
|
|
|
|
|
|
|
|
if( !fn.IsOk() || !fn.FileExists() )
|
2010-04-23 14:46:00 +00:00
|
|
|
{
|
2012-08-29 16:59:50 +00:00
|
|
|
fn = GetBoard()->GetFileName();
|
2012-03-08 17:47:23 +00:00
|
|
|
fn.SetExt( NetlistFileExtension );
|
2015-09-01 09:13:22 +00:00
|
|
|
|
|
|
|
if( fn.GetName().IsEmpty() )
|
|
|
|
netlistName.Clear();
|
|
|
|
else
|
|
|
|
netlistName = fn.GetFullPath();
|
2010-04-23 14:46:00 +00:00
|
|
|
}
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2015-07-24 18:49:47 +00:00
|
|
|
DIALOG_NETLIST dlg( this, DC, netlistName );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-02-02 17:39:59 +00:00
|
|
|
dlg.ShowModal();
|
2011-03-22 17:58:58 +00:00
|
|
|
|
|
|
|
// Save project settings if needed.
|
|
|
|
// Project settings are saved in the corresponding <board name>.pro file
|
2015-07-24 18:49:47 +00:00
|
|
|
bool configChanged = !GetLastNetListRead().IsEmpty() && ( netlistName != GetLastNetListRead() );
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2015-06-12 12:46:41 +00:00
|
|
|
if( configChanged && !GetBoard()->GetFileName().IsEmpty()
|
2013-04-25 16:29:35 +00:00
|
|
|
&& IsOK( NULL, _( "The project configuration has changed. Do you want to save it?" ) ) )
|
2011-03-22 17:58:58 +00:00
|
|
|
{
|
2016-04-18 18:15:44 +00:00
|
|
|
fn = Prj().AbsolutePath( GetBoard()->GetFileName() );
|
2011-03-22 17:58:58 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
* 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
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString pro_name = fn.GetFullPath();
|
|
|
|
|
|
|
|
Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_PCB,
|
|
|
|
GetProjectFileParameters(), pro_name );
|
2011-03-22 17:58:58 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_NETLIST::DIALOG_NETLIST( PCB_EDIT_FRAME* aParent, wxDC * aDC,
|
2012-12-18 17:50:00 +00:00
|
|
|
const wxString & aNetlistFullFilename )
|
2010-04-23 14:46:00 +00:00
|
|
|
: DIALOG_NETLIST_FBP( aParent )
|
2008-03-22 18:08:44 +00:00
|
|
|
{
|
2012-12-18 17:50:00 +00:00
|
|
|
m_parent = aParent;
|
|
|
|
m_dc = aDC;
|
* 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
|
|
|
m_config = Kiface().KifaceSettings();
|
2015-07-24 18:49:47 +00:00
|
|
|
|
2013-06-19 16:11:12 +00:00
|
|
|
m_silentMode = m_config->Read( NETLIST_SILENTMODE_KEY, 0l );
|
2013-08-24 08:08:55 +00:00
|
|
|
bool tmp = m_config->Read( NETLIST_DELETESINGLEPADNETS_KEY, 0l );
|
|
|
|
m_rbSingleNets->SetSelection( tmp == 0 ? 0 : 1);
|
2012-12-18 17:50:00 +00:00
|
|
|
m_NetlistFilenameCtrl->SetValue( aNetlistFullFilename );
|
2013-06-19 16:11:12 +00:00
|
|
|
m_checkBoxSilentMode->SetValue( m_silentMode );
|
2015-07-24 18:49:47 +00:00
|
|
|
|
|
|
|
int severities = m_config->Read( NETLIST_FILTER_MESSAGES_KEY, -1l );
|
|
|
|
m_MessageWindow->SetVisibleSeverities( severities );
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2015-12-04 17:06:54 +00:00
|
|
|
// Update sizes and sizers:
|
|
|
|
m_MessageWindow->MsgPanelSetMinSize( wxSize( -1, 150 ) );
|
2011-05-03 12:57:44 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2013-06-19 16:11:12 +00:00
|
|
|
DIALOG_NETLIST::~DIALOG_NETLIST()
|
|
|
|
{
|
|
|
|
m_config->Write( NETLIST_SILENTMODE_KEY, (long) m_silentMode );
|
2013-08-24 08:08:55 +00:00
|
|
|
m_config->Write( NETLIST_DELETESINGLEPADNETS_KEY,
|
|
|
|
(long) m_rbSingleNets->GetSelection() );
|
2015-07-24 18:49:47 +00:00
|
|
|
m_config->Write( NETLIST_FILTER_MESSAGES_KEY,
|
|
|
|
(long) m_MessageWindow->GetVisibleSeverities() );
|
2013-06-19 16:11:12 +00:00
|
|
|
}
|
2013-04-28 20:20:40 +00:00
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
|
2012-12-18 17:50:00 +00:00
|
|
|
void DIALOG_NETLIST::OnOpenNetlistClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString lastPath = wxFileName( Prj().GetProjectFullName() ).GetPath();
|
|
|
|
|
2012-12-18 17:50:00 +00:00
|
|
|
wxString lastNetlistRead = m_parent->GetLastNetListRead();
|
2010-04-23 14:46:00 +00:00
|
|
|
|
|
|
|
if( !lastNetlistRead.IsEmpty() && !wxFileName::FileExists( lastNetlistRead ) )
|
|
|
|
{
|
|
|
|
lastNetlistRead = wxEmptyString;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxFileName fn = lastNetlistRead;
|
|
|
|
lastPath = fn.GetPath();
|
2010-04-24 09:03:35 +00:00
|
|
|
lastNetlistRead = fn.GetFullName();
|
2010-04-23 14:46:00 +00:00
|
|
|
}
|
|
|
|
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxLogDebug( wxT( "Last net list read path '%s', file name '%s'." ),
|
2010-04-23 14:46:00 +00:00
|
|
|
GetChars( lastPath ), GetChars( lastNetlistRead ) );
|
|
|
|
|
|
|
|
wxFileDialog FilesDialog( this, _( "Select Netlist" ), lastPath, lastNetlistRead,
|
2017-11-12 00:31:38 +00:00
|
|
|
NetlistFileWildcard(), wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2009-04-24 07:36:36 +00:00
|
|
|
if( FilesDialog.ShowModal() != wxID_OK )
|
|
|
|
return;
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2010-04-23 14:46:00 +00:00
|
|
|
m_NetlistFilenameCtrl->SetValue( FilesDialog.GetPath() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2009-04-24 07:36:36 +00:00
|
|
|
void DIALOG_NETLIST::OnReadNetlistFileClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-04-25 16:29:35 +00:00
|
|
|
wxString netlistFileName = m_NetlistFilenameCtrl->GetValue();
|
2015-09-01 09:13:22 +00:00
|
|
|
wxFileName fn = netlistFileName;
|
|
|
|
|
|
|
|
if( !fn.IsOk() )
|
|
|
|
{
|
|
|
|
wxMessageBox( _("Please, choose a valid netlist file") );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !fn.FileExists() )
|
|
|
|
{
|
|
|
|
wxMessageBox( _("The netlist file does not exist") );
|
|
|
|
return;
|
|
|
|
}
|
2013-04-25 16:29:35 +00:00
|
|
|
|
|
|
|
// Give the user a chance to bail out when making changes from a netlist.
|
2013-06-19 16:11:12 +00:00
|
|
|
if( !m_checkDryRun->GetValue() && !m_silentMode
|
2013-04-26 15:11:52 +00:00
|
|
|
&& !m_parent->GetBoard()->IsEmpty()
|
2013-04-25 16:29:35 +00:00
|
|
|
&& !IsOK( NULL, _( "The changes made by reading the netlist cannot be undone. Are you "
|
|
|
|
"sure you want to read the netlist?" ) ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_MessageWindow->Clear();
|
2015-06-16 12:20:42 +00:00
|
|
|
REPORTER& reporter = m_MessageWindow->Reporter();
|
|
|
|
|
|
|
|
wxBusyCursor busy;
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2015-09-01 09:13:22 +00:00
|
|
|
wxString msg;
|
2013-04-25 16:29:35 +00:00
|
|
|
msg.Printf( _( "Reading netlist file \"%s\".\n" ), GetChars( netlistFileName ) );
|
2015-06-16 12:20:42 +00:00
|
|
|
reporter.Report( msg, REPORTER::RPT_INFO );
|
2013-04-25 16:29:35 +00:00
|
|
|
|
|
|
|
if( m_Select_By_Timestamp->GetSelection() == 1 )
|
2015-06-12 12:46:41 +00:00
|
|
|
msg = _( "Using time stamps to match components and footprints.\n" );
|
|
|
|
else
|
|
|
|
msg = _( "Using references to match components and footprints.\n" );
|
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
reporter.Report( msg, REPORTER::RPT_INFO );
|
2015-07-24 18:49:47 +00:00
|
|
|
m_MessageWindow->SetLazyUpdate( true ); // use a "lazy" update to speed up the creation of the report
|
|
|
|
// (The window is not updated for each message)
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2015-06-12 12:46:41 +00:00
|
|
|
m_parent->ReadPcbNetlist( netlistFileName, wxEmptyString, &reporter,
|
2013-04-25 16:29:35 +00:00
|
|
|
m_ChangeExistingFootprintCtrl->GetSelection() == 1,
|
|
|
|
m_DeleteBadTracks->GetSelection() == 1,
|
|
|
|
m_RemoveExtraFootprintsCtrl->GetSelection() == 1,
|
|
|
|
m_Select_By_Timestamp->GetSelection() == 1,
|
2013-08-24 08:08:55 +00:00
|
|
|
m_rbSingleNets->GetSelection() == 1,
|
2013-04-25 16:29:35 +00:00
|
|
|
m_checkDryRun->GetValue() );
|
2015-07-24 18:49:47 +00:00
|
|
|
// The creation of the report was made without window update:
|
|
|
|
// the full page must be displayed
|
|
|
|
m_MessageWindow->Flush();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2009-04-24 07:36:36 +00:00
|
|
|
void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-12-18 17:50:00 +00:00
|
|
|
if( m_parent->GetBoard()->m_Modules == NULL )
|
|
|
|
{
|
2014-11-02 12:44:57 +00:00
|
|
|
DisplayInfoMessage( this, _( "No footprints" ) );
|
2012-12-18 17:50:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lists of duplicates, missing references and not in netlist footprints:
|
|
|
|
std::vector <MODULE*> duplicate;
|
|
|
|
wxArrayString missing;
|
|
|
|
std::vector <MODULE*> notInNetlist;
|
|
|
|
wxString netlistFilename = m_NetlistFilenameCtrl->GetValue();
|
|
|
|
|
2015-06-12 12:46:41 +00:00
|
|
|
if( !verifyFootprints( netlistFilename, wxEmptyString, duplicate, missing, notInNetlist ) )
|
2013-04-25 16:29:35 +00:00
|
|
|
return;
|
|
|
|
|
2012-12-18 17:50:00 +00:00
|
|
|
#define ERR_CNT_MAX 100 // Max number of errors to output in dialog
|
|
|
|
// to avoid a too long message list
|
|
|
|
|
|
|
|
wxString list; // The messages to display
|
|
|
|
|
|
|
|
m_parent->SetLastNetListRead( netlistFilename );
|
|
|
|
|
|
|
|
int err_cnt = 0;
|
|
|
|
|
|
|
|
// Search for duplicate footprints.
|
|
|
|
if( duplicate.size() == 0 )
|
|
|
|
list << wxT("<p><b>") << _( "No duplicate." ) << wxT("</b></p>");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list << wxT("<p><b>") << _( "Duplicates:" ) << wxT("</b></p>");
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < duplicate.size(); ii++ )
|
|
|
|
{
|
|
|
|
MODULE* module = duplicate[ii];
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module->GetReference().IsEmpty() )
|
2012-12-18 17:50:00 +00:00
|
|
|
list << wxT("<br>") << wxT("[noref)");
|
|
|
|
else
|
2013-03-13 18:53:58 +00:00
|
|
|
list << wxT("<br>") << module->GetReference();
|
2012-12-18 17:50:00 +00:00
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
list << wxT(" (<i>") << module->GetValue() << wxT("</i>)");
|
2012-12-18 17:50:00 +00:00
|
|
|
list << wxT(" @ ");
|
|
|
|
list << CoordinateToString( module->GetPosition().x ),
|
|
|
|
list << wxT(", ") << CoordinateToString( module->GetPosition().y ),
|
|
|
|
err_cnt++;
|
|
|
|
|
|
|
|
if( ERR_CNT_MAX < err_cnt )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search for missing modules on board.
|
|
|
|
if( missing.size() == 0 )
|
2014-11-02 12:44:57 +00:00
|
|
|
list << wxT("<p><b>") << _( "No missing footprints." ) << wxT("</b></p>");
|
2012-12-18 17:50:00 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
list << wxT("<p><b>") << _( "Missing:" ) << wxT("</b></p>");
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < missing.size(); ii += 2 )
|
|
|
|
{
|
|
|
|
list << wxT("<br>") << missing[ii];
|
|
|
|
list << wxT(" (<i>") << missing[ii+1] << wxT("</i>)");
|
|
|
|
err_cnt++;
|
|
|
|
|
|
|
|
if( ERR_CNT_MAX < err_cnt )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Search for modules found on board but not in net list.
|
|
|
|
if( notInNetlist.size() == 0 )
|
2014-11-02 12:44:57 +00:00
|
|
|
list << wxT( "<p><b>" ) << _( "No extra footprints." ) << wxT( "</b></p>" );
|
2012-12-18 17:50:00 +00:00
|
|
|
else
|
|
|
|
{
|
2013-04-25 16:29:35 +00:00
|
|
|
list << wxT( "<p><b>" ) << _( "Not in Netlist:" ) << wxT( "</b></p>" );
|
2012-12-18 17:50:00 +00:00
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < notInNetlist.size(); ii++ )
|
|
|
|
{
|
|
|
|
MODULE* module = notInNetlist[ii];
|
|
|
|
|
2013-03-13 18:53:58 +00:00
|
|
|
if( module->GetReference().IsEmpty() )
|
2013-04-25 16:29:35 +00:00
|
|
|
list << wxT( "<br>" ) << wxT( "[noref)" );
|
2012-12-18 17:50:00 +00:00
|
|
|
else
|
2013-04-25 16:29:35 +00:00
|
|
|
list << wxT( "<br>" ) << module->GetReference() ;
|
2013-03-13 18:53:58 +00:00
|
|
|
|
2013-04-25 16:29:35 +00:00
|
|
|
list << wxT( " (<i>" ) << module->GetValue() << wxT( "</i>)" );
|
|
|
|
list << wxT( " @ " );
|
2012-12-18 17:50:00 +00:00
|
|
|
list << CoordinateToString( module->GetPosition().x ),
|
2013-04-25 16:29:35 +00:00
|
|
|
list << wxT( ", " ) << CoordinateToString( module->GetPosition().y ),
|
2012-12-18 17:50:00 +00:00
|
|
|
err_cnt++;
|
|
|
|
|
|
|
|
if( ERR_CNT_MAX < err_cnt )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ERR_CNT_MAX < err_cnt )
|
|
|
|
{
|
2013-04-25 16:29:35 +00:00
|
|
|
list << wxT( "<p><b>" )
|
2012-12-18 17:50:00 +00:00
|
|
|
<< _( "Too many errors: some are skipped" )
|
2013-04-25 16:29:35 +00:00
|
|
|
<< wxT( "</b></p>" );
|
2012-12-18 17:50:00 +00:00
|
|
|
}
|
|
|
|
|
2014-11-02 12:44:57 +00:00
|
|
|
HTML_MESSAGE_BOX dlg( this, _( "Check footprints" ) );
|
2013-04-25 16:29:35 +00:00
|
|
|
dlg.AddHTML_Text( list );
|
2012-12-18 17:50:00 +00:00
|
|
|
dlg.ShowModal();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_COMPILE_RATSNEST
|
|
|
|
*/
|
|
|
|
|
2009-04-24 07:36:36 +00:00
|
|
|
void DIALOG_NETLIST::OnCompileRatsnestClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2015-03-10 18:31:21 +00:00
|
|
|
// Rebuild the board connectivity:
|
2017-03-22 13:43:10 +00:00
|
|
|
auto board = m_parent->GetBoard();
|
2017-04-25 09:06:24 +00:00
|
|
|
board->GetConnectivity()->RecalculateRatsnest();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-22 18:08:44 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
2007-11-13 09:35:39 +00:00
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
|
|
|
|
2009-04-24 07:36:36 +00:00
|
|
|
void DIALOG_NETLIST::OnCancelClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2013-02-22 20:03:00 +00:00
|
|
|
EndModal( wxID_CANCEL );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2013-04-25 16:29:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_NETLIST::OnSaveMessagesToFile( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
if( !m_parent->GetLastNetListRead().IsEmpty() )
|
|
|
|
{
|
|
|
|
fn = m_parent->GetLastNetListRead();
|
2017-11-12 00:31:38 +00:00
|
|
|
fn.SetExt( "txt" );
|
2013-04-25 16:29:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
fn = wxPathOnly( Prj().GetProjectFullName() );
|
2013-04-25 16:29:35 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Contents of Message Window" ), fn.GetPath(), fn.GetFullName(),
|
|
|
|
TextFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2013-04-25 16:29:35 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
fn = dlg.GetPath();
|
|
|
|
|
|
|
|
if( fn.GetExt().IsEmpty() )
|
|
|
|
fn.SetExt( wxT( "txt" ) );
|
|
|
|
|
|
|
|
wxFile f( fn.GetFullPath(), wxFile::write );
|
|
|
|
|
|
|
|
if( !f.IsOpened() )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg.Printf( _( "Cannot write message contents to file \"%s\"." ),
|
|
|
|
GetChars( fn.GetFullPath() ) );
|
|
|
|
wxMessageBox( msg, _( "File Write Error" ), wxOK | wxICON_ERROR, this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_NETLIST::OnUpdateUISaveMessagesToFile( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
2015-06-16 12:20:42 +00:00
|
|
|
//aEvent.Enable( !m_MessageWindow->IsEmpty() );
|
2013-04-25 16:29:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_NETLIST::OnUpdateUIValidNetlistFile( wxUpdateUIEvent& aEvent )
|
|
|
|
{
|
|
|
|
aEvent.Enable( !m_NetlistFilenameCtrl->GetValue().IsEmpty() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_NETLIST::verifyFootprints( const wxString& aNetlistFilename,
|
|
|
|
const wxString & aCmpFilename,
|
|
|
|
std::vector< MODULE* >& aDuplicates,
|
|
|
|
wxArrayString& aMissing,
|
|
|
|
std::vector< MODULE* >& aNotInNetlist )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
MODULE* module;
|
|
|
|
MODULE* nextModule;
|
|
|
|
NETLIST netlist;
|
|
|
|
wxBusyCursor dummy; // Shows an hourglass while calculating.
|
|
|
|
NETLIST_READER* netlistReader;
|
|
|
|
COMPONENT* component;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
netlistReader = NETLIST_READER::GetNetlistReader( &netlist, aNetlistFilename,
|
|
|
|
aCmpFilename );
|
|
|
|
|
|
|
|
if( netlistReader == NULL )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Cannot open netlist file \"%s\"." ), GetChars( aNetlistFilename ) );
|
|
|
|
wxMessageBox( msg, _( "Netlist Load Error." ), wxOK | wxICON_ERROR );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-05 12:26:39 +00:00
|
|
|
std::unique_ptr< NETLIST_READER > nlr( netlistReader );
|
2013-04-25 16:29:35 +00:00
|
|
|
netlistReader->LoadNetlist();
|
|
|
|
}
|
2014-04-09 13:33:04 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-04-25 16:29:35 +00:00
|
|
|
{
|
2016-09-14 22:36:45 +00:00
|
|
|
msg.Printf( _( "Error loading netlist file:\n%s" ), ioe.What().GetData() );
|
2013-04-25 16:29:35 +00:00
|
|
|
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOARD* pcb = m_parent->GetBoard();
|
|
|
|
|
|
|
|
// Search for duplicate footprints.
|
|
|
|
module = pcb->m_Modules;
|
|
|
|
|
|
|
|
for( ; module != NULL; module = module->Next() )
|
|
|
|
{
|
|
|
|
nextModule = module->Next();
|
|
|
|
|
|
|
|
for( ; nextModule != NULL; nextModule = nextModule->Next() )
|
|
|
|
{
|
|
|
|
if( module->GetReference().CmpNoCase( nextModule->GetReference() ) == 0 )
|
|
|
|
{
|
|
|
|
aDuplicates.push_back( module );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search for component footprints in the netlist but not on the board.
|
|
|
|
for( unsigned ii = 0; ii < netlist.GetCount(); ii++ )
|
|
|
|
{
|
|
|
|
component = netlist.GetComponent( ii );
|
|
|
|
|
|
|
|
module = pcb->FindModuleByReference( component->GetReference() );
|
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
{
|
|
|
|
aMissing.Add( component->GetReference() );
|
|
|
|
aMissing.Add( component->GetValue() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search for component footprints found on board but not in netlist.
|
|
|
|
module = pcb->m_Modules;
|
|
|
|
|
|
|
|
for( ; module != NULL; module = module->Next() )
|
|
|
|
{
|
|
|
|
|
|
|
|
component = netlist.GetComponentByReference( module->GetReference() );
|
|
|
|
|
|
|
|
if( component == NULL )
|
|
|
|
aNotInNetlist.push_back( module );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|