KiCad PCB EDA Suite
editmod.cpp
Go to the documentation of this file.
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 
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <kiway.h>
32 #include <confirm.h>
33 #include <class_drawpanel.h>
34 #include <pcbnew.h>
35 #include <wxPcbStruct.h>
36 #include <module_editor_frame.h>
38 
39 #include <class_module.h>
40 #include <class_pad.h>
41 #include <class_edge_mod.h>
42 
44 
45 
46 /*
47  * Show module property dialog.
48  */
50 {
51  if( Module == NULL )
52  return;
53 
54 #ifdef __WXMAC__
55  // avoid Avoid "writes" in the dialog, creates errors with WxOverlay and NSView & Modal
56  // Raising an Exception - Fixes #764678
57  DC = NULL;
58 #endif
59 
60  DIALOG_MODULE_BOARD_EDITOR* dlg = new DIALOG_MODULE_BOARD_EDITOR( this, Module, DC );
61 
62  int retvalue = dlg->ShowModal();
63  /* retvalue =
64  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_ABORT if abort,
65  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_EXCHANGE_FP if exchange module,
66  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_EDIT_OK for normal edition
67  * FP_PRM_EDITOR_RETVALUE::PRM_EDITOR_WANT_MODEDIT for a goto editor command
68  */
69 
70  dlg->Close();
71  dlg->Destroy();
72 
73 #ifdef __WXMAC__
74  // If something edited, push a refresh request
76  m_canvas->Refresh();
77 #endif
78 
80  {
82 
83  editor->Load_Module_From_BOARD( Module );
84  SetCurItem( NULL );
85 
86  editor->Show( true );
87  editor->Raise(); // Iconize( false );
88  }
89 
91  {
93  // Warning: the current item can be deleted by exchange module
94  SetCurItem( NULL );
95  }
96 }
97 
98 
100 {
101  if( Item == NULL )
102  return;
103 
104  switch( Item->Type() )
105  {
106  case PCB_PAD_T:
107  DeletePad( (D_PAD*) Item, false );
108  break;
109 
110  case PCB_MODULE_TEXT_T:
111  {
112  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( Item );
113 
114  switch( text->GetType() )
115  {
117  DisplayError( this, _( "Cannot delete REFERENCE!" ) );
118  break;
119 
121  DisplayError( this, _( "Cannot delete VALUE!" ) );
122  break;
123 
125  DeleteTextModule( text );
126  }
127  }
128  break;
129 
130  case PCB_MODULE_EDGE_T:
131  Delete_Edge_Module( (EDGE_MODULE*) Item );
132  m_canvas->Refresh();
133  break;
134 
135  case PCB_MODULE_T:
136  break;
137 
138  default:
139  {
140  wxString Line;
141  Line.Printf( wxT( " RemoveStruct: item type %d unknown." ), Item->Type() );
142  wxMessageBox( Line );
143  }
144  break;
145  }
146 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
Definition of class FOOTPRINT_EDIT_FRAME.
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
int InstallExchangeModuleFrame(MODULE *ExchangeModuleModule)
Definition: pcbframe.cpp:1233
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
void RemoveStruct(EDA_ITEM *Item)
Definition: editmod.cpp:99
This file is part of the common library.
TEXT_TYPE GetType() const
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
void DeletePad(D_PAD *aPad, bool aQuery=true)
Function DeletePad Delete the pad aPad.
class MODULE, a footprint
Definition: typeinfo.h:101
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, KIWAY_PLAYER *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:302
void InstallModuleOptionsFrame(MODULE *Module, wxDC *DC)
Definition: editmod.cpp:49
bool Load_Module_From_BOARD(MODULE *Module)
Function Load_Module_From_BOARD load in Modedit a footprint from the main board.
Definition: loadcmp.cpp:75
Pad object description.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
void DeleteTextModule(TEXTE_MODULE *Text)
Definition: edtxtmod.cpp:139
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
Declaration of the eda_3d_viewer class.
void Delete_Edge_Module(EDGE_MODULE *Edge)
Function Delete_Edge_Module deletes EDGE_MODULE Edge.
Definition: edgemod.cpp:272
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
Module description (excepted pads)
EDGE_MODULE class definition.
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71