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 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>
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
60
62{
63 if( m_boardFrame )
64 {
65 return m_boardFrame->GetColorSettings()->GetColor( aLayer );
66 }
67 else
68 {
71
72 return current->GetColor( aLayer );
73 }
74}
75
76wxString PCB_LAYER_PRESENTATION::getLayerName( int aLayer ) const
77{
78 if( m_boardFrame )
79 return m_boardFrame->GetBoard()->GetLayerName( ToLAYER_ID( aLayer ) );
80 else
81 return BOARD::GetStandardLayerName( ToLAYER_ID( aLayer ) );
82}
83
85{
86 return m_boardFrame->GetBoard()->GetEnabledLayers().UIOrder();
87}
88
90{
91 const wxString layerAName = getLayerName( aPair.GetLayerA() );
92 const wxString layerBName = getLayerName( aPair.GetLayerB() );
93
94 return layerAName + wxT( " / " ) + layerBName;
95}
96
97
102{
103public:
104 PCB_ONE_LAYER_SELECTOR( PCB_BASE_FRAME* aParent, PCB_LAYER_ID aDefaultLayer,
105 LSET aNotAllowedLayersMask, bool aHideCheckBoxes = false );
107
109
110private:
111 // Event handlers
112 void OnLeftGridCellClick( wxGridEvent& aEvent ) override;
113 void OnRightGridCellClick( wxGridEvent& aEvent ) override;
114 void OnMouseMove( wxUpdateUIEvent& aEvent ) override;
115
116 // Will close the dialog on ESC key
117 void onCharHook( wxKeyEvent& event );
118
119 wxString getLayerHotKey( PCB_LAYER_ID aLayer ) const
120 {
121 int code = PCB_ACTIONS::LayerIDToAction( aLayer )->GetHotKey();
122 return AddHotkeyName( wxS( "" ), code, IS_COMMENT );
123 }
124
125 void buildList();
126
130 std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
131 std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
132};
133
134
136 LSET aNotAllowedLayersMask, bool aHideCheckBoxes ) :
138{
139 m_useCalculatedSize = true;
140
141 m_layerSelected = aDefaultLayer;
142 m_notAllowedLayersMask = aNotAllowedLayersMask;
143
144 m_leftGridLayers->SetCellHighlightPenWidth( 0 );
145 m_rightGridLayers->SetCellHighlightPenWidth( 0 );
146 m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
147 m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
148
149 m_leftGridLayers->AppendCols( 1 );
150
151 buildList();
152
153 if( aHideCheckBoxes )
154 {
157 }
158
159 Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
160
161 Layout();
162 GetSizer()->SetSizeHints( this );
163 SetFocus();
164}
165
166
168{
169 Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
170}
171
172
173void PCB_ONE_LAYER_SELECTOR::OnMouseMove( wxUpdateUIEvent& aEvent )
174{
178
179 wxPoint mouse_pos = KIPLATFORM::UI::GetMousePosition();
180 wxPoint left_pos = m_leftGridLayers->ScreenToClient( mouse_pos );
181 wxPoint right_pos = m_rightGridLayers->ScreenToClient( mouse_pos );
182
183 if( m_leftGridLayers->HitTest( left_pos ) == wxHT_WINDOW_INSIDE )
184 {
185 int row = m_leftGridLayers->YToRow( left_pos.y );
186
187 if( row != wxNOT_FOUND && row < static_cast<int>( m_layersIdLeftColumn.size() ) )
188 {
190 m_leftGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYER_HK_COLUMN );
191 return;
192 }
193 }
194
195 if( m_rightGridLayers->HitTest( right_pos ) == wxHT_WINDOW_INSIDE )
196 {
197 int row = m_rightGridLayers->YToRow( right_pos.y );
198
199 if( row == wxNOT_FOUND || row >= static_cast<int>( m_layersIdRightColumn.size() ) )
200 return;
201
203 m_rightGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYERNAME_COLNUM );
204 }
205}
206
207
208void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
209{
210 if( event.GetKeyCode() == WXK_ESCAPE )
211 Close();
212}
213
214
216{
217 wxColour bg = m_layerPresentation.getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
218 int left_row = 0;
219 int right_row = 0;
220 wxString layername;
221
222 for( PCB_LAYER_ID layerid : m_layerPresentation.getOrderedEnabledLayers() )
223 {
224 if( m_notAllowedLayersMask[layerid] )
225 continue;
226
227 wxColour fg = m_layerPresentation.getLayerColor( layerid ).ToColour();
228 wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
229 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
230 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
231
232 layername = wxT( " " ) + m_layerPresentation.getLayerName( layerid );
233
234 if( IsCopperLayer( layerid ) )
235 {
236 if( left_row )
237 m_leftGridLayers->AppendRows( 1 );
238
239 m_leftGridLayers->SetCellBackgroundColour( left_row, COLOR_COLNUM, color );
240 m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
241 m_leftGridLayers->SetCellValue( left_row, LAYER_HK_COLUMN, getLayerHotKey( layerid ) );
242
243 if( m_layerSelected == layerid )
244 m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, wxT( "1" ) );
245
246 m_layersIdLeftColumn.push_back( layerid );
247 left_row++;
248 }
249 else
250 {
251 if( right_row )
252 m_rightGridLayers->AppendRows( 1 );
253
254 m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
255 m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
256
257 if( m_layerSelected == layerid )
258 m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, wxT( "1" ) );
259
260 m_layersIdRightColumn.push_back( layerid );
261 right_row++;
262 }
263 }
264
265 // Show only populated lists:
266 if( left_row <= 0 )
267 m_leftGridLayers->Show( false );
268
269 if( right_row <= 0 )
270 m_rightGridLayers->Show( false );
271
272 // Now fix min grid column size (it also sets a minimal size)
273 m_leftGridLayers->AutoSizeColumns();
274 m_rightGridLayers->AutoSizeColumns();
275}
276
277
279{
280 m_layerSelected = m_layersIdLeftColumn[event.GetRow()];
281
282 if( IsQuasiModal() )
283 EndQuasiModal( 1 );
284 else
285 EndDialog( 1 );
286}
287
288
290{
291 m_layerSelected = m_layersIdRightColumn[event.GetRow()];
292
293 if( IsQuasiModal() )
294 EndQuasiModal( 2 );
295 else
296 EndDialog( 2 );
297}
298
299
301 const 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{
334
335public:
337 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
338 m_layerPresentation( aPresentation ),
339 m_grid( aGrid ),
340 m_layerPairSettings( aLayerPairSettings )
341 {
342 wxASSERT_MSG( m_grid.GetNumberRows() == 0, "Grid should be empty at controller start" );
343
346
347 m_grid.Bind( wxEVT_GRID_CELL_CHANGED,
348 [this]( wxGridEvent& aEvent )
349 {
350 const int col = aEvent.GetCol();
351 const int row = aEvent.GetRow();
352 if( col == (int) COLNUMS::USERNAME )
353 {
354 onUserNameChanged( row, m_grid.GetCellValue( row, col ) );
355 }
356 else if( col == (int) COLNUMS::ENABLED )
357 {
358 onEnableChanged( row, m_grid.GetCellValue( row, col ) == wxS( "1" ) );
359 }
360 } );
361
362 m_grid.Bind( wxEVT_GRID_CELL_LEFT_DCLICK,
363 [&]( wxGridEvent& aEvent )
364 {
365 const int row = aEvent.GetRow();
366 const int col = aEvent.GetCol();
367
368 if( col == (int) COLNUMS::LAYERNAMES || col == (int) COLNUMS::SWATCH )
369 {
370 onPairActivated( row );
371 }
372 } );
373 }
374
375 void OnLayerPairAdded( const LAYER_PAIR& aLayerPair )
376 {
377 LAYER_PAIR_INFO layerPairInfo{ aLayerPair, true, std::nullopt };
378
379 const bool added = m_layerPairSettings.AddLayerPair( layerPairInfo );
380
381 if( added )
382 {
383 m_grid.AppendRows( 1 );
384 fillRowFromLayerPair( m_grid.GetNumberRows() - 1, layerPairInfo );
385 }
386 }
387
389 {
390 m_grid.OnDeleteRows(
391 [&]( int row )
392 {
393 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[row];
394
395 if( m_layerPairSettings.RemoveLayerPair( layerPairInfo.GetLayerPair() ) )
396 m_grid.DeleteRows( row );
397 } );
398 }
399
400private:
402 {
403 m_grid.UseNativeColHeader( true );
404
405 m_grid.SetCellHighlightPenWidth( 0 );
406 m_grid.SetColFormatBool( (int) COLNUMS::ENABLED );
407 m_grid.SetupColumnAutosizer( (int) COLNUMS::USERNAME );
408
409 m_grid.SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
410 }
411
413 {
414 std::span<const LAYER_PAIR_INFO> storePairs = m_layerPairSettings.GetLayerPairs();
415
416 m_grid.AppendRows( storePairs.size() );
417
418 int row = 0;
419 for( const LAYER_PAIR_INFO& layerPairInfo : storePairs )
420 {
421 fillRowFromLayerPair( row, layerPairInfo );
422 row++;
423 }
424 }
425
426 void fillRowFromLayerPair( int aRow, const LAYER_PAIR_INFO& aLayerPairInfo )
427 {
428 wxASSERT_MSG( aRow < m_grid.GetNumberRows(), "Row index out of bounds" );
429
430 const LAYER_PAIR& layerPair = aLayerPairInfo.GetLayerPair();
431
432 const wxString layerNames = m_layerPresentation.getLayerPairName( layerPair );
433
434 m_grid.SetCellValue( aRow, (int) COLNUMS::LAYERNAMES, layerNames );
435
436 const std::optional<wxString> userName = aLayerPairInfo.GetName();
437 if( userName )
438 {
439 m_grid.SetCellValue( aRow, (int) COLNUMS::USERNAME, *userName );
440 }
441
442 m_grid.SetCellValue( aRow, (int) COLNUMS::ENABLED,
443 aLayerPairInfo.IsEnabled() ? wxT( "1" ) : wxT( "0" ) );
444
445 // Set the color swatch
446 std::unique_ptr<wxBitmap>& swatch =
447 m_swatches.emplace_back( m_layerPresentation.CreateLayerPairIcon(
448 layerPair.GetLayerA(), layerPair.GetLayerB(), KiIconScale( &m_grid ) ) );
449
450 m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH,
451 new GRID_CELL_ICON_RENDERER( *swatch ) );
452
453 m_grid.SetReadOnly( aRow, (int) COLNUMS::SWATCH );
454 m_grid.SetReadOnly( aRow, (int) COLNUMS::LAYERNAMES );
455 }
456
457 void onUserNameChanged( int aRow, const wxString& aNewValue )
458 {
459 LAYER_PAIR_INFO& changedPair = m_layerPairSettings.GetLayerPairs()[aRow];
460 changedPair.SetName( aNewValue );
461 }
462
463 void onEnableChanged( int aRow, bool aNewValue )
464 {
465 LAYER_PAIR_INFO& changedPair = m_layerPairSettings.GetLayerPairs()[aRow];
466 changedPair.SetEnabled( aNewValue );
467 }
468
469 void onPairActivated( int aRow )
470 {
471 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[aRow];
472 const LAYER_PAIR& layerPair = layerPairInfo.GetLayerPair();
473
474 m_layerPairSettings.SetCurrentLayerPair( layerPair );
475 }
476
480
481 // Lifetime managment of the swatches
482 std::vector<std::unique_ptr<wxBitmap>> m_swatches;
483};
484
485
491{
493 {
495 COLOR = 1,
497 };
498
499public:
500 COPPER_LAYERS_PAIR_SELECTION_UI( wxGrid& aLeftGrid, wxGrid& aRightGrid,
501 PCB_LAYER_PRESENTATION& aPresentation,
502 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
503 m_layerPresentation( aPresentation ), m_layerPairSettings( aLayerPairSettings ),
504 m_leftGrid( aLeftGrid ), m_rightGrid( aRightGrid )
505 {
508
509 for( const PCB_LAYER_ID& layerId : m_layerPresentation.getOrderedEnabledLayers() )
510 {
511 if( IsCopperLayer( layerId ) )
512 m_layersId.push_back( layerId );
513 }
514
517
518 m_leftGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
519 [this]( wxGridEvent& aEvent )
520 {
521 onLeftGridRowSelected( aEvent.GetRow() );
522 } );
523
524 m_rightGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
525 [this]( wxGridEvent& aEvent )
526 {
527 onRightGridRowSelected( aEvent.GetRow() );
528 } );
529
530 m_layerPairSettings.Bind( PCB_CURRENT_LAYER_PAIR_CHANGED,
531 [this]( wxCommandEvent& aEvent )
532 {
533 const LAYER_PAIR& newPair = m_layerPairSettings.GetCurrentLayerPair();
535 rowForLayer( newPair.GetLayerB() ) );
536 } );
537 }
538
539private:
540 void configureGrid( wxGrid& aGrid )
541 {
542 aGrid.SetCellHighlightPenWidth( 0 );
543 aGrid.SetColFormatBool( (int) CU_LAYER_COLNUMS::SELECT );
544 }
545
546 void fillLayerGrid( wxGrid& aGrid )
547 {
548 const wxColour bg = m_layerPresentation.getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
549
550 aGrid.AppendRows( m_layersId.size() - 1 );
551
552 int row = 0;
553 for( const PCB_LAYER_ID& layerId : m_layersId )
554 {
555 const wxColour fg = m_layerPresentation.getLayerColor( layerId ).ToColour();
556 const wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
557 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
558 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
559
560 const wxString layerName = wxT( " " ) + m_layerPresentation.getLayerName( layerId );
561
562 aGrid.SetCellBackgroundColour( row, (int) CU_LAYER_COLNUMS::COLOR, color );
563 aGrid.SetCellValue( row, (int) CU_LAYER_COLNUMS::LAYERNAME, layerName );
564
565 row++;
566 };
567
568 // Now fix min grid layer name column size (it also sets a minimal size)
569 aGrid.AutoSizeColumn( (int) CU_LAYER_COLNUMS::LAYERNAME );
570 }
571
572 PCB_LAYER_ID layerForRow( int aRow ) { return m_layersId.at( aRow ); }
573
574 int rowForLayer( PCB_LAYER_ID aLayerId )
575 {
576 for( unsigned i = 0; i < m_layersId.size(); ++i )
577 {
578 if( m_layersId[i] == aLayerId )
579 return i;
580 }
581
582 wxASSERT_MSG( false, wxString::Format( "Unknown layer in grid: %d", aLayerId ) );
583 return 0;
584 }
585
586 void onLeftGridRowSelected( int aRow )
587 {
588 LAYER_PAIR newPair{
589 layerForRow( aRow ),
591 };
593 m_layerPairSettings.SetCurrentLayerPair( newPair );
594 }
595
596 void onRightGridRowSelected( int aRow )
597 {
598 LAYER_PAIR newPair{
600 layerForRow( aRow ),
601 };
603 m_layerPairSettings.SetCurrentLayerPair( newPair );
604 }
605
612 void setCurrentSelection( int aLeftRow, int aRightRow )
613 {
614 const auto selectGridRow = []( wxGrid& aGrid, int aRow, bool aSelect )
615 {
616 // At start, there is no old row
617 if( aRow < 0 )
618 return;
619
620 const wxString val = aSelect ? wxT( "1" ) : wxEmptyString;
621 aGrid.SetCellValue( aRow, (int) CU_LAYER_COLNUMS::SELECT, val );
622 aGrid.SetGridCursor( aRow, (int) CU_LAYER_COLNUMS::COLOR );
623 };
624
625 if( m_leftCurrRow != aLeftRow )
626 {
627 selectGridRow( m_leftGrid, m_leftCurrRow, false );
628 selectGridRow( m_leftGrid, aLeftRow, true );
629 m_leftCurrRow = aLeftRow;
630 }
631
632 if( m_rightCurrRow != aRightRow )
633 {
634 selectGridRow( m_rightGrid, m_rightCurrRow, false );
635 selectGridRow( m_rightGrid, aRightRow, true );
636 m_rightCurrRow = aRightRow;
637 }
638 }
639
642 std::vector<PCB_LAYER_ID> m_layersId;
643 wxGrid& m_leftGrid;
644 wxGrid& m_rightGrid;
645
648};
649
650
658{
659public:
661 LAYER_PAIR_SETTINGS& aBoardSettings ) :
663 m_boardPairSettings( aBoardSettings ), m_dialogPairSettings( aBoardSettings ),
664 m_layerPresentation( &aParent ),
668 {
671
672 m_addToPresetsButton->Bind( wxEVT_BUTTON,
673 [this]( wxCommandEvent& aEvent )
674 {
675 const LAYER_PAIR newPair = m_dialogPairSettings.GetCurrentLayerPair();
676 m_presetsGridController.OnLayerPairAdded( newPair );
677 } );
678
679 m_deleteRowButton->Bind( wxEVT_BUTTON,
680 [this]( wxCommandEvent& aEvent )
681 {
682 m_presetsGridController.OnDeleteSelectedLayerPairs();
683 } );
684
685 SetFocus();
686
687 GetSizer()->SetSizeHints( this );
688 Center();
689 }
690
691 bool TransferDataToWindow() override
692 {
693 m_presetsGrid->Freeze();
694 m_leftGridLayers->Freeze();
695 m_rightGridLayers->Freeze();
696
697 m_dialogPairSettings.SetCurrentLayerPair( m_boardPairSettings.GetCurrentLayerPair() );
698
699 m_rightGridLayers->Thaw();
700 m_leftGridLayers->Thaw();
701 m_presetsGrid->Thaw();
702 return true;
703 }
704
706 {
707 // Pull out the dialog's stored pairs
708 std::span<const LAYER_PAIR_INFO> storePairs = m_dialogPairSettings.GetLayerPairs();
709
710 m_boardPairSettings.SetLayerPairs( storePairs );
711 m_boardPairSettings.SetCurrentLayerPair( m_dialogPairSettings.GetCurrentLayerPair() );
712
713 return true;
714 }
715
716private:
717 // The BOARD's pair store to be updated
719 // A local copy while we modify it
721 // Information about the layer presentation (colors, etc)
723 // UI controllers
726};
727
728
730{
731 LAYER_PAIR_SETTINGS* const boardSettings = frame()->GetLayerPairSettings();
732
733 if( !boardSettings )
734 {
735 // Should only be used for suitable frame types with layer pairs
736 wxASSERT_MSG( false, "Could not access layer pair settings" );
737 return 0;
738 }
739
740 SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( *frame(), *boardSettings );
741
742 if( dlg.ShowModal() == wxID_OK )
743 {
744 const LAYER_PAIR layerPair = boardSettings->GetCurrentLayerPair();
745
746 // select the same layer for both layers is allowed (normal in some boards)
747 // but could be a mistake. So display an info message
748 if( layerPair.GetLayerA() == layerPair.GetLayerB() )
749 {
750 DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
751 }
752 }
753
754 return 0;
755}
int color
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.
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
Definition board.h:858
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...
void onUserNameChanged(int aRow, const wxString &aNewValue)
std::vector< std::unique_ptr< wxBitmap > > m_swatches
COPPER_LAYERS_PAIR_PRESETS_UI(WX_GRID &aGrid, PCB_LAYER_PRESENTATION &aPresentation, LAYER_PAIR_SETTINGS &aLayerPairSettings)
LAYER_PAIR_SETTINGS & m_layerPairSettings
void OnLayerPairAdded(const LAYER_PAIR &aLayerPair)
void fillRowFromLayerPair(int aRow, const LAYER_PAIR_INFO &aLayerPairInfo)
void onEnableChanged(int aRow, bool aNewValue)
PCB_LAYER_PRESENTATION & m_layerPresentation
Class that manages the UI for the copper layer pair selection (left and right grids).
void setCurrentSelection(int aLeftRow, int aRightRow)
Set the current layer selection.
void onRightGridRowSelected(int aRow)
COPPER_LAYERS_PAIR_SELECTION_UI(wxGrid &aLeftGrid, wxGrid &aRightGrid, PCB_LAYER_PRESENTATION &aPresentation, LAYER_PAIR_SETTINGS &aLayerPairSettings)
PCB_LAYER_PRESENTATION & m_layerPresentation
void configureGrid(wxGrid &aGrid)
void fillLayerGrid(wxGrid &aGrid)
int rowForLayer(PCB_LAYER_ID aLayerId)
LAYER_PAIR_SETTINGS & m_layerPairSettings
PCB_LAYER_ID layerForRow(int aRow)
std::vector< PCB_LAYER_ID > m_layersId
DIALOG_COPPER_LAYER_PAIR_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Select Copper Layer Pair"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
DIALOG_LAYER_SELECTION_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Select Layer"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
bool IsQuasiModal() const
Definition dialog_shim.h:93
bool m_useCalculatedSize
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
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
const LAYER_PAIR & GetCurrentLayerPair() const
Definition layer_pairs.h:87
PCB_LAYER_ID GetLayerA() const
PCB_LAYER_ID GetLayerB() const
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
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, const LSET &aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Class that manages the presentation of PCB layers in a PCB frame.
wxString getLayerName(int aLayer) const override
Definition sel_layer.cpp:76
PCB_LAYER_PRESENTATION(PCB_BASE_FRAME *aFrame)
Definition sel_layer.cpp:57
LSEQ getOrderedEnabledLayers() const
Definition sel_layer.cpp:84
COLOR4D getLayerColor(int aLayer) const override
Definition sel_layer.cpp:61
wxString getLayerPairName(const LAYER_PAIR &aPair) const
Definition sel_layer.cpp:89
Display a PCB layers list in a dialog to select one layer from this list.
void OnLeftGridCellClick(wxGridEvent &aEvent) override
PCB_LAYER_PRESENTATION m_layerPresentation
void OnRightGridCellClick(wxGridEvent &aEvent) override
void onCharHook(wxKeyEvent &event)
std::vector< PCB_LAYER_ID > m_layersIdLeftColumn
std::vector< PCB_LAYER_ID > m_layersIdRightColumn
void OnMouseMove(wxUpdateUIEvent &aEvent) override
PCB_LAYER_ID m_layerSelected
PCB_ONE_LAYER_SELECTOR(PCB_BASE_FRAME *aParent, PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask, bool aHideCheckBoxes=false)
wxString getLayerHotKey(PCB_LAYER_ID aLayer) const
T * frame() const
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
PCB_LAYER_PRESENTATION m_layerPresentation
LAYER_PAIR_SETTINGS & m_boardPairSettings
SELECT_COPPER_LAYERS_PAIR_DIALOG(PCB_BASE_FRAME &aParent, LAYER_PAIR_SETTINGS &aBoardSettings)
COPPER_LAYERS_PAIR_PRESETS_UI m_presetsGridController
COPPER_LAYERS_PAIR_SELECTION_UI m_pairSelectionController
bool TransferDataFromWindow() override
LAYER_PAIR_SETTINGS m_dialogPairSettings
int GetHotKey() const
Return the hotkey keycode which initiates the action.
Generic, UI-independent tool event.
Definition tool_event.h:171
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
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:676
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:281
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:737
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition wxgtk/ui.cpp:689
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
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)