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.

444 lines
14 KiB

* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
Modular-Kicad milestone B), major portions: *) Rework the set language support, simplify it by using KIWAY. Now any major frame with a "change language" menu can change the language for all KIWAY_PLAYERs in the whole KIWAY. Multiple KIWAYs are not supported yet. *) Simplify "modal wxFrame" support, and add that support exclusively to KIWAY_PLAYER where it is inherited by all derivatives. The function KIWAY_PLAYER::ShowModal() is in the vtable and so is cross module capable. *) Remove the requirements and assumptions that the wxFrame hierarchy always had PCB_EDIT_FRAME and SCH_EDIT_FRAME as immediate parents of their viewers and editors. This is no longer the case, nor required. *) Use KIWAY::Player() everywhere to make KIWAY_PLAYERs, this registers the KIWAY_PLAYER within the KIWAY and makes it very easy to find an open frame quickly. It also gives control to the KIWAY as to frame hierarchical relationships. *) Change single_top to use the KIWAY for loading a KIFACE and instantiating the single KIWAY_PLAYER, see bullet immediately above. *) Add KIWAY::OnKiwayEnd() and call it from PGM_BASE at program termination, this gives the KIFACEs a chance to save their final configuration dope to disk. *) Add dedicated FRAME_T's for the modal frames, so m_Ident can be tested and these modal frames are distinctly different than their non-modal equivalents. KIWAY_PLAYER::IsModal() is !not! a valid test during the wxFrame's constructor, so this is another important reason for having a dedicated FRAME_T for each modal wxFrame. On balance, more lines were deleted than were added to achieve all this.
12 years ago
* 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
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
  6. * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /**
  26. * @file getpart.cpp
  27. * @brief functions to get and place library components.
  28. */
  29. #include <algorithm>
  30. #include <fctsys.h>
  31. #include <pgm_base.h>
  32. #include <kiway.h>
  33. #include <gr_basic.h>
  34. #include <sch_draw_panel.h>
  35. #include <confirm.h>
  36. #include <sch_edit_frame.h>
  37. #include <kicad_device_context.h>
  38. #include <msgpanel.h>
  39. #include <general.h>
  40. #include <class_library.h>
  41. #include <sch_component.h>
  42. #include <lib_edit_frame.h>
  43. #include <viewlib_frame.h>
  44. #include <eeschema_id.h>
  45. #include <symbol_lib_table.h>
  46. #include <dialog_choose_component.h>
  47. #include <symbol_tree_model_adapter.h>
  48. SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser(
  49. wxTopLevelWindow* aParent,
  50. const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId,
  51. int aUnit, int aConvert )
  52. {
  53. // Close any open non-modal Lib browser, and open a new one, in "modal" mode:
  54. LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
  55. if( viewlibFrame )
  56. viewlibFrame->Destroy();
  57. viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER_MODAL, true, aParent );
  58. if( aFilter )
  59. viewlibFrame->SetFilter( aFilter );
  60. if( aPreselectedLibId.IsValid() )
  61. {
  62. viewlibFrame->SetSelectedLibrary( aPreselectedLibId.GetLibNickname() );
  63. viewlibFrame->SetSelectedComponent( aPreselectedLibId.GetLibItemName() );
  64. }
  65. viewlibFrame->SetUnitAndConvert( aUnit, aConvert );
  66. viewlibFrame->Refresh();
  67. COMPONENT_SELECTION sel;
  68. wxString symbol = sel.LibId.Format();
  69. if( viewlibFrame->ShowModal( &symbol, aParent ) )
  70. {
  71. LIB_ID id;
  72. if( id.Parse( symbol, LIB_ID::ID_SCH ) == -1 )
  73. sel.LibId = id;
  74. sel.Unit = viewlibFrame->GetUnit();
  75. sel.Convert = viewlibFrame->GetConvert();
  76. }
  77. viewlibFrame->Destroy();
  78. return sel;
  79. }
  80. SCH_BASE_FRAME::COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibTree(
  81. const SCHLIB_FILTER* aFilter,
  82. std::vector<COMPONENT_SELECTION>& aHistoryList,
  83. bool aAllowBrowser,
  84. int aUnit,
  85. int aConvert,
  86. bool aShowFootprints,
  87. const LIB_ID* aHighlight,
  88. bool aAllowFields )
  89. {
  90. std::unique_lock<std::mutex> dialogLock( DIALOG_CHOOSE_COMPONENT::g_Mutex, std::defer_lock );
  91. wxString dialogTitle;
  92. SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
  93. // One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway.
  94. if( !dialogLock.try_lock() )
  95. return COMPONENT_SELECTION();
  96. auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( libs ) );
  97. auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
  98. bool loaded = false;
  99. if( aFilter )
  100. {
  101. const wxArrayString& liblist = aFilter->GetAllowedLibList();
  102. for( unsigned ii = 0; ii < liblist.GetCount(); ii++ )
  103. {
  104. if( libs->HasLibrary( liblist[ii], true ) )
  105. {
  106. loaded = true;
  107. adapter->AddLibrary( liblist[ii] );
  108. }
  109. }
  110. adapter->AssignIntrinsicRanks();
  111. if( aFilter->GetFilterPowerParts() )
  112. adapter->SetFilter( SYMBOL_TREE_MODEL_ADAPTER::CMP_FILTER_POWER );
  113. }
  114. std::vector< LIB_TREE_ITEM* > history_list;
  115. for( auto const& i : aHistoryList )
  116. {
  117. LIB_ALIAS* alias = GetLibAlias( i.LibId );
  118. if( alias )
  119. history_list.push_back( alias );
  120. }
  121. adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, history_list, true );
  122. if( !aHistoryList.empty() )
  123. adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
  124. const std::vector< wxString > libNicknames = libs->GetLogicalLibs();
  125. if( !loaded )
  126. adapter->AddLibraries( libNicknames, this );
  127. if( aHighlight && aHighlight->IsValid() )
  128. adapter->SetPreselectNode( *aHighlight, /* aUnit */ 0 );
  129. if( adapter->GetFilter() == SYMBOL_TREE_MODEL_ADAPTER::CMP_FILTER_POWER )
  130. dialogTitle.Printf( _( "Choose Power Symbol (%d items loaded)" ), adapter->GetItemCount() );
  131. else
  132. dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() );
  133. DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, aConvert,
  134. aAllowFields, aShowFootprints, aAllowBrowser );
  135. if( dlg.ShowQuasiModal() == wxID_CANCEL )
  136. return COMPONENT_SELECTION();
  137. COMPONENT_SELECTION sel;
  138. LIB_ID id;
  139. if( dlg.IsExternalBrowserSelected() ) // User requested component browser.
  140. {
  141. sel = SelectComponentFromLibBrowser( this, aFilter, id, sel.Unit, sel.Convert );
  142. id = sel.LibId;
  143. }
  144. else
  145. id = dlg.GetSelectedLibId( &sel.Unit );
  146. if( !id.IsValid() ) // Dialog closed by OK button,
  147. // or the selection by lib browser was requested,
  148. // but no symbol selected
  149. return COMPONENT_SELECTION();
  150. if( sel.Unit == 0 )
  151. sel.Unit = 1;
  152. sel.Fields = dlg.GetFields();
  153. sel.LibId = id;
  154. if( sel.LibId.IsValid() )
  155. {
  156. aHistoryList.erase(
  157. std::remove_if(
  158. aHistoryList.begin(),
  159. aHistoryList.end(),
  160. [ &sel ]( COMPONENT_SELECTION const& i ){ return i.LibId == sel.LibId; } ),
  161. aHistoryList.end() );
  162. aHistoryList.insert( aHistoryList.begin(), sel );
  163. }
  164. return sel;
  165. }
  166. SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
  167. const SCHLIB_FILTER* aFilter,
  168. SCH_BASE_FRAME::HISTORY_LIST& aHistoryList,
  169. bool aAllowBrowser )
  170. {
  171. wxString msg;
  172. SetRepeatItem( NULL );
  173. m_canvas->SetIgnoreMouseEvents( true );
  174. auto sel = SelectComponentFromLibTree( aFilter, aHistoryList, aAllowBrowser, 1, 1,
  175. m_footprintPreview );
  176. if( !sel.LibId.IsValid() )
  177. {
  178. m_canvas->SetIgnoreMouseEvents( false );
  179. m_canvas->MoveCursorToCrossHair();
  180. return NULL;
  181. }
  182. m_canvas->SetIgnoreMouseEvents( false );
  183. m_canvas->MoveCursorToCrossHair();
  184. wxString libsource; // the library name to use. If empty, load from any lib
  185. if( aFilter )
  186. libsource = aFilter->GetLibSource();
  187. LIB_ID libId = sel.LibId;
  188. LIB_PART* part = GetLibPart( libId, true );
  189. if( !part )
  190. return NULL;
  191. SCH_COMPONENT* component = new SCH_COMPONENT( *part, m_CurrentSheet, sel.Unit, sel.Convert,
  192. GetCrossHairPosition(), true );
  193. // Set the m_ChipName value, from component name in lib, for aliases
  194. // Note if part is found, and if name is an alias of a component,
  195. // alias exists because its root component was found
  196. component->SetLibId( libId );
  197. // Be sure the link to the corresponding LIB_PART is OK:
  198. component->Resolve( *Prj().SchSymbolLibTable() );
  199. // Set any fields that have been modified
  200. for( auto const& i : sel.Fields )
  201. {
  202. auto field = component->GetField( i.first );
  203. if( field )
  204. field->SetText( i.second );
  205. }
  206. // Set the component value that can differ from component name in lib, for aliases
  207. component->GetField( VALUE )->SetText( sel.LibId.GetLibItemName() );
  208. // If there is no field defined in the component, copy one over from the library
  209. // ( from the .dcm file )
  210. // This way the Datasheet field will not be empty and can be changed from the schematic
  211. if( component->GetField( DATASHEET )->GetText().IsEmpty() )
  212. {
  213. LIB_ALIAS* entry = GetLibAlias( component->GetLibId(), true, true );
  214. if( entry && !!entry->GetDocFileName() )
  215. component->GetField( DATASHEET )->SetText( entry->GetDocFileName() );
  216. }
  217. MSG_PANEL_ITEMS items;
  218. component->SetCurrentSheetPath( &GetCurrentSheet() );
  219. component->GetMsgPanelInfo( m_UserUnits, items );
  220. SetMsgPanel( items );
  221. component->SetFlags( IS_NEW );
  222. if( m_autoplaceFields )
  223. component->AutoplaceFields( /* aScreen */ NULL, /* aManual */ false );
  224. PrepareMoveItem( (SCH_ITEM*) component, aDC );
  225. return component;
  226. }
  227. void SCH_EDIT_FRAME::OrientComponent( COMPONENT_ORIENTATION_T aOrientation )
  228. {
  229. SCH_SCREEN* screen = GetScreen();
  230. SCH_ITEM* item = screen->GetCurItem();
  231. wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T,
  232. wxT( "Cannot change orientation of invalid schematic item." ) );
  233. SCH_COMPONENT* component = (SCH_COMPONENT*) item;
  234. m_canvas->MoveCursorToCrossHair();
  235. if( item->GetFlags() == 0 )
  236. SetUndoItem( item );
  237. component->SetOrientation( aOrientation );
  238. m_canvas->CrossHairOn( );
  239. if( item->GetFlags() == 0 )
  240. {
  241. addCurrentItemToList();
  242. SchematicCleanUp( true );
  243. }
  244. if( GetScreen()->TestDanglingEnds() )
  245. m_canvas->Refresh();
  246. OnModify();
  247. }
  248. void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
  249. {
  250. SCH_SCREEN* screen = GetScreen();
  251. SCH_ITEM* item = screen->GetCurItem();
  252. wxCHECK_RET( item != NULL && item->Type() == SCH_COMPONENT_T,
  253. wxT( "Cannot select unit of invalid schematic item." ) );
  254. //fixme-gal
  255. //INSTALL_UNBUFFERED_DC( dc, m_canvas );
  256. m_canvas->MoveCursorToCrossHair();
  257. SCH_COMPONENT* component = (SCH_COMPONENT*) item;
  258. int unit = aEvent.GetId() + 1 - ID_POPUP_SCH_SELECT_UNIT1;
  259. LIB_PART* part = GetLibPart( component->GetLibId() );
  260. if( !part )
  261. return;
  262. int unitCount = part->GetUnitCount();
  263. wxCHECK_RET( (unit >= 1) && (unit <= unitCount),
  264. wxString::Format( wxT( "Cannot select unit %d from component " ), unit ) +
  265. part->GetName() );
  266. if( unitCount <= 1 || component->GetUnit() == unit )
  267. return;
  268. if( unit > unitCount )
  269. unit = unitCount;
  270. STATUS_FLAGS flags = component->GetFlags();
  271. if( !flags ) // No command in progress: save in undo list
  272. SaveCopyInUndoList( component, UR_CHANGED );
  273. //if( flags )
  274. //component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
  275. //else
  276. //component->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
  277. /* Update the unit number. */
  278. component->SetUnitSelection( m_CurrentSheet, unit );
  279. component->SetUnit( unit );
  280. component->ClearFlags();
  281. component->SetFlags( flags ); // Restore m_Flag modified by SetUnit()
  282. if( m_autoplaceFields )
  283. component->AutoAutoplaceFields( GetScreen() );
  284. if( screen->TestDanglingEnds() )
  285. m_canvas->Refresh();
  286. OnModify();
  287. }
  288. void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent, wxDC* DC )
  289. {
  290. if( !aComponent )
  291. return;
  292. LIB_ID id = aComponent->GetLibId();
  293. LIB_PART* part = GetLibPart( id );
  294. if( part )
  295. {
  296. wxString msg;
  297. if( !part->HasConversion() )
  298. {
  299. msg.Printf( _( "No alternate body style found for symbol \"%s\" in library \"%s\"." ),
  300. id.GetLibItemName().wx_str(), id.GetLibNickname().wx_str() );
  301. DisplayError( this, msg );
  302. return;
  303. }
  304. STATUS_FLAGS flags = aComponent->GetFlags();
  305. if( aComponent->GetFlags() )
  306. aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
  307. else
  308. aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
  309. aComponent->SetConvert( aComponent->GetConvert() + 1 );
  310. // ensure m_Convert = 0, 1 or 2
  311. // 0 and 1 = shape 1 = not converted
  312. // 2 = shape 2 = first converted shape
  313. // > 2 is not used but could be used for more shapes
  314. // like multiple shapes for a programmable component
  315. // When m_Convert = val max, return to the first shape
  316. if( aComponent->GetConvert() > 2 )
  317. aComponent->SetConvert( 1 );
  318. // The alternate symbol may cause a change in the connection status so test the
  319. // connections so the connection indicators are drawn correctly.
  320. GetScreen()->TestDanglingEnds();
  321. aComponent->ClearFlags();
  322. aComponent->SetFlags( flags ); // Restore m_Flag (modified by SetConvert())
  323. /* Redraw the component in the new position. */
  324. if( aComponent->IsMoving() )
  325. aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
  326. else
  327. aComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
  328. OnModify();
  329. }
  330. }