KiCad PCB EDA Suite
TEXT_MOD_GRID_TABLE Class Reference

#include <text_mod_grid_table.h>

Inheritance diagram for TEXT_MOD_GRID_TABLE:

Public Member Functions

 TEXT_MOD_GRID_TABLE (EDA_UNITS_T userUnits, PCB_BASE_FRAME *aFrame)
 
 ~TEXT_MOD_GRID_TABLE ()
 
int GetNumberRows () override
 
int GetNumberCols () override
 
wxString GetColLabelValue (int aCol) override
 
wxString GetRowLabelValue (int aRow) override
 
bool IsEmptyCell (int row, int col) override
 
bool CanGetValueAs (int aRow, int aCol, const wxString &aTypeName) override
 
bool CanSetValueAs (int aRow, int aCol, const wxString &aTypeName) override
 
wxGridCellAttr * GetAttr (int row, int col, wxGridCellAttr::wxAttrKind kind) override
 
wxString GetValue (int aRow, int aCol) override
 
bool GetValueAsBool (int aRow, int aCol) override
 
long GetValueAsLong (int aRow, int aCol) override
 
void SetValue (int aRow, int aCol, const wxString &aValue) override
 
void SetValueAsBool (int aRow, int aCol, bool aValue) override
 
void SetValueAsLong (int aRow, int aCol, long aValue) override
 

Private Attributes

EDA_UNITS_T m_userUnits
 
PCB_BASE_FRAMEm_frame
 
wxGridCellAttr * m_readOnlyAttr
 
wxGridCellAttr * m_boolColAttr
 
wxGridCellAttr * m_orientationColAttr
 
wxGridCellAttr * m_layerColAttr
 

Detailed Description

Definition at line 54 of file text_mod_grid_table.h.

Constructor & Destructor Documentation

◆ TEXT_MOD_GRID_TABLE()

TEXT_MOD_GRID_TABLE::TEXT_MOD_GRID_TABLE ( EDA_UNITS_T  userUnits,
PCB_BASE_FRAME aFrame 
)

Definition at line 41 of file text_mod_grid_table.cpp.

41  :
42  m_userUnits( aUserUnits ),
43  m_frame( aFrame )
44 {
45  // Build the column attributes.
46 
47  m_readOnlyAttr = new wxGridCellAttr;
48  m_readOnlyAttr->SetReadOnly( true );
49 
50  m_boolColAttr = new wxGridCellAttr;
51  m_boolColAttr->SetRenderer( new wxGridCellBoolRenderer() );
52  m_boolColAttr->SetEditor( new wxGridCellBoolEditor() );
53  m_boolColAttr->SetAlignment( wxALIGN_CENTER, wxALIGN_BOTTOM );
54 
55  if( g_menuOrientations.IsEmpty() )
56  {
57  g_menuOrientations.push_back( wxT( "0 " ) + GetAbbreviatedUnitsLabel( DEGREES ) );
58  g_menuOrientations.push_back( wxT( "90 " ) + GetAbbreviatedUnitsLabel( DEGREES ) );
59  g_menuOrientations.push_back( wxT( "-90 " ) + GetAbbreviatedUnitsLabel( DEGREES ) );
60  g_menuOrientations.push_back( wxT( "180 " ) + GetAbbreviatedUnitsLabel( DEGREES ) );
61  }
62 
63  m_orientationColAttr = new wxGridCellAttr;
65 
66  m_layerColAttr = new wxGridCellAttr;
67  m_layerColAttr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) );
69 }
wxGridCellAttr * m_boolColAttr
wxGridCellAttr * m_orientationColAttr
wxGridCellAttr * m_readOnlyAttr
PCB_BASE_FRAME * m_frame
wxArrayString g_menuOrientations
wxGridCellAttr * m_layerColAttr
static LSET ForbiddenTextLayers()
Function ForbiddenTextLayers Layers which are now allowed to have text on them.
Definition: lset.cpp:796
wxString GetAbbreviatedUnitsLabel(EDA_UNITS_T aUnit, bool aUseMils)
Get the units string for a given units type.
Definition: base_units.cpp:432

References DEGREES, LSET::ForbiddenTextLayers(), g_menuOrientations, GetAbbreviatedUnitsLabel(), m_boolColAttr, m_frame, m_layerColAttr, m_orientationColAttr, and m_readOnlyAttr.

◆ ~TEXT_MOD_GRID_TABLE()

TEXT_MOD_GRID_TABLE::~TEXT_MOD_GRID_TABLE ( )

Definition at line 72 of file text_mod_grid_table.cpp.

73 {
74  m_readOnlyAttr->DecRef();
75  m_boolColAttr->DecRef();
76  m_orientationColAttr->DecRef();
77  m_layerColAttr->DecRef();
78 }
wxGridCellAttr * m_boolColAttr
wxGridCellAttr * m_orientationColAttr
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_layerColAttr

References m_boolColAttr, m_layerColAttr, m_orientationColAttr, and m_readOnlyAttr.

Member Function Documentation

◆ CanGetValueAs()

bool TEXT_MOD_GRID_TABLE::CanGetValueAs ( int  aRow,
int  aCol,
const wxString &  aTypeName 
)
override

Definition at line 112 of file text_mod_grid_table.cpp.

113 {
114  switch( aCol )
115  {
116  case TMC_TEXT:
117  case TMC_WIDTH:
118  case TMC_HEIGHT:
119  case TMC_THICKNESS:
120  case TMC_ORIENTATION:
121  case TMC_XOFFSET:
122  case TMC_YOFFSET:
123  return aTypeName == wxGRID_VALUE_STRING;
124 
125  case TMC_SHOWN:
126  case TMC_ITALIC:
127  case TMC_UPRIGHT:
128  return aTypeName == wxGRID_VALUE_BOOL;
129 
130  case TMC_LAYER:
131  return aTypeName == wxGRID_VALUE_NUMBER;
132 
133  default:
134  wxFAIL;
135  return false;
136  }
137 }

References TMC_HEIGHT, TMC_ITALIC, TMC_LAYER, TMC_ORIENTATION, TMC_SHOWN, TMC_TEXT, TMC_THICKNESS, TMC_UPRIGHT, TMC_WIDTH, TMC_XOFFSET, and TMC_YOFFSET.

Referenced by CanSetValueAs().

◆ CanSetValueAs()

bool TEXT_MOD_GRID_TABLE::CanSetValueAs ( int  aRow,
int  aCol,
const wxString &  aTypeName 
)
override

Definition at line 140 of file text_mod_grid_table.cpp.

141 {
142  return CanGetValueAs( aRow, aCol, aTypeName );
143 }
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override

References CanGetValueAs().

◆ GetAttr()

wxGridCellAttr * TEXT_MOD_GRID_TABLE::GetAttr ( int  row,
int  col,
wxGridCellAttr::wxAttrKind  kind 
)
override

Definition at line 146 of file text_mod_grid_table.cpp.

147 {
148  switch( aCol )
149  {
150  case TMC_TEXT:
151  case TMC_WIDTH:
152  case TMC_HEIGHT:
153  case TMC_THICKNESS:
154  case TMC_XOFFSET:
155  case TMC_YOFFSET:
156  return nullptr;
157 
158  case TMC_SHOWN:
159  case TMC_ITALIC:
160  case TMC_UPRIGHT:
161  m_boolColAttr->IncRef();
162  return m_boolColAttr;
163 
164  case TMC_LAYER:
165  m_layerColAttr->IncRef();
166  return m_layerColAttr;
167 
168  case TMC_ORIENTATION:
169  m_orientationColAttr->IncRef();
170  return m_orientationColAttr;
171 
172  default:
173  wxFAIL;
174  return nullptr;
175  }
176 }
wxGridCellAttr * m_boolColAttr
wxGridCellAttr * m_orientationColAttr
wxGridCellAttr * m_layerColAttr

References m_boolColAttr, m_layerColAttr, m_orientationColAttr, TMC_HEIGHT, TMC_ITALIC, TMC_LAYER, TMC_ORIENTATION, TMC_SHOWN, TMC_TEXT, TMC_THICKNESS, TMC_UPRIGHT, TMC_WIDTH, TMC_XOFFSET, and TMC_YOFFSET.

◆ GetColLabelValue()

wxString TEXT_MOD_GRID_TABLE::GetColLabelValue ( int  aCol)
override

Definition at line 81 of file text_mod_grid_table.cpp.

82 {
83  switch( aCol )
84  {
85  case TMC_TEXT: return _( "Text Items" );
86  case TMC_SHOWN: return _( "Show" );
87  case TMC_WIDTH: return _( "Width" );
88  case TMC_HEIGHT: return _( "Height" );
89  case TMC_THICKNESS: return _( "Thickness" );
90  case TMC_ITALIC: return _( "Italic" );
91  case TMC_LAYER: return _( "Layer" );
92  case TMC_ORIENTATION: return _( "Orientation" );
93  case TMC_UPRIGHT: return _( "Keep Upright" );
94  case TMC_XOFFSET: return _( "X Offset" );
95  case TMC_YOFFSET: return _( "Y Offset" );
96  default: wxFAIL; return wxEmptyString;
97  }
98 }

References TMC_HEIGHT, TMC_ITALIC, TMC_LAYER, TMC_ORIENTATION, TMC_SHOWN, TMC_TEXT, TMC_THICKNESS, TMC_UPRIGHT, TMC_WIDTH, TMC_XOFFSET, and TMC_YOFFSET.

◆ GetNumberCols()

int TEXT_MOD_GRID_TABLE::GetNumberCols ( )
inlineoverride

Definition at line 61 of file text_mod_grid_table.h.

61 { return TMC_COUNT; }

References TMC_COUNT.

◆ GetNumberRows()

int TEXT_MOD_GRID_TABLE::GetNumberRows ( )
inlineoverride

◆ GetRowLabelValue()

wxString TEXT_MOD_GRID_TABLE::GetRowLabelValue ( int  aRow)
override

Definition at line 101 of file text_mod_grid_table.cpp.

102 {
103  switch( aRow )
104  {
105  case 0: return _( "Reference" );
106  case 1: return _( "Value" );
107  default: return wxEmptyString;
108  }
109 }

◆ GetValue()

wxString TEXT_MOD_GRID_TABLE::GetValue ( int  aRow,
int  aCol 
)
override

Definition at line 179 of file text_mod_grid_table.cpp.

180 {
181  const TEXTE_MODULE& text = this->at( (size_t) aRow );
182 
183  switch( aCol )
184  {
185  case TMC_TEXT:
186  return text.GetText();
187 
188  case TMC_WIDTH:
189  return StringFromValue( m_userUnits, text.GetTextWidth(), true, true );
190 
191  case TMC_HEIGHT:
192  return StringFromValue( m_userUnits, text.GetTextHeight(), true, true );
193 
194  case TMC_THICKNESS:
195  return StringFromValue( m_userUnits, text.GetThickness(), true, true );
196 
197  case TMC_LAYER:
198  return text.GetLayerName();
199 
200  case TMC_ORIENTATION:
201  return StringFromValue( DEGREES, (int) NormalizeAnglePos( text.GetTextAngle() ), true );
202 
203  case TMC_XOFFSET:
204  return StringFromValue( m_userUnits, text.GetPos0().x, true );
205 
206  case TMC_YOFFSET:
207  return StringFromValue( m_userUnits, text.GetPos0().y, true );
208 
209  default:
210  // we can't assert here because wxWidgets sometimes calls this without checking
211  // the column type when trying to see if there's an overflow
212  return wxT( "bad wxWidgets!" );
213  }
214 }
double GetTextAngle() const
Definition: eda_text.h:181
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:171
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
int GetTextHeight() const
Definition: eda_text.h:238
const wxPoint & GetPos0() const
int GetTextWidth() const
Definition: eda_text.h:235
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:242
wxString StringFromValue(EDA_UNITS_T aUnits, int aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:210
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.

References DEGREES, BOARD_ITEM::GetLayerName(), TEXTE_MODULE::GetPos0(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextHeight(), EDA_TEXT::GetTextWidth(), EDA_TEXT::GetThickness(), m_userUnits, NormalizeAnglePos(), StringFromValue(), TMC_HEIGHT, TMC_LAYER, TMC_ORIENTATION, TMC_TEXT, TMC_THICKNESS, TMC_WIDTH, TMC_XOFFSET, and TMC_YOFFSET.

◆ GetValueAsBool()

bool TEXT_MOD_GRID_TABLE::GetValueAsBool ( int  aRow,
int  aCol 
)
override

Definition at line 217 of file text_mod_grid_table.cpp.

218 {
219  TEXTE_MODULE& text = this->at( (size_t) aRow );
220 
221  switch( aCol )
222  {
223  case TMC_SHOWN: return text.IsVisible();
224  case TMC_ITALIC: return text.IsItalic();
225  case TMC_UPRIGHT: return text.IsKeepUpright();
226  default:
227  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
228  return false;
229  }
230 }
bool IsVisible() const
Definition: eda_text.h:193
bool IsItalic() const
Definition: eda_text.h:187
bool IsKeepUpright()
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

References Format(), EDA_TEXT::IsItalic(), TEXTE_MODULE::IsKeepUpright(), EDA_TEXT::IsVisible(), TMC_ITALIC, TMC_SHOWN, and TMC_UPRIGHT.

◆ GetValueAsLong()

long TEXT_MOD_GRID_TABLE::GetValueAsLong ( int  aRow,
int  aCol 
)
override

Definition at line 233 of file text_mod_grid_table.cpp.

234 {
235  TEXTE_MODULE& text = this->at( (size_t) aRow );
236 
237  switch( aCol )
238  {
239  case TMC_LAYER: return text.GetLayer();
240  default:
241  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a long value" ), aCol ) );
242  return 0;
243  }
244 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.

References Format(), BOARD_ITEM::GetLayer(), and TMC_LAYER.

◆ IsEmptyCell()

bool TEXT_MOD_GRID_TABLE::IsEmptyCell ( int  row,
int  col 
)
inlineoverride

Definition at line 66 of file text_mod_grid_table.h.

67  {
68  return false; // don't allow adjacent cell overflow, even if we are actually empty
69  }

◆ SetValue()

void TEXT_MOD_GRID_TABLE::SetValue ( int  aRow,
int  aCol,
const wxString &  aValue 
)
override

Definition at line 247 of file text_mod_grid_table.cpp.

248 {
249  TEXTE_MODULE& text = this->at( (size_t) aRow );
250  wxPoint pos;
251 
252  switch( aCol )
253  {
254  case TMC_TEXT:
255  text.SetText( aValue );
256  break;
257 
258  case TMC_WIDTH:
259  text.SetTextWidth( ValueFromString( m_userUnits, aValue, true ) );
260  break;
261 
262  case TMC_HEIGHT:
263  text.SetTextHeight( ValueFromString( m_userUnits, aValue, true ) );
264  break;
265 
266  case TMC_THICKNESS:
267  text.SetThickness( ValueFromString( m_userUnits, aValue, true ) );
268  break;
269 
270  case TMC_ORIENTATION:
271  text.SetTextAngle( DoubleValueFromString( DEGREES, aValue ) );
272  text.SetDrawCoord();
273  break;
274 
275  case TMC_XOFFSET:
276  case TMC_YOFFSET:
277  pos = text.GetPos0();
278 
279  if( aCol == TMC_XOFFSET )
280  pos.x = ValueFromString( m_userUnits, aValue );
281  else
282  pos.y = ValueFromString( m_userUnits, aValue );
283 
284  text.SetPos0( pos );
285  text.SetDrawCoord();
286  break;
287 
288  default:
289  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
290  break;
291  }
292 
293  GetView()->Refresh();
294 }
int ValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:409
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:64
double DoubleValueFromString(EDA_UNITS_T aUnits, const wxString &aTextValue, bool aUseMils)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:302
void SetPos0(const wxPoint &aPos)
const wxPoint & GetPos0() const
void SetTextWidth(int aWidth)
Definition: eda_text.h:234
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetDrawCoord()
Set absolute coordinates.
void SetTextHeight(int aHeight)
Definition: eda_text.h:237
void SetTextAngle(double aAngle)
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:165

References DEGREES, DoubleValueFromString(), Format(), TEXTE_MODULE::GetPos0(), m_userUnits, TEXTE_MODULE::SetDrawCoord(), TEXTE_MODULE::SetPos0(), EDA_TEXT::SetText(), TEXTE_MODULE::SetTextAngle(), EDA_TEXT::SetTextHeight(), EDA_TEXT::SetTextWidth(), EDA_TEXT::SetThickness(), TMC_HEIGHT, TMC_ORIENTATION, TMC_TEXT, TMC_THICKNESS, TMC_WIDTH, TMC_XOFFSET, TMC_YOFFSET, and ValueFromString().

◆ SetValueAsBool()

void TEXT_MOD_GRID_TABLE::SetValueAsBool ( int  aRow,
int  aCol,
bool  aValue 
)
override

Definition at line 297 of file text_mod_grid_table.cpp.

298 {
299  TEXTE_MODULE& text = this->at( (size_t) aRow );
300 
301  switch( aCol )
302  {
303  case TMC_SHOWN:
304  text.SetVisible( aValue );
305  break;
306 
307  case TMC_ITALIC:
308  text.SetItalic( aValue );
309  break;
310 
311  case TMC_UPRIGHT:text.SetKeepUpright( aValue );
312  break;
313 
314  default:
315  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
316  break;
317  }
318 }
void SetKeepUpright(bool aKeepUpright)
void SetItalic(bool isItalic)
Definition: eda_text.h:186
void SetVisible(bool aVisible)
Definition: eda_text.h:192
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

References Format(), EDA_TEXT::SetItalic(), TEXTE_MODULE::SetKeepUpright(), EDA_TEXT::SetVisible(), TMC_ITALIC, TMC_SHOWN, and TMC_UPRIGHT.

◆ SetValueAsLong()

void TEXT_MOD_GRID_TABLE::SetValueAsLong ( int  aRow,
int  aCol,
long  aValue 
)
override

Definition at line 321 of file text_mod_grid_table.cpp.

322 {
323  TEXTE_MODULE& text = this->at( (size_t) aRow );
324 
325  switch( aCol )
326  {
327  case TMC_LAYER:
328  text.SetLayer( ToLAYER_ID( (int) aValue ) );
329  text.SetMirrored( IsBackLayer( text.GetLayer() ) );
330  break;
331 
332  default:
333  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a long value" ), aCol ) );
334  break;
335  }
336 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:195
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813

References Format(), BOARD_ITEM::GetLayer(), IsBackLayer(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), TMC_LAYER, and ToLAYER_ID().

Member Data Documentation

◆ m_boolColAttr

wxGridCellAttr* TEXT_MOD_GRID_TABLE::m_boolColAttr
private

Definition at line 88 of file text_mod_grid_table.h.

Referenced by GetAttr(), TEXT_MOD_GRID_TABLE(), and ~TEXT_MOD_GRID_TABLE().

◆ m_frame

PCB_BASE_FRAME* TEXT_MOD_GRID_TABLE::m_frame
private

Definition at line 85 of file text_mod_grid_table.h.

Referenced by TEXT_MOD_GRID_TABLE().

◆ m_layerColAttr

wxGridCellAttr* TEXT_MOD_GRID_TABLE::m_layerColAttr
private

Definition at line 90 of file text_mod_grid_table.h.

Referenced by GetAttr(), TEXT_MOD_GRID_TABLE(), and ~TEXT_MOD_GRID_TABLE().

◆ m_orientationColAttr

wxGridCellAttr* TEXT_MOD_GRID_TABLE::m_orientationColAttr
private

Definition at line 89 of file text_mod_grid_table.h.

Referenced by GetAttr(), TEXT_MOD_GRID_TABLE(), and ~TEXT_MOD_GRID_TABLE().

◆ m_readOnlyAttr

wxGridCellAttr* TEXT_MOD_GRID_TABLE::m_readOnlyAttr
private

Definition at line 87 of file text_mod_grid_table.h.

Referenced by TEXT_MOD_GRID_TABLE(), and ~TEXT_MOD_GRID_TABLE().

◆ m_userUnits

EDA_UNITS_T TEXT_MOD_GRID_TABLE::m_userUnits
private

Definition at line 84 of file text_mod_grid_table.h.

Referenced by GetValue(), and SetValue().


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