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.

1044 lines
33 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
15 years ago
15 years ago
15 years ago
15 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) 2004-2013 KiCad Developers, see change_log.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 dialog_edit_component_in_schematic.cpp
  25. */
  26. #include <wx/tooltip.h>
  27. #include <wx/hyperlink.h>
  28. #include <fctsys.h>
  29. #include <pgm_base.h>
  30. #include <kiway.h>
  31. #include <gr_basic.h>
  32. #include <class_drawpanel.h>
  33. #include <confirm.h>
  34. #include <class_sch_screen.h>
  35. #include <wxEeschemaStruct.h>
  36. #include <base_units.h>
  37. #include <general.h>
  38. #include <class_library.h>
  39. #include <sch_component.h>
  40. #include <dialog_helpers.h>
  41. #include <dialog_edit_component_in_schematic_fbp.h>
  42. /**
  43. * class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
  44. * is hand coded and implements DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP which
  45. * is maintained by wxFormBuilder. Do not auto-generate this class or file,
  46. * it is hand coded.
  47. */
  48. class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC : public DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP
  49. {
  50. public:
  51. /** Constructor */
  52. DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent );
  53. /**
  54. * Function InitBuffers
  55. * sets up to edit the given component.
  56. * @param aComponent The component to edit.
  57. */
  58. void InitBuffers( SCH_COMPONENT* aComponent );
  59. private:
  60. friend class SCH_EDIT_FRAME;
  61. SCH_EDIT_FRAME* m_Parent;
  62. SCH_COMPONENT* m_Cmp;
  63. LIB_PART* m_part;
  64. bool m_skipCopyFromPanel;
  65. static int s_SelectedRow;
  66. /// a copy of the edited component's SCH_FIELDs
  67. SCH_FIELDS m_FieldsBuf;
  68. void setSelectedFieldNdx( int aFieldNdx );
  69. int getSelectedFieldNdx();
  70. /**
  71. * Function copySelectedFieldToPanel
  72. * sets the values displayed on the panel according to
  73. * the currently selected field row
  74. */
  75. void copySelectedFieldToPanel();
  76. /**
  77. * Function copyPanelToSelectedField
  78. * copies the values displayed on the panel fields to the currently
  79. * selected field
  80. * @return bool - true if all fields are OK, else false if the user has put
  81. * bad data into a field, and this value can be used to deny a row change.
  82. */
  83. bool copyPanelToSelectedField();
  84. void copyOptionsToPanel();
  85. void copyPanelToOptions();
  86. void setRowItem( int aFieldNdx, const SCH_FIELD& aField );
  87. // event handlers
  88. void OnCloseDialog( wxCloseEvent& event );
  89. void OnListItemDeselected( wxListEvent& event );
  90. void OnListItemSelected( wxListEvent& event );
  91. void OnCancelButtonClick( wxCommandEvent& event );
  92. void OnOKButtonClick( wxCommandEvent& event );
  93. void SetInitCmp( wxCommandEvent& event );
  94. void addFieldButtonHandler( wxCommandEvent& event );
  95. void deleteFieldButtonHandler( wxCommandEvent& event );
  96. void moveUpButtonHandler( wxCommandEvent& event );
  97. void showButtonHandler( wxCommandEvent& event );
  98. SCH_FIELD* findField( const wxString& aFieldName );
  99. /**
  100. * Function updateDisplay
  101. * update the listbox showing fields, according to the fields texts
  102. * must be called after a text change in fields, if this change is not an edition
  103. */
  104. void updateDisplay( )
  105. {
  106. for( unsigned ii = FIELD1; ii<m_FieldsBuf.size(); ii++ )
  107. setRowItem( ii, m_FieldsBuf[ii] );
  108. }
  109. };
  110. int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::s_SelectedRow;
  111. void SCH_EDIT_FRAME::EditComponent( SCH_COMPONENT* aComponent )
  112. {
  113. wxCHECK_RET( aComponent != NULL && aComponent->Type() == SCH_COMPONENT_T,
  114. wxT( "Invalid component object pointer. Bad Programmer!" ) );
  115. m_canvas->SetIgnoreMouseEvents( true );
  116. DIALOG_EDIT_COMPONENT_IN_SCHEMATIC* dlg = new DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( this );
  117. dlg->InitBuffers( aComponent );
  118. // make sure the chipnameTextCtrl is wide enough to hold any unusually long chip names:
  119. EnsureTextCtrlWidth( dlg->chipnameTextCtrl );
  120. // This dialog itself subsequently can invoke a KIWAY_PLAYER as a quasimodal
  121. // frame. Therefore this dialog as a modal frame parent, MUST be run under
  122. // quasimodal mode for the quasimodal frame support to work. So don't use
  123. // the QUASIMODAL macros here.
  124. dlg->ShowQuasiModal();
  125. m_canvas->SetIgnoreMouseEvents( false );
  126. m_canvas->MoveCursorToCrossHair();
  127. dlg->Destroy();
  128. }
  129. DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow* parent ) :
  130. DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_FBP( parent )
  131. {
  132. m_Parent = (SCH_EDIT_FRAME*) parent;
  133. m_part = NULL;
  134. m_skipCopyFromPanel = false;
  135. wxListItem columnLabel;
  136. columnLabel.SetImage( -1 );
  137. columnLabel.SetText( _( "Name" ) );
  138. fieldListCtrl->InsertColumn( 0, columnLabel );
  139. columnLabel.SetText( _( "Value" ) );
  140. fieldListCtrl->InsertColumn( 1, columnLabel );
  141. m_staticTextUnitSize->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  142. m_staticTextUnitPosX->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  143. m_staticTextUnitPosY->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
  144. copySelectedFieldToPanel();
  145. wxToolTip::Enable( true );
  146. GetSizer()->SetSizeHints( this );
  147. Center();
  148. stdDialogButtonSizerOK->SetDefault();
  149. }
  150. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& event )
  151. {
  152. DBG( printf( "OnListItemDeselected()\n" ); )
  153. if( !m_skipCopyFromPanel )
  154. {
  155. if( !copyPanelToSelectedField() )
  156. event.Skip(); // do not go to the next row
  157. }
  158. }
  159. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemSelected( wxListEvent& event )
  160. {
  161. DBG( printf( "OnListItemSelected()\n" ); )
  162. // remember the selected row, statically
  163. s_SelectedRow = event.GetIndex();
  164. copySelectedFieldToPanel();
  165. }
  166. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog( wxCloseEvent& event )
  167. {
  168. // On wxWidgets 2.8, and on Linux, calling EndQuasiModal here is mandatory
  169. // Otherwise, the main event loop is never restored, and Eeschema does not
  170. // respond to any event, because the DIALOG_SHIM destructor is never called.
  171. // on wxWidgets 3.0, or on Windows, the DIALOG_SHIM destructor is called,
  172. // and calls EndQuasiModal.
  173. // therefore calling EndQuasiModal here is not mandatory but it creates no issues
  174. EndQuasiModal( wxID_CANCEL );
  175. }
  176. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick( wxCommandEvent& event )
  177. {
  178. EndQuasiModal( wxID_CANCEL );
  179. }
  180. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions()
  181. {
  182. wxString newname = chipnameTextCtrl->GetValue();
  183. newname.Replace( wxT( " " ), wxT( "_" ) );
  184. if( newname.IsEmpty() )
  185. {
  186. DisplayError( NULL, _( "No Component Name!" ) );
  187. }
  188. else if( Cmp_KEEPCASE( newname, m_Cmp->m_part_name ) )
  189. {
  190. PART_LIBS* libs = Prj().SchLibs();
  191. if( libs->FindLibraryEntry( newname ) == NULL )
  192. {
  193. if( LIB_ALIAS* entry = libs->FindLibraryNearEntry( newname ) )
  194. {
  195. wxString near_name = entry->GetName();
  196. wxString msg = wxString::Format( _(
  197. "Component '%s' not found!\n"
  198. "But the component '%s' exists\n"
  199. "Do you want to use it?"),
  200. GetChars( newname ), GetChars( near_name ) );
  201. if( IsOK( this, msg ) )
  202. {
  203. chipnameTextCtrl->SetValue( near_name );
  204. m_Cmp->SetPartName( near_name, libs );
  205. }
  206. }
  207. else
  208. {
  209. wxString msg = wxString::Format( _(
  210. "Component '%s' not found!" ),
  211. GetChars( newname ) );
  212. DisplayError( this, msg );
  213. }
  214. }
  215. else // Change component from lib!
  216. {
  217. m_Cmp->SetPartName( newname, libs );
  218. }
  219. }
  220. // For components with multiple shapes (De Morgan representation) Set the selected shape:
  221. if( convertCheckBox->IsEnabled() )
  222. {
  223. m_Cmp->SetConvert( convertCheckBox->GetValue() ? 2 : 1 );
  224. }
  225. //Set the part selection in multiple part per package
  226. if( m_Cmp->GetUnit() )
  227. {
  228. int unit_selection = unitChoice->GetCurrentSelection() + 1;
  229. STATUS_FLAGS flags = m_Cmp->GetFlags();
  230. m_Cmp->SetUnitSelection( &m_Parent->GetCurrentSheet(), unit_selection );
  231. m_Cmp->SetUnit( unit_selection );
  232. m_Cmp->ClearFlags();
  233. m_Cmp->SetFlags( flags ); // Restore m_Flag modified by SetUnit()
  234. }
  235. switch( orientationRadioBox->GetSelection() )
  236. {
  237. case 0:
  238. m_Cmp->SetOrientation( CMP_ORIENT_0 );
  239. break;
  240. case 1:
  241. m_Cmp->SetOrientation( CMP_ORIENT_90 );
  242. break;
  243. case 2:
  244. m_Cmp->SetOrientation( CMP_ORIENT_180 );
  245. break;
  246. case 3:
  247. m_Cmp->SetOrientation( CMP_ORIENT_270 );
  248. break;
  249. }
  250. int mirror = mirrorRadioBox->GetSelection();
  251. switch( mirror )
  252. {
  253. case 0:
  254. break;
  255. case 1:
  256. m_Cmp->SetOrientation( CMP_MIRROR_X );
  257. break;
  258. case 2:
  259. m_Cmp->SetOrientation( CMP_MIRROR_Y );
  260. break;
  261. }
  262. }
  263. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event )
  264. {
  265. bool removeRemainingFields = false;
  266. if( !copyPanelToSelectedField() )
  267. return;
  268. if( ! SCH_COMPONENT::IsReferenceStringValid( m_FieldsBuf[REFERENCE].GetText() ) )
  269. {
  270. DisplayError( NULL, _( "Illegal reference. A reference must start with a letter" ) );
  271. return;
  272. }
  273. // save old cmp in undo list if not already in edit, or moving ...
  274. // or the component to be edited is part of a block
  275. if( m_Cmp->m_Flags == 0 ||
  276. m_Parent->GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK )
  277. m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
  278. copyPanelToOptions();
  279. // Delete any fields with no name before we copy all of m_FieldsBuf back into the component.
  280. for( unsigned i = MANDATORY_FIELDS; i<m_FieldsBuf.size(); )
  281. {
  282. if( m_FieldsBuf[i].GetName( false ).IsEmpty() || m_FieldsBuf[i].GetText().IsEmpty() )
  283. {
  284. // If a field has no value and is not it the field template list, warn the user
  285. // that it will be remove from the component. This gives the user a chance to
  286. // correct the problem before removing the undefined fields. It should also
  287. // resolve most of the bug reports and questions regarding missing fields.
  288. if( !m_FieldsBuf[i].GetName( false ).IsEmpty() && m_FieldsBuf[i].GetText().IsEmpty()
  289. && !m_Parent->GetTemplates().HasFieldName( m_FieldsBuf[i].GetName( false ) )
  290. && !removeRemainingFields )
  291. {
  292. wxString msg = wxString::Format(
  293. _( "The field name <%s> does not have a value and is not defined in "
  294. "the field template list. Empty field values are invalid an will "
  295. "be removed from the component. Do you wish to remove this and "
  296. "all remaining undefined fields?" ),
  297. GetChars( m_FieldsBuf[i].GetName( false ) )
  298. );
  299. wxMessageDialog dlg( this, msg, _( "Remove Fields" ), wxYES_NO | wxNO_DEFAULT );
  300. if( dlg.ShowModal() == wxID_NO )
  301. return;
  302. removeRemainingFields = true;
  303. }
  304. m_FieldsBuf.erase( m_FieldsBuf.begin() + i );
  305. continue;
  306. }
  307. ++i;
  308. }
  309. // change all field positions from relative to absolute
  310. for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
  311. {
  312. m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() + m_Cmp->m_Pos );
  313. }
  314. LIB_PART* entry = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name );
  315. if( entry && entry->IsPower() )
  316. m_FieldsBuf[VALUE].SetText( m_Cmp->m_part_name );
  317. // copy all the fields back, and change the length of m_Fields.
  318. m_Cmp->SetFields( m_FieldsBuf );
  319. // Reference has a specific initialization, depending on the current active sheet
  320. // because for a given component, in a complex hierarchy, there are more than one
  321. // reference.
  322. m_Cmp->SetRef( &m_Parent->GetCurrentSheet(), m_FieldsBuf[REFERENCE].GetText() );
  323. m_Parent->OnModify();
  324. m_Parent->GetScreen()->TestDanglingEnds();
  325. m_Parent->GetCanvas()->Refresh( true );
  326. EndQuasiModal( wxID_OK );
  327. }
  328. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::addFieldButtonHandler( wxCommandEvent& event )
  329. {
  330. // in case m_FieldsBuf[REFERENCE].m_Orient has changed on screen only, grab
  331. // screen contents.
  332. if( !copyPanelToSelectedField() )
  333. return;
  334. unsigned fieldNdx = m_FieldsBuf.size();
  335. SCH_FIELD blank( wxPoint(), fieldNdx, m_Cmp );
  336. blank.SetOrientation( m_FieldsBuf[REFERENCE].GetOrientation() );
  337. m_FieldsBuf.push_back( blank );
  338. m_FieldsBuf[fieldNdx].SetName( TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx ) );
  339. m_skipCopyFromPanel = true;
  340. setRowItem( fieldNdx, m_FieldsBuf[fieldNdx] );
  341. setSelectedFieldNdx( fieldNdx );
  342. m_skipCopyFromPanel = false;
  343. }
  344. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::deleteFieldButtonHandler( wxCommandEvent& event )
  345. {
  346. unsigned fieldNdx = getSelectedFieldNdx();
  347. if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
  348. return;
  349. if( fieldNdx < MANDATORY_FIELDS )
  350. {
  351. wxBell();
  352. return;
  353. }
  354. m_skipCopyFromPanel = true;
  355. m_FieldsBuf.erase( m_FieldsBuf.begin() + fieldNdx );
  356. fieldListCtrl->DeleteItem( fieldNdx );
  357. if( fieldNdx >= m_FieldsBuf.size() )
  358. --fieldNdx;
  359. updateDisplay();
  360. setSelectedFieldNdx( fieldNdx );
  361. m_skipCopyFromPanel = false;
  362. }
  363. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler( wxCommandEvent& event )
  364. {
  365. unsigned fieldNdx = getSelectedFieldNdx();
  366. if( fieldNdx == DATASHEET )
  367. {
  368. wxString datasheet_uri = fieldValueTextCtrl->GetValue();
  369. ::wxLaunchDefaultBrowser( datasheet_uri );
  370. }
  371. else if( fieldNdx == FOOTPRINT )
  372. {
  373. // pick a footprint using the footprint picker.
  374. wxString fpid;
  375. KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
  376. if( frame->ShowModal( &fpid, this ) )
  377. {
  378. // DBG( printf( "%s: %s\n", __func__, TO_UTF8( fpid ) ); )
  379. fieldValueTextCtrl->SetValue( fpid );
  380. }
  381. frame->Destroy();
  382. }
  383. }
  384. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& event )
  385. {
  386. unsigned fieldNdx = getSelectedFieldNdx();
  387. if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
  388. return;
  389. if( fieldNdx <= MANDATORY_FIELDS )
  390. {
  391. wxBell();
  392. return;
  393. }
  394. if( !copyPanelToSelectedField() )
  395. return;
  396. // swap the fieldNdx field with the one before it, in both the vector
  397. // and in the fieldListCtrl
  398. SCH_FIELD tmp = m_FieldsBuf[fieldNdx - 1];
  399. DBG( printf( "tmp.m_Text=\"%s\" tmp.m_Name=\"%s\"\n",
  400. TO_UTF8( tmp.GetText() ), TO_UTF8( tmp.GetName( false ) ) ); )
  401. m_FieldsBuf[fieldNdx - 1] = m_FieldsBuf[fieldNdx];
  402. setRowItem( fieldNdx - 1, m_FieldsBuf[fieldNdx] );
  403. m_FieldsBuf[fieldNdx] = tmp;
  404. setRowItem( fieldNdx, tmp );
  405. updateDisplay();
  406. m_skipCopyFromPanel = true;
  407. setSelectedFieldNdx( fieldNdx - 1 );
  408. m_skipCopyFromPanel = false;
  409. }
  410. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setSelectedFieldNdx( int aFieldNdx )
  411. {
  412. /* deselect old selection, but I think this is done by single selection
  413. * flag within fieldListCtrl.
  414. * fieldListCtrl->SetItemState( s_SelectedRow, 0,
  415. * wxLIST_STATE_SELECTED|wxLIST_STATE_FOCUSED);
  416. */
  417. if( aFieldNdx >= (int) m_FieldsBuf.size() )
  418. aFieldNdx = m_FieldsBuf.size() - 1;
  419. if( aFieldNdx < 0 )
  420. aFieldNdx = 0;
  421. fieldListCtrl->SetItemState( aFieldNdx, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
  422. fieldListCtrl->EnsureVisible( aFieldNdx );
  423. s_SelectedRow = aFieldNdx;
  424. }
  425. int DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::getSelectedFieldNdx()
  426. {
  427. return s_SelectedRow;
  428. }
  429. SCH_FIELD* DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::findField( const wxString& aFieldName )
  430. {
  431. for( unsigned i=0; i<m_FieldsBuf.size(); ++i )
  432. {
  433. if( aFieldName == m_FieldsBuf[i].GetName( false ) )
  434. return &m_FieldsBuf[i];
  435. }
  436. return NULL;
  437. }
  438. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers( SCH_COMPONENT* aComponent )
  439. {
  440. m_Cmp = aComponent;
  441. /* We have 3 component related field lists to be aware of: 1) UI
  442. presentation, 2) fields in component ram copy, and 3) fields recorded
  443. with component on disk. m_FieldsBuf is the list of UI fields, and this
  444. list is not the same as the list which is in the component, which is
  445. also not the same as the list on disk. All 3 lists are potentially
  446. different. In the UI we choose to preserve the order of the first
  447. MANDATORY_FIELDS which are sometimes called fixed fields. Then we append
  448. the template fieldnames in the exact same order as the template
  449. fieldname editor shows them. Then we append any user defined fieldnames
  450. which came from the component.
  451. */
  452. m_part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name );
  453. #if 0 && defined(DEBUG)
  454. for( int i = 0; i<aComponent->GetFieldCount(); ++i )
  455. {
  456. printf( "Orig[%d] (x=%d, y=%d)\n", i, aComponent->m_Fields[i].GetTextPosition().x,
  457. aComponent->m_Fields[i].GetTextPosition().y );
  458. }
  459. #endif
  460. // When this code was written, all field constructors ensure that the fixed fields
  461. // are all present within a component. So we can knowingly copy them over
  462. // in the normal order. Copy only the fixed fields at first.
  463. // Please do not break the field constructors.
  464. m_FieldsBuf.clear();
  465. for( int i=0; i<MANDATORY_FIELDS; ++i )
  466. {
  467. m_FieldsBuf.push_back( aComponent->m_Fields[i] );
  468. // make the editable field position relative to the component
  469. m_FieldsBuf[i].SetTextPosition( m_FieldsBuf[i].GetTextPosition() - m_Cmp->m_Pos );
  470. }
  471. // Add template fieldnames:
  472. // Now copy in the template fields, in the order that they are present in the
  473. // template field editor UI.
  474. const TEMPLATE_FIELDNAMES& tfnames = m_Parent->GetTemplateFieldNames();
  475. for( TEMPLATE_FIELDNAMES::const_iterator it = tfnames.begin(); it!=tfnames.end(); ++it )
  476. {
  477. // add a new field unconditionally to the UI only
  478. SCH_FIELD fld( wxPoint(0,0), -1 /* id is a relic */, m_Cmp, it->m_Name );
  479. // See if field by same name already exists in component.
  480. SCH_FIELD* schField = aComponent->FindField( it->m_Name );
  481. // If the field does not already exist in the component, then we
  482. // use defaults from the template fieldname, otherwise the original
  483. // values from the component will be set.
  484. if( !schField )
  485. {
  486. if( !it->m_Visible )
  487. fld.SetVisible( false );
  488. else
  489. fld.SetVisible( true );
  490. fld.SetText( it->m_Value ); // empty? ok too.
  491. }
  492. else
  493. {
  494. fld = *schField;
  495. // make the editable field position relative to the component
  496. fld.SetTextPosition( fld.GetTextPosition() - m_Cmp->m_Pos );
  497. }
  498. m_FieldsBuf.push_back( fld );
  499. }
  500. // Lastly, append any original fields from the component which were not added
  501. // from the set of fixed fields nor from the set of template fields.
  502. for( unsigned i=MANDATORY_FIELDS; i<aComponent->m_Fields.size(); ++i )
  503. {
  504. SCH_FIELD* cmp = &aComponent->m_Fields[i];
  505. SCH_FIELD* buf = findField( cmp->GetName( false ) );
  506. if( !buf )
  507. {
  508. int newNdx = m_FieldsBuf.size();
  509. m_FieldsBuf.push_back( *cmp );
  510. // make the editable field position relative to the component
  511. m_FieldsBuf[newNdx].SetTextPosition( m_FieldsBuf[newNdx].GetTextPosition() -
  512. m_Cmp->m_Pos );
  513. }
  514. }
  515. #if 0 && defined(DEBUG)
  516. for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
  517. {
  518. printf( "m_FieldsBuf[%d] (x=%-3d, y=%-3d) name:%s\n", i, m_FieldsBuf[i].m_Pos.x,
  519. m_FieldsBuf[i].m_Pos.y, TO_UTF8(m_FieldsBuf[i].GetName( false ) ) );
  520. }
  521. #endif
  522. m_FieldsBuf[REFERENCE].SetText( m_Cmp->GetRef( &m_Parent->GetCurrentSheet() ) );
  523. for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
  524. {
  525. setRowItem( i, m_FieldsBuf[i] );
  526. }
  527. #if 0 && defined(DEBUG)
  528. for( unsigned i = 0; i<m_FieldsBuf.size(); ++i )
  529. {
  530. printf( "after[%d] (x=%d, y=%d)\n", i, m_FieldsBuf[i].m_Pos.x,
  531. m_FieldsBuf[i].m_Pos.y );
  532. }
  533. #endif
  534. copyOptionsToPanel();
  535. // disable some options inside the edit dialog
  536. // which can cause problems while dragging
  537. if( m_Cmp->IsDragging() )
  538. {
  539. orientationRadioBox->Disable();
  540. mirrorRadioBox->Disable();
  541. chipnameTextCtrl->Disable();
  542. }
  543. // put focus on the list ctrl
  544. fieldListCtrl->SetFocus();
  545. // resume editing at the last row edited, last time dialog was up.
  546. setSelectedFieldNdx( s_SelectedRow );
  547. }
  548. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::setRowItem( int aFieldNdx, const SCH_FIELD& aField )
  549. {
  550. wxASSERT( aFieldNdx >= 0 );
  551. // insert blanks if aFieldNdx is referencing a "yet to be defined" row
  552. while( aFieldNdx >= fieldListCtrl->GetItemCount() )
  553. {
  554. long ndx = fieldListCtrl->InsertItem( fieldListCtrl->GetItemCount(), wxEmptyString );
  555. wxASSERT( ndx >= 0 );
  556. fieldListCtrl->SetItem( ndx, 1, wxEmptyString );
  557. }
  558. fieldListCtrl->SetItem( aFieldNdx, 0, aField.GetName( false ) );
  559. fieldListCtrl->SetItem( aFieldNdx, 1, aField.GetText() );
  560. // recompute the column widths here, after setting texts
  561. fieldListCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
  562. fieldListCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
  563. }
  564. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
  565. {
  566. unsigned fieldNdx = getSelectedFieldNdx();
  567. if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
  568. return;
  569. SCH_FIELD& field = m_FieldsBuf[fieldNdx];
  570. showCheckBox->SetValue( field.IsVisible() );
  571. rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
  572. int style = 0;
  573. if( field.IsItalic() )
  574. style = 1;
  575. if( field.IsBold() )
  576. style |= 2;
  577. m_StyleRadioBox->SetSelection( style );
  578. // Select the right text justification
  579. if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
  580. m_FieldHJustifyCtrl->SetSelection( 0 );
  581. else if( field.GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
  582. m_FieldHJustifyCtrl->SetSelection( 2 );
  583. else
  584. m_FieldHJustifyCtrl->SetSelection( 1 );
  585. if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_BOTTOM )
  586. m_FieldVJustifyCtrl->SetSelection( 0 );
  587. else if( field.GetVertJustify() == GR_TEXT_VJUSTIFY_TOP )
  588. m_FieldVJustifyCtrl->SetSelection( 2 );
  589. else
  590. m_FieldVJustifyCtrl->SetSelection( 1 );
  591. fieldNameTextCtrl->SetValue( field.GetName( false ) );
  592. // the names of the fixed fields are not editable, others are.
  593. fieldNameTextCtrl->Enable( fieldNdx >= MANDATORY_FIELDS );
  594. fieldNameTextCtrl->SetEditable( fieldNdx >= MANDATORY_FIELDS );
  595. // only user defined fields may be moved, and not the top most user defined
  596. // field since it would be moving up into the fixed fields, > not >=
  597. moveUpButton->Enable( fieldNdx > MANDATORY_FIELDS );
  598. // may only delete user defined fields
  599. deleteFieldButton->Enable( fieldNdx >= MANDATORY_FIELDS );
  600. fieldValueTextCtrl->SetValue( field.GetText() );
  601. m_show_datasheet_button->Enable( fieldNdx == DATASHEET || fieldNdx == FOOTPRINT );
  602. if( fieldNdx == DATASHEET )
  603. m_show_datasheet_button->SetLabel( _( "Show in Browser" ) );
  604. else if( fieldNdx == FOOTPRINT )
  605. m_show_datasheet_button->SetLabel( _( "Assign Footprint" ) );
  606. else
  607. m_show_datasheet_button->SetLabel( wxEmptyString );
  608. // For power symbols, the value is NOR editable, because value and pin
  609. // name must be same and can be edited only in library editor
  610. if( fieldNdx == VALUE && m_part && m_part->IsPower() )
  611. fieldValueTextCtrl->Enable( false );
  612. else
  613. fieldValueTextCtrl->Enable( true );
  614. textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.GetSize().x ) );
  615. wxPoint coord = field.GetTextPosition();
  616. wxPoint zero = -m_Cmp->m_Pos; // relative zero
  617. // If the field value is empty and the position is at relative zero, we
  618. // set the initial position as a small offset from the ref field, and
  619. // orient it the same as the ref field. That is likely to put it at least
  620. // close to the desired position.
  621. if( coord == zero && field.GetText().IsEmpty() )
  622. {
  623. rotateCheckBox->SetValue( m_FieldsBuf[REFERENCE].GetOrientation() == TEXT_ORIENT_VERT );
  624. coord.x = m_FieldsBuf[REFERENCE].GetTextPosition().x
  625. + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
  626. coord.y = m_FieldsBuf[REFERENCE].GetTextPosition().y
  627. + ( fieldNdx - MANDATORY_FIELDS + 1 ) * 100;
  628. // coord can compute negative if field is < MANDATORY_FIELDS, e.g. FOOTPRINT.
  629. // That is ok, we basically don't want all the new empty fields on
  630. // top of each other.
  631. }
  632. wxString coordText = StringFromValue( g_UserUnit, coord.x );
  633. posXTextCtrl->SetValue( coordText );
  634. coordText = StringFromValue( g_UserUnit, coord.y );
  635. posYTextCtrl->SetValue( coordText );
  636. }
  637. bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
  638. {
  639. unsigned fieldNdx = getSelectedFieldNdx();
  640. if( fieldNdx >= m_FieldsBuf.size() ) // traps the -1 case too
  641. return true;
  642. SCH_FIELD& field = m_FieldsBuf[fieldNdx];
  643. field.SetVisible( showCheckBox->GetValue() );
  644. if( rotateCheckBox->GetValue() )
  645. field.SetOrientation( TEXT_ORIENT_VERT );
  646. else
  647. field.SetOrientation( TEXT_ORIENT_HORIZ );
  648. rotateCheckBox->SetValue( field.GetOrientation() == TEXT_ORIENT_VERT );
  649. // Copy the text justification
  650. static const EDA_TEXT_HJUSTIFY_T hjustify[] = {
  651. GR_TEXT_HJUSTIFY_LEFT,
  652. GR_TEXT_HJUSTIFY_CENTER,
  653. GR_TEXT_HJUSTIFY_RIGHT
  654. };
  655. static const EDA_TEXT_VJUSTIFY_T vjustify[] = {
  656. GR_TEXT_VJUSTIFY_BOTTOM,
  657. GR_TEXT_VJUSTIFY_CENTER,
  658. GR_TEXT_VJUSTIFY_TOP
  659. };
  660. field.SetHorizJustify( hjustify[m_FieldHJustifyCtrl->GetSelection()] );
  661. field.SetVertJustify( vjustify[m_FieldVJustifyCtrl->GetSelection()] );
  662. field.SetName( fieldNameTextCtrl->GetValue() );
  663. /* Void fields texts for REFERENCE and VALUE (value is the name of the
  664. * component in lib ! ) are not allowed
  665. * change them only for a new non void value
  666. * When void, usually netlists are broken
  667. */
  668. if( !fieldValueTextCtrl->GetValue().IsEmpty() || fieldNdx > VALUE )
  669. field.SetText( fieldValueTextCtrl->GetValue() );
  670. setRowItem( fieldNdx, field ); // update fieldListCtrl
  671. int tmp = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
  672. field.SetSize( wxSize( tmp, tmp ) );
  673. int style = m_StyleRadioBox->GetSelection();
  674. field.SetItalic( (style & 1 ) != 0 );
  675. field.SetBold( (style & 2 ) != 0 );
  676. wxPoint pos;
  677. pos.x = ValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
  678. pos.y = ValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
  679. field.SetTextPosition( pos );
  680. return true;
  681. }
  682. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
  683. {
  684. int choiceCount = unitChoice->GetCount();
  685. // Remove non existing choices (choiceCount must be <= number for parts)
  686. int unitcount = m_part ? m_part->GetUnitCount() : 1;
  687. if( unitcount < 1 )
  688. unitcount = 1;
  689. if( unitcount < choiceCount )
  690. {
  691. while( unitcount < choiceCount )
  692. {
  693. choiceCount--;
  694. unitChoice->Delete( choiceCount );
  695. }
  696. }
  697. // For components with multiple parts per package, set the unit selection
  698. choiceCount = unitChoice->GetCount();
  699. if( m_Cmp->GetUnit() <= choiceCount )
  700. unitChoice->SetSelection( m_Cmp->GetUnit() - 1 );
  701. // Disable unit selection if only one unit exists:
  702. if( choiceCount <= 1 )
  703. {
  704. unitChoice->Enable( false );
  705. unitsInterchageableLabel->Show( false );
  706. unitsInterchageableText->Show( false );
  707. }
  708. else
  709. {
  710. // Show the "Units are not interchangeable" message option?
  711. if( !m_part || !m_part->UnitsLocked() )
  712. unitsInterchageableLabel->SetLabel( _("Yes") );
  713. else
  714. unitsInterchageableLabel->SetLabel( _("No") );
  715. }
  716. int orientation = m_Cmp->GetOrientation()
  717. & ~( CMP_MIRROR_X | CMP_MIRROR_Y );
  718. if( orientation == CMP_ORIENT_90 )
  719. orientationRadioBox->SetSelection( 1 );
  720. else if( orientation == CMP_ORIENT_180 )
  721. orientationRadioBox->SetSelection( 2 );
  722. else if( orientation == CMP_ORIENT_270 )
  723. orientationRadioBox->SetSelection( 3 );
  724. else
  725. orientationRadioBox->SetSelection( 0 );
  726. int mirror = m_Cmp->GetOrientation() & ( CMP_MIRROR_X | CMP_MIRROR_Y );
  727. if( mirror == CMP_MIRROR_X )
  728. {
  729. mirrorRadioBox->SetSelection( 1 );
  730. DBG( printf( "mirror=X,1\n" ); )
  731. }
  732. else if( mirror == CMP_MIRROR_Y )
  733. {
  734. mirrorRadioBox->SetSelection( 2 );
  735. DBG( printf( "mirror=Y,2\n" ); )
  736. }
  737. else
  738. mirrorRadioBox->SetSelection( 0 );
  739. // Activate/Desactivate the normal/convert option ? (activated only if
  740. // the component has more than one shape)
  741. if( m_Cmp->GetConvert() > 1 )
  742. convertCheckBox->SetValue( true );
  743. if( m_part == NULL || !m_part->HasConversion() )
  744. convertCheckBox->Enable( false );
  745. // Set the component's library name.
  746. chipnameTextCtrl->SetValue( m_Cmp->m_part_name );
  747. // Set the component's unique ID time stamp.
  748. m_textCtrlTimeStamp->SetValue( wxString::Format( wxT("%8.8lX"),
  749. (unsigned long) m_Cmp->GetTimeStamp() ) );
  750. }
  751. #include <kicad_device_context.h>
  752. /* reinitialize components parameters to default values found in lib
  753. */
  754. void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp( wxCommandEvent& event )
  755. {
  756. if( !m_Cmp )
  757. return;
  758. if( LIB_PART* part = Prj().SchLibs()->FindLibPart( m_Cmp->m_part_name ) )
  759. {
  760. // save old cmp in undo list if not already in edit, or moving ...
  761. if( m_Cmp->m_Flags == 0 )
  762. m_Parent->SaveCopyInUndoList( m_Cmp, UR_CHANGED );
  763. INSTALL_UNBUFFERED_DC( dc, m_Parent->GetCanvas() );
  764. m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), g_XorMode );
  765. // Initialize fixed field values to default values found in library
  766. // Note: the field texts are not modified because they are set in schematic,
  767. // the text from libraries is most of time a dummy text
  768. // Only VALUE, REFERENCE , FOOTPRINT and DATASHEET are re-initialized
  769. LIB_FIELD& refField = part->GetReferenceField();
  770. m_Cmp->GetField( REFERENCE )->SetTextPosition( refField.GetTextPosition() + m_Cmp->m_Pos );
  771. m_Cmp->GetField( REFERENCE )->ImportValues( refField );
  772. LIB_FIELD& valField = part->GetValueField();
  773. m_Cmp->GetField( VALUE )->SetTextPosition( valField.GetTextPosition() + m_Cmp->m_Pos );
  774. m_Cmp->GetField( VALUE )->ImportValues( valField );
  775. LIB_FIELD* field = part->GetField(FOOTPRINT);
  776. if( field && m_Cmp->GetField( FOOTPRINT ) )
  777. {
  778. m_Cmp->GetField( FOOTPRINT )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
  779. m_Cmp->GetField( FOOTPRINT )->ImportValues( *field );
  780. }
  781. field = part->GetField(DATASHEET);
  782. if( field && m_Cmp->GetField( DATASHEET ) )
  783. {
  784. m_Cmp->GetField( DATASHEET )->SetTextPosition( field->GetTextPosition() + m_Cmp->m_Pos );
  785. m_Cmp->GetField( DATASHEET )->ImportValues( *field );
  786. }
  787. m_Cmp->SetOrientation( CMP_NORMAL );
  788. m_Parent->OnModify();
  789. m_Cmp->Draw( m_Parent->GetCanvas(), &dc, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
  790. EndQuasiModal( wxID_OK );
  791. }
  792. }