2012-02-09 20:33:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-09-11 19:03:21 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2012-02-09 20:33:38 +00:00
|
|
|
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
2012-09-11 19:03:21 +00:00
|
|
|
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
|
2012-02-09 20:33:38 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file modview_frame.cpp
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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 <pgm_base.h>
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
#include <kiway.h>
|
2013-09-26 17:22:35 +00:00
|
|
|
#include <gr_basic.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <3d_viewer.h>
|
|
|
|
#include <pcbcommon.h>
|
2013-09-26 17:22:35 +00:00
|
|
|
#include <dialog_helpers.h>
|
2013-01-12 17:32:24 +00:00
|
|
|
#include <msgpanel.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2013-05-20 14:49:20 +00:00
|
|
|
#include <fp_lib_table.h>
|
|
|
|
#include <fpid.h>
|
|
|
|
#include <confirm.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
|
|
|
#include <modview_frame.h>
|
|
|
|
#include <footprint_info.h>
|
|
|
|
|
|
|
|
#include <hotkeys.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2013-04-11 18:29:56 +00:00
|
|
|
#include <pcbnew_config.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
|
2013-09-26 17:22:35 +00:00
|
|
|
#define NEXT_PART 1
|
|
|
|
#define NEW_PART 0
|
|
|
|
#define PREVIOUS_PART -1
|
|
|
|
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
/**
|
|
|
|
* Save previous component library viewer state.
|
|
|
|
*/
|
|
|
|
wxString FOOTPRINT_VIEWER_FRAME::m_libraryName;
|
|
|
|
wxString FOOTPRINT_VIEWER_FRAME::m_footprintName;
|
|
|
|
|
|
|
|
/// When the viewer is used to select a component in schematic, the selected component is here.
|
|
|
|
wxString FOOTPRINT_VIEWER_FRAME::m_selectedFootprintName;
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// Window events
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_CLOSE( FOOTPRINT_VIEWER_FRAME::OnCloseWindow )
|
|
|
|
EVT_SIZE( FOOTPRINT_VIEWER_FRAME::OnSize )
|
|
|
|
EVT_ACTIVATE( FOOTPRINT_VIEWER_FRAME::OnActivate )
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// Toolbar events
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_SELECT_LIB,
|
|
|
|
FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary )
|
|
|
|
EVT_TOOL( ID_MODVIEW_SELECT_PART,
|
|
|
|
FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint )
|
|
|
|
EVT_TOOL( ID_MODVIEW_NEXT,
|
2013-09-26 17:22:35 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_PREVIOUS,
|
2013-09-26 17:22:35 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_FOOTPRINT_EXPORT_TO_BOARD,
|
|
|
|
FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint )
|
2012-02-10 08:49:43 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_SHOW_3D_VIEW, FOOTPRINT_VIEWER_FRAME::Show3D_Frame )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// listbox events
|
2012-02-09 20:33:38 +00:00
|
|
|
EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList )
|
|
|
|
EVT_LISTBOX( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList )
|
2013-02-14 21:20:56 +00:00
|
|
|
EVT_LISTBOX_DCLICK( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset )
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This emulates the zoom menu entries found in the other KiCad applications.
|
|
|
|
* The library viewer does not have any menus so add an accelerator table to
|
|
|
|
* the main frame.
|
|
|
|
*/
|
|
|
|
static wxAcceleratorEntry accels[] =
|
|
|
|
{
|
|
|
|
wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F1, ID_ZOOM_IN ),
|
|
|
|
wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F2, ID_ZOOM_OUT ),
|
|
|
|
wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F3, ID_ZOOM_REDRAW ),
|
|
|
|
wxAcceleratorEntry( wxACCEL_NORMAL, WXK_F4, ID_POPUP_ZOOM_CENTER ),
|
|
|
|
wxAcceleratorEntry( wxACCEL_NORMAL, WXK_HOME, ID_ZOOM_PAGE ),
|
|
|
|
wxAcceleratorEntry( wxACCEL_NORMAL, WXK_SPACE, ID_SET_RELATIVE_OFFSET )
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-01-03 23:19:54 +00:00
|
|
|
#define EXTRA_BORDER_SIZE 2
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-03 23:19:54 +00:00
|
|
|
#define FOOTPRINT_VIEWER_FRAME_NAME wxT( "ModViewFrame" )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) :
|
|
|
|
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
|
* 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
|
|
|
wxDefaultPosition, wxDefaultSize,
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ?
|
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT :
|
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE,
|
* 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
|
|
|
GetFootprintViewerFrameName() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
wxASSERT( aFrameType==FRAME_PCB_MODULE_VIEWER || aFrameType==FRAME_PCB_MODULE_VIEWER_MODAL );
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL )
|
|
|
|
SetModal( true );
|
|
|
|
|
2014-01-03 23:19:54 +00:00
|
|
|
wxAcceleratorTable table( DIM( accels ), accels );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
m_FrameName = GetFootprintViewerFrameName();
|
2012-02-09 20:33:38 +00:00
|
|
|
m_configPath = wxT( "FootprintViewer" );
|
2014-01-27 06:41:40 +00:00
|
|
|
m_showAxis = true; // true to draw axis.
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
2012-02-13 14:27:34 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
SetIcon( icon );
|
|
|
|
|
|
|
|
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
|
2014-01-27 06:41:40 +00:00
|
|
|
|
|
|
|
m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST,
|
2014-01-29 17:01:42 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
|
|
|
m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST,
|
2014-01-29 17:01:42 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
m_selectedFootprintName.Empty();
|
|
|
|
|
|
|
|
SetBoard( new BOARD() );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2012-02-26 18:49:00 +00:00
|
|
|
// Ensure all layers and items are visible:
|
|
|
|
GetBoard()->SetVisibleAlls();
|
2013-09-24 18:45:57 +00:00
|
|
|
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
GetScreen()->m_Center = true; // Center coordinate origins on screen.
|
* 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() );
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
2014-01-28 01:29:26 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
|
|
|
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
|
|
|
|
ReCreateLibraryList();
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
// If a footprint was previously loaded, reload it
|
2012-02-09 20:33:38 +00:00
|
|
|
if( !m_libraryName.IsEmpty() && !m_footprintName.IsEmpty() )
|
2013-05-20 14:49:20 +00:00
|
|
|
{
|
|
|
|
FPID id;
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2013-09-08 18:31:21 +00:00
|
|
|
id.SetLibNickname( m_libraryName );
|
|
|
|
id.SetFootprintName( m_footprintName );
|
2013-05-20 14:49:20 +00:00
|
|
|
GetBoard()->Add( loadFootprint( id ) );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( m_canvas )
|
|
|
|
m_canvas->SetAcceleratorTable( table );
|
|
|
|
|
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2014-01-29 17:01:42 +00:00
|
|
|
wxSize minsize(100,-1); // Min size of list boxes
|
|
|
|
|
2013-12-07 00:33:16 +00:00
|
|
|
// Main toolbar is initially docked at the top of the main window and dockable on any side.
|
|
|
|
// The close button is disable because the footprint viewer has no main menu to re-enable it.
|
|
|
|
// The tool bar will only be dockable on the top or bottom of the main frame window. This is
|
|
|
|
// most likely due to the fact that the other windows are not dockable and are preventing the
|
|
|
|
// tool bar from docking on the right and left.
|
|
|
|
wxAuiPaneInfo toolbarPaneInfo;
|
2014-01-27 06:41:40 +00:00
|
|
|
toolbarPaneInfo.Name( wxT( "m_mainToolBar" ) ).ToolbarPane().Top().CloseButton( false );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
EDA_PANEINFO info;
|
|
|
|
info.InfoToolbarPane();
|
|
|
|
|
|
|
|
EDA_PANEINFO mesg;
|
|
|
|
mesg.MessageToolbarPane();
|
|
|
|
|
2013-12-07 00:33:16 +00:00
|
|
|
// Manage main toolbar, top pane
|
|
|
|
m_auimgr.AddPane( m_mainToolBar, toolbarPaneInfo );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-12-07 00:33:16 +00:00
|
|
|
// Manage the list of libraries, left pane.
|
2014-01-13 15:09:52 +00:00
|
|
|
m_auimgr.AddPane( m_libList,
|
|
|
|
wxAuiPaneInfo( info ).Name( wxT( "m_libList" ) )
|
2014-01-29 17:01:42 +00:00
|
|
|
.Left().Row( 1 ).MinSize( minsize ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-12-07 00:33:16 +00:00
|
|
|
// Manage the list of footprints, center pane.
|
2014-01-13 15:09:52 +00:00
|
|
|
m_auimgr.AddPane( m_footprintList,
|
|
|
|
wxAuiPaneInfo( info ).Name( wxT( "m_footprintList" ) )
|
2014-01-29 17:01:42 +00:00
|
|
|
.Left().Row( 2 ).MinSize( minsize ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-12-07 00:33:16 +00:00
|
|
|
// Manage the draw panel, right pane.
|
2012-02-09 20:33:38 +00:00
|
|
|
m_auimgr.AddPane( m_canvas,
|
2014-01-29 17:01:42 +00:00
|
|
|
wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-12-07 00:33:16 +00:00
|
|
|
// Manage the message panel, bottom pane.
|
2012-02-09 20:33:38 +00:00
|
|
|
m_auimgr.AddPane( m_messagePanel,
|
2013-12-07 00:33:16 +00:00
|
|
|
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom() );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
if( !m_perspective.IsEmpty() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
// Restore last saved sizes, pos and other params
|
|
|
|
// However m_mainToolBar size cannot be set to its last saved size
|
|
|
|
// because the actual size change depending on the way modview was called:
|
|
|
|
// the tool to export the current footprint exist or not.
|
|
|
|
// and the saved size is not always OK
|
|
|
|
// the trick is to get the default toolbar size, and set the size after
|
|
|
|
// calling LoadPerspective
|
|
|
|
wxSize tbsize = m_mainToolBar->GetSize();
|
|
|
|
m_auimgr.LoadPerspective( m_perspective, false );
|
|
|
|
m_auimgr.GetPane( m_mainToolBar ).BestSize( tbsize );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2014-01-28 01:29:26 +00:00
|
|
|
#if 0 // no.
|
|
|
|
// Set min size (overwrite params read in LoadPerspective(), if any)
|
2014-01-13 15:09:52 +00:00
|
|
|
m_auimgr.GetPane( m_libList ).MinSize( minsize );
|
|
|
|
m_auimgr.GetPane( m_footprintList ).MinSize( minsize );
|
2014-01-28 01:29:26 +00:00
|
|
|
#endif
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
// after changing something to the aui manager,
|
|
|
|
// call Update()() to reflect the changes
|
|
|
|
m_auimgr.Update();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
// Now Drawpanel is sized, we can use BestZoom to show the component (if any)
|
|
|
|
#ifdef USE_WX_GRAPHICS_CONTEXT
|
|
|
|
GetScreen()->SetZoom( BestZoom() );
|
|
|
|
#else
|
|
|
|
Zoom_Automatique( false );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Show( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
|
|
|
|
{
|
2012-02-10 08:49:43 +00:00
|
|
|
if( m_Draw3DFrame )
|
|
|
|
m_Draw3DFrame->Destroy();
|
2012-09-12 09:53:11 +00:00
|
|
|
}
|
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
|
2012-09-12 09:53:11 +00:00
|
|
|
const wxChar* FOOTPRINT_VIEWER_FRAME::GetFootprintViewerFrameName()
|
|
|
|
{
|
|
|
|
return FOOTPRINT_VIEWER_FRAME_NAME;
|
|
|
|
}
|
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|
|
|
{
|
2014-05-04 18:22:27 +00:00
|
|
|
DBG(printf( "%s:\n", __func__ );)
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( IsModal() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// Only dismiss a modal frame once, so that the return values set by
|
|
|
|
// the prior DismissModal() are not bashed for ShowModal().
|
|
|
|
if( !IsDismissed() )
|
|
|
|
DismissModal( false );
|
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
// window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
|
|
|
|
{
|
|
|
|
if( m_auimgr.GetManagedWindow() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
|
|
|
|
SizeEv.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
GetScreen()->m_O_Curseur = GetCrossHairPosition();
|
2012-02-09 20:33:38 +00:00
|
|
|
UpdateStatusBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
m_libList->Clear();
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
std::vector< wxString > nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
for( unsigned ii = 0; ii < nicknames.size(); ii++ )
|
|
|
|
m_libList->Append( nicknames[ii] );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
// Search for a previous selection:
|
2014-01-13 15:09:52 +00:00
|
|
|
int index = m_libList->FindString( m_libraryName );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( index != wxNOT_FOUND )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
m_libList->SetSelection( index, true );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-27 06:41:40 +00:00
|
|
|
// If not found, clear current library selection because it can be
|
|
|
|
// deleted after a configuration change.
|
2012-02-09 20:33:38 +00:00
|
|
|
m_libraryName = wxEmptyString;
|
|
|
|
m_footprintName = wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReCreateFootprintList();
|
|
|
|
ReCreateHToolbar();
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
m_footprintList->Clear();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( m_libraryName.IsEmpty() )
|
|
|
|
{
|
|
|
|
m_footprintName = wxEmptyString;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-22 00:28:02 +00:00
|
|
|
FOOTPRINT_LIST fp_info_list;
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
fp_info_list.ReadFootprintFiles( Prj().PcbFootprintLibs(), &m_libraryName );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2013-12-09 18:09:58 +00:00
|
|
|
if( fp_info_list.GetErrorCount() )
|
2013-09-22 00:28:02 +00:00
|
|
|
{
|
2013-12-09 18:09:58 +00:00
|
|
|
fp_info_list.DisplayErrors( this );
|
2013-09-22 00:28:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-12-09 18:09:58 +00:00
|
|
|
BOOST_FOREACH( const FOOTPRINT_INFO& footprint, fp_info_list.GetList() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-01-27 06:41:40 +00:00
|
|
|
m_footprintList->Append( footprint.GetFootprintName() );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2013-09-22 00:28:02 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
int index = m_footprintList->FindString( m_footprintName );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( index == wxNOT_FOUND )
|
|
|
|
m_footprintName = wxEmptyString;
|
|
|
|
else
|
2014-01-13 15:09:52 +00:00
|
|
|
m_footprintList->SetSelection( index, true );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
int ii = m_libList->GetSelection();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
wxString name = m_libList->GetString( ii );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( m_libraryName == name )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_libraryName = name;
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
ReCreateFootprintList();
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2012-02-09 20:33:38 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
if( m_footprintList->GetCount() == 0 )
|
2013-09-22 17:20:46 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
int ii = m_footprintList->GetSelection();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( ii < 0 )
|
|
|
|
return;
|
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
wxString name = m_footprintList->GetString( ii );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( m_footprintName.CmpNoCase( name ) != 0 )
|
|
|
|
{
|
|
|
|
m_footprintName = name;
|
|
|
|
SetCurItem( NULL );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
// Delete the current footprint
|
|
|
|
GetBoard()->m_Modules.DeleteAll();
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
FPID id;
|
2013-09-08 18:31:21 +00:00
|
|
|
id.SetLibNickname( m_libraryName );
|
|
|
|
id.SetFootprintName( m_footprintName );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
GetBoard()->Add( loadFootprint( id ) );
|
|
|
|
}
|
2014-04-04 14:57:26 +00:00
|
|
|
catch( const IO_ERROR& ioe )
|
2013-05-20 14:49:20 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "Could not load footprint \"%s\" from library \"%s\".\n\n"
|
|
|
|
"Error %s." ), GetChars( m_footprintName ), GetChars( m_libraryName ),
|
|
|
|
GetChars( ioe.errorText ) );
|
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2012-02-09 20:33:38 +00:00
|
|
|
Zoom_Automatique( false );
|
|
|
|
m_canvas->Refresh();
|
2012-02-10 08:49:43 +00:00
|
|
|
Update3D_Frame();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2013-02-14 21:20:56 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& event )
|
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
if( IsModal() )
|
2013-02-14 21:20:56 +00:00
|
|
|
{
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// @todo(DICK)
|
2013-02-14 21:20:56 +00:00
|
|
|
ExportSelectedFootprint( event );
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2013-02-14 21:20:56 +00:00
|
|
|
// Prevent the double click from being as a single mouse button release
|
|
|
|
// event in the parent window which would cause the part to be parked
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// rather than staying in move mode.
|
2013-02-14 21:20:56 +00:00
|
|
|
// Remember the mouse button will be released in the parent window
|
2013-09-24 18:45:57 +00:00
|
|
|
// thus creating a mouse button release event which should be ignored
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
PCB_EDIT_FRAME* pcbframe = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
|
|
|
|
|
|
|
|
// The parent may not be the board editor:
|
|
|
|
if( pcbframe )
|
|
|
|
{
|
|
|
|
pcbframe->SkipNextLeftButtonReleaseEvent();
|
|
|
|
}
|
2013-02-14 21:20:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
int ii = m_footprintList->GetSelection();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( ii >= 0 )
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
{
|
|
|
|
wxString fp_name = m_footprintList->GetString( ii );
|
|
|
|
|
|
|
|
// @todo(DICK) assign to static now, later PROJECT retained string.
|
|
|
|
m_selectedFootprintName = fp_name;
|
|
|
|
|
|
|
|
FPID fpid;
|
|
|
|
|
|
|
|
fpid.SetLibNickname( GetSelectedLibrary() );
|
|
|
|
fpid.SetFootprintName( fp_name );
|
|
|
|
|
|
|
|
DismissModal( true, fpid.Format() );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
else
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
{
|
2012-02-09 20:33:38 +00:00
|
|
|
m_selectedFootprintName.Empty();
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
DismissModal( false );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
Close( 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
|
|
|
void FOOTPRINT_VIEWER_FRAME::LoadSettings( wxConfigBase* aCfg )
|
2012-02-09 20:33: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
|
|
|
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
2012-02-09 20:33: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
|
|
|
void FOOTPRINT_VIEWER_FRAME::SaveSettings( wxConfigBase* aCfg )
|
2012-02-09 20:33: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
|
|
|
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::OnActivate( event );
|
|
|
|
|
|
|
|
// Ensure we do not have old selection:
|
2012-02-10 15:31:11 +00:00
|
|
|
if( ! m_FrameIsActive )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_selectedFootprintName.Empty();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2012-02-10 15:31:11 +00:00
|
|
|
// Ensure we have the right library list:
|
2014-05-09 18:35:48 +00:00
|
|
|
std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
|
2013-09-24 18:45:57 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
if( libNicknames.size() == m_libList->GetCount() )
|
2013-09-24 18:45:57 +00:00
|
|
|
{
|
|
|
|
unsigned ii;
|
|
|
|
|
|
|
|
for( ii = 0; ii < libNicknames.size(); ii++ )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
if( libNicknames[ii] != m_libList->GetString( ii ) )
|
2013-09-24 18:45:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ii == libNicknames.size() )
|
|
|
|
return;
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2012-02-10 15:31:11 +00:00
|
|
|
// If we are here, the library list has changed, rebuild it
|
|
|
|
ReCreateLibraryList();
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
|
|
|
|
{
|
|
|
|
wxRealPoint gridSize;
|
|
|
|
wxPoint oldpos;
|
|
|
|
PCB_SCREEN* screen = GetScreen();
|
|
|
|
wxPoint pos = aPosition;
|
|
|
|
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
pos = GetNearestGridPosition( pos );
|
|
|
|
oldpos = GetCrossHairPosition();
|
2012-02-09 20:33:38 +00:00
|
|
|
gridSize = screen->GetGridSize();
|
|
|
|
|
|
|
|
switch( aHotKey )
|
|
|
|
{
|
|
|
|
case WXK_F1:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_IN );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_F2:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_OUT );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_F3:
|
|
|
|
cmd.SetId( ID_ZOOM_REDRAW );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_F4:
|
|
|
|
cmd.SetId( ID_POPUP_ZOOM_CENTER );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_HOME:
|
|
|
|
cmd.SetId( ID_ZOOM_PAGE );
|
|
|
|
GetEventHandler()->ProcessEvent( cmd );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ' ':
|
2013-08-03 05:15:23 +00:00
|
|
|
screen->m_O_Curseur = GetCrossHairPosition();
|
2012-02-09 20:33:38 +00:00
|
|
|
break;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case WXK_NUMPAD8: // cursor moved up
|
2012-02-09 20:33:38 +00:00
|
|
|
case WXK_UP:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.y -= KiROUND( gridSize.y );
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
|
|
|
break;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case WXK_NUMPAD2: // cursor moved down
|
2012-02-09 20:33:38 +00:00
|
|
|
case WXK_DOWN:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.y += KiROUND( gridSize.y );
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
|
|
|
break;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case WXK_NUMPAD4: // cursor moved left
|
2012-02-09 20:33:38 +00:00
|
|
|
case WXK_LEFT:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.x -= KiROUND( gridSize.x );
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
|
|
|
break;
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
case WXK_NUMPAD6: // cursor moved right
|
2012-02-09 20:33:38 +00:00
|
|
|
case WXK_RIGHT:
|
// Dick Hollenbeck's KiROUND R&D
// This provides better project control over rounding to int from double
// than wxRound() did. This scheme provides better logging in Debug builds
// and it provides for compile time calculation of constants.
#include <stdio.h>
#include <assert.h>
#include <limits.h>
//-----<KiROUND KIT>------------------------------------------------------------
/**
* KiROUND
* rounds a floating point number to an int using
* "round halfway cases away from zero".
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
static inline int KiRound( double v, int line, const char* filename )
{
v = v < 0 ? v - 0.5 : v + 0.5;
if( v > INT_MAX + 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v );
}
else if( v < INT_MIN - 0.5 )
{
printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v );
}
return int( v );
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#endif
//-----</KiROUND KIT>-----------------------------------------------------------
// Only a macro is compile time calculated, an inline function causes a static constructor
// in a situation like this.
// Therefore the Release build is best done with a MACRO not an inline function.
int Computed = KiROUND( 14.3 * 8 );
int main( int argc, char** argv )
{
for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 )
{
int i = KiROUND( d );
printf( "t: %d %.16g\n", i, d );
}
return 0;
}
2012-04-19 06:55:45 +00:00
|
|
|
pos.x += KiROUND( gridSize.x );
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->MoveCursor( pos );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( pos );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
if( oldpos != GetCrossHairPosition() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
pos = GetCrossHairPosition();
|
|
|
|
SetCrossHairPosition( oldpos );
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->CrossHairOff( aDC );
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( pos );
|
2012-02-09 20:33:38 +00:00
|
|
|
m_canvas->CrossHairOn( aDC );
|
|
|
|
|
|
|
|
if( m_canvas->IsMouseCaptured() )
|
|
|
|
{
|
|
|
|
m_canvas->CallMouseCapture( aDC, aPosition, 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
UpdateStatusBar(); // Display new cursor coordinates
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2012-02-10 08:49:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_Draw3DFrame )
|
|
|
|
{
|
|
|
|
// Raising the window does not show the window on Windows if iconized.
|
|
|
|
// This should work on any platform.
|
|
|
|
if( m_Draw3DFrame->IsIconized() )
|
|
|
|
m_Draw3DFrame->Iconize( false );
|
|
|
|
|
|
|
|
m_Draw3DFrame->Raise();
|
|
|
|
|
|
|
|
// Raising the window does not set the focus on Linux. This should work on any platform.
|
|
|
|
if( wxWindow::FindFocus() != m_Draw3DFrame )
|
|
|
|
m_Draw3DFrame->SetFocus();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
* 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_Draw3DFrame = new EDA_3D_FRAME( &Kiway(), this, wxEmptyString );
|
2012-02-10 15:31:11 +00:00
|
|
|
Update3D_Frame( false );
|
2012-02-10 08:49:43 +00:00
|
|
|
m_Draw3DFrame->Show( true );
|
|
|
|
}
|
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2012-02-10 15:31:11 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
|
2012-02-10 08:49:43 +00:00
|
|
|
{
|
|
|
|
if( m_Draw3DFrame == NULL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString frm3Dtitle;
|
|
|
|
frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_footprintName ) );
|
|
|
|
m_Draw3DFrame->SetTitle( frm3Dtitle );
|
2012-02-10 15:31:11 +00:00
|
|
|
|
|
|
|
if( aForceReloadFootprint )
|
|
|
|
{
|
|
|
|
m_Draw3DFrame->ReloadRequest();
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2012-02-10 15:31:11 +00:00
|
|
|
// Force 3D screen refresh immediately
|
|
|
|
if( GetBoard()->m_Modules )
|
|
|
|
m_Draw3DFrame->NewDisplay();
|
|
|
|
}
|
2012-02-10 08:49:43 +00:00
|
|
|
}
|
2013-04-11 18:29:56 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2013-04-11 18:29:56 +00:00
|
|
|
EDA_COLOR_T FOOTPRINT_VIEWER_FRAME::GetGridColor() const
|
|
|
|
{
|
|
|
|
return g_ColorsSettings.GetItemColor( GRID_VISIBLE );
|
|
|
|
}
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_MODVIEW_NEXT:
|
|
|
|
SelectAndViewFootprint( NEXT_PART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODVIEW_PREVIOUS:
|
|
|
|
SelectAndViewFootprint( PREVIOUS_PART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxT( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " ) +
|
|
|
|
event.GetId() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FOOTPRINT_VIEWER_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::UpdateTitle()
|
2013-09-26 17:22:35 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
msg = _( "Library Browser" );
|
|
|
|
msg << wxT( " [" );
|
|
|
|
|
|
|
|
if( ! m_libraryName.IsEmpty() )
|
|
|
|
msg << m_libraryName;
|
|
|
|
else
|
|
|
|
msg += _( "no library selected" );
|
|
|
|
|
|
|
|
msg << wxT( "]" );
|
|
|
|
|
|
|
|
SetTitle( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
|
|
|
|
{
|
2014-01-27 06:41:40 +00:00
|
|
|
wxString selection = SelectLibrary( m_libraryName );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
if( !!selection && selection != m_libraryName )
|
2013-09-26 17:22:35 +00:00
|
|
|
{
|
2014-01-27 06:41:40 +00:00
|
|
|
m_libraryName = selection;
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
|
|
|
ReCreateFootprintList();
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
int id = m_libList->FindString( m_libraryName );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
if( id >= 0 )
|
|
|
|
m_libList->SetSelection( id );
|
|
|
|
}
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
|
|
|
{
|
2014-05-09 18:35:48 +00:00
|
|
|
#if 0 // cannot remember why this is here
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
// The PCB_EDIT_FRAME may not be the FOOTPRINT_VIEW_FRAME's parent,
|
|
|
|
// so use Kiway().Player() to fetch.
|
|
|
|
PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB, true );
|
2014-05-09 18:35:48 +00:00
|
|
|
(void*) parent;
|
|
|
|
#endif
|
Modular-Kicad milestone B), major portions:
*) Rework the set language support, simplify it by using KIWAY. Now any major
frame with a "change language" menu can change the language for all KIWAY_PLAYERs
in the whole KIWAY. Multiple KIWAYs are not supported yet.
*) Simplify "modal wxFrame" support, and add that support exclusively to
KIWAY_PLAYER where it is inherited by all derivatives. The function
KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable.
*) Remove the requirements and assumptions that the wxFrame hierarchy always
had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers
and editors. This is no longer the case, nor required.
*) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the
KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame
quickly. It also gives control to the KIWAY as to frame hierarchical
relationships.
*) Change single_top to use the KIWAY for loading a KIFACE and instantiating
the single KIWAY_PLAYER, see bullet immediately above.
*) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this
gives the KIFACEs a chance to save their final configuration dope to disk.
*) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and
these modal frames are distinctly different than their non-modal equivalents.
KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor,
so this is another important reason for having a dedicated FRAME_T for each
modal wxFrame.
On balance, more lines were deleted than were added to achieve all this.
2014-05-03 17:40:19 +00:00
|
|
|
|
2013-09-26 17:22:35 +00:00
|
|
|
wxString libname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
|
|
|
|
MODULE* oldmodule = GetBoard()->m_Modules;
|
2014-05-09 18:35:48 +00:00
|
|
|
MODULE* module = LoadModuleFromLibrary( libname, Prj().PcbFootprintLibs(), false );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
module->SetPosition( wxPoint( 0, 0 ) );
|
|
|
|
|
|
|
|
// Only one footprint allowed: remove the previous footprint (if exists)
|
|
|
|
if( oldmodule )
|
|
|
|
{
|
|
|
|
GetBoard()->Remove( oldmodule );
|
|
|
|
delete oldmodule;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_footprintName = FROM_UTF8( module->GetFPID().GetFootprintName().c_str() );
|
|
|
|
module->ClearFlags();
|
|
|
|
SetCurItem( NULL );
|
|
|
|
|
|
|
|
Zoom_Automatique( false );
|
|
|
|
m_canvas->Refresh();
|
|
|
|
Update3D_Frame();
|
2014-01-13 15:09:52 +00:00
|
|
|
m_footprintList->SetStringSelection( m_footprintName );
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
|
|
|
|
{
|
|
|
|
wxString fullname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
|
|
|
|
return fullname;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
|
|
|
|
{
|
2014-01-27 07:23:02 +00:00
|
|
|
if( !m_libraryName )
|
2013-09-26 17:22:35 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
int selection = m_footprintList->FindString( m_footprintName );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( aMode == NEXT_PART )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
if( selection != wxNOT_FOUND && selection < (int)m_footprintList->GetCount()-1 )
|
2013-09-26 17:22:35 +00:00
|
|
|
selection++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aMode == PREVIOUS_PART )
|
|
|
|
{
|
|
|
|
if( selection != wxNOT_FOUND && selection > 0 )
|
|
|
|
selection--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( selection != wxNOT_FOUND )
|
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
m_footprintList->SetSelection( selection );
|
|
|
|
m_footprintName = m_footprintList->GetString( selection );
|
2013-09-26 17:22:35 +00:00
|
|
|
SetCurItem( NULL );
|
|
|
|
|
|
|
|
// Delete the current footprint
|
|
|
|
GetBoard()->m_Modules.DeleteAll();
|
2014-01-27 07:23:02 +00:00
|
|
|
|
2014-05-09 18:35:48 +00:00
|
|
|
MODULE* footprint = Prj().PcbFootprintLibs()->FootprintLoad( m_libraryName, m_footprintName );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
GetBoard()->Add( footprint, ADD_APPEND );
|
|
|
|
|
|
|
|
Update3D_Frame();
|
|
|
|
}
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2013-09-26 17:22:35 +00:00
|
|
|
Zoom_Automatique( false );
|
|
|
|
m_canvas->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
|
|
|
{
|
|
|
|
if( !GetBoard() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_canvas->DrawBackGround( DC );
|
|
|
|
GetBoard()->Draw( m_canvas, DC, GR_COPY );
|
|
|
|
|
|
|
|
MODULE* module = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
m_canvas->DrawCrossHair( DC );
|
|
|
|
|
|
|
|
ClearMsgPanel();
|
|
|
|
|
|
|
|
if( module )
|
|
|
|
SetMsgPanel( module );
|
|
|
|
}
|