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 }
#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 }
static int PolyShapeType
wxSize GetValue()
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 mask = wxFileSelectorDefaultWildcardStr;
166 
167  wxString FullFileName = EDA_FILE_SELECTOR( _( "Read descr shape file" ), lastpath,
168  FullFileName, wxEmptyString, mask, this,
169  wxFD_OPEN, true );
170  if( FullFileName.IsEmpty() )
171  return;
172 
173  wxFileName fn( FullFileName );
174  lastpath = fn.GetPath();
175  PolyEdges.clear();
176 
177  FILE* File = wxFopen( FullFileName, wxT( "rt" ) );
178 
179  if( File == NULL )
180  {
181  DisplayError( this, _( "File not found" ) );
182  return;
183  }
184 
185  double unitconv = IU_PER_MM;
186  ShapeScaleX = ShapeScaleY = 1.0;
187 
188  FILE_LINE_READER fileReader( File, FullFileName );
189  FILTER_READER reader( fileReader );
190 
191  LOCALE_IO toggle;
192 
193  while( reader.ReadLine() )
194  {
195  char* Line = reader.Line();
196  char* param1 = strtok( Line, " =\n\r" );
197  char* param2 = strtok( NULL, " \t\n\r" );
198 
199  if( strncasecmp( param1, "Unit", 4 ) == 0 )
200  {
201  if( strncasecmp( param2, "inch", 4 ) == 0 )
202  unitconv = IU_PER_MILS*1000;
203 
204  if( strncasecmp( param2, "mm", 2 ) == 0 )
205  unitconv = IU_PER_MM;
206  }
207 
208  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
209  break;
210 
211  if( strncasecmp( param1, "$COORD", 6 ) == 0 )
212  {
213  while( reader.ReadLine() )
214  {
215  Line = reader.Line();
216  param1 = strtok( Line, " \t\n\r" );
217  param2 = strtok( NULL, " \t\n\r" );
218 
219  if( strncasecmp( param1, "$ENDCOORD", 8 ) == 0 )
220  break;
221 
222  wxRealPoint coord( atof( param1 ), atof( param2 ) );
223  PolyEdges.push_back( coord );
224  }
225  }
226 
227  if( strncasecmp( Line, "XScale", 6 ) == 0 )
228  ShapeScaleX = atof( param2 );
229 
230  if( strncasecmp( Line, "YScale", 6 ) == 0 )
231  ShapeScaleY = atof( param2 );
232  }
233 
234  ShapeScaleX *= unitconv;
235  ShapeScaleY *= unitconv;
236 
237  m_SizeCtrl->SetValue( (int) ShapeScaleX, (int) ShapeScaleY );
238 }
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: common.h:216
static constexpr double IU_PER_MM
Mock up a conversion function.
FILE_LINE_READER is a LINE_READER that reads from an open file.
Definition: richio.h:180
#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)
Function EDA_FILE_SELECTOR.
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:138
FILTER_READER reads lines of text from another LINE_READER, but only returns non-comment lines and no...
Definition: filter_reader.h:37
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: