You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

827 lines
26 KiB

* 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.
12 years ago
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.
12 years ago
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.
12 years ago
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.
12 years ago
* 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.
12 years ago
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.
12 years ago
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.
12 years ago
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.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
* 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.
12 years ago
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.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2015 Miguel Angel Ajo Pelayo <miguelangel@nbee.es>
  5. * Copyright (C) 2012-2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  6. * Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file footprint_wizard_frame.cpp
  28. */
  29. #include <fctsys.h>
  30. #include <kiface_i.h>
  31. #include <gal/graphics_abstraction_layer.h>
  32. #include <class_drawpanel.h>
  33. #include <pcb_draw_panel_gal.h>
  34. #include <pcb_edit_frame.h>
  35. #include <pcbnew.h>
  36. #include <3d_viewer/eda_3d_viewer.h>
  37. #include <msgpanel.h>
  38. #include <macros.h>
  39. #include <bitmaps.h>
  40. #include <grid_tricks.h>
  41. #include <eda_dockart.h>
  42. #include <class_board.h>
  43. #include <class_module.h>
  44. #include <footprint_edit_frame.h>
  45. #include <pcbnew_id.h>
  46. #include "footprint_wizard_frame.h"
  47. #include <footprint_info.h>
  48. #include <wx/grid.h>
  49. #include <wx/tokenzr.h>
  50. #include <wx/numformatter.h>
  51. #include <wx/statline.h>
  52. #include <hotkeys.h>
  53. #include <wildcards_and_files_ext.h>
  54. #include <base_units.h>
  55. #include <tool/tool_manager.h>
  56. #include <tool/tool_dispatcher.h>
  57. #include <tool/common_tools.h>
  58. #include "tools/selection_tool.h"
  59. #include "tools/pcbnew_control.h"
  60. #include "tools/pcb_actions.h"
  61. BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
  62. // Window events
  63. EVT_CLOSE( FOOTPRINT_WIZARD_FRAME::OnCloseWindow )
  64. EVT_SIZE( FOOTPRINT_WIZARD_FRAME::OnSize )
  65. EVT_ACTIVATE( FOOTPRINT_WIZARD_FRAME::OnActivate )
  66. // Toolbar events
  67. EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
  68. FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard )
  69. EVT_TOOL( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT,
  70. FOOTPRINT_WIZARD_FRAME::DefaultParameters )
  71. EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT,
  72. FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
  73. EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
  74. FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
  75. EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
  76. FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint )
  77. EVT_TOOL( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW,
  78. FOOTPRINT_WIZARD_FRAME::Show3D_Frame )
  79. // listbox events
  80. EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
  81. EVT_GRID_CMD_CELL_CHANGED( ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
  82. FOOTPRINT_WIZARD_FRAME::ParametersUpdated )
  83. EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset )
  84. END_EVENT_TABLE()
  85. /* Note: our FOOTPRINT_WIZARD_FRAME is always modal.
  86. * Note:
  87. * On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
  88. * its parent frame is sometimes brought to the foreground when closing the
  89. * LIB_VIEW_FRAME frame.
  90. * If it still happens, it could be better to use wxSTAY_ON_TOP
  91. * instead of wxFRAME_FLOAT_ON_PARENT
  92. */
  93. #ifdef __WINDOWS__
  94. #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT // could be wxSTAY_ON_TOP if issues
  95. #else
  96. #define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
  97. #endif
  98. FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( KIWAY* aKiway,
  99. wxWindow* aParent, FRAME_T aFrameType ) :
  100. PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Wizard" ),
  101. wxDefaultPosition, wxDefaultSize,
  102. aParent ? KICAD_DEFAULT_DRAWFRAME_STYLE | MODAL_MODE_EXTRASTYLE
  103. : KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP,
  104. FOOTPRINT_WIZARD_FRAME_NAME ), m_wizardListShown( false )
  105. {
  106. wxASSERT( aFrameType == FRAME_PCB_FOOTPRINT_WIZARD );
  107. // This frame is always show modal:
  108. SetModal( true );
  109. m_showAxis = true; // true to draw axis.
  110. // Give an icon
  111. wxIcon icon;
  112. icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
  113. SetIcon( icon );
  114. m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
  115. m_wizardName.Empty();
  116. SetBoard( new BOARD() );
  117. // Ensure all layers and items are visible:
  118. GetBoard()->SetVisibleAlls();
  119. SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
  120. GetScreen()->m_Center = true; // Center coordinate origins on screen.
  121. LoadSettings( config() );
  122. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  123. // Set some display options here, because the FOOTPRINT_WIZARD_FRAME
  124. // does not have a config menu to do that:
  125. // the footprint wizard frame has no config menu. so use some settings
  126. // from the caller, or force some options:
  127. PCB_BASE_FRAME* caller = dynamic_cast<PCB_BASE_FRAME*>( aParent );
  128. if( caller )
  129. {
  130. SetUserUnits( caller->GetUserUnits() );
  131. }
  132. auto disp_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
  133. // In viewer, the default net clearance is not known (it depends on the actual board).
  134. // So we do not show the default clearance, by setting it to 0
  135. // The footprint or pad specific clearance will be shown
  136. GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
  137. disp_opts->m_DisplayPadIsol = true;
  138. disp_opts->m_DisplayPadNum = true;
  139. GetBoard()->SetElementVisibility( LAYER_NO_CONNECTS, false );
  140. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
  141. ReCreateHToolbar();
  142. ReCreateVToolbar();
  143. // Create GAL canvas
  144. #ifdef __WXMAC__
  145. // Cairo renderer doesn't handle Retina displays
  146. EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL;
  147. #else
  148. EDA_DRAW_PANEL_GAL::GAL_TYPE backend = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
  149. #endif
  150. PCB_DRAW_PANEL_GAL* gal_drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
  151. GetGalDisplayOptions(), backend );
  152. SetGalCanvas( gal_drawPanel );
  153. // Create the parameters panel
  154. m_parametersPanel = new wxPanel( this, wxID_ANY );
  155. m_pageList = new wxListBox( m_parametersPanel, ID_FOOTPRINT_WIZARD_PAGE_LIST,
  156. wxDefaultPosition, wxDefaultSize, 0, NULL,
  157. wxLB_HSCROLL | wxNO_BORDER );
  158. auto divider = new wxStaticLine( m_parametersPanel, wxID_ANY,
  159. wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
  160. m_parameterGrid = new wxGrid( m_parametersPanel, ID_FOOTPRINT_WIZARD_PARAMETER_LIST );
  161. initParameterGrid();
  162. m_parameterGrid->PushEventHandler( new GRID_TRICKS( m_parameterGrid ) );
  163. ReCreatePageList();
  164. wxBoxSizer* parametersSizer = new wxBoxSizer( wxHORIZONTAL );
  165. parametersSizer->Add( m_pageList, 0, wxEXPAND, 5 );
  166. parametersSizer->Add( divider, 0, wxEXPAND, 5 );
  167. parametersSizer->Add( m_parameterGrid, 1, wxEXPAND, 5 );
  168. m_parametersPanel->SetSizer( parametersSizer );
  169. m_parametersPanel->Layout();
  170. // Create the build message box
  171. m_buildMessageBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
  172. wxDefaultPosition, wxDefaultSize,
  173. wxTE_MULTILINE | wxTE_READONLY | wxNO_BORDER );
  174. DisplayWizardInfos();
  175. m_auimgr.SetManagedWindow( this );
  176. m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
  177. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  178. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  179. m_auimgr.AddPane( m_parametersPanel, EDA_PANE().Palette().Name( "Params" ).Left().Position(0)
  180. .Caption( _( "Parameters" ) ).MinSize( 360, 180 ) );
  181. m_auimgr.AddPane( m_buildMessageBox, EDA_PANE().Palette().Name( "Output" ).Left().Position(1)
  182. .CaptionVisible( false ).MinSize( 360, -1 ) );
  183. m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  184. m_auimgr.AddPane( (wxWindow*) GetGalCanvas(),
  185. wxAuiPaneInfo().Name( "DrawFrameGal" ).CentrePane().Hide() );
  186. // Create the manager and dispatcher & route draw panel events to the dispatcher
  187. m_toolManager = new TOOL_MANAGER;
  188. m_toolManager->SetEnvironment( GetBoard(), gal_drawPanel->GetView(),
  189. gal_drawPanel->GetViewControls(), this );
  190. m_actions = new PCB_ACTIONS();
  191. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
  192. gal_drawPanel->SetEventDispatcher( m_toolDispatcher );
  193. m_toolManager->RegisterTool( new PCBNEW_CONTROL );
  194. m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
  195. m_toolManager->RegisterTool( new COMMON_TOOLS );
  196. m_toolManager->InitTools();
  197. // Run the control tool, it is supposed to be always active
  198. m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
  199. auto& galOpts = GetGalDisplayOptions();
  200. galOpts.m_fullscreenCursor = true;
  201. galOpts.m_forceDisplayCursor = true;
  202. galOpts.m_axesEnabled = true;
  203. UseGalCanvas( backend != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
  204. updateView();
  205. SetActiveLayer( F_Cu );
  206. // Now Drawpanel is sized, we can use BestZoom to show the component (if any)
  207. #ifdef USE_WX_GRAPHICS_CONTEXT
  208. GetScreen()->SetScalingFactor( BestZoom() );
  209. #else
  210. Zoom_Automatique( false );
  211. #endif
  212. // Do not Run a dialog here: on some Window Managers, it creates issues.
  213. // Reason: the FOOTPRINT_WIZARD_FRAME is run as modal;
  214. // It means the call to FOOTPRINT_WIZARD_FRAME::ShowModal will change the
  215. // Event Loop Manager, and stop the one created by the dialog.
  216. // It does not happen on all W.M., perhaps due to the way the order events are called
  217. // See the call in onActivate instead
  218. }
  219. FOOTPRINT_WIZARD_FRAME::~FOOTPRINT_WIZARD_FRAME()
  220. {
  221. // Delete the GRID_TRICKS.
  222. m_parameterGrid->PopEventHandler( true );
  223. if( IsGalCanvasActive() )
  224. {
  225. GetGalCanvas()->StopDrawing();
  226. // Be sure any event cannot be fired after frame deletion:
  227. GetGalCanvas()->SetEvtHandlerEnabled( false );
  228. }
  229. // Be sure a active tool (if exists) is desactivated:
  230. if( m_toolManager )
  231. m_toolManager->DeactivateTool();
  232. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  233. if( draw3DFrame )
  234. draw3DFrame->Destroy();
  235. // Now this frame can be deleted
  236. }
  237. void FOOTPRINT_WIZARD_FRAME::OnCloseWindow( wxCloseEvent& Event )
  238. {
  239. SaveSettings( config() );
  240. if( IsModal() )
  241. {
  242. // Only dismiss a modal frame once, so that the return values set by
  243. // the prior DismissModal() are not bashed for ShowModal().
  244. if( !IsDismissed() )
  245. DismissModal( false );
  246. }
  247. else
  248. {
  249. Destroy();
  250. }
  251. }
  252. void FOOTPRINT_WIZARD_FRAME::ExportSelectedFootprint( wxCommandEvent& aEvent )
  253. {
  254. DismissModal( true );
  255. Close();
  256. }
  257. void FOOTPRINT_WIZARD_FRAME::OnGridSize( wxSizeEvent& aSizeEvent )
  258. {
  259. // Resize the parameter columns
  260. ResizeParamColumns();
  261. aSizeEvent.Skip();
  262. }
  263. void FOOTPRINT_WIZARD_FRAME::OnSize( wxSizeEvent& SizeEv )
  264. {
  265. if( m_auimgr.GetManagedWindow() )
  266. m_auimgr.Update();
  267. SizeEv.Skip();
  268. }
  269. void FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
  270. {
  271. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  272. UpdateStatusBar();
  273. }
  274. void FOOTPRINT_WIZARD_FRAME::updateView()
  275. {
  276. if( IsGalCanvasActive() )
  277. {
  278. auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
  279. dp->UseColorScheme( &Settings().Colors() );
  280. dp->DisplayBoard( GetBoard() );
  281. m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
  282. m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
  283. UpdateMsgPanel();
  284. }
  285. }
  286. void FOOTPRINT_WIZARD_FRAME::UpdateMsgPanel()
  287. {
  288. BOARD_ITEM* footprint = GetBoard()->m_Modules;
  289. if( footprint )
  290. {
  291. MSG_PANEL_ITEMS items;
  292. footprint->GetMsgPanelInfo( m_UserUnits, items );
  293. SetMsgPanel( items );
  294. }
  295. else
  296. ClearMsgPanel();
  297. }
  298. void FOOTPRINT_WIZARD_FRAME::initParameterGrid()
  299. {
  300. m_parameterGridPage = -1;
  301. // Prepare the grid where parameters are displayed
  302. m_parameterGrid->CreateGrid( 0, 3 );
  303. m_parameterGrid->SetColLabelValue( WIZ_COL_NAME, _( "Parameter" ) );
  304. m_parameterGrid->SetColLabelValue( WIZ_COL_VALUE, _( "Value" ) );
  305. m_parameterGrid->SetColLabelValue( WIZ_COL_UNITS, _( "Units" ) );
  306. m_parameterGrid->SetColLabelSize( 22 );
  307. m_parameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
  308. m_parameterGrid->AutoSizeColumns();
  309. m_parameterGrid->AutoSizeRows();
  310. m_parameterGrid->SetRowLabelSize( 0 );
  311. m_parameterGrid->DisableDragGridSize();
  312. m_parameterGrid->DisableDragColSize();
  313. m_parameterGrid->Connect( wxEVT_SIZE,
  314. wxSizeEventHandler( FOOTPRINT_WIZARD_FRAME::OnGridSize ),
  315. NULL, this );
  316. }
  317. void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
  318. {
  319. if( m_pageList == NULL )
  320. return;
  321. FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
  322. if( !footprintWizard )
  323. return;
  324. m_pageList->Clear();
  325. int max_page = footprintWizard->GetNumParameterPages();
  326. for( int i = 0; i<max_page; i++ )
  327. {
  328. wxString name = footprintWizard->GetParameterPageName( i );
  329. m_pageList->Append( name );
  330. }
  331. m_pageList->SetSelection( 0, true );
  332. ReCreateParameterList();
  333. ReCreateHToolbar();
  334. DisplayWizardInfos();
  335. m_canvas->Refresh();
  336. }
  337. void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
  338. {
  339. if( m_parameterGrid == NULL )
  340. return;
  341. FOOTPRINT_WIZARD* footprintWizard = GetMyWizard();
  342. if( footprintWizard == NULL )
  343. return;
  344. m_parameterGrid->ClearGrid();
  345. m_parameterGridPage = m_pageList->GetSelection();
  346. if( m_parameterGridPage < 0 ) // Should not happen
  347. return;
  348. // Get the list of names, values, types, hints and designators
  349. wxArrayString designatorsList = footprintWizard->GetParameterDesignators( m_parameterGridPage );
  350. wxArrayString namesList = footprintWizard->GetParameterNames( m_parameterGridPage );
  351. wxArrayString valuesList = footprintWizard->GetParameterValues( m_parameterGridPage );
  352. wxArrayString typesList = footprintWizard->GetParameterTypes( m_parameterGridPage );
  353. wxArrayString hintsList = footprintWizard->GetParameterHints( m_parameterGridPage );
  354. // Dimension the wxGrid
  355. if( m_parameterGrid->GetNumberRows() > 0 )
  356. m_parameterGrid->DeleteRows( 0, m_parameterGrid->GetNumberRows() );
  357. m_parameterGrid->AppendRows( namesList.size() );
  358. wxString designator, name, value, units, hint;
  359. for( unsigned int i = 0; i< namesList.size(); i++ )
  360. {
  361. designator = designatorsList[i];
  362. name = namesList[i];
  363. value = valuesList[i];
  364. units = typesList[i];
  365. hint = hintsList[i];
  366. m_parameterGrid->SetRowLabelValue( i, designator );
  367. // Set the 'Name'
  368. m_parameterGrid->SetCellValue( i, WIZ_COL_NAME, name );
  369. m_parameterGrid->SetReadOnly( i, WIZ_COL_NAME );
  370. // Boolean parameters are displayed using a checkbox
  371. if( units == WIZARD_PARAM_UNITS_BOOL )
  372. {
  373. // Set to ReadOnly as we delegate interactivity to GRID_TRICKS
  374. m_parameterGrid->SetReadOnly( i, WIZ_COL_VALUE );
  375. m_parameterGrid->SetCellRenderer( i, WIZ_COL_VALUE, new wxGridCellBoolRenderer );
  376. }
  377. // Parameters that can be selected from a list of multiple options
  378. else if( units.Contains( "," ) ) // Indicates list of available options
  379. {
  380. wxStringTokenizer tokenizer( units, "," );
  381. wxArrayString options;
  382. while( tokenizer.HasMoreTokens() )
  383. {
  384. options.Add( tokenizer.GetNextToken() );
  385. }
  386. m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellChoiceEditor( options ) );
  387. units = wxT( "" );
  388. }
  389. // Integer parameters
  390. else if( units == WIZARD_PARAM_UNITS_INTEGER )
  391. {
  392. m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellNumberEditor );
  393. }
  394. // Non-integer numerical parameters
  395. else if( ( units == WIZARD_PARAM_UNITS_MM ) ||
  396. ( units == WIZARD_PARAM_UNITS_MILS ) ||
  397. ( units == WIZARD_PARAM_UNITS_FLOAT ) ||
  398. ( units == WIZARD_PARAM_UNITS_RADIANS ) ||
  399. ( units == WIZARD_PARAM_UNITS_DEGREES ) ||
  400. ( units == WIZARD_PARAM_UNITS_PERCENT ) )
  401. {
  402. m_parameterGrid->SetCellEditor( i, WIZ_COL_VALUE, new wxGridCellFloatEditor );
  403. // Convert separators to the locale-specific character
  404. value.Replace( ",", wxNumberFormatter::GetDecimalSeparator() );
  405. value.Replace( ".", wxNumberFormatter::GetDecimalSeparator() );
  406. }
  407. // Set the 'Units'
  408. m_parameterGrid->SetCellValue( i, WIZ_COL_UNITS, units );
  409. m_parameterGrid->SetReadOnly( i, WIZ_COL_UNITS );
  410. // Set the 'Value'
  411. m_parameterGrid->SetCellValue( i, WIZ_COL_VALUE, value );
  412. }
  413. ResizeParamColumns();
  414. }
  415. void FOOTPRINT_WIZARD_FRAME::ResizeParamColumns()
  416. {
  417. // Parameter grid is not yet configured
  418. if( ( m_parameterGrid == NULL ) || ( m_parameterGrid->GetNumberCols() == 0 ) )
  419. return;
  420. // first auto-size the columns to ensure enough space around text
  421. m_parameterGrid->AutoSizeColumns();
  422. // Auto-size the value column
  423. int width = m_parameterGrid->GetClientSize().GetWidth() -
  424. m_parameterGrid->GetRowLabelSize() -
  425. m_parameterGrid->GetColSize( WIZ_COL_NAME ) -
  426. m_parameterGrid->GetColSize( WIZ_COL_UNITS );
  427. if( width > m_parameterGrid->GetColMinimalAcceptableWidth() )
  428. {
  429. m_parameterGrid->SetColSize( WIZ_COL_VALUE, width );
  430. }
  431. }
  432. void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
  433. {
  434. int ii = m_pageList->GetSelection();
  435. if( ii < 0 )
  436. return;
  437. ReCreateParameterList();
  438. m_canvas->Refresh();
  439. DisplayWizardInfos();
  440. }
  441. #define AUI_PERSPECTIVE_KEY wxT( "Fpwizard_auiPerspective" )
  442. void FOOTPRINT_WIZARD_FRAME::LoadSettings( wxConfigBase* aCfg )
  443. {
  444. EDA_DRAW_FRAME::LoadSettings( aCfg );
  445. aCfg->Read( AUI_PERSPECTIVE_KEY, &m_auiPerspective );
  446. }
  447. void FOOTPRINT_WIZARD_FRAME::SaveSettings( wxConfigBase* aCfg )
  448. {
  449. EDA_DRAW_FRAME::SaveSettings( aCfg );
  450. aCfg->Write( AUI_PERSPECTIVE_KEY, m_auimgr.SavePerspective() );
  451. }
  452. void FOOTPRINT_WIZARD_FRAME::OnActivate( wxActivateEvent& event )
  453. {
  454. EDA_DRAW_FRAME::OnActivate( event );
  455. // Ensure we do not have old selection:
  456. if( !event.GetActive() )
  457. return;
  458. if( !m_wizardListShown )
  459. {
  460. m_wizardListShown = true;
  461. SelectFootprintWizard();
  462. }
  463. #if 0
  464. // Currently, we do not have a way to see if a Python wizard has changed,
  465. // therefore the lists of parameters and option has to be rebuilt
  466. // This code could be enabled when this way exists
  467. bool footprintWizardsChanged = false;
  468. if( footprintWizardsChanged )
  469. {
  470. // If we are here, the library list has changed, rebuild it
  471. ReCreatePageList();
  472. DisplayWizardInfos();
  473. }
  474. #endif
  475. }
  476. bool FOOTPRINT_WIZARD_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
  477. {
  478. // Filter out the 'fake' mouse motion after a keyboard movement
  479. if( !aHotKey && m_movingCursorWithKeyboard )
  480. {
  481. m_movingCursorWithKeyboard = false;
  482. return false;
  483. }
  484. wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
  485. cmd.SetEventObject( this );
  486. wxPoint pos = aPosition;
  487. wxPoint oldpos = GetCrossHairPosition();
  488. bool keyHandled = GeneralControlKeyMovement( aHotKey, &pos, true );
  489. switch( aHotKey )
  490. {
  491. case WXK_F1:
  492. cmd.SetId( ID_KEY_ZOOM_IN );
  493. GetEventHandler()->ProcessEvent( cmd );
  494. keyHandled = true;
  495. break;
  496. case WXK_F2:
  497. cmd.SetId( ID_KEY_ZOOM_OUT );
  498. GetEventHandler()->ProcessEvent( cmd );
  499. keyHandled = true;
  500. break;
  501. case WXK_F3:
  502. cmd.SetId( ID_ZOOM_REDRAW );
  503. GetEventHandler()->ProcessEvent( cmd );
  504. keyHandled = true;
  505. break;
  506. case WXK_F4:
  507. cmd.SetId( ID_POPUP_ZOOM_CENTER );
  508. GetEventHandler()->ProcessEvent( cmd );
  509. keyHandled = true;
  510. break;
  511. case WXK_HOME:
  512. cmd.SetId( ID_ZOOM_PAGE );
  513. GetEventHandler()->ProcessEvent( cmd );
  514. keyHandled = true;
  515. break;
  516. case ' ':
  517. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  518. keyHandled = true;
  519. break;
  520. default:
  521. break;
  522. }
  523. SetCrossHairPosition( pos );
  524. RefreshCrossHair( oldpos, aPosition, aDC );
  525. UpdateStatusBar(); // Display new cursor coordinates
  526. return keyHandled;
  527. }
  528. void FOOTPRINT_WIZARD_FRAME::Show3D_Frame( wxCommandEvent& event )
  529. {
  530. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  531. // We can probably remove this for 6.0, but just to be safe we'll stick to
  532. // one 3DFrame at a time for 5.0
  533. if( draw3DFrame )
  534. draw3DFrame->Close( true );
  535. draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
  536. Update3D_Frame( false );
  537. #ifdef __WXMAC__
  538. // A stronger version of Raise() which promotes the window to its parent's level.
  539. draw3DFrame->ReparentQuasiModal();
  540. #else
  541. draw3DFrame->Raise(); // Needed with some Window Managers
  542. #endif
  543. draw3DFrame->Show( true );
  544. }
  545. /**
  546. * Function Update3D_Frame
  547. * must be called after a footprint selection
  548. * Updates the 3D view and 3D frame title.
  549. */
  550. void FOOTPRINT_WIZARD_FRAME::Update3D_Frame( bool aForceReloadFootprint )
  551. {
  552. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  553. if( draw3DFrame == NULL )
  554. return;
  555. wxString frm3Dtitle;
  556. frm3Dtitle.Printf( _( "ModView: 3D Viewer [%s]" ), GetChars( m_wizardName ) );
  557. draw3DFrame->SetTitle( frm3Dtitle );
  558. if( aForceReloadFootprint )
  559. {
  560. // Force 3D screen refresh immediately
  561. draw3DFrame->NewDisplay( true );
  562. }
  563. }
  564. void FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar()
  565. {
  566. wxString msg;
  567. if( !m_mainToolBar )
  568. {
  569. m_mainToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
  570. KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
  571. // Set up toolbar
  572. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SELECT_WIZARD, wxEmptyString,
  573. KiBitmap( module_wizard_xpm ),
  574. _( "Select wizard script to run" ) );
  575. m_mainToolBar->AddSeparator();
  576. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_RESET_TO_DEFAULT, wxEmptyString,
  577. KiBitmap( reload_xpm ),
  578. _( "Reset wizard parameters to default") );
  579. m_mainToolBar->AddSeparator();
  580. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_PREVIOUS, wxEmptyString,
  581. KiBitmap( lib_previous_xpm ),
  582. _( "Select previous parameters page" ) );
  583. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_NEXT, wxEmptyString,
  584. KiBitmap( lib_next_xpm ),
  585. _( "Select next parameters page" ) );
  586. m_mainToolBar->AddSeparator();
  587. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_SHOW_3D_VIEW, wxEmptyString,
  588. KiBitmap( three_d_xpm ),
  589. _( "Show footprint in 3D viewer" ) );
  590. m_mainToolBar->AddSeparator();
  591. msg = AddHotkeyName( _( "Zoom in" ), g_Module_Editor_Hotkeys_Descr,
  592. HK_ZOOM_IN, IS_COMMENT );
  593. m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString,
  594. KiBitmap( zoom_in_xpm ), msg );
  595. msg = AddHotkeyName( _( "Zoom out" ), g_Module_Editor_Hotkeys_Descr,
  596. HK_ZOOM_OUT, IS_COMMENT );
  597. m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString,
  598. KiBitmap( zoom_out_xpm ), msg );
  599. msg = AddHotkeyName( _( "Redraw view" ), g_Module_Editor_Hotkeys_Descr,
  600. HK_ZOOM_REDRAW, IS_COMMENT );
  601. m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
  602. KiBitmap( zoom_redraw_xpm ), msg );
  603. msg = AddHotkeyName( _( "Zoom auto" ), g_Module_Editor_Hotkeys_Descr,
  604. HK_ZOOM_AUTO, IS_COMMENT );
  605. m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString,
  606. KiBitmap( zoom_fit_in_page_xpm ), msg );
  607. // The footprint wizard always can export the current footprint
  608. m_mainToolBar->AddSeparator();
  609. m_mainToolBar->AddTool( ID_FOOTPRINT_WIZARD_DONE,
  610. wxEmptyString, KiBitmap( export_footprint_names_xpm ),
  611. _( "Export footprint to editor" ) );
  612. // after adding the buttons to the toolbar, must call Realize() to
  613. // reflect the changes
  614. m_mainToolBar->Realize();
  615. }
  616. m_mainToolBar->Refresh();
  617. }
  618. void FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar()
  619. {
  620. // Currently, there is no vertical toolbar
  621. }
  622. #if defined(KICAD_SCRIPTING)
  623. void FOOTPRINT_WIZARD_FRAME::PythonPluginsReload()
  624. {
  625. // Reload the Python plugins
  626. // Because the board editor has also a plugin python menu,
  627. // call PCB_EDIT_FRAME::PythonPluginsReload() if the board editor
  628. // is running
  629. PCB_EDIT_FRAME* brd_frame =
  630. static_cast<PCB_EDIT_FRAME*>( Kiway().Player( FRAME_PCB, false ) );
  631. if( brd_frame )
  632. brd_frame->PythonPluginsReload();
  633. else
  634. PythonPluginsReloadBase();
  635. }
  636. #endif