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.

560 lines
19 KiB

14 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
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
13 years ago
14 years ago
12 years ago
13 years ago
12 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
14 years ago
12 years ago
14 years ago
14 years ago
12 years ago
14 years ago
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004-2016 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
  5. * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2010-2016 KiCad Developers, see change_log.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. /* class_pcb_layer_widget.cpp - Pcbnew layers manager */
  27. /******************************************************/
  28. #include <fctsys.h>
  29. #include <pgm_base.h>
  30. #include <class_drawpanel.h>
  31. #include <class_draw_panel_gal.h>
  32. #include <view/view.h>
  33. #include <painter.h>
  34. #include <confirm.h>
  35. #include <wxPcbStruct.h>
  36. #include <pcbstruct.h> // enum PCB_VISIBLE
  37. #include <layer_widget.h>
  38. #include <macros.h>
  39. #include <menus_helpers.h>
  40. #include <class_board.h>
  41. #include <class_pcb_layer_widget.h>
  42. #include <pcbnew.h>
  43. #include <collectors.h>
  44. #include <pcbnew_id.h>
  45. #include <gal/graphics_abstraction_layer.h>
  46. /// This is a read only template that is copied and modified before adding to LAYER_WIDGET
  47. const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = {
  48. #define RR LAYER_WIDGET::ROW // Render Row abbreviation to reduce source width
  49. // text id color tooltip
  50. RR( _( "Through Via" ), VIA_THROUGH_VISIBLE, WHITE, _( "Show through vias" ) ),
  51. RR( _( "Bl/Buried Via" ), VIA_BBLIND_VISIBLE, WHITE, _( "Show blind or buried vias" ) ),
  52. RR( _( "Micro Via" ), VIA_MICROVIA_VISIBLE, WHITE, _( "Show micro vias") ),
  53. RR( _( "Non Plated" ), NON_PLATED_VISIBLE, WHITE, _( "Show non plated holes") ),
  54. RR( _( "Ratsnest" ), RATSNEST_VISIBLE, WHITE, _( "Show unconnected nets as a ratsnest") ),
  55. RR( _( "Pads Front" ), PAD_FR_VISIBLE, WHITE, _( "Show footprint pads on board's front" ) ),
  56. RR( _( "Pads Back" ), PAD_BK_VISIBLE, WHITE, _( "Show footprint pads on board's back" ) ),
  57. RR( _( "Text Front" ), MOD_TEXT_FR_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprint text on board's front" ) ),
  58. RR( _( "Text Back" ), MOD_TEXT_BK_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprint text on board's back" ) ),
  59. RR( _( "Hidden Text" ), MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
  60. RR( _( "Anchors" ), ANCHOR_VISIBLE, WHITE, _( "Show footprint and text origins as a cross" ) ),
  61. RR( _( "Grid" ), GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ),
  62. RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, UNSPECIFIED_COLOR, _( "Show a marker on pads which have no net connected" ) ),
  63. RR( _( "Footprints Front" ), MOD_FR_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprints that are on board's front") ),
  64. RR( _( "Footprints Back" ), MOD_BK_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprints that are on board's back") ),
  65. RR( _( "Values" ), MOD_VALUES_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprint's values") ),
  66. RR( _( "References" ), MOD_REFERENCES_VISIBLE, UNSPECIFIED_COLOR, _( "Show footprint's references") ),
  67. };
  68. static int s_allowed_in_FpEditor[] =
  69. {
  70. MOD_TEXT_INVISIBLE, PAD_FR_VISIBLE, PAD_BK_VISIBLE,
  71. GRID_VISIBLE, MOD_VALUES_VISIBLE, MOD_REFERENCES_VISIBLE
  72. };
  73. PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwner,
  74. int aPointSize, bool aFpEditorMode ) :
  75. LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
  76. myframe( aParent )
  77. {
  78. m_alwaysShowActiveCopperLayer = false;
  79. m_fp_editor_mode = aFpEditorMode;
  80. ReFillRender();
  81. // Update default tabs labels
  82. SetLayersManagerTabsText();
  83. //-----<Popup menu>-------------------------------------------------
  84. // handle the popup menu over the layer window.
  85. m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
  86. wxMouseEventHandler( PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
  87. // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
  88. // and not m_LayerScrolledWindow->Connect()
  89. Connect( ID_SHOW_ALL_COPPER_LAYERS, ID_SHOW_ALL_LAYERS,
  90. wxEVT_COMMAND_MENU_SELECTED,
  91. wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
  92. // install the right click handler into each control at end of ReFill()
  93. // using installRightLayerClickHandler
  94. }
  95. bool PCB_LAYER_WIDGET::isAllowedInFpMode( int aId )
  96. {
  97. for( unsigned ii = 0; ii < DIM( s_allowed_in_FpEditor ); ii++ )
  98. if( s_allowed_in_FpEditor[ii] == aId )
  99. return true;
  100. return false;
  101. }
  102. bool PCB_LAYER_WIDGET::isLayerAllowedInFpMode( LAYER_ID aLayer )
  103. {
  104. static LSET allowed = LSET::AllTechMask();
  105. // Currently not in use because putting a graphic item on a copper layer
  106. // is not currently supported by DRC.
  107. // allowed.set( F_Cu ).set( B_Cu );
  108. return allowed.test( aLayer );
  109. }
  110. void PCB_LAYER_WIDGET::installRightLayerClickHandler()
  111. {
  112. int rowCount = GetLayerRowCount();
  113. for( int row=0; row < rowCount; ++row )
  114. {
  115. for( int col=0; col<LYR_COLUMN_COUNT; ++col )
  116. {
  117. wxWindow* w = getLayerComp( row, col );
  118. w->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler(
  119. PCB_LAYER_WIDGET::onRightDownLayers ), NULL, this );
  120. }
  121. }
  122. }
  123. void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
  124. {
  125. wxMenu menu;
  126. // menu text is capitalized:
  127. // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
  128. AddMenuItem( &menu, ID_SHOW_ALL_COPPER_LAYERS,
  129. _( "Show All Copper Layers" ),
  130. KiBitmap( select_layer_pair_xpm ) );
  131. AddMenuItem( &menu, ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
  132. _( "Hide All Copper Layers But Active" ),
  133. KiBitmap( select_w_layer_xpm ) );
  134. AddMenuItem( &menu, ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE,
  135. _( "Always Hide All Copper Layers But Active" ),
  136. KiBitmap( select_w_layer_xpm ) );
  137. AddMenuItem( &menu, ID_SHOW_NO_COPPER_LAYERS,
  138. _( "Hide All Copper Layers" ),
  139. KiBitmap( show_no_copper_layers_xpm ) );
  140. menu.AppendSeparator();
  141. AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
  142. KiBitmap( show_no_layers_xpm ) );
  143. AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
  144. KiBitmap( show_all_layers_xpm ) );
  145. PopupMenu( &menu );
  146. passOnFocus();
  147. }
  148. void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
  149. {
  150. int rowCount;
  151. int menuId = event.GetId();
  152. bool visible;
  153. bool force_active_layer_visible;
  154. m_alwaysShowActiveCopperLayer = ( menuId == ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE );
  155. force_active_layer_visible = ( menuId == ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE ||
  156. menuId == ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE );
  157. switch( menuId )
  158. {
  159. case ID_SHOW_NO_LAYERS:
  160. case ID_SHOW_ALL_LAYERS:
  161. visible = menuId == ID_SHOW_ALL_LAYERS;
  162. rowCount = GetLayerRowCount();
  163. for( int row=0; row<rowCount; ++row )
  164. {
  165. bool isLast;
  166. wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
  167. LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
  168. cb->SetValue( visible );
  169. isLast = row == rowCount-1;
  170. OnLayerVisible( layer, visible, isLast );
  171. if( isLast )
  172. break;
  173. }
  174. break;
  175. case ID_SHOW_ALL_COPPER_LAYERS:
  176. case ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE:
  177. case ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE:
  178. case ID_SHOW_NO_COPPER_LAYERS:
  179. // Search the last copper layer row index:
  180. int lastCu = -1;
  181. rowCount = GetLayerRowCount();
  182. for( int row = rowCount-1; row>=0; --row )
  183. {
  184. wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
  185. LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
  186. if( IsCopperLayer( layer ) )
  187. {
  188. lastCu = row;
  189. break;
  190. }
  191. }
  192. // Enable/disable the copper layers visibility:
  193. for( int row=0; row<rowCount; ++row )
  194. {
  195. wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
  196. LAYER_ID layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
  197. if( IsCopperLayer( layer ) )
  198. {
  199. visible = menuId == ID_SHOW_ALL_COPPER_LAYERS;
  200. if( force_active_layer_visible && (layer == myframe->GetActiveLayer() ) )
  201. visible = true;
  202. cb->SetValue( visible );
  203. bool isLastCopperLayer = (row == lastCu);
  204. OnLayerVisible( layer, visible, isLastCopperLayer );
  205. if( isLastCopperLayer )
  206. break;
  207. }
  208. }
  209. break;
  210. }
  211. }
  212. void PCB_LAYER_WIDGET::SetLayersManagerTabsText()
  213. {
  214. m_notebook->SetPageText( 0, _( "Layer" ) );
  215. m_notebook->SetPageText( 1, _( "Render" ) );
  216. }
  217. void PCB_LAYER_WIDGET::ReFillRender()
  218. {
  219. BOARD* board = myframe->GetBoard();
  220. ClearRenderRows();
  221. // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
  222. // Because s_render_rows is created static, we must explicitly call
  223. // wxGetTranslation for texts which are internationalized (tool tips
  224. // and item names)
  225. for( unsigned row=0; row<DIM(s_render_rows); ++row )
  226. {
  227. LAYER_WIDGET::ROW renderRow = s_render_rows[row];
  228. if( m_fp_editor_mode && !isAllowedInFpMode( renderRow.id ) )
  229. continue;
  230. renderRow.tooltip = wxGetTranslation( s_render_rows[row].tooltip );
  231. renderRow.rowName = wxGetTranslation( s_render_rows[row].rowName );
  232. if( renderRow.color != -1 ) // does this row show a color?
  233. {
  234. // this window frame must have an established BOARD, i.e. after SetBoard()
  235. renderRow.color = board->GetVisibleElementColor( renderRow.id );
  236. }
  237. renderRow.state = board->IsElementVisible( renderRow.id );
  238. AppendRenderRow( renderRow );
  239. }
  240. }
  241. void PCB_LAYER_WIDGET::SyncRenderStates()
  242. {
  243. BOARD* board = myframe->GetBoard();
  244. for( unsigned row=0; row<DIM(s_render_rows); ++row )
  245. {
  246. int rowId = s_render_rows[row].id;
  247. if( m_fp_editor_mode && !isAllowedInFpMode( rowId ) )
  248. continue;
  249. // this does not fire a UI event
  250. SetRenderState( rowId, board->IsElementVisible( rowId ) );
  251. }
  252. }
  253. void PCB_LAYER_WIDGET::SyncLayerVisibilities()
  254. {
  255. BOARD* board = myframe->GetBoard();
  256. int count = GetLayerRowCount();
  257. for( int row=0; row<count; ++row )
  258. {
  259. // this utilizes more implementation knowledge than ideal, eventually
  260. // add member ROW getRow() or similar to base LAYER_WIDGET.
  261. wxWindow* w = getLayerComp( row, COLUMN_ICON_ACTIVE );
  262. LAYER_ID layerId = ToLAYER_ID( getDecodedId( w->GetId() ) );
  263. // this does not fire a UI event
  264. SetLayerVisible( layerId, board->IsLayerVisible( layerId ) );
  265. }
  266. }
  267. void PCB_LAYER_WIDGET::ReFill()
  268. {
  269. BOARD* brd = myframe->GetBoard();
  270. LSET enabled = brd->GetEnabledLayers();
  271. ClearLayerRows();
  272. wxString dsc;
  273. // show all coppers first, with front on top, back on bottom, then technical layers
  274. for( LSEQ cu_stack = enabled.CuStack(); cu_stack; ++cu_stack )
  275. {
  276. LAYER_ID layer = *cu_stack;
  277. switch( layer )
  278. {
  279. case F_Cu:
  280. dsc = _( "Front copper layer" );
  281. break;
  282. case B_Cu:
  283. dsc = _( "Back copper layer" );
  284. break;
  285. default:
  286. dsc = _( "Inner copper layer" );
  287. break;
  288. }
  289. AppendLayerRow( LAYER_WIDGET::ROW(
  290. brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ),
  291. dsc, true ) );
  292. if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
  293. {
  294. getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
  295. getLayerComp( GetLayerRowCount()-1,
  296. COLUMN_COLORBM )->SetToolTip( wxEmptyString );
  297. }
  298. }
  299. // technical layers are shown in this order:
  300. // Because they are static, wxGetTranslation must be explicitly
  301. // called for tooltips.
  302. static const struct {
  303. LAYER_ID layerId;
  304. wxString tooltip;
  305. } non_cu_seq[] = {
  306. { F_Adhes, _( "Adhesive on board's front" ) },
  307. { B_Adhes, _( "Adhesive on board's back" ) },
  308. { F_Paste, _( "Solder paste on board's front" ) },
  309. { B_Paste, _( "Solder paste on board's back" ) },
  310. { F_SilkS, _( "Silkscreen on board's front" ) },
  311. { B_SilkS, _( "Silkscreen on board's back" ) },
  312. { F_Mask, _( "Solder mask on board's front" ) },
  313. { B_Mask, _( "Solder mask on board's back" ) },
  314. { Dwgs_User, _( "Explanatory drawings" ) },
  315. { Cmts_User, _( "Explanatory comments" ) },
  316. { Eco1_User, _( "User defined meaning" ) },
  317. { Eco2_User, _( "User defined meaning" ) },
  318. { Edge_Cuts, _( "Board's perimeter definition" ) },
  319. { Margin, _( "Board's edge setback outline" ) },
  320. { F_CrtYd, _( "Footprint courtyards on board's front" ) },
  321. { B_CrtYd, _( "Footprint courtyards on board's back" ) },
  322. { F_Fab, _( "Footprint assembly on board's front" ) },
  323. { B_Fab, _( "Footprint assembly on board's back" ) }
  324. };
  325. for( unsigned i=0; i<DIM( non_cu_seq ); ++i )
  326. {
  327. LAYER_ID layer = non_cu_seq[i].layerId;
  328. if( !enabled[layer] )
  329. continue;
  330. AppendLayerRow( LAYER_WIDGET::ROW(
  331. brd->GetLayerName( layer ), layer, brd->GetLayerColor( layer ),
  332. wxGetTranslation( non_cu_seq[i].tooltip ), true ) );
  333. if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
  334. {
  335. getLayerComp( GetLayerRowCount()-1, COLUMN_COLOR_LYRNAME )->Enable( false );
  336. getLayerComp( GetLayerRowCount()-1,
  337. COLUMN_COLORBM )->SetToolTip( wxEmptyString );
  338. }
  339. }
  340. installRightLayerClickHandler();
  341. }
  342. //-----<LAYER_WIDGET callbacks>-------------------------------------------
  343. void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, EDA_COLOR_T aColor )
  344. {
  345. myframe->GetBoard()->SetLayerColor( ToLAYER_ID( aLayer ), aColor );
  346. if( myframe->IsGalCanvasActive() )
  347. {
  348. KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
  349. view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->GetBoard()->GetColorsSettings() );
  350. view->UpdateLayerColor( aLayer );
  351. view->UpdateLayerColor( GetNetnameLayer( aLayer ) );
  352. }
  353. myframe->GetCanvas()->Refresh();
  354. }
  355. bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
  356. {
  357. // the layer change from the PCB_LAYER_WIDGET can be denied by returning
  358. // false from this function.
  359. LAYER_ID layer = ToLAYER_ID( aLayer );
  360. if( m_fp_editor_mode && !isLayerAllowedInFpMode( layer ) )
  361. return false;
  362. myframe->SetActiveLayer( layer );
  363. DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)myframe->GetDisplayOptions();
  364. if( m_alwaysShowActiveCopperLayer )
  365. OnLayerSelected();
  366. else if( displ_opts->m_ContrastModeDisplay )
  367. myframe->GetCanvas()->Refresh();
  368. return true;
  369. }
  370. bool PCB_LAYER_WIDGET::OnLayerSelected()
  371. {
  372. if( !m_alwaysShowActiveCopperLayer )
  373. return false;
  374. // postprocess after an active layer selection
  375. // ensure active layer visible
  376. wxCommandEvent event;
  377. event.SetId( ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE );
  378. onPopupSelection( event );
  379. return true;
  380. }
  381. void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
  382. {
  383. BOARD* brd = myframe->GetBoard();
  384. LSET visibleLayers = brd->GetVisibleLayers();
  385. visibleLayers.set( aLayer, isVisible );
  386. brd->SetVisibleLayers( visibleLayers );
  387. EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
  388. if( galCanvas )
  389. galCanvas->GetView()->SetLayerVisible( aLayer, isVisible );
  390. if( isFinal )
  391. myframe->GetCanvas()->Refresh();
  392. }
  393. void PCB_LAYER_WIDGET::OnRenderColorChange( int aId, EDA_COLOR_T aColor )
  394. {
  395. myframe->GetBoard()->SetVisibleElementColor( aId, aColor );
  396. if( myframe->GetGalCanvas() )
  397. {
  398. KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
  399. view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->GetBoard()->GetColorsSettings() );
  400. view->UpdateLayerColor( aId );
  401. }
  402. myframe->GetCanvas()->Refresh();
  403. }
  404. void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
  405. {
  406. BOARD* brd = myframe->GetBoard();
  407. LSET visibleLayers = brd->GetVisibleLayers();
  408. visibleLayers.set( aId, isEnabled );
  409. // The layer visibility status is saved in the board file so set the board modified
  410. // state so the user has the option to save the changes.
  411. if( brd->IsElementVisible( aId ) != isEnabled )
  412. myframe->OnModify();
  413. brd->SetElementVisibility( aId, isEnabled );
  414. EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
  415. if( galCanvas )
  416. {
  417. if( aId == GRID_VISIBLE )
  418. {
  419. galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
  420. galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
  421. }
  422. else
  423. galCanvas->GetView()->SetLayerVisible( ITEM_GAL_LAYER( aId ), isEnabled );
  424. }
  425. if( galCanvas && myframe->IsGalCanvasActive() )
  426. galCanvas->Refresh();
  427. else
  428. myframe->GetCanvas()->Refresh();
  429. }
  430. //-----</LAYER_WIDGET callbacks>------------------------------------------