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.

1474 lines
48 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
* 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
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
14 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
* 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
* 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
14 years ago
14 years ago
14 years ago
14 years ago
14 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
9 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
  7. * Copyright (C) 2013-2018 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software: you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation, either version 3 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. /**
  23. * @file pcb_edit_frame.cpp
  24. * @brief PCB editor main frame implementation.
  25. */
  26. #include <fctsys.h>
  27. #include <kiface_i.h>
  28. #include <pgm_base.h>
  29. #include <class_drawpanel.h>
  30. #include <confirm.h>
  31. #include <pcb_edit_frame.h>
  32. #include <collectors.h>
  33. #include <build_version.h>
  34. #include <3d_viewer/eda_3d_viewer.h>
  35. #include <fp_lib_table.h>
  36. #include <bitmaps.h>
  37. #include <trace_helpers.h>
  38. #include <pcbnew.h>
  39. #include <pcbnew_id.h>
  40. #include <drc.h>
  41. #include <layer_widget.h>
  42. #include <pcb_layer_widget.h>
  43. #include <hotkeys.h>
  44. #include <config_params.h>
  45. #include <footprint_edit_frame.h>
  46. #include <dialog_helpers.h>
  47. #include <dialog_plot.h>
  48. #include <dialog_exchange_footprints.h>
  49. #include <dialog_edit_footprint_for_BoardEditor.h>
  50. #include <dialog_board_setup.h>
  51. #include <dialog_configure_paths.h>
  52. #include <dialog_update_pcb.h>
  53. #include <convert_to_biu.h>
  54. #include <view/view.h>
  55. #include <view/view_controls.h>
  56. #include <pcb_painter.h>
  57. #include <invoke_pcb_dialog.h>
  58. #include <class_track.h>
  59. #include <class_board.h>
  60. #include <class_module.h>
  61. #include <worksheet_viewitem.h>
  62. #include <connectivity/connectivity_data.h>
  63. #include <ratsnest_viewitem.h>
  64. #include <wildcards_and_files_ext.h>
  65. #include <kicad_string.h>
  66. #include <pcb_draw_panel_gal.h>
  67. #include <gal/graphics_abstraction_layer.h>
  68. #include <functional>
  69. #include <tool/tool_manager.h>
  70. #include <tool/tool_dispatcher.h>
  71. #include <tools/pcb_actions.h>
  72. #include <tools/selection_tool.h>
  73. #include <gestfich.h>
  74. #include <executable_names.h>
  75. #include <eda_dockart.h>
  76. #include <board_netlist_updater.h>
  77. #include <netlist_reader.h>
  78. #include <pcb_netlist.h>
  79. #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON)
  80. #include <python_scripting.h>
  81. #endif
  82. using namespace std::placeholders;
  83. ///@{
  84. /// \ingroup config
  85. static const wxString PlotLineWidthEntry = "PlotLineWidth_mm";
  86. static const wxString ShowMicrowaveEntry = "ShowMicrowaveTools";
  87. static const wxString ShowLayerManagerEntry = "ShowLayerManagerTools";
  88. static const wxString ShowPageLimitsEntry = "ShowPageLimits";
  89. ///@}
  90. BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
  91. EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, PCB_EDIT_FRAME::OnSockRequestServer )
  92. EVT_SOCKET( ID_EDA_SOCKET_EVENT, PCB_EDIT_FRAME::OnSockRequest )
  93. EVT_CHOICE( ID_ON_ZOOM_SELECT, PCB_EDIT_FRAME::OnSelectZoom )
  94. EVT_CHOICE( ID_ON_GRID_SELECT, PCB_EDIT_FRAME::OnSelectGrid )
  95. EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow )
  96. EVT_SIZE( PCB_EDIT_FRAME::OnSize )
  97. EVT_TOOL( ID_LOAD_FILE, PCB_EDIT_FRAME::Files_io )
  98. EVT_TOOL( ID_MENU_READ_BOARD_BACKUP_FILE, PCB_EDIT_FRAME::Files_io )
  99. EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io )
  100. EVT_TOOL( ID_NEW_BOARD, PCB_EDIT_FRAME::Files_io )
  101. EVT_TOOL( ID_SAVE_BOARD, PCB_EDIT_FRAME::Files_io )
  102. EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions )
  103. EVT_TOOL( ID_OPEN_MODULE_VIEWER, PCB_EDIT_FRAME::Process_Special_Functions )
  104. // Menu Files:
  105. EVT_MENU( ID_MAIN_MENUBAR, PCB_EDIT_FRAME::Process_Special_Functions )
  106. EVT_MENU( ID_MENU_PCB_FLIP_VIEW, PCB_EDIT_FRAME::OnFlipPcbView )
  107. EVT_MENU( ID_APPEND_FILE, PCB_EDIT_FRAME::Files_io )
  108. EVT_MENU( ID_SAVE_BOARD_AS, PCB_EDIT_FRAME::Files_io )
  109. EVT_MENU( ID_COPY_BOARD_AS, PCB_EDIT_FRAME::Files_io )
  110. EVT_MENU( ID_IMPORT_NON_KICAD_BOARD, PCB_EDIT_FRAME::Files_io )
  111. EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PCB_EDIT_FRAME::OnFileHistory )
  112. EVT_MENU( ID_GEN_PLOT, PCB_EDIT_FRAME::ToPlotter )
  113. EVT_MENU( ID_GEN_PLOT_GERBER, PCB_EDIT_FRAME::ToPlotter )
  114. EVT_MENU( ID_GEN_EXPORT_SPECCTRA, PCB_EDIT_FRAME::ExportToSpecctra )
  115. EVT_MENU( ID_GEN_EXPORT_FILE_GENCADFORMAT, PCB_EDIT_FRAME::ExportToGenCAD )
  116. EVT_MENU( ID_GEN_EXPORT_FILE_MODULE_REPORT, PCB_EDIT_FRAME::GenFootprintsReport )
  117. EVT_MENU( ID_GEN_EXPORT_FILE_VRML, PCB_EDIT_FRAME::OnExportVRML )
  118. EVT_MENU( ID_GEN_EXPORT_FILE_IDF3, PCB_EDIT_FRAME::OnExportIDF3 )
  119. EVT_MENU( ID_GEN_EXPORT_FILE_STEP, PCB_EDIT_FRAME::OnExportSTEP )
  120. EVT_MENU( ID_GEN_EXPORT_FILE_HYPERLYNX, PCB_EDIT_FRAME::OnExportHyperlynx )
  121. EVT_MENU( ID_GEN_IMPORT_SPECCTRA_SESSION,PCB_EDIT_FRAME::ImportSpecctraSession )
  122. EVT_MENU( ID_GEN_IMPORT_SPECCTRA_DESIGN, PCB_EDIT_FRAME::ImportSpecctraDesign )
  123. EVT_MENU( ID_GEN_IMPORT_GRAPHICS_FILE, PCB_EDIT_FRAME::Process_Special_Functions )
  124. EVT_MENU( ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
  125. EVT_MENU( ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, PCB_EDIT_FRAME::Process_Special_Functions )
  126. EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
  127. // menu Config
  128. EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config )
  129. EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::Process_Config )
  130. EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, PCB_EDIT_FRAME::OnConfigurePaths )
  131. EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PCB_EDIT_FRAME::Process_Config )
  132. EVT_MENU( wxID_PREFERENCES, PCB_EDIT_FRAME::Process_Config )
  133. EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::OnGridSettings )
  134. // menu Postprocess
  135. EVT_MENU( ID_PCB_GEN_POS_MODULES_FILE, PCB_EDIT_FRAME::GenFootprintsPositionFile )
  136. EVT_MENU( ID_PCB_GEN_DRILL_FILE, PCB_EDIT_FRAME::InstallDrillFrame )
  137. EVT_MENU( ID_PCB_GEN_D356_FILE, PCB_EDIT_FRAME::GenD356File )
  138. EVT_MENU( ID_PCB_GEN_CMP_FILE, PCB_EDIT_FRAME::RecreateCmpFileFromBoard )
  139. EVT_MENU( ID_PCB_GEN_BOM_FILE_FROM_BOARD, PCB_EDIT_FRAME::RecreateBOMFileFromBoard )
  140. // menu Miscellaneous
  141. EVT_MENU( ID_MENU_LIST_NETS, PCB_EDIT_FRAME::ListNetsAndSelect )
  142. EVT_MENU( ID_PCB_EDIT_TRACKS_AND_VIAS, PCB_EDIT_FRAME::OnEditTracksAndVias )
  143. EVT_MENU( ID_PCB_GLOBAL_DELETE, PCB_EDIT_FRAME::Process_Special_Functions )
  144. EVT_MENU( ID_MENU_PCB_CLEAN, PCB_EDIT_FRAME::Process_Special_Functions )
  145. EVT_MENU( ID_MENU_PCB_UPDATE_FOOTPRINTS, PCB_EDIT_FRAME::Process_Special_Functions )
  146. EVT_MENU( ID_MENU_PCB_EXCHANGE_FOOTPRINTS, PCB_EDIT_FRAME::Process_Special_Functions )
  147. EVT_MENU( ID_MENU_PCB_SWAP_LAYERS, PCB_EDIT_FRAME::Process_Special_Functions )
  148. EVT_MENU( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS, PCB_EDIT_FRAME::OnEditTextAndGraphics )
  149. // Menu Help
  150. EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
  151. EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
  152. EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
  153. EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
  154. // Menu 3D Frame
  155. EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame )
  156. // Switching canvases
  157. EVT_MENU( ID_MENU_CANVAS_LEGACY, PCB_EDIT_FRAME::OnSwitchCanvas )
  158. EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::OnSwitchCanvas )
  159. EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::OnSwitchCanvas )
  160. // Menu Get Design Rules Editor
  161. EVT_MENU( ID_BOARD_SETUP_DIALOG, PCB_EDIT_FRAME::ShowBoardSetupDialog )
  162. // Horizontal toolbar
  163. EVT_TOOL( ID_RUN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
  164. EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
  165. EVT_TOOL( wxID_CUT, PCB_EDIT_FRAME::Process_Special_Functions )
  166. EVT_TOOL( wxID_COPY, PCB_EDIT_FRAME::Process_Special_Functions )
  167. EVT_TOOL( wxID_PASTE, PCB_EDIT_FRAME::Process_Special_Functions )
  168. EVT_TOOL( wxID_UNDO, PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList )
  169. EVT_TOOL( wxID_REDO, PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList )
  170. EVT_TOOL( wxID_PRINT, PCB_EDIT_FRAME::ToPrinter )
  171. EVT_TOOL( ID_GEN_PLOT_SVG, PCB_EDIT_FRAME::ExportSVG )
  172. EVT_TOOL( ID_GEN_PLOT, PCB_EDIT_FRAME::Process_Special_Functions )
  173. EVT_TOOL( ID_FIND_ITEMS, PCB_EDIT_FRAME::Process_Special_Functions )
  174. EVT_TOOL( ID_GET_NETLIST, PCB_EDIT_FRAME::Process_Special_Functions )
  175. EVT_TOOL( ID_DRC_CONTROL, PCB_EDIT_FRAME::Process_Special_Functions )
  176. EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::Process_Special_Functions )
  177. EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_AUTO_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
  178. EVT_COMBOBOX( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::Process_Special_Functions )
  179. EVT_CHOICE( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
  180. EVT_CHOICE( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
  181. #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
  182. EVT_TOOL( ID_TOOLBARH_PCB_ACTION_PLUGIN_REFRESH, PCB_EDIT_FRAME::OnActionPluginRefresh )
  183. #endif
  184. #if defined( KICAD_SCRIPTING_WXPYTHON )
  185. // has meaning only with KICAD_SCRIPTING_WXPYTHON enabled
  186. EVT_TOOL( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, PCB_EDIT_FRAME::ScriptingConsoleEnableDisable )
  187. EVT_UPDATE_UI( ID_TOOLBARH_PCB_SCRIPTING_CONSOLE,
  188. PCB_EDIT_FRAME::OnUpdateScriptingConsoleState )
  189. #endif
  190. // Option toolbar
  191. EVT_TOOL( ID_TB_OPTIONS_DRC_OFF,
  192. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  193. EVT_TOOL( ID_TB_OPTIONS_SHOW_RATSNEST,
  194. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  195. EVT_TOOL( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
  196. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  197. EVT_TOOL( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
  198. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  199. EVT_TOOL( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
  200. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  201. EVT_TOOL( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
  202. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  203. EVT_TOOL( ID_UPDATE_PCB_FROM_SCH, PCB_EDIT_FRAME::OnUpdatePCBFromSch )
  204. EVT_TOOL( ID_RUN_EESCHEMA, PCB_EDIT_FRAME::OnRunEeschema )
  205. EVT_TOOL_RANGE( ID_TB_OPTIONS_SHOW_ZONES, ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY,
  206. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  207. EVT_TOOL( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
  208. PCB_EDIT_FRAME::OnSelectOptionToolbar )
  209. // Vertical main toolbar:
  210. EVT_TOOL( ID_NO_TOOL_SELECTED, PCB_EDIT_FRAME::OnSelectTool )
  211. EVT_TOOL( ID_ZOOM_SELECTION, PCB_EDIT_FRAME::OnSelectTool )
  212. EVT_TOOL_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL,
  213. PCB_EDIT_FRAME::OnSelectTool )
  214. EVT_TOOL_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD,
  215. PCB_EDIT_FRAME::ProcessMuWaveFunctions )
  216. EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE,
  217. PCB_EDIT_FRAME::Process_Special_Functions )
  218. // Tracks and vias sizes general options
  219. EVT_MENU_RANGE( ID_POPUP_PCB_SELECT_WIDTH_START_RANGE,
  220. ID_POPUP_PCB_SELECT_WIDTH_END_RANGE,
  221. PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event )
  222. // popup menus
  223. EVT_MENU( ID_POPUP_PCB_DELETE_TRACKSEG, PCB_EDIT_FRAME::Process_Special_Functions )
  224. EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
  225. PCB_EDIT_FRAME::Process_Special_Functions )
  226. // User interface update event handlers.
  227. EVT_UPDATE_UI( ID_SAVE_BOARD, PCB_EDIT_FRAME::OnUpdateSave )
  228. EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair )
  229. EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox )
  230. EVT_UPDATE_UI( ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnUpdateDrcEnable )
  231. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_RATSNEST, PCB_EDIT_FRAME::OnUpdateShowBoardRatsnest )
  232. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, PCB_EDIT_FRAME::OnUpdateViaDrawMode )
  233. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, PCB_EDIT_FRAME::OnUpdateTraceDrawMode )
  234. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE,
  235. PCB_EDIT_FRAME::OnUpdateHighContrastDisplayMode )
  236. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
  237. PCB_EDIT_FRAME::OnUpdateShowLayerManager )
  238. EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
  239. PCB_EDIT_FRAME::OnUpdateShowMicrowaveToolbar )
  240. EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
  241. EVT_UPDATE_UI( ID_ZOOM_SELECTION, PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
  242. EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_TRACK_WIDTH, PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
  243. EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_VIA_SIZE, PCB_EDIT_FRAME::OnUpdateSelectViaSize )
  244. EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_WIDTH1, ID_POPUP_PCB_SELECT_WIDTH8,
  245. PCB_EDIT_FRAME::OnUpdateSelectTrackWidth )
  246. EVT_UPDATE_UI_RANGE( ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE8,
  247. PCB_EDIT_FRAME::OnUpdateSelectViaSize )
  248. EVT_UPDATE_UI_RANGE( ID_PCB_HIGHLIGHT_BUTT, ID_PCB_MEASUREMENT_TOOL,
  249. PCB_EDIT_FRAME::OnUpdateVerticalToolbar )
  250. EVT_UPDATE_UI_RANGE( ID_PCB_MUWAVE_START_CMD, ID_PCB_MUWAVE_END_CMD,
  251. PCB_EDIT_FRAME::OnUpdateMuWaveToolbar )
  252. EVT_COMMAND( wxID_ANY, LAYER_WIDGET::EVT_LAYER_COLOR_CHANGE, PCB_EDIT_FRAME::OnLayerColorChange )
  253. END_EVENT_TABLE()
  254. PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
  255. PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
  256. wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME )
  257. {
  258. m_showBorderAndTitleBlock = true; // true to display sheet references
  259. m_showAxis = false; // true to display X and Y axis
  260. m_showOriginAxis = true;
  261. m_showGridAxis = true;
  262. m_SelTrackWidthBox = NULL;
  263. m_SelViaSizeBox = NULL;
  264. m_SelLayerBox = NULL;
  265. m_show_microwave_tools = false;
  266. m_show_layer_manager_tools = true;
  267. m_hotkeysDescrList = g_Board_Editor_Hotkeys_Descr;
  268. m_hasAutoSave = true;
  269. m_microWaveToolBar = NULL;
  270. m_Layers = nullptr;
  271. m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
  272. // We don't know what state board was in when it was lasat saved, so we have to
  273. // assume dirty
  274. m_ZoneFillsDirty = true;
  275. m_rotationAngle = 900;
  276. // Create GAL canvas
  277. EDA_DRAW_PANEL_GAL* galCanvas = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ),
  278. m_FrameSize,
  279. GetGalDisplayOptions(),
  280. EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
  281. SetGalCanvas( galCanvas );
  282. SetBoard( new BOARD() );
  283. // Create the PCB_LAYER_WIDGET *after* SetBoard():
  284. m_Layers = new PCB_LAYER_WIDGET( this, GetCanvas() );
  285. m_drc = new DRC( this ); // these 2 objects point to each other
  286. wxIcon icon;
  287. icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
  288. SetIcon( icon );
  289. // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
  290. // initialize parameters in m_LayersManager
  291. LoadSettings( config() );
  292. SetScreen( new PCB_SCREEN( GetPageSettings().GetSizeIU() ) );
  293. GetScreen()->SetMaxUndoItems( m_UndoRedoCountMax );
  294. // PCB drawings start in the upper left corner.
  295. GetScreen()->m_Center = false;
  296. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  297. GetScreen()->AddGrid( m_UserGridSize, EDA_UNITS_T::UNSCALED_UNITS, ID_POPUP_GRID_USER );
  298. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
  299. if( m_canvas )
  300. m_canvas->SetEnableBlockCommands( true );
  301. ReCreateMenuBar();
  302. ReCreateHToolbar();
  303. ReCreateAuxiliaryToolbar();
  304. ReCreateVToolbar();
  305. ReCreateOptToolbar();
  306. ReCreateMicrowaveVToolbar();
  307. m_auimgr.SetManagedWindow( this );
  308. m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
  309. // Horizontal items; layers 4 - 6
  310. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  311. m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
  312. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  313. // Vertical items; layers 1 - 3
  314. m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
  315. m_auimgr.AddPane( m_microWaveToolBar, EDA_PANE().VToolbar().Name( "MicrowaveToolbar" ).Right().Layer(1) );
  316. m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(2) );
  317. m_auimgr.AddPane( m_Layers, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
  318. .Caption( _( "Layers Manager" ) ).PaneBorder( false )
  319. .MinSize( 80, -1 ).BestSize( m_Layers->GetBestSize() ) );
  320. m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  321. m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
  322. m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
  323. m_auimgr.GetPane( "MicrowaveToolbar" ).Show( m_show_microwave_tools );
  324. ReFillLayerWidget(); // this is near end because contents establish size
  325. m_Layers->ReFillRender(); // Update colors in Render after the config is read
  326. syncLayerWidgetLayer();
  327. m_auimgr.Update();
  328. setupTools();
  329. Zoom_Automatique( false );
  330. m_canvasType = LoadCanvasTypeSetting();
  331. // Nudge user to switch to OpenGL if they are on legacy or Cairo
  332. if( m_firstRunDialogSetting < 1 )
  333. {
  334. if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
  335. {
  336. wxString msg = _( "KiCad can use your graphics card to give you a smoother "
  337. "and faster experience. This option is turned off by "
  338. "default since it is not compatible with all computers.\n\n"
  339. "Would you like to try enabling graphics acceleration?\n\n"
  340. "If you'd like to choose later, select Modern Toolset "
  341. "(Accelerated) in the Preferences menu." );
  342. wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ),
  343. wxYES_NO );
  344. dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
  345. if( dlg.ShowModal() == wxID_YES )
  346. {
  347. // Save Cairo as default in case OpenGL crashes
  348. saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
  349. // Switch to OpenGL, which will save the new setting if successful
  350. wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_OPENGL );
  351. GetEventHandler()->ProcessEvent( evt );
  352. // Switch back to Cairo if OpenGL is not supported
  353. if( GetGalCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
  354. {
  355. wxCommandEvent cairoEvt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
  356. GetEventHandler()->ProcessEvent( cairoEvt );
  357. }
  358. }
  359. else
  360. {
  361. // If they were on legacy, or they've been coerced into GAL
  362. // due to unavailable legacy (GTK3), switch to Cairo
  363. wxCommandEvent evt( wxEVT_MENU, ID_MENU_CANVAS_CAIRO );
  364. GetEventHandler()->ProcessEvent( evt );
  365. }
  366. }
  367. m_firstRunDialogSetting = 1;
  368. SaveSettings( config() );
  369. }
  370. if( m_canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
  371. {
  372. if( GetGalCanvas()->SwitchBackend( m_canvasType ) )
  373. UseGalCanvas( true );
  374. }
  375. enableGALSpecificMenus();
  376. // disable Export STEP item if kicad2step does not exist
  377. wxString strK2S = Pgm().GetExecutablePath();
  378. #ifdef __WXMAC__
  379. if (strK2S.find( "pcbnew.app" ) != wxNOT_FOUND )
  380. {
  381. // On macOS, we have standalone applications inside the main bundle, so we handle that here:
  382. strK2S += "../../";
  383. }
  384. strK2S += "Contents/MacOS/";
  385. #endif
  386. wxFileName appK2S( strK2S, "kicad2step" );
  387. #ifdef _WIN32
  388. appK2S.SetExt( "exe" );
  389. #endif
  390. if( !appK2S.FileExists() )
  391. GetMenuBar()->FindItem( ID_GEN_EXPORT_FILE_STEP )->Enable( false );
  392. }
  393. PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
  394. {
  395. delete m_drc;
  396. }
  397. void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard )
  398. {
  399. PCB_BASE_EDIT_FRAME::SetBoard( aBoard );
  400. if( IsGalCanvasActive() )
  401. {
  402. aBoard->GetConnectivity()->Build( aBoard );
  403. // reload the worksheet
  404. SetPageSettings( aBoard->GetPageSettings() );
  405. }
  406. }
  407. BOARD_ITEM_CONTAINER* PCB_EDIT_FRAME::GetModel() const
  408. {
  409. return m_Pcb;
  410. }
  411. void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
  412. {
  413. PCB_BASE_FRAME::SetPageSettings( aPageSettings );
  414. if( IsGalCanvasActive() )
  415. {
  416. PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
  417. // Prepare worksheet template
  418. KIGFX::WORKSHEET_VIEWITEM* worksheet;
  419. worksheet = new KIGFX::WORKSHEET_VIEWITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
  420. &m_Pcb->GetTitleBlock() );
  421. worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
  422. BASE_SCREEN* screen = GetScreen();
  423. if( screen != NULL )
  424. {
  425. worksheet->SetSheetNumber( screen->m_ScreenNumber );
  426. worksheet->SetSheetCount( screen->m_NumberOfScreens );
  427. }
  428. if( auto board = GetBoard() )
  429. worksheet->SetFileName( TO_UTF8( board->GetFileName() ) );
  430. // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
  431. drawPanel->SetWorksheet( worksheet );
  432. }
  433. }
  434. bool PCB_EDIT_FRAME::isAutoSaveRequired() const
  435. {
  436. if( GetScreen() )
  437. return GetScreen()->IsSave();
  438. return false;
  439. }
  440. void PCB_EDIT_FRAME::setupTools()
  441. {
  442. // Create the manager and dispatcher & route draw panel events to the dispatcher
  443. m_toolManager = new TOOL_MANAGER;
  444. m_toolManager->SetEnvironment( m_Pcb, GetGalCanvas()->GetView(),
  445. GetGalCanvas()->GetViewControls(), this );
  446. m_actions = new PCB_ACTIONS();
  447. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
  448. // Register tools
  449. m_actions->RegisterAllTools( m_toolManager );
  450. m_toolManager->InitTools();
  451. // Run the selection tool, it is supposed to be always active
  452. m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
  453. }
  454. void PCB_EDIT_FRAME::ReFillLayerWidget()
  455. {
  456. m_Layers->ReFill();
  457. wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_Layers );
  458. wxSize bestz = m_Layers->GetBestSize();
  459. lyrs.MinSize( bestz );
  460. lyrs.BestSize( bestz );
  461. lyrs.FloatingSize( bestz );
  462. if( lyrs.IsDocked() )
  463. m_auimgr.Update();
  464. else
  465. m_Layers->SetSize( bestz );
  466. }
  467. void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
  468. {
  469. Close( false );
  470. }
  471. void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
  472. {
  473. m_canvas->SetAbortRequest( true );
  474. if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
  475. {
  476. wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
  477. if( !HandleUnsavedChanges( this, wxString::Format( msg, GetBoard()->GetFileName() ),
  478. [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) )
  479. {
  480. Event.Veto();
  481. return;
  482. }
  483. }
  484. if( IsGalCanvasActive() )
  485. {
  486. // On Windows 7 / 32 bits, on OpenGL mode only, Pcbnew crashes
  487. // when closing this frame if a footprint was selected, and the footprint editor called
  488. // to edit this footprint, and when closing pcbnew if this footprint is still selected
  489. // See https://bugs.launchpad.net/kicad/+bug/1655858
  490. // I think this is certainly a OpenGL event fired after frame deletion, so this workaround
  491. // avoid the crash (JPC)
  492. GetGalCanvas()->SetEvtHandlerEnabled( false );
  493. }
  494. GetGalCanvas()->StopDrawing();
  495. // Delete the auto save file if it exists.
  496. wxFileName fn = GetBoard()->GetFileName();
  497. // Auto save file name is the normal file name prefixed with 'GetAutoSaveFilePrefix()'.
  498. fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
  499. // When the auto save feature does not have write access to the board file path, it falls
  500. // back to a platform specific user temporary file path.
  501. if( !fn.IsOk() || !fn.IsDirWritable() )
  502. fn.SetPath( wxFileName::GetTempDir() );
  503. wxLogTrace( traceAutoSave, "Deleting auto save file <" + fn.GetFullPath() + ">" );
  504. // Remove the auto save file on a normal close of Pcbnew.
  505. if( fn.FileExists() && !wxRemoveFile( fn.GetFullPath() ) )
  506. {
  507. wxString msg = wxString::Format( _( "The auto save file \"%s\" could not be removed!" ),
  508. fn.GetFullPath() );
  509. wxMessageBox( msg, Pgm().App().GetAppName(), wxOK | wxICON_ERROR, this );
  510. }
  511. // Do not show the layer manager during closing to avoid flicker
  512. // on some platforms (Windows) that generate useless redraw of items in
  513. // the Layer Manger
  514. if( m_show_layer_manager_tools )
  515. m_auimgr.GetPane( "LayersManager" ).Show( false );
  516. // Delete board structs and undo/redo lists, to avoid crash on exit
  517. // when deleting some structs (mainly in undo/redo lists) too late
  518. Clear_Pcb( false );
  519. // do not show the window because ScreenPcb will be deleted and we do not
  520. // want any paint event
  521. Show( false );
  522. Destroy();
  523. }
  524. void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
  525. {
  526. bool forceRecreateIfNotOwner = true;
  527. CreateAndShow3D_Frame( forceRecreateIfNotOwner );
  528. }
  529. void PCB_EDIT_FRAME::UseGalCanvas( bool aEnable )
  530. {
  531. if( !aEnable )
  532. Compile_Ratsnest( NULL, true );
  533. PCB_BASE_EDIT_FRAME::UseGalCanvas( aEnable );
  534. COLORS_DESIGN_SETTINGS& cds = Settings().Colors();
  535. if( aEnable )
  536. {
  537. cds.SetLegacyMode( false );
  538. GetGalCanvas()->GetGAL()->SetGridColor( cds.GetLayerColor( LAYER_GRID ) );
  539. auto view = GetGalCanvas()->GetView();
  540. view->GetPainter()->GetSettings()->ImportLegacyColors( &cds );
  541. GetGalCanvas()->Refresh();
  542. }
  543. enableGALSpecificMenus();
  544. // Force colors to be legacy-compatible in case they were changed in GAL
  545. if( !aEnable )
  546. {
  547. cds.SetLegacyMode( true );
  548. Refresh();
  549. }
  550. // Re-create the layer manager to allow arbitrary colors when GAL is enabled
  551. UpdateUserInterface();
  552. }
  553. void PCB_EDIT_FRAME::enableGALSpecificMenus()
  554. {
  555. // some menus are active only in GAL mode and do nothing in legacy mode.
  556. // So enable or disable them, depending on the display mode
  557. ReCreateMenuBar();
  558. if( GetMenuBar() )
  559. {
  560. // Enable / disable some menus which are usable only on GAL
  561. pcbnew_ids id_list[] =
  562. {
  563. ID_MENU_INTERACTIVE_ROUTER_SETTINGS,
  564. ID_DIFF_PAIR_BUTT,
  565. ID_TUNE_SINGLE_TRACK_LEN_BUTT,
  566. ID_TUNE_DIFF_PAIR_LEN_BUTT,
  567. ID_TUNE_DIFF_PAIR_SKEW_BUTT,
  568. ID_MENU_DIFF_PAIR_DIMENSIONS,
  569. ID_MENU_PCB_FLIP_VIEW
  570. };
  571. bool enable = IsGalCanvasActive();
  572. for( auto& id : id_list )
  573. {
  574. if( GetMenuBar()->FindItem( id ) )
  575. GetMenuBar()->FindItem( id )->Enable( enable );
  576. }
  577. // Update settings for GAL menus
  578. auto view = GetGalCanvas()->GetView();
  579. GetMenuBar()->FindItem( ID_MENU_PCB_FLIP_VIEW )->Check( view->IsMirroredX() );
  580. }
  581. }
  582. void PCB_EDIT_FRAME::ShowBoardSetupDialog( wxCommandEvent& event )
  583. {
  584. DoShowBoardSetupDialog();
  585. }
  586. void PCB_EDIT_FRAME::DoShowBoardSetupDialog( const wxString& aInitialPage,
  587. const wxString& aInitialParentPage )
  588. {
  589. DIALOG_BOARD_SETUP dlg( this );
  590. if( !aInitialPage.IsEmpty() )
  591. dlg.SetInitialPage( aInitialPage, aInitialParentPage );
  592. if( dlg.ShowModal() == wxID_OK )
  593. {
  594. SaveProjectSettings( false );
  595. UpdateUserInterface();
  596. ReCreateAuxiliaryToolbar();
  597. if( IsGalCanvasActive() )
  598. {
  599. for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
  600. GetGalCanvas()->GetView()->Update( module );
  601. GetGalCanvas()->Refresh();
  602. }
  603. //this event causes the routing tool to reload its design rules information
  604. TOOL_EVENT toolEvent( TC_COMMAND, TA_MODEL_CHANGE, AS_ACTIVE );
  605. m_toolManager->ProcessEvent( toolEvent );
  606. OnModify();
  607. }
  608. }
  609. void PCB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
  610. {
  611. PCB_BASE_FRAME::LoadSettings( aCfg );
  612. wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
  613. m_configSettings.Load( aCfg );
  614. double dtmp;
  615. aCfg->Read( PlotLineWidthEntry, &dtmp, 0.1 ); // stored in mm
  616. dtmp = std::max( 0.01, std::min( dtmp, 5.0 ) );
  617. g_DrawDefaultLineThickness = Millimeter2iu( dtmp );
  618. aCfg->Read( ShowMicrowaveEntry, &m_show_microwave_tools );
  619. aCfg->Read( ShowLayerManagerEntry, &m_show_layer_manager_tools );
  620. aCfg->Read( ShowPageLimitsEntry, &m_showPageLimits );
  621. }
  622. void PCB_EDIT_FRAME::SaveSettings( wxConfigBase* aCfg )
  623. {
  624. m_configSettings.Save( aCfg );
  625. PCB_BASE_FRAME::SaveSettings( aCfg );
  626. wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
  627. // This value is stored in mm )
  628. aCfg->Write( PlotLineWidthEntry, MM_PER_IU * g_DrawDefaultLineThickness );
  629. aCfg->Write( ShowMicrowaveEntry, (long) m_show_microwave_tools );
  630. aCfg->Write( ShowLayerManagerEntry, (long)m_show_layer_manager_tools );
  631. aCfg->Write( ShowPageLimitsEntry, m_showPageLimits );
  632. }
  633. bool PCB_EDIT_FRAME::IsGridVisible() const
  634. {
  635. return IsElementVisible( LAYER_GRID );
  636. }
  637. void PCB_EDIT_FRAME::SetGridVisibility(bool aVisible)
  638. {
  639. SetElementVisibility( LAYER_GRID, aVisible );
  640. }
  641. COLOR4D PCB_EDIT_FRAME::GetGridColor()
  642. {
  643. return Settings().Colors().GetItemColor( LAYER_GRID );
  644. }
  645. void PCB_EDIT_FRAME::SetGridColor( COLOR4D aColor )
  646. {
  647. Settings().Colors().SetItemColor( LAYER_GRID, aColor );
  648. if( IsGalCanvasActive() )
  649. {
  650. GetGalCanvas()->GetGAL()->SetGridColor( aColor );
  651. }
  652. }
  653. bool PCB_EDIT_FRAME::IsMicroViaAcceptable()
  654. {
  655. int copperlayercnt = GetBoard()->GetCopperLayerCount( );
  656. PCB_LAYER_ID currLayer = GetActiveLayer();
  657. if( !GetDesignSettings().m_MicroViasAllowed )
  658. return false; // Obvious..
  659. if( copperlayercnt < 4 )
  660. return false; // Only on multilayer boards..
  661. if( ( currLayer == B_Cu )
  662. || ( currLayer == F_Cu )
  663. || ( currLayer == copperlayercnt - 2 )
  664. || ( currLayer == In1_Cu ) )
  665. return true;
  666. return false;
  667. }
  668. void PCB_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
  669. {
  670. PCB_BASE_FRAME::SetActiveLayer( aLayer );
  671. syncLayerWidgetLayer();
  672. if( IsGalCanvasActive() )
  673. {
  674. m_toolManager->RunAction( PCB_ACTIONS::layerChanged ); // notify other tools
  675. GetGalCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
  676. GetGalCanvas()->SetHighContrastLayer( aLayer );
  677. GetGalCanvas()->Refresh();
  678. }
  679. }
  680. void PCB_EDIT_FRAME::onBoardLoaded()
  681. {
  682. UpdateTitle();
  683. // Re-create layers manager based on layer info in board
  684. ReFillLayerWidget();
  685. ReCreateLayerBox();
  686. // Sync layer and item visibility
  687. syncLayerVisibilities();
  688. syncLayerWidgetLayer();
  689. syncRenderStates();
  690. // Update the tracks / vias available sizes list:
  691. ReCreateAuxiliaryToolbar();
  692. // Update the RATSNEST items, which were not loaded at the time
  693. // BOARD::SetVisibleElements() was called from within any PLUGIN.
  694. // See case LAYER_RATSNEST: in BOARD::SetElementVisibility()
  695. GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() );
  696. // Display the loaded board:
  697. Zoom_Automatique( false );
  698. Refresh();
  699. SetMsgPanel( GetBoard() );
  700. SetStatusText( wxEmptyString );
  701. }
  702. void PCB_EDIT_FRAME::syncLayerWidgetLayer()
  703. {
  704. m_Layers->SelectLayer( GetActiveLayer() );
  705. m_Layers->OnLayerSelected();
  706. }
  707. void PCB_EDIT_FRAME::syncRenderStates()
  708. {
  709. m_Layers->ReFillRender();
  710. }
  711. void PCB_EDIT_FRAME::syncLayerVisibilities()
  712. {
  713. m_Layers->SyncLayerVisibilities();
  714. static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( m_Pcb );
  715. }
  716. void PCB_EDIT_FRAME::OnUpdateLayerAlpha( wxUpdateUIEvent & )
  717. {
  718. m_Layers->SyncLayerAlphaIndicators();
  719. }
  720. bool PCB_EDIT_FRAME::IsElementVisible( GAL_LAYER_ID aElement ) const
  721. {
  722. return GetBoard()->IsElementVisible( aElement );
  723. }
  724. void PCB_EDIT_FRAME::SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState )
  725. {
  726. GetGalCanvas()->GetView()->SetLayerVisible( aElement , aNewState );
  727. GetBoard()->SetElementVisibility( aElement, aNewState );
  728. m_Layers->SetRenderState( aElement, aNewState );
  729. }
  730. void PCB_EDIT_FRAME::SetVisibleAlls()
  731. {
  732. GetBoard()->SetVisibleAlls();
  733. for( GAL_LAYER_ID ii = GAL_LAYER_ID_START; ii < GAL_LAYER_ID_BITMASK_END; ++ii )
  734. m_Layers->SetRenderState( ii, true );
  735. }
  736. void PCB_EDIT_FRAME::ShowChangedLanguage()
  737. {
  738. // call my base class
  739. PCB_BASE_EDIT_FRAME::ShowChangedLanguage();
  740. // update the layer manager
  741. m_Layers->Freeze();
  742. wxAuiPaneInfo& pane_info = m_auimgr.GetPane( m_Layers );
  743. pane_info.Caption( _( "Visibles" ) );
  744. m_auimgr.Update();
  745. m_Layers->SetLayersManagerTabsText();
  746. ReFillLayerWidget();
  747. // m_Layers->ReFillRender(); // syncRenderStates() does this
  748. // upate the layer widget to match board visibility states, both layers and render columns.
  749. syncLayerVisibilities();
  750. syncLayerWidgetLayer();
  751. syncRenderStates();
  752. m_Layers->Thaw();
  753. // pcbnew-specific toolbars
  754. ReCreateMicrowaveVToolbar();
  755. }
  756. wxString PCB_EDIT_FRAME::GetLastNetListRead()
  757. {
  758. wxFileName absoluteFileName = m_lastNetListRead;
  759. wxFileName pcbFileName = GetBoard()->GetFileName();
  760. if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() )
  761. {
  762. absoluteFileName.Clear();
  763. m_lastNetListRead = wxEmptyString;
  764. }
  765. return absoluteFileName.GetFullPath();
  766. }
  767. void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
  768. {
  769. wxFileName relativeFileName = aLastNetListRead;
  770. wxFileName pcbFileName = GetBoard()->GetFileName();
  771. if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
  772. && relativeFileName.GetFullPath() != aLastNetListRead )
  773. {
  774. m_lastNetListRead = relativeFileName.GetFullPath();
  775. }
  776. }
  777. void PCB_EDIT_FRAME::OnModify( )
  778. {
  779. PCB_BASE_FRAME::OnModify();
  780. Update3DView();
  781. m_ZoneFillsDirty = true;
  782. }
  783. void PCB_EDIT_FRAME::ExportSVG( wxCommandEvent& event )
  784. {
  785. InvokeExportSVG( this, GetBoard() );
  786. }
  787. void PCB_EDIT_FRAME::UpdateTitle()
  788. {
  789. wxFileName fileName = GetBoard()->GetFileName();
  790. wxString fileinfo;
  791. if( fileName.IsOk() && fileName.FileExists() )
  792. fileinfo = fileName.IsFileWritable() ? wxString( wxEmptyString ) : _( " [Read Only]" );
  793. else
  794. fileinfo = _( " [Unsaved]" );
  795. SetTitle( wxString::Format( _( "Pcbnew" ) + wxT( " \u2014 %s%s" ),
  796. fileName.GetFullPath(),
  797. fileinfo ) );
  798. }
  799. void PCB_EDIT_FRAME::UpdateUserInterface()
  800. {
  801. // Update the layer manager and other widgets from the board setup
  802. // (layer and items visibility, colors ...)
  803. // Rebuild list of nets (full ratsnest rebuild)
  804. Compile_Ratsnest( NULL, true );
  805. GetBoard()->BuildConnectivity();
  806. // Update info shown by the horizontal toolbars
  807. ReCreateLayerBox();
  808. // Update the layer manager
  809. m_Layers->Freeze();
  810. ReFillLayerWidget();
  811. // m_Layers->ReFillRender(); // syncRenderStates() does this
  812. // upate the layer widget to match board visibility states, both layers and render columns.
  813. syncLayerVisibilities();
  814. syncLayerWidgetLayer();
  815. syncRenderStates();
  816. m_Layers->Thaw();
  817. }
  818. #if defined( KICAD_SCRIPTING_WXPYTHON )
  819. void PCB_EDIT_FRAME::ScriptingConsoleEnableDisable( wxCommandEvent& aEvent )
  820. {
  821. wxWindow * pythonPanelFrame = findPythonConsole();
  822. bool pythonPanelShown = true;
  823. if( pythonPanelFrame == NULL )
  824. pythonPanelFrame = CreatePythonShellWindow( this, pythonConsoleNameId() );
  825. else
  826. pythonPanelShown = ! pythonPanelFrame->IsShown();
  827. if( pythonPanelFrame )
  828. pythonPanelFrame->Show( pythonPanelShown );
  829. else
  830. wxMessageBox( wxT( "Error: unable to create the Python Console" ) );
  831. }
  832. #endif
  833. void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent )
  834. {
  835. ReCreateLayerBox();
  836. }
  837. void PCB_EDIT_FRAME::OnSwitchCanvas( wxCommandEvent& aEvent )
  838. {
  839. // switches currently used canvas (default / Cairo / OpenGL).
  840. PCB_BASE_FRAME::OnSwitchCanvas( aEvent );
  841. // The base class method *does not reinit* the layers manager.
  842. // We must upate the layer widget to match board visibility states,
  843. // both layers and render columns.
  844. syncLayerVisibilities();
  845. syncLayerWidgetLayer();
  846. syncRenderStates();
  847. }
  848. void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event )
  849. {
  850. PCB_PLOT_PARAMS plotSettings = GetPlotSettings();
  851. switch( event.GetId() )
  852. {
  853. case ID_GEN_PLOT_GERBER: plotSettings.SetFormat( PLOT_FORMAT_GERBER ); break;
  854. case ID_GEN_PLOT_DXF: plotSettings.SetFormat( PLOT_FORMAT_DXF ); break;
  855. case ID_GEN_PLOT_HPGL: plotSettings.SetFormat( PLOT_FORMAT_HPGL ); break;
  856. case ID_GEN_PLOT_PDF: plotSettings.SetFormat( PLOT_FORMAT_PDF ); break;
  857. case ID_GEN_PLOT_PS: plotSettings.SetFormat( PLOT_FORMAT_POST ); break;
  858. case ID_GEN_PLOT_SVG: wxFAIL_MSG( "Must be handled by ExportSVG()" ); break;
  859. default: wxFAIL_MSG( "Unknown plot type" ); break;
  860. }
  861. SetPlotSettings( plotSettings );
  862. // Force rebuild the dialog if currently open because the old dialog can be not up to date
  863. // if the board (or units) has changed
  864. wxWindow* dlg = wxWindow::FindWindowByName( DLG_WINDOW_NAME );
  865. if( dlg )
  866. dlg->Destroy();
  867. dlg = new DIALOG_PLOT( this );
  868. dlg->Show( true );
  869. }
  870. bool PCB_EDIT_FRAME::SetCurrentNetClass( const wxString& aNetClassName )
  871. {
  872. bool change = GetDesignSettings().SetCurrentNetClass( aNetClassName );
  873. if( change )
  874. {
  875. ReCreateAuxiliaryToolbar();
  876. }
  877. return change;
  878. }
  879. void PCB_EDIT_FRAME::OnConfigurePaths( wxCommandEvent& aEvent )
  880. {
  881. DIALOG_CONFIGURE_PATHS dlg( this, Prj().Get3DCacheManager()->GetResolver() );
  882. dlg.ShowModal();
  883. }
  884. void PCB_EDIT_FRAME::OnUpdatePCBFromSch( wxCommandEvent& event )
  885. {
  886. NETLIST netlist;
  887. if( FetchNetlistFromSchematic( netlist, ANNOTATION_DIALOG ) )
  888. UpdatePCBFromNetlist( netlist );
  889. }
  890. bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist, FETCH_NETLIST_MODE aMode )
  891. {
  892. if( Kiface().IsSingle() )
  893. {
  894. DisplayError( this, _( "Cannot update the PCB, because Pcbnew is "
  895. "opened in stand-alone mode. In order to create or update "
  896. "PCBs from schematics, you need to launch the KiCad project manager "
  897. "and create a PCB project." ) );
  898. return false;
  899. }
  900. // Update PCB requires a netlist. Therefore the schematic editor must be running
  901. // If this is not the case, open the schematic editor
  902. KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
  903. if( !frame->IsShown() )
  904. {
  905. wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(), SchematicFileExtension );
  906. frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
  907. // we show the schematic editor frame, because do not show is seen as
  908. // a not yet opened schematic by Kicad manager, which is not the case
  909. frame->Show( true );
  910. // bring ourselves back to the front
  911. Raise();
  912. }
  913. std::string payload;
  914. if( aMode == NO_ANNOTATION )
  915. payload = "no-annotate";
  916. else if( aMode == QUIET_ANNOTATION )
  917. payload = "quiet-annotate";
  918. Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_GET_NETLIST, payload, this );
  919. try
  920. {
  921. auto lineReader = new STRING_LINE_READER( payload, _( "Eeschema netlist" ) );
  922. KICAD_NETLIST_READER netlistReader( lineReader, &aNetlist );
  923. netlistReader.LoadNetlist();
  924. }
  925. catch( const IO_ERROR& )
  926. {
  927. assert( false ); // should never happen
  928. return false;
  929. }
  930. return true;
  931. }
  932. void PCB_EDIT_FRAME::UpdatePCBFromNetlist( NETLIST& aNetlist )
  933. {
  934. DIALOG_UPDATE_PCB updateDialog( this, &aNetlist );
  935. updateDialog.ShowModal();
  936. auto selectionTool = static_cast<SELECTION_TOOL*>(
  937. m_toolManager->FindTool( "pcbnew.InteractiveSelection" ) );
  938. if( !selectionTool->GetSelection().Empty() )
  939. GetToolManager()->InvokeTool( "pcbnew.InteractiveEdit" );
  940. }
  941. void PCB_EDIT_FRAME::DoUpdatePCBFromNetlist( NETLIST& aNetlist, bool aUseTimestamps )
  942. {
  943. BOARD_NETLIST_UPDATER updater( this, GetBoard() );
  944. updater.SetLookupByTimestamp( aUseTimestamps );
  945. updater.SetDeleteUnusedComponents( false );
  946. updater.SetReplaceFootprints( true );
  947. updater.SetDeleteSinglePadNets( false );
  948. updater.UpdateNetlist( aNetlist );
  949. }
  950. void PCB_EDIT_FRAME::OnRunEeschema( wxCommandEvent& event )
  951. {
  952. wxString msg;
  953. wxFileName schfn( Prj().GetProjectPath(), Prj().GetProjectName(), SchematicFileExtension );
  954. if( !schfn.FileExists() )
  955. {
  956. msg.Printf( _( "Schematic file \"%s\" not found." ), schfn.GetFullPath() );
  957. wxMessageBox( msg, _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
  958. return;
  959. }
  960. if( Kiface().IsSingle() )
  961. {
  962. wxString filename = wxT( "\"" ) + schfn.GetFullPath( wxPATH_NATIVE ) + wxT( "\"" );
  963. ExecuteFile( this, EESCHEMA_EXE, filename );
  964. }
  965. else
  966. {
  967. KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, false );
  968. // Please: note: DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers() calls
  969. // Kiway.Player( FRAME_SCH, true )
  970. // therefore, the schematic editor is sometimes running, but the schematic project
  971. // is not loaded, if the library editor was called, and the dialog field editor was used.
  972. // On linux, it happens the first time the schematic editor is launched, if
  973. // library editor was running, and the dialog field editor was open
  974. // On Windows, it happens always after the library editor was called,
  975. // and the dialog field editor was used
  976. if( !frame )
  977. {
  978. try
  979. {
  980. frame = Kiway().Player( FRAME_SCH, true );
  981. }
  982. catch( const IO_ERROR& err )
  983. {
  984. wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(),
  985. _( "KiCad Error" ), wxOK | wxICON_ERROR, this );
  986. return;
  987. }
  988. }
  989. if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
  990. // but no project loaded.
  991. {
  992. frame->OpenProjectFiles( std::vector<wxString>( 1, schfn.GetFullPath() ) );
  993. frame->Show( true );
  994. }
  995. // On Windows, Raise() does not bring the window on screen, when iconized or not shown
  996. // On linux, Raise() brings the window on screen, but this code works fine
  997. if( frame->IsIconized() )
  998. {
  999. frame->Iconize( false );
  1000. // If an iconized frame was created by Pcbnew, Iconize( false ) is not enough
  1001. // to show the frame at its normal size: Maximize should be called.
  1002. frame->Maximize( false );
  1003. }
  1004. frame->Raise();
  1005. }
  1006. }
  1007. void PCB_EDIT_FRAME::OnFlipPcbView( wxCommandEvent& evt )
  1008. {
  1009. auto view = GetGalCanvas()->GetView();
  1010. view->SetMirror( evt.IsChecked(), false );
  1011. view->RecacheAllItems();
  1012. Refresh();
  1013. }
  1014. void PCB_EDIT_FRAME::PythonPluginsReload()
  1015. {
  1016. // Reload Python plugins if they are newer than
  1017. // the already loaded, and load new plugins
  1018. #if defined(KICAD_SCRIPTING)
  1019. //Reload plugin list: reload Python plugins if they are newer than
  1020. // the already loaded, and load new plugins
  1021. PythonPluginsReloadBase();
  1022. #if defined(KICAD_SCRIPTING_ACTION_MENU)
  1023. // Action plugins can be modified, therefore the plugins menu
  1024. // must be updated:
  1025. RebuildActionPluginMenus();
  1026. // Recreate top toolbar to add action plugin buttons
  1027. ReCreateHToolbar();
  1028. #endif
  1029. #endif
  1030. }
  1031. void PCB_EDIT_FRAME::InstallFootprintPropertiesDialog( MODULE* Module, wxDC* DC )
  1032. {
  1033. if( Module == NULL )
  1034. return;
  1035. #ifdef __WXMAC__
  1036. // avoid Avoid "writes" in the dialog, creates errors with WxOverlay and NSView & Modal
  1037. // Raising an Exception - Fixes #764678
  1038. DC = NULL;
  1039. #endif
  1040. DIALOG_FOOTPRINT_BOARD_EDITOR* dlg = new DIALOG_FOOTPRINT_BOARD_EDITOR( this, Module, DC );
  1041. int retvalue = dlg->ShowModal();
  1042. /* retvalue =
  1043. * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_UPDATE_FP if update footprint
  1044. * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if change footprint
  1045. * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command
  1046. * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edit
  1047. */
  1048. dlg->Close();
  1049. dlg->Destroy();
  1050. if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_OK )
  1051. {
  1052. #ifdef __WXMAC__
  1053. // If something edited, push a refresh request
  1054. m_canvas->Refresh();
  1055. #endif
  1056. }
  1057. else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_BOARD_FOOTPRINT )
  1058. {
  1059. FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
  1060. editor->Load_Module_From_BOARD( Module );
  1061. SetCurItem( NULL );
  1062. editor->Show( true );
  1063. editor->Raise(); // Iconize( false );
  1064. }
  1065. else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_EDIT_LIBRARY_FOOTPRINT )
  1066. {
  1067. FOOTPRINT_EDIT_FRAME* editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_PCB_MODULE_EDITOR, true );
  1068. editor->LoadModuleFromLibrary( Module->GetFPID() );
  1069. SetCurItem( NULL );
  1070. editor->Show( true );
  1071. editor->Raise(); // Iconize( false );
  1072. }
  1073. else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_WANT_UPDATE_FP )
  1074. {
  1075. InstallExchangeModuleFrame( Module, true, true );
  1076. }
  1077. else if( retvalue == DIALOG_FOOTPRINT_BOARD_EDITOR::PRM_EDITOR_WANT_EXCHANGE_FP )
  1078. {
  1079. InstallExchangeModuleFrame( Module, false, true );
  1080. }
  1081. }
  1082. int PCB_EDIT_FRAME::InstallExchangeModuleFrame( MODULE* aModule, bool updateMode,
  1083. bool selectedMode )
  1084. {
  1085. DIALOG_EXCHANGE_FOOTPRINTS dialog( this, aModule, updateMode, selectedMode );
  1086. return dialog.ShowQuasiModal();
  1087. }
  1088. void PCB_EDIT_FRAME::CommonSettingsChanged()
  1089. {
  1090. PCB_BASE_EDIT_FRAME::CommonSettingsChanged();
  1091. ReCreateMicrowaveVToolbar();
  1092. Layout();
  1093. SendSizeEvent();
  1094. }
  1095. void PCB_EDIT_FRAME::LockModule( MODULE* aModule, bool aLocked )
  1096. {
  1097. const wxString ModulesMaskSelection = wxT( "*" );
  1098. if( aModule )
  1099. {
  1100. aModule->SetLocked( aLocked );
  1101. SetMsgPanel( aModule );
  1102. OnModify();
  1103. }
  1104. else
  1105. {
  1106. aModule = GetBoard()->m_Modules;
  1107. for( ; aModule != NULL; aModule = aModule->Next() )
  1108. {
  1109. if( WildCompareString( ModulesMaskSelection, aModule->GetReference() ) )
  1110. {
  1111. aModule->SetLocked( aLocked );
  1112. OnModify();
  1113. }
  1114. }
  1115. }
  1116. }
  1117. bool ExportBoardToHyperlynx( BOARD* aBoard, const wxFileName& aPath );
  1118. void PCB_EDIT_FRAME::OnExportHyperlynx( wxCommandEvent& event )
  1119. {
  1120. wxString wildcard = wxT("*.hyp");
  1121. wxFileName fn = GetBoard()->GetFileName();
  1122. fn.SetExt( wxT("hyp") );
  1123. wxFileDialog dlg( this,
  1124. _( "Export Hyperlynx Layout" ),
  1125. fn.GetPath(),
  1126. fn.GetFullName(),
  1127. wildcard,
  1128. wxFD_SAVE | wxFD_OVERWRITE_PROMPT
  1129. );
  1130. if( dlg.ShowModal() != wxID_OK )
  1131. return;
  1132. fn = dlg.GetPath();
  1133. // always enforce filename extension, user may not have entered it.
  1134. fn.SetExt( wxT("hyp") );
  1135. ExportBoardToHyperlynx( GetBoard(), fn );
  1136. }