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.

837 lines
24 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
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
* 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) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 2004-2019 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. #include <fctsys.h>
  26. #include <kiface_i.h>
  27. #include <pgm_base.h>
  28. #include <sch_draw_panel.h>
  29. #include <sch_view.h>
  30. #include <msgpanel.h>
  31. #include <bitmaps.h>
  32. #include <eda_dockart.h>
  33. #include <sch_edit_frame.h>
  34. #include <eeschema_id.h>
  35. #include <general.h>
  36. #include <viewlib_frame.h>
  37. #include <symbol_lib_table.h>
  38. #include <sch_legacy_plugin.h>
  39. #include <hotkeys.h>
  40. #include <dialog_helpers.h>
  41. #include <class_libentry.h>
  42. #include <class_library.h>
  43. #include <view/view_controls.h>
  44. #include <sch_painter.h>
  45. #include <confirm.h>
  46. #include <tool/tool_manager.h>
  47. #include <tools/sch_actions.h>
  48. // Save previous component library viewer state.
  49. wxString LIB_VIEW_FRAME::m_libraryName;
  50. wxString LIB_VIEW_FRAME::m_entryName;
  51. int LIB_VIEW_FRAME::m_unit = 1;
  52. int LIB_VIEW_FRAME::m_convert = 1;
  53. BEGIN_EVENT_TABLE( LIB_VIEW_FRAME, EDA_DRAW_FRAME )
  54. // Window events
  55. EVT_CLOSE( LIB_VIEW_FRAME::OnCloseWindow )
  56. EVT_SIZE( LIB_VIEW_FRAME::OnSize )
  57. EVT_ACTIVATE( LIB_VIEW_FRAME::OnActivate )
  58. // Toolbar events
  59. EVT_TOOL( ID_LIBVIEW_SELECT_PART, LIB_VIEW_FRAME::OnSelectSymbol )
  60. EVT_TOOL( ID_LIBVIEW_NEXT, LIB_VIEW_FRAME::onSelectNextSymbol )
  61. EVT_TOOL( ID_LIBVIEW_PREVIOUS, LIB_VIEW_FRAME::onSelectPreviousSymbol )
  62. EVT_TOOL( ID_LIBVIEW_VIEWDOC, LIB_VIEW_FRAME::onViewSymbolDocument )
  63. EVT_TOOL_RANGE( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT,
  64. LIB_VIEW_FRAME::onSelectSymbolBodyStyle )
  65. EVT_CHOICE( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onSelectSymbolUnit )
  66. EVT_TOOL( ID_ADD_PART_TO_SCHEMATIC, LIB_VIEW_FRAME::OnAddPartToSchematic )
  67. // listbox events
  68. EVT_LISTBOX( ID_LIBVIEW_LIB_LIST, LIB_VIEW_FRAME::ClickOnLibList )
  69. EVT_LISTBOX( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::ClickOnCmpList )
  70. EVT_LISTBOX_DCLICK( ID_LIBVIEW_CMP_LIST, LIB_VIEW_FRAME::DClickOnCmpList )
  71. // Menu (and/or hotkey) events
  72. EVT_MENU( wxID_HELP, EDA_DRAW_FRAME::GetKicadHelp )
  73. EVT_MENU( wxID_EXIT, LIB_VIEW_FRAME::CloseLibraryViewer )
  74. EVT_MENU( ID_HELP_GET_INVOLVED, EDA_DRAW_FRAME::GetKicadContribute )
  75. EVT_MENU( ID_SET_RELATIVE_OFFSET, LIB_VIEW_FRAME::OnSetRelativeOffset )
  76. EVT_MENU( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnShowElectricalType )
  77. EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton )
  78. EVT_UPDATE_UI( ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, LIB_VIEW_FRAME::onUpdateAltBodyStyleButton )
  79. EVT_UPDATE_UI( ID_LIBVIEW_SHOW_ELECTRICAL_TYPE, LIB_VIEW_FRAME::OnUpdateElectricalType )
  80. EVT_UPDATE_UI( ID_LIBVIEW_SELECT_PART_NUMBER, LIB_VIEW_FRAME::onUpdateUnitChoice )
  81. EVT_UPDATE_UI( ID_LIBEDIT_VIEW_DOC, LIB_VIEW_FRAME::onUpdateDocButton )
  82. END_EVENT_TABLE()
  83. #define LIB_VIEW_NAME "ViewlibFrame"
  84. #define LIB_VIEW_NAME_MODAL "ViewlibFrameModal"
  85. #define LIB_VIEW_STYLE ( KICAD_DEFAULT_DRAWFRAME_STYLE )
  86. #define LIB_VIEW_STYLE_MODAL ( KICAD_DEFAULT_DRAWFRAME_STYLE | wxFRAME_FLOAT_ON_PARENT )
  87. LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
  88. const wxString& aLibraryName ) :
  89. SCH_BASE_FRAME( aKiway, aParent, aFrameType, _( "Symbol Library Browser" ),
  90. wxDefaultPosition, wxDefaultSize,
  91. aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_STYLE_MODAL : LIB_VIEW_STYLE,
  92. aFrameType == FRAME_SCH_VIEWER_MODAL ? LIB_VIEW_NAME_MODAL : LIB_VIEW_NAME ),
  93. m_libList( nullptr ),
  94. m_cmpList( nullptr ),
  95. m_previewItem( nullptr )
  96. {
  97. wxASSERT( aFrameType == FRAME_SCH_VIEWER || aFrameType == FRAME_SCH_VIEWER_MODAL );
  98. if( aFrameType == FRAME_SCH_VIEWER_MODAL )
  99. SetModal( true );
  100. // Force the frame name used in config. the lib viewer frame has a name
  101. // depending on aFrameType (needed to identify the frame by wxWidgets),
  102. // but only one configuration is preferable.
  103. m_configFrameName = LIB_VIEW_NAME;
  104. // Give an icon
  105. wxIcon icon;
  106. icon.CopyFromBitmap( KiBitmap( library_browse_xpm ) );
  107. SetIcon( icon );
  108. m_hotkeysDescrList = g_Viewlib_Hotkeys_Descr;
  109. m_libListWidth = 200;
  110. m_cmpListWidth = 300;
  111. m_listPowerCmpOnly = false;
  112. SetShowElectricalType( true );
  113. // Initialize grid id to the default value (50 mils):
  114. m_LastGridSizeId = ID_POPUP_GRID_LEVEL_50 - ID_POPUP_GRID_LEVEL_1000;
  115. SetScreen( new SCH_SCREEN( aKiway ) );
  116. GetScreen()->m_Center = true; // Axis origin centered on screen.
  117. LoadSettings( config() );
  118. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  119. // Menu bar is not mandatory: uncomment/comment the next line
  120. // to add/remove the menubar
  121. ReCreateMenuBar();
  122. ReCreateHToolbar();
  123. ReCreateVToolbar();
  124. m_libList = new wxListBox( this, ID_LIBVIEW_LIB_LIST, wxDefaultPosition, wxDefaultSize,
  125. 0, NULL, wxLB_HSCROLL | wxNO_BORDER );
  126. m_cmpList = new wxListBox( this, ID_LIBVIEW_CMP_LIST, wxDefaultPosition, wxDefaultSize,
  127. 0, NULL, wxLB_HSCROLL | wxNO_BORDER );
  128. if( aLibraryName.empty() )
  129. {
  130. ReCreateListLib();
  131. }
  132. else
  133. {
  134. m_libraryName = aLibraryName;
  135. m_entryName.Clear();
  136. m_unit = 1;
  137. m_convert = 1;
  138. }
  139. m_selection_changed = false;
  140. DisplayLibInfos();
  141. m_auimgr.SetManagedWindow( this );
  142. m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
  143. // Manage main toolbar
  144. m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
  145. m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
  146. m_auimgr.AddPane( m_libList, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(3)
  147. .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_libListWidth, -1 ) );
  148. m_auimgr.AddPane( m_cmpList, EDA_PANE().Palette().Name( "Symbols" ).Left().Layer(1)
  149. .CaptionVisible( false ).MinSize( 80, -1 ).BestSize( m_cmpListWidth, -1 ) );
  150. m_auimgr.AddPane( m_canvas->GetWindow(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
  151. m_auimgr.GetPane( m_libList ).Show( aLibraryName.empty() );
  152. m_auimgr.Update();
  153. setupTools();
  154. GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
  155. GetToolManager()->RunAction( "common.Control.zoomFitScreen", true );
  156. if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
  157. {
  158. Raise();
  159. Show( true );
  160. }
  161. SyncView();
  162. GetGalCanvas()->GetViewControls()->SetSnapping( true );
  163. GetGalCanvas()->GetGAL()->SetAxesEnabled( true );
  164. GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
  165. // Set the working/draw area size to display a symbol to a reasonable value:
  166. // A 450mm x 450mm with a origin at the area center looks like a large working area
  167. double max_size_x = Millimeter2iu( 450 );
  168. double max_size_y = Millimeter2iu( 450 );
  169. BOX2D bbox;
  170. bbox.SetOrigin( -max_size_x /2, -max_size_y/2 );
  171. bbox.SetSize( max_size_x, max_size_y );
  172. GetCanvas()->GetView()->SetBoundary( bbox );
  173. }
  174. LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
  175. {
  176. if( m_previewItem )
  177. GetCanvas()->GetView()->Remove( m_previewItem );
  178. }
  179. void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
  180. {
  181. m_unit = aUnit > 0 ? aUnit : 1;
  182. m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
  183. m_selection_changed = false;
  184. // Update canvas
  185. GetRenderSettings()->m_ShowUnit = m_unit;
  186. GetRenderSettings()->m_ShowConvert = m_convert;
  187. GetCanvas()->GetView()->MarkDirty();
  188. GetCanvas()->Refresh();
  189. }
  190. LIB_ALIAS* LIB_VIEW_FRAME::getSelectedAlias() const
  191. {
  192. LIB_ALIAS* alias = NULL;
  193. if( !m_libraryName.IsEmpty() && !m_entryName.IsEmpty() )
  194. alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
  195. return alias;
  196. }
  197. LIB_PART* LIB_VIEW_FRAME::getSelectedSymbol() const
  198. {
  199. LIB_PART* symbol = NULL;
  200. LIB_ALIAS* alias = getSelectedAlias();
  201. if( alias )
  202. symbol = alias->GetPart();
  203. return symbol;
  204. }
  205. void LIB_VIEW_FRAME::updatePreviewSymbol()
  206. {
  207. LIB_ALIAS* alias = getSelectedAlias();
  208. KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
  209. if( m_previewItem )
  210. {
  211. view->Remove( m_previewItem );
  212. m_previewItem = nullptr;
  213. }
  214. ClearMsgPanel();
  215. if( alias )
  216. {
  217. GetRenderSettings()->m_ShowUnit = m_unit;
  218. GetRenderSettings()->m_ShowConvert = m_convert;
  219. view->Add( alias );
  220. m_previewItem = alias;
  221. AppendMsgPanel( _( "Name" ), alias->GetName(), BLUE, 6 );
  222. AppendMsgPanel( _( "Description" ), alias->GetDescription(), CYAN, 6 );
  223. AppendMsgPanel( _( "Key words" ), alias->GetKeyWords(), DARKDARKGRAY );
  224. }
  225. GetCanvas()->ForceRefresh();
  226. }
  227. void LIB_VIEW_FRAME::onUpdateAltBodyStyleButton( wxUpdateUIEvent& aEvent )
  228. {
  229. LIB_PART* symbol = getSelectedSymbol();
  230. aEvent.Enable( symbol && symbol->HasConversion() );
  231. if( symbol )
  232. aEvent.Check( m_convert > 1 );
  233. else
  234. aEvent.Check( false );
  235. }
  236. void LIB_VIEW_FRAME::onUpdateNormalBodyStyleButton( wxUpdateUIEvent& aEvent )
  237. {
  238. LIB_PART* symbol = getSelectedSymbol();
  239. aEvent.Enable( symbol && symbol->HasConversion() );
  240. if( symbol )
  241. aEvent.Check( m_convert <= 1 );
  242. else
  243. aEvent.Check( true );
  244. }
  245. bool LIB_VIEW_FRAME::ShowModal( wxString* aSymbol, wxWindow* aParent )
  246. {
  247. if( aSymbol && !aSymbol->IsEmpty() )
  248. {
  249. wxString msg;
  250. LIB_TABLE* libTable = Prj().SchSymbolLibTable();
  251. LIB_ID libid;
  252. libid.Parse( *aSymbol, LIB_ID::ID_SCH, true );
  253. if( libid.IsValid() )
  254. {
  255. wxString nickname = libid.GetLibNickname();
  256. if( !libTable->HasLibrary( libid.GetLibNickname(), false ) )
  257. {
  258. msg.sprintf( _( "The current configuration does not include a library with the\n"
  259. "nickname \"%s\". Use Manage Symbol Libraries\n"
  260. "to edit the configuration." ), nickname );
  261. DisplayErrorMessage( aParent, _( "Symbol library not found." ), msg );
  262. }
  263. else if ( !libTable->HasLibrary( libid.GetLibNickname(), true ) )
  264. {
  265. msg.sprintf( _( "The library with the nickname \"%s\" is not enabled\n"
  266. "in the current configuration. Use Manage Symbol Libraries to\n"
  267. "edit the configuration." ), nickname );
  268. DisplayErrorMessage( aParent, _( "Symbol library not enabled." ), msg );
  269. }
  270. else
  271. {
  272. SetSelectedLibrary( libid.GetLibNickname() );
  273. SetSelectedComponent( libid.GetLibItemName() );
  274. }
  275. }
  276. }
  277. return KIWAY_PLAYER::ShowModal( aSymbol, aParent );
  278. }
  279. void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event )
  280. {
  281. GetCanvas()->StopDrawing();
  282. if( !IsModal() )
  283. {
  284. Destroy();
  285. }
  286. else if( !IsDismissed() )
  287. {
  288. // only dismiss modal frame if not already dismissed.
  289. DismissModal( false );
  290. // Modal frame will be destroyed by the calling function.
  291. }
  292. }
  293. void LIB_VIEW_FRAME::OnSize( wxSizeEvent& SizeEv )
  294. {
  295. if( m_auimgr.GetManagedWindow() )
  296. m_auimgr.Update();
  297. SizeEv.Skip();
  298. }
  299. void LIB_VIEW_FRAME::OnSetRelativeOffset( wxCommandEvent& event )
  300. {
  301. GetScreen()->m_O_Curseur = GetCrossHairPosition();
  302. UpdateStatusBar();
  303. }
  304. void LIB_VIEW_FRAME::OnShowElectricalType( wxCommandEvent& event )
  305. {
  306. m_showPinElectricalTypeName = !m_showPinElectricalTypeName;
  307. // Update canvas
  308. GetRenderSettings()->m_ShowPinsElectricalType = m_showPinElectricalTypeName;
  309. GetCanvas()->GetView()->MarkDirty();
  310. GetCanvas()->Refresh();
  311. }
  312. void LIB_VIEW_FRAME::OnUpdateElectricalType( wxUpdateUIEvent& aEvent )
  313. {
  314. aEvent.Check( GetShowElectricalType() );
  315. }
  316. void LIB_VIEW_FRAME::onUpdateUnitChoice( wxUpdateUIEvent& aEvent )
  317. {
  318. LIB_PART* part = getSelectedSymbol();
  319. int unit_count = 1;
  320. if( part )
  321. unit_count = std::max( part->GetUnitCount(), 1 );
  322. m_unitChoice->Enable( unit_count > 1 );
  323. if( unit_count > 1 )
  324. {
  325. // rebuild the unit list if it is not suitable (after a new selection for instance)
  326. if( unit_count != (int)m_unitChoice->GetCount() )
  327. {
  328. m_unitChoice->Clear();
  329. for( int ii = 0; ii < unit_count; ii++ )
  330. m_unitChoice->Append( wxString::Format( _( "Unit %c" ), 'A' + ii ) );
  331. }
  332. if( m_unitChoice->GetSelection() != std::max( 0, m_unit - 1 ) )
  333. m_unitChoice->SetSelection( std::max( 0, m_unit - 1 ) );
  334. }
  335. else if( m_unitChoice->GetCount() )
  336. m_unitChoice->Clear();
  337. }
  338. double LIB_VIEW_FRAME::BestZoom()
  339. {
  340. LIB_PART* part = NULL;
  341. double defaultLibraryZoom = 7.33;
  342. if( m_libraryName.IsEmpty() || m_entryName.IsEmpty() )
  343. {
  344. SetScrollCenterPosition( wxPoint( 0, 0 ) );
  345. return defaultLibraryZoom;
  346. }
  347. LIB_ALIAS* alias = nullptr;
  348. try
  349. {
  350. alias = Prj().SchSymbolLibTable()->LoadSymbol( m_libraryName, m_entryName );
  351. }
  352. catch( ... )
  353. {
  354. }
  355. if( alias )
  356. part = alias->GetPart();
  357. if( !part )
  358. {
  359. SetScrollCenterPosition( wxPoint( 0, 0 ) );
  360. return defaultLibraryZoom;
  361. }
  362. EDA_RECT boundingBox = part->GetUnitBoundingBox( m_unit, m_convert );
  363. double sizeX = (double) boundingBox.GetWidth();
  364. double sizeY = (double) boundingBox.GetHeight();
  365. wxPoint centre = boundingBox.Centre();
  366. // Reserve a 20% margin around component bounding box.
  367. double margin_scale_factor = 1.2;
  368. return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
  369. }
  370. bool LIB_VIEW_FRAME::ReCreateListLib()
  371. {
  372. if( !m_libList )
  373. return false;
  374. m_libList->Clear();
  375. std::vector< wxString > libs = Prj().SchSymbolLibTable()->GetLogicalLibs();
  376. // Remove not allowed libs from main list, if the allowed lib list is not empty
  377. if( m_allowedLibs.GetCount() )
  378. {
  379. for( unsigned ii = 0; ii < libs.size(); )
  380. {
  381. if( m_allowedLibs.Index( libs[ii] ) == wxNOT_FOUND )
  382. libs.erase( libs.begin() + ii );
  383. else
  384. ii++;
  385. }
  386. }
  387. // Remove libs which have no power components, if this filter is activated
  388. if( m_listPowerCmpOnly )
  389. {
  390. for( unsigned ii = 0; ii < libs.size(); )
  391. {
  392. wxArrayString aliasNames;
  393. Prj().SchSymbolLibTable()->EnumerateSymbolLib( libs[ii], aliasNames, true );
  394. if( aliasNames.IsEmpty() )
  395. libs.erase( libs.begin() + ii );
  396. else
  397. ii++;
  398. }
  399. }
  400. if( libs.empty() )
  401. return true;
  402. wxArrayString libNames;
  403. for( const auto& name : libs )
  404. libNames.Add( name );
  405. m_libList->Append( libNames );
  406. // Search for a previous selection:
  407. int index = m_libList->FindString( m_libraryName );
  408. if( index != wxNOT_FOUND )
  409. {
  410. m_libList->SetSelection( index, true );
  411. }
  412. else
  413. {
  414. // If not found, clear current library selection because it can be
  415. // deleted after a config change.
  416. m_libraryName = libs[0];
  417. m_entryName = wxEmptyString;
  418. m_unit = 1;
  419. m_convert = LIB_ITEM::LIB_CONVERT::BASE;
  420. }
  421. bool cmp_changed = ReCreateListCmp();
  422. DisplayLibInfos();
  423. m_canvas->Refresh();
  424. return cmp_changed;
  425. }
  426. bool LIB_VIEW_FRAME::ReCreateListCmp()
  427. {
  428. if( m_cmpList == NULL )
  429. return false;
  430. wxArrayString aliasNames;
  431. try
  432. {
  433. Prj().SchSymbolLibTable()->EnumerateSymbolLib( m_libraryName, aliasNames,
  434. m_listPowerCmpOnly );
  435. }
  436. catch( const IO_ERROR& ) {} // ignore, it is handled below
  437. m_cmpList->Clear();
  438. if( aliasNames.IsEmpty() )
  439. {
  440. m_libraryName = wxEmptyString;
  441. m_entryName = wxEmptyString;
  442. m_convert = LIB_ITEM::LIB_CONVERT::BASE;
  443. m_unit = 1;
  444. return true;
  445. }
  446. m_cmpList->Append( aliasNames );
  447. int index = m_cmpList->FindString( m_entryName );
  448. bool changed = false;
  449. if( index == wxNOT_FOUND )
  450. {
  451. // Select the first library entry when the previous entry name does not exist in
  452. // the current library.
  453. m_convert = LIB_ITEM::LIB_CONVERT::BASE;
  454. m_unit = 1;
  455. index = 0;
  456. changed = true;
  457. m_entryName = wxEmptyString;
  458. }
  459. m_cmpList->SetSelection( index, true );
  460. wxCommandEvent evt( wxEVT_COMMAND_LISTBOX_SELECTED, ID_LIBVIEW_CMP_LIST );
  461. ProcessEvent( evt );
  462. return changed;
  463. }
  464. void LIB_VIEW_FRAME::ClickOnLibList( wxCommandEvent& event )
  465. {
  466. int ii = m_libList->GetSelection();
  467. if( ii < 0 )
  468. return;
  469. m_selection_changed = true;
  470. SetSelectedLibrary( m_libList->GetString( ii ) );
  471. }
  472. void LIB_VIEW_FRAME::SetSelectedLibrary( const wxString& aLibraryName )
  473. {
  474. if( m_libraryName == aLibraryName )
  475. return;
  476. m_libraryName = aLibraryName;
  477. ReCreateListCmp();
  478. m_canvas->Refresh();
  479. DisplayLibInfos();
  480. // Ensure the corresponding line in m_libList is selected
  481. // (which is not necessary the case if SetSelectedLibrary is called
  482. // by another caller than ClickOnLibList.
  483. m_libList->SetStringSelection( m_libraryName, true );
  484. }
  485. void LIB_VIEW_FRAME::ClickOnCmpList( wxCommandEvent& event )
  486. {
  487. int ii = m_cmpList->GetSelection();
  488. if( ii < 0 )
  489. return;
  490. m_selection_changed = true;
  491. SetSelectedComponent( m_cmpList->GetString( ii ) );
  492. }
  493. void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
  494. {
  495. if( m_entryName != aComponentName )
  496. {
  497. m_entryName = aComponentName;
  498. // Ensure the corresponding line in m_cmpList is selected
  499. // (which is not necessarily the case if SetSelectedComponent is called
  500. // by another caller than ClickOnCmpList.
  501. m_cmpList->SetStringSelection( aComponentName, true );
  502. DisplayLibInfos();
  503. if( m_selection_changed )
  504. {
  505. m_unit = 1;
  506. m_convert = LIB_ITEM::LIB_CONVERT::BASE;
  507. m_selection_changed = false;
  508. }
  509. updatePreviewSymbol();
  510. Zoom_Automatique( false );
  511. }
  512. }
  513. void LIB_VIEW_FRAME::DClickOnCmpList( wxCommandEvent& event )
  514. {
  515. OnAddPartToSchematic( event );
  516. // The schematic editor might not be the parent of the library viewer.
  517. // It could be a python window.
  518. SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( GetParent() );
  519. if( schframe )
  520. {
  521. // Prevent the double click from being as a single click in the parent
  522. // window which would cause the part to be parked rather than staying
  523. // in drag mode.
  524. schframe->SkipNextLeftButtonReleaseEvent();
  525. }
  526. }
  527. #define LIBLIST_WIDTH_KEY "ViewLiblistWidth"
  528. #define CMPLIST_WIDTH_KEY "ViewCmplistWidth"
  529. #define CMPVIEW_SHOW_PINELECTRICALTYPE_KEY "ViewCmpShowPinElectricalType"
  530. void LIB_VIEW_FRAME::LoadSettings( wxConfigBase* aCfg )
  531. {
  532. EDA_DRAW_FRAME::LoadSettings( aCfg );
  533. // Fetch grid settings from Symbol Editor
  534. wxString symbolEditor = LIB_EDIT_FRAME_NAME;
  535. bool btmp;
  536. COLOR4D wtmp;
  537. if( aCfg->Read( symbolEditor + ShowGridEntryKeyword, &btmp ) )
  538. SetGridVisibility( btmp );
  539. if( wtmp.SetFromWxString( aCfg->Read( symbolEditor + GridColorEntryKeyword, wxT( "NONE" ) ) ) )
  540. SetGridColor( wtmp );
  541. // Grid shape, etc.
  542. GetGalDisplayOptions().ReadAppConfig( *aCfg, symbolEditor );
  543. aCfg->Read( LIBLIST_WIDTH_KEY, &m_libListWidth, 150 );
  544. aCfg->Read( CMPLIST_WIDTH_KEY, &m_cmpListWidth, 150 );
  545. m_showPinElectricalTypeName = aCfg->Read( CMPVIEW_SHOW_PINELECTRICALTYPE_KEY, true );
  546. // Set parameters to a reasonable value.
  547. if( m_libListWidth > m_FrameSize.x/2 )
  548. m_libListWidth = m_FrameSize.x/2;
  549. if( m_cmpListWidth > m_FrameSize.x/2 )
  550. m_cmpListWidth = m_FrameSize.x/2;
  551. }
  552. void LIB_VIEW_FRAME::SaveSettings( wxConfigBase* aCfg )
  553. {
  554. EDA_DRAW_FRAME::SaveSettings( aCfg );
  555. if( m_libListWidth && m_libList )
  556. {
  557. m_libListWidth = m_libList->GetSize().x;
  558. aCfg->Write( LIBLIST_WIDTH_KEY, m_libListWidth );
  559. }
  560. m_cmpListWidth = m_cmpList->GetSize().x;
  561. aCfg->Write( CMPLIST_WIDTH_KEY, m_cmpListWidth );
  562. aCfg->Write( CMPVIEW_SHOW_PINELECTRICALTYPE_KEY, m_showPinElectricalTypeName );
  563. }
  564. void LIB_VIEW_FRAME::OnActivate( wxActivateEvent& event )
  565. {
  566. EDA_DRAW_FRAME::OnActivate( event );
  567. bool changed = m_libList ? ReCreateListLib() : false;
  568. if (changed)
  569. m_selection_changed = true;
  570. updatePreviewSymbol();
  571. DisplayLibInfos();
  572. }
  573. void LIB_VIEW_FRAME::CloseLibraryViewer( wxCommandEvent& event )
  574. {
  575. Close();
  576. }
  577. void LIB_VIEW_FRAME::SetFilter( const SCHLIB_FILTER* aFilter )
  578. {
  579. m_listPowerCmpOnly = false;
  580. m_allowedLibs.Clear();
  581. if( aFilter )
  582. {
  583. m_allowedLibs = aFilter->GetAllowedLibList();
  584. m_listPowerCmpOnly = aFilter->GetFilterPowerParts();
  585. }
  586. ReCreateListLib();
  587. }
  588. const BOX2I LIB_VIEW_FRAME::GetDocumentExtents() const
  589. {
  590. LIB_ALIAS* alias = getSelectedAlias();
  591. LIB_PART* part = alias ? alias->GetPart() : nullptr;
  592. if( !part )
  593. {
  594. return BOX2I( VECTOR2I(-200, -200), VECTOR2I( 400, 400 ) );
  595. }
  596. else
  597. {
  598. EDA_RECT bbox = part->GetUnitBoundingBox( m_unit, m_convert );
  599. return BOX2I( bbox.GetOrigin(), VECTOR2I( bbox.GetWidth(), bbox.GetHeight() ) );
  600. }
  601. }
  602. void LIB_VIEW_FRAME::OnAddPartToSchematic( wxCommandEvent& aEvent )
  603. {
  604. if( IsModal() )
  605. {
  606. // if we're modal then we just need to return the symbol selection; the caller is
  607. // already in a SCH_ACTIONS::placeSymbol coroutine.
  608. if( m_cmpList->GetSelection() >= 0 )
  609. DismissModal( true, m_libraryName + ':' + m_cmpList->GetStringSelection() );
  610. else
  611. DismissModal( false );
  612. Close( true );
  613. return;
  614. }
  615. if( getSelectedSymbol() )
  616. {
  617. SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway().Player( FRAME_SCH, false );
  618. if( schframe == NULL ) // happens when the schematic editor is not active (or closed)
  619. {
  620. DisplayErrorMessage( this, _("No schematic currently open." ) );
  621. return;
  622. }
  623. SCH_COMPONENT* component = new SCH_COMPONENT( *getSelectedSymbol(),
  624. getSelectedAlias()->GetLibId(),
  625. g_CurrentSheet, m_unit, m_convert,
  626. wxPoint( 0, 0 ), true );
  627. // Be sure the link to the corresponding LIB_PART is OK:
  628. component->Resolve( *Prj().SchSymbolLibTable() );
  629. MSG_PANEL_ITEMS items;
  630. component->GetMsgPanelInfo( schframe->GetUserUnits(), items );
  631. schframe->SetMsgPanel( items );
  632. if( schframe->GetAutoplaceFields() )
  633. component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
  634. schframe->Raise();
  635. schframe->GetToolManager()->RunAction( SCH_ACTIONS::placeSymbol, true, component );
  636. }
  637. }