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.

665 lines
22 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 Rivos
  5. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Wayne Stambaugh <stambaughw@gmail.com>
  8. *
  9. * This program is free software: you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation, either version 3 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #include <wx/log.h>
  23. #include <wx/wupdlock.h>
  24. #include <core/profile.h>
  25. #include <tool/tool_manager.h>
  26. #include <kiface_base.h>
  27. #include <sch_edit_frame.h>
  28. #include <sch_bus_entry.h>
  29. #include <sch_line.h>
  30. #include <sch_junction.h>
  31. #include <sch_no_connect.h>
  32. #include <sch_sheet_pin.h>
  33. #include <string_utils.h>
  34. #include <trace_helpers.h>
  35. #include <connection_graph.h>
  36. #include <widgets/wx_aui_utils.h>
  37. #include <tools/sch_actions.h>
  38. static wxString GetNetNavigatorItemText( const SCH_ITEM* aItem,
  39. const SCH_SHEET_PATH& aSheetPath,
  40. UNITS_PROVIDER* aUnitsProvider )
  41. {
  42. wxString retv;
  43. wxCHECK( aItem && aUnitsProvider, retv );
  44. switch( aItem->Type() )
  45. {
  46. case SCH_LINE_T:
  47. {
  48. const SCH_LINE* line = static_cast<const SCH_LINE*>( aItem );
  49. if( aItem->GetLayer() == LAYER_WIRE )
  50. {
  51. retv.Printf( _( "Wire from %s, %s to %s, %s" ),
  52. aUnitsProvider->MessageTextFromValue( line->GetStartPoint().x ),
  53. aUnitsProvider->MessageTextFromValue( line->GetStartPoint().y ),
  54. aUnitsProvider->MessageTextFromValue( line->GetEndPoint().x ),
  55. aUnitsProvider->MessageTextFromValue( line->GetEndPoint().y ) );
  56. }
  57. else if( aItem->GetLayer() == LAYER_BUS )
  58. {
  59. retv.Printf( _( "Bus from %s, %s to %s, %s" ),
  60. aUnitsProvider->MessageTextFromValue( line->GetStartPoint().x ),
  61. aUnitsProvider->MessageTextFromValue( line->GetStartPoint().y ),
  62. aUnitsProvider->MessageTextFromValue( line->GetEndPoint().x ),
  63. aUnitsProvider->MessageTextFromValue( line->GetEndPoint().y ) );
  64. }
  65. else
  66. {
  67. retv = _( "Graphic line not connectable" );
  68. }
  69. break;
  70. }
  71. case SCH_PIN_T:
  72. {
  73. const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem );
  74. if( const SYMBOL* symbol = pin->GetParentSymbol() )
  75. {
  76. retv.Printf( _( "Symbol '%s' pin '%s'" ),
  77. symbol->GetRef( &aSheetPath, true ),
  78. UnescapeString( pin->GetNumber() ) );
  79. if( wxString pinName = UnescapeString( pin->GetShownName() ); !pinName.IsEmpty() )
  80. {
  81. retv += wxString::Format( " (%s)", pinName );
  82. }
  83. }
  84. break;
  85. }
  86. case SCH_SHEET_PIN_T:
  87. {
  88. const SCH_SHEET_PIN* pin = static_cast<const SCH_SHEET_PIN*>( aItem );
  89. if( SCH_SHEET* sheet = pin->GetParent() )
  90. {
  91. retv.Printf( _( "Sheet '%s' pin '%s'" ),
  92. sheet->GetName(),
  93. UnescapeString( pin->GetText() ) );
  94. }
  95. break;
  96. }
  97. case SCH_LABEL_T:
  98. {
  99. const SCH_LABEL* label = static_cast<const SCH_LABEL*>( aItem );
  100. retv.Printf( _( "Label '%s' at %s, %s" ),
  101. UnescapeString( label->GetText() ),
  102. aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
  103. aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
  104. break;
  105. }
  106. case SCH_GLOBAL_LABEL_T:
  107. {
  108. const SCH_GLOBALLABEL* label = static_cast<const SCH_GLOBALLABEL*>( aItem );
  109. retv.Printf( _( "Global label '%s' at %s, %s" ),
  110. UnescapeString( label->GetText() ),
  111. aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
  112. aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
  113. break;
  114. }
  115. case SCH_HIER_LABEL_T:
  116. {
  117. const SCH_HIERLABEL* label = static_cast<const SCH_HIERLABEL*>( aItem );
  118. retv.Printf( _( "Hierarchical label '%s' at %s, %s" ),
  119. UnescapeString( label->GetText() ),
  120. aUnitsProvider->MessageTextFromValue( label->GetPosition().x ),
  121. aUnitsProvider->MessageTextFromValue( label->GetPosition().y ) );
  122. break;
  123. }
  124. case SCH_JUNCTION_T:
  125. {
  126. const SCH_JUNCTION* junction = static_cast<const SCH_JUNCTION*>( aItem );
  127. retv.Printf( _( "Junction at %s, %s" ),
  128. aUnitsProvider->MessageTextFromValue( junction->GetPosition().x ),
  129. aUnitsProvider->MessageTextFromValue( junction->GetPosition().y ) );
  130. break;
  131. }
  132. case SCH_NO_CONNECT_T:
  133. {
  134. const SCH_NO_CONNECT* nc = static_cast<const SCH_NO_CONNECT*>( aItem );
  135. retv.Printf( _( "No-Connect at %s, %s" ),
  136. aUnitsProvider->MessageTextFromValue( nc->GetPosition().x ),
  137. aUnitsProvider->MessageTextFromValue( nc->GetPosition().y ) );
  138. break;
  139. }
  140. case SCH_BUS_WIRE_ENTRY_T:
  141. {
  142. const SCH_BUS_WIRE_ENTRY* entry = static_cast<const SCH_BUS_WIRE_ENTRY*>( aItem );
  143. retv.Printf( _( "Bus to wire entry from %s, %s to %s, %s" ),
  144. aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
  145. aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ),
  146. aUnitsProvider->MessageTextFromValue( entry->GetEnd().x ),
  147. aUnitsProvider->MessageTextFromValue( entry->GetEnd().y ) );
  148. break;
  149. }
  150. case SCH_BUS_BUS_ENTRY_T:
  151. {
  152. const SCH_BUS_BUS_ENTRY* entry = static_cast<const SCH_BUS_BUS_ENTRY*>( aItem );
  153. retv.Printf( _( "Bus to bus entry from %s, %s to %s, %s" ),
  154. aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
  155. aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ),
  156. aUnitsProvider->MessageTextFromValue( entry->GetEnd().x ),
  157. aUnitsProvider->MessageTextFromValue( entry->GetEnd().y ) );
  158. break;
  159. }
  160. case SCH_DIRECTIVE_LABEL_T:
  161. {
  162. const SCH_DIRECTIVE_LABEL* entry = static_cast<const SCH_DIRECTIVE_LABEL*>( aItem );
  163. retv.Printf( _( "Netclass label '%s' at %s, %s" ),
  164. UnescapeString( entry->GetText() ),
  165. aUnitsProvider->MessageTextFromValue( entry->GetPosition().x ),
  166. aUnitsProvider->MessageTextFromValue( entry->GetPosition().y ) );
  167. break;
  168. }
  169. default:
  170. retv.Printf( _( "Unhandled item type %d" ), aItem->Type() );
  171. }
  172. return retv;
  173. }
  174. void SCH_EDIT_FRAME::MakeNetNavigatorNode( const wxString& aNetName, wxTreeItemId aParentId,
  175. const NET_NAVIGATOR_ITEM_DATA* aSelection,
  176. bool aSingleSheetSchematic )
  177. {
  178. wxCHECK( !aNetName.IsEmpty(), /* void */ );
  179. wxCHECK( m_schematic, /* void */ );
  180. wxCHECK( m_netNavigator, /* void */ );
  181. wxTreeItemId expandId = aParentId;
  182. CONNECTION_GRAPH* connectionGraph = m_schematic->ConnectionGraph();
  183. wxCHECK( connectionGraph, /* void */ );
  184. std::set<CONNECTION_SUBGRAPH*> subgraphs;
  185. {
  186. const std::vector<CONNECTION_SUBGRAPH*>& tmp = connectionGraph->GetAllSubgraphs( aNetName );
  187. subgraphs.insert( tmp.begin(), tmp.end() );
  188. }
  189. for( CONNECTION_SUBGRAPH* sg : subgraphs )
  190. {
  191. for( const auto& [_, bus_sgs] : sg->GetBusParents() )
  192. {
  193. for( const CONNECTION_SUBGRAPH* bus_sg : bus_sgs )
  194. {
  195. const std::vector<CONNECTION_SUBGRAPH*>& tmp =
  196. connectionGraph->GetAllSubgraphs( bus_sg->GetNetName() );
  197. subgraphs.insert( tmp.begin(), tmp.end() );
  198. }
  199. }
  200. }
  201. std::map<wxString, wxTreeItemId> sheetIds;
  202. for( const CONNECTION_SUBGRAPH* subGraph : subgraphs )
  203. {
  204. NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
  205. SCH_SHEET_PATH sheetPath = subGraph->GetSheet();
  206. wxCHECK2( subGraph && sheetPath.Last(), continue );
  207. if( subGraph->GetItems().empty() )
  208. continue;
  209. itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, nullptr );
  210. bool stripTrailingSeparator = !sheetPath.Last()->IsRootSheet();
  211. wxString txt = sheetPath.PathHumanReadable( true, stripTrailingSeparator );
  212. wxTreeItemId sheetId;
  213. if( auto sheetIdIt = sheetIds.find( txt ); sheetIdIt != sheetIds.end() )
  214. {
  215. sheetId = sheetIdIt->second;
  216. }
  217. else
  218. {
  219. sheetIds[txt] = m_netNavigator->AppendItem( aParentId, txt, -1, -1, itemData );
  220. sheetId = sheetIds[txt];
  221. }
  222. if( aSelection && *aSelection == *itemData )
  223. m_netNavigator->SelectItem( sheetId );
  224. // If there is only one sheet in the schematic, always expand the sheet tree.
  225. if( aSingleSheetSchematic )
  226. expandId = sheetId;
  227. for( const SCH_ITEM* item : subGraph->GetItems() )
  228. {
  229. if( item->Type() == SCH_LINE_T
  230. || item->Type() == SCH_JUNCTION_T
  231. || item->Type() == SCH_BUS_WIRE_ENTRY_T
  232. || item->Type() == SCH_BUS_BUS_ENTRY_T )
  233. {
  234. continue;
  235. }
  236. itemData = new NET_NAVIGATOR_ITEM_DATA( sheetPath, item );
  237. wxTreeItemId id = m_netNavigator->AppendItem( sheetId,
  238. GetNetNavigatorItemText( item, sheetPath, this ),
  239. -1, -1, itemData );
  240. if( aSelection && *aSelection == *itemData )
  241. {
  242. expandId = sheetId;
  243. m_netNavigator->EnsureVisible( id );
  244. m_netNavigator->SelectItem( id );
  245. }
  246. }
  247. m_netNavigator->SortChildren( sheetId );
  248. }
  249. // Sort the items in the tree control alphabetically
  250. m_netNavigator->SortChildren( aParentId );
  251. m_netNavigator->Expand( aParentId );
  252. }
  253. void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelection )
  254. {
  255. wxCHECK( m_netNavigator, /* void */ );
  256. if( !m_netNavigator->IsShown() )
  257. return;
  258. bool singleSheetSchematic = m_schematic->Hierarchy().size() == 1;
  259. size_t nodeCnt = 0;
  260. wxWindowUpdateLocker updateLock( m_netNavigator );
  261. PROF_TIMER timer;
  262. if( m_highlightedConn.IsEmpty() )
  263. {
  264. m_netNavigator->DeleteAllItems();
  265. // Create a tree of all nets in the schematic.
  266. wxTreeItemId rootId = m_netNavigator->AddRoot( _( "Nets" ), 0 );
  267. const NET_MAP& netMap = m_schematic->ConnectionGraph()->GetNetMap();
  268. for( const auto& net : netMap )
  269. {
  270. // Skip bus member subgraphs for the moment.
  271. if( net.first.Name.IsEmpty() )
  272. continue;
  273. nodeCnt++;
  274. wxTreeItemId netId = m_netNavigator->AppendItem( rootId, UnescapeString( net.first.Name ) );
  275. MakeNetNavigatorNode( net.first.Name, netId, aSelection, singleSheetSchematic );
  276. }
  277. m_netNavigator->Expand( rootId );
  278. }
  279. else if( !m_netNavigator->IsEmpty() )
  280. {
  281. const wxString shownNetName = m_netNavigator->GetItemText( m_netNavigator->GetRootItem() );
  282. if( shownNetName != m_highlightedConn )
  283. {
  284. m_netNavigator->DeleteAllItems();
  285. nodeCnt++;
  286. wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 );
  287. MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
  288. }
  289. else
  290. {
  291. NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
  292. wxTreeItemId selection = m_netNavigator->GetSelection();
  293. if( selection.IsOk() )
  294. itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
  295. m_netNavigator->DeleteAllItems();
  296. nodeCnt++;
  297. wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 );
  298. MakeNetNavigatorNode( m_highlightedConn, rootId, itemData, singleSheetSchematic );
  299. }
  300. }
  301. else
  302. {
  303. nodeCnt++;
  304. wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 );
  305. MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection, singleSheetSchematic );
  306. }
  307. timer.Stop();
  308. wxLogTrace( traceUiProfile, wxS( "Adding %zu nodes to net navigator took %s." ),
  309. nodeCnt, timer.to_string() );
  310. }
  311. const SCH_ITEM* SCH_EDIT_FRAME::SelectNextPrevNetNavigatorItem( bool aNext )
  312. {
  313. wxCHECK( m_netNavigator, nullptr );
  314. wxTreeItemId id = m_netNavigator->GetSelection();
  315. if( !id.IsOk() )
  316. return nullptr;
  317. wxTreeItemId nextId;
  318. wxTreeItemId netNode = m_netNavigator->GetRootItem();
  319. std::vector<wxTreeItemId> netItems;
  320. std::list<wxTreeItemId> itemList;
  321. itemList.push_back( netNode );
  322. while( !itemList.empty() )
  323. {
  324. wxTreeItemId current = itemList.front();
  325. itemList.pop_front();
  326. wxTreeItemIdValue cookie;
  327. wxTreeItemId child = m_netNavigator->GetFirstChild( current, cookie );
  328. while( child.IsOk() )
  329. {
  330. if( m_netNavigator->ItemHasChildren( child ) )
  331. itemList.push_back( child );
  332. else
  333. netItems.push_back( child );
  334. child = m_netNavigator->GetNextSibling( child );
  335. }
  336. }
  337. // Locate current item and move forward or backward with wrap
  338. auto it = std::find( netItems.begin(), netItems.end(), id );
  339. if( it != netItems.end() )
  340. {
  341. if( aNext )
  342. {
  343. ++it;
  344. if( it == netItems.end() )
  345. it = netItems.begin();
  346. }
  347. else
  348. {
  349. if( it == netItems.begin() )
  350. it = netItems.end();
  351. --it;
  352. }
  353. nextId = *it;
  354. }
  355. if( nextId.IsOk() )
  356. {
  357. if( !m_netNavigator->IsVisible( nextId ) )
  358. {
  359. m_netNavigator->CollapseAll();
  360. m_netNavigator->EnsureVisible( nextId );
  361. }
  362. m_netNavigator->UnselectAll();
  363. m_netNavigator->SelectItem( nextId );
  364. auto* data = static_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( nextId ) );
  365. if( data && data->GetItem() )
  366. return data->GetItem();
  367. }
  368. return nullptr;
  369. }
  370. void SCH_EDIT_FRAME::SelectNetNavigatorItem( const NET_NAVIGATOR_ITEM_DATA* aSelection )
  371. {
  372. wxCHECK( m_netNavigator, /* void */ );
  373. wxCHECK( !m_netNavigator->IsFrozen(), /* void */ );
  374. // Maybe in the future we can do something like collapse the tree for an empty selection.
  375. // For now, leave the tree selection in its current state.
  376. if( !aSelection )
  377. return;
  378. wxTreeItemId rootId = m_netNavigator->GetRootItem();
  379. if( !rootId.IsOk() )
  380. return;
  381. wxTreeItemIdValue sheetCookie;
  382. NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
  383. wxTreeItemId sheetId = m_netNavigator->GetFirstChild( rootId, sheetCookie );
  384. while( sheetId.IsOk() )
  385. {
  386. if( m_netNavigator->ItemHasChildren( sheetId ) )
  387. {
  388. wxTreeItemIdValue itemCookie;
  389. wxTreeItemId itemId = m_netNavigator->GetFirstChild( sheetId, itemCookie );
  390. while( itemId.IsOk() )
  391. {
  392. itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( itemId ) );
  393. wxCHECK2( itemData, continue );
  394. if( *itemData == *aSelection )
  395. {
  396. if( !m_netNavigator->IsVisible( itemId ) )
  397. {
  398. m_netNavigator->CollapseAll();
  399. m_netNavigator->EnsureVisible( itemId );
  400. }
  401. m_netNavigator->SelectItem( itemId );
  402. return;
  403. }
  404. itemId = m_netNavigator->GetNextSibling( itemId );
  405. }
  406. sheetId = m_netNavigator->GetNextSibling( sheetId );
  407. }
  408. }
  409. }
  410. const SCH_ITEM* SCH_EDIT_FRAME::GetSelectedNetNavigatorItem() const
  411. {
  412. if( !m_netNavigator || m_netNavigator->IsFrozen() )
  413. return nullptr;
  414. wxTreeItemId id = m_netNavigator->GetSelection();
  415. if( !id.IsOk() || ( id == m_netNavigator->GetRootItem() ) )
  416. return nullptr;
  417. auto* itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( id ) );
  418. wxCHECK( itemData, nullptr );
  419. return itemData->GetItem();
  420. }
  421. void SCH_EDIT_FRAME::onNetNavigatorSelection( wxTreeEvent& aEvent )
  422. {
  423. if( !m_netNavigator || m_netNavigator->IsFrozen() )
  424. return;
  425. wxTreeItemId id = aEvent.GetItem();
  426. // Clicking on the root item (net name ) does nothing.
  427. if( id == m_netNavigator->GetRootItem() )
  428. return;
  429. auto* itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( id ) );
  430. // Just a net name when we have all nets displayed.
  431. if( !itemData )
  432. return;
  433. if( GetCurrentSheet() != itemData->GetSheetPath() )
  434. GetToolManager()->RunAction<SCH_SHEET_PATH*>( SCH_ACTIONS::changeSheet, &itemData->GetSheetPath() );
  435. // Do not focus on item when a sheet tree node is selected.
  436. if( m_netNavigator->GetItemParent( id ) != m_netNavigator->GetRootItem() && itemData->GetItem() )
  437. {
  438. // Make sure we didn't remove the item and/or the screen it resides on before we access it.
  439. const SCH_ITEM* item = itemData->GetItem();
  440. // Don't search for child items in screen r-tree.
  441. item = ( item->Type() == SCH_SHEET_PIN_T || item->Type() == SCH_PIN_T )
  442. ? static_cast<const SCH_ITEM*>( item->GetParent() )
  443. : item;
  444. const SCH_SCREEN* screen = itemData->GetSheetPath().LastScreen();
  445. wxCHECK( screen, /* void */ );
  446. wxCHECK( screen->Items().contains( item, true ), /* void */ );
  447. FocusOnLocation( itemData->GetItem()->GetBoundingBox().Centre() );
  448. }
  449. GetCanvas()->Refresh();
  450. }
  451. void SCH_EDIT_FRAME::onNetNavigatorSelChanging( wxTreeEvent& aEvent )
  452. {
  453. if( !m_netNavigator || m_netNavigator->IsFrozen() )
  454. return;
  455. aEvent.Skip();
  456. }
  457. void SCH_EDIT_FRAME::ToggleNetNavigator()
  458. {
  459. EESCHEMA_SETTINGS* cfg = eeconfig();
  460. wxCHECK( cfg, /* void */ );
  461. wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
  462. netNavigatorPane.Show( !netNavigatorPane.IsShown() );
  463. updateSelectionFilterVisbility();
  464. cfg->m_AuiPanels.show_net_nav_panel = netNavigatorPane.IsShown();
  465. if( netNavigatorPane.IsShown() )
  466. {
  467. if( netNavigatorPane.IsFloating() )
  468. {
  469. netNavigatorPane.FloatingSize( cfg->m_AuiPanels.net_nav_panel_float_size );
  470. m_auimgr.Update();
  471. }
  472. else if( cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth() > 0 )
  473. {
  474. // SetAuiPaneSize also updates m_auimgr
  475. SetAuiPaneSize( m_auimgr, netNavigatorPane,
  476. cfg->m_AuiPanels.net_nav_panel_docked_size.GetWidth(), -1 );
  477. }
  478. }
  479. else
  480. {
  481. if( netNavigatorPane.IsFloating() )
  482. {
  483. cfg->m_AuiPanels.net_nav_panel_float_size = netNavigatorPane.floating_size;
  484. }
  485. else
  486. {
  487. cfg->m_AuiPanels.net_nav_panel_docked_size = m_netNavigator->GetSize();
  488. }
  489. m_auimgr.Update();
  490. }
  491. if( netNavigatorPane.IsShown() )
  492. {
  493. NET_NAVIGATOR_ITEM_DATA* itemData = nullptr;
  494. wxTreeItemId selection = m_netNavigator->GetSelection();
  495. if( selection.IsOk() )
  496. itemData = dynamic_cast<NET_NAVIGATOR_ITEM_DATA*>( m_netNavigator->GetItemData( selection ) );
  497. RefreshNetNavigator( itemData );
  498. }
  499. }
  500. void SCH_EDIT_FRAME::onResizeNetNavigator( wxSizeEvent& aEvent )
  501. {
  502. aEvent.Skip();
  503. // Called when resizing the Hierarchy Navigator panel
  504. // Store the current pane size
  505. // It allows to retrieve the last defined pane size when switching between
  506. // docked and floating pane state
  507. // Note: *DO NOT* call m_auimgr.Update() here: it crashes KiCad at least on Windows
  508. EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( Kiface().KifaceSettings() );
  509. wxCHECK( cfg, /* void */ );
  510. wxAuiPaneInfo& netNavigatorPane = m_auimgr.GetPane( NetNavigatorPaneName() );
  511. if( m_netNavigator->IsShownOnScreen() )
  512. {
  513. cfg->m_AuiPanels.net_nav_panel_float_size = netNavigatorPane.floating_size;
  514. // initialize net_nav_panel_docked_width and best size only if the netNavigatorPane
  515. // width is > 0 (i.e. if its size is already set and has meaning)
  516. // if it is floating, its size is not initialized (only floating_size is initialized)
  517. // initializing netNavigatorPane.best_size is useful when switching to float pane and
  518. // after switching to the docked pane, to retrieve the last docked pane width
  519. if( netNavigatorPane.rect.width > 50 ) // 50 is a good margin
  520. {
  521. cfg->m_AuiPanels.net_nav_panel_docked_size.SetWidth( netNavigatorPane.rect.width );
  522. netNavigatorPane.best_size.x = netNavigatorPane.rect.width;
  523. }
  524. }
  525. }