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.

1408 lines
42 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
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
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
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include <fctsys.h>
  25. #include <kiface_i.h>
  26. #include <pgm_base.h>
  27. #include <gr_basic.h>
  28. #include <sch_draw_panel.h>
  29. #include <gestfich.h>
  30. #include <confirm.h>
  31. #include <base_units.h>
  32. #include <msgpanel.h>
  33. #include <html_messagebox.h>
  34. #include <executable_names.h>
  35. #include <eda_dockart.h>
  36. #include <profile.h>
  37. #include <advanced_config.h>
  38. #include <general.h>
  39. #include <eeschema_id.h>
  40. #include <netlist.h>
  41. #include <class_library.h>
  42. #include <sch_edit_frame.h>
  43. #include <symbol_lib_table.h>
  44. #include <reporter.h>
  45. #include <lib_edit_frame.h>
  46. #include <viewlib_frame.h>
  47. #include <hotkeys.h>
  48. #include <eeschema_config.h>
  49. #include <sch_sheet.h>
  50. #include "sim/sim_plot_frame.h"
  51. #include <invoke_sch_dialog.h>
  52. #include <dialogs/dialog_schematic_find.h>
  53. #include <dialog_symbol_remap.h>
  54. #include <view/view.h>
  55. #include <tool/tool_manager.h>
  56. #include <tools/sch_actions.h>
  57. #include <tools/sch_selection_tool.h>
  58. #include <wx/display.h>
  59. #include <build_version.h>
  60. #include <wildcards_and_files_ext.h>
  61. #include <connection_graph.h>
  62. #include <dialogs/dialog_fields_editor_global.h>
  63. #include <sch_view.h>
  64. #include <sch_painter.h>
  65. #include <gal/graphics_abstraction_layer.h>
  66. SCH_SHEET_PATH* g_CurrentSheet = nullptr; // declared in general.h
  67. CONNECTION_GRAPH* g_ConnectionGraph = nullptr;
  68. // non-member so it can be moved easily, and kept REALLY private.
  69. // Do NOT Clear() in here.
  70. static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
  71. {
  72. for( unsigned i=0; i<aSrc.GetCount(); ++i )
  73. aDst->AddPaths( aSrc[i], aIndex );
  74. }
  75. // non-member so it can be moved easily, and kept REALLY private.
  76. // Do NOT Clear() in here.
  77. static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
  78. {
  79. for( int i=1; true; ++i )
  80. {
  81. wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
  82. wxString upath = aCfg->Read( key, wxEmptyString );
  83. if( !upath )
  84. break;
  85. aDst->AddPaths( upath, aIndex );
  86. }
  87. }
  88. //-----<SCH "data on demand" functions>-------------------------------------------
  89. SEARCH_STACK* PROJECT::SchSearchS()
  90. {
  91. SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK );
  92. wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
  93. if( !ss )
  94. {
  95. ss = new SEARCH_STACK();
  96. // Make PROJECT the new SEARCH_STACK owner.
  97. SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss );
  98. // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
  99. ss->AddPaths( m_project_name.GetPath() );
  100. // next add the paths found in *.pro, variable "LibDir"
  101. wxString libDir;
  102. try
  103. {
  104. PART_LIBS::LibNamesAndPaths( this, false, &libDir );
  105. }
  106. catch( const IO_ERROR& DBG( ioe ) )
  107. {
  108. DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
  109. }
  110. if( !!libDir )
  111. {
  112. wxArrayString paths;
  113. SEARCH_STACK::Split( &paths, libDir );
  114. for( unsigned i =0; i<paths.GetCount(); ++i )
  115. {
  116. wxString path = AbsolutePath( paths[i] );
  117. ss->AddPaths( path ); // at the end
  118. }
  119. }
  120. // append all paths from aSList
  121. add_search_paths( ss, Kiface().KifaceSearch(), -1 );
  122. // addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
  123. // This is undocumented, but somebody wanted to store !schematic!
  124. // library search paths in the .kicad_common file?
  125. add_search_paths( ss, Pgm().CommonSettings(), -1 );
  126. }
  127. return ss;
  128. }
  129. PART_LIBS* PROJECT::SchLibs()
  130. {
  131. PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS );
  132. wxASSERT( !libs || libs->Type() == PART_LIBS_T );
  133. if( !libs )
  134. {
  135. libs = new PART_LIBS();
  136. // Make PROJECT the new PART_LIBS owner.
  137. SetElem( PROJECT::ELEM_SCH_PART_LIBS, libs );
  138. try
  139. {
  140. libs->LoadAllLibraries( this );
  141. }
  142. catch( const PARSE_ERROR& pe )
  143. {
  144. wxString lib_list = UTF8( pe.inputLine );
  145. wxWindow* parent = Pgm().App().GetTopWindow();
  146. // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
  147. HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
  148. dlg.MessageSet( _( "The following libraries were not found:" ) );
  149. dlg.ListSet( lib_list );
  150. dlg.Layout();
  151. dlg.ShowModal();
  152. }
  153. catch( const IO_ERROR& ioe )
  154. {
  155. wxWindow* parent = Pgm().App().GetTopWindow();
  156. DisplayError( parent, ioe.What() );
  157. }
  158. }
  159. return libs;
  160. }
  161. //-----</SCH "data on demand" functions>------------------------------------------
  162. BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
  163. EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
  164. EVT_SOCKET( ID_EDA_SOCKET_EVENT, EDA_DRAW_FRAME::OnSockRequest )
  165. EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
  166. EVT_SIZE( SCH_EDIT_FRAME::OnSize )
  167. EVT_MENU( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
  168. EVT_MENU( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
  169. EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, SCH_EDIT_FRAME::OnLoadFile )
  170. EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject )
  171. EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject )
  172. EVT_TOOL( ID_NEW_PROJECT, SCH_EDIT_FRAME::OnNewProject )
  173. EVT_TOOL( ID_LOAD_PROJECT, SCH_EDIT_FRAME::OnLoadProject )
  174. EVT_MENU( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnSaveProject )
  175. EVT_MENU( ID_UPDATE_ONE_SHEET, SCH_EDIT_FRAME::Save_File )
  176. EVT_MENU( ID_SAVE_ONE_SHEET_UNDER_NEW_NAME, SCH_EDIT_FRAME::Save_File )
  177. EVT_MENU( ID_GEN_PLOT_SCHEMATIC, SCH_EDIT_FRAME::PlotSchematic )
  178. EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard )
  179. EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
  180. EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
  181. EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
  182. EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, SCH_EDIT_FRAME::Process_Config )
  183. EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnPreferencesOptions )
  184. EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, SCH_EDIT_FRAME::OnConfigurePaths )
  185. EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
  186. EVT_TOOL( ID_TO_LIBVIEW, SCH_EDIT_FRAME::OnOpenLibraryViewer )
  187. EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
  188. EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
  189. EVT_MENU( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, SCH_EDIT_FRAME::OnEditComponentSymbolsId )
  190. EVT_TOOL( ID_RUN_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
  191. EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor )
  192. EVT_TOOL( ID_RUN_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
  193. EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
  194. EVT_TOOL( ID_HIERARCHY, SCH_EDIT_FRAME::Process_Special_Functions )
  195. EVT_TOOL( wxID_UNDO, SCH_EDIT_FRAME::GetSchematicFromUndoList )
  196. EVT_TOOL( wxID_REDO, SCH_EDIT_FRAME::GetSchematicFromRedoList )
  197. EVT_TOOL( ID_GET_ANNOTATE, SCH_EDIT_FRAME::OnAnnotate )
  198. EVT_TOOL( wxID_PRINT, SCH_EDIT_FRAME::OnPrint )
  199. EVT_TOOL( ID_GET_ERC, SCH_EDIT_FRAME::OnErc )
  200. EVT_TOOL( ID_GET_NETLIST, SCH_EDIT_FRAME::OnCreateNetlist )
  201. EVT_TOOL( ID_UPDATE_PCB_FROM_SCH, SCH_EDIT_FRAME::OnUpdatePCB )
  202. EVT_TOOL( ID_GET_TOOLS, SCH_EDIT_FRAME::OnCreateBillOfMaterials )
  203. EVT_TOOL( ID_OPEN_CMP_TABLE, SCH_EDIT_FRAME::OnLaunchBomManager )
  204. EVT_TOOL( ID_BUS_MANAGER, SCH_EDIT_FRAME::OnLaunchBusManager )
  205. EVT_TOOL( ID_FIND_ITEMS, SCH_EDIT_FRAME::OnFindItems )
  206. EVT_TOOL( wxID_REPLACE, SCH_EDIT_FRAME::OnFindItems )
  207. EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile )
  208. EVT_TOOL( ID_UPDATE_FIELDS, SCH_EDIT_FRAME::OnUpdateFields )
  209. EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
  210. EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
  211. EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
  212. EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
  213. EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
  214. #ifdef KICAD_SPICE
  215. EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate )
  216. #endif /* KICAD_SPICE */
  217. EVT_MENU( ID_CANCEL_CURRENT_COMMAND, SCH_EDIT_FRAME::OnCancelCurrentCommand )
  218. EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
  219. SCH_EDIT_FRAME::Process_Special_Functions )
  220. EVT_MENU( ID_SCH_UNFOLD_BUS, SCH_EDIT_FRAME::OnUnfoldBusHotkey )
  221. EVT_MENU( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnSwitchCanvas )
  222. EVT_MENU( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnSwitchCanvas )
  223. // Tools and buttons options toolbar
  224. EVT_TOOL( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnSelectOptionToolbar )
  225. EVT_TOOL( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnSelectOptionToolbar )
  226. EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
  227. SCH_EDIT_FRAME::Process_Special_Functions )
  228. EVT_MENU_RANGE( ID_POPUP_SCH_SELECT_UNIT1, ID_POPUP_SCH_SELECT_UNIT_CMP_MAX,
  229. SCH_EDIT_FRAME::OnSelectUnit )
  230. /* Handle user interface update events. */
  231. EVT_UPDATE_UI( wxID_PASTE, SCH_EDIT_FRAME::OnUpdatePaste )
  232. EVT_UPDATE_UI( ID_TB_OPTIONS_HIDDEN_PINS, SCH_EDIT_FRAME::OnUpdateHiddenPins )
  233. EVT_UPDATE_UI( ID_TB_OPTIONS_BUS_WIRES_ORIENT, SCH_EDIT_FRAME::OnUpdateBusOrientation )
  234. EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnUpdateSelectTool )
  235. EVT_UPDATE_UI( ID_HIGHLIGHT_BUTT, SCH_EDIT_FRAME::OnUpdateSelectTool )
  236. EVT_UPDATE_UI( ID_ZOOM_SELECTION, SCH_EDIT_FRAME::OnUpdateSelectTool )
  237. EVT_UPDATE_UI_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
  238. SCH_EDIT_FRAME::OnUpdateSelectTool )
  239. EVT_UPDATE_UI( ID_SAVE_PROJECT, SCH_EDIT_FRAME::OnUpdateSave )
  240. EVT_UPDATE_UI( ID_UPDATE_ONE_SHEET, SCH_EDIT_FRAME::OnUpdateSaveSheet )
  241. EVT_UPDATE_UI( ID_POPUP_SCH_LEAVE_SHEET, SCH_EDIT_FRAME::OnUpdateHierarchySheet )
  242. EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
  243. EVT_UPDATE_UI( ID_MENU_CANVAS_CAIRO, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
  244. EVT_UPDATE_UI( ID_MENU_CANVAS_OPENGL, SCH_EDIT_FRAME::OnUpdateSwitchCanvas )
  245. /* Search dialog events. */
  246. EVT_FIND_CLOSE( wxID_ANY, SCH_EDIT_FRAME::OnFindDialogClose )
  247. EVT_FIND_DRC_MARKER( wxID_ANY, SCH_EDIT_FRAME::OnFindDrcMarker )
  248. EVT_FIND( wxID_ANY, SCH_EDIT_FRAME::OnFindSchematicItem )
  249. EVT_FIND_REPLACE( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
  250. EVT_FIND_REPLACE_ALL( wxID_ANY, SCH_EDIT_FRAME::OnFindReplace )
  251. END_EVENT_TABLE()
  252. SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
  253. SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
  254. wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
  255. m_item_to_repeat( 0 )
  256. {
  257. g_CurrentSheet = new SCH_SHEET_PATH();
  258. g_ConnectionGraph = new CONNECTION_GRAPH( this );
  259. m_showAxis = false; // true to show axis
  260. m_showBorderAndTitleBlock = true; // true to show sheet references
  261. m_DefaultSchematicFileName = NAMELESS_PROJECT;
  262. m_DefaultSchematicFileName += wxT( ".sch" );
  263. m_showAllPins = false;
  264. m_printMonochrome = true;
  265. m_printSheetReference = true;
  266. SetShowPageLimits( true );
  267. m_hotkeysDescrList = g_Schematic_Hotkeys_Descr;
  268. m_dlgFindReplace = NULL;
  269. m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
  270. m_findReplaceStatus = new wxString( wxEmptyString );
  271. m_undoItem = NULL;
  272. m_hasAutoSave = true;
  273. m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
  274. SetForceHVLines( true );
  275. SetSpiceAjustPassiveValues( false );
  276. // Give an icon
  277. wxIcon icon;
  278. icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
  279. SetIcon( icon );
  280. // Initialize grid id to the default value (50 mils):
  281. m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
  282. LoadSettings( config() );
  283. CreateScreens();
  284. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  285. if( m_canvas )
  286. m_canvas->SetEnableBlockCommands( true );
  287. ReCreateMenuBar();
  288. ReCreateHToolbar();
  289. ReCreateVToolbar();
  290. ReCreateOptToolbar();
  291. // Initialize common print setup dialog settings.
  292. m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
  293. m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
  294. m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
  295. m_pageSetupData.GetPrintData().SetNoCopies( 1 );
  296. m_auimgr.SetManagedWindow( this );
  297. m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
  298. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  299. m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
  300. m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
  301. m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  302. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  303. m_auimgr.Update();
  304. setupTools();
  305. GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
  306. GetToolManager()->RunAction( "common.Control.zoomFitScreen", true );
  307. if( GetGalCanvas() )
  308. GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
  309. // Net list generator
  310. DefaultExecFlags();
  311. Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
  312. ID_EDIT_SYM_LIB_TABLE );
  313. UpdateTitle();
  314. }
  315. SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
  316. {
  317. Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
  318. ID_EDIT_SYM_LIB_TABLE );
  319. delete m_item_to_repeat; // we own the cloned object, see this->SetRepeatItem()
  320. SetScreen( NULL );
  321. delete g_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
  322. delete g_ConnectionGraph;
  323. delete m_undoItem;
  324. delete m_findReplaceData;
  325. delete m_findReplaceStatus;
  326. delete g_RootSheet;
  327. g_CurrentSheet = nullptr;
  328. g_ConnectionGraph = nullptr;
  329. g_RootSheet = NULL;
  330. }
  331. void SCH_EDIT_FRAME::SetRepeatItem( SCH_ITEM* aItem )
  332. {
  333. // we cannot store a pointer to an item in the display list here since
  334. // that item may be deleted, such as part of a line concatonation or other.
  335. // So simply always keep a copy of the object which is to be repeated.
  336. SCH_ITEM* old = m_item_to_repeat;
  337. SCH_ITEM* cur = aItem;
  338. if( cur != old )
  339. {
  340. if( cur )
  341. {
  342. aItem = (SCH_ITEM*) cur->Clone();
  343. // Clone() preserves the flags, we want 'em cleared.
  344. aItem->ClearFlags();
  345. }
  346. m_item_to_repeat = aItem;
  347. delete old;
  348. }
  349. }
  350. void SCH_EDIT_FRAME::SetSheetNumberAndCount()
  351. {
  352. SCH_SCREEN* screen;
  353. SCH_SCREENS s_list;
  354. /* Set the sheet count, and the sheet number (1 for root sheet)
  355. */
  356. int sheet_count = g_RootSheet->CountSheets();
  357. int SheetNumber = 1;
  358. wxString current_sheetpath = g_CurrentSheet->Path();
  359. SCH_SHEET_LIST sheetList( g_RootSheet );
  360. // Examine all sheets path to find the current sheets path,
  361. // and count them from root to the current sheet path:
  362. for( unsigned i = 0; i < sheetList.size(); i++ )
  363. {
  364. wxString sheetpath = sheetList[i].Path();
  365. if( sheetpath == current_sheetpath ) // Current sheet path found
  366. break;
  367. SheetNumber++; /* Not found, increment sheet
  368. * number before this current
  369. * path */
  370. }
  371. g_CurrentSheet->SetPageNumber( SheetNumber );
  372. for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
  373. {
  374. screen->m_NumberOfScreens = sheet_count;
  375. }
  376. GetScreen()->m_ScreenNumber = SheetNumber;
  377. }
  378. SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
  379. {
  380. return g_CurrentSheet->LastScreen();
  381. }
  382. wxString SCH_EDIT_FRAME::GetScreenDesc() const
  383. {
  384. wxString s = g_CurrentSheet->PathHumanReadable();
  385. return s;
  386. }
  387. void SCH_EDIT_FRAME::CreateScreens()
  388. {
  389. if( g_RootSheet == NULL )
  390. {
  391. g_RootSheet = new SCH_SHEET();
  392. }
  393. if( g_RootSheet->GetScreen() == NULL )
  394. {
  395. SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
  396. screen->SetMaxUndoItems( m_UndoRedoCountMax );
  397. g_RootSheet->SetScreen( screen );
  398. SetScreen( g_RootSheet->GetScreen() );
  399. }
  400. g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
  401. g_CurrentSheet->clear();
  402. g_CurrentSheet->push_back( g_RootSheet );
  403. g_ConnectionGraph->Reset();
  404. if( GetScreen() == NULL )
  405. {
  406. SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
  407. screen->SetMaxUndoItems( m_UndoRedoCountMax );
  408. SetScreen( screen );
  409. }
  410. GetScreen()->SetZoom( 32.0 );
  411. }
  412. SCH_SHEET_PATH& SCH_EDIT_FRAME::GetCurrentSheet()
  413. {
  414. wxASSERT_MSG( g_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME g_CurrentSheet member is NULL." ) );
  415. return *g_CurrentSheet;
  416. }
  417. void SCH_EDIT_FRAME::SetCurrentSheet( const SCH_SHEET_PATH& aSheet )
  418. {
  419. if( aSheet != *g_CurrentSheet )
  420. {
  421. *g_CurrentSheet = aSheet;
  422. static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( g_CurrentSheet->LastScreen() );
  423. }
  424. }
  425. void SCH_EDIT_FRAME::HardRedraw()
  426. {
  427. static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( g_CurrentSheet->LastScreen() );
  428. GetGalCanvas()->ForceRefresh();
  429. }
  430. /*
  431. * Redraws only the active window which is assumed to be whole visible.
  432. */
  433. void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
  434. {
  435. if( GetScreen() == NULL )
  436. return;
  437. if( m_canvas->IsMouseCaptured() )
  438. m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
  439. // Display the sheet filename, and the sheet path, for non root sheets
  440. UpdateTitle();
  441. }
  442. void SCH_EDIT_FRAME::SetUndoItem( const SCH_ITEM* aItem )
  443. {
  444. // if aItem != NULL, delete a previous m_undoItem, if exists
  445. // if aItme = NULL, just clear m_undoItem,
  446. // because when calling SetUndoItem( NULL ), we only clear m_undoItem,
  447. // because the owner of m_undoItem is no more me.
  448. if( aItem && m_undoItem )
  449. {
  450. delete m_undoItem;
  451. }
  452. m_undoItem = NULL;
  453. if( aItem )
  454. m_undoItem = (SCH_ITEM*) aItem->Clone();
  455. }
  456. void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem, bool aAppend )
  457. {
  458. wxCHECK_RET( aItem != NULL,
  459. wxT( "Cannot swap undo item structures. Bad programmer!." ) );
  460. wxCHECK_RET( m_undoItem != NULL,
  461. wxT( "Cannot swap undo item structures. Bad programmer!." ) );
  462. wxCHECK_RET( aItem->Type() == m_undoItem->Type(),
  463. wxT( "Cannot swap undo item structures. Bad programmer!." ) );
  464. aItem->SwapData( m_undoItem );
  465. SaveCopyInUndoList( aItem, UR_CHANGED, aAppend );
  466. aItem->SwapData( m_undoItem );
  467. }
  468. void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
  469. {
  470. if( Kiface().IsSingle() )
  471. {
  472. LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
  473. if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
  474. return;
  475. LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
  476. if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
  477. return;
  478. viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
  479. if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
  480. return;
  481. }
  482. SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
  483. if( simFrame && !simFrame->Close() ) // Can close the simulator?
  484. return;
  485. SCH_SHEET_LIST sheetList( g_RootSheet );
  486. if( sheetList.IsModified() )
  487. {
  488. wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  489. wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
  490. if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName ),
  491. [&]()->bool { return SaveProject(); } ) )
  492. {
  493. aEvent.Veto();
  494. return;
  495. }
  496. }
  497. // Close the find dialog and preserve it's setting if it is displayed.
  498. if( m_dlgFindReplace )
  499. {
  500. m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
  501. m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
  502. m_dlgFindReplace->Destroy();
  503. m_dlgFindReplace = NULL;
  504. }
  505. SCH_SCREENS screens;
  506. wxFileName fn;
  507. for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
  508. {
  509. fn = Prj().AbsolutePath( screen->GetFileName() );
  510. // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
  511. fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
  512. if( fn.FileExists() && fn.IsFileWritable() )
  513. wxRemoveFile( fn.GetFullPath() );
  514. }
  515. sheetList.ClearModifyStatus();
  516. wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  517. if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() &&
  518. g_RootSheet->GetScreen()->GetDrawItems() != NULL )
  519. {
  520. UpdateFileHistory( fileName );
  521. }
  522. g_RootSheet->GetScreen()->Clear();
  523. // all sub sheets are deleted, only the main sheet is usable
  524. g_CurrentSheet->clear();
  525. Destroy();
  526. }
  527. double SCH_EDIT_FRAME::BestZoom()
  528. {
  529. double sizeX = (double) GetScreen()->GetPageSettings().GetWidthIU();
  530. double sizeY = (double) GetScreen()->GetPageSettings().GetHeightIU();
  531. wxPoint centre( wxPoint( sizeX / 2, sizeY / 2 ) );
  532. // The sheet boundary already affords us some margin, so add only an
  533. // additional 5%.
  534. double margin_scale_factor = 1.05;
  535. return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
  536. }
  537. wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
  538. {
  539. wxFileName fn = GetScreen()->GetFileName();
  540. // Name is <root sheet filename>-<sheet path> and has no extension.
  541. // However if filename is too long name is <sheet filename>-<sheet number>
  542. #define FN_LEN_MAX 80 // A reasonable value for the short filename len
  543. wxString filename = fn.GetName();
  544. wxString sheetFullName = g_CurrentSheet->PathHumanReadable();
  545. // Remove the last '/' of the path human readable
  546. // (and for the root sheet, make sheetFullName empty):
  547. sheetFullName.RemoveLast();
  548. sheetFullName.Trim( true );
  549. sheetFullName.Trim( false );
  550. // Convert path human readable separator to '-'
  551. sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
  552. if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
  553. filename += sheetFullName;
  554. else
  555. filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
  556. return filename;
  557. }
  558. void SCH_EDIT_FRAME::OnModify()
  559. {
  560. GetScreen()->SetModify();
  561. GetScreen()->SetSave();
  562. m_foundItems.SetForceSearch();
  563. if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
  564. RecalculateConnections( false );
  565. m_canvas->Refresh();
  566. }
  567. void SCH_EDIT_FRAME::OnUpdatePaste( wxUpdateUIEvent& event )
  568. {
  569. event.Enable( m_blockItems.GetCount() > 0 );
  570. }
  571. void SCH_EDIT_FRAME::OnUpdateBusOrientation( wxUpdateUIEvent& aEvent )
  572. {
  573. wxString tool_tip = GetForceHVLines() ?
  574. _( "Draw wires and buses in any direction" ) :
  575. _( "Draw horizontal and vertical wires and buses only" );
  576. aEvent.Check( GetForceHVLines() );
  577. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT, tool_tip );
  578. }
  579. void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent )
  580. {
  581. wxString tool_tip = m_showAllPins ? _( "Do not show hidden pins" ) :
  582. _( "Show hidden pins" );
  583. aEvent.Check( m_showAllPins );
  584. m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS, tool_tip );
  585. }
  586. void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
  587. {
  588. SCH_SHEET_LIST sheetList( g_RootSheet );
  589. aEvent.Enable( sheetList.IsModified() );
  590. }
  591. void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent )
  592. {
  593. SCH_SCREENS schematic;
  594. // The remapping can only be performed on legacy projects.
  595. aEvent.Enable( schematic.HasNoFullyDefinedLibIds() );
  596. }
  597. void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent )
  598. {
  599. aEvent.Enable( GetScreen()->IsModify() );
  600. }
  601. void SCH_EDIT_FRAME::OnUpdateHierarchySheet( wxUpdateUIEvent& aEvent )
  602. {
  603. aEvent.Enable( g_CurrentSheet->Last() != g_RootSheet );
  604. }
  605. void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
  606. {
  607. // See if it's already open...
  608. wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
  609. if( erc )
  610. // Bring it to the top if already open. Dual monitor users need this.
  611. erc->Raise();
  612. else
  613. InvokeDialogERC( this );
  614. }
  615. void SCH_EDIT_FRAME::CloseErc()
  616. {
  617. // Find the ERC dialog if it's open and close it
  618. wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
  619. if( erc )
  620. erc->Close( false );
  621. }
  622. void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
  623. {
  624. std::string payload;
  625. Kiway().ExpressMail( FRAME_PCB, MAIL_PCB_UPDATE, payload, this );
  626. }
  627. void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )
  628. {
  629. int result;
  630. do
  631. {
  632. result = InvokeDialogNetList( this );
  633. // If a plugin is removed or added, rebuild and reopen the new dialog
  634. } while( result == NET_PLUGIN_CHANGE );
  635. }
  636. void SCH_EDIT_FRAME::OnCreateBillOfMaterials( wxCommandEvent& )
  637. {
  638. InvokeDialogCreateBOM( this );
  639. }
  640. void SCH_EDIT_FRAME::OnLaunchBomManager( wxCommandEvent& event )
  641. {
  642. DIALOG_FIELDS_EDITOR_GLOBAL dlg( this );
  643. dlg.ShowQuasiModal();
  644. }
  645. void SCH_EDIT_FRAME::OnLaunchBusManager( wxCommandEvent& )
  646. {
  647. InvokeDialogBusManager( this );
  648. }
  649. void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& aEvent )
  650. {
  651. wxCHECK_RET( m_findReplaceData != NULL,
  652. wxT( "Forgot to create find/replace data. Bad Programmer!" ) );
  653. if( m_dlgFindReplace )
  654. {
  655. delete m_dlgFindReplace;
  656. m_dlgFindReplace = NULL;
  657. }
  658. int style = 0;
  659. if( aEvent.GetId() == wxID_REPLACE )
  660. style = wxFR_REPLACEDIALOG;
  661. m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, m_findReplaceStatus,
  662. wxDefaultPosition, wxDefaultSize, style );
  663. m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
  664. m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
  665. m_dlgFindReplace->Show( true );
  666. }
  667. void SCH_EDIT_FRAME::OnFindDialogClose( wxFindDialogEvent& event )
  668. {
  669. // If the user dismissed the dialog with the mouse, this will send the cursor back
  670. // to the last item found.
  671. OnFindSchematicItem( event );
  672. if( m_dlgFindReplace )
  673. {
  674. m_findStringHistoryList = m_dlgFindReplace->GetFindEntries();
  675. m_replaceStringHistoryList = m_dlgFindReplace->GetReplaceEntries();
  676. m_dlgFindReplace->Destroy();
  677. m_dlgFindReplace = NULL;
  678. }
  679. }
  680. void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
  681. {
  682. wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
  683. if( fn.size() )
  684. OpenProjectFiles( std::vector<wxString>( 1, fn ) );
  685. }
  686. void SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile( wxCommandEvent& event )
  687. {
  688. LoadCmpToFootprintLinkFile();
  689. m_canvas->Refresh();
  690. }
  691. void SCH_EDIT_FRAME::OnUpdateFields( wxCommandEvent& event )
  692. {
  693. std::list<SCH_COMPONENT*> components;
  694. for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
  695. {
  696. if( item->Type() == SCH_COMPONENT_T )
  697. components.push_back( static_cast<SCH_COMPONENT*>( item ) );
  698. }
  699. if( InvokeDialogUpdateFields( this, components, true ) == wxID_OK )
  700. m_canvas->Refresh();
  701. }
  702. void SCH_EDIT_FRAME::OnNewProject( wxCommandEvent& event )
  703. {
  704. wxString pro_dir = m_mruPath;
  705. wxFileDialog dlg( this, _( "New Schematic" ), pro_dir,
  706. wxEmptyString, SchematicFileWildcard(),
  707. wxFD_SAVE );
  708. if( dlg.ShowModal() != wxID_CANCEL )
  709. {
  710. // Enforce the extension, wxFileDialog is inept.
  711. wxFileName create_me = dlg.GetPath();
  712. create_me.SetExt( SchematicFileExtension );
  713. if( create_me.FileExists() )
  714. {
  715. wxString msg;
  716. msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
  717. DisplayError( this, msg );
  718. return ;
  719. }
  720. // OpenProjectFiles() requires absolute
  721. wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
  722. OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
  723. m_mruPath = create_me.GetPath();
  724. }
  725. }
  726. void SCH_EDIT_FRAME::OnLoadProject( wxCommandEvent& event )
  727. {
  728. wxString pro_dir = m_mruPath;
  729. wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir,
  730. wxEmptyString, SchematicFileWildcard(),
  731. wxFD_OPEN | wxFD_FILE_MUST_EXIST );
  732. if( dlg.ShowModal() != wxID_CANCEL )
  733. {
  734. OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
  735. m_mruPath = Prj().GetProjectPath();
  736. }
  737. }
  738. void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
  739. {
  740. wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  741. if( kicad_board.IsOk() )
  742. {
  743. kicad_board.SetExt( PcbFileExtension );
  744. wxFileName legacy_board( kicad_board );
  745. legacy_board.SetExt( LegacyPcbFileExtension );
  746. wxFileName& boardfn = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
  747. kicad_board : legacy_board;
  748. if( Kiface().IsSingle() )
  749. {
  750. wxString filename = QuoteFullPath( boardfn );
  751. ExecuteFile( this, PCBNEW_EXE, filename );
  752. }
  753. else
  754. {
  755. KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
  756. // a pcb frame can be already existing, but not yet used.
  757. // this is the case when running the footprint editor, or the footprint viewer first
  758. // if the frame is not visible, the board is not yet loaded
  759. if( !frame->IsVisible() )
  760. {
  761. frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
  762. frame->Show( true );
  763. }
  764. // On Windows, Raise() does not bring the window on screen, when iconized
  765. if( frame->IsIconized() )
  766. frame->Iconize( false );
  767. frame->Raise();
  768. }
  769. }
  770. else
  771. {
  772. ExecuteFile( this, PCBNEW_EXE );
  773. }
  774. }
  775. void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
  776. {
  777. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  778. if( fn.IsOk() )
  779. {
  780. KIWAY_PLAYER* fp_editor = Kiway().Player( FRAME_PCB_MODULE_EDITOR );
  781. // On Windows, Raise() does not bring the window on screen, when iconized
  782. if( fp_editor->IsIconized() )
  783. fp_editor->Iconize( false );
  784. fp_editor->Show( true );
  785. fp_editor->Raise();
  786. }
  787. }
  788. void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
  789. {
  790. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  791. fn.SetExt( NetlistFileExtension );
  792. if( !prepareForNetlist() )
  793. return;
  794. try
  795. {
  796. KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
  797. if( !player )
  798. {
  799. player = Kiway().Player( FRAME_CVPCB, true );
  800. player->Show( true );
  801. // player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
  802. }
  803. sendNetlistToCvpcb();
  804. player->Raise();
  805. }
  806. catch( const IO_ERROR& )
  807. {
  808. DisplayError( this, _( "Could not open CvPcb" ) );
  809. }
  810. }
  811. void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
  812. {
  813. LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
  814. if( !libeditFrame )
  815. {
  816. libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
  817. libeditFrame->Show( true );
  818. }
  819. libeditFrame->PushPreferences( m_canvas );
  820. // On Windows, Raise() does not bring the window on screen, when iconized
  821. if( libeditFrame->IsIconized() )
  822. libeditFrame->Iconize( false );
  823. libeditFrame->Raise();
  824. }
  825. void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
  826. {
  827. SCH_SCREENS schematic;
  828. if( schematic.HasNoFullyDefinedLibIds() )
  829. RescueLegacyProject( true );
  830. else
  831. RescueSymbolLibTableProject( true );
  832. }
  833. void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
  834. {
  835. DIALOG_SYMBOL_REMAP dlgRemap( this );
  836. dlgRemap.ShowQuasiModal();
  837. m_canvas->Refresh( true );
  838. }
  839. // This method is not the same as OnRemapSymbols.
  840. // It allows renaming the lib id of groups of components when a symbol
  841. // has moved from a library to another library.
  842. // For instance to rename libname1::mysymbol to libname2::mysymbol
  843. // or any other lib id name
  844. void SCH_EDIT_FRAME::OnEditComponentSymbolsId( wxCommandEvent& event )
  845. {
  846. InvokeDialogEditComponentsLibId( this );
  847. m_canvas->Refresh( true );
  848. }
  849. void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
  850. {
  851. Close( false );
  852. }
  853. void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
  854. {
  855. InvokeDialogPrintUsingPrinter( this );
  856. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  857. if( fn.GetName() != NAMELESS_PROJECT )
  858. Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
  859. }
  860. void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
  861. {
  862. wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
  863. GRSetDrawMode( aDC, GR_DEFAULT_DRAWMODE );
  864. GetScreen()->Draw( m_canvas, aDC );
  865. DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName );
  866. }
  867. bool SCH_EDIT_FRAME::isAutoSaveRequired() const
  868. {
  869. // In case this event happens before g_RootSheet is initialized which does happen
  870. // on mingw64 builds.
  871. if( g_RootSheet != NULL )
  872. {
  873. SCH_SCREENS screenList;
  874. for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
  875. {
  876. if( screen->IsSave() )
  877. return true;
  878. }
  879. }
  880. return false;
  881. }
  882. void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppend )
  883. {
  884. SCH_SCREEN* screen = GetScreen();
  885. wxCHECK_RET( aItem != NULL, wxT( "Cannot add current aItem to list." ) );
  886. m_canvas->SetAutoPanRequest( false );
  887. SCH_SHEET* parentSheet = nullptr;
  888. SCH_COMPONENT* parentComponent = nullptr;
  889. SCH_ITEM* undoItem = aItem;
  890. if( aItem->Type() == SCH_SHEET_PIN_T )
  891. {
  892. parentSheet = (SCH_SHEET*) aItem->GetParent();
  893. wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
  894. wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
  895. undoItem = parentSheet;
  896. }
  897. else if( aItem->Type() == SCH_FIELD_T )
  898. {
  899. parentComponent = (SCH_COMPONENT*) aItem->GetParent();
  900. wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
  901. wxT( "Cannot place field in invalid schematic component object." ) );
  902. undoItem = parentComponent;
  903. }
  904. if( aItem->IsNew() )
  905. {
  906. // When a new sheet is added to the hierarchy, a clear annotation can be needed
  907. // for all new sheet paths added by the new sheet (if this sheet is loaded from
  908. // and existing sheet or a existing file, it can also contain subsheets)
  909. bool doClearAnnotation = false;
  910. SCH_SHEET_LIST initial_sheetpathList( g_RootSheet );
  911. if( aItem->Type() == SCH_SHEET_T )
  912. {
  913. if( !EditSheet( (SCH_SHEET*)aItem, g_CurrentSheet, &doClearAnnotation ) )
  914. {
  915. screen->SetCurItem( NULL );
  916. delete aItem;
  917. return;
  918. }
  919. SetSheetNumberAndCount();
  920. if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
  921. AddToScreen( aItem );
  922. SetRepeatItem( aItem );
  923. SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
  924. }
  925. else if( aItem->Type() == SCH_SHEET_PIN_T )
  926. {
  927. // Sheet pins are owned by their parent sheet.
  928. SaveCopyInUndoList( undoItem, UR_CHANGED, aUndoAppend ); // save the parent sheet
  929. parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
  930. }
  931. else if( aItem->Type() == SCH_FIELD_T )
  932. {
  933. // Component fields are also owned by their parent, but new component fields
  934. // are handled elsewhere.
  935. wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
  936. }
  937. else
  938. {
  939. if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
  940. AddToScreen( aItem );
  941. SetRepeatItem( aItem );
  942. SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
  943. }
  944. if( doClearAnnotation )
  945. {
  946. // Clear annotation of new sheet paths: the new sheet and its sub-sheets
  947. // If needed the missing alternate references of components will be created
  948. SCH_SCREENS screensList( g_RootSheet );
  949. screensList.ClearAnnotationOfNewSheetPaths( initial_sheetpathList );
  950. }
  951. // Update connectivity info for new item
  952. if( !aItem->IsMoving() )
  953. RecalculateConnections();
  954. }
  955. else
  956. {
  957. SaveUndoItemInUndoList( undoItem, aUndoAppend );
  958. }
  959. aItem->ClearFlags( aItem->GetEditFlags() );
  960. screen->SetModify();
  961. screen->SetCurItem( NULL );
  962. m_canvas->SetMouseCapture( NULL, NULL );
  963. m_canvas->EndMouseCapture();
  964. RefreshItem( aItem );
  965. if( !aItem->IsMoving() && aItem->IsConnectable() )
  966. {
  967. std::vector< wxPoint > pts;
  968. aItem->GetConnectionPoints( pts );
  969. for( auto i = pts.begin(); i != pts.end(); i++ )
  970. {
  971. for( auto j = i + 1; j != pts.end(); j++ )
  972. TrimWire( *i, *j, true );
  973. if( screen->IsJunctionNeeded( *i, true ) )
  974. AddJunction( *i, true );
  975. }
  976. TestDanglingEnds();
  977. }
  978. GetCanvas()->Refresh();
  979. }
  980. void SCH_EDIT_FRAME::UpdateTitle()
  981. {
  982. wxString title;
  983. if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
  984. {
  985. title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s" ), GetScreen()->GetFileName() );
  986. }
  987. else
  988. {
  989. wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
  990. wxFileName fn = fileName;
  991. title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
  992. fn.GetFullName(), g_CurrentSheet->PathHumanReadable(),
  993. fn.GetPath() );
  994. if( fn.FileExists() )
  995. {
  996. if( !fn.IsFileWritable() )
  997. title += _( " [Read Only]" );
  998. }
  999. else
  1000. title += _( " [no file]" );
  1001. }
  1002. SetTitle( title );
  1003. }
  1004. void SCH_EDIT_FRAME::RecalculateConnections( bool aDoCleanup )
  1005. {
  1006. SCH_SHEET_LIST list( g_RootSheet );
  1007. PROF_COUNTER timer;
  1008. // Ensure schematic graph is accurate
  1009. if( aDoCleanup )
  1010. {
  1011. for( const auto& sheet : list )
  1012. SchematicCleanUp( false, sheet.LastScreen() );
  1013. }
  1014. timer.Stop();
  1015. wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
  1016. g_ConnectionGraph->Recalculate( list, true );
  1017. }
  1018. void SCH_EDIT_FRAME::CommonSettingsChanged()
  1019. {
  1020. SCH_BASE_FRAME::CommonSettingsChanged();
  1021. ReCreateHToolbar();
  1022. ReCreateVToolbar();
  1023. ReCreateOptToolbar();
  1024. Layout();
  1025. SendSizeEvent();
  1026. }
  1027. void SCH_EDIT_FRAME::OnPageSettingsChange()
  1028. {
  1029. // Rebuild the sheet view (draw area and any other items):
  1030. DisplayCurrentSheet();
  1031. }
  1032. void SCH_EDIT_FRAME::ShowChangedLanguage()
  1033. {
  1034. // call my base class
  1035. SCH_BASE_FRAME::ShowChangedLanguage();
  1036. // tooltips in toolbars
  1037. ReCreateHToolbar();
  1038. ReCreateVToolbar();
  1039. ReCreateOptToolbar();
  1040. // status bar
  1041. UpdateMsgPanel();
  1042. // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
  1043. // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
  1044. // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
  1045. // toolbar to update correctly.
  1046. #if defined( __WXMSW__ )
  1047. PostSizeEvent();
  1048. #endif
  1049. }
  1050. void SCH_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
  1051. {
  1052. SCH_BASE_FRAME::SetScreen( aScreen );
  1053. auto c = static_cast<SCH_DRAW_PANEL*>(m_canvas);
  1054. c->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
  1055. }
  1056. const BOX2I SCH_EDIT_FRAME::GetDocumentExtents() const
  1057. {
  1058. int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
  1059. int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
  1060. return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
  1061. }