2012-02-09 20:33:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-01-22 13:42:24 +00:00
|
|
|
* Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2016-10-28 13:11:23 +00:00
|
|
|
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
2018-09-11 15:28:57 +00:00
|
|
|
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-01-31 12:37:36 +00:00
|
|
|
* @file footprint_viewer_frame.cpp
|
2012-02-09 20:33:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <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>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <class_drawpanel.h>
|
2014-07-09 09:22:42 +00:00
|
|
|
#include <pcb_draw_panel_gal.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <3d_viewer/eda_3d_viewer.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-20 14:49:20 +00:00
|
|
|
#include <fp_lib_table.h>
|
2016-11-20 23:35:08 +00:00
|
|
|
#include <lib_id.h>
|
2013-05-20 14:49:20 +00:00
|
|
|
#include <confirm.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2018-02-19 00:04:03 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2018-08-11 16:04:46 +00:00
|
|
|
#include <eda_dockart.h>
|
2018-09-11 15:28:57 +00:00
|
|
|
#include <pcb_painter.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbnew_id.h>
|
2018-01-31 12:37:36 +00:00
|
|
|
#include <footprint_viewer_frame.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
#include <footprint_info.h>
|
|
|
|
|
|
|
|
#include <hotkeys.h>
|
2012-03-08 17:47:23 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2017-08-04 12:43:02 +00:00
|
|
|
#include <config_params.h>
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tool/tool_dispatcher.h>
|
2017-03-01 02:58:15 +00:00
|
|
|
#include <tool/common_tools.h>
|
2018-06-11 10:37:05 +00:00
|
|
|
#include "tools/selection_tool.h"
|
2014-07-09 09:22:43 +00:00
|
|
|
#include "tools/pcbnew_control.h"
|
2017-02-21 12:42:08 +00:00
|
|
|
#include "tools/pcb_actions.h"
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
2017-03-23 00:59:25 +00:00
|
|
|
#include <memory>
|
2016-06-29 10:23:11 +00:00
|
|
|
using namespace std::placeholders;
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
#define NEXT_PART 1
|
|
|
|
#define NEW_PART 0
|
|
|
|
#define PREVIOUS_PART -1
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
|
2014-10-15 11:40:38 +00:00
|
|
|
// Menu (and/or hotkey) events
|
|
|
|
EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
|
|
|
|
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset )
|
|
|
|
|
2017-04-13 16:36:07 +00:00
|
|
|
// Menu Help
|
|
|
|
EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
|
|
|
|
EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
|
|
|
|
EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
|
|
|
|
EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
|
|
|
|
|
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
|
2018-08-01 10:00:10 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_SELECT_PART, FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint )
|
2018-09-11 15:28:57 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_OPTIONS, FOOTPRINT_VIEWER_FRAME::InstallDisplayOptions )
|
2018-08-01 10:00:10 +00:00
|
|
|
EVT_TOOL( ID_MODVIEW_NEXT, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
|
|
|
EVT_TOOL( ID_MODVIEW_PREVIOUS, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
|
|
|
|
EVT_TOOL( ID_MODVIEW_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 )
|
2019-01-28 14:15:32 +00:00
|
|
|
EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectZoom )
|
|
|
|
EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectGrid )
|
2018-09-11 15:28:57 +00:00
|
|
|
|
|
|
|
EVT_UPDATE_UI( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectGrid )
|
|
|
|
EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectZoom )
|
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
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
2015-06-22 17:21:34 +00:00
|
|
|
/* Note:
|
2015-12-30 07:46:32 +00:00
|
|
|
* FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
|
2015-06-22 17:21:34 +00:00
|
|
|
* In modal mode:
|
|
|
|
* a tool to export the selected footprint is shown in the toolbar
|
2016-03-21 16:36:06 +00:00
|
|
|
* the style is wxFRAME_FLOAT_ON_PARENT
|
|
|
|
* Note:
|
|
|
|
* On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
|
|
|
|
* its parent frame is sometimes brought to the foreground when closing the
|
|
|
|
* LIB_VIEW_FRAME frame.
|
|
|
|
* If it still happens, it could be better to use wxSTAY_ON_TOP
|
|
|
|
* instead of wxFRAME_FLOAT_ON_PARENT
|
2015-06-22 17:21:34 +00:00
|
|
|
*/
|
2018-09-11 15:28:57 +00:00
|
|
|
|
|
|
|
#define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
|
|
|
|
#define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
|
|
|
|
#define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-01-13 15:09:52 +00:00
|
|
|
|
2018-08-03 19:41:57 +00:00
|
|
|
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent,
|
2018-09-11 15:28:57 +00:00
|
|
|
FRAME_T aFrameType ) :
|
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_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,
|
2018-09-11 15:28:57 +00:00
|
|
|
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
|
|
|
|
: NONMODAL_STYLE,
|
|
|
|
aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? FOOTPRINT_VIEWER_FRAME_NAME_MODAL
|
|
|
|
: FOOTPRINT_VIEWER_FRAME_NAME )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2016-03-21 16:36:06 +00:00
|
|
|
wxASSERT( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ||
|
|
|
|
aFrameType == FRAME_PCB_MODULE_VIEWER );
|
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
|
|
|
|
2014-05-04 18:22:27 +00:00
|
|
|
if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL )
|
|
|
|
SetModal( true );
|
|
|
|
|
2015-12-22 11:58:26 +00:00
|
|
|
// Force the frame name used in config. the footprint viewer frame has a name
|
|
|
|
// depending on aFrameType (needed to identify the frame by wxWidgets),
|
|
|
|
// but only one configuration is preferable.
|
2015-08-31 06:43:33 +00:00
|
|
|
m_configFrameName = FOOTPRINT_VIEWER_FRAME_NAME;
|
2015-12-22 11:58:26 +00:00
|
|
|
|
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 );
|
|
|
|
|
2018-02-14 22:07:59 +00:00
|
|
|
m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, NULL, wxLB_HSCROLL | wxNO_BORDER );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
|
|
|
|
0, NULL, wxLB_HSCROLL | wxNO_BORDER );
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
SetBoard( new BOARD() );
|
2015-01-10 10:27:49 +00:00
|
|
|
// In viewer, the default net clearance is not known (it depends on the actual board).
|
|
|
|
// So we do not show the default clearance, by setting it to 0
|
|
|
|
// The footprint or pad specific clearance will be shown
|
|
|
|
GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
|
2014-07-09 13:10:32 +00:00
|
|
|
|
2018-08-28 17:00:31 +00:00
|
|
|
// Don't show the default board solder mask clearance in the footprint viewer. Only the
|
|
|
|
// footprint or pad clearance setting should be shown if it is not 0.
|
|
|
|
GetBoard()->GetDesignSettings().m_SolderMaskMargin = 0;
|
|
|
|
|
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() );
|
2018-02-19 00:04:03 +00:00
|
|
|
GetGalDisplayOptions().m_axesEnabled = true;
|
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 );
|
|
|
|
|
2014-10-15 11:40:38 +00:00
|
|
|
// Menu bar is not mandatory: uncomment/comment the next line
|
|
|
|
// to add/remove the menubar
|
|
|
|
ReCreateMenuBar();
|
2012-02-09 20:33:38 +00:00
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateVToolbar();
|
|
|
|
|
|
|
|
ReCreateLibraryList();
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-07-09 09:22:43 +00:00
|
|
|
// Create GAL canvas
|
|
|
|
PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
|
2019-01-31 19:43:13 +00:00
|
|
|
GetGalDisplayOptions(),
|
|
|
|
LoadCanvasTypeSetting() );
|
2014-07-09 09:22:43 +00:00
|
|
|
SetGalCanvas( drawPanel );
|
|
|
|
|
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
|
|
|
m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
|
|
|
|
drawPanel->GetViewControls(), this );
|
2017-02-21 12:42:08 +00:00
|
|
|
m_actions = new PCB_ACTIONS();
|
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
|
2014-07-09 09:22:43 +00:00
|
|
|
drawPanel->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
|
|
|
|
m_toolManager->RegisterTool( new PCBNEW_CONTROL );
|
2018-06-11 10:37:05 +00:00
|
|
|
m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
|
2017-03-01 02:58:15 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
2017-01-30 12:21:22 +00:00
|
|
|
m_toolManager->InitTools();
|
2018-06-11 10:37:05 +00:00
|
|
|
m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
// If a footprint was previously loaded, reload it
|
2014-06-16 19:00:26 +00:00
|
|
|
if( getCurNickname().size() && getCurFootprintName().size() )
|
2013-05-20 14:49:20 +00:00
|
|
|
{
|
2016-11-20 23:35:08 +00:00
|
|
|
LIB_ID id;
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2017-07-24 19:02:59 +00:00
|
|
|
id.SetLibNickname( getCurNickname() );
|
|
|
|
id.SetLibItemName( getCurFootprintName() );
|
2013-05-20 14:49:20 +00:00
|
|
|
GetBoard()->Add( loadFootprint( id ) );
|
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-07-09 14:57:01 +00:00
|
|
|
drawPanel->DisplayBoard( m_Pcb );
|
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
// Horizontal items; layers 4 - 6
|
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
|
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
|
2014-01-29 17:01:42 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
// Vertical items; layers 1 - 3
|
|
|
|
m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
|
|
|
|
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
|
|
|
|
m_auimgr.AddPane( m_footprintList, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(1)
|
|
|
|
.CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2018-08-11 20:47:18 +00:00
|
|
|
m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
|
|
|
m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
|
2013-05-20 14:49:20 +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
|
|
|
|
2018-02-19 00:04:03 +00:00
|
|
|
GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
|
2018-09-11 15:28:57 +00:00
|
|
|
UseGalCanvas( true );
|
|
|
|
|
|
|
|
// Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
|
|
|
|
GetGalCanvas()->GetView()->SetScale( m_lastZoom );
|
|
|
|
|
2018-06-12 12:38:31 +00:00
|
|
|
updateView();
|
2017-04-13 16:28:16 +00:00
|
|
|
|
2015-06-22 17:21:34 +00:00
|
|
|
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
|
2015-07-15 08:18:48 +00:00
|
|
|
{
|
|
|
|
Raise(); // On some window managers, this is needed
|
2015-06-22 17:21:34 +00:00
|
|
|
Show( true );
|
2015-07-15 08:18:48 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
|
|
|
|
{
|
2018-09-11 15:28:57 +00:00
|
|
|
GetGalCanvas()->StopDrawing();
|
|
|
|
GetGalCanvas()->GetView()->Clear();
|
|
|
|
// Be sure any event cannot be fired after frame deletion:
|
|
|
|
GetGalCanvas()->SetEvtHandlerEnabled( false );
|
2012-09-12 09:53:11 +00:00
|
|
|
}
|
|
|
|
|
2013-09-24 18:45:57 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event )
|
|
|
|
{
|
2016-03-21 16:36:06 +00:00
|
|
|
// A workaround to avoid flicker, in modal mode when modview frame is destroyed,
|
|
|
|
// when the aui toolbar is not docked (i.e. shown in a miniframe)
|
|
|
|
// (usefull on windows only)
|
|
|
|
m_mainToolBar->SetFocus();
|
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
GetGalCanvas()->StopDrawing();
|
2014-07-09 09:22:43 +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
|
|
|
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-06-16 19:00:26 +00:00
|
|
|
int index = m_libList->FindString( getCurNickname() );
|
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.
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurNickname( wxEmptyString );
|
|
|
|
setCurFootprintName( wxEmptyString );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ReCreateFootprintList();
|
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
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
if( !getCurNickname() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurFootprintName( wxEmptyString );
|
2012-02-09 20:33:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-25 12:48:13 +00:00
|
|
|
auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
wxString nickname = getCurNickname();
|
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
if( fp_info_list->GetErrorCount() )
|
2013-09-22 00:28:02 +00:00
|
|
|
{
|
2017-03-23 00:59:25 +00:00
|
|
|
fp_info_list->DisplayErrors( this );
|
2017-06-11 20:20:44 +00:00
|
|
|
|
|
|
|
// For footprint libraries that support one footprint per file, there may have been
|
|
|
|
// valid footprints read so show the footprints that loaded properly.
|
|
|
|
if( fp_info_list->GetList().size() == 0 )
|
|
|
|
return;
|
2013-09-22 00:28:02 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
for( auto& footprint : fp_info_list->GetList() )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2017-03-23 00:59:25 +00:00
|
|
|
m_footprintList->Append( footprint->GetFootprintName() );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2013-09-22 00:28:02 +00:00
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
int index = m_footprintList->FindString( getCurFootprintName() );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
if( index == wxNOT_FOUND )
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurFootprintName( wxEmptyString );
|
2012-02-09 20:33:38 +00:00
|
|
|
else
|
2018-10-02 20:53:00 +00:00
|
|
|
{
|
2014-01-13 15:09:52 +00:00
|
|
|
m_footprintList->SetSelection( index, true );
|
2018-10-02 20:53:00 +00:00
|
|
|
m_footprintList->EnsureVisible( index );
|
|
|
|
}
|
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
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
if( getCurNickname() == name )
|
2012-02-09 20:33:38 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurNickname( 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
if( getCurFootprintName().CmpNoCase( name ) != 0 )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-06-16 19:00:26 +00:00
|
|
|
setCurFootprintName( name );
|
|
|
|
|
2018-06-14 08:54:49 +00:00
|
|
|
// Delete the current footprint (MUST reset tools first)
|
|
|
|
GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
SetCurItem( nullptr );
|
2012-02-09 20:33:38 +00:00
|
|
|
GetBoard()->m_Modules.DeleteAll();
|
2014-01-27 06:41:40 +00:00
|
|
|
|
2016-11-20 23:35:08 +00:00
|
|
|
LIB_ID id;
|
2017-07-24 19:02:59 +00:00
|
|
|
id.SetLibNickname( getCurNickname() );
|
|
|
|
id.SetLibItemName( getCurFootprintName() );
|
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
|
|
|
{
|
2014-06-16 19:00:26 +00:00
|
|
|
wxString msg = wxString::Format(
|
|
|
|
_( "Could not load footprint \"%s\" from library \"%s\".\n\nError %s." ),
|
|
|
|
GetChars( getCurFootprintName() ),
|
|
|
|
GetChars( getCurNickname() ),
|
2016-09-14 22:36:45 +00:00
|
|
|
GetChars( ioe.What() ) );
|
2014-06-16 19:00:26 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
}
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
updateView();
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2012-02-09 20:33:38 +00:00
|
|
|
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 );
|
|
|
|
|
2016-11-20 23:35:08 +00:00
|
|
|
LIB_ID fpid;
|
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
|
|
|
|
2017-07-24 19:02:59 +00:00
|
|
|
fpid.SetLibNickname( getCurNickname() );
|
|
|
|
fpid.SetLibItemName( fp_name );
|
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
|
|
|
|
2017-07-24 19:02:59 +00:00
|
|
|
DismissModal( true, fpid.Format() );
|
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
|
|
|
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
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2018-09-11 15:28:57 +00:00
|
|
|
PCB_BASE_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
m_configSettings.Load( aCfg ); // mainly, load the color config
|
2018-09-11 15:28:57 +00:00
|
|
|
|
|
|
|
aCfg->Read( ConfigBaseName() + AUTO_ZOOM_KEY, &m_autoZoom, true );
|
|
|
|
aCfg->Read( ConfigBaseName() + ZOOM_KEY, &m_lastZoom, 10.0 );
|
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
|
|
|
{
|
2018-09-11 15:28:57 +00:00
|
|
|
PCB_BASE_FRAME::SaveSettings( aCfg );
|
|
|
|
|
|
|
|
aCfg->Write( ConfigBaseName() + AUTO_ZOOM_KEY, m_autoZoom );
|
|
|
|
aCfg->Write( ConfigBaseName() + ZOOM_KEY, GetGalCanvas()->GetView()->GetScale() );
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
const wxString FOOTPRINT_VIEWER_FRAME::getCurNickname()
|
|
|
|
{
|
|
|
|
return Prj().GetRString( PROJECT::PCB_FOOTPRINT_VIEWER_NICKNAME );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
|
|
|
|
{
|
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_VIEWER_NICKNAME, aNickname );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString FOOTPRINT_VIEWER_FRAME::getCurFootprintName()
|
|
|
|
{
|
|
|
|
return Prj().GetRString( PROJECT::PCB_FOOTPRINT_VIEWER_FPNAME );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
|
|
|
|
{
|
|
|
|
Prj().SetRString( PROJECT::PCB_FOOTPRINT_VIEWER_FPNAME, aName );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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:
|
2015-01-22 13:42:24 +00:00
|
|
|
if( !event.GetActive() )
|
2012-02-10 15:31:11 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-03 16:58:23 +00:00
|
|
|
bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
|
2018-03-21 21:13:10 +00:00
|
|
|
{
|
2018-03-22 10:37:54 +00:00
|
|
|
if( aFootprint && !aFootprint->IsEmpty() )
|
2018-03-21 21:13:10 +00:00
|
|
|
{
|
2018-08-03 16:58:23 +00:00
|
|
|
wxString msg;
|
|
|
|
LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
2018-07-26 14:38:30 +00:00
|
|
|
LIB_ID fpid;
|
|
|
|
|
|
|
|
fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
|
|
|
|
|
|
|
|
if( fpid.IsValid() )
|
2018-03-21 21:13:10 +00:00
|
|
|
{
|
2018-08-03 16:58:23 +00:00
|
|
|
wxString nickname = fpid.GetLibNickname();
|
|
|
|
|
|
|
|
if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
|
|
|
|
{
|
|
|
|
msg.sprintf( _( "The current configuration does not include a library with the\n"
|
|
|
|
"nickname \"%s\". Use Manage Footprint Libraries\n"
|
|
|
|
"to edit the configuration." ), nickname );
|
|
|
|
DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
|
|
|
|
}
|
|
|
|
else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
|
|
|
|
{
|
|
|
|
msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
|
|
|
|
"in the current configuration. Use Manage Footprint Libraries to\n"
|
|
|
|
"edit the configuration." ), nickname );
|
|
|
|
DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setCurNickname( nickname );
|
|
|
|
setCurFootprintName( fpid.GetLibItemName() );
|
|
|
|
ReCreateFootprintList();
|
|
|
|
}
|
|
|
|
|
2018-07-26 14:38:30 +00:00
|
|
|
SelectAndViewFootprint( NEW_PART );
|
2018-03-21 21:13:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 16:58:23 +00:00
|
|
|
return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
|
2018-03-21 21:13:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-20 12:11:17 +00:00
|
|
|
bool FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
|
2012-02-09 20:33:38 +00:00
|
|
|
{
|
2014-08-29 20:23:40 +00:00
|
|
|
bool eventHandled = true;
|
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
// Filter out the 'fake' mouse motion after a keyboard movement
|
|
|
|
if( !aHotKey && m_movingCursorWithKeyboard )
|
|
|
|
{
|
|
|
|
m_movingCursorWithKeyboard = false;
|
2014-08-29 20:23:40 +00:00
|
|
|
return false;
|
2014-06-12 16:12:14 +00:00
|
|
|
}
|
2012-02-09 20:33:38 +00:00
|
|
|
|
|
|
|
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
|
|
|
|
cmd.SetEventObject( this );
|
|
|
|
|
2014-06-12 16:12:14 +00:00
|
|
|
wxPoint oldpos = GetCrossHairPosition();
|
|
|
|
wxPoint pos = aPosition;
|
|
|
|
GeneralControlKeyMovement( aHotKey, &pos, true );
|
2012-02-09 20:33:38 +00:00
|
|
|
|
2014-10-15 11:40:38 +00:00
|
|
|
if( aHotKey )
|
|
|
|
{
|
|
|
|
eventHandled = OnHotKey( aDC, aHotKey, aPosition );
|
|
|
|
}
|
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
SetCrossHairPosition( pos );
|
2014-06-12 16:12:14 +00:00
|
|
|
RefreshCrossHair( oldpos, aPosition, aDC );
|
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
|
|
|
UpdateStatusBar(); // Display new cursor coordinates
|
2014-08-29 20:23:40 +00:00
|
|
|
|
|
|
|
return eventHandled;
|
2012-02-09 20:33:38 +00:00
|
|
|
}
|
2012-02-10 08:49:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event )
|
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
|
2015-12-21 11:52:00 +00:00
|
|
|
|
2018-03-14 19:16:01 +00:00
|
|
|
// We can probably remove this for 6.0, but just to be safe we'll stick to
|
|
|
|
// one 3DFrame at a time for 5.0
|
2015-12-21 11:52:00 +00:00
|
|
|
if( draw3DFrame )
|
2018-03-14 19:16:01 +00:00
|
|
|
draw3DFrame->Close( true );
|
2012-02-10 08:49:43 +00:00
|
|
|
|
2018-03-14 19:16:01 +00:00
|
|
|
draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
|
2012-02-10 15:31:11 +00:00
|
|
|
Update3D_Frame( false );
|
2018-03-14 19:16:01 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// A stronger version of Raise() which promotes the window to its parent's level.
|
|
|
|
draw3DFrame->ReparentQuasiModal();
|
|
|
|
#else
|
2015-12-21 11:52:00 +00:00
|
|
|
draw3DFrame->Raise(); // Needed with some Window Managers
|
2018-03-14 19:16:01 +00:00
|
|
|
#endif
|
|
|
|
|
2015-12-21 11:52:00 +00:00
|
|
|
draw3DFrame->Show( true );
|
2012-02-10 08:49:43 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2018-03-12 19:16:09 +00:00
|
|
|
wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
|
|
|
|
getCurFootprintName() );
|
2014-06-16 19:00:26 +00:00
|
|
|
|
2018-05-10 10:49:20 +00:00
|
|
|
Update3DView( &title );
|
2012-02-10 08:49:43 +00:00
|
|
|
}
|
2013-04-11 18:29:56 +00:00
|
|
|
|
2013-05-20 14:49:20 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
COLOR4D FOOTPRINT_VIEWER_FRAME::GetGridColor()
|
2013-04-11 18:29:56 +00:00
|
|
|
{
|
2017-08-04 12:43:02 +00:00
|
|
|
return Settings().Colors().GetItemColor( LAYER_GRID );
|
2013-04-11 18:29:56 +00:00
|
|
|
}
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
|
|
|
case ID_MODVIEW_NEXT:
|
|
|
|
SelectAndViewFootprint( NEXT_PART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_MODVIEW_PREVIOUS:
|
|
|
|
SelectAndViewFootprint( PREVIOUS_PART );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2016-10-28 13:11:23 +00:00
|
|
|
wxString id = wxString::Format( "%i", event.GetId() );
|
|
|
|
wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2016-09-26 17:15:33 +00:00
|
|
|
wxString title;
|
|
|
|
wxString path;
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2019-01-30 19:51:49 +00:00
|
|
|
title.Printf( _( "Footprint Library Browser" ) + L" \u2014 %s",
|
2016-09-26 17:15:33 +00:00
|
|
|
getCurNickname().size()
|
|
|
|
? getCurNickname()
|
|
|
|
: _( "no library selected" ) );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2016-08-19 07:45:59 +00:00
|
|
|
// Now, add the full path, for info
|
|
|
|
if( getCurNickname().size() )
|
|
|
|
{
|
|
|
|
FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
|
2016-11-19 22:15:34 +00:00
|
|
|
const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
|
2016-08-19 07:45:59 +00:00
|
|
|
|
|
|
|
if( row )
|
2016-09-26 17:15:33 +00:00
|
|
|
title << L" \u2014 " << row->GetFullURI( true );
|
2016-08-19 07:45:59 +00:00
|
|
|
}
|
|
|
|
|
2016-09-26 17:15:33 +00:00
|
|
|
SetTitle( title );
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
|
|
|
{
|
2019-01-30 15:44:39 +00:00
|
|
|
LIB_ID current( getCurNickname(), getCurFootprintName() );
|
|
|
|
|
|
|
|
MODULE* module = SelectFootprintFromLibTree( current, false );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( module )
|
|
|
|
{
|
2018-08-01 10:00:10 +00:00
|
|
|
const LIB_ID& fpid = module->GetFPID();
|
2018-04-02 21:31:45 +00:00
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
setCurNickname( fpid.GetLibNickname() );
|
|
|
|
setCurFootprintName( fpid.GetLibItemName() );
|
2014-06-16 19:00:26 +00:00
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
int index = m_libList->FindString( fpid.GetLibNickname() );
|
2014-06-16 19:00:26 +00:00
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
if( index != wxNOT_FOUND )
|
2014-06-16 19:00:26 +00:00
|
|
|
{
|
2018-08-01 10:00:10 +00:00
|
|
|
m_libList->SetSelection( index, true );
|
|
|
|
m_libList->EnsureVisible( index );
|
2014-06-16 19:00:26 +00:00
|
|
|
}
|
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
ReCreateFootprintList();
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
SelectAndViewFootprint( NEW_PART );
|
|
|
|
}
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
|
|
|
|
{
|
2014-06-16 19:00:26 +00:00
|
|
|
if( !getCurNickname() )
|
2013-09-26 17:22:35 +00:00
|
|
|
return;
|
|
|
|
|
2014-06-16 19:00:26 +00:00
|
|
|
int selection = m_footprintList->FindString( getCurFootprintName() );
|
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 );
|
2018-08-01 10:00:10 +00:00
|
|
|
m_footprintList->EnsureVisible( selection );
|
|
|
|
|
|
|
|
setCurFootprintName( m_footprintList->GetString( (unsigned) 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
|
|
|
|
2018-08-01 10:00:10 +00:00
|
|
|
MODULE* footprint = Prj().PcbFootprintLibs()->FootprintLoad( getCurNickname(),
|
|
|
|
getCurFootprintName() );
|
2013-09-26 17:22:35 +00:00
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
GetBoard()->Add( footprint, ADD_APPEND );
|
|
|
|
|
|
|
|
Update3D_Frame();
|
2014-07-09 09:22:43 +00:00
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
updateView();
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 06:41:40 +00:00
|
|
|
UpdateTitle();
|
2018-09-11 15:28:57 +00:00
|
|
|
|
2013-09-26 17:22:35 +00:00
|
|
|
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 );
|
|
|
|
|
|
|
|
m_canvas->DrawCrossHair( DC );
|
|
|
|
|
2018-05-12 08:44:31 +00:00
|
|
|
UpdateMsgPanel();
|
|
|
|
}
|
2013-09-26 17:22:35 +00:00
|
|
|
|
2018-05-12 08:44:31 +00:00
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::UpdateMsgPanel()
|
|
|
|
{
|
|
|
|
BOARD_ITEM* footprint = GetBoard()->m_Modules;
|
|
|
|
|
|
|
|
if( footprint )
|
|
|
|
{
|
|
|
|
MSG_PANEL_ITEMS items;
|
|
|
|
|
2018-04-10 10:52:12 +00:00
|
|
|
footprint->GetMsgPanelInfo( m_UserUnits, items );
|
2018-05-12 08:44:31 +00:00
|
|
|
SetMsgPanel( items );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ClearMsgPanel();
|
2013-09-26 17:22:35 +00:00
|
|
|
}
|
2014-07-09 09:22:42 +00:00
|
|
|
|
|
|
|
|
2018-09-11 15:28:57 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::ApplyDisplaySettingsToGAL()
|
|
|
|
{
|
|
|
|
auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetGalCanvas()->GetView()->GetPainter() );
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
|
|
|
|
settings->LoadDisplayOptions( &m_DisplayOptions, false );
|
|
|
|
|
|
|
|
GetGalCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
|
|
|
GetGalCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
void FOOTPRINT_VIEWER_FRAME::updateView()
|
2014-07-09 09:22:42 +00:00
|
|
|
{
|
2018-09-11 15:28:57 +00:00
|
|
|
auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
|
|
|
|
dp->UseColorScheme( &Settings().Colors() );
|
|
|
|
dp->DisplayBoard( GetBoard() );
|
|
|
|
|
|
|
|
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
|
|
|
|
|
|
|
|
if( m_autoZoom )
|
2017-02-20 18:10:20 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
2018-09-11 15:28:57 +00:00
|
|
|
else
|
|
|
|
m_toolManager->RunAction( ACTIONS::centerContents, true );
|
|
|
|
|
|
|
|
UpdateMsgPanel();
|
2014-07-09 09:22:42 +00:00
|
|
|
}
|
2014-10-15 11:40:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|