KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
sel_layer.cpp
Go to the documentation of this file.
1
5/*
6 * This program source code file is part of KiCad, a free EDA CAD application.
7 *
8 * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
9 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
10 *
11 * This program is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation, either version 3 of the License, or (at your
14 * option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25#include <wx/bitmap.h>
26
27#include <kiplatform/ui.h>
28#include <confirm.h>
29#include <lset.h>
30#include <board.h>
31#include <pgm_base.h>
32#include <project.h>
33#include <pcb_base_frame.h>
36#include <layer_pairs.h>
39#include <router/router_tool.h>
42#include <tools/pcb_actions.h>
46#include <widgets/wx_grid.h>
49
50
51// Column position by function:
52#define SELECT_COLNUM 0
53#define COLOR_COLNUM 1
54#define LAYERNAME_COLNUM 2
55#define LAYER_HK_COLUMN 3
56
57
59{
60}
61
63{
64 if( m_boardFrame )
65 {
66 return m_boardFrame->GetColorSettings()->GetColor( aLayer );
67 }
68 else
69 {
72 COLOR_SETTINGS* current = mgr.GetColorSettings( cfg->m_ColorTheme );
73
74 return current->GetColor( aLayer );
75 }
76}
77
78wxString PCB_LAYER_PRESENTATION::getLayerName( int aLayer ) const
79{
80 if( m_boardFrame )
81 return m_boardFrame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
82 else
83 return BOARD::GetStandardLayerName( ToLAYER_ID( aLayer ) );
84}
85
87{
89}
90
92{
93 const wxString layerAName = getLayerName( aPair.GetLayerA() );
94 const wxString layerBName = getLayerName( aPair.GetLayerB() );
95
96 return layerAName + wxT( " / " ) + layerBName;
97}
98
99
104{
105public:
106 PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, PCB_LAYER_ID aDefaultLayer,
107 LSET aNotAllowedLayersMask, bool aHideCheckBoxes = false );
109
111
112private:
113 // Event handlers
114 void OnLeftGridCellClick( wxGridEvent& aEvent ) override;
115 void OnRightGridCellClick( wxGridEvent& aEvent ) override;
116 void OnMouseMove( wxUpdateUIEvent& aEvent ) override;
117
118 // Will close the dialog on ESC key
119 void onCharHook( wxKeyEvent& event );
120
121 wxString getLayerHotKey( PCB_LAYER_ID aLayer ) const
122 {
123 int code = PCB_ACTIONS::LayerIDToAction( aLayer )->GetHotKey();
124 return AddHotkeyName( wxS( "" ), code, IS_COMMENT );
125 }
126
127 void buildList();
128
132 std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
133 std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
134};
135
136
138 LSET aNotAllowedLayersMask, bool aHideCheckBoxes ) :
139 DIALOG_LAYER_SELECTION_BASE( aParent ), m_layerPresentation( aParent )
140{
141 m_useCalculatedSize = true;
142
143 m_layerSelected = aDefaultLayer;
144 m_notAllowedLayersMask = aNotAllowedLayersMask;
145
146 m_leftGridLayers->SetCellHighlightPenWidth( 0 );
147 m_rightGridLayers->SetCellHighlightPenWidth( 0 );
148 m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
149 m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
150
151 m_leftGridLayers->AppendCols( 1 );
152
153 buildList();
154
155 if( aHideCheckBoxes )
156 {
159 }
160
161 Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
162
163 Layout();
164 GetSizer()->SetSizeHints( this );
165 SetFocus();
166}
167
168
170{
171 Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
172}
173
174
175void PCB_ONE_LAYER_SELECTOR::OnMouseMove( wxUpdateUIEvent& aEvent )
176{
180
181 wxPoint mouse_pos = KIPLATFORM::UI::GetMousePosition();
182 wxPoint left_pos = m_leftGridLayers->ScreenToClient( mouse_pos );
183 wxPoint right_pos = m_rightGridLayers->ScreenToClient( mouse_pos );
184
185 if( m_leftGridLayers->HitTest( left_pos ) == wxHT_WINDOW_INSIDE )
186 {
187 int row = m_leftGridLayers->YToRow( left_pos.y );
188
189 if( row != wxNOT_FOUND && row < static_cast<int>( m_layersIdLeftColumn.size() ) )
190 {
192 m_leftGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYER_HK_COLUMN );
193 return;
194 }
195 }
196
197 if( m_rightGridLayers->HitTest( right_pos ) == wxHT_WINDOW_INSIDE )
198 {
199 int row = m_rightGridLayers->YToRow( right_pos.y );
200
201 if( row == wxNOT_FOUND || row >= static_cast<int>( m_layersIdRightColumn.size() ) )
202 return;
203
205 m_rightGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYERNAME_COLNUM );
206 }
207}
208
209
210void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
211{
212 if( event.GetKeyCode() == WXK_ESCAPE )
213 Close();
214}
215
216
218{
220 int left_row = 0;
221 int right_row = 0;
222 wxString layername;
223
225 {
226 if( m_notAllowedLayersMask[layerid] )
227 continue;
228
229 wxColour fg = m_layerPresentation.getLayerColor( layerid ).ToColour();
230 wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
231 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
232 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
233
234 layername = wxT( " " ) + m_layerPresentation.getLayerName( layerid );
235
236 if( IsCopperLayer( layerid ) )
237 {
238 if( left_row )
239 m_leftGridLayers->AppendRows( 1 );
240
241 m_leftGridLayers->SetCellBackgroundColour( left_row, COLOR_COLNUM, color );
242 m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
243 m_leftGridLayers->SetCellValue( left_row, LAYER_HK_COLUMN, getLayerHotKey( layerid ) );
244
245 if( m_layerSelected == layerid )
246 m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, wxT( "1" ) );
247
248 m_layersIdLeftColumn.push_back( layerid );
249 left_row++;
250 }
251 else
252 {
253 if( right_row )
254 m_rightGridLayers->AppendRows( 1 );
255
256 m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
257 m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
258
259 if( m_layerSelected == layerid )
260 m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, wxT( "1" ) );
261
262 m_layersIdRightColumn.push_back( layerid );
263 right_row++;
264 }
265 }
266
267 // Show only populated lists:
268 if( left_row <= 0 )
269 m_leftGridLayers->Show( false );
270
271 if( right_row <= 0 )
272 m_rightGridLayers->Show( false );
273
274 // Now fix min grid column size (it also sets a minimal size)
275 m_leftGridLayers->AutoSizeColumns();
276 m_rightGridLayers->AutoSizeColumns();
277}
278
279
281{
282 m_layerSelected = m_layersIdLeftColumn[event.GetRow()];
283
284 if( IsQuasiModal() )
285 EndQuasiModal( 1 );
286 else
287 EndDialog( 1 );
288}
289
290
292{
293 m_layerSelected = m_layersIdRightColumn[event.GetRow()];
294
295 if( IsQuasiModal() )
296 EndQuasiModal( 2 );
297 else
298 EndDialog( 2 );
299}
300
301
303 const LSET& aNotAllowedLayersMask,
304 wxPoint aDlgPosition )
305{
306 PCB_ONE_LAYER_SELECTOR dlg( this, aDefaultLayer, aNotAllowedLayersMask, true );
307
308 if( aDlgPosition != wxDefaultPosition )
309 {
310 wxSize dlgSize = dlg.GetSize();
311 aDlgPosition.x -= dlgSize.x / 2;
312 aDlgPosition.y -= dlgSize.y / 2;
313 dlg.SetPosition( aDlgPosition );
314 }
315
316 if( dlg.ShowModal() != wxID_CANCEL )
317 return ToLAYER_ID( dlg.GetLayerSelection() );
318 else
319 return UNDEFINED_LAYER;
320}
321
322
328{
329 enum class COLNUMS
330 {
331 ENABLED,
332 SWATCH,
334 USERNAME,
335 };
336
337public:
339 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
340 m_layerPresentation( aPresentation ), m_grid( aGrid ),
341 m_layerPairSettings( aLayerPairSettings )
342 {
343 wxASSERT_MSG( m_grid.GetNumberRows() == 0, "Grid should be empty at controller start" );
344
347
348 m_grid.Bind( wxEVT_GRID_CELL_CHANGED,
349 [this]( wxGridEvent& aEvent )
350 {
351 const int col = aEvent.GetCol();
352 const int row = aEvent.GetRow();
353 if( col == (int) COLNUMS::USERNAME )
354 {
355 onUserNameChanged( row, m_grid.GetCellValue( row, col ) );
356 }
357 else if( col == (int) COLNUMS::ENABLED )
358 {
359 onEnableChanged( row, m_grid.GetCellValue( row, col ) == wxS( "1" ) );
360 }
361 } );
362
363 m_grid.Bind( wxEVT_GRID_CELL_LEFT_DCLICK,
364 [&]( wxGridEvent& aEvent )
365 {
366 const int row = aEvent.GetRow();
367 const int col = aEvent.GetCol();
368
369 if( col == (int) COLNUMS::LAYERNAMES || col == (int) COLNUMS::SWATCH )
370 {
371 onPairActivated( row );
372 }
373 } );
374
376 std::make_unique<WX_GRID_AUTOSIZER>( m_grid,
378 { (int) COLNUMS::LAYERNAMES, 72 },
379 { (int) COLNUMS::USERNAME, 72 },
380 },
381 (int) COLNUMS::USERNAME );
382 }
383
384 void OnLayerPairAdded( const LAYER_PAIR& aLayerPair )
385 {
386 LAYER_PAIR_INFO layerPairInfo{ aLayerPair, true, std::nullopt };
387
388 const bool added = m_layerPairSettings.AddLayerPair( layerPairInfo );
389
390 if( added )
391 {
392 m_grid.AppendRows( 1 );
393 fillRowFromLayerPair( m_grid.GetNumberRows() - 1, layerPairInfo );
394 }
395 }
396
398 {
399 int row = m_grid.GetGridCursorRow();
400
401 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[row];
402 const bool removed = m_layerPairSettings.RemoveLayerPair( layerPairInfo.GetLayerPair() );
403
404 if( removed )
405 {
406 m_grid.DeleteRows( row );
407 }
408 }
409
410private:
412 {
413 m_grid.UseNativeColHeader( true );
414
415 m_grid.SetCellHighlightPenWidth( 0 );
416 m_grid.SetColFormatBool( (int) COLNUMS::ENABLED );
417
418 m_grid.SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
419
420 m_grid.AutoSizeColumn( (int) COLNUMS::USERNAME );
421 }
422
424 {
425 std::span<const LAYER_PAIR_INFO> storePairs = m_layerPairSettings.GetLayerPairs();
426
427 m_grid.AppendRows( storePairs.size() );
428
429 int row = 0;
430 for( const LAYER_PAIR_INFO& layerPairInfo : storePairs )
431 {
432 fillRowFromLayerPair( row, layerPairInfo );
433 row++;
434 }
435 }
436
437 void fillRowFromLayerPair( int aRow, const LAYER_PAIR_INFO& aLayerPairInfo )
438 {
439 wxASSERT_MSG( aRow < m_grid.GetNumberRows(), "Row index out of bounds" );
440
441 const LAYER_PAIR& layerPair = aLayerPairInfo.GetLayerPair();
442
443 const wxString layerNames = m_layerPresentation.getLayerPairName( layerPair );
444
445 m_grid.SetCellValue( aRow, (int) COLNUMS::LAYERNAMES, layerNames );
446
447 const std::optional<wxString> userName = aLayerPairInfo.GetName();
448 if( userName )
449 {
450 m_grid.SetCellValue( aRow, (int) COLNUMS::USERNAME, *userName );
451 }
452
453 m_grid.SetCellValue( aRow, (int) COLNUMS::ENABLED,
454 aLayerPairInfo.IsEnabled() ? wxT( "1" ) : wxT( "0" ) );
455
456 // Set the color swatch
457 std::unique_ptr<wxBitmap>& swatch =
459 layerPair.GetLayerA(), layerPair.GetLayerB(), KiIconScale( &m_grid ) ) );
460
461 m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH,
462 new GRID_CELL_ICON_RENDERER( *swatch ) );
463
464 m_grid.SetReadOnly( aRow, (int) COLNUMS::SWATCH );
465 m_grid.SetReadOnly( aRow, (int) COLNUMS::LAYERNAMES );
466 }
467
468 void onUserNameChanged( int aRow, const wxString& aNewValue )
469 {
471 changedPair.SetName( aNewValue );
472 }
473
474 void onEnableChanged( int aRow, bool aNewValue )
475 {
477 changedPair.SetEnabled( aNewValue );
478 }
479
480 void onPairActivated( int aRow )
481 {
482 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[aRow];
483 const LAYER_PAIR& layerPair = layerPairInfo.GetLayerPair();
484
486 }
487
491
492 // Lifetime managment of the swatches
493 std::vector<std::unique_ptr<wxBitmap>> m_swatches;
494
495 std::unique_ptr<WX_GRID_AUTOSIZER> m_autosizer;
496};
497
498
504{
506 {
507 SELECT = 0,
508 COLOR = 1,
509 LAYERNAME = 2,
510 };
511
512public:
513 COPPER_LAYERS_PAIR_SELECTION_UI( wxGrid& aLeftGrid, wxGrid& aRightGrid,
514 PCB_LAYER_PRESENTATION& aPresentation,
515 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
516 m_layerPresentation( aPresentation ), m_layerPairSettings( aLayerPairSettings ),
517 m_leftGrid( aLeftGrid ), m_rightGrid( aRightGrid )
518 {
521
523 {
524 if( IsCopperLayer( layerId ) )
525 {
526 m_layersId.push_back( layerId );
527 }
528 }
529
532
533 m_leftGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
534 [this]( wxGridEvent& aEvent )
535 {
536 onLeftGridRowSelected( aEvent.GetRow() );
537 } );
538
539 m_rightGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
540 [this]( wxGridEvent& aEvent )
541 {
542 onRightGridRowSelected( aEvent.GetRow() );
543 } );
544
545 m_layerPairSettings.Bind( PCB_CURRENT_LAYER_PAIR_CHANGED,
546 [this]( wxCommandEvent& aEvent )
547 {
548 const LAYER_PAIR& newPair =
551 rowForLayer( newPair.GetLayerB() ) );
552 } );
553 }
554
555private:
556 void configureGrid( wxGrid& aGrid )
557 {
558 aGrid.SetCellHighlightPenWidth( 0 );
559 aGrid.SetColFormatBool( (int) CU_LAYER_COLNUMS::SELECT );
560 }
561
562 void fillLayerGrid( wxGrid& aGrid )
563 {
565
566 aGrid.AppendRows( m_layersId.size() - 1 );
567
568 int row = 0;
569 for( const PCB_LAYER_ID& layerId : m_layersId )
570 {
571 const wxColour fg = m_layerPresentation.getLayerColor( layerId ).ToColour();
572 const wxColour color(
573 wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
574 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
575 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
576
577 const wxString layerName = wxT( " " ) + m_layerPresentation.getLayerName( layerId );
578
579 aGrid.SetCellBackgroundColour( row, (int) CU_LAYER_COLNUMS::COLOR, color );
580 aGrid.SetCellValue( row, (int) CU_LAYER_COLNUMS::LAYERNAME, layerName );
581
582 row++;
583 };
584
585 // Now fix min grid layer name column size (it also sets a minimal size)
586 aGrid.AutoSizeColumn( (int) CU_LAYER_COLNUMS::LAYERNAME );
587 }
588
589 PCB_LAYER_ID layerForRow( int aRow ) { return m_layersId.at( aRow ); }
590
591 int rowForLayer( PCB_LAYER_ID aLayerId )
592 {
593 for( unsigned i = 0; i < m_layersId.size(); ++i )
594 {
595 if( m_layersId[i] == aLayerId )
596 {
597 return i;
598 }
599 }
600
601 wxASSERT_MSG( false, wxString::Format( "Unknown layer in grid: %d", aLayerId ) );
602 return 0;
603 }
604
605 void onLeftGridRowSelected( int aRow )
606 {
607 LAYER_PAIR newPair{
608 layerForRow( aRow ),
610 };
613 }
614
615 void onRightGridRowSelected( int aRow )
616 {
617 LAYER_PAIR newPair{
619 layerForRow( aRow ),
620 };
623 }
624
631 void setCurrentSelection( int aLeftRow, int aRightRow )
632 {
633 const auto selectGridRow = []( wxGrid& aGrid, int aRow, bool aSelect )
634 {
635 // At start, there is no old row
636 if( aRow < 0 )
637 {
638 return;
639 }
640 const wxString val = aSelect ? wxT( "1" ) : wxEmptyString;
641 aGrid.SetCellValue( aRow, (int) CU_LAYER_COLNUMS::SELECT, val );
642 aGrid.SetGridCursor( aRow, (int) CU_LAYER_COLNUMS::COLOR );
643 };
644
645 if( m_leftCurrRow != aLeftRow )
646 {
647 selectGridRow( m_leftGrid, m_leftCurrRow, false );
648 selectGridRow( m_leftGrid, aLeftRow, true );
649 m_leftCurrRow = aLeftRow;
650 }
651
652 if( m_rightCurrRow != aRightRow )
653 {
654 selectGridRow( m_rightGrid, m_rightCurrRow, false );
655 selectGridRow( m_rightGrid, aRightRow, true );
656 m_rightCurrRow = aRightRow;
657 }
658 }
659
662 std::vector<PCB_LAYER_ID> m_layersId;
663 wxGrid& m_leftGrid;
664 wxGrid& m_rightGrid;
665
668};
669
670
678{
679public:
681 LAYER_PAIR_SETTINGS& aBoardSettings ) :
683 m_boardPairSettings( aBoardSettings ), m_dialogPairSettings( aBoardSettings ),
684 m_layerPresentation( &aParent ),
688 {
689 m_addToPresetsButton->SetBitmap( KiBitmapBundle( BITMAPS::right ) );
690 m_deleteRowButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
691
692 m_addToPresetsButton->Bind( wxEVT_BUTTON,
693 [this]( wxCommandEvent& aEvent )
694 {
695 const LAYER_PAIR newPair =
698 } );
699
700 m_deleteRowButton->Bind( wxEVT_BUTTON,
701 [this]( wxCommandEvent& aEvent )
702 {
704 } );
705
706 SetFocus();
707
708 GetSizer()->SetSizeHints( this );
709 Center();
710 }
711
712 bool TransferDataToWindow() override
713 {
714 m_presetsGrid->Freeze();
715 m_leftGridLayers->Freeze();
716 m_rightGridLayers->Freeze();
717
719
720 m_rightGridLayers->Thaw();
721 m_leftGridLayers->Thaw();
722 m_presetsGrid->Thaw();
723 return true;
724 }
725
727 {
728 // Pull out the dialog's stored pairs
729 std::span<const LAYER_PAIR_INFO> storePairs = m_dialogPairSettings.GetLayerPairs();
730
733
734 return true;
735 }
736
737private:
738 // The BOARD's pair store to be updated
740 // A local copy while we modify it
742 // Information about the layer presentation (colors, etc)
744 // UI controllers
747};
748
749
751{
752 LAYER_PAIR_SETTINGS* const boardSettings = frame()->GetLayerPairSettings();
753
754 if( !boardSettings )
755 {
756 // Should only be used for suitable frame types with layer pairs
757 wxASSERT_MSG( false, "Could not access layer pair settings" );
758 return 0;
759 }
760
761 SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( *frame(), *boardSettings );
762
763 if( dlg.ShowModal() == wxID_OK )
764 {
765 const LAYER_PAIR layerPair = boardSettings->GetCurrentLayerPair();
766
767 // select the same layer for both layers is allowed (normal in some boards)
768 // but could be a mistake. So display an info message
769 if( layerPair.GetLayerA() == layerPair.GetLayerB() )
770 {
771 DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
772 }
773 }
774
775 return 0;
776}
int color
Definition: DXF_plotter.cpp:60
int KiIconScale(wxWindow *aWindow)
Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScale...
Definition: bitmap.cpp:122
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:216
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:829
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:812
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:614
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
Class that manages the UI for the copper layer pair presets list based on an injected layer pair stor...
Definition: sel_layer.cpp:328
void onPairActivated(int aRow)
Definition: sel_layer.cpp:480
void onUserNameChanged(int aRow, const wxString &aNewValue)
Definition: sel_layer.cpp:468
std::vector< std::unique_ptr< wxBitmap > > m_swatches
Definition: sel_layer.cpp:493
COPPER_LAYERS_PAIR_PRESETS_UI(WX_GRID &aGrid, PCB_LAYER_PRESENTATION &aPresentation, LAYER_PAIR_SETTINGS &aLayerPairSettings)
Definition: sel_layer.cpp:338
LAYER_PAIR_SETTINGS & m_layerPairSettings
Definition: sel_layer.cpp:490
void OnLayerPairAdded(const LAYER_PAIR &aLayerPair)
Definition: sel_layer.cpp:384
void fillRowFromLayerPair(int aRow, const LAYER_PAIR_INFO &aLayerPairInfo)
Definition: sel_layer.cpp:437
void onEnableChanged(int aRow, bool aNewValue)
Definition: sel_layer.cpp:474
std::unique_ptr< WX_GRID_AUTOSIZER > m_autosizer
Definition: sel_layer.cpp:495
PCB_LAYER_PRESENTATION & m_layerPresentation
Definition: sel_layer.cpp:488
Class that manages the UI for the copper layer pair selection (left and right grids).
Definition: sel_layer.cpp:504
void setCurrentSelection(int aLeftRow, int aRightRow)
Set the current layer selection.
Definition: sel_layer.cpp:631
void onRightGridRowSelected(int aRow)
Definition: sel_layer.cpp:615
COPPER_LAYERS_PAIR_SELECTION_UI(wxGrid &aLeftGrid, wxGrid &aRightGrid, PCB_LAYER_PRESENTATION &aPresentation, LAYER_PAIR_SETTINGS &aLayerPairSettings)
Definition: sel_layer.cpp:513
PCB_LAYER_PRESENTATION & m_layerPresentation
Definition: sel_layer.cpp:660
void configureGrid(wxGrid &aGrid)
Definition: sel_layer.cpp:556
void fillLayerGrid(wxGrid &aGrid)
Definition: sel_layer.cpp:562
int rowForLayer(PCB_LAYER_ID aLayerId)
Definition: sel_layer.cpp:591
LAYER_PAIR_SETTINGS & m_layerPairSettings
Definition: sel_layer.cpp:661
PCB_LAYER_ID layerForRow(int aRow)
Definition: sel_layer.cpp:589
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:662
void onLeftGridRowSelected(int aRow)
Definition: sel_layer.cpp:605
Class DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.
Class DIALOG_LAYER_SELECTION_BASE.
bool IsQuasiModal() const
Definition: dialog_shim.h:77
bool m_useCalculatedSize
Definition: dialog_shim.h:198
void EndQuasiModal(int retCode)
void SetPosition(const wxPoint &aNewPosition)
Force the position of the dialog to a new position.
int ShowModal() override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
wxColour ToColour() const
Definition: color4d.cpp:220
All information about a layer pair as stored in the layer pair store.
const LAYER_PAIR & GetLayerPair() const
void SetName(const wxString &aNewName)
const std::optional< wxString > & GetName() const
void SetEnabled(bool aNewEnabled)
Management class for layer pairs in a PCB.
Definition: layer_pairs.h:47
bool AddLayerPair(LAYER_PAIR_INFO aPair)
Definition: layer_pairs.cpp:78
std::span< const LAYER_PAIR_INFO > GetLayerPairs() const
Returns a span of all stored layer pairs.
void SetCurrentLayerPair(const LAYER_PAIR &aPair)
Set the "active" layer pair.
void SetLayerPairs(std::span< const LAYER_PAIR_INFO > aPairs)
Replace the stored layer pairs with the given list.
bool RemoveLayerPair(const LAYER_PAIR &aPair)
Remove the matching layer pair from the store, if present.
const LAYER_PAIR & GetCurrentLayerPair() const
Definition: layer_pairs.h:87
PCB_LAYER_ID GetLayerA() const
PCB_LAYER_ID GetLayerB() const
static std::unique_ptr< wxBitmap > CreateLayerPairIcon(const KIGFX::COLOR4D &aBgColor, const KIGFX::COLOR4D &aTopColor, const KIGFX::COLOR4D &aBottomColor, int aScale)
Create a layer pair "side-by-side swatch" icon.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
LSEQ UIOrder() const
Return the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:712
static TOOL_ACTION * LayerIDToAction(PCB_LAYER_ID aLayerID)
Translate a layer ID into the action that switches to that layer.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard() const
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, const LSET &aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:302
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Helper to retrieve the current color settings.
Class that manages the presentation of PCB layers in a PCB frame.
wxString getLayerName(int aLayer) const override
Definition: sel_layer.cpp:78
PCB_LAYER_PRESENTATION(PCB_BASE_FRAME *aFrame)
Definition: sel_layer.cpp:58
LSEQ getOrderedEnabledLayers() const
Definition: sel_layer.cpp:86
COLOR4D getLayerColor(int aLayer) const override
Definition: sel_layer.cpp:62
wxString getLayerPairName(const LAYER_PAIR &aPair) const
Definition: sel_layer.cpp:91
Display a PCB layers list in a dialog to select one layer from this list.
Definition: sel_layer.cpp:104
void OnLeftGridCellClick(wxGridEvent &aEvent) override
Definition: sel_layer.cpp:280
PCB_LAYER_PRESENTATION m_layerPresentation
Definition: sel_layer.cpp:129
void OnRightGridCellClick(wxGridEvent &aEvent) override
Definition: sel_layer.cpp:291
void onCharHook(wxKeyEvent &event)
Definition: sel_layer.cpp:210
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
Definition: sel_layer.cpp:132
std::vector< PCB_LAYER_ID > m_layersIdRightColumn
Definition: sel_layer.cpp:133
void OnMouseMove(wxUpdateUIEvent &aEvent) override
Definition: sel_layer.cpp:175
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:130
PCB_ONE_LAYER_SELECTOR(PCB_BASE_FRAME *aParent, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask, bool aHideCheckBoxes=false)
Definition: sel_layer.cpp:137
wxString getLayerHotKey(PCB_LAYER_ID aLayer) const
Definition: sel_layer.cpp:121
T * frame() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:125
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:750
Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
Definition: sel_layer.cpp:678
bool TransferDataToWindow() override
Definition: sel_layer.cpp:712
PCB_LAYER_PRESENTATION m_layerPresentation
Definition: sel_layer.cpp:743
LAYER_PAIR_SETTINGS & m_boardPairSettings
Definition: sel_layer.cpp:739
SELECT_COPPER_LAYERS_PAIR_DIALOG(PCB_BASE_FRAME &aParent, LAYER_PAIR_SETTINGS &aBoardSettings)
Definition: sel_layer.cpp:680
COPPER_LAYERS_PAIR_PRESETS_UI m_presetsGridController
Definition: sel_layer.cpp:746
COPPER_LAYERS_PAIR_SELECTION_UI m_pairSelectionController
Definition: sel_layer.cpp:745
bool TransferDataFromWindow() override
Definition: sel_layer.cpp:726
LAYER_PAIR_SETTINGS m_dialogPairSettings
Definition: sel_layer.cpp:741
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieve a color settings object that applications can read colors from.
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
void SetBitmap(const wxBitmapBundle &aBmp)
int GetHotKey() const
Return the hotkey keycode which initiates the action.
Definition: tool_action.h:348
Generic, UI-independent tool event.
Definition: tool_event.h:168
std::map< int, int > COL_MIN_WIDTHS
Map of column indices to minimum widths.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:221
This file is part of the common library.
#define _(s)
wxString AddHotkeyName(const wxString &aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle)
@ IS_COMMENT
Definition: hotkeys_basic.h:82
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition: layer_ids.h:663
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:280
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:723
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition: wxgtk/ui.cpp:677
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:1071
see class PGM_BASE
#define LAYER_HK_COLUMN
Definition: sel_layer.cpp:55
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:54
#define SELECT_COLNUM
Definition: sel_layer.cpp:52
#define COLOR_COLNUM
Definition: sel_layer.cpp:53