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
22 * along with this program. If not, see <https://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>
47#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
61
63{
64 if( m_boardFrame )
65 {
66 return m_boardFrame->GetColorSettings()->GetColor( aLayer );
67 }
68 else
69 {
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{
87 return m_boardFrame->GetBoard()->GetEnabledLayers().UIOrder();
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 // Return the selectable layer whose layer-switch hotkey matches aKeyCode, or UNDEFINED_LAYER.
127 // Only copper layers (the left column) carry a switch action and a displayed hotkey.
128 PCB_LAYER_ID layerForHotKey( long aKeyCode ) const
129 {
130 if( aKeyCode == 0 )
131 return UNDEFINED_LAYER;
132
134 {
135 if( TOOL_ACTION* action = PCB_ACTIONS::LayerIDToAction( layer );
136 action && action->GetHotKey() == aKeyCode )
137 {
138 return layer;
139 }
140 }
141
142 return UNDEFINED_LAYER;
143 }
144
145 void buildList();
146
150 std::vector<PCB_LAYER_ID> m_layersIdLeftColumn;
151 std::vector<PCB_LAYER_ID> m_layersIdRightColumn;
152};
153
154
156 LSET aNotAllowedLayersMask, bool aHideCheckBoxes ) :
158{
159 m_useCalculatedSize = true;
160
161 m_layerSelected = aDefaultLayer;
162 m_notAllowedLayersMask = aNotAllowedLayersMask;
163
164 m_leftGridLayers->SetCellHighlightPenWidth( 0 );
165 m_rightGridLayers->SetCellHighlightPenWidth( 0 );
166 m_leftGridLayers->SetColFormatBool( SELECT_COLNUM );
167 m_rightGridLayers->SetColFormatBool( SELECT_COLNUM );
168
169 m_leftGridLayers->AppendCols( 1 );
170
171 buildList();
172
173 if( aHideCheckBoxes )
174 {
177 }
178
179 Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
180
181 Layout();
182 GetSizer()->SetSizeHints( this );
183 SetFocus();
184}
185
186
188{
189 Disconnect( wxEVT_CHAR_HOOK, wxKeyEventHandler( PCB_ONE_LAYER_SELECTOR::onCharHook ) );
190}
191
192
193void PCB_ONE_LAYER_SELECTOR::OnMouseMove( wxUpdateUIEvent& aEvent )
194{
198
199 wxPoint mouse_pos = KIPLATFORM::UI::GetMousePosition();
200 wxPoint left_pos = m_leftGridLayers->ScreenToClient( mouse_pos );
201 wxPoint right_pos = m_rightGridLayers->ScreenToClient( mouse_pos );
202
203 if( m_leftGridLayers->HitTest( left_pos ) == wxHT_WINDOW_INSIDE )
204 {
205 int row = m_leftGridLayers->YToRow( left_pos.y );
206
207 if( row != wxNOT_FOUND && row < static_cast<int>( m_layersIdLeftColumn.size() ) )
208 {
210 m_leftGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYER_HK_COLUMN );
211 return;
212 }
213 }
214
215 if( m_rightGridLayers->HitTest( right_pos ) == wxHT_WINDOW_INSIDE )
216 {
217 int row = m_rightGridLayers->YToRow( right_pos.y );
218
219 if( row == wxNOT_FOUND || row >= static_cast<int>( m_layersIdRightColumn.size() ) )
220 return;
221
223 m_rightGridLayers->SelectBlock( row, LAYERNAME_COLNUM, row, LAYERNAME_COLNUM );
224 }
225}
226
227
228void PCB_ONE_LAYER_SELECTOR::onCharHook( wxKeyEvent& event )
229{
230 if( event.GetKeyCode() == WXK_ESCAPE )
231 {
232 Close();
233 return;
234 }
235
236 // The hotkeys shown in the layer list are the global layer-switch shortcuts; pressing one
237 // here selects that layer and closes the dialog, matching the displayed annotations.
239
240 if( layer != UNDEFINED_LAYER )
241 {
242 m_layerSelected = layer;
243 EndDialogShim( 1 );
244 return;
245 }
246
247 event.Skip();
248}
249
250
252{
253 wxColour bg = m_layerPresentation.getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
254 int left_row = 0;
255 int right_row = 0;
256 wxString layername;
257
258 for( PCB_LAYER_ID layerid : m_layerPresentation.getOrderedEnabledLayers() )
259 {
260 if( m_notAllowedLayersMask[layerid] )
261 continue;
262
263 wxColour fg = m_layerPresentation.getLayerColor( layerid ).ToColour();
264 wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
265 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
266 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
267
268 layername = wxT( " " ) + m_layerPresentation.getLayerName( layerid );
269
270 if( IsCopperLayer( layerid ) )
271 {
272 if( left_row )
273 m_leftGridLayers->AppendRows( 1 );
274
275 m_leftGridLayers->SetCellBackgroundColour( left_row, COLOR_COLNUM, color );
276 m_leftGridLayers->SetCellValue( left_row, LAYERNAME_COLNUM, layername );
277 m_leftGridLayers->SetCellValue( left_row, LAYER_HK_COLUMN, getLayerHotKey( layerid ) );
278
279 if( m_layerSelected == layerid )
280 m_leftGridLayers->SetCellValue( left_row, SELECT_COLNUM, wxT( "1" ) );
281
282 m_layersIdLeftColumn.push_back( layerid );
283 left_row++;
284 }
285 else
286 {
287 if( right_row )
288 m_rightGridLayers->AppendRows( 1 );
289
290 m_rightGridLayers->SetCellBackgroundColour( right_row, COLOR_COLNUM, color );
291 m_rightGridLayers->SetCellValue( right_row, LAYERNAME_COLNUM, layername );
292
293 if( m_layerSelected == layerid )
294 m_rightGridLayers->SetCellValue( right_row, SELECT_COLNUM, wxT( "1" ) );
295
296 m_layersIdRightColumn.push_back( layerid );
297 right_row++;
298 }
299 }
300
301 // Show only populated lists:
302 if( left_row <= 0 )
303 m_leftGridLayers->Show( false );
304
305 if( right_row <= 0 )
306 m_rightGridLayers->Show( false );
307
308 // Now fix min grid column size (it also sets a minimal size)
309 m_leftGridLayers->AutoSizeColumns();
310 m_rightGridLayers->AutoSizeColumns();
311}
312
313
315{
316 m_layerSelected = m_layersIdLeftColumn[event.GetRow()];
317
318 EndDialogShim( 1 );
319}
320
321
323{
324 m_layerSelected = m_layersIdRightColumn[event.GetRow()];
325
326 EndDialogShim( 2 );
327}
328
329
331 const LSET& aNotAllowedLayersMask,
332 wxPoint aDlgPosition )
333{
334 PCB_ONE_LAYER_SELECTOR dlg( this, aDefaultLayer, aNotAllowedLayersMask, true );
335
336 if( aDlgPosition != wxDefaultPosition )
337 {
338 wxSize dlgSize = dlg.GetSize();
339 aDlgPosition.x -= dlgSize.x / 2;
340 aDlgPosition.y -= dlgSize.y / 2;
341 dlg.SetPosition( aDlgPosition );
342 }
343
344 if( dlg.ShowModal() != wxID_CANCEL )
345 return ToLAYER_ID( dlg.GetLayerSelection() );
346 else
347 return UNDEFINED_LAYER;
348}
349
350
356{
364
365public:
367 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
368 m_layerPresentation( aPresentation ),
369 m_grid( aGrid ),
370 m_layerPairSettings( aLayerPairSettings )
371 {
372 wxASSERT_MSG( m_grid.GetNumberRows() == 0, "Grid should be empty at controller start" );
373
376
377 m_grid.Bind( wxEVT_GRID_CELL_CHANGED,
378 [this]( wxGridEvent& aEvent )
379 {
380 const int col = aEvent.GetCol();
381 const int row = aEvent.GetRow();
382 if( col == (int) COLNUMS::USERNAME )
383 {
384 onUserNameChanged( row, m_grid.GetCellValue( row, col ) );
385 }
386 else if( col == (int) COLNUMS::ENABLED )
387 {
388 onEnableChanged( row, m_grid.GetCellValue( row, col ) == wxS( "1" ) );
389 }
390 } );
391
392 m_grid.Bind( wxEVT_GRID_CELL_LEFT_DCLICK,
393 [&]( wxGridEvent& aEvent )
394 {
395 const int row = aEvent.GetRow();
396 const int col = aEvent.GetCol();
397
398 if( col == (int) COLNUMS::LAYERNAMES || col == (int) COLNUMS::SWATCH )
399 {
400 onPairActivated( row );
401 }
402 } );
403 }
404
405 void OnLayerPairAdded( const LAYER_PAIR& aLayerPair )
406 {
407 LAYER_PAIR_INFO layerPairInfo{ aLayerPair, true, std::nullopt };
408
409 const bool added = m_layerPairSettings.AddLayerPair( layerPairInfo );
410
411 if( added )
412 {
413 m_grid.AppendRows( 1 );
414 fillRowFromLayerPair( m_grid.GetNumberRows() - 1, layerPairInfo );
415 }
416 }
417
419 {
420 m_grid.OnDeleteRows(
421 [&]( int row )
422 {
423 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[row];
424
425 if( m_layerPairSettings.RemoveLayerPair( layerPairInfo.GetLayerPair() ) )
426 m_grid.DeleteRows( row );
427 } );
428 }
429
430private:
432 {
433 m_grid.UseNativeColHeader( true );
434
435 m_grid.SetCellHighlightPenWidth( 0 );
436 m_grid.SetColFormatBool( (int) COLNUMS::ENABLED );
437 m_grid.SetupColumnAutosizer( (int) COLNUMS::USERNAME );
438
439 m_grid.SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
440 }
441
443 {
444 std::span<const LAYER_PAIR_INFO> storePairs = m_layerPairSettings.GetLayerPairs();
445
446 m_grid.AppendRows( storePairs.size() );
447
448 int row = 0;
449 for( const LAYER_PAIR_INFO& layerPairInfo : storePairs )
450 {
451 fillRowFromLayerPair( row, layerPairInfo );
452 row++;
453 }
454 }
455
456 void fillRowFromLayerPair( int aRow, const LAYER_PAIR_INFO& aLayerPairInfo )
457 {
458 wxASSERT_MSG( aRow < m_grid.GetNumberRows(), "Row index out of bounds" );
459
460 const LAYER_PAIR& layerPair = aLayerPairInfo.GetLayerPair();
461
462 const wxString layerNames = m_layerPresentation.getLayerPairName( layerPair );
463
464 m_grid.SetCellValue( aRow, (int) COLNUMS::LAYERNAMES, layerNames );
465
466 const std::optional<wxString> userName = aLayerPairInfo.GetName();
467 if( userName )
468 {
469 m_grid.SetCellValue( aRow, (int) COLNUMS::USERNAME, *userName );
470 }
471
472 m_grid.SetCellValue( aRow, (int) COLNUMS::ENABLED,
473 aLayerPairInfo.IsEnabled() ? wxT( "1" ) : wxT( "0" ) );
474
475 // Set the color swatch
476 wxBitmapBundle swatch = m_layerPresentation.CreateLayerPairIcon( layerPair.GetLayerA(), layerPair.GetLayerB() );
477
478 m_grid.SetCellRenderer( aRow, (int) COLNUMS::SWATCH, new GRID_CELL_ICON_RENDERER( swatch ) );
479
480 m_grid.SetReadOnly( aRow, (int) COLNUMS::SWATCH );
481 m_grid.SetReadOnly( aRow, (int) COLNUMS::LAYERNAMES );
482 }
483
484 void onUserNameChanged( int aRow, const wxString& aNewValue )
485 {
486 LAYER_PAIR_INFO& changedPair = m_layerPairSettings.GetLayerPairs()[aRow];
487 changedPair.SetName( aNewValue );
488 }
489
490 void onEnableChanged( int aRow, bool aNewValue )
491 {
492 LAYER_PAIR_INFO& changedPair = m_layerPairSettings.GetLayerPairs()[aRow];
493 changedPair.SetEnabled( aNewValue );
494 }
495
496 void onPairActivated( int aRow )
497 {
498 const LAYER_PAIR_INFO& layerPairInfo = m_layerPairSettings.GetLayerPairs()[aRow];
499 const LAYER_PAIR& layerPair = layerPairInfo.GetLayerPair();
500
501 m_layerPairSettings.SetCurrentLayerPair( layerPair );
502 }
503
507};
508
509
515{
517 {
519 COLOR = 1,
521 };
522
523public:
524 COPPER_LAYERS_PAIR_SELECTION_UI( wxGrid& aLeftGrid, wxGrid& aRightGrid,
525 PCB_LAYER_PRESENTATION& aPresentation,
526 LAYER_PAIR_SETTINGS& aLayerPairSettings ) :
527 m_layerPresentation( aPresentation ), m_layerPairSettings( aLayerPairSettings ),
528 m_leftGrid( aLeftGrid ), m_rightGrid( aRightGrid )
529 {
532
533 for( const PCB_LAYER_ID& layerId : m_layerPresentation.getOrderedEnabledLayers() )
534 {
535 if( IsCopperLayer( layerId ) )
536 m_layersId.push_back( layerId );
537 }
538
541
542 m_leftGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
543 [this]( wxGridEvent& aEvent )
544 {
545 onLeftGridRowSelected( aEvent.GetRow() );
546 } );
547
548 m_rightGrid.Bind( wxEVT_GRID_CELL_LEFT_CLICK,
549 [this]( wxGridEvent& aEvent )
550 {
551 onRightGridRowSelected( aEvent.GetRow() );
552 } );
553
554 m_layerPairSettings.Bind( PCB_CURRENT_LAYER_PAIR_CHANGED,
555 [this]( wxCommandEvent& aEvent )
556 {
557 const LAYER_PAIR& newPair = m_layerPairSettings.GetCurrentLayerPair();
559 rowForLayer( newPair.GetLayerB() ) );
560 } );
561 }
562
563private:
564 void configureGrid( wxGrid& aGrid )
565 {
566 aGrid.SetCellHighlightPenWidth( 0 );
567 aGrid.SetColFormatBool( (int) CU_LAYER_COLNUMS::SELECT );
568 }
569
570 void fillLayerGrid( wxGrid& aGrid )
571 {
572 const wxColour bg = m_layerPresentation.getLayerColor( LAYER_PCB_BACKGROUND ).ToColour();
573
574 aGrid.AppendRows( m_layersId.size() - 1 );
575
576 int row = 0;
577 for( const PCB_LAYER_ID& layerId : m_layersId )
578 {
579 const wxColour fg = m_layerPresentation.getLayerColor( layerId ).ToColour();
580 const wxColour color( wxColour::AlphaBlend( fg.Red(), bg.Red(), fg.Alpha() / 255.0 ),
581 wxColour::AlphaBlend( fg.Green(), bg.Green(), fg.Alpha() / 255.0 ),
582 wxColour::AlphaBlend( fg.Blue(), bg.Blue(), fg.Alpha() / 255.0 ) );
583
584 const wxString layerName = wxT( " " ) + m_layerPresentation.getLayerName( layerId );
585
586 aGrid.SetCellBackgroundColour( row, (int) CU_LAYER_COLNUMS::COLOR, color );
587 aGrid.SetCellValue( row, (int) CU_LAYER_COLNUMS::LAYERNAME, layerName );
588
589 row++;
590 };
591
592 // Now fix min grid layer name column size (it also sets a minimal size)
593 aGrid.AutoSizeColumn( (int) CU_LAYER_COLNUMS::LAYERNAME );
594 }
595
596 PCB_LAYER_ID layerForRow( int aRow ) { return m_layersId.at( aRow ); }
597
598 int rowForLayer( PCB_LAYER_ID aLayerId )
599 {
600 for( unsigned i = 0; i < m_layersId.size(); ++i )
601 {
602 if( m_layersId[i] == aLayerId )
603 return i;
604 }
605
606 wxASSERT_MSG( false, wxString::Format( "Unknown layer in grid: %d", aLayerId ) );
607 return 0;
608 }
609
610 void onLeftGridRowSelected( int aRow )
611 {
612 LAYER_PAIR newPair{
613 layerForRow( aRow ),
615 };
617 m_layerPairSettings.SetCurrentLayerPair( newPair );
618 }
619
620 void onRightGridRowSelected( int aRow )
621 {
622 LAYER_PAIR newPair{
624 layerForRow( aRow ),
625 };
627 m_layerPairSettings.SetCurrentLayerPair( newPair );
628 }
629
636 void setCurrentSelection( int aLeftRow, int aRightRow )
637 {
638 const auto selectGridRow =
639 []( wxGrid& aGrid, int aRow, bool aSelect )
640 {
641 // At start, there is no old row
642 if( aRow < 0 )
643 return;
644
645 const wxString val = aSelect ? wxT( "1" ) : wxEmptyString;
646 aGrid.SetCellValue( aRow, (int) CU_LAYER_COLNUMS::SELECT, val );
647 aGrid.SetGridCursor( aRow, (int) CU_LAYER_COLNUMS::COLOR );
648 };
649
650 if( m_leftCurrRow != aLeftRow )
651 {
652 selectGridRow( m_leftGrid, m_leftCurrRow, false );
653 selectGridRow( m_leftGrid, aLeftRow, true );
654 m_leftCurrRow = aLeftRow;
655 }
656
657 if( m_rightCurrRow != aRightRow )
658 {
659 selectGridRow( m_rightGrid, m_rightCurrRow, false );
660 selectGridRow( m_rightGrid, aRightRow, true );
661 m_rightCurrRow = aRightRow;
662 }
663 }
664
667 std::vector<PCB_LAYER_ID> m_layersId;
668 wxGrid& m_leftGrid;
669 wxGrid& m_rightGrid;
670
673};
674
675
683{
684public:
686 LAYER_PAIR_SETTINGS& aBoardSettings ) :
688 m_boardPairSettings( aBoardSettings ), m_dialogPairSettings( aBoardSettings ),
689 m_layerPresentation( &aParent ),
693 {
696
697 m_addToPresetsButton->Bind( wxEVT_BUTTON,
698 [this]( wxCommandEvent& aEvent )
699 {
700 const LAYER_PAIR newPair = m_dialogPairSettings.GetCurrentLayerPair();
701 m_presetsGridController.OnLayerPairAdded( newPair );
702 } );
703
704 m_deleteRowButton->Bind( wxEVT_BUTTON,
705 [this]( wxCommandEvent& aEvent )
706 {
707 m_presetsGridController.OnDeleteSelectedLayerPairs();
708 } );
709
710 SetFocus();
711
712 GetSizer()->SetSizeHints( this );
713 Center();
714 }
715
716 bool TransferDataToWindow() override
717 {
718 m_presetsGrid->Freeze();
719 m_leftGridLayers->Freeze();
720 m_rightGridLayers->Freeze();
721
722 m_dialogPairSettings.SetCurrentLayerPair( m_boardPairSettings.GetCurrentLayerPair() );
723
724 m_rightGridLayers->Thaw();
725 m_leftGridLayers->Thaw();
726 m_presetsGrid->Thaw();
727 return true;
728 }
729
731 {
732 // Pull out the dialog's stored pairs
733 std::span<const LAYER_PAIR_INFO> storePairs = m_dialogPairSettings.GetLayerPairs();
734
735 m_boardPairSettings.SetLayerPairs( storePairs );
736 m_boardPairSettings.SetCurrentLayerPair( m_dialogPairSettings.GetCurrentLayerPair() );
737
738 return true;
739 }
740
741private:
742 // The BOARD's pair store to be updated
744 // A local copy while we modify it
746 // Information about the layer presentation (colors, etc)
748 // UI controllers
751};
752
753
755{
756 LAYER_PAIR_SETTINGS* const boardSettings = frame()->GetLayerPairSettings();
757
758 if( !boardSettings )
759 {
760 // Should only be used for suitable frame types with layer pairs
761 wxASSERT_MSG( false, "Could not access layer pair settings" );
762 return 0;
763 }
764
765 SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( *frame(), *boardSettings );
766
767 if( dlg.ShowModal() == wxID_OK )
768 {
769 const LAYER_PAIR layerPair = boardSettings->GetCurrentLayerPair();
770
771 // select the same layer for both layers is allowed (normal in some boards)
772 // but could be a mistake. So display an info message
773 if( layerPair.GetLayerA() == layerPair.GetLayerB() )
774 {
775 DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
776 }
777 }
778
779 return 0;
780}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
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:1003
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)
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 m_useCalculatedSize
void EndDialogShim(int aReturnCode)
A mode agnostic way to close a dialog.
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:101
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:43
const LAYER_PAIR & GetCurrentLayerPair() const
Definition layer_pairs.h:83
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:77
PCB_LAYER_PRESENTATION(PCB_BASE_FRAME *aFrame)
Definition sel_layer.cpp:58
LSEQ getOrderedEnabledLayers() const
Definition sel_layer.cpp:85
COLOR4D getLayerColor(int aLayer) const override
Definition sel_layer.cpp:62
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.
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
PCB_LAYER_ID layerForHotKey(long aKeyCode) const
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
Represent a single user action.
int GetHotKey() const
Return the hotkey keycode which initiates the action.
Generic, UI-independent tool event.
Definition tool_event.h:167
static long MapKeypressToKeycode(const wxKeyEvent &aEvent)
Map a keypress event to the correct key code for use as a hotkey.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
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:683
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition layer_ids.h:277
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:750
wxPoint GetMousePosition()
Returns the mouse position in screen coordinates.
Definition wxgtk/ui.cpp:839
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
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)