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.

561 lines
19 KiB

9 years ago
9 years ago
9 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2014-2017 CERN
  5. * @author Maciej Suminski <maciej.suminski@cern.ch>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #include "pcb_draw_panel_gal.h"
  25. #include <pcb_view.h>
  26. #include <view/wx_view_controls.h>
  27. #include <pcb_painter.h>
  28. #include <ws_proxy_view_item.h>
  29. #include <connectivity/connectivity_data.h>
  30. #include <class_board.h>
  31. #include <class_module.h>
  32. #include <class_track.h>
  33. #include <class_marker_pcb.h>
  34. #include <pcb_base_frame.h>
  35. #include <pcbnew_settings.h>
  36. #include <ratsnest/ratsnest_data.h>
  37. #include <ratsnest/ratsnest_viewitem.h>
  38. #include <pgm_base.h>
  39. #include <settings/settings_manager.h>
  40. #include <confirm.h>
  41. #include <gal/graphics_abstraction_layer.h>
  42. #include <functional>
  43. #include <memory>
  44. #include <thread>
  45. using namespace std::placeholders;
  46. const LAYER_NUM GAL_LAYER_ORDER[] =
  47. {
  48. LAYER_GP_OVERLAY,
  49. LAYER_SELECT_OVERLAY,
  50. LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION,
  51. LAYER_PADS_NETNAMES, LAYER_VIAS_NETNAMES,
  52. Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts,
  53. LAYER_MOD_TEXT_FR,
  54. LAYER_MOD_REFERENCES, LAYER_MOD_VALUES,
  55. LAYER_RATSNEST, LAYER_ANCHOR,
  56. LAYER_VIAS_HOLES, LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES,
  57. LAYER_VIA_THROUGH, LAYER_VIA_BBLIND,
  58. LAYER_VIA_MICROVIA, LAYER_PADS_TH,
  59. LAYER_PAD_FR_NETNAMES, LAYER_PAD_FR,
  60. NETNAMES_LAYER_INDEX( F_Cu ), F_Cu, ZONE_LAYER_FOR( F_Cu ),
  61. F_Mask, F_SilkS, F_Paste, F_Adhes, F_CrtYd, F_Fab,
  62. NETNAMES_LAYER_INDEX( In1_Cu ), In1_Cu, ZONE_LAYER_FOR( In1_Cu ),
  63. NETNAMES_LAYER_INDEX( In2_Cu ), In2_Cu, ZONE_LAYER_FOR( In2_Cu ),
  64. NETNAMES_LAYER_INDEX( In3_Cu ), In3_Cu, ZONE_LAYER_FOR( In3_Cu ),
  65. NETNAMES_LAYER_INDEX( In4_Cu ), In4_Cu, ZONE_LAYER_FOR( In4_Cu ),
  66. NETNAMES_LAYER_INDEX( In5_Cu ), In5_Cu, ZONE_LAYER_FOR( In5_Cu ),
  67. NETNAMES_LAYER_INDEX( In6_Cu ), In6_Cu, ZONE_LAYER_FOR( In6_Cu ),
  68. NETNAMES_LAYER_INDEX( In7_Cu ), In7_Cu, ZONE_LAYER_FOR( In7_Cu ),
  69. NETNAMES_LAYER_INDEX( In8_Cu ), In8_Cu, ZONE_LAYER_FOR( In8_Cu ),
  70. NETNAMES_LAYER_INDEX( In9_Cu ), In9_Cu, ZONE_LAYER_FOR( In9_Cu ),
  71. NETNAMES_LAYER_INDEX( In10_Cu ), In10_Cu, ZONE_LAYER_FOR( In10_Cu ),
  72. NETNAMES_LAYER_INDEX( In11_Cu ), In11_Cu, ZONE_LAYER_FOR( In11_Cu ),
  73. NETNAMES_LAYER_INDEX( In12_Cu ), In12_Cu, ZONE_LAYER_FOR( In12_Cu ),
  74. NETNAMES_LAYER_INDEX( In13_Cu ), In13_Cu, ZONE_LAYER_FOR( In13_Cu ),
  75. NETNAMES_LAYER_INDEX( In14_Cu ), In14_Cu, ZONE_LAYER_FOR( In14_Cu ),
  76. NETNAMES_LAYER_INDEX( In15_Cu ), In15_Cu, ZONE_LAYER_FOR( In15_Cu ),
  77. NETNAMES_LAYER_INDEX( In16_Cu ), In16_Cu, ZONE_LAYER_FOR( In16_Cu ),
  78. NETNAMES_LAYER_INDEX( In17_Cu ), In17_Cu, ZONE_LAYER_FOR( In17_Cu ),
  79. NETNAMES_LAYER_INDEX( In18_Cu ), In18_Cu, ZONE_LAYER_FOR( In18_Cu ),
  80. NETNAMES_LAYER_INDEX( In19_Cu ), In19_Cu, ZONE_LAYER_FOR( In19_Cu ),
  81. NETNAMES_LAYER_INDEX( In20_Cu ), In20_Cu, ZONE_LAYER_FOR( In20_Cu ),
  82. NETNAMES_LAYER_INDEX( In21_Cu ), In21_Cu, ZONE_LAYER_FOR( In21_Cu ),
  83. NETNAMES_LAYER_INDEX( In22_Cu ), In22_Cu, ZONE_LAYER_FOR( In22_Cu ),
  84. NETNAMES_LAYER_INDEX( In23_Cu ), In23_Cu, ZONE_LAYER_FOR( In23_Cu ),
  85. NETNAMES_LAYER_INDEX( In24_Cu ), In24_Cu, ZONE_LAYER_FOR( In24_Cu ),
  86. NETNAMES_LAYER_INDEX( In25_Cu ), In25_Cu, ZONE_LAYER_FOR( In25_Cu ),
  87. NETNAMES_LAYER_INDEX( In26_Cu ), In26_Cu, ZONE_LAYER_FOR( In26_Cu ),
  88. NETNAMES_LAYER_INDEX( In27_Cu ), In27_Cu, ZONE_LAYER_FOR( In27_Cu ),
  89. NETNAMES_LAYER_INDEX( In28_Cu ), In28_Cu, ZONE_LAYER_FOR( In28_Cu ),
  90. NETNAMES_LAYER_INDEX( In29_Cu ), In29_Cu, ZONE_LAYER_FOR( In29_Cu ),
  91. NETNAMES_LAYER_INDEX( In30_Cu ), In30_Cu, ZONE_LAYER_FOR( In30_Cu ),
  92. LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK,
  93. NETNAMES_LAYER_INDEX( B_Cu ), B_Cu, ZONE_LAYER_FOR( B_Cu ),
  94. B_Mask, B_Adhes, B_Paste, B_SilkS, B_CrtYd, B_Fab,
  95. LAYER_MOD_TEXT_BK,
  96. LAYER_WORKSHEET
  97. };
  98. PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
  99. const wxPoint& aPosition, const wxSize& aSize,
  100. KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
  101. EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType )
  102. {
  103. m_view = new KIGFX::PCB_VIEW( true );
  104. m_view->SetGAL( m_gal );
  105. m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal );
  106. m_view->SetPainter( m_painter.get() );
  107. setDefaultLayerOrder();
  108. setDefaultLayerDeps();
  109. // View controls is the first in the event handler chain, so the Tool Framework operates
  110. // on updated viewport data.
  111. m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
  112. // Load display options (such as filled/outline display of items).
  113. // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
  114. // which is not always the case (namely when it is used from a wxDialog like the pad editor)
  115. if( !IsDialogPreview() )
  116. {
  117. KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( m_view );
  118. PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
  119. if( frame )
  120. view->UpdateDisplayOptions( frame->GetDisplayOptions() );
  121. }
  122. }
  123. PCB_DRAW_PANEL_GAL::~PCB_DRAW_PANEL_GAL()
  124. {
  125. }
  126. void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard )
  127. {
  128. m_view->Clear();
  129. auto zones = aBoard->Zones();
  130. std::atomic<size_t> next( 0 );
  131. std::atomic<size_t> count_done( 0 );
  132. size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
  133. for( size_t ii = 0; ii < parallelThreadCount; ++ii )
  134. {
  135. std::thread t = std::thread( [ &count_done, &next, &zones ]( )
  136. {
  137. for( size_t i = next.fetch_add( 1 ); i < zones.size(); i = next.fetch_add( 1 ) )
  138. zones[i]->CacheTriangulation();
  139. count_done++;
  140. } );
  141. t.detach();
  142. }
  143. if( m_worksheet )
  144. m_worksheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
  145. // Load drawings
  146. for( auto drawing : const_cast<BOARD*>(aBoard)->Drawings() )
  147. m_view->Add( drawing );
  148. // Load tracks
  149. for( auto track : aBoard->Tracks() )
  150. m_view->Add( track );
  151. // Load modules and its additional elements
  152. for( auto module : aBoard->Modules() )
  153. m_view->Add( module );
  154. // DRC markers
  155. for( auto marker : aBoard->Markers() )
  156. m_view->Add( marker );
  157. // Finalize the triangulation threads
  158. while( count_done < parallelThreadCount )
  159. std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
  160. // Load zones
  161. for( auto zone : aBoard->Zones() )
  162. m_view->Add( zone );
  163. // Ratsnest
  164. m_ratsnest = std::make_unique<KIGFX::RATSNEST_VIEWITEM>( aBoard->GetConnectivity() );
  165. m_view->Add( m_ratsnest.get() );
  166. }
  167. void PCB_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
  168. {
  169. m_worksheet.reset( aWorksheet );
  170. m_view->Add( m_worksheet.get() );
  171. }
  172. void PCB_DRAW_PANEL_GAL::UpdateColors()
  173. {
  174. COLOR_SETTINGS* cs = nullptr;
  175. PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
  176. if( frame )
  177. {
  178. cs = frame->GetColorSettings();
  179. }
  180. else
  181. {
  182. PCBNEW_SETTINGS* app = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
  183. if( app )
  184. cs = Pgm().GetSettingsManager().GetColorSettings( app->m_ColorTheme );
  185. else
  186. cs = Pgm().GetSettingsManager().GetColorSettings();
  187. }
  188. wxCHECK_RET( cs, "null COLOR_SETTINGS" );
  189. Pgm().GetSettingsManager().SaveColorSettings( cs, "board" );
  190. auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
  191. rs->LoadColors( cs );
  192. m_gal->SetGridColor( cs->GetColor( LAYER_GRID ) );
  193. m_gal->SetCursorColor( cs->GetColor( LAYER_CURSOR ) );
  194. }
  195. void PCB_DRAW_PANEL_GAL::SetHighContrastLayer( PCB_LAYER_ID aLayer )
  196. {
  197. // Set display settings for high contrast mode
  198. KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
  199. SetTopLayer( aLayer );
  200. rSettings->ClearActiveLayers();
  201. rSettings->SetActiveLayer( aLayer );
  202. if( IsCopperLayer( aLayer ) )
  203. {
  204. // Bring some other layers to the front in case of copper layers and make them colored
  205. // fixme do not like the idea of storing the list of layers here,
  206. // should be done in some other way I guess..
  207. LAYER_NUM layers[] = {
  208. GetNetnameLayer( aLayer ),
  209. ZONE_LAYER_FOR( aLayer ),
  210. LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, LAYER_VIAS_NETNAMES,
  211. LAYER_PADS_TH, LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES,
  212. LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION,
  213. LAYER_NON_PLATEDHOLES, LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY,
  214. LAYER_RATSNEST, LAYER_CURSOR
  215. };
  216. for( unsigned int i : layers )
  217. rSettings->SetActiveLayer( i );
  218. // Pads should be shown too
  219. if( aLayer == B_Cu )
  220. {
  221. rSettings->SetActiveLayer( LAYER_PAD_BK );
  222. rSettings->SetActiveLayer( LAYER_MOD_BK );
  223. rSettings->SetActiveLayer( LAYER_PAD_BK_NETNAMES );
  224. }
  225. else if( aLayer == F_Cu )
  226. {
  227. rSettings->SetActiveLayer( LAYER_PAD_FR );
  228. rSettings->SetActiveLayer( LAYER_MOD_FR );
  229. rSettings->SetActiveLayer( LAYER_PAD_FR_NETNAMES );
  230. }
  231. }
  232. m_view->UpdateAllLayersColor();
  233. }
  234. void PCB_DRAW_PANEL_GAL::SetTopLayer( PCB_LAYER_ID aLayer )
  235. {
  236. m_view->ClearTopLayers();
  237. setDefaultLayerOrder();
  238. m_view->SetTopLayer( aLayer );
  239. // Layers that should always have on-top attribute enabled
  240. const std::vector<LAYER_NUM> layers = {
  241. LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, LAYER_VIAS_NETNAMES, LAYER_PADS_TH,
  242. LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES, LAYER_NON_PLATEDHOLES,
  243. LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY, LAYER_RATSNEST, LAYER_DRC_ERROR,
  244. LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION
  245. };
  246. for( auto layer : layers )
  247. m_view->SetTopLayer( layer );
  248. // Extra layers that are brought to the top if a F.* or B.* is selected
  249. const std::vector<LAYER_NUM> frontLayers = {
  250. F_Cu, F_Adhes, F_Paste, F_SilkS, F_Mask, F_Fab, F_CrtYd, LAYER_PAD_FR,
  251. LAYER_PAD_FR_NETNAMES, NETNAMES_LAYER_INDEX( F_Cu ), ZONE_LAYER_FOR( F_Cu )
  252. };
  253. const std::vector<LAYER_NUM> backLayers = {
  254. B_Cu, B_Adhes, B_Paste, B_SilkS, B_Mask, B_Fab, B_CrtYd, LAYER_PAD_BK,
  255. LAYER_PAD_BK_NETNAMES, NETNAMES_LAYER_INDEX( B_Cu ), ZONE_LAYER_FOR( B_Cu )
  256. };
  257. const std::vector<LAYER_NUM>* extraLayers = NULL;
  258. // Bring a few more extra layers to the top depending on the selected board side
  259. if( IsFrontLayer( aLayer ) )
  260. extraLayers = &frontLayers;
  261. else if( IsBackLayer( aLayer ) )
  262. extraLayers = &backLayers;
  263. if( extraLayers )
  264. {
  265. for( auto layer : *extraLayers )
  266. m_view->SetTopLayer( layer );
  267. // Move the active layer to the top
  268. if( !IsCopperLayer( aLayer ) )
  269. m_view->SetLayerOrder( aLayer, m_view->GetLayerOrder( GAL_LAYER_ORDER[0] ) );
  270. }
  271. else if( IsCopperLayer( aLayer ) )
  272. {
  273. // Display labels for copper layers on the top
  274. m_view->SetTopLayer( GetNetnameLayer( aLayer ) );
  275. m_view->SetTopLayer( ZONE_LAYER_FOR( aLayer ) );
  276. }
  277. m_view->EnableTopLayer( true );
  278. m_view->UpdateAllLayersOrder();
  279. }
  280. void PCB_DRAW_PANEL_GAL::SyncLayersVisibility( const BOARD* aBoard )
  281. {
  282. // Load layer & elements visibility settings
  283. for( LAYER_NUM i = 0; i < PCB_LAYER_ID_COUNT; ++i )
  284. m_view->SetLayerVisible( i, aBoard->IsLayerVisible( PCB_LAYER_ID( i ) ) );
  285. for( GAL_LAYER_ID i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; ++i )
  286. m_view->SetLayerVisible( i, aBoard->IsElementVisible( i ) );
  287. // Via layers controlled by dependencies
  288. m_view->SetLayerVisible( LAYER_VIA_MICROVIA, true );
  289. m_view->SetLayerVisible( LAYER_VIA_BBLIND, true );
  290. m_view->SetLayerVisible( LAYER_VIA_THROUGH, true );
  291. // Pad layers controlled by dependencies
  292. m_view->SetLayerVisible( LAYER_PADS_TH, true );
  293. m_view->SetLayerVisible( LAYER_PAD_FR, true );
  294. m_view->SetLayerVisible( LAYER_PAD_BK, true );
  295. // Always enable netname layers, as their visibility is controlled by layer dependencies
  296. for( LAYER_NUM i = NETNAMES_LAYER_ID_START; i < NETNAMES_LAYER_ID_END; ++i )
  297. m_view->SetLayerVisible( i, true );
  298. for( LAYER_NUM i = LAYER_ZONE_START; i < LAYER_ZONE_END; i++ )
  299. m_view->SetLayerVisible( i, true );
  300. // Enable some layers that are GAL specific
  301. m_view->SetLayerVisible( LAYER_PADS_PLATEDHOLES, true );
  302. m_view->SetLayerVisible( LAYER_VIAS_HOLES, true );
  303. m_view->SetLayerVisible( LAYER_GP_OVERLAY, true );
  304. m_view->SetLayerVisible( LAYER_SELECT_OVERLAY, true );
  305. m_view->SetLayerVisible( LAYER_RATSNEST, true );
  306. }
  307. void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
  308. std::vector<MSG_PANEL_ITEM>& aList )
  309. {
  310. BOARD* board = static_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() )->GetBoard();
  311. wxString txt;
  312. int viasCount = 0;
  313. int trackSegmentsCount = 0;
  314. for( TRACK* item : board->Tracks() )
  315. {
  316. if( item->Type() == PCB_VIA_T )
  317. viasCount++;
  318. else
  319. trackSegmentsCount++;
  320. }
  321. txt.Printf( wxT( "%d" ), board->GetPadCount() );
  322. aList.emplace_back( _( "Pads" ), txt, DARKGREEN );
  323. txt.Printf( wxT( "%d" ), viasCount );
  324. aList.emplace_back( _( "Vias" ), txt, DARKGREEN );
  325. txt.Printf( wxT( "%d" ), trackSegmentsCount );
  326. aList.emplace_back( _( "Track Segments" ), txt, DARKGREEN );
  327. txt.Printf( wxT( "%d" ), board->GetNodesCount() );
  328. aList.emplace_back( _( "Nodes" ), txt, DARKCYAN );
  329. txt.Printf( wxT( "%d" ), board->GetNetCount() - 1 /* don't include "No Net" in count */ );
  330. aList.emplace_back( _( "Nets" ), txt, RED );
  331. txt.Printf( wxT( "%d" ), board->GetConnectivity()->GetUnconnectedCount() );
  332. aList.emplace_back( _( "Unrouted" ), txt, BLUE );
  333. }
  334. void PCB_DRAW_PANEL_GAL::OnShow()
  335. {
  336. PCB_BASE_FRAME* frame = nullptr;
  337. if( !IsDialogPreview() )
  338. frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
  339. try
  340. {
  341. // Check if the current rendering backend can be properly initialized
  342. m_view->UpdateItems();
  343. }
  344. catch( const std::runtime_error& e )
  345. {
  346. DisplayError( GetParent(), e.what() );
  347. // Use the fallback if we have one
  348. if( GAL_FALLBACK != m_backend )
  349. {
  350. SwitchBackend( GAL_FALLBACK );
  351. if( frame )
  352. frame->ActivateGalCanvas();
  353. }
  354. }
  355. if( frame )
  356. {
  357. SetTopLayer( frame->GetActiveLayer() );
  358. KIGFX::PAINTER* painter = m_view->GetPainter();
  359. auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
  360. settings->LoadDisplayOptions( frame->GetDisplayOptions(), frame->ShowPageLimits() );
  361. }
  362. }
  363. void PCB_DRAW_PANEL_GAL::setDefaultLayerOrder()
  364. {
  365. for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
  366. {
  367. LAYER_NUM layer = GAL_LAYER_ORDER[i];
  368. wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
  369. m_view->SetLayerOrder( layer, i );
  370. }
  371. }
  372. bool PCB_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
  373. {
  374. bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
  375. setDefaultLayerDeps();
  376. m_gal->SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
  377. return rv;
  378. }
  379. void PCB_DRAW_PANEL_GAL::RedrawRatsnest()
  380. {
  381. if( m_ratsnest )
  382. m_view->Update( m_ratsnest.get() );
  383. }
  384. BOX2I PCB_DRAW_PANEL_GAL::GetDefaultViewBBox() const
  385. {
  386. if( m_worksheet && m_view->IsLayerVisible( LAYER_WORKSHEET ) )
  387. return m_worksheet->ViewBBox();
  388. return BOX2I();
  389. }
  390. void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
  391. {
  392. // caching makes no sense for Cairo and other software renderers
  393. auto target = m_backend == GAL_TYPE_OPENGL ? KIGFX::TARGET_CACHED : KIGFX::TARGET_NONCACHED;
  394. for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
  395. m_view->SetLayerTarget( i, target );
  396. for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
  397. {
  398. LAYER_NUM layer = GAL_LAYER_ORDER[i];
  399. wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
  400. // Set layer display dependencies & targets
  401. if( IsCopperLayer( layer ) )
  402. {
  403. m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
  404. m_view->SetRequired( GetNetnameLayer( layer ), layer );
  405. }
  406. else if( IsNetnameLayer( layer ) )
  407. m_view->SetLayerDisplayOnly( layer );
  408. }
  409. m_view->SetLayerTarget( LAYER_ANCHOR, KIGFX::TARGET_NONCACHED );
  410. m_view->SetLayerDisplayOnly( LAYER_ANCHOR );
  411. // Some more required layers settings
  412. m_view->SetRequired( LAYER_VIAS_HOLES, LAYER_VIA_THROUGH );
  413. m_view->SetRequired( LAYER_VIAS_NETNAMES, LAYER_VIA_THROUGH );
  414. m_view->SetRequired( LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH );
  415. m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS_TH );
  416. m_view->SetRequired( LAYER_PADS_NETNAMES, LAYER_PADS_TH );
  417. // Via visibility
  418. m_view->SetRequired( LAYER_VIA_MICROVIA, LAYER_VIAS );
  419. m_view->SetRequired( LAYER_VIA_BBLIND, LAYER_VIAS );
  420. m_view->SetRequired( LAYER_VIA_THROUGH, LAYER_VIAS );
  421. // Pad visibility
  422. m_view->SetRequired( LAYER_PADS_TH, LAYER_PADS );
  423. m_view->SetRequired( LAYER_PAD_FR, LAYER_PADS );
  424. m_view->SetRequired( LAYER_PAD_BK, LAYER_PADS );
  425. // Front modules
  426. m_view->SetRequired( LAYER_PAD_FR, F_Cu );
  427. m_view->SetRequired( LAYER_MOD_TEXT_FR, LAYER_MOD_FR );
  428. m_view->SetRequired( LAYER_PAD_FR_NETNAMES, LAYER_PAD_FR );
  429. // Back modules
  430. m_view->SetRequired( LAYER_PAD_BK, B_Cu );
  431. m_view->SetRequired( LAYER_MOD_TEXT_BK, LAYER_MOD_BK );
  432. m_view->SetRequired( LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK );
  433. m_view->SetLayerTarget( LAYER_SELECT_OVERLAY , KIGFX::TARGET_OVERLAY );
  434. m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ;
  435. m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY );
  436. m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
  437. m_view->SetLayerTarget( LAYER_RATSNEST, KIGFX::TARGET_OVERLAY );
  438. m_view->SetLayerDisplayOnly( LAYER_RATSNEST );
  439. m_view->SetLayerTarget( LAYER_WORKSHEET, KIGFX::TARGET_NONCACHED );
  440. m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
  441. m_view->SetLayerDisplayOnly( LAYER_GRID );
  442. }
  443. KIGFX::PCB_VIEW* PCB_DRAW_PANEL_GAL::GetView() const
  444. {
  445. return static_cast<KIGFX::PCB_VIEW*>( m_view );
  446. }