44#include <wx/filedlg.h>
45#include <wx/radiobox.h>
47#include <wx/statbox.h>
110 const wxPoint& framepos ) :
111 DIALOG_SHIM( parent, -1,
_( "Complex Shape" ), framepos, wxDefaultSize,
112 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
120 wxBoxSizer* mainBoxSizer =
new wxBoxSizer( wxVERTICAL );
121 SetSizer( mainBoxSizer );
125 wxBoxSizer* topBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
126 mainBoxSizer->Add( topBoxSizer, 1, wxGROW | wxALL, 5 );
128 wxString shapelist[] = {
_(
"Normal" ),
_(
"Symmetrical" ),
_(
"Mirrored" ) };
131 wxDefaultPosition, wxDefaultSize, 3,
136 auto sizeSizer =
new wxStaticBoxSizer(
new wxStaticBox(
this, wxID_ANY,
_(
"Size" ) ),
138 wxBoxSizer* xSizer =
new wxBoxSizer( wxHORIZONTAL );
139 wxBoxSizer* ySizer =
new wxBoxSizer( wxHORIZONTAL );
141 topBoxSizer->Add( sizeSizer, 1, wxGROW | wxALL, 5 );
142 sizeSizer->Add( xSizer, 0, 0, 5 );
143 sizeSizer->Add( ySizer, 0, 0, 5 );
145 wxStaticText* xLabel =
new wxStaticText(
this, -1,
_(
"X:" ) );
146 wxTextCtrl* xCtrl =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString );
147 wxStaticText* xUnits =
new wxStaticText(
this, -1,
_(
"units" ) );
149 xSizer->Add( xLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
150 xSizer->Add( xCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 );
151 xSizer->Add( xUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
154 wxStaticText* yLabel =
new wxStaticText(
this, -1,
_(
"Y:" ) );
155 wxTextCtrl* yCtrl =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString );
156 wxStaticText* yUnits =
new wxStaticText(
this, -1,
_(
"units" ) );
158 ySizer->Add( yLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
159 ySizer->Add( yCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 );
160 ySizer->Add( yUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
165 wxBoxSizer* buttonsBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
166 mainBoxSizer->Add( buttonsBoxSizer, 0, wxALL, 5 );
168 wxButton* btn =
new wxButton(
this,
ID_READ_SHAPE_FILE,
_(
"Read Shape Description File..." ) );
169 buttonsBoxSizer->Add( btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 10 );
170 buttonsBoxSizer->AddStretchSpacer();
172 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
173 buttonsBoxSizer->Add( sdbSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
174 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
175 sdbSizer->AddButton( sdbSizerOK );
176 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
177 sdbSizer->AddButton( sdbSizerCancel );
180 GetSizer()->SetSizeHints(
this );
193 if( !wxDialog::TransferDataFromWindow() )
206 static wxString s_lastpath;
207 wxString fullFileName;
208 wxString mask = wxFileSelectorDefaultWildcardStr;
210 fullFileName = wxFileSelector(
_(
"Shape Description File" ), s_lastpath,
211 fullFileName, wxEmptyString, mask, wxFD_OPEN,
this );
213 if( fullFileName.IsEmpty() )
216 wxFileName fn( fullFileName );
217 s_lastpath = fn.GetPath();
220 FILE* File = wxFopen( fullFileName, wxT(
"rt" ) );
222 if( File ==
nullptr )
238 char* Line = reader.
Line();
239 char* param1 = strtok( Line,
" =\n\r" );
240 char* param2 = strtok(
nullptr,
" \t\n\r" );
242 if( strncasecmp( param1,
"Unit", 4 ) == 0 )
244 if( strncasecmp( param2,
"inch", 4 ) == 0 )
247 if( strncasecmp( param2,
"mm", 2 ) == 0 )
251 if( strncasecmp( param1,
"$ENDCOORD", 8 ) == 0 )
254 if( strncasecmp( param1,
"$COORD", 6 ) == 0 )
258 Line = reader.
Line();
259 param1 = strtok( Line,
" \t\n\r" );
260 param2 = strtok(
nullptr,
" \t\n\r" );
262 if( strncasecmp( param1,
"$ENDCOORD", 8 ) == 0 )
265 wxRealPoint coord( atof( param1 ), atof( param2 ) );
270 if( strncasecmp( Line,
"XScale", 6 ) == 0 )
273 if( strncasecmp( Line,
"YScale", 6 ) == 0 )
298 int ret = dlg.ShowModal();
324 cmp_name = wxT(
"muwave_polygon" );
327 footprint = createBaseFootprint( cmp_name, 0, pad_count );
333 auto it = footprint->
Pads().begin();
351 std::vector<VECTOR2I> polyPoints;
355 polyPoints.emplace_back(
VECTOR2I( offset.
x, 0 ) );
363 last_coordinate += offset;
364 polyPoints.push_back( last_coordinate );
368 if( last_coordinate.
y != 0 )
369 polyPoints.emplace_back(
VECTOR2I( last_coordinate.
x, 0 ) );
378 for(
int ndx = (
int) polyPoints.size() - 1; ndx >= 0; --ndx )
382 polyPoints.push_back( pt );
constexpr EDA_IU_SCALE pcbIUScale
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void SetFilled(bool aFlag)
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
A LINE_READER that reads from an open file.
Read lines of text from another LINE_READER but only returns non-comment lines and non-blank lines fr...
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
char * Line() const
Return a pointer to the last line that was read in.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
wxRadioBox * m_shapeOptionCtrl
void OnCancelClick(wxCommandEvent &event)
~MWAVE_POLYGONAL_SHAPE_DLG()
MWAVE_POLYGONAL_SHAPE_DLG(PCB_EDIT_FRAME *parent, const wxPoint &pos)
bool TransferDataFromWindow() override
void ReadDataShapeDescr(wxCommandEvent &event)
Read a description shape file.
const VECTOR2I & GetPos0() const
The main frame for Pcbnew.
void OnModify() override
Must be called after a board change to set the modified flag.
void SetStroke(const STROKE_PARAMS &aStroke) override
Simple container to manage line stroke parameters.
virtual long long int GetValue()
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
static double g_ShapeScaleX
static double g_ShapeScaleY
static std::vector< wxRealPoint > g_PolyEdges
static int g_PolyShapeType
static wxSize g_ShapeSize
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".