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.

1243 lines
37 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
8 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* 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
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software: you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation, either version 3 of the License, or (at your
  10. * option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <fctsys.h>
  21. #include <kiface_i.h>
  22. #include <pgm_base.h>
  23. #include <eda_base_frame.h>
  24. #include <trigo.h>
  25. #include <base_units.h>
  26. #include <gbr_layer_box_selector.h>
  27. #include <msgpanel.h>
  28. #include <bitmaps.h>
  29. #include <wildcards_and_files_ext.h>
  30. #include <gerbview.h>
  31. #include <gerbview_frame.h>
  32. #include <gerbview_id.h>
  33. #include <gerber_file_image.h>
  34. #include <gerber_file_image_list.h>
  35. #include <DCodeSelectionbox.h>
  36. #include <gerbview_layer_widget.h>
  37. #include <gerbview_draw_panel_gal.h>
  38. #include <gal/graphics_abstraction_layer.h>
  39. #include <tool/tool_manager.h>
  40. #include <tool/action_toolbar.h>
  41. #include <tool/tool_dispatcher.h>
  42. #include <tool/common_control.h>
  43. #include <tool/common_tools.h>
  44. #include <tool/zoom_tool.h>
  45. #include <tools/gerbview_actions.h>
  46. #include <tools/gerbview_selection_tool.h>
  47. #include <tools/gerbview_control.h>
  48. #include <view/view.h>
  49. #include <gerbview_painter.h>
  50. #include <geometry/shape_poly_set.h>
  51. // Config keywords
  52. static const wxString cfgShowPageSizeOption( wxT( "PageSizeOpt" ) );
  53. static const wxString cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
  54. static const wxString cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
  55. static const wxString cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
  56. // Colors for layers and items
  57. COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_GERBER );
  58. GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ):
  59. EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ),
  60. wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ),
  61. m_zipFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_ZIP_FILE1 ),
  62. m_drillFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_DRILL_FILE1 ),
  63. m_jobFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_JOB_FILE1 )
  64. {
  65. m_colorsSettings = &g_ColorsSettings;
  66. m_gerberLayout = NULL;
  67. m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1
  68. // when the screen shows a 1:1 image
  69. // obviously depends on the monitor,
  70. // but this is an acceptable value
  71. m_show_layer_manager_tools = true;
  72. m_showBorderAndTitleBlock = false; // true for reference drawings.
  73. m_SelLayerBox = NULL;
  74. m_DCodeSelector = NULL;
  75. m_SelComponentBox = nullptr;
  76. m_SelNetnameBox = nullptr;
  77. m_SelAperAttributesBox = nullptr;
  78. m_displayMode = 0;
  79. m_AboutTitle = "GerbView";
  80. SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
  81. // some methods in code and avoid link errors
  82. int fileHistorySize;
  83. Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize,
  84. DEFAULT_FILE_HISTORY_SIZE );
  85. m_drillFileHistory.SetMaxFiles( fileHistorySize );
  86. m_zipFileHistory.SetMaxFiles( fileHistorySize );
  87. m_jobFileHistory.SetMaxFiles( fileHistorySize );
  88. auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
  89. GetGalDisplayOptions(),
  90. EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
  91. SetCanvas( galCanvas );
  92. // GerbView requires draw priority for rendering negative objects
  93. galCanvas->GetView()->UseDrawPriority( true );
  94. // Give an icon
  95. wxIcon icon;
  96. icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) );
  97. SetIcon( icon );
  98. // Be sure a page info is set. this default value will be overwritten later.
  99. PAGE_INFO pageInfo( wxT( "GERBER" ) );
  100. SetLayout( new GBR_LAYOUT() );
  101. SetPageSettings( pageInfo );
  102. SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
  103. SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) );
  104. // Create the PCB_LAYER_WIDGET *after* SetLayout():
  105. m_LayersManager = new GERBER_LAYER_WIDGET( this, GetCanvas() );
  106. // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
  107. // initialize parameters in m_LayersManager
  108. LoadSettings( config() );
  109. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  110. if( m_LastGridSizeId < 0 )
  111. m_LastGridSizeId = 0;
  112. if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000 )
  113. m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000;
  114. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
  115. setupTools();
  116. ReCreateMenuBar();
  117. ReCreateHToolbar();
  118. ReCreateOptToolbar();
  119. ReCreateAuxiliaryToolbar();
  120. m_auimgr.SetManagedWindow( this );
  121. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  122. m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top().Layer(4) );
  123. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  124. m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left().Layer(3) );
  125. m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right().Layer(3)
  126. .Caption( _( "Layers Manager" ) ).PaneBorder( false )
  127. .MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
  128. m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  129. ReFillLayerWidget(); // this is near end because contents establish size
  130. m_auimgr.Update();
  131. SetActiveLayer( 0, true );
  132. GetToolManager()->RunAction( ACTIONS::zoomFitScreen, false );
  133. EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = LoadCanvasTypeSetting();
  134. // Nudge user to switch to OpenGL if they are on legacy or Cairo
  135. if( m_firstRunDialogSetting < 1 )
  136. {
  137. if( canvasType != EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
  138. {
  139. wxString msg = _( "KiCad can use your graphics card to give you a smoother "
  140. "and faster experience. This option is turned off by "
  141. "default since it is not compatible with all computers.\n\n"
  142. "Would you like to try enabling graphics acceleration?\n\n"
  143. "If you'd like to choose later, select Accelerated Graphics "
  144. "in the Preferences menu." );
  145. wxMessageDialog dlg( this, msg, _( "Enable Graphics Acceleration" ), wxYES_NO );
  146. dlg.SetYesNoLabels( _( "&Enable Acceleration" ), _( "&No Thanks" ) );
  147. if( dlg.ShowModal() == wxID_YES )
  148. {
  149. // Save Cairo as default in case OpenGL crashes
  150. saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO );
  151. // Switch to OpenGL, which will save the new setting if successful
  152. GetToolManager()->RunAction( ACTIONS::acceleratedGraphics, true );
  153. // Switch back to Cairo if OpenGL is not supported
  154. if( GetCanvas()->GetBackend() == EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE )
  155. GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
  156. }
  157. else
  158. {
  159. // If they were on legacy, switch to Cairo
  160. GetToolManager()->RunAction( ACTIONS::standardGraphics, true );
  161. }
  162. }
  163. m_firstRunDialogSetting = 1;
  164. SaveSettings( config() );
  165. }
  166. GetCanvas()->SwitchBackend( canvasType );
  167. ActivateGalCanvas();
  168. // Enable the axes to match legacy draw style
  169. auto& galOptions = GetGalDisplayOptions();
  170. galOptions.m_axesEnabled = true;
  171. galOptions.NotifyChanged();
  172. m_LayersManager->ReFill();
  173. m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
  174. // Update the checked state of tools
  175. SyncToolbars();
  176. }
  177. GERBVIEW_FRAME::~GERBVIEW_FRAME()
  178. {
  179. GetCanvas()->GetView()->Clear();
  180. GetGerberLayout()->GetImagesList()->DeleteAllImages();
  181. delete m_gerberLayout;
  182. }
  183. void GERBVIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
  184. {
  185. GetCanvas()->StopDrawing();
  186. GetCanvas()->GetView()->Clear();
  187. if( m_toolManager )
  188. m_toolManager->DeactivateTool();
  189. // Be sure any OpenGL event cannot be fired after frame deletion:
  190. GetCanvas()->SetEvtHandlerEnabled( false );
  191. Destroy();
  192. }
  193. bool GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
  194. {
  195. // Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
  196. // when trying to change the view if it is not fully initialized.
  197. // It happens when starting Gerbview with a gerber job file to load
  198. if( !IsShown() )
  199. Show();
  200. // The current project path is also a valid command parameter. Check if a single path
  201. // rather than a file name was passed to GerbView and use it as the initial MRU path.
  202. if( aFileSet.size() > 0 )
  203. {
  204. wxString path = aFileSet[0];
  205. // For some reason wxApp appears to leave the trailing double quote on quoted
  206. // parameters which are required for paths with spaces. Maybe this should be
  207. // pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
  208. // We can't buy a break!
  209. if( path.Last() == wxChar( '\"' ) )
  210. path.RemoveLast();
  211. if( !wxFileExists( path ) && wxDirExists( path ) )
  212. {
  213. wxLogDebug( wxT( "MRU path: %s." ), GetChars( path ) );
  214. m_mruPath = path;
  215. return true;
  216. }
  217. const unsigned limit = std::min( unsigned( aFileSet.size() ),
  218. unsigned( GERBER_DRAWLAYERS_COUNT ) );
  219. int layer = 0;
  220. for( unsigned i = 0; i < limit; ++i, ++layer )
  221. {
  222. SetActiveLayer( layer );
  223. // Try to guess the type of file by its ext
  224. // if it is .drl (Kicad files), .nc or .xnc it is a drill file
  225. wxFileName fn( aFileSet[i] );
  226. wxString ext = fn.GetExt();
  227. if( ext == DrillFileExtension || // our Excellon format
  228. ext == "nc" || ext == "xnc" ) // alternate ext for Excellon format
  229. LoadExcellonFiles( aFileSet[i] );
  230. else if( ext == GerberJobFileExtension )
  231. LoadGerberJobFile( aFileSet[i] );
  232. else
  233. LoadGerberFiles( aFileSet[i] );
  234. }
  235. }
  236. Zoom_Automatique( true ); // Zoom fit in frame
  237. return true;
  238. }
  239. void GERBVIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
  240. {
  241. EDA_DRAW_FRAME::LoadSettings( aCfg );
  242. // was: wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
  243. wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
  244. bool tmp;
  245. aCfg->Read( cfgShowBorderAndTitleBlock, &tmp, false );
  246. SetElementVisibility( LAYER_WORKSHEET, tmp );
  247. PAGE_INFO pageInfo( wxT( "GERBER" ) );
  248. wxString pageType;
  249. aCfg->Read( cfgShowPageSizeOption, &pageType, wxT( "GERBER" ) );
  250. pageInfo.SetType( pageType );
  251. SetPageSettings( pageInfo );
  252. aCfg->Read( cfgShowDCodes, &tmp, true );
  253. SetElementVisibility( LAYER_DCODES, tmp );
  254. aCfg->Read( cfgShowNegativeObjects, &tmp, false );
  255. SetElementVisibility( LAYER_NEGATIVE_OBJECTS, tmp );
  256. // because we have more than one file history, we must read this one
  257. // using a specific path
  258. aCfg->SetPath( wxT( "drl_files" ) );
  259. m_drillFileHistory.Load( *aCfg );
  260. aCfg->SetPath( wxT( ".." ) );
  261. // because we have more than one file history, we must read this one
  262. // using a specific path
  263. aCfg->SetPath( wxT( "zip_files" ) );
  264. m_zipFileHistory.Load( *aCfg );
  265. aCfg->SetPath( wxT( ".." ) );
  266. // because we have more than one file history, we must read this one
  267. // using a specific path
  268. aCfg->SetPath( "job_files" );
  269. m_jobFileHistory.Load( *aCfg );
  270. aCfg->SetPath( wxT( ".." ) );
  271. }
  272. void GERBVIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
  273. {
  274. EDA_DRAW_FRAME::SaveSettings( aCfg );
  275. // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
  276. wxConfigSaveSetups( aCfg, GetConfigurationSettings() );
  277. aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
  278. aCfg->Write( cfgShowBorderAndTitleBlock, m_showBorderAndTitleBlock );
  279. aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
  280. aCfg->Write( cfgShowNegativeObjects, IsElementVisible( LAYER_NEGATIVE_OBJECTS ) );
  281. // Save the drill file history list.
  282. // Because we have more than one file history, we must save this one
  283. // in a specific path
  284. aCfg->SetPath( wxT( "drl_files" ) );
  285. m_drillFileHistory.Save( *aCfg );
  286. aCfg->SetPath( wxT( ".." ) );
  287. // Save the zip file history list.
  288. aCfg->SetPath( wxT( "zip_files" ) );
  289. m_zipFileHistory.Save( *aCfg );
  290. aCfg->SetPath( wxT( ".." ) );
  291. // Save the job file history list.
  292. aCfg->SetPath( "job_files" );
  293. m_jobFileHistory.Save( *aCfg );
  294. aCfg->SetPath( ".." );
  295. }
  296. void GERBVIEW_FRAME::ReFillLayerWidget()
  297. {
  298. m_LayersManager->ReFill();
  299. m_SelLayerBox->Resync();
  300. ReCreateAuxiliaryToolbar();
  301. // Update the checked state of tools
  302. SyncToolbars();
  303. wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
  304. wxSize bestz = m_LayersManager->GetBestSize();
  305. bestz.x += 5; // gives a little margin
  306. lyrs.MinSize( bestz );
  307. lyrs.BestSize( bestz );
  308. lyrs.FloatingSize( bestz );
  309. if( lyrs.IsDocked() )
  310. m_auimgr.Update();
  311. else
  312. m_LayersManager->SetSize( bestz );
  313. syncLayerWidget();
  314. }
  315. void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
  316. {
  317. bool dcodes_changed = false;
  318. switch( aLayerID )
  319. {
  320. case LAYER_DCODES:
  321. dcodes_changed = m_DisplayOptions.m_DisplayDCodes != aNewState;
  322. m_DisplayOptions.m_DisplayDCodes = aNewState;
  323. break;
  324. case LAYER_NEGATIVE_OBJECTS:
  325. {
  326. m_DisplayOptions.m_DisplayNegativeObjects = aNewState;
  327. auto view = GetCanvas()->GetView();
  328. view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
  329. {
  330. auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
  331. // GetLayerPolarity() returns true for negative items
  332. return ( item && item->GetLayerPolarity() );
  333. } );
  334. break;
  335. }
  336. case LAYER_WORKSHEET:
  337. m_showBorderAndTitleBlock = aNewState;
  338. GetCanvas()->GetView()->SetLayerVisible( LAYER_WORKSHEET, aNewState );
  339. break;
  340. case LAYER_GERBVIEW_GRID:
  341. SetGridVisibility( aNewState );
  342. break;
  343. default:
  344. wxLogDebug( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ), aLayerID );
  345. }
  346. if( dcodes_changed )
  347. {
  348. auto view = GetCanvas()->GetView();
  349. for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
  350. {
  351. int layer = GERBER_DRAW_LAYER( i );
  352. int dcode_layer = GERBER_DCODE_LAYER( layer );
  353. view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
  354. }
  355. }
  356. applyDisplaySettingsToGAL();
  357. m_LayersManager->SetRenderState( aLayerID, aNewState );
  358. }
  359. void GERBVIEW_FRAME::applyDisplaySettingsToGAL()
  360. {
  361. auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
  362. KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
  363. settings->LoadDisplayOptions( &m_DisplayOptions );
  364. settings->ImportLegacyColors( m_colorsSettings );
  365. GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
  366. }
  367. int GERBVIEW_FRAME::getNextAvailableLayer( int aLayer ) const
  368. {
  369. int layer = aLayer;
  370. for( unsigned i = 0; i < ImagesMaxCount(); ++i )
  371. {
  372. const GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
  373. if( gerber == NULL ) // this graphic layer is available: use it
  374. return layer;
  375. ++layer; // try next graphic layer
  376. if( layer >= (int)ImagesMaxCount() )
  377. layer = 0;
  378. }
  379. return NO_AVAILABLE_LAYERS;
  380. }
  381. void GERBVIEW_FRAME::syncLayerWidget()
  382. {
  383. m_LayersManager->SelectLayer( GetActiveLayer() );
  384. }
  385. void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
  386. {
  387. if( aRebuildLayerBox )
  388. m_SelLayerBox->Resync();
  389. m_SelLayerBox->SetSelection( GetActiveLayer() );
  390. int dcodeSelected = -1;
  391. GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
  392. if( gerber )
  393. dcodeSelected = gerber->m_Selected_Tool;
  394. if( m_DCodeSelector )
  395. {
  396. updateDCodeSelectBox();
  397. m_DCodeSelector->SetDCodeSelection( dcodeSelected );
  398. m_DCodeSelector->Enable( gerber != NULL );
  399. }
  400. }
  401. void GERBVIEW_FRAME::Liste_D_Codes()
  402. {
  403. int ii, jj;
  404. wxString Line;
  405. wxArrayString list;
  406. double scale = GetUserUnits() == INCHES ? IU_PER_MILS * 1000 : IU_PER_MM;
  407. int curr_layer = GetActiveLayer();
  408. for( int layer = 0; layer < (int)ImagesMaxCount(); ++layer )
  409. {
  410. GERBER_FILE_IMAGE* gerber = GetGbrImage( layer );
  411. if( gerber == NULL )
  412. continue;
  413. if( gerber->GetDcodesCount() == 0 )
  414. continue;
  415. if( layer == curr_layer )
  416. Line.Printf( wxT( "*** Active layer (%2.2d) ***" ), layer + 1 );
  417. else
  418. Line.Printf( wxT( "*** layer %2.2d ***" ), layer + 1 );
  419. list.Add( Line );
  420. const char* units = GetUserUnits() == INCHES ? "\"" : "mm";
  421. for( ii = 0, jj = 1; ii < TOOLS_MAX_COUNT; ii++ )
  422. {
  423. D_CODE* pt_D_code = gerber->GetDCODE( ii + FIRST_DCODE );
  424. if( pt_D_code == NULL )
  425. continue;
  426. if( !pt_D_code->m_InUse && !pt_D_code->m_Defined )
  427. continue;
  428. Line.Printf( wxT( "tool %2.2d: D%2.2d V %.4f %s H %.4f %s %s attribute '%s'" ),
  429. jj,
  430. pt_D_code->m_Num_Dcode,
  431. pt_D_code->m_Size.y / scale, units,
  432. pt_D_code->m_Size.x / scale, units,
  433. D_CODE::ShowApertureType( pt_D_code->m_Shape ),
  434. pt_D_code->m_AperFunction.IsEmpty()? wxT( "none" ) : GetChars( pt_D_code->m_AperFunction )
  435. );
  436. if( !pt_D_code->m_Defined )
  437. Line += wxT( " (not defined)" );
  438. if( pt_D_code->m_InUse )
  439. Line += wxT( " (in use)" );
  440. list.Add( Line );
  441. jj++;
  442. }
  443. }
  444. wxSingleChoiceDialog dlg( this, wxEmptyString, _( "D Codes" ), list, (void**) NULL,
  445. wxCHOICEDLG_STYLE & ~wxCANCEL );
  446. dlg.ShowModal();
  447. }
  448. void GERBVIEW_FRAME::SortLayersByX2Attributes()
  449. {
  450. auto remapping = GetImagesList()->SortImagesByZOrder();
  451. ReFillLayerWidget();
  452. syncLayerBox( true );
  453. std::unordered_map<int, int> view_remapping;
  454. for( auto it : remapping )
  455. {
  456. view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second );
  457. view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] =
  458. GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) );
  459. }
  460. GetCanvas()->GetView()->ReorderLayerData( view_remapping );
  461. GetCanvas()->Refresh();
  462. }
  463. void GERBVIEW_FRAME::UpdateDisplayOptions( const GBR_DISPLAY_OPTIONS& aOptions )
  464. {
  465. bool update_flashed = ( m_DisplayOptions.m_DisplayFlashedItemsFill !=
  466. aOptions.m_DisplayFlashedItemsFill );
  467. bool update_lines = ( m_DisplayOptions.m_DisplayLinesFill !=
  468. aOptions.m_DisplayLinesFill );
  469. bool update_polygons = ( m_DisplayOptions.m_DisplayPolygonsFill !=
  470. aOptions.m_DisplayPolygonsFill );
  471. m_DisplayOptions = aOptions;
  472. applyDisplaySettingsToGAL();
  473. auto view = GetCanvas()->GetView();
  474. if( update_flashed )
  475. {
  476. view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
  477. {
  478. auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
  479. switch( item->m_Shape )
  480. {
  481. case GBR_SPOT_CIRCLE:
  482. case GBR_SPOT_RECT:
  483. case GBR_SPOT_OVAL:
  484. case GBR_SPOT_POLY:
  485. case GBR_SPOT_MACRO:
  486. return true;
  487. default:
  488. return false;
  489. }
  490. } );
  491. }
  492. else if( update_lines )
  493. {
  494. view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
  495. {
  496. auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
  497. switch( item->m_Shape )
  498. {
  499. case GBR_CIRCLE:
  500. case GBR_ARC:
  501. case GBR_SEGMENT:
  502. return true;
  503. default:
  504. return false;
  505. }
  506. } );
  507. }
  508. else if( update_polygons )
  509. {
  510. view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem )
  511. {
  512. auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
  513. return ( item->m_Shape == GBR_POLYGON );
  514. } );
  515. }
  516. view->UpdateAllItems( KIGFX::COLOR );
  517. GetCanvas()->Refresh();
  518. }
  519. void GERBVIEW_FRAME::UpdateTitleAndInfo()
  520. {
  521. GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
  522. // Display the gerber filename
  523. if( gerber == NULL )
  524. {
  525. SetTitle( "GerbView" );
  526. SetStatusText( wxEmptyString, 0 );
  527. wxString info;
  528. info.Printf( _( "Drawing layer %d not in use" ), GetActiveLayer() + 1 );
  529. m_TextInfo->SetValue( info );
  530. if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
  531. m_auimgr.Update();
  532. ClearMsgPanel();
  533. return;
  534. }
  535. else
  536. {
  537. wxString title;
  538. title.Printf( _( "GerbView" ) + wxT( " \u2014 %s%s" ),
  539. gerber->m_FileName,
  540. gerber->m_IsX2_file ? _( " (with X2 attributes)" )
  541. : wxString( wxEmptyString ) );
  542. SetTitle( title );
  543. gerber->DisplayImageInfo( this );
  544. // Display Image Name and Layer Name (from the current gerber data):
  545. wxString status;
  546. status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
  547. gerber->m_ImageName,
  548. gerber->GetLayerParams().m_LayerName );
  549. SetStatusText( status, 0 );
  550. // Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
  551. wxString info;
  552. info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
  553. gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
  554. gerber->m_FmtLen.x - gerber->m_FmtScale.x,
  555. gerber->m_FmtScale.x,
  556. gerber->m_FmtLen.y - gerber->m_FmtScale.y,
  557. gerber->m_FmtScale.y,
  558. gerber->m_NoTrailingZeros ? 'T' : 'L' );
  559. if( gerber->m_IsX2_file )
  560. info << wxT(" ") << _( "X2 attr" );
  561. m_TextInfo->SetValue( info );
  562. if( EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
  563. m_auimgr.Update();
  564. }
  565. }
  566. bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
  567. {
  568. switch( aLayerID )
  569. {
  570. case LAYER_DCODES: return m_DisplayOptions.m_DisplayDCodes;
  571. case LAYER_NEGATIVE_OBJECTS: return m_DisplayOptions.m_DisplayNegativeObjects;
  572. case LAYER_GERBVIEW_GRID: return IsGridVisible();
  573. case LAYER_WORKSHEET: return m_showBorderAndTitleBlock;
  574. case LAYER_PCB_BACKGROUND: return true;
  575. default:
  576. wxLogDebug( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ), aLayerID );
  577. }
  578. return true;
  579. }
  580. LSET GERBVIEW_FRAME::GetVisibleLayers() const
  581. {
  582. LSET visible = LSET::AllLayersMask();
  583. if( GetCanvas() )
  584. {
  585. for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
  586. visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
  587. }
  588. return visible;
  589. }
  590. void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask )
  591. {
  592. if( GetCanvas() )
  593. {
  594. for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
  595. {
  596. bool v = aLayerMask[i];
  597. int layer = GERBER_DRAW_LAYER( i );
  598. GetCanvas()->GetView()->SetLayerVisible( layer, v );
  599. GetCanvas()->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
  600. m_DisplayOptions.m_DisplayDCodes && v );
  601. }
  602. }
  603. }
  604. bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
  605. {
  606. return m_LayersManager->IsLayerVisible( aLayer );
  607. }
  608. COLOR4D GERBVIEW_FRAME::GetVisibleElementColor( int aLayerID )
  609. {
  610. COLOR4D color = COLOR4D::UNSPECIFIED;
  611. switch( aLayerID )
  612. {
  613. case LAYER_NEGATIVE_OBJECTS:
  614. case LAYER_DCODES:
  615. case LAYER_WORKSHEET:
  616. case LAYER_PCB_BACKGROUND:
  617. color = m_colorsSettings->GetItemColor( aLayerID );
  618. break;
  619. case LAYER_GERBVIEW_GRID:
  620. color = GetGridColor();
  621. break;
  622. default:
  623. wxLogDebug( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ), aLayerID );
  624. }
  625. return color;
  626. }
  627. void GERBVIEW_FRAME::SetGridVisibility( bool aVisible )
  628. {
  629. EDA_DRAW_FRAME::SetGridVisibility( aVisible );
  630. m_LayersManager->SetRenderState( LAYER_GERBVIEW_GRID, aVisible );
  631. }
  632. void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, COLOR4D aColor )
  633. {
  634. switch( aLayerID )
  635. {
  636. case LAYER_NEGATIVE_OBJECTS:
  637. case LAYER_DCODES:
  638. case LAYER_WORKSHEET:
  639. m_colorsSettings->SetItemColor( aLayerID, aColor );
  640. break;
  641. case LAYER_GERBVIEW_GRID:
  642. SetGridColor( aColor );
  643. m_colorsSettings->SetItemColor( aLayerID, aColor );
  644. break;
  645. case LAYER_PCB_BACKGROUND:
  646. SetDrawBgColor( aColor );
  647. m_colorsSettings->SetItemColor( aLayerID, aColor );
  648. break;
  649. default:
  650. wxLogDebug( wxT( "GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d" ), aLayerID );
  651. }
  652. }
  653. COLOR4D GERBVIEW_FRAME::GetNegativeItemsColor()
  654. {
  655. if( IsElementVisible( LAYER_NEGATIVE_OBJECTS ) )
  656. return GetVisibleElementColor( LAYER_NEGATIVE_OBJECTS );
  657. else
  658. return GetDrawBgColor();
  659. }
  660. COLOR4D GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
  661. {
  662. return m_colorsSettings->GetLayerColor( aLayer );
  663. }
  664. void GERBVIEW_FRAME::SetLayerColor( int aLayer, COLOR4D aColor )
  665. {
  666. m_colorsSettings->SetLayerColor( aLayer, aColor );
  667. applyDisplaySettingsToGAL();
  668. }
  669. int GERBVIEW_FRAME::GetActiveLayer()
  670. {
  671. return ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer;
  672. }
  673. void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
  674. {
  675. ( (GBR_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
  676. if( doLayerWidgetUpdate )
  677. m_LayersManager->SelectLayer( GetActiveLayer() );
  678. UpdateTitleAndInfo();
  679. m_toolManager->RunAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
  680. GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
  681. GetCanvas()->SetHighContrastLayer( GERBER_DRAW_LAYER( aLayer ) );
  682. GetCanvas()->Refresh();
  683. }
  684. void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
  685. {
  686. m_paper = aPageSettings;
  687. GBR_SCREEN* screen = static_cast<GBR_SCREEN*>( GetScreen() );
  688. if( screen )
  689. screen->InitDataPoints( aPageSettings.GetSizeIU() );
  690. auto drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
  691. // Prepare worksheet template
  692. auto worksheet =
  693. new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
  694. if( screen != NULL )
  695. {
  696. worksheet->SetSheetNumber( 1 );
  697. worksheet->SetSheetCount( 1 );
  698. }
  699. // PCB_DRAW_PANEL_GAL takes ownership of the worksheet
  700. drawPanel->SetWorksheet( worksheet );
  701. }
  702. const PAGE_INFO& GERBVIEW_FRAME::GetPageSettings() const
  703. {
  704. return m_paper;
  705. }
  706. const wxSize GERBVIEW_FRAME::GetPageSizeIU() const
  707. {
  708. // this function is only needed because EDA_DRAW_FRAME is not compiled
  709. // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
  710. // into an application specific source file.
  711. return GetPageSettings().GetSizeIU();
  712. }
  713. const TITLE_BLOCK& GERBVIEW_FRAME::GetTitleBlock() const
  714. {
  715. wxASSERT( m_gerberLayout );
  716. return m_gerberLayout->GetTitleBlock();
  717. }
  718. void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
  719. {
  720. wxASSERT( m_gerberLayout );
  721. m_gerberLayout->SetTitleBlock( aTitleBlock );
  722. }
  723. const wxPoint& GERBVIEW_FRAME::GetAuxOrigin() const
  724. {
  725. wxASSERT( m_gerberLayout );
  726. return m_gerberLayout->GetAuxOrigin();
  727. }
  728. void GERBVIEW_FRAME::SetAuxOrigin( const wxPoint& aPosition )
  729. {
  730. wxASSERT( m_gerberLayout );
  731. m_gerberLayout->SetAuxOrigin( aPosition );
  732. }
  733. void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
  734. {
  735. GetCanvas()->GetGAL()->SetGridColor( aColor );
  736. m_gridColor = aColor;
  737. }
  738. /*
  739. * Display the grid status.
  740. */
  741. void GERBVIEW_FRAME::DisplayGridMsg()
  742. {
  743. wxString line;
  744. wxString gridformatter;
  745. switch( m_userUnits )
  746. {
  747. case INCHES:
  748. gridformatter = "grid X %.6f Y %.6f";
  749. break;
  750. case MILLIMETRES:
  751. gridformatter = "grid X %.6f Y %.6f";
  752. break;
  753. default:
  754. gridformatter = "grid X %f Y %f";
  755. break;
  756. }
  757. BASE_SCREEN* screen = GetScreen();
  758. wxArrayString gridsList;
  759. int icurr = screen->BuildGridsChoiceList( gridsList, m_userUnits != INCHES );
  760. GRID_TYPE& grid = screen->GetGrid( icurr );
  761. double grid_x = To_User_Unit( m_userUnits, grid.m_Size.x );
  762. double grid_y = To_User_Unit( m_userUnits, grid.m_Size.y );
  763. line.Printf( gridformatter, grid_x, grid_y );
  764. SetStatusText( line, 4 );
  765. }
  766. void GERBVIEW_FRAME::UpdateStatusBar()
  767. {
  768. EDA_DRAW_FRAME::UpdateStatusBar();
  769. GBR_SCREEN* screen = (GBR_SCREEN*) GetScreen();
  770. if( !screen )
  771. return;
  772. wxString line;
  773. VECTOR2D cursorPos = GetCanvas()->GetViewControls()->GetCursorPosition();
  774. if( GetShowPolarCoords() ) // display relative polar coordinates
  775. {
  776. double dx = cursorPos.x - screen->m_LocalOrigin.x;
  777. double dy = cursorPos.y - screen->m_LocalOrigin.y;
  778. double theta = RAD2DEG( atan2( -dy, dx ) );
  779. double ro = hypot( dx, dy );
  780. wxString formatter;
  781. switch( GetUserUnits() )
  782. {
  783. case INCHES: formatter = wxT( "r %.6f theta %.1f" ); break;
  784. case MILLIMETRES: formatter = wxT( "r %.5f theta %.1f" ); break;
  785. case UNSCALED_UNITS: formatter = wxT( "r %f theta %f" ); break;
  786. default: wxASSERT( false ); break;
  787. }
  788. line.Printf( formatter, To_User_Unit( GetUserUnits(), ro ), theta );
  789. SetStatusText( line, 3 );
  790. }
  791. // Display absolute coordinates:
  792. double dXpos = To_User_Unit( GetUserUnits(), cursorPos.x );
  793. double dYpos = To_User_Unit( GetUserUnits(), cursorPos.y );
  794. wxString absformatter;
  795. wxString relformatter;
  796. switch( GetUserUnits() )
  797. {
  798. case INCHES:
  799. absformatter = wxT( "X %.6f Y %.6f" );
  800. relformatter = wxT( "dx %.6f dy %.6f dist %.4f" );
  801. break;
  802. case MILLIMETRES:
  803. absformatter = wxT( "X %.5f Y %.5f" );
  804. relformatter = wxT( "dx %.5f dy %.5f dist %.3f" );
  805. break;
  806. case UNSCALED_UNITS:
  807. absformatter = wxT( "X %f Y %f" );
  808. relformatter = wxT( "dx %f dy %f dist %f" );
  809. break;
  810. default:
  811. wxASSERT( false );
  812. break;
  813. }
  814. line.Printf( absformatter, dXpos, dYpos );
  815. SetStatusText( line, 2 );
  816. if( !GetShowPolarCoords() ) // display relative cartesian coordinates
  817. {
  818. // Display relative coordinates:
  819. dXpos = To_User_Unit( GetUserUnits(), cursorPos.x - screen->m_LocalOrigin.x );
  820. dYpos = To_User_Unit( GetUserUnits(), cursorPos.y - screen->m_LocalOrigin.y );
  821. // We already decided the formatter above
  822. line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
  823. SetStatusText( line, 3 );
  824. }
  825. DisplayGridMsg();
  826. }
  827. const wxString GERBVIEW_FRAME::GetZoomLevelIndicator() const
  828. {
  829. return EDA_DRAW_FRAME::GetZoomLevelIndicator();
  830. }
  831. GERBER_FILE_IMAGE* GERBVIEW_FRAME::GetGbrImage( int aIdx ) const
  832. {
  833. return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
  834. }
  835. unsigned GERBVIEW_FRAME::ImagesMaxCount() const
  836. {
  837. return m_gerberLayout->GetImagesList()->ImagesMaxCount();
  838. }
  839. void GERBVIEW_FRAME::unitsChangeRefresh()
  840. {
  841. // Called on units change (see EDA_DRAW_FRAME)
  842. EDA_DRAW_FRAME::unitsChangeRefresh();
  843. updateDCodeSelectBox();
  844. updateGridSelectBox();
  845. }
  846. void GERBVIEW_FRAME::ActivateGalCanvas()
  847. {
  848. EDA_DRAW_FRAME::ActivateGalCanvas();
  849. EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
  850. if( m_toolManager )
  851. {
  852. m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
  853. GetCanvas()->GetViewControls(), this );
  854. m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
  855. }
  856. galCanvas->GetGAL()->SetGridColor( GetLayerColor( LAYER_GERBVIEW_GRID ) );
  857. SetPageSettings( GetPageSettings() );
  858. galCanvas->GetView()->RecacheAllItems();
  859. galCanvas->SetEventDispatcher( m_toolDispatcher );
  860. galCanvas->StartDrawing();
  861. m_LayersManager->ReFill();
  862. m_LayersManager->ReFillRender();
  863. ReCreateOptToolbar();
  864. ReCreateMenuBar();
  865. // Update the checked state of tools
  866. SyncToolbars();
  867. }
  868. void GERBVIEW_FRAME::setupTools()
  869. {
  870. // Create the manager and dispatcher & route draw panel events to the dispatcher
  871. m_toolManager = new TOOL_MANAGER;
  872. m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
  873. GetCanvas()->GetViewControls(), this );
  874. m_actions = new GERBVIEW_ACTIONS();
  875. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
  876. // Register tools
  877. m_toolManager->RegisterTool( new COMMON_CONTROL );
  878. m_toolManager->RegisterTool( new COMMON_TOOLS );
  879. m_toolManager->RegisterTool( new GERBVIEW_SELECTION_TOOL );
  880. m_toolManager->RegisterTool( new GERBVIEW_CONTROL );
  881. m_toolManager->RegisterTool( new ZOOM_TOOL );
  882. m_toolManager->InitTools();
  883. // Run the selection tool, it is supposed to be always active
  884. m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
  885. }
  886. void GERBVIEW_FRAME::updateGridSelectBox()
  887. {
  888. UpdateStatusBar();
  889. DisplayUnitsMsg();
  890. if( m_gridSelectBox == NULL )
  891. return;
  892. // Update grid values with the current units setting.
  893. m_gridSelectBox->Clear();
  894. wxArrayString gridsList;
  895. int icurr = GetScreen()->BuildGridsChoiceList( gridsList, GetUserUnits() != INCHES );
  896. for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ )
  897. {
  898. GRID_TYPE& grid = GetScreen()->GetGrid( i );
  899. m_gridSelectBox->Append( gridsList[i], (void*) &grid.m_CmdId );
  900. }
  901. m_gridSelectBox->SetSelection( icurr );
  902. }
  903. void GERBVIEW_FRAME::updateZoomSelectBox()
  904. {
  905. if( m_zoomSelectBox == NULL )
  906. return;
  907. wxString msg;
  908. m_zoomSelectBox->Clear();
  909. m_zoomSelectBox->Append( _( "Zoom Auto" ) );
  910. m_zoomSelectBox->SetSelection( 0 );
  911. for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); ++i )
  912. {
  913. msg = _( "Zoom " );
  914. double level = m_zoomLevelCoeff / (double)GetScreen()->m_ZoomList[i];
  915. wxString value = wxString::Format( wxT( "%.2f" ), level );
  916. msg += value;
  917. m_zoomSelectBox->Append( msg );
  918. if( GetScreen()->GetZoom() == GetScreen()->m_ZoomList[i] )
  919. m_zoomSelectBox->SetSelection( i + 1 );
  920. }
  921. }
  922. void GERBVIEW_FRAME::OnUpdateSelectZoom( wxUpdateUIEvent& aEvent )
  923. {
  924. if( m_zoomSelectBox == NULL || m_auxiliaryToolBar == NULL )
  925. return;
  926. int current = 0; // display Auto if no match found
  927. // check for a match within 1%
  928. double zoom = GetCanvas()->GetLegacyZoom();
  929. for( unsigned i = 0; i < GetScreen()->m_ZoomList.size(); i++ )
  930. {
  931. if( std::fabs( zoom - GetScreen()->m_ZoomList[i] ) < ( zoom / 100.0 ) )
  932. {
  933. current = i + 1;
  934. break;
  935. }
  936. }
  937. if( current != m_zoomSelectBox->GetSelection() )
  938. m_zoomSelectBox->SetSelection( current );
  939. }
  940. void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged )
  941. {
  942. EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged );
  943. RecreateToolbars();
  944. Layout();
  945. SendSizeEvent();
  946. }