KiCad PCB EDA Suite
MWAVE_POLYGONAL_SHAPE_DLG Class Reference
Inheritance diagram for MWAVE_POLYGONAL_SHAPE_DLG:

Public Member Functions

 MWAVE_POLYGONAL_SHAPE_DLG (PCB_EDIT_FRAME *parent, const wxPoint &pos)
 
 ~MWAVE_POLYGONAL_SHAPE_DLG ()
 

Private Member Functions

void OnOkClick (wxCommandEvent &event)
 
void OnCancelClick (wxCommandEvent &event)
 
void ReadDataShapeDescr (wxCommandEvent &event)
 Function ReadDataShapeDescr read a description shape file File format is Unit=MM XScale=271.501 YScale=1.00133. More...
 

Private Attributes

PCB_EDIT_FRAMEm_Parent
 
wxRadioBox * m_ShapeOptionCtrl
 
EDA_SIZE_CTRLm_SizeCtrl
 

Detailed Description

Definition at line 62 of file microwave_polygon.cpp.

Constructor & Destructor Documentation

◆ MWAVE_POLYGONAL_SHAPE_DLG()

MWAVE_POLYGONAL_SHAPE_DLG::MWAVE_POLYGONAL_SHAPE_DLG ( PCB_EDIT_FRAME parent,
const wxPoint &  pos 
)

Definition at line 106 of file microwave_polygon.cpp.

107  :
108  wxDialog( parent, -1, _( "Complex shape" ), framepos, wxSize( 350, 280 ),
109  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
110 {
111  m_Parent = parent;
112 
113  PolyEdges.clear();
114 
115  wxBoxSizer* MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
116  SetSizer( MainBoxSizer );
117  wxBoxSizer* LeftBoxSizer = new wxBoxSizer( wxVERTICAL );
118  wxBoxSizer* RightBoxSizer = new wxBoxSizer( wxVERTICAL );
119  MainBoxSizer->Add( LeftBoxSizer, 0, wxGROW | wxALL, 5 );
120  MainBoxSizer->Add( RightBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
121 
122  wxButton* Button = new wxButton( this, wxID_OK, _( "OK" ) );
123  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
124 
125  Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ) );
126  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
127 
128  Button = new wxButton( this, ID_READ_SHAPE_FILE,
129  _( "Read Shape Description File..." ) );
130  RightBoxSizer->Add( Button, 0, wxGROW | wxALL, 5 );
131 
132  wxString shapelist[] = { _( "Normal" ), _( "Symmetrical" ), _( "Mirrored" ) };
133 
134  m_ShapeOptionCtrl = new wxRadioBox( this, -1, _( "Shape Option" ),
135  wxDefaultPosition, wxDefaultSize, 3,
136  shapelist, 1,
137  wxRA_SPECIFY_COLS );
138  LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
139 
140  m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, parent->GetUserUnits(),
141  LeftBoxSizer );
142 
143  GetSizer()->SetSizeHints( this );
144 }
Object to edit/enter a size (pair of values for X and Y size ( INCHES or MM ) in dialog boxes.
#define _(s)
Definition: 3d_actions.cpp:33
static std::vector< wxRealPoint > PolyEdges
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static wxSize ShapeSize

References _, ID_READ_SHAPE_FILE, PolyEdges, and ShapeSize.

◆ ~MWAVE_POLYGONAL_SHAPE_DLG()

MWAVE_POLYGONAL_SHAPE_DLG::~MWAVE_POLYGONAL_SHAPE_DLG ( )
inline

Definition at line 71 of file microwave_polygon.cpp.

71 { };

Member Function Documentation

◆ OnCancelClick()

void MWAVE_POLYGONAL_SHAPE_DLG::OnCancelClick ( wxCommandEvent &  event)
private

Definition at line 147 of file microwave_polygon.cpp.

148 {
149  PolyEdges.clear();
150  EndModal( wxID_CANCEL );
151 }
static std::vector< wxRealPoint > PolyEdges

References PolyEdges.

◆ OnOkClick()

void MWAVE_POLYGONAL_SHAPE_DLG::OnOkClick ( wxCommandEvent &  event)
private

Definition at line 154 of file microwave_polygon.cpp.

155 {
157  PolyShapeType = m_ShapeOptionCtrl->GetSelection();
158  EndModal( wxID_OK );
159 }
wxSize GetValue() const
static int PolyShapeType
static wxSize ShapeSize

References EDA_SIZE_CTRL::GetValue(), m_ShapeOptionCtrl, m_SizeCtrl, PolyShapeType, and ShapeSize.

◆ ReadDataShapeDescr()

void MWAVE_POLYGONAL_SHAPE_DLG::ReadDataShapeDescr ( wxCommandEvent &  event)
private

Function ReadDataShapeDescr read a description shape file File format is Unit=MM XScale=271.501 YScale=1.00133.

$COORD 0 0.6112600148417837 0.001851851851851852 0.6104800531118608 .... $ENDCOORD

Each line is the X Y coord (normalized units from 0 to 1)

Definition at line 162 of file microwave_polygon.cpp.

163 {
164  static wxString lastpath; // To remember the last open path during a session
165  wxString fullFileName;
166  wxString mask = wxFileSelectorDefaultWildcardStr;
167 
168  fullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ), lastpath,
169  fullFileName, wxEmptyString, mask, this,
170  wxFD_OPEN, true );
171 
172  if( fullFileName.IsEmpty() )
173  return;
174 
175  wxFileName fn( fullFileName );
176  lastpath = fn.GetPath();
177  PolyEdges.clear();
178 
179  FILE* File = wxFopen( fullFileName, wxT( "rt" ) );
180 
181  if( File == NULL )
182  {
183  DisplayError( this, _( "File not found" ) );
184  return;
185  }
186 
187  double unitconv = IU_PER_MM;
188  ShapeScaleX = ShapeScaleY = 1.0;
189 
190  FILE_LINE_READER fileReader( File, fullFileName );
191  FILTER_READER reader( fileReader );
192 
193  LOCALE_IO toggle;
194 
195  while( reader.ReadLine() )
196  {
197  char* Line = reader.Line();
198  char* param1 = strtok( Line, " =\n\r" );
199  char* param2 = strtok( NULL, " \t\n\r" );
200 
201  if( strncasecmp( param1, "Unit", 4 ) == 0 )
202  {
203  if( strncasecmp( param2, "inch", 4 ) == 0 )
204  unitconv = IU_PER_MILS*1000;
205 
206  if( strncasecmp( param2, "mm", 2 ) == 0 )
207  unitconv = IU_PER_MM;
208  }
209 
210  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
211  break;
212 
213  if( strncasecmp( param1, "$COORD", 6 ) == 0 )
214  {
215  while( reader.ReadLine() )
216  {
217  Line = reader.Line();
218  param1 = strtok( Line, " \t\n\r" );
219  param2 = strtok( NULL, " \t\n\r" );
220 
221  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
222  break;
223 
224  wxRealPoint coord( atof( param1 ), atof( param2 ) );
225  PolyEdges.push_back( coord );
226  }
227  }
228 
229  if( strncasecmp( Line, "XScale", 6 ) == 0 )
230  ShapeScaleX = atof( param2 );
231 
232  if( strncasecmp( Line, "YScale", 6 ) == 0 )
233  ShapeScaleY = atof( param2 );
234  }
235 
236  ShapeScaleX *= unitconv;
237  ShapeScaleY *= unitconv;
238 
239  m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
240 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:252
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:40
static constexpr double IU_PER_MM
Mock up a conversion function.
A LINE_READER that reads from an open file.
Definition: richio.h:172
#define NULL
wxString EDA_FILE_SELECTOR(const wxString &aTitle, const wxString &aPath, const wxString &aFileName, const wxString &aExtension, const wxString &aWildcard, wxWindow *aParent, int aStyle, const bool aKeepWorkingDirectory, const wxPoint &aPosition, wxString *aMruPath)
A helper function that wraps a call to wxFileSelector.
Definition: gestfich.cpp:52
static double ShapeScaleY
#define _(s)
Definition: 3d_actions.cpp:33
static std::vector< wxRealPoint > PolyEdges
#define IU_PER_MILS
Definition: plotter.cpp:137
Read lines of text from another LINE_READER but only returns non-comment lines and non-blank lines fr...
Definition: filter_reader.h:36
void SetValue(int x_value, int y_value)
static double ShapeScaleX

References _, DisplayError(), EDA_FILE_SELECTOR(), IU_PER_MILS, IU_PER_MM, LINE_READER::Line(), m_SizeCtrl, NULL, PolyEdges, FILTER_READER::ReadLine(), EDA_POSITION_CTRL::SetValue(), ShapeScaleX, and ShapeScaleY.

Member Data Documentation

◆ m_Parent

PCB_EDIT_FRAME* MWAVE_POLYGONAL_SHAPE_DLG::m_Parent
private

Definition at line 65 of file microwave_polygon.cpp.

◆ m_ShapeOptionCtrl

wxRadioBox* MWAVE_POLYGONAL_SHAPE_DLG::m_ShapeOptionCtrl
private

Definition at line 66 of file microwave_polygon.cpp.

Referenced by OnOkClick().

◆ m_SizeCtrl

EDA_SIZE_CTRL* MWAVE_POLYGONAL_SHAPE_DLG::m_SizeCtrl
private

Definition at line 67 of file microwave_polygon.cpp.

Referenced by OnOkClick(), and ReadDataShapeDescr().


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