kicad/cvpcb/cvpcb_mainframe.cpp

991 lines
28 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file cvframe.cpp
*/
#include <fctsys.h>
#include <build_version.h>
#include <kiway_express.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 <pgm_base.h>
#include <kiface_i.h>
#include <macros.h>
#include <confirm.h>
#include <eda_doc.h>
#include <eda_dde.h>
#include <gestfich.h>
#include <html_messagebox.h>
#include <wildcards_and_files_ext.h>
#include <fp_lib_table.h>
#include <netlist_reader.h>
#include <bitmaps.h>
#include <cvpcb_mainframe.h>
#include <cvpcb.h>
#include <listview_classes.h>
#include <invoke_pcb_dialog.h>
#include <class_DisplayFootprintsFrame.h>
#include <cvpcb_id.h>
2007-05-06 16:03:28 +00:00
#define FRAME_MIN_SIZE_X 450
#define FRAME_MIN_SIZE_Y 300
///@{
/// \ingroup config
/// Nonzero iff cvpcb should be kept open after saving files
static const wxString KeepCvpcbOpenEntry = "KeepCvpcbOpen";
static const wxString FootprintDocFileEntry = "footprints_doc_file";
static const wxString FilterFootprintEntry = "FilterFootprint";
///@}
BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, KIWAY_PLAYER )
// Menu events
EVT_MENU( wxID_SAVE, CVPCB_MAINFRAME::SaveQuitCvpcb )
EVT_MENU( wxID_EXIT, CVPCB_MAINFRAME::OnQuit )
EVT_MENU( wxID_HELP, CVPCB_MAINFRAME::GetKicadHelp )
EVT_MENU( wxID_ABOUT, CVPCB_MAINFRAME::GetKicadAbout )
EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, CVPCB_MAINFRAME::OnConfigurePaths )
EVT_MENU( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnKeepOpenOnSave )
EVT_MENU( ID_CVPCB_EQUFILES_LIST_EDIT, CVPCB_MAINFRAME::OnEditEquFilesList )
// Toolbar events
EVT_TOOL( ID_CVPCB_QUIT, CVPCB_MAINFRAME::OnQuit )
EVT_TOOL( ID_CVPCB_LIB_TABLE_EDIT, CVPCB_MAINFRAME::OnEditFootprintLibraryTable )
EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, CVPCB_MAINFRAME::DisplayModule )
EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, CVPCB_MAINFRAME::ToFirstNA )
EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, CVPCB_MAINFRAME::ToPreviousNA )
EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, CVPCB_MAINFRAME::DelAssociations )
EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, CVPCB_MAINFRAME::AutomaticFootprintMatching )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME,
CVPCB_MAINFRAME::OnSelectFilteringFootprint )
2016-02-25 14:38:08 +00:00
EVT_TEXT( ID_CVPCB_FILTER_TEXT_EDIT, CVPCB_MAINFRAME::OnEnterFilteringText )
// Frame events
EVT_CLOSE( CVPCB_MAINFRAME::OnCloseWindow )
EVT_SIZE( CVPCB_MAINFRAME::OnSize )
// UI event handlers
EVT_UPDATE_UI( ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE, CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave )
2016-02-25 10:35:27 +00:00
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyKeywords)
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST, CVPCB_MAINFRAME::OnFilterFPbyPinCount )
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST, CVPCB_MAINFRAME::OnFilterFPbyLibrary )
EVT_UPDATE_UI( ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME, CVPCB_MAINFRAME::OnFilterFPbyKeyName )
END_EVENT_TABLE()
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
* 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
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, wxT( "CvPCB" ), wxDefaultPosition,
* 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
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
2007-05-06 16:03:28 +00:00
{
m_compListBox = NULL;
m_footprintListBox = NULL;
m_libListBox = NULL;
m_mainToolBar = NULL;
m_modified = false;
m_keepCvpcbOpen = false;
m_undefinedComponentCnt = 0;
m_skipComponentSelect = false;
m_filteringOptions = 0;
m_tcFilterString = NULL;
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
* this is of the responsibility to users to create this file
* if they want to have a list of footprints
*/
m_DocModulesFileName = DEFAULT_FOOTPRINTS_LIST_FILENAME;
2007-12-04 18:23:38 +00:00
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
SetIcon( icon );
2007-12-04 18:23:38 +00:00
SetAutoLayout( true );
2007-12-04 18:23:38 +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
LoadSettings( config() );
2007-12-04 18:23:38 +00:00
if( m_FrameSize.x < FRAME_MIN_SIZE_X )
m_FrameSize.x = FRAME_MIN_SIZE_X;
2007-12-04 18:23:38 +00:00
if( m_FrameSize.y < FRAME_MIN_SIZE_Y )
m_FrameSize.y = FRAME_MIN_SIZE_Y;
// Set minimal frame width and height
SetSizeHints( FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, -1, -1, -1, -1 );
// Frame size and position
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
2007-12-04 18:23:38 +00:00
// create the status bar
static const int dims[3] = { -1, -1, 250 };
2007-12-04 18:23:38 +00:00
CreateStatusBar( 3 );
SetStatusWidths( 3, dims );
2007-12-04 18:23:38 +00:00
ReCreateMenuBar();
2007-05-06 16:03:28 +00:00
ReCreateHToolbar();
// Create list of available modules and components of the schematic
2007-12-04 18:23:38 +00:00
BuildCmpListBox();
BuildFOOTPRINTS_LISTBOX();
BuildLIBRARY_LISTBOX();
2007-12-04 18:23:38 +00:00
m_auimgr.SetManagedWindow( this );
UpdateTitle();
EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane();
EDA_PANEINFO info;
info.InfoToolbarPane();
if( m_mainToolBar )
m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top() );
if( m_compListBox )
m_auimgr.AddPane( m_compListBox,
wxAuiPaneInfo( horiz ).Name( wxT( "m_compListBox" ) ).CentrePane() );
if( m_libListBox)
m_auimgr.AddPane( m_libListBox,
wxAuiPaneInfo( info ).Name( wxT( "m_libListBox" ) ).
Left().BestSize( (int) ( m_FrameSize.x * 0.20 ), m_FrameSize.y ) );
if( m_footprintListBox )
m_auimgr.AddPane( m_footprintListBox,
wxAuiPaneInfo( info ).Name( wxT( "m_footprintListBox" ) ).
Right().BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) );
2009-11-02 22:24:55 +00:00
m_auimgr.Update();
2007-05-06 16:03:28 +00:00
}
CVPCB_MAINFRAME::~CVPCB_MAINFRAME()
{
2009-11-02 22:24:55 +00:00
m_auimgr.UnInit();
}
* 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
void CVPCB_MAINFRAME::LoadSettings( wxConfigBase* aCfg )
{
* 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_BASE_FRAME::LoadSettings( aCfg );
aCfg->Read( KeepCvpcbOpenEntry, &m_keepCvpcbOpen, true );
* 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
aCfg->Read( FootprintDocFileEntry, &m_DocModulesFileName,
DEFAULT_FOOTPRINTS_LIST_FILENAME );
aCfg->Read( FilterFootprintEntry, &m_filteringOptions, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
* 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
}
* 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
void CVPCB_MAINFRAME::SaveSettings( wxConfigBase* aCfg )
{
EDA_BASE_FRAME::SaveSettings( aCfg );
aCfg->Write( KeepCvpcbOpenEntry, m_keepCvpcbOpen );
* 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
aCfg->Write( FootprintDocFileEntry, m_DocModulesFileName );
aCfg->Write( FilterFootprintEntry, m_filteringOptions );
2007-05-06 16:03:28 +00:00
}
2007-12-04 18:23:38 +00:00
void CVPCB_MAINFRAME::OnSize( wxSizeEvent& event )
2007-05-06 16:03:28 +00:00
{
2007-12-04 18:23:38 +00:00
event.Skip();
2007-05-06 16:03:28 +00:00
}
2007-12-04 18:23:38 +00:00
void CVPCB_MAINFRAME::OnQuit( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
Close( false );
2007-05-06 16:03:28 +00:00
}
2007-12-04 18:23:38 +00:00
void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
2007-05-06 16:03:28 +00:00
{
if( m_modified )
2007-12-04 18:23:38 +00:00
{
wxString msg = _( "Component to Footprint links modified.\nSave before exit ?" );
int ii = DisplayExitDialog( this, msg );
2007-12-04 18:23:38 +00:00
switch( ii )
{
case wxID_CANCEL:
Event.Veto();
return;
case wxID_NO:
break;
case wxID_YES:
SaveFootprintAssociation();
2007-12-04 18:23:38 +00:00
break;
}
}
// Close module display frame
if( GetFootprintViewerFrame() )
GetFootprintViewerFrame()->Close( true );
m_modified = false;
2007-12-04 18:23:38 +00:00
Destroy();
return;
2007-05-06 16:03:28 +00:00
}
void CVPCB_MAINFRAME::ChangeFocus( bool aMoveRight )
2007-05-06 16:03:28 +00:00
{
wxWindow* hasFocus = wxWindow::FindFocus();
if( aMoveRight )
{
if( hasFocus == m_libListBox )
m_compListBox->SetFocus();
else if( hasFocus == m_compListBox )
m_footprintListBox->SetFocus();
else if( hasFocus == m_footprintListBox )
m_libListBox->SetFocus();
}
else
{
if( hasFocus == m_libListBox )
m_footprintListBox->SetFocus();
else if( hasFocus == m_compListBox )
m_libListBox->SetFocus();
else if( hasFocus == m_footprintListBox )
m_compListBox->SetFocus();
}
2007-05-06 16:03:28 +00:00
}
void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
if( m_netlist.IsEmpty() )
return;
2007-12-04 18:23:38 +00:00
long first_selected = m_compListBox->GetFirstSelected();
if( first_selected < 0 )
first_selected = -1; // We will start to 0 for the first search , if no item selected
2008-10-29 23:57:35 +00:00
int candidate = -1;
for( unsigned jj = first_selected+1; jj < m_netlist.GetCount(); jj++ )
{
if( m_netlist.GetComponent( jj )->GetFPID().empty() )
{
candidate = jj;
break;
}
2007-12-04 18:23:38 +00:00
}
if( candidate >= 0 )
{
m_compListBox->DeselectAll();
m_compListBox->SetSelection( candidate );
SendMessageToEESCHEMA();
}
2007-05-06 16:03:28 +00:00
}
2007-12-04 18:23:38 +00:00
void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
if( m_netlist.IsEmpty() )
return;
2007-12-04 18:23:38 +00:00
int first_selected = m_compListBox->GetFirstSelected();
if( first_selected < 0 )
first_selected = m_compListBox->GetCount();
2007-12-04 18:23:38 +00:00
int candidate = -1;
for( int jj = first_selected-1; jj >= 0; jj-- )
{
if( m_netlist.GetComponent( jj )->GetFPID().empty() )
{
candidate = jj;
break;
}
2007-12-04 18:23:38 +00:00
}
if( candidate >= 0 )
{
m_compListBox->DeselectAll();
m_compListBox->SetSelection( candidate );
SendMessageToEESCHEMA();
}
2007-05-06 16:03:28 +00:00
}
void CVPCB_MAINFRAME::SaveQuitCvpcb( wxCommandEvent& aEvent )
2007-05-06 16:03:28 +00:00
{
SaveFootprintAssociation();
m_modified = false;
if( !m_keepCvpcbOpen )
Close( true );
2007-05-06 16:03:28 +00:00
}
2007-12-04 18:23:38 +00:00
void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
2007-12-04 18:23:38 +00:00
if( IsOK( this, _( "Delete selections" ) ) )
{
m_skipComponentSelect = true;
// Remove all selections to avoid issues when setting the fpids
m_compListBox->DeselectAll();
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
LIB_ID fpid;
m_netlist.GetComponent( i )->SetFPID( fpid );
2007-12-04 18:23:38 +00:00
SetNewPkg( wxEmptyString );
}
// Remove all selections after setting the fpids
m_compListBox->DeselectAll();
m_skipComponentSelect = false;
m_compListBox->SetSelection( 0 );
m_undefinedComponentCnt = m_netlist.GetCount();
2007-12-04 18:23:38 +00:00
}
DisplayStatus();
2007-05-06 16:03:28 +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
bool CVPCB_MAINFRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
{
return true;
2007-05-06 16:03:28 +00:00
}
void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
{
bool tableChanged = false;
int r = InvokePcbLibTableEditor( this, &GFootprintTable, Prj().PcbFootprintLibs() );
if( r & 1 )
{
wxString fileName = FP_LIB_TABLE::GetGlobalTableFileName();
try
{
GFootprintTable.Save( fileName );
tableChanged = true;
}
* 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
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format(
_( "Error occurred saving the global footprint library table:\n'%s'\n%s" ),
GetChars( fileName ),
GetChars( ioe.What() )
);
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
if( r & 2 )
{
wxString fileName = Prj().FootprintLibTblName();
try
{
Prj().PcbFootprintLibs()->Save( fileName );
tableChanged = true;
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format(
_( "Error occurred saving the project footprint library table:\n'%s'\n%s" ),
GetChars( fileName ),
GetChars( ioe.What() )
);
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
if( tableChanged )
{
wxBusyCursor dummy;
BuildLIBRARY_LISTBOX();
m_FootprintsList.ReadFootprintFiles( Prj().PcbFootprintLibs() );
}
}
void CVPCB_MAINFRAME::OnKeepOpenOnSave( wxCommandEvent& event )
{
m_keepCvpcbOpen = event.IsChecked();
}
void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
2007-05-06 16:03:28 +00:00
{
2007-12-04 18:23:38 +00:00
CreateScreenCmp();
GetFootprintViewerFrame()->RedrawScreen( wxPoint( 0, 0 ), false );
2007-05-06 16:03:28 +00:00
}
void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
2007-05-06 16:03:28 +00:00
{
if( m_skipComponentSelect )
return;
wxString libraryName;
COMPONENT* component = GetSelectedComponent();
libraryName = m_libListBox->GetSelectedLibrary();
m_footprintListBox->SetFootprints( m_FootprintsList, libraryName, component,
m_currentSearchPattern, m_filteringOptions);
refreshAfterComponentSearch (component);
}
void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
{
// Tell AuiMgr that objects are changed !
if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
// (could be not the case when starting CvPcb
m_auimgr.Update();
if( component == NULL )
return;
// Preview of the already assigned footprint.
// Find the footprint that was already chosen for this component and select it,
// but only if the selection is made from the component list or the library list.
// If the selection is made from the footprint list, do not change the current
// selected footprint.
if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
{
wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );
bool found = false;
for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
{
wxString footprintName;
wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
msg.Trim( true );
msg.Trim( false );
footprintName = msg.AfterFirst( wxChar( ' ' ) );
if( module.Cmp( footprintName ) == 0 )
{
m_footprintListBox->SetSelection( ii, true );
found = true;
break;
}
}
if( !found )
{
int ii = m_footprintListBox->GetSelection();
if ( ii >= 0 )
m_footprintListBox->SetSelection( ii, false );
if( GetFootprintViewerFrame() )
{
CreateScreenCmp();
}
}
}
SendMessageToEESCHEMA();
DisplayStatus();
2007-05-06 16:03:28 +00:00
}
void CVPCB_MAINFRAME::OnSelectFilteringFootprint( wxCommandEvent& event )
{
int option = 0;
switch( event.GetId() )
{
case ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST:
option = FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD;
break;
case ID_CVPCB_FOOTPRINT_DISPLAY_PIN_FILTERED_LIST:
option = FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT;
break;
case ID_CVPCB_FOOTPRINT_DISPLAY_BY_LIBRARY_LIST:
option = FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY;
break;
case ID_CVPCB_FOOTPRINT_DISPLAY_BY_NAME:
m_currentSearchPattern = m_tcFilterString->GetValue();
option = FOOTPRINTS_LISTBOX::FILTERING_BY_NAME;
break;
}
if( event.IsChecked() )
m_filteringOptions |= option;
else
m_filteringOptions &= ~option;
wxListEvent l_event;
2007-12-04 18:23:38 +00:00
OnSelectComponent( l_event );
}
void CVPCB_MAINFRAME::OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event )
{
event.Check( m_keepCvpcbOpen );
}
void CVPCB_MAINFRAME::OnFilterFPbyKeywords( wxUpdateUIEvent& event )
{
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD );
}
void CVPCB_MAINFRAME::OnFilterFPbyPinCount( wxUpdateUIEvent& event )
{
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT );
}
void CVPCB_MAINFRAME::OnFilterFPbyLibrary( wxUpdateUIEvent& event )
{
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY );
}
void CVPCB_MAINFRAME::OnFilterFPbyKeyName( wxUpdateUIEvent& event )
{
event.Check( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME );
}
void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
{
// Called when changing the filter string in main toolbar.
// If the option FOOTPRINTS_LISTBOX::FILTERING_BY_NAME is set, update the list of
// available footprints which match the filter
m_currentSearchPattern = m_tcFilterString->GetValue();
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) == 0 )
return;
OnSelectFilteringFootprint( aEvent );
}
void CVPCB_MAINFRAME::DisplayStatus()
{
wxString msg;
COMPONENT* component;
if( wxWindow::FindFocus() == m_compListBox || wxWindow::FindFocus() == m_libListBox )
{
msg.Printf( _( "Components: %d, unassigned: %d" ), (int) m_netlist.GetCount(),
m_undefinedComponentCnt );
SetStatusText( msg, 0 );
msg.Empty();
component = GetSelectedComponent();
if( component )
{
for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ )
{
if( msg.IsEmpty() )
msg += component->GetFootprintFilters()[ii];
else
msg += wxT( ", " ) + component->GetFootprintFilters()[ii];
}
msg = _( "Filter list: " ) + msg;
}
SetStatusText( msg, 1 );
}
else
{
wxString footprintName = GetSelectedFootprint();
FOOTPRINT_INFO* module = m_FootprintsList.GetModuleInfo( footprintName );
if( module ) // can be NULL if no netlist loaded
{
msg = _( "Description: " ) + module->GetDoc();
SetStatusText( msg, 0 );
msg = _( "Key words: " ) + module->GetKeywords();
SetStatusText( msg, 1 );
}
}
msg.Empty();
2015-01-11 18:35:02 +00:00
wxString filters;
if( m_footprintListBox )
{
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_KEYWORD ) )
2015-01-11 18:35:02 +00:00
filters = _( "key words" );
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT ) )
{
2015-01-11 18:35:02 +00:00
if( !filters.IsEmpty() )
filters += wxT( "+" );
2015-01-11 18:35:02 +00:00
filters += _( "pin count" );
}
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY ) )
{
2015-01-11 18:35:02 +00:00
if( !filters.IsEmpty() )
filters += wxT( "+" );
2015-01-11 18:35:02 +00:00
filters += _( "library" );
}
if( ( m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_NAME ) )
{
if( !filters.IsEmpty() )
filters += wxT( "+" );
filters += _( "name" );
}
2015-01-11 18:35:02 +00:00
if( filters.IsEmpty() )
msg = _( "No filtering" );
else
2015-01-11 18:35:02 +00:00
msg.Printf( _( "Filtered by %s" ), GetChars( filters ) );
msg << wxT( ": " ) << m_footprintListBox->GetCount();
SetStatusText( msg, 2 );
}
}
bool CVPCB_MAINFRAME::LoadFootprintFiles()
{
FP_LIB_TABLE* fptbl = Prj().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
// Check if there are footprint libraries in the footprint library 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
if( !fptbl || !fptbl->GetLogicalLibs().size() )
{
wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
"library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
return false;
}
{
wxBusyCursor dummy; // Let the user know something is happening.
m_FootprintsList.ReadFootprintFiles( fptbl );
}
if( m_FootprintsList.GetErrorCount() )
{
m_FootprintsList.DisplayErrors( this );
}
return true;
}
void CVPCB_MAINFRAME::UpdateTitle()
{
wxString title;
PROJECT& prj = Prj();
wxFileName fn = prj.GetProjectFullName();
2015-01-11 18:35:02 +00:00
if( fn.IsOk() && !prj.GetProjectFullName().IsEmpty() && fn.FileExists() )
{
title.Printf( L"Cvpcb \u2014 %s%s",
fn.GetFullPath(),
fn.IsFileWritable()
? wxString( wxEmptyString )
: _( " [Read Only]" ) );
}
else
{
title = "Cvpcb";
}
SetTitle( title );
}
void CVPCB_MAINFRAME::SendMessageToEESCHEMA()
{
if( m_netlist.IsEmpty() )
return;
int selection = m_compListBox->GetSelection();
if ( selection < 0 )
selection = 0;
if( m_netlist.GetComponent( selection ) == NULL )
return;
COMPONENT* component = m_netlist.GetComponent( selection );
std::string packet = StrPrintf( "$PART: \"%s\"", TO_UTF8( component->GetReference() ) );
if( Kiface().IsSingle() )
SendCommand( MSG_TO_SCH, packet.c_str() );
else
Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
}
int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
{
STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
m_netlist.Clear();
try
{
netrdr.LoadNetlist();
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.What().GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
return 1;
}
// We also remove footprint name if it is "$noname" because this is a dummy name,
// not the actual name of the footprint.
for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
{
if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
m_netlist.GetComponent( ii )->SetFPID( LIB_ID( wxEmptyString ) );
}
// Sort components by reference:
m_netlist.SortByReference();
return 0;
}
void CVPCB_MAINFRAME::CreateScreenCmp()
{
DISPLAY_FOOTPRINTS_FRAME* fpframe = GetFootprintViewerFrame();
if( !fpframe )
{
fpframe = new DISPLAY_FOOTPRINTS_FRAME( &Kiway(), this );
fpframe->Show( true );
}
else
{
if( fpframe->IsIconized() )
fpframe->Iconize( false );
// The display footprint window might be buried under some other
// windows, so CreateScreenCmp() on an existing window would not
// show any difference, leaving the user confused.
// So we want to put it to front, second after our CVPCB_MAINFRAME.
// We do this by a little dance of bringing it to front then the main
// frame back.
fpframe->Raise(); // Make sure that is visible.
Raise(); // .. but still we want the focus.
}
fpframe->InitDisplay();
}
void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX()
{
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
if( m_footprintListBox == NULL )
{
m_footprintListBox = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST,
wxDefaultPosition, wxDefaultSize );
m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
}
m_footprintListBox->SetFootprints( m_FootprintsList, wxEmptyString, NULL,
wxEmptyString, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
DisplayStatus();
}
void CVPCB_MAINFRAME::BuildCmpListBox()
{
wxString msg;
COMPONENT* component;
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
if( m_compListBox == NULL )
{
m_compListBox = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST,
wxDefaultPosition, wxDefaultSize );
m_compListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
}
m_compListBox->m_ComponentList.Clear();
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
{
component = m_netlist.GetComponent( i );
msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
GetChars( component->GetReference() ),
GetChars( component->GetValue() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
m_compListBox->m_ComponentList.Add( msg );
}
if( m_compListBox->m_ComponentList.Count() )
{
m_compListBox->SetItemCount( m_compListBox->m_ComponentList.Count() );
m_compListBox->SetSelection( 0, true );
m_compListBox->RefreshItems( 0L, m_compListBox->m_ComponentList.Count()-1 );
m_compListBox->UpdateWidth();
}
}
void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX()
{
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
if( m_libListBox == NULL )
{
m_libListBox = new LIBRARY_LISTBOX( this, ID_CVPCB_LIBRARY_LIST,
wxDefaultPosition, wxDefaultSize );
m_libListBox->SetFont( wxFont( guiFont.GetPointSize(),
wxFONTFAMILY_MODERN,
wxFONTSTYLE_NORMAL,
wxFONTWEIGHT_NORMAL ) );
}
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
if( tbl )
{
wxArrayString libNames;
std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
libNames.Add( libNickNames[ii] );
m_libListBox->SetLibraryList( libNames );
}
}
COMPONENT* CVPCB_MAINFRAME::GetSelectedComponent()
{
int selection = m_compListBox->GetSelection();
if( selection >= 0 && selection < (int) m_netlist.GetCount() )
return m_netlist.GetComponent( selection );
return NULL;
}
DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame()
{
// returns the Footprint Viewer frame, if exists, or NULL
return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>
( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) );
}
const wxString CVPCB_MAINFRAME::GetSelectedFootprint()
{
// returns the LIB_ID of the selected footprint in footprint listview
// or a empty string
return m_footprintListBox->GetSelectedFootprint();
}
void CVPCB_MAINFRAME::OnConfigurePaths( wxCommandEvent& aEvent )
{
Pgm().ConfigurePaths( this );
}
void CVPCB_MAINFRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
{
const std::string& payload = mail.GetPayload();
DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
switch( mail.Command() )
{
case MAIL_EESCHEMA_NETLIST:
ReadNetListAndLinkFiles( payload );
/* @todo
Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
*/
break;
default:
; // ignore most
}
}