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.

1310 lines
38 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 <ee_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 <tool/tool_dispatcher.h>
  57. #include <tool/common_tools.h>
  58. #include <tool/zoom_tool.h>
  59. #include <tools/ee_actions.h>
  60. #include <tools/ee_selection_tool.h>
  61. #include <tools/ee_picker_tool.h>
  62. #include <tools/ee_point_editor.h>
  63. #include <tools/sch_drawing_tools.h>
  64. #include <tools/sch_wire_bus_tool.h>
  65. #include <tools/sch_move_tool.h>
  66. #include <tools/sch_edit_tool.h>
  67. #include <tools/ee_inspection_tool.h>
  68. #include <tools/sch_editor_control.h>
  69. #include <build_version.h>
  70. #include <wildcards_and_files_ext.h>
  71. #include <connection_graph.h>
  72. #include <dialogs/dialog_fields_editor_global.h>
  73. #include <sch_view.h>
  74. #include <sch_painter.h>
  75. #include <gal/graphics_abstraction_layer.h>
  76. SCH_SHEET_PATH* g_CurrentSheet = nullptr; // declared in general.h
  77. CONNECTION_GRAPH* g_ConnectionGraph = nullptr;
  78. // non-member so it can be moved easily, and kept REALLY private.
  79. // Do NOT Clear() in here.
  80. static void add_search_paths( SEARCH_STACK* aDst, const SEARCH_STACK& aSrc, int aIndex )
  81. {
  82. for( unsigned i=0; i<aSrc.GetCount(); ++i )
  83. aDst->AddPaths( aSrc[i], aIndex );
  84. }
  85. // non-member so it can be moved easily, and kept REALLY private.
  86. // Do NOT Clear() in here.
  87. static void add_search_paths( SEARCH_STACK* aDst, wxConfigBase* aCfg, int aIndex )
  88. {
  89. for( int i=1; true; ++i )
  90. {
  91. wxString key = wxString::Format( wxT( "LibraryPath%d" ), i );
  92. wxString upath = aCfg->Read( key, wxEmptyString );
  93. if( !upath )
  94. break;
  95. aDst->AddPaths( upath, aIndex );
  96. }
  97. }
  98. //-----<SCH "data on demand" functions>-------------------------------------------
  99. SEARCH_STACK* PROJECT::SchSearchS()
  100. {
  101. SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK );
  102. wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) );
  103. if( !ss )
  104. {
  105. ss = new SEARCH_STACK();
  106. // Make PROJECT the new SEARCH_STACK owner.
  107. SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss );
  108. // to the empty SEARCH_STACK for SchSearchS(), add project dir as first
  109. ss->AddPaths( m_project_name.GetPath() );
  110. // next add the paths found in *.pro, variable "LibDir"
  111. wxString libDir;
  112. try
  113. {
  114. PART_LIBS::LibNamesAndPaths( this, false, &libDir );
  115. }
  116. catch( const IO_ERROR& DBG( ioe ) )
  117. {
  118. DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );)
  119. }
  120. if( !!libDir )
  121. {
  122. wxArrayString paths;
  123. SEARCH_STACK::Split( &paths, libDir );
  124. for( unsigned i =0; i<paths.GetCount(); ++i )
  125. {
  126. wxString path = AbsolutePath( paths[i] );
  127. ss->AddPaths( path ); // at the end
  128. }
  129. }
  130. // append all paths from aSList
  131. add_search_paths( ss, Kiface().KifaceSearch(), -1 );
  132. // addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg )
  133. // This is undocumented, but somebody wanted to store !schematic!
  134. // library search paths in the .kicad_common file?
  135. add_search_paths( ss, Pgm().CommonSettings(), -1 );
  136. }
  137. return ss;
  138. }
  139. PART_LIBS* PROJECT::SchLibs()
  140. {
  141. PART_LIBS* libs = (PART_LIBS*) GetElem( PROJECT::ELEM_SCH_PART_LIBS );
  142. wxASSERT( !libs || libs->Type() == PART_LIBS_T );
  143. if( !libs )
  144. {
  145. libs = new PART_LIBS();
  146. // Make PROJECT the new PART_LIBS owner.
  147. SetElem( PROJECT::ELEM_SCH_PART_LIBS, libs );
  148. try
  149. {
  150. libs->LoadAllLibraries( this );
  151. }
  152. catch( const PARSE_ERROR& pe )
  153. {
  154. wxString lib_list = UTF8( pe.inputLine );
  155. wxWindow* parent = Pgm().App().GetTopWindow();
  156. // parent of this dialog cannot be NULL since that breaks the Kiway() chain.
  157. HTML_MESSAGE_BOX dlg( parent, _( "Not Found" ) );
  158. dlg.MessageSet( _( "The following libraries were not found:" ) );
  159. dlg.ListSet( lib_list );
  160. dlg.Layout();
  161. dlg.ShowModal();
  162. }
  163. catch( const IO_ERROR& ioe )
  164. {
  165. wxWindow* parent = Pgm().App().GetTopWindow();
  166. DisplayError( parent, ioe.What() );
  167. }
  168. }
  169. return libs;
  170. }
  171. //-----</SCH "data on demand" functions>------------------------------------------
  172. BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
  173. EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV, EDA_DRAW_FRAME::OnSockRequestServer )
  174. EVT_SOCKET( ID_EDA_SOCKET_EVENT, EDA_DRAW_FRAME::OnSockRequest )
  175. EVT_CLOSE( SCH_EDIT_FRAME::OnCloseWindow )
  176. EVT_SIZE( SCH_EDIT_FRAME::OnSize )
  177. EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, SCH_EDIT_FRAME::OnLoadFile )
  178. EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject )
  179. EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject )
  180. EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard )
  181. EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
  182. EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )
  183. EVT_MENU( ID_CONFIG_READ, SCH_EDIT_FRAME::Process_Config )
  184. EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, SCH_EDIT_FRAME::Process_Config )
  185. EVT_TOOL( wxID_PREFERENCES, SCH_EDIT_FRAME::OnPreferencesOptions )
  186. EVT_MENU( ID_PREFERENCES_CONFIGURE_PATHS, SCH_EDIT_FRAME::OnConfigurePaths )
  187. EVT_TOOL( ID_RUN_LIBRARY, SCH_EDIT_FRAME::OnOpenLibraryEditor )
  188. EVT_TOOL( ID_RESCUE_CACHED, SCH_EDIT_FRAME::OnRescueProject )
  189. EVT_MENU( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnRemapSymbols )
  190. EVT_MENU( ID_EDIT_COMPONENTS_TO_SYMBOLS_LIB_ID, SCH_EDIT_FRAME::OnEditComponentSymbolsId )
  191. EVT_TOOL( ID_RUN_PCB, SCH_EDIT_FRAME::OnOpenPcbnew )
  192. EVT_TOOL( ID_RUN_PCB_MODULE_EDITOR, SCH_EDIT_FRAME::OnOpenPcbModuleEditor )
  193. EVT_TOOL( ID_RUN_CVPCB, SCH_EDIT_FRAME::OnOpenCvpcb )
  194. EVT_TOOL( ID_GET_ANNOTATE, SCH_EDIT_FRAME::OnAnnotate )
  195. EVT_TOOL( ID_GET_ERC, SCH_EDIT_FRAME::OnErc )
  196. EVT_TOOL( ID_GET_NETLIST, SCH_EDIT_FRAME::OnCreateNetlist )
  197. EVT_TOOL( ID_UPDATE_PCB_FROM_SCH, SCH_EDIT_FRAME::OnUpdatePCB )
  198. EVT_TOOL( ID_GET_TOOLS, SCH_EDIT_FRAME::OnCreateBillOfMaterials )
  199. EVT_TOOL( ID_OPEN_CMP_TABLE, SCH_EDIT_FRAME::OnLaunchBomManager )
  200. EVT_TOOL( ID_BUS_MANAGER, SCH_EDIT_FRAME::OnLaunchBusManager )
  201. EVT_TOOL( ID_BACKANNO_ITEMS, SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile )
  202. EVT_TOOL( ID_UPDATE_FIELDS, SCH_EDIT_FRAME::OnUpdateFields )
  203. EVT_MENU( ID_GRID_SETTINGS, SCH_BASE_FRAME::OnGridSettings )
  204. #ifdef KICAD_SPICE
  205. EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate )
  206. #endif /* KICAD_SPICE */
  207. /* Handle user interface update events. */
  208. EVT_UPDATE_UI( ID_REMAP_SYMBOLS, SCH_EDIT_FRAME::OnUpdateRemapSymbols )
  209. END_EVENT_TABLE()
  210. SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ):
  211. SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH, wxT( "Eeschema" ),
  212. wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, SCH_EDIT_FRAME_NAME ),
  213. m_item_to_repeat( 0 )
  214. {
  215. g_CurrentSheet = new SCH_SHEET_PATH();
  216. g_ConnectionGraph = new CONNECTION_GRAPH( this );
  217. m_showAxis = false; // true to show axis
  218. m_showBorderAndTitleBlock = true; // true to show sheet references
  219. m_DefaultSchematicFileName = NAMELESS_PROJECT;
  220. m_DefaultSchematicFileName += wxT( ".sch" );
  221. m_showAllPins = false;
  222. m_printMonochrome = true;
  223. m_printSheetReference = true;
  224. SetShowPageLimits( true );
  225. m_hotkeysDescrList = g_Schematic_Hotkeys_Descr;
  226. m_undoItem = NULL;
  227. m_hasAutoSave = true;
  228. m_FrameSize = ConvertDialogToPixels( wxSize( 500, 350 ) ); // default in case of no prefs
  229. m_AboutTitle = "Eeschema";
  230. m_findReplaceData = new wxFindReplaceData( wxFR_DOWN );
  231. m_findReplaceDialog = nullptr;
  232. m_findReplaceStatusPopup = nullptr;
  233. SetForceHVLines( true );
  234. SetSpiceAjustPassiveValues( false );
  235. // Give an icon
  236. wxIcon icon;
  237. icon.CopyFromBitmap( KiBitmap( icon_eeschema_xpm ) );
  238. SetIcon( icon );
  239. // Initialize grid id to the default value (50 mils):
  240. m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
  241. LoadSettings( config() );
  242. CreateScreens();
  243. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  244. setupTools();
  245. ReCreateMenuBar();
  246. ReCreateHToolbar();
  247. ReCreateVToolbar();
  248. ReCreateOptToolbar();
  249. // Initialize common print setup dialog settings.
  250. m_pageSetupData.GetPrintData().SetPrintMode( wxPRINT_MODE_PRINTER );
  251. m_pageSetupData.GetPrintData().SetQuality( wxPRINT_QUALITY_MEDIUM );
  252. m_pageSetupData.GetPrintData().SetBin( wxPRINTBIN_AUTO );
  253. m_pageSetupData.GetPrintData().SetNoCopies( 1 );
  254. m_auimgr.SetManagedWindow( this );
  255. m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
  256. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  257. m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
  258. m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
  259. m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  260. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  261. m_auimgr.Update();
  262. GetToolManager()->RunAction( ACTIONS::gridPreset, true, m_LastGridSizeId );
  263. GetToolManager()->RunAction( ACTIONS::zoomFitScreen, true );
  264. if( GetGalCanvas() )
  265. GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
  266. // Net list generator
  267. DefaultExecFlags();
  268. Bind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
  269. ID_EDIT_SYM_LIB_TABLE );
  270. UpdateTitle();
  271. }
  272. SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
  273. {
  274. Unbind( wxEVT_COMMAND_MENU_SELECTED, &SCH_EDIT_FRAME::OnEditSymbolLibTable, this,
  275. ID_EDIT_SYM_LIB_TABLE );
  276. delete m_item_to_repeat; // we own the cloned object, see this->SaveCopyForRepeatItem()
  277. SetScreen( NULL );
  278. delete g_CurrentSheet; // a SCH_SHEET_PATH, on the heap.
  279. delete g_ConnectionGraph;
  280. delete m_undoItem;
  281. delete m_findReplaceData;
  282. delete g_RootSheet;
  283. g_CurrentSheet = nullptr;
  284. g_ConnectionGraph = nullptr;
  285. g_RootSheet = NULL;
  286. }
  287. void SCH_EDIT_FRAME::setupTools()
  288. {
  289. // Create the manager and dispatcher & route draw panel events to the dispatcher
  290. m_toolManager = new TOOL_MANAGER;
  291. m_toolManager->SetEnvironment( GetScreen(), GetCanvas()->GetView(),
  292. GetCanvas()->GetViewControls(), this );
  293. m_actions = new EE_ACTIONS();
  294. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
  295. // Register tools
  296. m_toolManager->RegisterTool( new COMMON_TOOLS );
  297. m_toolManager->RegisterTool( new ZOOM_TOOL );
  298. m_toolManager->RegisterTool( new EE_SELECTION_TOOL );
  299. m_toolManager->RegisterTool( new EE_PICKER_TOOL );
  300. m_toolManager->RegisterTool( new SCH_DRAWING_TOOLS );
  301. m_toolManager->RegisterTool( new SCH_WIRE_BUS_TOOL );
  302. m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
  303. m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
  304. m_toolManager->RegisterTool( new EE_INSPECTION_TOOL );
  305. m_toolManager->RegisterTool( new SCH_EDITOR_CONTROL );
  306. m_toolManager->RegisterTool( new EE_POINT_EDITOR );
  307. m_toolManager->InitTools();
  308. // Run the selection tool, it is supposed to be always active
  309. m_toolManager->InvokeTool( "eeschema.InteractiveSelection" );
  310. GetCanvas()->SetEventDispatcher( m_toolDispatcher );
  311. }
  312. void SCH_EDIT_FRAME::SaveCopyForRepeatItem( SCH_ITEM* aItem )
  313. {
  314. // we cannot store a pointer to an item in the display list here since
  315. // that item may be deleted, such as part of a line concatonation or other.
  316. // So simply always keep a copy of the object which is to be repeated.
  317. delete m_item_to_repeat;
  318. m_item_to_repeat = (SCH_ITEM*) aItem->Clone();
  319. // Clone() preserves the flags, we want 'em cleared.
  320. m_item_to_repeat->ClearFlags();
  321. }
  322. void SCH_EDIT_FRAME::SetSheetNumberAndCount()
  323. {
  324. SCH_SCREEN* screen;
  325. SCH_SCREENS s_list;
  326. /* Set the sheet count, and the sheet number (1 for root sheet)
  327. */
  328. int sheet_count = g_RootSheet->CountSheets();
  329. int SheetNumber = 1;
  330. wxString current_sheetpath = g_CurrentSheet->Path();
  331. SCH_SHEET_LIST sheetList( g_RootSheet );
  332. // Examine all sheets path to find the current sheets path,
  333. // and count them from root to the current sheet path:
  334. for( unsigned i = 0; i < sheetList.size(); i++ )
  335. {
  336. wxString sheetpath = sheetList[i].Path();
  337. if( sheetpath == current_sheetpath ) // Current sheet path found
  338. break;
  339. SheetNumber++; // Not found, increment before this current path
  340. }
  341. g_CurrentSheet->SetPageNumber( SheetNumber );
  342. for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
  343. screen->m_NumberOfScreens = sheet_count;
  344. GetScreen()->m_ScreenNumber = SheetNumber;
  345. }
  346. SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
  347. {
  348. if( !g_CurrentSheet )
  349. return nullptr;
  350. return g_CurrentSheet->LastScreen();
  351. }
  352. wxString SCH_EDIT_FRAME::GetScreenDesc() const
  353. {
  354. if(! g_CurrentSheet )
  355. return wxT("<unknown>");
  356. wxString s = g_CurrentSheet->PathHumanReadable();
  357. return s;
  358. }
  359. void SCH_EDIT_FRAME::CreateScreens()
  360. {
  361. if( g_RootSheet == NULL )
  362. g_RootSheet = new SCH_SHEET();
  363. if( g_RootSheet->GetScreen() == NULL )
  364. {
  365. SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
  366. screen->SetMaxUndoItems( m_UndoRedoCountMax );
  367. g_RootSheet->SetScreen( screen );
  368. SetScreen( g_RootSheet->GetScreen() );
  369. }
  370. g_RootSheet->GetScreen()->SetFileName( m_DefaultSchematicFileName );
  371. g_CurrentSheet->clear();
  372. g_CurrentSheet->push_back( g_RootSheet );
  373. g_ConnectionGraph->Reset();
  374. if( GetScreen() == NULL )
  375. {
  376. SCH_SCREEN* screen = new SCH_SCREEN( &Kiway() );
  377. screen->SetMaxUndoItems( m_UndoRedoCountMax );
  378. SetScreen( screen );
  379. }
  380. GetScreen()->SetZoom( 32.0 );
  381. }
  382. SCH_SHEET_PATH& SCH_EDIT_FRAME::GetCurrentSheet()
  383. {
  384. wxASSERT_MSG( g_CurrentSheet != NULL, wxT( "SCH_EDIT_FRAME g_CurrentSheet member is NULL." ) );
  385. return *g_CurrentSheet;
  386. }
  387. void SCH_EDIT_FRAME::SetCurrentSheet( const SCH_SHEET_PATH& aSheet )
  388. {
  389. if( aSheet != *g_CurrentSheet )
  390. {
  391. *g_CurrentSheet = aSheet;
  392. static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( g_CurrentSheet->LastScreen() );
  393. }
  394. }
  395. void SCH_EDIT_FRAME::HardRedraw()
  396. {
  397. static_cast<SCH_DRAW_PANEL*>( m_canvas )->DisplaySheet( g_CurrentSheet->LastScreen() );
  398. GetGalCanvas()->ForceRefresh();
  399. }
  400. void SCH_EDIT_FRAME::SaveUndoItemInUndoList( SCH_ITEM* aItem, bool aAppend )
  401. {
  402. wxCHECK_RET( aItem != NULL, wxT( "Cannot swap undo item structures." ) );
  403. wxCHECK_RET( m_undoItem != NULL, wxT( "Cannot swap undo item structures." ) );
  404. wxCHECK_RET( aItem->Type() == m_undoItem->Type(), wxT( "Cannot swap undo item structures." ) );
  405. aItem->SwapData( m_undoItem );
  406. SaveCopyInUndoList( aItem, UR_CHANGED, aAppend );
  407. aItem->SwapData( m_undoItem );
  408. }
  409. void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
  410. {
  411. if( Kiface().IsSingle() )
  412. {
  413. LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
  414. if( libeditFrame && !libeditFrame->Close() ) // Can close component editor?
  415. return;
  416. LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
  417. if( viewlibFrame && !viewlibFrame->Close() ) // Can close component viewer?
  418. return;
  419. viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, false );
  420. if( viewlibFrame && !viewlibFrame->Close() ) // Can close modal component viewer?
  421. return;
  422. }
  423. SIM_PLOT_FRAME* simFrame = (SIM_PLOT_FRAME*) Kiway().Player( FRAME_SIMULATOR, false );
  424. if( simFrame && !simFrame->Close() ) // Can close the simulator?
  425. return;
  426. SCH_SHEET_LIST sheetList( g_RootSheet );
  427. if( sheetList.IsModified() )
  428. {
  429. wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  430. wxString msg = _( "Save changes to\n\"%s\"\nbefore closing?" );
  431. if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName ),
  432. [&]()->bool { return SaveProject(); } ) )
  433. {
  434. aEvent.Veto();
  435. return;
  436. }
  437. }
  438. // Close the find dialog and preserve it's setting if it is displayed.
  439. if( m_findReplaceDialog )
  440. {
  441. m_findStringHistoryList = m_findReplaceDialog->GetFindEntries();
  442. m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries();
  443. m_findReplaceStatusPopup->Destroy();
  444. m_findReplaceStatusPopup = nullptr;
  445. // Must destroy statusPopup first as it holds a pointer to the dialog
  446. m_findReplaceDialog->Destroy();
  447. m_findReplaceDialog = nullptr;
  448. }
  449. SCH_SCREENS screens;
  450. wxFileName fn;
  451. for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() )
  452. {
  453. fn = Prj().AbsolutePath( screen->GetFileName() );
  454. // Auto save file name is the normal file name prepended with GetAutoSaveFilePrefix().
  455. fn.SetName( GetAutoSaveFilePrefix() + fn.GetName() );
  456. if( fn.FileExists() && fn.IsFileWritable() )
  457. wxRemoveFile( fn.GetFullPath() );
  458. }
  459. sheetList.ClearModifyStatus();
  460. wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  461. if( !g_RootSheet->GetScreen()->GetFileName().IsEmpty() &&
  462. g_RootSheet->GetScreen()->GetDrawItems() != NULL )
  463. {
  464. UpdateFileHistory( fileName );
  465. }
  466. g_RootSheet->GetScreen()->Clear();
  467. // all sub sheets are deleted, only the main sheet is usable
  468. g_CurrentSheet->clear();
  469. Destroy();
  470. }
  471. double SCH_EDIT_FRAME::BestZoom()
  472. {
  473. double sizeX = (double) GetScreen()->GetPageSettings().GetWidthIU();
  474. double sizeY = (double) GetScreen()->GetPageSettings().GetHeightIU();
  475. wxPoint centre( wxPoint( sizeX / 2, sizeY / 2 ) );
  476. // The sheet boundary already affords us some margin, so add only an
  477. // additional 5%.
  478. double margin_scale_factor = 1.05;
  479. return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
  480. }
  481. wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
  482. {
  483. wxFileName fn = GetScreen()->GetFileName();
  484. // Name is <root sheet filename>-<sheet path> and has no extension.
  485. // However if filename is too long name is <sheet filename>-<sheet number>
  486. #define FN_LEN_MAX 80 // A reasonable value for the short filename len
  487. wxString filename = fn.GetName();
  488. wxString sheetFullName = g_CurrentSheet->PathHumanReadable();
  489. // Remove the last '/' of the path human readable
  490. // (and for the root sheet, make sheetFullName empty):
  491. sheetFullName.RemoveLast();
  492. sheetFullName.Trim( true );
  493. sheetFullName.Trim( false );
  494. // Convert path human readable separator to '-'
  495. sheetFullName.Replace( wxT( "/" ), wxT( "-" ) );
  496. if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
  497. filename += sheetFullName;
  498. else
  499. filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
  500. return filename;
  501. }
  502. void SCH_EDIT_FRAME::OnModify()
  503. {
  504. GetScreen()->SetModify();
  505. GetScreen()->SetSave();
  506. if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
  507. RecalculateConnections( false );
  508. m_canvas->Refresh();
  509. }
  510. void SCH_EDIT_FRAME::OnUpdateRemapSymbols( wxUpdateUIEvent& aEvent )
  511. {
  512. SCH_SCREENS schematic;
  513. // The remapping can only be performed on legacy projects.
  514. aEvent.Enable( schematic.HasNoFullyDefinedLibIds() );
  515. }
  516. void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
  517. {
  518. // See if it's already open...
  519. wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
  520. if( erc )
  521. // Bring it to the top if already open. Dual monitor users need this.
  522. erc->Raise();
  523. else
  524. InvokeDialogERC( this );
  525. }
  526. void SCH_EDIT_FRAME::CloseErc()
  527. {
  528. // Find the ERC dialog if it's open and close it
  529. wxWindow* erc = FindWindowById( ID_DIALOG_ERC, this );
  530. if( erc )
  531. erc->Close( false );
  532. }
  533. void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
  534. {
  535. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  536. fn.SetExt( PcbFileExtension );
  537. if( Kiface().IsSingle() )
  538. {
  539. DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is"
  540. " opened in stand-alone mode. In order to create/update"
  541. " PCBs from schematics, you need to launch Kicad shell"
  542. " and create a PCB project." ) );
  543. return;
  544. }
  545. KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
  546. // a pcb frame can be already existing, but not yet used.
  547. // this is the case when running the footprint editor, or the footprint viewer first
  548. // if the frame is not visible, the board is not yet loaded
  549. if( !frame->IsVisible() )
  550. {
  551. frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
  552. frame->Show( true );
  553. }
  554. // On Windows, Raise() does not bring the window on screen, when iconized
  555. if( frame->IsIconized() )
  556. frame->Iconize( false );
  557. frame->Raise();
  558. std::string payload;
  559. Kiway().ExpressMail( FRAME_PCB, MAIL_PCB_UPDATE, payload, this );
  560. }
  561. void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )
  562. {
  563. int result;
  564. do
  565. {
  566. result = InvokeDialogNetList( this );
  567. // If a plugin is removed or added, rebuild and reopen the new dialog
  568. } while( result == NET_PLUGIN_CHANGE );
  569. }
  570. void SCH_EDIT_FRAME::OnCreateBillOfMaterials( wxCommandEvent& )
  571. {
  572. InvokeDialogCreateBOM( this );
  573. }
  574. void SCH_EDIT_FRAME::OnLaunchBomManager( wxCommandEvent& event )
  575. {
  576. DIALOG_FIELDS_EDITOR_GLOBAL dlg( this );
  577. dlg.ShowQuasiModal();
  578. }
  579. void SCH_EDIT_FRAME::OnLaunchBusManager( wxCommandEvent& )
  580. {
  581. InvokeDialogBusManager( this );
  582. }
  583. wxFindReplaceData* SCH_EDIT_FRAME::GetFindReplaceData()
  584. {
  585. if( m_findReplaceDialog && m_findReplaceDialog->IsVisible()
  586. && !m_findReplaceData->GetFindString().IsEmpty() )
  587. {
  588. return m_findReplaceData;
  589. }
  590. return nullptr;
  591. }
  592. void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
  593. {
  594. if( m_findReplaceStatusPopup )
  595. m_findReplaceStatusPopup->Destroy();
  596. // Must destroy statup popup first as it holds a pointer to the dialog
  597. if( m_findReplaceDialog )
  598. m_findReplaceDialog->Destroy();
  599. m_findReplaceDialog= new DIALOG_SCH_FIND( this, m_findReplaceData, wxDefaultPosition,
  600. wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 );
  601. m_findReplaceDialog->SetFindEntries( m_findStringHistoryList );
  602. m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList );
  603. m_findReplaceDialog->Show( true );
  604. m_findReplaceStatusPopup = new STATUS_TEXT_POPUP( m_findReplaceDialog );
  605. m_findReplaceStatusPopup->SetTextColor( wxColour( 255, 0, 0 ) );
  606. }
  607. void SCH_EDIT_FRAME::ShowFindReplaceStatus( const wxString& aMsg )
  608. {
  609. wxPoint pos = wxGetMousePosition() - m_findReplaceStatusPopup->GetSize() - wxPoint( 10, 10 );
  610. m_findReplaceStatusPopup->SetText( aMsg );
  611. m_findReplaceStatusPopup->Move( pos );
  612. m_findReplaceStatusPopup->PopupFor( 3000 );
  613. }
  614. void SCH_EDIT_FRAME::ClearFindReplaceStatus()
  615. {
  616. m_findReplaceStatusPopup->Hide();
  617. }
  618. void SCH_EDIT_FRAME::OnFindDialogClose()
  619. {
  620. m_findStringHistoryList = m_findReplaceDialog->GetFindEntries();
  621. m_replaceStringHistoryList = m_findReplaceDialog->GetReplaceEntries();
  622. m_findReplaceStatusPopup->Destroy();
  623. m_findReplaceStatusPopup = nullptr;
  624. // Must destroy statusPopup first as it holds a pointer to the dialog
  625. m_findReplaceDialog->Destroy();
  626. m_findReplaceDialog = nullptr;
  627. }
  628. void SCH_EDIT_FRAME::OnLoadFile( wxCommandEvent& event )
  629. {
  630. wxString fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
  631. if( fn.size() )
  632. OpenProjectFiles( std::vector<wxString>( 1, fn ) );
  633. }
  634. void SCH_EDIT_FRAME::OnLoadCmpToFootprintLinkFile( wxCommandEvent& event )
  635. {
  636. LoadCmpToFootprintLinkFile();
  637. m_canvas->Refresh();
  638. }
  639. void SCH_EDIT_FRAME::OnUpdateFields( wxCommandEvent& event )
  640. {
  641. std::list<SCH_COMPONENT*> components;
  642. for( SCH_ITEM* item = GetScreen()->GetDrawItems(); item; item = item->Next() )
  643. {
  644. if( item->Type() == SCH_COMPONENT_T )
  645. components.push_back( static_cast<SCH_COMPONENT*>( item ) );
  646. }
  647. if( InvokeDialogUpdateFields( this, components, true ) == wxID_OK )
  648. m_canvas->Refresh();
  649. }
  650. void SCH_EDIT_FRAME::NewProject()
  651. {
  652. wxString pro_dir = m_mruPath;
  653. wxFileDialog dlg( this, _( "New Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard(),
  654. wxFD_SAVE );
  655. if( dlg.ShowModal() != wxID_CANCEL )
  656. {
  657. // Enforce the extension, wxFileDialog is inept.
  658. wxFileName create_me = dlg.GetPath();
  659. create_me.SetExt( SchematicFileExtension );
  660. if( create_me.FileExists() )
  661. {
  662. wxString msg;
  663. msg.Printf( _( "Schematic file \"%s\" already exists." ), create_me.GetFullName() );
  664. DisplayError( this, msg );
  665. return ;
  666. }
  667. // OpenProjectFiles() requires absolute
  668. wxASSERT_MSG( create_me.IsAbsolute(), "wxFileDialog returned non-absolute path" );
  669. OpenProjectFiles( std::vector<wxString>( 1, create_me.GetFullPath() ), KICTL_CREATE );
  670. m_mruPath = create_me.GetPath();
  671. }
  672. }
  673. void SCH_EDIT_FRAME::LoadProject()
  674. {
  675. wxString pro_dir = m_mruPath;
  676. wxFileDialog dlg( this, _( "Open Schematic" ), pro_dir, wxEmptyString, SchematicFileWildcard(),
  677. wxFD_OPEN | wxFD_FILE_MUST_EXIST );
  678. if( dlg.ShowModal() != wxID_CANCEL )
  679. {
  680. OpenProjectFiles( std::vector<wxString>( 1, dlg.GetPath() ) );
  681. m_mruPath = Prj().GetProjectPath();
  682. }
  683. }
  684. void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
  685. {
  686. wxFileName kicad_board = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  687. if( kicad_board.IsOk() )
  688. {
  689. kicad_board.SetExt( PcbFileExtension );
  690. wxFileName legacy_board( kicad_board );
  691. legacy_board.SetExt( LegacyPcbFileExtension );
  692. wxFileName& boardfn = legacy_board;
  693. if( !legacy_board.FileExists() || kicad_board.FileExists() )
  694. boardfn = kicad_board;
  695. if( Kiface().IsSingle() )
  696. {
  697. wxString filename = QuoteFullPath( boardfn );
  698. ExecuteFile( this, PCBNEW_EXE, filename );
  699. }
  700. else
  701. {
  702. KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
  703. // a pcb frame can be already existing, but not yet used.
  704. // this is the case when running the footprint editor, or the footprint viewer first
  705. // if the frame is not visible, the board is not yet loaded
  706. if( !frame->IsVisible() )
  707. {
  708. frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
  709. frame->Show( true );
  710. }
  711. // On Windows, Raise() does not bring the window on screen, when iconized
  712. if( frame->IsIconized() )
  713. frame->Iconize( false );
  714. frame->Raise();
  715. }
  716. }
  717. else
  718. {
  719. ExecuteFile( this, PCBNEW_EXE );
  720. }
  721. }
  722. void SCH_EDIT_FRAME::OnOpenPcbModuleEditor( wxCommandEvent& event )
  723. {
  724. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  725. if( fn.IsOk() )
  726. {
  727. KIWAY_PLAYER* fp_editor = Kiway().Player( FRAME_PCB_MODULE_EDITOR );
  728. // On Windows, Raise() does not bring the window on screen, when iconized
  729. if( fp_editor->IsIconized() )
  730. fp_editor->Iconize( false );
  731. fp_editor->Show( true );
  732. fp_editor->Raise();
  733. }
  734. }
  735. void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
  736. {
  737. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  738. fn.SetExt( NetlistFileExtension );
  739. if( !prepareForNetlist() )
  740. return;
  741. try
  742. {
  743. KIWAY_PLAYER* player = Kiway().Player( FRAME_CVPCB, false ); // test open already.
  744. if( !player )
  745. {
  746. player = Kiway().Player( FRAME_CVPCB, true );
  747. player->Show( true );
  748. // player->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
  749. }
  750. sendNetlistToCvpcb();
  751. player->Raise();
  752. }
  753. catch( const IO_ERROR& )
  754. {
  755. DisplayError( this, _( "Could not open CvPcb" ) );
  756. }
  757. }
  758. void SCH_EDIT_FRAME::OnOpenLibraryEditor( wxCommandEvent& event )
  759. {
  760. LIB_EDIT_FRAME* libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, false );
  761. if( !libeditFrame )
  762. {
  763. libeditFrame = (LIB_EDIT_FRAME*) Kiway().Player( FRAME_SCH_LIB_EDITOR, true );
  764. libeditFrame->Show( true );
  765. }
  766. libeditFrame->PushPreferences( m_canvas );
  767. // On Windows, Raise() does not bring the window on screen, when iconized
  768. if( libeditFrame->IsIconized() )
  769. libeditFrame->Iconize( false );
  770. libeditFrame->Raise();
  771. }
  772. void SCH_EDIT_FRAME::OnRescueProject( wxCommandEvent& event )
  773. {
  774. SCH_SCREENS schematic;
  775. if( schematic.HasNoFullyDefinedLibIds() )
  776. RescueLegacyProject( true );
  777. else
  778. RescueSymbolLibTableProject( true );
  779. }
  780. void SCH_EDIT_FRAME::OnRemapSymbols( wxCommandEvent& event )
  781. {
  782. DIALOG_SYMBOL_REMAP dlgRemap( this );
  783. dlgRemap.ShowQuasiModal();
  784. m_canvas->Refresh( true );
  785. }
  786. // This method is not the same as OnRemapSymbols.
  787. // It allows renaming the lib id of groups of components when a symbol
  788. // has moved from a library to another library.
  789. // For instance to rename libname1::mysymbol to libname2::mysymbol
  790. // or any other lib id name
  791. void SCH_EDIT_FRAME::OnEditComponentSymbolsId( wxCommandEvent& event )
  792. {
  793. InvokeDialogEditComponentsLibId( this );
  794. m_canvas->Refresh( true );
  795. }
  796. void SCH_EDIT_FRAME::OnExit( wxCommandEvent& event )
  797. {
  798. Close( false );
  799. }
  800. void SCH_EDIT_FRAME::Print()
  801. {
  802. InvokeDialogPrintUsingPrinter( this );
  803. wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
  804. if( fn.GetName() != NAMELESS_PROJECT )
  805. Prj().ConfigSave( Kiface().KifaceSearch(), GROUP_SCH_EDIT, GetProjectFileParameters() );
  806. }
  807. void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
  808. {
  809. wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
  810. GRSetDrawMode( aDC, GR_DEFAULT_DRAWMODE );
  811. GetScreen()->Draw( m_canvas, aDC );
  812. DrawWorkSheet( aDC, GetScreen(), GetDefaultLineThickness(), IU_PER_MILS, fileName );
  813. }
  814. bool SCH_EDIT_FRAME::isAutoSaveRequired() const
  815. {
  816. // In case this event happens before g_RootSheet is initialized which does happen
  817. // on mingw64 builds.
  818. if( g_RootSheet != NULL )
  819. {
  820. SCH_SCREENS screenList;
  821. for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
  822. {
  823. if( screen->IsSave() )
  824. return true;
  825. }
  826. }
  827. return false;
  828. }
  829. void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppend )
  830. {
  831. SCH_SCREEN* screen = GetScreen();
  832. wxCHECK_RET( aItem != NULL, wxT( "Cannot add current aItem to list." ) );
  833. m_canvas->SetAutoPanRequest( false );
  834. SCH_SHEET* parentSheet = nullptr;
  835. SCH_COMPONENT* parentComponent = nullptr;
  836. SCH_ITEM* undoItem = aItem;
  837. if( aItem->Type() == SCH_SHEET_PIN_T )
  838. {
  839. parentSheet = (SCH_SHEET*) aItem->GetParent();
  840. wxCHECK_RET( parentSheet && parentSheet->Type() == SCH_SHEET_T,
  841. wxT( "Cannot place sheet pin in invalid schematic sheet object." ) );
  842. undoItem = parentSheet;
  843. }
  844. else if( aItem->Type() == SCH_FIELD_T )
  845. {
  846. parentComponent = (SCH_COMPONENT*) aItem->GetParent();
  847. wxCHECK_RET( parentComponent && parentComponent->Type() == SCH_COMPONENT_T,
  848. wxT( "Cannot place field in invalid schematic component object." ) );
  849. undoItem = parentComponent;
  850. }
  851. if( aItem->IsNew() )
  852. {
  853. if( aItem->Type() == SCH_SHEET_PIN_T )
  854. {
  855. // Sheet pins are owned by their parent sheet.
  856. SaveCopyInUndoList( undoItem, UR_CHANGED, aUndoAppend ); // save the parent sheet
  857. parentSheet->AddPin( (SCH_SHEET_PIN*) aItem );
  858. }
  859. else if( aItem->Type() == SCH_FIELD_T )
  860. {
  861. // Component fields are also owned by their parent, but new component fields
  862. // are handled elsewhere.
  863. wxLogMessage( wxT( "addCurrentItemToScreen: unexpected new SCH_FIELD" ) );
  864. }
  865. else
  866. {
  867. if( !screen->CheckIfOnDrawList( aItem ) ) // don't want a loop!
  868. AddToScreen( aItem );
  869. SaveCopyForRepeatItem( aItem );
  870. SaveCopyInUndoList( undoItem, UR_NEW, aUndoAppend );
  871. }
  872. // Update connectivity info for new item
  873. if( !aItem->IsMoving() )
  874. RecalculateConnections();
  875. }
  876. else
  877. {
  878. SaveUndoItemInUndoList( undoItem, aUndoAppend );
  879. }
  880. aItem->ClearEditFlags();
  881. screen->SetModify();
  882. RefreshItem( aItem );
  883. if( !aItem->IsMoving() && aItem->IsConnectable() )
  884. {
  885. std::vector< wxPoint > pts;
  886. aItem->GetConnectionPoints( pts );
  887. for( auto i = pts.begin(); i != pts.end(); i++ )
  888. {
  889. for( auto j = i + 1; j != pts.end(); j++ )
  890. TrimWire( *i, *j );
  891. if( screen->IsJunctionNeeded( *i, true ) )
  892. AddJunction( *i, true, false );
  893. }
  894. TestDanglingEnds();
  895. }
  896. GetCanvas()->Refresh();
  897. }
  898. void SCH_EDIT_FRAME::UpdateTitle()
  899. {
  900. wxString title;
  901. if( GetScreen()->GetFileName() == m_DefaultSchematicFileName )
  902. {
  903. title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s" ), GetScreen()->GetFileName() );
  904. }
  905. else
  906. {
  907. wxString fileName = Prj().AbsolutePath( GetScreen()->GetFileName() );
  908. wxFileName fn = fileName;
  909. title.Printf( _( "Eeschema" ) + wxT( " \u2014 %s [%s] \u2014 %s" ),
  910. fn.GetFullName(), g_CurrentSheet->PathHumanReadable(),
  911. fn.GetPath() );
  912. if( fn.FileExists() )
  913. {
  914. if( !fn.IsFileWritable() )
  915. title += _( " [Read Only]" );
  916. }
  917. else
  918. title += _( " [no file]" );
  919. }
  920. SetTitle( title );
  921. }
  922. void SCH_EDIT_FRAME::RecalculateConnections( bool aDoCleanup )
  923. {
  924. SCH_SHEET_LIST list( g_RootSheet );
  925. PROF_COUNTER timer;
  926. // Ensure schematic graph is accurate
  927. if( aDoCleanup )
  928. {
  929. for( const auto& sheet : list )
  930. SchematicCleanUp( sheet.LastScreen() );
  931. }
  932. timer.Stop();
  933. wxLogTrace( "CONN_PROFILE", "SchematicCleanUp() %0.4f ms", timer.msecs() );
  934. g_ConnectionGraph->Recalculate( list, true );
  935. }
  936. void SCH_EDIT_FRAME::CommonSettingsChanged()
  937. {
  938. SCH_BASE_FRAME::CommonSettingsChanged();
  939. ReCreateHToolbar();
  940. ReCreateVToolbar();
  941. ReCreateOptToolbar();
  942. Layout();
  943. SendSizeEvent();
  944. }
  945. void SCH_EDIT_FRAME::OnPageSettingsChange()
  946. {
  947. // Rebuild the sheet view (draw area and any other items):
  948. DisplayCurrentSheet();
  949. }
  950. void SCH_EDIT_FRAME::ShowChangedLanguage()
  951. {
  952. // call my base class
  953. SCH_BASE_FRAME::ShowChangedLanguage();
  954. // tooltips in toolbars
  955. ReCreateHToolbar();
  956. ReCreateVToolbar();
  957. ReCreateOptToolbar();
  958. // status bar
  959. UpdateMsgPanel();
  960. // This ugly hack is to fix an option(left) toolbar update bug that seems to only affect
  961. // windows. See https://bugs.launchpad.net/kicad/+bug/1816492. For some reason, calling
  962. // wxWindow::Refresh() does not resolve the issue. Only a resize event seems to force the
  963. // toolbar to update correctly.
  964. #if defined( __WXMSW__ )
  965. PostSizeEvent();
  966. #endif
  967. }
  968. void SCH_EDIT_FRAME::SetScreen( BASE_SCREEN* aScreen )
  969. {
  970. SCH_BASE_FRAME::SetScreen( aScreen );
  971. auto c = static_cast<SCH_DRAW_PANEL*>(m_canvas);
  972. c->DisplaySheet( static_cast<SCH_SCREEN*>( aScreen ) );
  973. }
  974. const BOX2I SCH_EDIT_FRAME::GetDocumentExtents() const
  975. {
  976. int sizeX = GetScreen()->GetPageSettings().GetWidthIU();
  977. int sizeY = GetScreen()->GetPageSettings().GetHeightIU();
  978. return BOX2I( VECTOR2I(0, 0), VECTOR2I( sizeX, sizeY ) );
  979. }