KiCad PCB EDA Suite
GAL_OPTIONS_PANEL Class Reference

#include <gal_options_panel.h>

Inheritance diagram for GAL_OPTIONS_PANEL:

Public Member Functions

 GAL_OPTIONS_PANEL (wxWindow *aParent, KIGFX::GAL_DISPLAY_OPTIONS &aGalOpts)
 
bool TransferDataToWindow () override
 Load the panel controls from the given opt. More...
 
bool TransferDataFromWindow () override
 Read the options set in the UI into the given options object. More...
 

Private Attributes

wxBoxSizer * m_mainSizer
 
wxRadioBox * m_gridStyle
 
wxStaticText * l_gridLineWidth
 
wxTextCtrl * m_gridLineWidth
 
wxSpinButton * m_gridLineWidthSpinBtn
 
wxStaticText * l_gridLineWidthUnits
 
wxStaticText * l_gridMinSpacing
 
wxTextCtrl * m_gridMinSpacing
 
wxSpinButton * m_gridMinSpacingSpinBtn
 
wxStaticText * l_gridMinSpacingUnits
 
wxRadioBox * m_cursorShape
 
wxCheckBox * m_forceCursorDisplay
 
KIGFX::GAL_DISPLAY_OPTIONSm_galOptions
 

The GAL options to read/write

More...
 
std::unique_ptr< INCREMENTAL_TEXT_CTRLm_gridSizeIncrementer
 
std::unique_ptr< INCREMENTAL_TEXT_CTRLm_gridMinSpacingIncrementer
 

Detailed Description

Definition at line 34 of file gal_options_panel.h.

Constructor & Destructor Documentation

◆ GAL_OPTIONS_PANEL()

GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL ( wxWindow *  aParent,
KIGFX::GAL_DISPLAY_OPTIONS aGalOpts 
)

Definition at line 52 of file gal_options_panel.cpp.

52  :
53  wxPanel( aParent, wxID_ANY ),
54  m_galOptions( aGalOpts )
55 {
56  // the main sizer that holds "columns" of settings
57  m_mainSizer = new wxBoxSizer( wxHORIZONTAL );
58  SetSizer( m_mainSizer );
59 
60  // second-level sizers that are one "column" of settings each
61  wxBoxSizer* sLeftSizer = new wxBoxSizer( wxVERTICAL );
62  m_mainSizer->Add( sLeftSizer, 1, wxALL | wxEXPAND, 0 );
63 
64  // @todo LEGACY: not required when legacy is gone
65  const wxString galOnlySuffix = _( " (not supported in Legacy Toolset)" );
66 
67  /*
68  * Grid settings subpanel
69  */
70  {
71  wxStaticBoxSizer* sGridSettings;
72  sGridSettings = new wxStaticBoxSizer( new wxStaticBox( this,
73  wxID_ANY, _( "Grid Options" ) + galOnlySuffix ), wxVERTICAL );
74 
75  wxString m_gridStyleChoices[] = {
76  _( "Dots" ),
77  _( "Lines" ),
78  _( "Small crosses" )
79  };
80  int m_gridStyleNChoices = sizeof( m_gridStyleChoices ) / sizeof( wxString );
81  m_gridStyle = new wxRadioBox( sGridSettings->GetStaticBox(),
82  wxID_ANY, _( "Grid Style" ),
83  wxDefaultPosition, wxDefaultSize,
84  m_gridStyleNChoices, m_gridStyleChoices, 1, wxRA_SPECIFY_COLS );
85  sGridSettings->Add( m_gridStyle, 0, wxALL|wxEXPAND, 5 );
86 
87  wxFlexGridSizer* sGridSettingsGrid;
88  sGridSettingsGrid = new wxFlexGridSizer( 0, 4, 0, 0 );
89  sGridSettingsGrid->AddGrowableCol( 1 );
90  sGridSettingsGrid->SetFlexibleDirection( wxBOTH );
91  sGridSettingsGrid->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
92 
93  l_gridLineWidth = new wxStaticText( sGridSettings->GetStaticBox(),
94  wxID_ANY, _( "Grid thickness:" ) );
95  l_gridLineWidth->Wrap( -1 );
96  sGridSettingsGrid->Add( l_gridLineWidth, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
97 
98  m_gridLineWidth = new wxTextCtrl( sGridSettings->GetStaticBox(), wxID_ANY );
99  sGridSettingsGrid->Add( m_gridLineWidth, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 );
100 
101  m_gridLineWidthSpinBtn = new wxSpinButton( sGridSettings->GetStaticBox(),
102  wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS );
103  sGridSettingsGrid->Add( m_gridLineWidthSpinBtn, 0,
104  wxEXPAND | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 3 );
105 
106  l_gridLineWidthUnits = new wxStaticText( sGridSettings->GetStaticBox(),
107  wxID_ANY, _( "px" ) );
108  l_gridLineWidthUnits->Wrap( -1 );
109  sGridSettingsGrid->Add( l_gridLineWidthUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
110 
111  l_gridMinSpacing = new wxStaticText( sGridSettings->GetStaticBox(),
112  wxID_ANY, _( "Min grid spacing:" ) );
113  l_gridMinSpacing->Wrap( -1 );
114  sGridSettingsGrid->Add( l_gridMinSpacing, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
115 
116  m_gridMinSpacing = new wxTextCtrl( sGridSettings->GetStaticBox(), wxID_ANY);
117  sGridSettingsGrid->Add( m_gridMinSpacing, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 );
118 
119  m_gridMinSpacingSpinBtn = new wxSpinButton( sGridSettings->GetStaticBox(),
120  wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS );
121  sGridSettingsGrid->Add( m_gridMinSpacingSpinBtn, 0,
122  wxEXPAND | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 3 );
123 
124  l_gridMinSpacingUnits = new wxStaticText( sGridSettings->GetStaticBox(),
125  wxID_ANY, _( "px" ) );
126  l_gridMinSpacingUnits->Wrap( -1 );
127  sGridSettingsGrid->Add( l_gridMinSpacingUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
128 
129  sGridSettings->Add( sGridSettingsGrid, 1, wxALL | wxEXPAND, 5 );
130 
131  sLeftSizer->Add( sGridSettings, 0, wxTOP | wxBOTTOM | wxRIGHT | wxEXPAND, 5 );
132 
133  // bind the spin buttons and text boxes
134  m_gridSizeIncrementer = std::make_unique<SPIN_INCREMENTAL_TEXT_CTRL>(
136 
139  m_gridSizeIncrementer->SetPrecision( 0 );
140 
141  m_gridMinSpacingIncrementer = std::make_unique<SPIN_INCREMENTAL_TEXT_CTRL>(
143 
146  m_gridMinSpacingIncrementer->SetPrecision( 0 ); // restrict to ints
147  }
148 
149  /*
150  * Cursor settings subpanel
151  */
152  {
153  wxString cursorDisplayTitle = _( "Cursor Options" );
154 
155  // cursor is not shown in legacy on OSX
156  // @todo LEGACY remove this
157 #ifdef __APPLE__
158  cursorDisplayTitle += galOnlySuffix;
159 #endif
160 
161  auto sCursorSettings = new wxStaticBoxSizer( new wxStaticBox( this,
162  wxID_ANY, cursorDisplayTitle ), wxVERTICAL );
163 
164  sLeftSizer->Add( sCursorSettings, 1, wxTOP | wxRIGHT | wxEXPAND, 5 );
165 
166  wxString m_CursorShapeChoices[] = {
167  _( "Small crosshair" ),
168  _( "Full window crosshair" )
169  };
170 
171  int m_CursorShapeNChoices = sizeof( m_CursorShapeChoices ) / sizeof( wxString );
172  m_cursorShape = new wxRadioBox( this, wxID_ANY,
173  _( "Cursor Shape:" ), wxDefaultPosition, wxDefaultSize,
174  m_CursorShapeNChoices, m_CursorShapeChoices, 1,
175  wxRA_SPECIFY_COLS );
176 
177  m_cursorShape->SetSelection( 0 );
178  m_cursorShape->SetToolTip( _( "Cursor shape for drawing, placement and movement tools" ) );
179 
180  sCursorSettings->Add( m_cursorShape, 0, wxALL | wxEXPAND, 5 );
181 
182 #ifdef __APPLE__
183  // Whole section is galOnly on OSX; no need for further qualifier here
184  m_forceCursorDisplay = new wxCheckBox( this, wxID_ANY, _( "Always show crosshairs" ) );
185 #else
186  // User a shorter galOnly qualifier as otherwise the label is obnoxiously long
187  // @todo LEGACY remove this
188  m_forceCursorDisplay = new wxCheckBox( this, wxID_ANY,
189  _( "Always show crosshairs (not in Legacy)" ) );
190 #endif
191 
192  sCursorSettings->Add( m_forceCursorDisplay, 0, wxALL | wxEXPAND, 5 );
193  }
194 }
wxStaticText * l_gridMinSpacingUnits
wxTextCtrl * m_gridLineWidth
wxRadioBox * m_cursorShape
wxBoxSizer * m_mainSizer
static const double gridMinSpacingMax
wxTextCtrl * m_gridMinSpacing
std::unique_ptr< INCREMENTAL_TEXT_CTRL > m_gridMinSpacingIncrementer
KIGFX::GAL_DISPLAY_OPTIONS & m_galOptions
The GAL options to read/write
std::unique_ptr< INCREMENTAL_TEXT_CTRL > m_gridSizeIncrementer
wxRadioBox * m_gridStyle
wxStaticText * l_gridMinSpacing
static const double gridThicknessMin
wxCheckBox * m_forceCursorDisplay
wxSpinButton * m_gridLineWidthSpinBtn
wxStaticText * l_gridLineWidthUnits
wxStaticText * l_gridLineWidth
static const double gridThicknessStep
static const double gridThicknessMax
static const double gridMinSpacingStep
static const double gridMinSpacingMin
wxSpinButton * m_gridMinSpacingSpinBtn

References gridMinSpacingMax, gridMinSpacingMin, gridMinSpacingStep, gridThicknessMax, gridThicknessMin, gridThicknessStep, l_gridLineWidth, l_gridLineWidthUnits, l_gridMinSpacing, l_gridMinSpacingUnits, m_cursorShape, m_forceCursorDisplay, m_gridLineWidth, m_gridLineWidthSpinBtn, m_gridMinSpacing, m_gridMinSpacingIncrementer, m_gridMinSpacingSpinBtn, m_gridSizeIncrementer, m_gridStyle, and m_mainSizer.

Member Function Documentation

◆ TransferDataFromWindow()

bool GAL_OPTIONS_PANEL::TransferDataFromWindow ( )
override

Read the options set in the UI into the given options object.

Definition at line 214 of file gal_options_panel.cpp.

215 {
217  gridStyleSelectMap, m_gridStyle->GetSelection() );
218 
219  m_galOptions.m_gridLineWidth = std::floor( m_gridSizeIncrementer->GetValue() + 0.5 );
220 
222 
224 
226 
228 
229  return true;
230 }
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleSelectMap
wxRadioBox * m_cursorShape
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
std::unique_ptr< INCREMENTAL_TEXT_CTRL > m_gridMinSpacingIncrementer
KIGFX::GAL_DISPLAY_OPTIONS & m_galOptions
The GAL options to read/write
bool m_forceDisplayCursor
Force cursor display
std::unique_ptr< INCREMENTAL_TEXT_CTRL > m_gridSizeIncrementer
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
wxRadioBox * m_gridStyle
wxCheckBox * m_forceCursorDisplay
static CFG_NATIVE_VAL< MAP > GetValFromConfig(const MAP &aMap, long aConf)
Get the native value corresponding to the config value (read from file or UI, probably) and find it i...
Definition: config_map.h:96
double m_gridLineWidth
Thickness to render grid lines/dots
bool m_fullscreenCursor
Fullscreen crosshair or small cross

References UTIL::GetValFromConfig(), gridStyleSelectMap, m_cursorShape, m_forceCursorDisplay, KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, KIGFX::GAL_DISPLAY_OPTIONS::m_fullscreenCursor, m_galOptions, KIGFX::GAL_DISPLAY_OPTIONS::m_gridLineWidth, KIGFX::GAL_DISPLAY_OPTIONS::m_gridMinSpacing, m_gridMinSpacingIncrementer, m_gridSizeIncrementer, m_gridStyle, KIGFX::GAL_DISPLAY_OPTIONS::m_gridStyle, and KIGFX::GAL_DISPLAY_OPTIONS::NotifyChanged().

Referenced by PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_MODEDIT_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_LIBEDIT_DISPLAY_OPTIONS::TransferDataFromWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow(), and PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataFromWindow().

◆ TransferDataToWindow()

bool GAL_OPTIONS_PANEL::TransferDataToWindow ( )
override

Load the panel controls from the given opt.

Definition at line 197 of file gal_options_panel.cpp.

198 {
199  m_gridStyle->SetSelection( UTIL::GetConfigForVal(
201 
203 
205 
207 
209 
210  return true;
211 }
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleSelectMap
wxRadioBox * m_cursorShape
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
std::unique_ptr< INCREMENTAL_TEXT_CTRL > m_gridMinSpacingIncrementer
KIGFX::GAL_DISPLAY_OPTIONS & m_galOptions
The GAL options to read/write
bool m_forceDisplayCursor
Force cursor display
std::unique_ptr< INCREMENTAL_TEXT_CTRL > m_gridSizeIncrementer
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
wxRadioBox * m_gridStyle
wxCheckBox * m_forceCursorDisplay
double m_gridLineWidth
Thickness to render grid lines/dots
bool m_fullscreenCursor
Fullscreen crosshair or small cross
static long GetConfigForVal(const MAP &aMap, CFG_NATIVE_VAL< MAP > aVal)
Get the mapped config value (the one to write to file, or use in an index) from the given native (pro...
Definition: config_map.h:69

References UTIL::GetConfigForVal(), gridStyleSelectMap, m_cursorShape, m_forceCursorDisplay, KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor, KIGFX::GAL_DISPLAY_OPTIONS::m_fullscreenCursor, m_galOptions, KIGFX::GAL_DISPLAY_OPTIONS::m_gridLineWidth, KIGFX::GAL_DISPLAY_OPTIONS::m_gridMinSpacing, m_gridMinSpacingIncrementer, m_gridSizeIncrementer, m_gridStyle, and KIGFX::GAL_DISPLAY_OPTIONS::m_gridStyle.

Referenced by PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataToWindow(), PANEL_MODEDIT_DISPLAY_OPTIONS::TransferDataToWindow(), PANEL_LIBEDIT_DISPLAY_OPTIONS::TransferDataToWindow(), PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow(), and PANEL_GERBVIEW_DISPLAY_OPTIONS::TransferDataToWindow().

Member Data Documentation

◆ l_gridLineWidth

wxStaticText* GAL_OPTIONS_PANEL::l_gridLineWidth
private

Definition at line 56 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ l_gridLineWidthUnits

wxStaticText* GAL_OPTIONS_PANEL::l_gridLineWidthUnits
private

Definition at line 59 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ l_gridMinSpacing

wxStaticText* GAL_OPTIONS_PANEL::l_gridMinSpacing
private

Definition at line 61 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ l_gridMinSpacingUnits

wxStaticText* GAL_OPTIONS_PANEL::l_gridMinSpacingUnits
private

Definition at line 64 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ m_cursorShape

wxRadioBox* GAL_OPTIONS_PANEL::m_cursorShape
private

◆ m_forceCursorDisplay

wxCheckBox* GAL_OPTIONS_PANEL::m_forceCursorDisplay
private

◆ m_galOptions

KIGFX::GAL_DISPLAY_OPTIONS& GAL_OPTIONS_PANEL::m_galOptions
private

The GAL options to read/write

Definition at line 70 of file gal_options_panel.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

◆ m_gridLineWidth

wxTextCtrl* GAL_OPTIONS_PANEL::m_gridLineWidth
private

Definition at line 57 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ m_gridLineWidthSpinBtn

wxSpinButton* GAL_OPTIONS_PANEL::m_gridLineWidthSpinBtn
private

Definition at line 58 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ m_gridMinSpacing

wxTextCtrl* GAL_OPTIONS_PANEL::m_gridMinSpacing
private

Definition at line 62 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ m_gridMinSpacingIncrementer

std::unique_ptr<INCREMENTAL_TEXT_CTRL> GAL_OPTIONS_PANEL::m_gridMinSpacingIncrementer
private

◆ m_gridMinSpacingSpinBtn

wxSpinButton* GAL_OPTIONS_PANEL::m_gridMinSpacingSpinBtn
private

Definition at line 63 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().

◆ m_gridSizeIncrementer

std::unique_ptr<INCREMENTAL_TEXT_CTRL> GAL_OPTIONS_PANEL::m_gridSizeIncrementer
private

◆ m_gridStyle

wxRadioBox* GAL_OPTIONS_PANEL::m_gridStyle
private

◆ m_mainSizer

wxBoxSizer* GAL_OPTIONS_PANEL::m_mainSizer
private

Definition at line 52 of file gal_options_panel.h.

Referenced by GAL_OPTIONS_PANEL().


The documentation for this class was generated from the following files: