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.

1076 lines
31 KiB

8 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
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
18 years ago
18 years ago
18 years ago
18 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
* 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
16 years ago
17 years ago
16 years ago
15 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
  5. * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file footprint_editor_utils.cpp
  26. */
  27. #include <fctsys.h>
  28. #include <kiface_i.h>
  29. #include <kiway.h>
  30. #include <kiway_express.h>
  31. #include <class_drawpanel.h>
  32. #include <pcb_draw_panel_gal.h>
  33. #include <confirm.h>
  34. #include <gestfich.h>
  35. #include <pgm_base.h>
  36. #include <trigo.h>
  37. #include <3d_viewer/eda_3d_viewer.h>
  38. #include <kicad_device_context.h>
  39. #include <macros.h>
  40. #include <invoke_pcb_dialog.h>
  41. #include <pcb_layer_widget.h>
  42. #include <board_commit.h>
  43. #include <view/view.h>
  44. #include <class_board.h>
  45. #include <class_module.h>
  46. #include <class_edge_mod.h>
  47. #include <ratsnest_data.h>
  48. #include <pcbnew.h>
  49. #include <protos.h>
  50. #include <pcbnew_id.h>
  51. #include <footprint_edit_frame.h>
  52. #include <footprint_viewer_frame.h>
  53. #include <footprint_tree_pane.h>
  54. #include <fp_lib_table.h>
  55. #include <widgets/lib_tree.h>
  56. #include <collectors.h>
  57. #include <tool/tool_manager.h>
  58. #include <tools/pcb_actions.h>
  59. #include <dialog_edit_footprint_for_fp_editor.h>
  60. #include <dialog_move_exact.h>
  61. #include <dialog_create_array.h>
  62. #include <wildcards_and_files_ext.h>
  63. #include <menus_helpers.h>
  64. #include <footprint_wizard_frame.h>
  65. #include <config_params.h>
  66. #include <functional>
  67. using namespace std::placeholders;
  68. // Functions defined in block_module_editor, but used here
  69. // These 3 functions are used in modedit to rotate, mirror or move the
  70. // whole footprint so they are called with force_all = true
  71. void MirrorMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
  72. void RotateMarkedItems( MODULE* module, wxPoint offset, bool force_all = false );
  73. void MoveMarkedItemsExactly( MODULE* module, const wxPoint& centre,
  74. const wxPoint& translation, double rotation,
  75. bool force_all = false );
  76. BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode )
  77. {
  78. BOARD_ITEM* item = GetCurItem();
  79. if( GetBoard()->m_Modules == NULL )
  80. return NULL;
  81. GENERAL_COLLECTORS_GUIDE guide = GetCollectorsGuide();
  82. // Assign to scanList the proper item types desired based on tool type
  83. // or hotkey that is in play.
  84. const KICAD_T* scanList = NULL;
  85. if( aHotKeyCode )
  86. {
  87. // @todo: add switch here and add calls to PcbGeneralLocateAndDisplay(
  88. // int aHotKeyCode ) when searching is needed from a hotkey handler
  89. }
  90. else
  91. {
  92. scanList = GENERAL_COLLECTOR::ModulesAndTheirItems;
  93. }
  94. m_Collector->Collect( GetBoard(), scanList, RefPos( true ), guide );
  95. // Remove redundancies: when an item is found, we can remove the module from list
  96. if( m_Collector->GetCount() > 1 )
  97. {
  98. for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
  99. {
  100. item = (*m_Collector)[ii];
  101. if( item->Type() != PCB_MODULE_T )
  102. continue;
  103. m_Collector->Remove( ii );
  104. ii--;
  105. }
  106. }
  107. if( m_Collector->GetCount() <= 1 )
  108. {
  109. item = (*m_Collector)[0];
  110. SetCurItem( item );
  111. }
  112. else // we can't figure out which item user wants, do popup menu so user can choose
  113. {
  114. wxMenu itemMenu;
  115. // Give a title to the selection menu. It also allows one to close the popup menu without any action
  116. AddMenuItem( &itemMenu, wxID_NONE, _( "Clarify Selection" ),
  117. KiBitmap( info_xpm ) );
  118. itemMenu.AppendSeparator();
  119. int limit = std::min( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
  120. for( int ii = 0; ii<limit; ++ii )
  121. {
  122. item = (*m_Collector)[ii];
  123. wxString text = item->GetSelectMenuText( GetUserUnits() );
  124. BITMAP_DEF xpm = item->GetMenuImage();
  125. AddMenuItem( &itemMenu,
  126. ID_POPUP_PCB_ITEM_SELECTION_START + ii,
  127. text,
  128. KiBitmap( xpm ) );
  129. }
  130. // this menu's handler is void
  131. // PCB_BASE_FRAME::ProcessItemSelection()
  132. // and it calls SetCurItem() which in turn calls DisplayInfo() on the
  133. // item.
  134. m_canvas->SetAbortRequest( true ); // changed in false if an item is selected
  135. PopupMenu( &itemMenu ); // m_AbortRequest = false if an item is selected
  136. m_canvas->MoveCursorToCrossHair();
  137. m_canvas->SetIgnoreMouseEvents( false );
  138. // The function ProcessItemSelection() has set the current item, return it.
  139. item = GetCurItem();
  140. }
  141. if( item )
  142. {
  143. SetMsgPanel( item );
  144. }
  145. return item;
  146. }
  147. void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
  148. {
  149. if( ! Load_Module_From_BOARD( NULL ) )
  150. return;
  151. GetScreen()->ClearUndoRedoList();
  152. GetScreen()->ClrModify();
  153. Update3DView();
  154. }
  155. void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
  156. {
  157. int id = event.GetId();
  158. wxPoint pos;
  159. INSTALL_UNBUFFERED_DC( dc, m_canvas );
  160. wxGetMousePosition( &pos.x, &pos.y );
  161. pos.y += 20;
  162. switch( id )
  163. {
  164. case wxID_CUT:
  165. case wxID_COPY:
  166. case ID_TOOLBARH_PCB_SELECT_LAYER:
  167. case ID_MODEDIT_PAD_SETTINGS:
  168. case ID_PCB_USER_GRID_SETUP:
  169. case ID_POPUP_PCB_ROTATE_TEXTEPCB:
  170. case ID_POPUP_PCB_EDIT_TEXTEPCB:
  171. case ID_POPUP_PCB_ROTATE_TEXTMODULE:
  172. case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
  173. case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
  174. case ID_POPUP_PCB_EDIT_TEXTMODULE:
  175. case ID_POPUP_PCB_APPLY_PAD_SETTINGS:
  176. case ID_POPUP_PCB_COPY_PAD_SETTINGS:
  177. case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
  178. case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
  179. case ID_POPUP_MODEDIT_EDIT_BODY_ITEM:
  180. case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
  181. case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
  182. case ID_POPUP_PCB_DELETE_EDGE:
  183. case ID_POPUP_PCB_DELETE_TEXTMODULE:
  184. case ID_POPUP_PCB_DELETE_PAD:
  185. case ID_POPUP_DELETE_BLOCK:
  186. case ID_POPUP_PLACE_BLOCK:
  187. case ID_POPUP_ZOOM_BLOCK:
  188. case ID_POPUP_MIRROR_X_BLOCK:
  189. case ID_POPUP_ROTATE_BLOCK:
  190. case ID_POPUP_DUPLICATE_BLOCK:
  191. break;
  192. case ID_POPUP_CANCEL_CURRENT_COMMAND:
  193. default:
  194. if( m_canvas->IsMouseCaptured() )
  195. {
  196. // for all other commands: stop the move in progress
  197. m_canvas->CallEndMouseCapture( &dc );
  198. }
  199. if( id != ID_POPUP_CANCEL_CURRENT_COMMAND )
  200. SetNoToolSelected();
  201. break;
  202. }
  203. switch( id )
  204. {
  205. case ID_EXIT:
  206. Close( true );
  207. break;
  208. case ID_OPEN_MODULE_VIEWER:
  209. {
  210. FOOTPRINT_VIEWER_FRAME* viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
  211. if( !viewer )
  212. {
  213. viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, true );
  214. viewer->Show( true );
  215. viewer->Zoom_Automatique( false );
  216. }
  217. else
  218. {
  219. // On Windows, Raise() does not bring the window on screen, when iconized
  220. if( viewer->IsIconized() )
  221. viewer->Iconize( false );
  222. viewer->Raise();
  223. // Raising the window does not set the focus on Linux. This should work on
  224. // any platform.
  225. if( wxWindow::FindFocus() != viewer )
  226. viewer->SetFocus();
  227. }
  228. }
  229. break;
  230. case ID_MODEDIT_DELETE_PART:
  231. if( DeleteModuleFromLibrary( LoadFootprint( getTargetFPId() ) ) )
  232. {
  233. if( getTargetFPId() == GetCurrentFPId() )
  234. Clear_Pcb( false );
  235. SyncLibraryTree( true );
  236. }
  237. break;
  238. case ID_MODEDIT_NEW_MODULE:
  239. {
  240. LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
  241. MODULE* module = CreateNewModule( wxEmptyString );
  242. if( !module )
  243. break;
  244. if( !Clear_Pcb( true ) )
  245. break;
  246. SetCrossHairPosition( wxPoint( 0, 0 ) );
  247. AddModuleToBoard( module );
  248. // Initialize data relative to nets and netclasses (for a new
  249. // module the defaults are used)
  250. // This is mandatory to handle and draw pads
  251. GetBoard()->BuildListOfNets();
  252. module->SetPosition( wxPoint( 0, 0 ) );
  253. if( GetBoard()->m_Modules )
  254. GetBoard()->m_Modules->ClearFlags();
  255. Zoom_Automatique( false );
  256. GetScreen()->SetModify();
  257. // If selected from the library tree then go ahead and save it there
  258. if( !selected.GetLibNickname().empty() )
  259. {
  260. LIB_ID fpid = module->GetFPID();
  261. fpid.SetLibNickname( selected.GetLibNickname() );
  262. module->SetFPID( fpid );
  263. SaveFootprint( module );
  264. GetScreen()->ClrModify();
  265. }
  266. updateView();
  267. m_canvas->Refresh();
  268. Update3DView();
  269. SyncLibraryTree( false );
  270. }
  271. break;
  272. case ID_MODEDIT_NEW_MODULE_FROM_WIZARD:
  273. {
  274. LIB_ID selected = m_treePane->GetLibTree()->GetSelectedLibId();
  275. if( GetScreen()->IsModify() && !GetBoard()->IsEmpty() )
  276. {
  277. if( !HandleUnsavedChanges( this, _( "The current footprint has been modified. Save changes?" ),
  278. [&]()->bool { return SaveFootprint( GetBoard()->m_Modules ); } ) )
  279. {
  280. break;
  281. }
  282. }
  283. FOOTPRINT_WIZARD_FRAME* wizard = (FOOTPRINT_WIZARD_FRAME*) Kiway().Player(
  284. FRAME_PCB_FOOTPRINT_WIZARD, true, this );
  285. if( wizard->ShowModal( NULL, this ) )
  286. {
  287. // Creates the new footprint from python script wizard
  288. MODULE* module = wizard->GetBuiltFootprint();
  289. if( module == NULL ) // i.e. if create module command aborted
  290. break;
  291. Clear_Pcb( false );
  292. SetCrossHairPosition( wxPoint( 0, 0 ) );
  293. // Add the new object to board
  294. GetBoard()->Add( module, ADD_APPEND );
  295. // Initialize data relative to nets and netclasses (for a new
  296. // module the defaults are used)
  297. // This is mandatory to handle and draw pads
  298. GetBoard()->BuildListOfNets();
  299. module->SetPosition( wxPoint( 0, 0 ) );
  300. module->ClearFlags();
  301. Zoom_Automatique( false );
  302. GetScreen()->SetModify();
  303. // If selected from the library tree then go ahead and save it there
  304. if( !selected.GetLibNickname().empty() )
  305. {
  306. LIB_ID fpid = module->GetFPID();
  307. fpid.SetLibNickname( selected.GetLibNickname() );
  308. module->SetFPID( fpid );
  309. SaveFootprint( module );
  310. GetScreen()->ClrModify();
  311. }
  312. updateView();
  313. m_canvas->Refresh();
  314. Update3DView();
  315. SyncLibraryTree( false );
  316. }
  317. wizard->Destroy();
  318. }
  319. break;
  320. case ID_MODEDIT_SAVE:
  321. if( getTargetFPId() == GetCurrentFPId() )
  322. {
  323. if( SaveFootprint( GetBoard()->m_Modules ) )
  324. {
  325. m_toolManager->GetView()->Update( GetBoard()->m_Modules );
  326. if( IsGalCanvasActive() && GetGalCanvas() )
  327. GetGalCanvas()->ForceRefresh();
  328. else
  329. GetCanvas()->Refresh();
  330. GetScreen()->ClrModify();
  331. }
  332. }
  333. m_treePane->GetLibTree()->Refresh();
  334. break;
  335. case ID_MODEDIT_SAVE_AS:
  336. if( getTargetFPId().GetLibItemName().empty() )
  337. {
  338. // Save Library As
  339. const wxString& libName = getTargetFPId().GetLibNickname();
  340. if( SaveLibraryAs( Prj().PcbFootprintLibs()->FindRow( libName )->GetFullURI() ) )
  341. SyncLibraryTree( true );
  342. }
  343. else
  344. {
  345. // Save Footprint As
  346. MODULE* footprint = LoadFootprint( getTargetFPId() );
  347. if( footprint && SaveFootprintAs( footprint ) )
  348. {
  349. SyncLibraryTree( false );
  350. if( getTargetFPId() == GetCurrentFPId() )
  351. {
  352. m_toolManager->GetView()->Update( GetBoard()->m_Modules );
  353. if( IsGalCanvasActive() && GetGalCanvas() )
  354. GetGalCanvas()->ForceRefresh();
  355. else
  356. GetCanvas()->Refresh();
  357. GetScreen()->ClrModify();
  358. }
  359. }
  360. }
  361. m_treePane->GetLibTree()->Refresh();
  362. break;
  363. case ID_MODEDIT_INSERT_MODULE_IN_BOARD:
  364. SaveFootprintToBoard( true );
  365. break;
  366. case ID_MODEDIT_IMPORT_PART:
  367. if( ! Clear_Pcb( true ) )
  368. break; // //this command is aborted
  369. SetCrossHairPosition( wxPoint( 0, 0 ) );
  370. Import_Module();
  371. if( GetBoard()->m_Modules )
  372. GetBoard()->m_Modules->ClearFlags();
  373. GetScreen()->ClrModify();
  374. Zoom_Automatique( false );
  375. m_canvas->Refresh();
  376. Update3DView();
  377. break;
  378. case ID_MODEDIT_EXPORT_PART:
  379. Export_Module( LoadFootprint( getTargetFPId() ) );
  380. break;
  381. case ID_MODEDIT_CREATE_NEW_LIB:
  382. {
  383. wxFileName fn( CreateNewLibrary() );
  384. wxString name = fn.GetName();
  385. if( !name.IsEmpty() )
  386. {
  387. LIB_ID newLib( name, wxEmptyString );
  388. SyncLibraryTree( false );
  389. m_treePane->GetLibTree()->SelectLibId( newLib );
  390. }
  391. }
  392. break;
  393. case ID_MODEDIT_SHEET_SET:
  394. break;
  395. case ID_MODEDIT_EDIT_MODULE:
  396. {
  397. LIB_ID partId = m_treePane->GetLibTree()->GetSelectedLibId();
  398. MODULE* module = LoadFootprint( partId );
  399. if( !module )
  400. break;
  401. if( !Clear_Pcb( true ) )
  402. break;
  403. SetCrossHairPosition( wxPoint( 0, 0 ) );
  404. AddModuleToBoard( module );
  405. if( GetBoard()->m_Modules )
  406. {
  407. GetBoard()->m_Modules->ClearFlags();
  408. // if either m_Reference or m_Value are gone, reinstall them -
  409. // otherwise you cannot see what you are doing on board
  410. TEXTE_MODULE* ref = &GetBoard()->m_Modules->Reference();
  411. TEXTE_MODULE* val = &GetBoard()->m_Modules->Value();
  412. if( val && ref )
  413. {
  414. ref->SetType( TEXTE_MODULE::TEXT_is_REFERENCE ); // just in case ...
  415. if( ref->GetLength() == 0 )
  416. ref->SetText( wxT( "Ref**" ) );
  417. val->SetType( TEXTE_MODULE::TEXT_is_VALUE ); // just in case ...
  418. if( val->GetLength() == 0 )
  419. val->SetText( wxT( "Val**" ) );
  420. }
  421. }
  422. Zoom_Automatique( false );
  423. Update3DView();
  424. GetScreen()->ClrModify();
  425. updateView();
  426. m_canvas->Refresh();
  427. m_treePane->GetLibTree()->Refresh();
  428. }
  429. break;
  430. case ID_MODEDIT_PAD_SETTINGS:
  431. InstallPadOptionsFrame( NULL );
  432. break;
  433. case ID_MODEDIT_CHECK:
  434. // Currently: not implemented
  435. break;
  436. case ID_MODEDIT_EDIT_MODULE_PROPERTIES:
  437. if( GetBoard()->m_Modules )
  438. {
  439. SetCurItem( GetBoard()->m_Modules );
  440. DIALOG_FOOTPRINT_FP_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
  441. dialog.ShowModal();
  442. GetScreen()->GetCurItem()->ClearFlags();
  443. m_canvas->Refresh();
  444. }
  445. break;
  446. case ID_POPUP_CLOSE_CURRENT_TOOL:
  447. break;
  448. case ID_POPUP_CANCEL_CURRENT_COMMAND:
  449. break;
  450. case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
  451. m_canvas->MoveCursorToCrossHair();
  452. Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), 900, true );
  453. m_canvas->Refresh();
  454. break;
  455. case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
  456. m_canvas->MoveCursorToCrossHair();
  457. Rotate_Module( NULL, (MODULE*) GetScreen()->GetCurItem(), -900, true );
  458. m_canvas->Refresh();
  459. break;
  460. case ID_POPUP_PCB_EDIT_MODULE_PRMS:
  461. {
  462. DIALOG_FOOTPRINT_FP_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
  463. dialog.ShowModal();
  464. GetScreen()->GetCurItem()->ClearFlags();
  465. m_canvas->MoveCursorToCrossHair();
  466. m_canvas->Refresh();
  467. }
  468. break;
  469. case ID_POPUP_PCB_MOVE_PAD_REQUEST:
  470. m_canvas->MoveCursorToCrossHair();
  471. StartMovePad( (D_PAD*) GetScreen()->GetCurItem(), &dc, false );
  472. break;
  473. case ID_POPUP_PCB_EDIT_PAD:
  474. InstallPadOptionsFrame( (D_PAD*) GetScreen()->GetCurItem() );
  475. m_canvas->MoveCursorToCrossHair();
  476. break;
  477. case ID_POPUP_PCB_DELETE_PAD:
  478. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  479. DeletePad( (D_PAD*) GetScreen()->GetCurItem(), false );
  480. SetCurItem( NULL );
  481. m_canvas->MoveCursorToCrossHair();
  482. break;
  483. case ID_POPUP_PCB_DUPLICATE_ITEM:
  484. duplicateItems( false );
  485. break;
  486. case ID_POPUP_PCB_DUPLICATE_ITEM_AND_INCREMENT:
  487. duplicateItems( true );
  488. break;
  489. case ID_POPUP_PCB_MOVE_EXACT:
  490. moveExact();
  491. break;
  492. case ID_POPUP_PCB_CREATE_ARRAY:
  493. createArray();
  494. break;
  495. case ID_POPUP_PCB_APPLY_PAD_SETTINGS:
  496. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  497. m_canvas->MoveCursorToCrossHair();
  498. Import_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem(), true );
  499. break;
  500. case ID_POPUP_PCB_GLOBAL_IMPORT_PAD_SETTINGS:
  501. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  502. // Calls the global change dialog:
  503. PushPadProperties((D_PAD*) GetScreen()->GetCurItem());
  504. m_canvas->MoveCursorToCrossHair();
  505. break;
  506. case ID_POPUP_PCB_COPY_PAD_SETTINGS:
  507. m_canvas->MoveCursorToCrossHair();
  508. Export_Pad_Settings( (D_PAD*) GetScreen()->GetCurItem() );
  509. break;
  510. case ID_POPUP_PCB_EDIT_TEXTMODULE:
  511. InstallTextOptionsFrame( GetScreen()->GetCurItem(), &dc );
  512. break;
  513. case ID_POPUP_PCB_MOVE_TEXTMODULE_REQUEST:
  514. m_canvas->MoveCursorToCrossHair();
  515. StartMoveTexteModule( static_cast<TEXTE_MODULE*>( GetScreen()->GetCurItem() ), &dc );
  516. break;
  517. case ID_POPUP_PCB_ROTATE_TEXTMODULE:
  518. RotateTextModule( static_cast<TEXTE_MODULE*>( GetScreen()->GetCurItem() ), &dc );
  519. m_canvas->MoveCursorToCrossHair();
  520. break;
  521. case ID_POPUP_PCB_DELETE_TEXTMODULE:
  522. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  523. DeleteTextModule( static_cast<TEXTE_MODULE*>( GetScreen()->GetCurItem() ) );
  524. SetCurItem( NULL );
  525. m_canvas->MoveCursorToCrossHair();
  526. break;
  527. case ID_POPUP_PCB_MOVE_EDGE:
  528. Start_Move_EdgeMod( static_cast<EDGE_MODULE*>( GetScreen()->GetCurItem() ), &dc );
  529. m_canvas->MoveCursorToCrossHair();
  530. break;
  531. case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
  532. m_canvas->MoveCursorToCrossHair();
  533. if( GetScreen()->GetCurItem()->IsNew() )
  534. {
  535. End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
  536. SetCurItem( NULL );
  537. }
  538. break;
  539. case ID_POPUP_MODEDIT_EDIT_BODY_ITEM :
  540. InstallGraphicItemPropertiesDialog( GetScreen()->GetCurItem(), nullptr );
  541. break;
  542. case ID_POPUP_MODEDIT_EDIT_WIDTH_ALL_EDGE:
  543. m_canvas->MoveCursorToCrossHair();
  544. Edit_Edge_Width( NULL );
  545. m_canvas->Refresh();
  546. break;
  547. case ID_POPUP_MODEDIT_EDIT_LAYER_ALL_EDGE:
  548. m_canvas->MoveCursorToCrossHair();
  549. Edit_Edge_Layer( NULL );
  550. m_canvas->Refresh();
  551. break;
  552. case ID_POPUP_PCB_DELETE_EDGE:
  553. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  554. m_canvas->MoveCursorToCrossHair();
  555. RemoveStruct( GetScreen()->GetCurItem() );
  556. SetCurItem( NULL );
  557. break;
  558. case ID_MODEDIT_MODULE_ROTATE:
  559. case ID_MODEDIT_MODULE_MIRROR:
  560. case ID_MODEDIT_MODULE_MOVE_EXACT:
  561. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  562. Transform( (MODULE*) GetScreen()->GetCurItem(), id );
  563. m_canvas->Refresh();
  564. break;
  565. case ID_PCB_USER_GRID_SETUP:
  566. InvokeDialogGrid();
  567. break;
  568. case ID_POPUP_PLACE_BLOCK:
  569. GetScreen()->m_BlockLocate.SetCommand( BLOCK_MOVE );
  570. m_canvas->SetAutoPanRequest( false );
  571. HandleBlockPlace( &dc );
  572. break;
  573. case ID_POPUP_DUPLICATE_BLOCK:
  574. GetScreen()->m_BlockLocate.SetCommand( BLOCK_DUPLICATE );
  575. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  576. m_canvas->SetAutoPanRequest( false );
  577. HandleBlockPlace( &dc );
  578. break;
  579. case ID_POPUP_ZOOM_BLOCK:
  580. GetScreen()->m_BlockLocate.SetCommand( BLOCK_ZOOM );
  581. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  582. HandleBlockEnd( &dc );
  583. break;
  584. case ID_POPUP_DELETE_BLOCK:
  585. GetScreen()->m_BlockLocate.SetCommand( BLOCK_DELETE );
  586. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  587. HandleBlockEnd( &dc );
  588. break;
  589. case ID_POPUP_ROTATE_BLOCK:
  590. GetScreen()->m_BlockLocate.SetCommand( BLOCK_ROTATE );
  591. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  592. HandleBlockEnd( &dc );
  593. break;
  594. case ID_POPUP_MIRROR_X_BLOCK:
  595. GetScreen()->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
  596. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  597. HandleBlockEnd( &dc );
  598. break;
  599. case ID_POPUP_MOVE_BLOCK_EXACT:
  600. GetScreen()->m_BlockLocate.SetCommand( BLOCK_MOVE_EXACT );
  601. GetScreen()->m_BlockLocate.SetMessageBlock( this );
  602. HandleBlockEnd( &dc );
  603. break;
  604. case ID_GEN_IMPORT_DXF_FILE:
  605. if( GetBoard()->m_Modules )
  606. {
  607. InvokeDXFDialogModuleImport( this, GetBoard()->m_Modules );
  608. m_canvas->Refresh();
  609. }
  610. break;
  611. default:
  612. DisplayError( this,
  613. wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
  614. break;
  615. }
  616. }
  617. void FOOTPRINT_EDIT_FRAME::moveExact()
  618. {
  619. wxPoint translation;
  620. double rotation;
  621. ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR;
  622. DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor );
  623. int ret = dialog.ShowModal();
  624. if( ret == wxID_OK )
  625. {
  626. SaveCopyInUndoList( GetBoard()->m_Modules, UR_CHANGED );
  627. BOARD_ITEM* item = GetScreen()->GetCurItem();
  628. item->Move( translation );
  629. switch( rotationAnchor )
  630. {
  631. case ROTATE_AROUND_ITEM_ANCHOR:
  632. item->Rotate( item->GetPosition(), rotation );
  633. break;
  634. case ROTATE_AROUND_USER_ORIGIN:
  635. item->Rotate( GetScreen()->m_O_Curseur, rotation );
  636. break;
  637. default:
  638. wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." );
  639. }
  640. item->Rotate( item->GetPosition(), rotation );
  641. m_canvas->Refresh();
  642. }
  643. m_canvas->MoveCursorToCrossHair();
  644. }
  645. void FOOTPRINT_EDIT_FRAME::duplicateItems( bool aIncrement )
  646. {
  647. BOARD_ITEM* item = GetScreen()->GetCurItem();
  648. PCB_BASE_EDIT_FRAME::duplicateItem( item, aIncrement );
  649. }
  650. void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
  651. {
  652. switch( transform )
  653. {
  654. case ID_MODEDIT_MODULE_ROTATE:
  655. RotateMarkedItems( module, wxPoint(0,0), true );
  656. break;
  657. case ID_MODEDIT_MODULE_MIRROR:
  658. MirrorMarkedItems( module, wxPoint(0,0), true );
  659. break;
  660. case ID_MODEDIT_MODULE_MOVE_EXACT:
  661. {
  662. wxPoint translation;
  663. double rotation;
  664. ROTATION_ANCHOR rotationAnchor = ROTATE_AROUND_ITEM_ANCHOR;
  665. DIALOG_MOVE_EXACT dialog( this, translation, rotation, rotationAnchor );
  666. if( dialog.ShowModal() == wxID_OK )
  667. {
  668. switch( rotationAnchor )
  669. {
  670. case ROTATE_AROUND_ITEM_ANCHOR:
  671. MoveMarkedItemsExactly( module, module->GetPosition() + translation, translation, rotation, true );
  672. break;
  673. case ROTATE_AROUND_USER_ORIGIN:
  674. MoveMarkedItemsExactly( module, GetScreen()->m_O_Curseur, translation, rotation, true );
  675. break;
  676. default:
  677. wxFAIL_MSG( "Rotation choice shouldn't have been available in this context." );
  678. }
  679. }
  680. break;
  681. }
  682. default:
  683. DisplayInfoMessage( this, wxT( "Not available" ) );
  684. break;
  685. }
  686. module->CalculateBoundingBox();
  687. OnModify();
  688. }
  689. void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent )
  690. {
  691. int id = aEvent.GetId();
  692. int lastToolID = GetToolId();
  693. // Stop the current command and deselect the current tool.
  694. SetNoToolSelected();
  695. switch( id )
  696. {
  697. case ID_NO_TOOL_SELECTED:
  698. break;
  699. case ID_ZOOM_SELECTION:
  700. // This tool is located on the main toolbar: switch it on or off on click on it
  701. if( lastToolID != ID_ZOOM_SELECTION )
  702. SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
  703. else
  704. SetNoToolSelected();
  705. break;
  706. case ID_MODEDIT_LINE_TOOL:
  707. SetToolID( id, wxCURSOR_PENCIL, _( "Add line" ) );
  708. break;
  709. case ID_MODEDIT_ARC_TOOL:
  710. SetToolID( id, wxCURSOR_PENCIL, _( "Add arc" ) );
  711. break;
  712. case ID_MODEDIT_CIRCLE_TOOL:
  713. SetToolID( id, wxCURSOR_PENCIL, _( "Add circle" ) );
  714. break;
  715. case ID_MODEDIT_TEXT_TOOL:
  716. SetToolID( id, wxCURSOR_PENCIL, _( "Add text" ) );
  717. break;
  718. case ID_MODEDIT_ANCHOR_TOOL:
  719. SetToolID( id, wxCURSOR_PENCIL, _( "Place anchor" ) );
  720. break;
  721. case ID_MODEDIT_PLACE_GRID_COORD:
  722. SetToolID( id, wxCURSOR_PENCIL, _( "Set grid origin" ) );
  723. break;
  724. case ID_MODEDIT_PAD_TOOL:
  725. if( GetBoard()->m_Modules )
  726. {
  727. SetToolID( id, wxCURSOR_PENCIL, _( "Add pad" ) );
  728. }
  729. else
  730. {
  731. SetToolID( id, wxCURSOR_ARROW, _( "Pad properties" ) );
  732. InstallPadOptionsFrame( NULL );
  733. SetNoToolSelected();
  734. }
  735. break;
  736. case ID_MODEDIT_DELETE_TOOL:
  737. SetToolID( id, wxCURSOR_BULLSEYE, _( "Delete item" ) );
  738. break;
  739. case ID_MODEDIT_MEASUREMENT_TOOL:
  740. DisplayError( this, wxT( "Measurement Tool not available in Legacy Toolset" ) );
  741. SetNoToolSelected();
  742. break;
  743. default:
  744. wxFAIL_MSG( wxT( "Unknown command id." ) );
  745. SetNoToolSelected();
  746. }
  747. }
  748. void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
  749. {
  750. if( Item == NULL )
  751. return;
  752. switch( Item->Type() )
  753. {
  754. case PCB_PAD_T:
  755. DeletePad( (D_PAD*) Item, false );
  756. break;
  757. case PCB_MODULE_TEXT_T:
  758. {
  759. TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( Item );
  760. switch( text->GetType() )
  761. {
  762. case TEXTE_MODULE::TEXT_is_REFERENCE:
  763. DisplayError( this, _( "Cannot delete REFERENCE!" ) );
  764. break;
  765. case TEXTE_MODULE::TEXT_is_VALUE:
  766. DisplayError( this, _( "Cannot delete VALUE!" ) );
  767. break;
  768. case TEXTE_MODULE::TEXT_is_DIVERS:
  769. DeleteTextModule( text );
  770. }
  771. }
  772. break;
  773. case PCB_MODULE_EDGE_T:
  774. Delete_Edge_Module( (EDGE_MODULE*) Item );
  775. m_canvas->Refresh();
  776. break;
  777. case PCB_MODULE_T:
  778. break;
  779. default:
  780. {
  781. wxString Line;
  782. Line.Printf( wxT( " RemoveStruct: item type %d unknown." ), Item->Type() );
  783. wxMessageBox( Line );
  784. }
  785. break;
  786. }
  787. }
  788. COLOR4D FOOTPRINT_EDIT_FRAME::GetGridColor()
  789. {
  790. return Settings().Colors().GetItemColor( LAYER_GRID );
  791. }
  792. void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
  793. {
  794. PCB_BASE_FRAME::SetActiveLayer( aLayer );
  795. m_Layers->SelectLayer( GetActiveLayer() );
  796. m_Layers->OnLayerSelected();
  797. if( IsGalCanvasActive() )
  798. {
  799. GetGalCanvas()->SetHighContrastLayer( aLayer );
  800. GetGalCanvas()->Refresh();
  801. }
  802. }
  803. bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
  804. {
  805. if( ! Clear_Pcb( true ) )
  806. return false; // //this command is aborted
  807. SetCrossHairPosition( wxPoint( 0, 0 ) );
  808. Import_Module( aFileSet[0] );
  809. if( GetBoard()->m_Modules )
  810. GetBoard()->m_Modules->ClearFlags();
  811. GetScreen()->ClrModify();
  812. Zoom_Automatique( false );
  813. m_canvas->Refresh();
  814. return true;
  815. }
  816. void FOOTPRINT_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
  817. {
  818. const std::string& payload = mail.GetPayload();
  819. switch( mail.Command() )
  820. {
  821. case MAIL_FP_EDIT:
  822. if( !payload.empty() )
  823. {
  824. wxFileName fpFileName( payload );
  825. wxString libNickname;
  826. wxString msg;
  827. FP_LIB_TABLE* libTable = Prj().PcbFootprintLibs();
  828. const LIB_TABLE_ROW* libTableRow = libTable->FindRowByURI( fpFileName.GetPath() );
  829. if( !libTableRow )
  830. {
  831. msg.Printf( _( "The current configuration does not include the footprint library\n"
  832. "\"%s\".\nUse Manage Footprint Libraries to edit the configuration." ),
  833. fpFileName.GetPath() );
  834. DisplayErrorMessage( this, _( "Library not found in footprint library table." ), msg );
  835. break;
  836. }
  837. libNickname = libTableRow->GetNickName();
  838. if( !libTable->HasLibrary( libNickname, true ) )
  839. {
  840. msg.Printf( _( "The library with the nickname \"%s\" is not enabled\n"
  841. "in the current configuration. Use Manage Footprint Libraries to\n"
  842. "edit the configuration." ), libNickname );
  843. DisplayErrorMessage( this, _( "Footprint library not enabled." ), msg );
  844. break;
  845. }
  846. LIB_ID fpId( libNickname, fpFileName.GetName() );
  847. if( m_treePane )
  848. {
  849. m_treePane->GetLibTree()->SelectLibId( fpId );
  850. wxCommandEvent event( COMPONENT_SELECTED );
  851. wxPostEvent( m_treePane, event );
  852. }
  853. }
  854. break;
  855. default:
  856. ;
  857. }
  858. }