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.

137 lines
3.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file edit.cpp
  25. * @brief Module editor dialog box for editing module properties and characteristics.
  26. */
  27. #include <fctsys.h>
  28. #include <confirm.h>
  29. #include <class_drawpanel.h>
  30. #include <pcbnew.h>
  31. #include <wxPcbStruct.h>
  32. #include <module_editor_frame.h>
  33. #include <3d_viewer.h>
  34. #include <class_module.h>
  35. #include <class_pad.h>
  36. #include <class_edge_mod.h>
  37. #include <dialog_edit_module_for_BoardEditor.h>
  38. /*
  39. * Show module property dialog.
  40. */
  41. void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
  42. {
  43. if( Module == NULL )
  44. return;
  45. #ifndef __WXMAC__
  46. DIALOG_MODULE_BOARD_EDITOR* dialog = new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC );
  47. #else
  48. // avoid Avoid "writes" in the dialog, creates errors with WxOverlay and NSView & Modal
  49. // Raising an Exception - Fixes #764678
  50. DIALOG_MODULE_BOARD_EDITOR* dialog = new DIALOG_MODULE_BOARD_EDITOR( this, Module, NULL );
  51. #endif
  52. int retvalue = dialog->ShowModal(); /* retvalue =
  53. * -1 if abort,
  54. * 0 if exchange module,
  55. * 1 for normal edition
  56. * and 2 for a goto editor command
  57. */
  58. dialog->Destroy();
  59. #ifdef __WXMAC__
  60. // If something edited, push a refresh request
  61. if (retvalue == 0 || retvalue == 1)
  62. RefreshCanvas();
  63. #endif
  64. if( retvalue == 2 )
  65. {
  66. FOOTPRINT_EDIT_FRAME* editorFrame = FOOTPRINT_EDIT_FRAME::GetActiveFootprintEditor();
  67. if( editorFrame == NULL )
  68. editorFrame = new FOOTPRINT_EDIT_FRAME( this, m_footprintLibTable );
  69. editorFrame->Load_Module_From_BOARD( Module );
  70. SetCurItem( NULL );
  71. editorFrame->Show( true );
  72. editorFrame->Iconize( false );
  73. }
  74. }
  75. void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
  76. {
  77. if( Item == NULL )
  78. return;
  79. switch( Item->Type() )
  80. {
  81. case PCB_PAD_T:
  82. DeletePad( (D_PAD*) Item, false );
  83. break;
  84. case PCB_MODULE_TEXT_T:
  85. {
  86. TEXTE_MODULE* text = (TEXTE_MODULE*) Item;
  87. switch( text->GetType() )
  88. {
  89. case TEXTE_MODULE::TEXT_is_REFERENCE:
  90. DisplayError( this, _( "Cannot delete REFERENCE!" ) );
  91. break;
  92. case TEXTE_MODULE::TEXT_is_VALUE:
  93. DisplayError( this, _( "Cannot delete VALUE!" ) );
  94. break;
  95. default:
  96. DeleteTextModule( text );
  97. }
  98. }
  99. break;
  100. case PCB_MODULE_EDGE_T:
  101. Delete_Edge_Module( (EDGE_MODULE*) Item );
  102. RefreshCanvas();
  103. break;
  104. case PCB_MODULE_T:
  105. break;
  106. default:
  107. {
  108. wxString Line;
  109. Line.Printf( wxT( " RemoveStruct: item type %d unknown." ), Item->Type() );
  110. wxMessageBox( Line );
  111. }
  112. break;
  113. }
  114. }