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