KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 (C) 1992-2021 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>
48
49
50// Column position by function:
51#define SELECT_COLNUM 0
52#define COLOR_COLNUM 1
53#define LAYERNAME_COLNUM 2
54#define LAYER_HK_COLUMN 3
55
56
58{
59}
60
62{
63 if( m_boardFrame )
64 {
65 return m_boardFrame->GetColorSettings()->GetColor( aLayer );
66 }
67 else
68 {
71 COLOR_SETTINGS* current = mgr.GetColorSettings( cfg->m_ColorTheme );
72
73 return current->GetColor( aLayer );
74 }
75}
76
77wxString PCB_LAYER_PRESENTATION::getLayerName( int aLayer ) const
78{
79 if( m_boardFrame )
80 return m_boardFrame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
81 else
82 return BOARD::GetStandardLayerName( ToLAYER_ID( aLayer ) );
83}
84
86{
88}
89
91{
92 const wxString layerAName = getLayerName( aPair.GetLayerA() );
93 const wxString layerBName = getLayerName( aPair.GetLayerB() );
94
95 return layerAName + wxT( " / " ) + layerBName;
96}
97
98
103{
104public:
105 PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, PCB_LAYER_ID aDefaultLayer,
106 LSET aNotAllowedLayersMask, bool aHideCheckBoxes = false );
108
110
111private:
112 // Event handlers
113 void OnLeftGridCellClick( wxGridEvent& aEvent ) override;
114 void OnRightGridCellClick( wxGridEvent& aEvent ) override;
115 void OnMouseMove( wxUpdateUIEvent& aEvent ) override;
116
117 // Will close the dialog on ESC key
118 void onCharHook( wxKeyEvent& event );
119
120 wxString getLayerHotKey( PCB_LAYER_ID aLayer ) const
121 {
122 int code = PCB_ACTIONS::LayerIDToAction( aLayer )->GetHotKey();
123 return AddHotkeyName( wxS( "" ), code, IS_COMMENT );
124 }
125
126 void buildList();
127
131 std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
132 std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
133};
134
135
137 LSET aNotAllowedLayersMask, bool aHideCheckBoxes ) :
138 DIALOG_LAYER_SELECTION_BASE( aParent ), m_layerPresentation( aParent )
139{
140 m_useCalculatedSize = true;
141
142 m_layerSelected = aDefaultLayer;
143 m_notAllowedLayersMask = aNotAllowedLayersMask;
144
145 m_leftGridLayers->SetCellHighlightPenWidth( 0 );
146 m_rightGridLayers->SetCellHighlightPenWidth( 0 );
147 m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
148 m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
149
150 m_leftGridLayers->AppendCols( 1 );
151
152 buildList();
153
154 if( aHideCheckBoxes )
155 {
158 }
159
160 Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
161
162 Layout();
163 GetSizer()->SetSizeHints( this );
164 SetFocus();
165}
166
167
169{
170 Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
171}
172
173
174void PCB_ONE_LAYER_SELECTOR::OnMouseMove( wxUpdateUIEvent& aEvent )
175{
179
180 wxPoint mouse_pos = KIPLATFORM::UI::GetMousePosition();
181 wxPoint left_pos = m_leftGridLayers->ScreenToClient( mouse_pos );
182 wxPoint right_pos = m_rightGridLayers->ScreenToClient( mouse_pos );
183
184 if( m_leftGridLayers->HitTest( left_pos ) == wxHT_WINDOW_INSIDE )
185 {
186 int row = m_leftGridLayers->YToRow( left_pos.y );
187
188 if( row != wxNOT_FOUND && row < static_cast<int>( m_layersIdLeftColumn.size() ) )
189 {
191 m_leftGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYER_HK_COLUMN );
192 return;
193 }
194 }
195
196 if( m_rightGridLayers->HitTest( right_pos ) == wxHT_WINDOW_INSIDE )
197 {
198 int row = m_rightGridLayers->YToRow( right_pos.y );
199
200 if( row == wxNOT_FOUND || row >= static_cast<int>( m_layersIdRightColumn.size() ) )
201 return;
202
204 m_rightGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYERNAME_COLNUM );
205 }
206}
207
208
209void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
210{
211 if( event.GetKeyCode() == WXK_ESCAPE )
212 Close();
213}
214
215
217{
219 int left_row = 0;
220 int right_row = 0;
221 wxString layername;
222
224 {
225 if( m_notAllowedLayersMask[layerid] )
226 continue;
227
228 wxColour fg = m_layerPresentation.getLayerColor( layerid ).ToColour();
229 wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
230 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
231 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
232
233 layername = wxT( " " ) + m_layerPresentation.getLayerName( layerid );
234
235 if( IsCopperLayer( layerid ) )
236 {
237 if( left_row )
238 m_leftGridLayers->AppendRows( 1 );
239
240 m_leftGridLayers->SetCellBackgroundColour( left_row, COLOR_COLNUM, color );
241 m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
242 m_leftGridLayers->SetCellValue( left_row, LAYER_HK_COLUMN, getLayerHotKey( layerid ) );
243
244 if( m_layerSelected == layerid )
245 m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, wxT( "1" ) );
246
247 m_layersIdLeftColumn.push_back( layerid );
248 left_row++;
249 }
250 else
251 {
252 if( right_row )
253 m_rightGridLayers->AppendRows( 1 );
254
255 m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
256 m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
257
258 if( m_layerSelected == layerid )
259 m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, wxT( "1" ) );
260
261 m_layersIdRightColumn.push_back( layerid );
262 right_row++;
263 }
264 }
265
266 // Show only populated lists:
267 if( left_row <= 0 )
268 m_leftGridLayers->Show( false );
269
270 if( right_row <= 0 )
271 m_rightGridLayers->Show( false );
272
273 // Now fix min grid column size (it also sets a minimal size)
274 m_leftGridLayers->AutoSizeColumns();
275 m_rightGridLayers->AutoSizeColumns();
276}
277
278
280{
281 m_layerSelected = m_layersIdLeftColumn[event.GetRow()];
282
283 if( IsQuasiModal() )
284 EndQuasiModal( 1 );
285 else
286 EndDialog( 1 );
287}
288
289
291{
292 m_layerSelected = m_layersIdRightColumn[event.GetRow()];
293
294 if( IsQuasiModal() )
295 EndQuasiModal( 2 );
296 else
297 EndDialog( 2 );
298}
299
300
301PCB_LAYER_ID PCB_BASE_FRAME::SelectOneLayer( PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask,
302 wxPoint aDlgPosition )
303{
304 PCB_ONE_LAYER_SELECTOR dlg( this, aDefaultLayer, aNotAllowedLayersMask, true );
305
306 if( aDlgPosition != wxDefaultPosition )
307 {
308 wxSize dlgSize = dlg.GetSize();
309 aDlgPosition.x -= dlgSize.x / 2;
310 aDlgPosition.y -= dlgSize.y / 2;
311 dlg.SetPosition( aDlgPosition );
312 }
313
314 if( dlg.ShowModal() != wxID_CANCEL )
315 return ToLAYER_ID( dlg.GetLayerSelection() );
316 else
317 return UNDEFINED_LAYER;
318}
319
320
326{
327 enum class COLNUMS
328 {
329 ENABLED,
330 SWATCH,
332 USERNAME,
333 };
334
335public:
337 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
338 m_layerPresentation( aPresentation ), m_grid( aGrid ),
339 m_layerPairSettings( aLayerPairSettings )
340 {
341 wxASSERT_MSG( m_grid.GetNumberRows() == 0, "Grid should be empty at controller start" );
342
345
346 m_grid.Bind( wxEVT_GRID_CELL_CHANGED,
347 [this]( wxGridEvent& aEvent )
348 {
349 const int col = aEvent.GetCol();
350 const int row = aEvent.GetRow();
351 if( col == (int) COLNUMS::USERNAME )
352 {
353 onUserNameChanged( row, m_grid.GetCellValue( row, col ) );
354 }
355 else if( col == (int) COLNUMS::ENABLED )
356 {
357 onEnableChanged( row, m_grid.GetCellValue( row, col ) == wxS( "1" ) );
358 }
359 } );
360
361 m_grid.Bind( wxEVT_GRID_CELL_LEFT_DCLICK,
362 [&]( wxGridEvent& aEvent )
363 {
364 const int row = aEvent.GetRow();
365 const int col = aEvent.GetCol();
366
367 if( col == (int) COLNUMS::LAYERNAMES || col == (int) COLNUMS::SWATCH )
368 {
369 onPairActivated( row );
370 }
371 } );
372
374 std::make_unique<WX_GRID_AUTOSIZER>( m_grid,
376 { (int) COLNUMS::LAYERNAMES, 72 },
377 { (int) COLNUMS::USERNAME, 72 },
378 },
379 (int) COLNUMS::USERNAME );
380 }
381
382 void OnLayerPairAdded( const LAYER_PAIR& aLayerPair )
383 {
384 LAYER_PAIR_INFO layerPairInfo{ aLayerPair, true, std::nullopt };
385
386 const bool added = m_layerPairSettings.AddLayerPair( layerPairInfo );
387
388 if( added )
389 {
390 m_grid.AppendRows( 1 );
391 fillRowFromLayerPair( m_grid.GetNumberRows() - 1, layerPairInfo );
392 }
393 }
394
396 {
397 int row = m_grid.GetGridCursorRow();
398
399 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[row];
400 const bool removed = m_layerPairSettings.RemoveLayerPair( layerPairInfo.GetLayerPair() );
401
402 if( removed )
403 {
404 m_grid.DeleteRows( row );
405 }
406 }
407
408private:
410 {
411 m_grid.UseNativeColHeader( true );
412
413 m_grid.SetCellHighlightPenWidth( 0 );
414 m_grid.SetColFormatBool( (int) COLNUMS::ENABLED );
415
416 m_grid.SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
417
418 m_grid.AutoSizeColumn( (int) COLNUMS::USERNAME );
419 }
420
422 {
423 std::span<const LAYER_PAIR_INFO> storePairs = m_layerPairSettings.GetLayerPairs();
424
425 m_grid.AppendRows( storePairs.size() );
426
427 int row = 0;
428 for( const LAYER_PAIR_INFO& layerPairInfo : storePairs )
429 {
430 fillRowFromLayerPair( row, layerPairInfo );
431 row++;
432 }
433 }
434
435 void fillRowFromLayerPair( int aRow, const LAYER_PAIR_INFO& aLayerPairInfo )
436 {
437 wxASSERT_MSG( aRow < m_grid.GetNumberRows(), "Row index out of bounds" );
438
439 const LAYER_PAIR& layerPair = aLayerPairInfo.GetLayerPair();
440
441 const wxString layerNames = m_layerPresentation.getLayerPairName( layerPair );
442
443 m_grid.SetCellValue( aRow, (int) COLNUMS::LAYERNAMES, layerNames );
444
445 const std::optional<wxString> userName = aLayerPairInfo.GetName();
446 if( userName )
447 {
448 m_grid.SetCellValue( aRow, (int) COLNUMS::USERNAME, *userName );
449 }
450
451 m_grid.SetCellValue( aRow, (int) COLNUMS::ENABLED,
452 aLayerPairInfo.IsEnabled() ? wxT( "1" ) : wxT( "0" ) );
453
454 // Set the color swatch
455 std::unique_ptr<wxBitmap>& swatch =
457 layerPair.GetLayerA(), layerPair.GetLayerB(), KiIconScale( &m_grid ) ) );
458
459 m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH,
460 new GRID_CELL_ICON_RENDERER( *swatch ) );
461
462 m_grid.SetReadOnly( aRow, (int) COLNUMS::SWATCH );
463 m_grid.SetReadOnly( aRow, (int) COLNUMS::LAYERNAMES );
464 }
465
466 void onUserNameChanged( int aRow, const wxString& aNewValue )
467 {
469 changedPair.SetName( aNewValue );
470 }
471
472 void onEnableChanged( int aRow, bool aNewValue )
473 {
475 changedPair.SetEnabled( aNewValue );
476 }
477
478 void onPairActivated( int aRow )
479 {
480 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[aRow];
481 const LAYER_PAIR& layerPair = layerPairInfo.GetLayerPair();
482
484 }
485
489
490 // Lifetime managment of the swatches
491 std::vector<std::unique_ptr<wxBitmap>> m_swatches;
492
493 std::unique_ptr<WX_GRID_AUTOSIZER> m_autosizer;
494};
495
496
502{
504 {
505 SELECT = 0,
506 COLOR = 1,
507 LAYERNAME = 2,
508 };
509
510public:
511 COPPER_LAYERS_PAIR_SELECTION_UI( wxGrid& aLeftGrid, wxGrid& aRightGrid,
512 PCB_LAYER_PRESENTATION& aPresentation,
513 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
514 m_layerPresentation( aPresentation ), m_layerPairSettings( aLayerPairSettings ),
515 m_leftGrid( aLeftGrid ), m_rightGrid( aRightGrid )
516 {
519
521 {
522 if( IsCopperLayer( layerId ) )
523 {
524 m_layersId.push_back( layerId );
525 }
526 }
527
530
531 m_leftGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
532 [this]( wxGridEvent& aEvent )
533 {
534 onLeftGridRowSelected( aEvent.GetRow() );
535 } );
536
537 m_rightGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
538 [this]( wxGridEvent& aEvent )
539 {
540 onRightGridRowSelected( aEvent.GetRow() );
541 } );
542
543 m_layerPairSettings.Bind( PCB_CURRENT_LAYER_PAIR_CHANGED,
544 [this]( wxCommandEvent& aEvent )
545 {
546 const LAYER_PAIR& newPair =
549 rowForLayer( newPair.GetLayerB() ) );
550 } );
551 }
552
553private:
554 void configureGrid( wxGrid& aGrid )
555 {
556 aGrid.SetCellHighlightPenWidth( 0 );
557 aGrid.SetColFormatBool( (int) CU_LAYER_COLNUMS::SELECT );
558 }
559
560 void fillLayerGrid( wxGrid& aGrid )
561 {
563
564 aGrid.AppendRows( m_layersId.size() - 1 );
565
566 int row = 0;
567 for( const PCB_LAYER_ID& layerId : m_layersId )
568 {
569 const wxColour fg = m_layerPresentation.getLayerColor( layerId ).ToColour();
570 const wxColour color(
571 wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
572 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
573 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
574
575 const wxString layerName = wxT( " " ) + m_layerPresentation.getLayerName( layerId );
576
577 aGrid.SetCellBackgroundColour( row, (int) CU_LAYER_COLNUMS::COLOR, color );
578 aGrid.SetCellValue( row, (int) CU_LAYER_COLNUMS::LAYERNAME, layerName );
579
580 row++;
581 };
582
583 // Now fix min grid layer name column size (it also sets a minimal size)
584 aGrid.AutoSizeColumn( (int) CU_LAYER_COLNUMS::LAYERNAME );
585 }
586
587 PCB_LAYER_ID layerForRow( int aRow ) { return m_layersId.at( aRow ); }
588
589 int rowForLayer( PCB_LAYER_ID aLayerId )
590 {
591 for( unsigned i = 0; i < m_layersId.size(); ++i )
592 {
593 if( m_layersId[i] == aLayerId )
594 {
595 return i;
596 }
597 }
598
599 wxASSERT_MSG( false, wxString::Format( "Unknown layer in grid: %d", aLayerId ) );
600 return 0;
601 }
602
603 void onLeftGridRowSelected( int aRow )
604 {
605 LAYER_PAIR newPair{
606 layerForRow( aRow ),
608 };
611 }
612
613 void onRightGridRowSelected( int aRow )
614 {
615 LAYER_PAIR newPair{
617 layerForRow( aRow ),
618 };
621 }
622
629 void setCurrentSelection( int aLeftRow, int aRightRow )
630 {
631 const auto selectGridRow = []( wxGrid& aGrid, int aRow, bool aSelect )
632 {
633 // At start, there is no old row
634 if( aRow < 0 )
635 {
636 return;
637 }
638 const wxString val = aSelect ? wxT( "1" ) : wxEmptyString;
639 aGrid.SetCellValue( aRow, (int) CU_LAYER_COLNUMS::SELECT, val );
640 aGrid.SetGridCursor( aRow, (int) CU_LAYER_COLNUMS::COLOR );
641 };
642
643 if( m_leftCurrRow != aLeftRow )
644 {
645 selectGridRow( m_leftGrid, m_leftCurrRow, false );
646 selectGridRow( m_leftGrid, aLeftRow, true );
647 m_leftCurrRow = aLeftRow;
648 }
649
650 if( m_rightCurrRow != aRightRow )
651 {
652 selectGridRow( m_rightGrid, m_rightCurrRow, false );
653 selectGridRow( m_rightGrid, aRightRow, true );
654 m_rightCurrRow = aRightRow;
655 }
656 }
657
660 std::vector<PCB_LAYER_ID> m_layersId;
661 wxGrid& m_leftGrid;
662 wxGrid& m_rightGrid;
663
666};
667
668
676{
677public:
679 LAYER_PAIR_SETTINGS& aBoardSettings ) :
681 m_boardPairSettings( aBoardSettings ), m_dialogPairSettings( aBoardSettings ),
682 m_layerPresentation( &aParent ),
686 {
687 m_addToPresetsButton->SetBitmap( KiBitmapBundle( BITMAPS::right ) );
688 m_deleteRowButton->SetBitmap( KiBitmapBundle( BITMAPS::trash ) );
689
690 m_addToPresetsButton->Bind( wxEVT_BUTTON,
691 [this]( wxCommandEvent& aEvent )
692 {
693 const LAYER_PAIR newPair =
696 } );
697
698 m_deleteRowButton->Bind( wxEVT_BUTTON,
699 [this]( wxCommandEvent& aEvent )
700 {
702 } );
703
704 SetFocus();
705
706 GetSizer()->SetSizeHints( this );
707 Center();
708 }
709
710 bool TransferDataToWindow() override
711 {
712 m_presetsGrid->Freeze();
713 m_leftGridLayers->Freeze();
714 m_rightGridLayers->Freeze();
715
717
718 m_rightGridLayers->Thaw();
719 m_leftGridLayers->Thaw();
720 m_presetsGrid->Thaw();
721 return true;
722 }
723
725 {
726 // Pull out the dialog's stored pairs
727 std::span<const LAYER_PAIR_INFO> storePairs = m_dialogPairSettings.GetLayerPairs();
728
731
732 return true;
733 }
734
735private:
736 // The BOARD's pair store to be updated
738 // A local copy while we modify it
740 // Information about the layer presentation (colors, etc)
742 // UI controllers
745};
746
747
749{
750 LAYER_PAIR_SETTINGS* const boardSettings = frame()->GetLayerPairSettings();
751
752 if( !boardSettings )
753 {
754 // Should only be used for suitable frame types with layer pairs
755 wxASSERT_MSG( false, "Could not access layer pair settings" );
756 return 0;
757 }
758
759 SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( *frame(), *boardSettings );
760
761 if( dlg.ShowModal() == wxID_OK )
762 {
763 const LAYER_PAIR layerPair = boardSettings->GetCurrentLayerPair();
764
765 // select the same layer for both layers is allowed (normal in some boards)
766 // but could be a mistake. So display an info message
767 if( layerPair.GetLayerA() == layerPair.GetLayerB() )
768 {
769 DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
770 }
771 }
772
773 return 0;
774}
int color
Definition: DXF_plotter.cpp:58
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
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
wxString m_ColorTheme
Active color theme name.
Definition: app_settings.h:197
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:778
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition: board.h:786
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:574
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:326
void onPairActivated(int aRow)
Definition: sel_layer.cpp:478
void onUserNameChanged(int aRow, const wxString &aNewValue)
Definition: sel_layer.cpp:466
std::vector< std::unique_ptr< wxBitmap > > m_swatches
Definition: sel_layer.cpp:491
COPPER_LAYERS_PAIR_PRESETS_UI(WX_GRID &aGrid, PCB_LAYER_PRESENTATION &aPresentation, LAYER_PAIR_SETTINGS &aLayerPairSettings)
Definition: sel_layer.cpp:336
LAYER_PAIR_SETTINGS & m_layerPairSettings
Definition: sel_layer.cpp:488
void OnLayerPairAdded(const LAYER_PAIR &aLayerPair)
Definition: sel_layer.cpp:382
void fillRowFromLayerPair(int aRow, const LAYER_PAIR_INFO &aLayerPairInfo)
Definition: sel_layer.cpp:435
void onEnableChanged(int aRow, bool aNewValue)
Definition: sel_layer.cpp:472
std::unique_ptr< WX_GRID_AUTOSIZER > m_autosizer
Definition: sel_layer.cpp:493
PCB_LAYER_PRESENTATION & m_layerPresentation
Definition: sel_layer.cpp:486
Class that manages the UI for the copper layer pair selection (left and right grids).
Definition: sel_layer.cpp:502
void setCurrentSelection(int aLeftRow, int aRightRow)
Set the current layer selection.
Definition: sel_layer.cpp:629
void onRightGridRowSelected(int aRow)
Definition: sel_layer.cpp:613
COPPER_LAYERS_PAIR_SELECTION_UI(wxGrid &aLeftGrid, wxGrid &aRightGrid, PCB_LAYER_PRESENTATION &aPresentation, LAYER_PAIR_SETTINGS &aLayerPairSettings)
Definition: sel_layer.cpp:511
PCB_LAYER_PRESENTATION & m_layerPresentation
Definition: sel_layer.cpp:658
void configureGrid(wxGrid &aGrid)
Definition: sel_layer.cpp:554
void fillLayerGrid(wxGrid &aGrid)
Definition: sel_layer.cpp:560
int rowForLayer(PCB_LAYER_ID aLayerId)
Definition: sel_layer.cpp:589
LAYER_PAIR_SETTINGS & m_layerPairSettings
Definition: sel_layer.cpp:659
PCB_LAYER_ID layerForRow(int aRow)
Definition: sel_layer.cpp:587
std::vector< PCB_LAYER_ID > m_layersId
Definition: sel_layer.cpp:660
void onLeftGridRowSelected(int aRow)
Definition: sel_layer.cpp:603
Class DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE.
Class DIALOG_LAYER_SELECTION_BASE.
bool IsQuasiModal() const
Definition: dialog_shim.h:113
bool m_useCalculatedSize
Definition: dialog_shim.h:226
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:36
LSEQ UIOrder() const
Returns the copper, technical and user layers in the order shown in layer widget.
Definition: lset.cpp:809
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.
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:301
BOARD * GetBoard() const
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:77
PCB_LAYER_PRESENTATION(PCB_BASE_FRAME *aFrame)
Definition: sel_layer.cpp:57
LSEQ getOrderedEnabledLayers() const
Definition: sel_layer.cpp:85
COLOR4D getLayerColor(int aLayer) const override
Definition: sel_layer.cpp:61
wxString getLayerPairName(const LAYER_PAIR &aPair) const
Definition: sel_layer.cpp:90
Display a PCB layers list in a dialog to select one layer from this list.
Definition: sel_layer.cpp:103
void OnLeftGridCellClick(wxGridEvent &aEvent) override
Definition: sel_layer.cpp:279
PCB_LAYER_PRESENTATION m_layerPresentation
Definition: sel_layer.cpp:128
void OnRightGridCellClick(wxGridEvent &aEvent) override
Definition: sel_layer.cpp:290
void onCharHook(wxKeyEvent &event)
Definition: sel_layer.cpp:209
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
Definition: sel_layer.cpp:131
std::vector< PCB_LAYER_ID > m_layersIdRightColumn
Definition: sel_layer.cpp:132
void OnMouseMove(wxUpdateUIEvent &aEvent) override
Definition: sel_layer.cpp:174
PCB_LAYER_ID m_layerSelected
Definition: sel_layer.cpp:129
PCB_ONE_LAYER_SELECTOR(PCB_BASE_FRAME *aParent, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask, bool aHideCheckBoxes=false)
Definition: sel_layer.cpp:136
wxString getLayerHotKey(PCB_LAYER_ID aLayer) const
Definition: sel_layer.cpp:120
T * frame() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:748
Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
Definition: sel_layer.cpp:676
bool TransferDataToWindow() override
Definition: sel_layer.cpp:710
PCB_LAYER_PRESENTATION m_layerPresentation
Definition: sel_layer.cpp:741
LAYER_PAIR_SETTINGS & m_boardPairSettings
Definition: sel_layer.cpp:737
SELECT_COPPER_LAYERS_PAIR_DIALOG(PCB_BASE_FRAME &aParent, LAYER_PAIR_SETTINGS &aBoardSettings)
Definition: sel_layer.cpp:678
COPPER_LAYERS_PAIR_PRESETS_UI m_presetsGridController
Definition: sel_layer.cpp:744
COPPER_LAYERS_PAIR_SELECTION_UI m_pairSelectionController
Definition: sel_layer.cpp:743
bool TransferDataFromWindow() override
Definition: sel_layer.cpp:724
LAYER_PAIR_SETTINGS m_dialogPairSettings
Definition: sel_layer.cpp:739
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
T * GetAppSettings(const wxString &aFilename)
Returns a handle to the a given settings by type If the settings have already been loaded,...
int GetHotKey() const
Return the hotkey keycode which initiates the action.
Definition: tool_action.h:313
Generic, UI-independent tool event.
Definition: tool_event.h:167
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:222
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:78
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:531
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:221
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:820
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition: wxgtk/ui.cpp:620
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1060
see class PGM_BASE
#define LAYER_HK_COLUMN
Definition: sel_layer.cpp:54
#define LAYERNAME_COLNUM
Definition: sel_layer.cpp:53
#define SELECT_COLNUM
Definition: sel_layer.cpp:51
#define COLOR_COLNUM
Definition: sel_layer.cpp:52