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.

878 lines
26 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* 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
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
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
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
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
  6. * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file footprint_viewer_frame.cpp
  27. */
  28. #include <fctsys.h>
  29. #include <pgm_base.h>
  30. #include <kiway.h>
  31. #include <class_drawpanel.h>
  32. #include <pcb_draw_panel_gal.h>
  33. #include <3d_viewer/eda_3d_viewer.h>
  34. #include <dialog_helpers.h>
  35. #include <msgpanel.h>
  36. #include <fp_lib_table.h>
  37. #include <lib_id.h>
  38. #include <confirm.h>
  39. #include <bitmaps.h>
  40. #include <gal/graphics_abstraction_layer.h>
  41. #include <eda_dockart.h>
  42. #include <pcb_painter.h>
  43. #include <class_board.h>
  44. #include <class_module.h>
  45. #include <pcbnew.h>
  46. #include <pcbnew_id.h>
  47. #include <footprint_viewer_frame.h>
  48. #include <footprint_info.h>
  49. #include <hotkeys.h>
  50. #include <wildcards_and_files_ext.h>
  51. #include <config_params.h>
  52. #include <tool/tool_manager.h>
  53. #include <tool/tool_dispatcher.h>
  54. #include <tool/common_tools.h>
  55. #include "tools/selection_tool.h"
  56. #include "tools/pcbnew_control.h"
  57. #include "tools/pcb_actions.h"
  58. #include <functional>
  59. #include <memory>
  60. using namespace std::placeholders;
  61. #define NEXT_PART 1
  62. #define NEW_PART 0
  63. #define PREVIOUS_PART -1
  64. BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
  65. // Window events
  66. EVT_CLOSE( FOOTPRINT_VIEWER_FRAME::OnCloseWindow )
  67. EVT_SIZE( FOOTPRINT_VIEWER_FRAME::OnSize )
  68. EVT_ACTIVATE( FOOTPRINT_VIEWER_FRAME::OnActivate )
  69. // Menu (and/or hotkey) events
  70. EVT_MENU( wxID_EXIT, FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer )
  71. EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset )
  72. // Menu Help
  73. EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
  74. EVT_MENU( wxID_INDEX, EDA_DRAW_FRAME::GetKicadHelp )
  75. EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
  76. EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::GetKicadAbout )
  77. // Toolbar events
  78. EVT_TOOL( ID_MODVIEW_SELECT_PART, FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint )
  79. EVT_TOOL( ID_MODVIEW_OPTIONS, FOOTPRINT_VIEWER_FRAME::InstallDisplayOptions )
  80. EVT_TOOL( ID_MODVIEW_NEXT, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
  81. EVT_TOOL( ID_MODVIEW_PREVIOUS, FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList )
  82. EVT_TOOL( ID_MODVIEW_EXPORT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint )
  83. EVT_TOOL( ID_MODVIEW_SHOW_3D_VIEW, FOOTPRINT_VIEWER_FRAME::Show3D_Frame )
  84. EVT_CHOICE( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectZoom )
  85. EVT_CHOICE( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnSelectGrid )
  86. EVT_UPDATE_UI( ID_ON_GRID_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectGrid )
  87. EVT_UPDATE_UI( ID_ON_ZOOM_SELECT, FOOTPRINT_VIEWER_FRAME::OnUpdateSelectZoom )
  88. // listbox events
  89. EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList )
  90. EVT_LISTBOX( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList )
  91. EVT_LISTBOX_DCLICK( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList )
  92. END_EVENT_TABLE()
  93. /* Note:
  94. * FOOTPRINT_VIEWER_FRAME can be created in "modal mode", or as a usual frame.
  95. * In modal mode:
  96. * a tool to export the selected footprint is shown in the toolbar
  97. * the style is wxFRAME_FLOAT_ON_PARENT
  98. * Note:
  99. * On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
  100. * its parent frame is sometimes brought to the foreground when closing the
  101. * LIB_VIEW_FRAME frame.
  102. * If it still happens, it could be better to use wxSTAY_ON_TOP
  103. * instead of wxFRAME_FLOAT_ON_PARENT
  104. */
  105. #define PARENT_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
  106. #define MODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxSTAY_ON_TOP )
  107. #define NONMODAL_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
  108. FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent,
  109. FRAME_T aFrameType ) :
  110. PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
  111. wxDefaultPosition, wxDefaultSize,
  112. aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? ( aParent ? PARENT_STYLE : MODAL_STYLE )
  113. : NONMODAL_STYLE,
  114. aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ? FOOTPRINT_VIEWER_FRAME_NAME_MODAL
  115. : FOOTPRINT_VIEWER_FRAME_NAME )
  116. {
  117. wxASSERT( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL ||
  118. aFrameType == FRAME_PCB_MODULE_VIEWER );
  119. if( aFrameType == FRAME_PCB_MODULE_VIEWER_MODAL )
  120. SetModal( true );
  121. // Force the frame name used in config. the footprint viewer frame has a name
  122. // depending on aFrameType (needed to identify the frame by wxWidgets),
  123. // but only one configuration is preferable.
  124. m_configFrameName = FOOTPRINT_VIEWER_FRAME_NAME;
  125. m_showAxis = true; // true to draw axis.
  126. // Give an icon
  127. wxIcon icon;
  128. icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) );
  129. SetIcon( icon );
  130. m_hotkeysDescrList = g_Module_Viewer_Hotkeys_Descr;
  131. m_libList = new wxListBox( this, ID_MODVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
  132. 0, NULL, wxLB_HSCROLL | wxNO_BORDER );
  133. m_footprintList = new wxListBox( this, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
  134. 0, NULL, wxLB_HSCROLL | wxNO_BORDER );
  135. SetBoard( new BOARD() );
  136. // In viewer, the default net clearance is not known (it depends on the actual board).
  137. // So we do not show the default clearance, by setting it to 0
  138. // The footprint or pad specific clearance will be shown
  139. GetBoard()->GetDesignSettings().GetDefault()->SetClearance(0);
  140. // Don't show the default board solder mask clearance in the footprint viewer. Only the
  141. // footprint or pad clearance setting should be shown if it is not 0.
  142. GetBoard()->GetDesignSettings().m_SolderMaskMargin = 0;
  143. // Ensure all layers and items are visible:
  144. GetBoard()->SetVisibleAlls();
  145. SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
  146. GetScreen()->m_Center = true; // Center coordinate origins on screen.
  147. LoadSettings( config() );
  148. GetGalDisplayOptions().m_axesEnabled = true;
  149. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  150. GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
  151. // Menu bar is not mandatory: uncomment/comment the next line
  152. // to add/remove the menubar
  153. ReCreateMenuBar();
  154. ReCreateHToolbar();
  155. ReCreateVToolbar();
  156. ReCreateLibraryList();
  157. UpdateTitle();
  158. // Create GAL canvas
  159. PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
  160. GetGalDisplayOptions(),
  161. LoadCanvasTypeSetting() );
  162. SetGalCanvas( drawPanel );
  163. // Create the manager and dispatcher & route draw panel events to the dispatcher
  164. m_toolManager = new TOOL_MANAGER;
  165. m_toolManager->SetEnvironment( GetBoard(), drawPanel->GetView(),
  166. drawPanel->GetViewControls(), this );
  167. m_actions = new PCB_ACTIONS();
  168. m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager, m_actions );
  169. drawPanel->SetEventDispatcher( m_toolDispatcher );
  170. m_toolManager->RegisterTool( new PCBNEW_CONTROL );
  171. m_toolManager->RegisterTool( new SELECTION_TOOL ); // for std context menus (zoom & grid)
  172. m_toolManager->RegisterTool( new COMMON_TOOLS );
  173. m_toolManager->InitTools();
  174. m_toolManager->InvokeTool( "pcbnew.InteractiveSelection" );
  175. // If a footprint was previously loaded, reload it
  176. if( getCurNickname().size() && getCurFootprintName().size() )
  177. {
  178. LIB_ID id;
  179. id.SetLibNickname( getCurNickname() );
  180. id.SetLibItemName( getCurFootprintName() );
  181. GetBoard()->Add( loadFootprint( id ) );
  182. }
  183. drawPanel->DisplayBoard( m_Pcb );
  184. m_auimgr.SetManagedWindow( this );
  185. m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
  186. // Horizontal items; layers 4 - 6
  187. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().VToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  188. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  189. // Vertical items; layers 1 - 3
  190. m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(2)
  191. .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 200, -1 ) );
  192. m_auimgr.AddPane( m_footprintList, EDA_PANE().Palette().Name( "Footprints" ).Left().Layer(1)
  193. .CaptionVisible( false ).MinSize( 100, -1 ).BestSize( 300, -1 ) );
  194. m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  195. m_auimgr.AddPane( GetGalCanvas(), EDA_PANE().Canvas().Name( "DrawFrameGal" ).Center().Hide() );
  196. // after changing something to the aui manager,
  197. // call Update()() to reflect the changes
  198. m_auimgr.Update();
  199. GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
  200. UseGalCanvas( true );
  201. // Restore last zoom. (If auto-zooming we'll adjust when we load the footprint.)
  202. GetGalCanvas()->GetView()->SetScale( m_lastZoom );
  203. updateView();
  204. if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
  205. {
  206. Raise(); // On some window managers, this is needed
  207. Show( true );
  208. }
  209. }
  210. FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
  211. {
  212. GetGalCanvas()->StopDrawing();
  213. GetGalCanvas()->GetView()->Clear();
  214. // Be sure any event cannot be fired after frame deletion:
  215. GetGalCanvas()->SetEvtHandlerEnabled( false );
  216. }
  217. void FOOTPRINT_VIEWER_FRAME::OnCloseWindow( wxCloseEvent& Event )
  218. {
  219. // A workaround to avoid flicker, in modal mode when modview frame is destroyed,
  220. // when the aui toolbar is not docked (i.e. shown in a miniframe)
  221. // (usefull on windows only)
  222. m_mainToolBar->SetFocus();
  223. GetGalCanvas()->StopDrawing();
  224. if( IsModal() )
  225. {
  226. // Only dismiss a modal frame once, so that the return values set by
  227. // the prior DismissModal() are not bashed for ShowModal().
  228. if( !IsDismissed() )
  229. DismissModal( false );
  230. // window to be destroyed by the caller of KIWAY_PLAYER::ShowModal()
  231. }
  232. else
  233. Destroy();
  234. }
  235. void FOOTPRINT_VIEWER_FRAME::OnSize( wxSizeEvent& SizeEv )
  236. {
  237. if( m_auimgr.GetManagedWindow() )
  238. m_auimgr.Update();
  239. SizeEv.Skip();
  240. }
  241. void FOOTPRINT_VIEWER_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
  242. {
  243. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  244. UpdateStatusBar();
  245. }
  246. void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
  247. {
  248. m_libList->Clear();
  249. std::vector< wxString > nicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
  250. for( unsigned ii = 0; ii < nicknames.size(); ii++ )
  251. m_libList->Append( nicknames[ii] );
  252. // Search for a previous selection:
  253. int index = m_libList->FindString( getCurNickname() );
  254. if( index != wxNOT_FOUND )
  255. {
  256. m_libList->SetSelection( index, true );
  257. }
  258. else
  259. {
  260. // If not found, clear current library selection because it can be
  261. // deleted after a configuration change.
  262. setCurNickname( wxEmptyString );
  263. setCurFootprintName( wxEmptyString );
  264. }
  265. ReCreateFootprintList();
  266. m_canvas->Refresh();
  267. }
  268. void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
  269. {
  270. m_footprintList->Clear();
  271. if( !getCurNickname() )
  272. {
  273. setCurFootprintName( wxEmptyString );
  274. return;
  275. }
  276. auto fp_info_list = FOOTPRINT_LIST::GetInstance( Kiway() );
  277. wxString nickname = getCurNickname();
  278. fp_info_list->ReadFootprintFiles( Prj().PcbFootprintLibs(), !nickname ? NULL : &nickname );
  279. if( fp_info_list->GetErrorCount() )
  280. {
  281. fp_info_list->DisplayErrors( this );
  282. // For footprint libraries that support one footprint per file, there may have been
  283. // valid footprints read so show the footprints that loaded properly.
  284. if( fp_info_list->GetList().size() == 0 )
  285. return;
  286. }
  287. for( auto& footprint : fp_info_list->GetList() )
  288. {
  289. m_footprintList->Append( footprint->GetFootprintName() );
  290. }
  291. int index = m_footprintList->FindString( getCurFootprintName() );
  292. if( index == wxNOT_FOUND )
  293. setCurFootprintName( wxEmptyString );
  294. else
  295. {
  296. m_footprintList->SetSelection( index, true );
  297. m_footprintList->EnsureVisible( index );
  298. }
  299. }
  300. void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
  301. {
  302. int ii = m_libList->GetSelection();
  303. if( ii < 0 )
  304. return;
  305. wxString name = m_libList->GetString( ii );
  306. if( getCurNickname() == name )
  307. return;
  308. setCurNickname( name );
  309. ReCreateFootprintList();
  310. UpdateTitle();
  311. }
  312. void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
  313. {
  314. if( m_footprintList->GetCount() == 0 )
  315. return;
  316. int ii = m_footprintList->GetSelection();
  317. if( ii < 0 )
  318. return;
  319. wxString name = m_footprintList->GetString( ii );
  320. if( getCurFootprintName().CmpNoCase( name ) != 0 )
  321. {
  322. setCurFootprintName( name );
  323. // Delete the current footprint (MUST reset tools first)
  324. GetToolManager()->ResetTools( TOOL_BASE::MODEL_RELOAD );
  325. SetCurItem( nullptr );
  326. GetBoard()->m_Modules.DeleteAll();
  327. LIB_ID id;
  328. id.SetLibNickname( getCurNickname() );
  329. id.SetLibItemName( getCurFootprintName() );
  330. try
  331. {
  332. GetBoard()->Add( loadFootprint( id ) );
  333. }
  334. catch( const IO_ERROR& ioe )
  335. {
  336. wxString msg = wxString::Format(
  337. _( "Could not load footprint \"%s\" from library \"%s\".\n\nError %s." ),
  338. GetChars( getCurFootprintName() ),
  339. GetChars( getCurNickname() ),
  340. GetChars( ioe.What() ) );
  341. DisplayError( this, msg );
  342. }
  343. UpdateTitle();
  344. updateView();
  345. m_canvas->Refresh();
  346. Update3D_Frame();
  347. }
  348. }
  349. void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& event )
  350. {
  351. if( IsModal() )
  352. {
  353. // @todo(DICK)
  354. ExportSelectedFootprint( event );
  355. // Prevent the double click from being as a single mouse button release
  356. // event in the parent window which would cause the part to be parked
  357. // rather than staying in move mode.
  358. // Remember the mouse button will be released in the parent window
  359. // thus creating a mouse button release event which should be ignored
  360. PCB_EDIT_FRAME* pcbframe = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
  361. // The parent may not be the board editor:
  362. if( pcbframe )
  363. {
  364. pcbframe->SkipNextLeftButtonReleaseEvent();
  365. }
  366. }
  367. }
  368. void FOOTPRINT_VIEWER_FRAME::ExportSelectedFootprint( wxCommandEvent& event )
  369. {
  370. int ii = m_footprintList->GetSelection();
  371. if( ii >= 0 )
  372. {
  373. wxString fp_name = m_footprintList->GetString( ii );
  374. LIB_ID fpid;
  375. fpid.SetLibNickname( getCurNickname() );
  376. fpid.SetLibItemName( fp_name );
  377. DismissModal( true, fpid.Format() );
  378. }
  379. else
  380. {
  381. DismissModal( false );
  382. }
  383. Close( true );
  384. }
  385. void FOOTPRINT_VIEWER_FRAME::LoadSettings( wxConfigBase* aCfg )
  386. {
  387. PCB_BASE_FRAME::LoadSettings( aCfg );
  388. m_configSettings.Load( aCfg ); // mainly, load the color config
  389. aCfg->Read( ConfigBaseName() + AUTO_ZOOM_KEY, &m_autoZoom, true );
  390. aCfg->Read( ConfigBaseName() + ZOOM_KEY, &m_lastZoom, 10.0 );
  391. }
  392. void FOOTPRINT_VIEWER_FRAME::SaveSettings( wxConfigBase* aCfg )
  393. {
  394. PCB_BASE_FRAME::SaveSettings( aCfg );
  395. aCfg->Write( ConfigBaseName() + AUTO_ZOOM_KEY, m_autoZoom );
  396. aCfg->Write( ConfigBaseName() + ZOOM_KEY, GetGalCanvas()->GetView()->GetScale() );
  397. }
  398. const wxString FOOTPRINT_VIEWER_FRAME::getCurNickname()
  399. {
  400. return Prj().GetRString( PROJECT::PCB_FOOTPRINT_VIEWER_NICKNAME );
  401. }
  402. void FOOTPRINT_VIEWER_FRAME::setCurNickname( const wxString& aNickname )
  403. {
  404. Prj().SetRString( PROJECT::PCB_FOOTPRINT_VIEWER_NICKNAME, aNickname );
  405. }
  406. const wxString FOOTPRINT_VIEWER_FRAME::getCurFootprintName()
  407. {
  408. return Prj().GetRString( PROJECT::PCB_FOOTPRINT_VIEWER_FPNAME );
  409. }
  410. void FOOTPRINT_VIEWER_FRAME::setCurFootprintName( const wxString& aName )
  411. {
  412. Prj().SetRString( PROJECT::PCB_FOOTPRINT_VIEWER_FPNAME, aName );
  413. }
  414. void FOOTPRINT_VIEWER_FRAME::OnActivate( wxActivateEvent& event )
  415. {
  416. EDA_DRAW_FRAME::OnActivate( event );
  417. // Ensure we do not have old selection:
  418. if( !event.GetActive() )
  419. return;
  420. // Ensure we have the right library list:
  421. std::vector< wxString > libNicknames = Prj().PcbFootprintLibs()->GetLogicalLibs();
  422. if( libNicknames.size() == m_libList->GetCount() )
  423. {
  424. unsigned ii;
  425. for( ii = 0; ii < libNicknames.size(); ii++ )
  426. {
  427. if( libNicknames[ii] != m_libList->GetString( ii ) )
  428. break;
  429. }
  430. if( ii == libNicknames.size() )
  431. return;
  432. }
  433. // If we are here, the library list has changed, rebuild it
  434. ReCreateLibraryList();
  435. UpdateTitle();
  436. }
  437. bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent )
  438. {
  439. if( aFootprint && !aFootprint->IsEmpty() )
  440. {
  441. wxString msg;
  442. LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
  443. LIB_ID fpid;
  444. fpid.Parse( *aFootprint, LIB_ID::ID_PCB, true );
  445. if( fpid.IsValid() )
  446. {
  447. wxString nickname = fpid.GetLibNickname();
  448. if( !fpTable->HasLibrary( fpid.GetLibNickname(), false ) )
  449. {
  450. msg.sprintf( _( "The current configuration does not include a library with the\n"
  451. "nickname \"%s\". Use Manage Footprint Libraries\n"
  452. "to edit the configuration." ), nickname );
  453. DisplayErrorMessage( aParent, _( "Footprint library not found." ), msg );
  454. }
  455. else if ( !fpTable->HasLibrary( fpid.GetLibNickname(), true ) )
  456. {
  457. msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
  458. "in the current configuration. Use Manage Footprint Libraries to\n"
  459. "edit the configuration." ), nickname );
  460. DisplayErrorMessage( aParent, _( "Footprint library not enabled." ), msg );
  461. }
  462. else
  463. {
  464. setCurNickname( nickname );
  465. setCurFootprintName( fpid.GetLibItemName() );
  466. ReCreateFootprintList();
  467. }
  468. SelectAndViewFootprint( NEW_PART );
  469. }
  470. }
  471. return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
  472. }
  473. bool FOOTPRINT_VIEWER_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
  474. {
  475. bool eventHandled = true;
  476. // Filter out the 'fake' mouse motion after a keyboard movement
  477. if( !aHotKey && m_movingCursorWithKeyboard )
  478. {
  479. m_movingCursorWithKeyboard = false;
  480. return false;
  481. }
  482. wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
  483. cmd.SetEventObject( this );
  484. wxPoint oldpos = GetCrossHairPosition();
  485. wxPoint pos = aPosition;
  486. GeneralControlKeyMovement( aHotKey, &pos, true );
  487. if( aHotKey )
  488. {
  489. eventHandled = OnHotKey( aDC, aHotKey, aPosition );
  490. }
  491. SetCrossHairPosition( pos );
  492. RefreshCrossHair( oldpos, aPosition, aDC );
  493. UpdateStatusBar(); // Display new cursor coordinates
  494. return eventHandled;
  495. }
  496. void FOOTPRINT_VIEWER_FRAME::Show3D_Frame( wxCommandEvent& event )
  497. {
  498. EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
  499. // We can probably remove this for 6.0, but just to be safe we'll stick to
  500. // one 3DFrame at a time for 5.0
  501. if( draw3DFrame )
  502. draw3DFrame->Close( true );
  503. draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
  504. Update3D_Frame( false );
  505. #ifdef __WXMAC__
  506. // A stronger version of Raise() which promotes the window to its parent's level.
  507. draw3DFrame->ReparentQuasiModal();
  508. #else
  509. draw3DFrame->Raise(); // Needed with some Window Managers
  510. #endif
  511. draw3DFrame->Show( true );
  512. }
  513. void FOOTPRINT_VIEWER_FRAME::Update3D_Frame( bool aForceReloadFootprint )
  514. {
  515. wxString title = wxString::Format( _( "3D Viewer" ) + wxT( " \u2014 %s" ),
  516. getCurFootprintName() );
  517. Update3DView( &title );
  518. }
  519. COLOR4D FOOTPRINT_VIEWER_FRAME::GetGridColor()
  520. {
  521. return Settings().Colors().GetItemColor( LAYER_GRID );
  522. }
  523. void FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList( wxCommandEvent& event )
  524. {
  525. switch( event.GetId() )
  526. {
  527. case ID_MODVIEW_NEXT:
  528. SelectAndViewFootprint( NEXT_PART );
  529. break;
  530. case ID_MODVIEW_PREVIOUS:
  531. SelectAndViewFootprint( PREVIOUS_PART );
  532. break;
  533. default:
  534. wxString id = wxString::Format( "%i", event.GetId() );
  535. wxFAIL_MSG( "FOOTPRINT_VIEWER_FRAME::OnIterateFootprintList error: id = " + id );
  536. }
  537. }
  538. void FOOTPRINT_VIEWER_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
  539. {
  540. }
  541. bool FOOTPRINT_VIEWER_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
  542. {
  543. return true;
  544. }
  545. void FOOTPRINT_VIEWER_FRAME::UpdateTitle()
  546. {
  547. wxString title;
  548. wxString path;
  549. title.Printf( _( "Footprint Library Browser" ) + L" \u2014 %s",
  550. getCurNickname().size()
  551. ? getCurNickname()
  552. : _( "no library selected" ) );
  553. // Now, add the full path, for info
  554. if( getCurNickname().size() )
  555. {
  556. FP_LIB_TABLE* libtable = Prj().PcbFootprintLibs();
  557. const LIB_TABLE_ROW* row = libtable->FindRow( getCurNickname() );
  558. if( row )
  559. title << L" \u2014 " << row->GetFullURI( true );
  560. }
  561. SetTitle( title );
  562. }
  563. void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
  564. {
  565. LIB_ID current( getCurNickname(), getCurFootprintName() );
  566. MODULE* module = SelectFootprintFromLibTree( current, false );
  567. if( module )
  568. {
  569. const LIB_ID& fpid = module->GetFPID();
  570. setCurNickname( fpid.GetLibNickname() );
  571. setCurFootprintName( fpid.GetLibItemName() );
  572. int index = m_libList->FindString( fpid.GetLibNickname() );
  573. if( index != wxNOT_FOUND )
  574. {
  575. m_libList->SetSelection( index, true );
  576. m_libList->EnsureVisible( index );
  577. }
  578. ReCreateFootprintList();
  579. SelectAndViewFootprint( NEW_PART );
  580. }
  581. }
  582. void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
  583. {
  584. if( !getCurNickname() )
  585. return;
  586. int selection = m_footprintList->FindString( getCurFootprintName() );
  587. if( aMode == NEXT_PART )
  588. {
  589. if( selection != wxNOT_FOUND && selection < (int)m_footprintList->GetCount()-1 )
  590. selection++;
  591. }
  592. if( aMode == PREVIOUS_PART )
  593. {
  594. if( selection != wxNOT_FOUND && selection > 0 )
  595. selection--;
  596. }
  597. if( selection != wxNOT_FOUND )
  598. {
  599. m_footprintList->SetSelection( selection );
  600. m_footprintList->EnsureVisible( selection );
  601. setCurFootprintName( m_footprintList->GetString( (unsigned) selection ) );
  602. SetCurItem( NULL );
  603. // Delete the current footprint
  604. GetBoard()->m_Modules.DeleteAll();
  605. MODULE* footprint = Prj().PcbFootprintLibs()->FootprintLoad( getCurNickname(),
  606. getCurFootprintName() );
  607. if( footprint )
  608. GetBoard()->Add( footprint, ADD_APPEND );
  609. Update3D_Frame();
  610. updateView();
  611. }
  612. UpdateTitle();
  613. m_canvas->Refresh();
  614. }
  615. void FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
  616. {
  617. if( !GetBoard() )
  618. return;
  619. m_canvas->DrawBackGround( DC );
  620. GetBoard()->Draw( m_canvas, DC, GR_COPY );
  621. m_canvas->DrawCrossHair( DC );
  622. UpdateMsgPanel();
  623. }
  624. void FOOTPRINT_VIEWER_FRAME::UpdateMsgPanel()
  625. {
  626. BOARD_ITEM* footprint = GetBoard()->m_Modules;
  627. if( footprint )
  628. {
  629. MSG_PANEL_ITEMS items;
  630. footprint->GetMsgPanelInfo( m_UserUnits, items );
  631. SetMsgPanel( items );
  632. }
  633. else
  634. ClearMsgPanel();
  635. }
  636. void FOOTPRINT_VIEWER_FRAME::ApplyDisplaySettingsToGAL()
  637. {
  638. auto painter = static_cast<KIGFX::PCB_PAINTER*>( GetGalCanvas()->GetView()->GetPainter() );
  639. KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings();
  640. settings->LoadDisplayOptions( &m_DisplayOptions, false );
  641. GetGalCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
  642. GetGalCanvas()->Refresh();
  643. }
  644. void FOOTPRINT_VIEWER_FRAME::updateView()
  645. {
  646. auto dp = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
  647. dp->UseColorScheme( &Settings().Colors() );
  648. dp->DisplayBoard( GetBoard() );
  649. m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
  650. if( m_autoZoom )
  651. m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
  652. else
  653. m_toolManager->RunAction( ACTIONS::centerContents, true );
  654. UpdateMsgPanel();
  655. }
  656. void FOOTPRINT_VIEWER_FRAME::CloseFootprintViewer( wxCommandEvent& event )
  657. {
  658. Close();
  659. }