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 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 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  userUnits,
PCB_BASE_FRAME aFrame 
)

Definition at line 42 of file text_mod_grid_table.cpp.

43  : m_userUnits( aUserUnits ), 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_CENTER );
54 
55  if( g_menuOrientations.IsEmpty() )
56  {
57  g_menuOrientations.push_back(
59  g_menuOrientations.push_back(
60  wxT( "90 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
61  g_menuOrientations.push_back(
62  wxT( "-90 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
63  g_menuOrientations.push_back(
64  wxT( "180 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
65  }
66 
67  m_orientationColAttr = new wxGridCellAttr;
69 
70  m_layerColAttr = new wxGridCellAttr;
71  m_layerColAttr->SetRenderer( new GRID_CELL_LAYER_RENDERER( m_frame ) );
72  m_layerColAttr->SetEditor( new GRID_CELL_LAYER_SELECTOR( m_frame, {} ) );
73 }
wxGridCellAttr * m_boolColAttr
wxString GetAbbreviatedUnitsLabel(EDA_UNITS aUnit, EDA_DATA_TYPE aType)
Get the units string for a given units type.
Definition: base_units.cpp:467
wxGridCellAttr * m_orientationColAttr
wxGridCellAttr * m_readOnlyAttr
PCB_BASE_FRAME * m_frame
wxArrayString g_menuOrientations
wxGridCellAttr * m_layerColAttr

References DEGREES, 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 76 of file text_mod_grid_table.cpp.

77 {
78  m_readOnlyAttr->DecRef();
79  m_boolColAttr->DecRef();
80  m_orientationColAttr->DecRef();
81  m_layerColAttr->DecRef();
82 }
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 116 of file text_mod_grid_table.cpp.

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

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 144 of file text_mod_grid_table.cpp.

145 {
146  return CanGetValueAs( aRow, aCol, aTypeName );
147 }
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 150 of file text_mod_grid_table.cpp.

151 {
152  switch( aCol )
153  {
154  case TMC_TEXT:
155  case TMC_WIDTH:
156  case TMC_HEIGHT:
157  case TMC_THICKNESS:
158  case TMC_XOFFSET:
159  case TMC_YOFFSET:
160  return nullptr;
161 
162  case TMC_SHOWN:
163  case TMC_ITALIC:
164  case TMC_UPRIGHT:
165  m_boolColAttr->IncRef();
166  return m_boolColAttr;
167 
168  case TMC_LAYER:
169  m_layerColAttr->IncRef();
170  return m_layerColAttr;
171 
172  case TMC_ORIENTATION:
173  m_orientationColAttr->IncRef();
174  return m_orientationColAttr;
175 
176  default:
177  wxFAIL;
178  return nullptr;
179  }
180 }
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 85 of file text_mod_grid_table.cpp.

86 {
87  switch( aCol )
88  {
89  case TMC_TEXT: return _( "Text Items" );
90  case TMC_SHOWN: return _( "Show" );
91  case TMC_WIDTH: return _( "Width" );
92  case TMC_HEIGHT: return _( "Height" );
93  case TMC_THICKNESS: return _( "Thickness" );
94  case TMC_ITALIC: return _( "Italic" );
95  case TMC_LAYER: return _( "Layer" );
96  case TMC_ORIENTATION: return _( "Orientation" );
97  case TMC_UPRIGHT: return _( "Keep Upright" );
98  case TMC_XOFFSET: return _( "X Offset" );
99  case TMC_YOFFSET: return _( "Y Offset" );
100  default: wxFAIL; return wxEmptyString;
101  }
102 }
#define _(s)
Definition: 3d_actions.cpp:33

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 105 of file text_mod_grid_table.cpp.

106 {
107  switch( aRow )
108  {
109  case 0: return _( "Reference designator" );
110  case 1: return _( "Value" );
111  default: return wxEmptyString;
112  }
113 }
#define _(s)
Definition: 3d_actions.cpp:33

References _.

◆ GetValue()

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

Definition at line 183 of file text_mod_grid_table.cpp.

184 {
185  const FP_TEXT& text = this->at((size_t) aRow );
186 
187  switch( aCol )
188  {
189  case TMC_TEXT:
190  return text.GetText();
191 
192  case TMC_WIDTH:
193  return StringFromValue( m_userUnits, text.GetTextWidth() );
194 
195  case TMC_HEIGHT:
196  return StringFromValue( m_userUnits, text.GetTextHeight() );
197 
198  case TMC_THICKNESS:
199  return StringFromValue( m_userUnits, text.GetTextThickness() );
200 
201  case TMC_LAYER:
202  return text.GetLayerName();
203 
204  case TMC_ORIENTATION:
206  true );
207 
208  case TMC_XOFFSET:
209  return StringFromValue( m_userUnits, text.GetPos0().x );
210 
211  case TMC_YOFFSET:
212  return StringFromValue( m_userUnits, text.GetPos0().y );
213 
214  default:
215  // we can't assert here because wxWidgets sometimes calls this without checking
216  // the column type when trying to see if there's an overflow
217  return wxT( "bad wxWidgets!" );
218  }
219 }
double GetTextAngle() const
Definition: eda_text.h:180
int GetTextThickness() const
Definition: eda_text.h:165
int GetTextHeight() const
Definition: eda_text.h:251
const wxPoint & GetPos0() const
Definition: fp_text.h:166
int GetTextWidth() const
Definition: eda_text.h:248
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:265
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:220
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
Definition: board_item.cpp:60
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

References DEGREES, BOARD_ITEM::GetLayerName(), FP_TEXT::GetPos0(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextHeight(), EDA_TEXT::GetTextThickness(), EDA_TEXT::GetTextWidth(), 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 222 of file text_mod_grid_table.cpp.

223 {
224  FP_TEXT& text = this->at((size_t) aRow );
225 
226  switch( aCol )
227  {
228  case TMC_SHOWN: return text.IsVisible();
229  case TMC_ITALIC: return text.IsItalic();
230  case TMC_UPRIGHT: return text.IsKeepUpright();
231  default:
232  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a bool value" ), aCol ) );
233  return false;
234  }
235 }
bool IsVisible() const
Definition: eda_text.h:192
bool IsItalic() const
Definition: eda_text.h:186
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
bool IsKeepUpright()
Definition: fp_text.h:108

References Format(), EDA_TEXT::IsItalic(), FP_TEXT::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 238 of file text_mod_grid_table.cpp.

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

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 252 of file text_mod_grid_table.cpp.

253 {
254  FP_TEXT& text = this->at((size_t) aRow );
255  wxPoint pos;
256 
257  switch( aCol )
258  {
259  case TMC_TEXT:
260  text.SetText( aValue );
261  break;
262 
263  case TMC_WIDTH:
264  text.SetTextWidth( ValueFromString( m_userUnits, aValue ) );
265  break;
266 
267  case TMC_HEIGHT:
268  text.SetTextHeight( ValueFromString( m_userUnits, aValue ) );
269  break;
270 
272  break;
273 
274  case TMC_ORIENTATION:
276  text.SetDrawCoord();
277  break;
278 
279  case TMC_XOFFSET:
280  case TMC_YOFFSET:
281  pos = text.GetPos0();
282 
283  if( aCol == TMC_XOFFSET )
284  pos.x = ValueFromString( m_userUnits, aValue );
285  else
286  pos.y = ValueFromString( m_userUnits, aValue );
287 
288  text.SetPos0( pos );
289  text.SetDrawCoord();
290  break;
291 
292  default:
293  wxFAIL_MSG( wxString::Format( wxT( "column %d doesn't hold a string value" ), aCol ) );
294  break;
295  }
296 
297  GetView()->Refresh();
298 }
void SetTextAngle(double aAngle) override
Definition: fp_text.cpp:69
void SetDrawCoord()
Set absolute coordinates.
Definition: fp_text.cpp:198
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:444
void SetPos0(const wxPoint &aPos)
Definition: fp_text.h:165
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
const wxPoint & GetPos0() const
Definition: fp_text.h:166
void SetTextWidth(int aWidth)
Definition: eda_text.h:247
void SetTextHeight(int aHeight)
Definition: eda_text.h:250
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:164
double DoubleValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function DoubleValueFromString converts aTextValue to a double.
Definition: base_units.cpp:333

References DEGREES, DoubleValueFromString(), Format(), FP_TEXT::GetPos0(), m_userUnits, FP_TEXT::SetDrawCoord(), FP_TEXT::SetPos0(), EDA_TEXT::SetText(), FP_TEXT::SetTextAngle(), EDA_TEXT::SetTextHeight(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetTextWidth(), 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 301 of file text_mod_grid_table.cpp.

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

References Format(), EDA_TEXT::SetItalic(), FP_TEXT::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 325 of file text_mod_grid_table.cpp.

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

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 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: