KiCad PCB EDA Suite
PANEL_SETUP_TEXT_AND_GRAPHICS Class Reference

#include <panel_setup_text_and_graphics.h>

Inheritance diagram for PANEL_SETUP_TEXT_AND_GRAPHICS:
PANEL_SETUP_TEXT_AND_GRAPHICS_BASE

Public Member Functions

 PANEL_SETUP_TEXT_AND_GRAPHICS (PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame)
 
 ~PANEL_SETUP_TEXT_AND_GRAPHICS () override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void ImportSettingsFrom (BOARD *aBoard)
 

Protected Attributes

wxBoxSizer * m_gridSizer
 
wxStaticText * m_staticText1
 
WX_GRIDm_grid
 
wxStaticText * m_staticText2
 
wxStaticText * m_dimensionUnitsLabel
 
wxChoice * m_dimensionUnits
 
wxStaticText * m_dimensionPrecisionLabel
 
wxChoice * m_dimensionPrecision
 

Private Member Functions

bool validateData ()
 
int getGridValue (int aRow, int aCol)
 

Private Attributes

PAGED_DIALOGm_Parent
 
PCB_EDIT_FRAMEm_Frame
 
BOARD_DESIGN_SETTINGSm_BrdSettings
 

Detailed Description

Definition at line 38 of file panel_setup_text_and_graphics.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_TEXT_AND_GRAPHICS()

PANEL_SETUP_TEXT_AND_GRAPHICS::PANEL_SETUP_TEXT_AND_GRAPHICS ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame 
)

Definition at line 56 of file panel_setup_text_and_graphics.cpp.

57  :
59 {
60  m_Parent = aParent;
61  m_Frame = aFrame;
63 
64  m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 );
65 
66  // Work around a bug in wxWidgets where it fails to recalculate the grid height
67  // after changing the default row size
68  m_grid->AppendRows( 1 );
69  m_grid->DeleteRows( m_grid->GetNumberRows() - 1, 1 );
70 
71  m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
72 }
GRID_TRICKS is used to add mouse and command handling (such as cut, copy, and paste) to a WX_GRID ins...
Definition: grid_tricks.h:51
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
PANEL_SETUP_TEXT_AND_GRAPHICS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
BOARD * GetBoard() const

References PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), m_BrdSettings, m_Frame, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and m_Parent.

◆ ~PANEL_SETUP_TEXT_AND_GRAPHICS()

PANEL_SETUP_TEXT_AND_GRAPHICS::~PANEL_SETUP_TEXT_AND_GRAPHICS ( )
override

Definition at line 75 of file panel_setup_text_and_graphics.cpp.

76 {
77  // destroy GRID_TRICKS before m_grid.
78  m_grid->PopEventHandler( true );
79 }

References PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid.

Member Function Documentation

◆ getGridValue()

int PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue ( int  aRow,
int  aCol 
)
private

Definition at line 141 of file panel_setup_text_and_graphics.cpp.

142 {
143  return ValueFromString( m_Frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ), true );
144 }
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:429
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References EDA_BASE_FRAME::GetUserUnits(), m_Frame, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and ValueFromString().

Referenced by TransferDataFromWindow(), and validateData().

◆ ImportSettingsFrom()

void PANEL_SETUP_TEXT_AND_GRAPHICS::ImportSettingsFrom ( BOARD aBoard)

Definition at line 199 of file panel_setup_text_and_graphics.cpp.

200 {
201  if( !m_grid->CommitPendingChanges() )
202  return;
203 
204  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
205 
206  m_BrdSettings = &aBoard->GetDesignSettings();
208 
209  m_BrdSettings = savedSettings;
210 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:172
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References WX_GRID::CommitPendingChanges(), BOARD::GetDesignSettings(), m_BrdSettings, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, and TransferDataToWindow().

Referenced by DIALOG_BOARD_SETUP::OnAuxiliaryAction().

◆ TransferDataFromWindow()

bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataFromWindow ( )
override

Definition at line 171 of file panel_setup_text_and_graphics.cpp.

172 {
173  if( !validateData() )
174  return false;
175 
176  for( int i = 0; i < ROW_COUNT; ++i )
177  {
179 
180  if( i == ROW_EDGES || i == ROW_COURTYARD )
181  continue;
182 
183  m_BrdSettings->m_TextSize[ i ] =
187  wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_ITALIC ) );
189  wxGridCellBoolEditor::IsTrueValue( m_grid->GetCellValue( i, COL_TEXT_UPRIGHT ) );
190  }
191 
194 
195  return true;
196 }
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
bool m_TextItalic[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
bool m_TextUpright[LAYER_CLASS_COUNT]

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_UPRIGHT, COL_TEXT_WIDTH, getGridValue(), m_BrdSettings, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecision, BOARD_DESIGN_SETTINGS::m_DimensionPrecision, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnits, BOARD_DESIGN_SETTINGS::m_DimensionUnits, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_TextUpright, ROW_COUNT, ROW_COURTYARD, ROW_EDGES, and validateData().

◆ TransferDataToWindow()

bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow ( )
override

Definition at line 82 of file panel_setup_text_and_graphics.cpp.

83 {
84  wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
85 
86 #define SET_MILS_CELL( row, col, val ) \
87  m_grid->SetCellValue( row, col, StringFromValue( m_Frame->GetUserUnits(), val, true, true ) )
88 
89 #define DISABLE_CELL( row, col ) \
90  m_grid->SetReadOnly( row, col ); m_grid->SetCellBackgroundColour( row, col, disabledColour );
91 
92  for( int i = 0; i < ROW_COUNT; ++i )
93  {
95 
96  if( i == ROW_EDGES || i == ROW_COURTYARD )
97  {
103  }
104  else
105  {
109  m_grid->SetCellValue( i, COL_TEXT_ITALIC, m_BrdSettings->m_TextItalic[ i ] ? "1" : "" );
110  m_grid->SetCellValue( i, COL_TEXT_UPRIGHT, m_BrdSettings->m_TextUpright[ i ] ? "1" : "" );
111 
112  auto attr = new wxGridCellAttr;
113  attr->SetRenderer( new wxGridCellBoolRenderer() );
114  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
115  attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
116  m_grid->SetAttr( i, COL_TEXT_ITALIC, attr );
117 
118  attr = new wxGridCellAttr;
119  attr->SetRenderer( new wxGridCellBoolRenderer() );
120  attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
121  attr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
122  m_grid->SetAttr( i, COL_TEXT_UPRIGHT, attr );
123  }
124  }
125 
126  // Work around an issue where wxWidgets doesn't calculate the row width on its own
127  for( int col = 0; col < m_grid->GetNumberCols(); col++ )
128  m_grid->SetColMinimalWidth( col, m_grid->GetVisibleWidth( col, true, true, false ) );
129 
130  m_grid->SetRowLabelSize( m_grid->GetVisibleWidth( -1, true, true, true ) );
131 
132  Layout();
133 
136 
137  return true;
138 }
int GetVisibleWidth(int aCol, bool aHeader=true, bool aContents=false, bool aKeep=true)
Calculates the specified column based on the actual size of the text on screen.
Definition: wx_grid.cpp:228
wxSize m_TextSize[LAYER_CLASS_COUNT]
int m_TextThickness[LAYER_CLASS_COUNT]
#define DISABLE_CELL(row, col)
bool m_TextItalic[LAYER_CLASS_COUNT]
int m_LineThickness[LAYER_CLASS_COUNT]
#define SET_MILS_CELL(row, col, val)
bool m_TextUpright[LAYER_CLASS_COUNT]

References COL_LINE_THICKNESS, COL_TEXT_HEIGHT, COL_TEXT_ITALIC, COL_TEXT_THICKNESS, COL_TEXT_UPRIGHT, COL_TEXT_WIDTH, DISABLE_CELL, WX_GRID::GetVisibleWidth(), m_BrdSettings, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecision, BOARD_DESIGN_SETTINGS::m_DimensionPrecision, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnits, BOARD_DESIGN_SETTINGS::m_DimensionUnits, PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, BOARD_DESIGN_SETTINGS::m_LineThickness, BOARD_DESIGN_SETTINGS::m_TextItalic, BOARD_DESIGN_SETTINGS::m_TextSize, BOARD_DESIGN_SETTINGS::m_TextThickness, BOARD_DESIGN_SETTINGS::m_TextUpright, ROW_COUNT, ROW_COURTYARD, ROW_EDGES, and SET_MILS_CELL.

Referenced by ImportSettingsFrom().

◆ validateData()

bool PANEL_SETUP_TEXT_AND_GRAPHICS::validateData ( )
private

Definition at line 147 of file panel_setup_text_and_graphics.cpp.

148 {
149  if( !m_grid->CommitPendingChanges() )
150  return false;
151 
152  // Test text parameters.
153  for( int row : { ROW_SILK, ROW_COPPER, ROW_OTHERS } )
154  {
155  int textSize = std::min( getGridValue( row, COL_TEXT_WIDTH ),
156  getGridValue( row, COL_TEXT_HEIGHT ) );
157 
158  if( getGridValue( row, COL_TEXT_THICKNESS ) > textSize / 4 )
159  {
160  wxString msg = _( "Text will not be readable with a thickness greater than\n"
161  "1/4 its width or height." );
162  m_Parent->SetError( msg, this, m_grid, row, COL_TEXT_THICKNESS );
163  return false;
164  }
165  }
166 
167  return true;
168 }
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:172
void SetError(const wxString &aMessage, wxWindow *aPage, wxObject *aCtrl, int aRow=-1, int aCol=-1)
#define _(s)
Definition: 3d_actions.cpp:31

References _, COL_TEXT_HEIGHT, COL_TEXT_THICKNESS, COL_TEXT_WIDTH, WX_GRID::CommitPendingChanges(), getGridValue(), PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_grid, m_Parent, ROW_COPPER, ROW_OTHERS, ROW_SILK, and PAGED_DIALOG::SetError().

Referenced by TransferDataFromWindow().

Member Data Documentation

◆ m_BrdSettings

BOARD_DESIGN_SETTINGS* PANEL_SETUP_TEXT_AND_GRAPHICS::m_BrdSettings
private

◆ m_dimensionPrecision

wxChoice* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecision
protectedinherited

◆ m_dimensionPrecisionLabel

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionPrecisionLabel
protectedinherited

◆ m_dimensionUnits

wxChoice* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnits
protectedinherited

◆ m_dimensionUnitsLabel

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_dimensionUnitsLabel
protectedinherited

◆ m_Frame

PCB_EDIT_FRAME* PANEL_SETUP_TEXT_AND_GRAPHICS::m_Frame
private

Definition at line 42 of file panel_setup_text_and_graphics.h.

Referenced by getGridValue(), and PANEL_SETUP_TEXT_AND_GRAPHICS().

◆ m_grid

◆ m_gridSizer

wxBoxSizer* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_gridSizer
protectedinherited

◆ m_Parent

PAGED_DIALOG* PANEL_SETUP_TEXT_AND_GRAPHICS::m_Parent
private

Definition at line 41 of file panel_setup_text_and_graphics.h.

Referenced by PANEL_SETUP_TEXT_AND_GRAPHICS(), and validateData().

◆ m_staticText1

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_staticText1
protectedinherited

◆ m_staticText2

wxStaticText* PANEL_SETUP_TEXT_AND_GRAPHICS_BASE::m_staticText2
protectedinherited

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