43#include <wx/filedlg.h>
44#include <wx/radiobox.h>
46#include <wx/statbox.h>
109 const wxPoint& framepos ) :
110 DIALOG_SHIM( parent, -1,
_( "Complex Shape" ), framepos, wxDefaultSize,
111 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
119 wxBoxSizer* mainBoxSizer =
new wxBoxSizer( wxVERTICAL );
120 SetSizer( mainBoxSizer );
124 wxBoxSizer* topBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
125 mainBoxSizer->Add( topBoxSizer, 1, wxGROW | wxALL, 5 );
127 wxString shapelist[] = {
_(
"Normal" ),
_(
"Symmetrical" ),
_(
"Mirrored" ) };
130 wxDefaultPosition, wxDefaultSize, 3,
135 auto sizeSizer =
new wxStaticBoxSizer(
new wxStaticBox(
this, wxID_ANY,
_(
"Size" ) ),
137 wxBoxSizer* xSizer =
new wxBoxSizer( wxHORIZONTAL );
138 wxBoxSizer* ySizer =
new wxBoxSizer( wxHORIZONTAL );
140 topBoxSizer->Add( sizeSizer, 1, wxGROW | wxALL, 5 );
141 sizeSizer->Add( xSizer, 0, 0, 5 );
142 sizeSizer->Add( ySizer, 0, 0, 5 );
144 wxStaticText* xLabel =
new wxStaticText(
this, -1,
_(
"X:" ) );
145 wxTextCtrl* xCtrl =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString );
146 wxStaticText* xUnits =
new wxStaticText(
this, -1,
_(
"units" ) );
148 xSizer->Add( xLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
149 xSizer->Add( xCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 );
150 xSizer->Add( xUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
153 wxStaticText* yLabel =
new wxStaticText(
this, -1,
_(
"Y:" ) );
154 wxTextCtrl* yCtrl =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString );
155 wxStaticText* yUnits =
new wxStaticText(
this, -1,
_(
"units" ) );
157 ySizer->Add( yLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
158 ySizer->Add( yCtrl, 1, wxALIGN_CENTER_VERTICAL, 5 );
159 ySizer->Add( yUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
164 wxBoxSizer* buttonsBoxSizer =
new wxBoxSizer( wxHORIZONTAL );
165 mainBoxSizer->Add( buttonsBoxSizer, 0, wxALL, 5 );
167 wxButton* btn =
new wxButton(
this,
ID_READ_SHAPE_FILE,
_(
"Read Shape Description File..." ) );
168 buttonsBoxSizer->Add( btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 10 );
169 buttonsBoxSizer->AddStretchSpacer();
171 wxStdDialogButtonSizer* sdbSizer =
new wxStdDialogButtonSizer();
172 buttonsBoxSizer->Add( sdbSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
173 wxButton* sdbSizerOK =
new wxButton(
this, wxID_OK );
174 sdbSizer->AddButton( sdbSizerOK );
175 wxButton* sdbSizerCancel =
new wxButton(
this, wxID_CANCEL );
176 sdbSizer->AddButton( sdbSizerCancel );
179 GetSizer()->SetSizeHints(
this );
192 if( !wxDialog::TransferDataFromWindow() )
205 static wxString s_lastpath;
206 wxString fullFileName;
207 wxString mask = wxFileSelectorDefaultWildcardStr;
209 fullFileName = wxFileSelector(
_(
"Shape Description File" ), s_lastpath,
210 fullFileName, wxEmptyString, mask, wxFD_OPEN,
this );
212 if( fullFileName.IsEmpty() )
215 wxFileName fn( fullFileName );
216 s_lastpath = fn.GetPath();
219 FILE* File = wxFopen( fullFileName, wxT(
"rt" ) );
221 if( File ==
nullptr )
237 char* Line = reader.
Line();
238 char* param1 = strtok( Line,
" =\n\r" );
239 char* param2 = strtok(
nullptr,
" \t\n\r" );
241 if( strncasecmp( param1,
"Unit", 4 ) == 0 )
243 if( strncasecmp( param2,
"inch", 4 ) == 0 )
246 if( strncasecmp( param2,
"mm", 2 ) == 0 )
250 if( strncasecmp( param1,
"$ENDCOORD", 8 ) == 0 )
253 if( strncasecmp( param1,
"$COORD", 6 ) == 0 )
257 Line = reader.
Line();
258 param1 = strtok( Line,
" \t\n\r" );
259 param2 = strtok(
nullptr,
" \t\n\r" );
261 if( strncasecmp( param1,
"$ENDCOORD", 8 ) == 0 )
264 wxRealPoint coord( atof( param1 ), atof( param2 ) );
269 if( strncasecmp( Line,
"XScale", 6 ) == 0 )
272 if( strncasecmp( Line,
"YScale", 6 ) == 0 )
297 int ret = dlg.ShowModal();
323 cmp_name = wxT(
"muwave_polygon" );
326 footprint = createBaseFootprint( cmp_name, 0, pad_count );
332 auto it = footprint->
Pads().begin();
335 pad1->
SetX( offset.
x );
341 shape =
new PCB_SHAPE( footprint, SHAPE_T::POLY );
345 footprint->
Add( shape, ADD_MODE::INSERT );
348 std::vector<VECTOR2I> polyPoints;
352 polyPoints.emplace_back(
VECTOR2I( offset.
x, 0 ) );
360 last_coordinate += offset;
361 polyPoints.push_back( last_coordinate );
365 if( last_coordinate.
y != 0 )
366 polyPoints.emplace_back(
VECTOR2I( last_coordinate.
x, 0 ) );
375 for(
int ndx = (
int) polyPoints.size() - 1; ndx >= 0; --ndx )
379 polyPoints.push_back( pt );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
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()
bool TransferDataFromWindow() override
void ReadDataShapeDescr(wxCommandEvent &event)
Read a description shape file.
The main frame for Pcbnew.
void OnModify() override
Must be called after a board change to set the modified flag.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
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
VECTOR2< int32_t > VECTOR2I