57 double increment_angle = a_ArcAngle.
AsRadians() / seg_count;
60 for(
int ii = 1; ii <= seg_count; ii++ )
62 double rot_angle = increment_angle * ii;
63 double fcos = cos( rot_angle );
64 double fsin = sin( rot_angle );
68 currpt.
x =
KiROUND( ( first_point.
x * fcos + first_point.
y * fsin ) );
69 currpt.
y =
KiROUND( ( first_point.
y * fcos - first_point.
x * fsin ) );
71 auto corner = aCenter + currpt;
72 aBuffer.push_back( corner );
97 const VECTOR2I& aEndPoint,
int aLength,
139 #define ADJUST_SIZE 0.988
141 auto pt = aEndPoint - aStartPoint;
143 int min_len = pt.EuclideanNorm();
157 size.x = min_len / 2;
161 int radius = std::min( aWidth * 5, size.x / 4 );
167 for( segm_count = 0; ; segm_count++ )
169 stubs_len = ( size.y - ( radius * 2 * (segm_count + 2 ) ) ) / 2;
171 if( stubs_len < size.y / 10 )
173 stubs_len = size.y / 10;
174 radius = ( size.y - (2 * stubs_len) ) / ( 2 * (segm_count + 2) );
176 if( radius < aWidth )
183 segm_len = size.x - ( radius * 2 );
184 full_len = 2 * stubs_len;
185 full_len += segm_len * segm_count;
187 full_len += segm_len - (2 * radius);
190 if( full_len >= aLength )
195 int delta_size = full_len - aLength;
198 segm_len -= delta_size / (segm_count + 1);
205 const int min_total_length = 2 * stubs_len + 2 * M_PI *
ADJUST_SIZE * radius;
206 if( min_total_length > aLength )
213 if( segm_len - 2 * radius < 0 )
226 aBuffer.push_back( pt );
228 aBuffer.push_back( pt );
235 int half_size_seg_len = segm_len / 2 - radius;
237 if( half_size_seg_len )
239 pt.x -= half_size_seg_len;
240 aBuffer.push_back( pt );
248 for( ii = 0; ii < segm_count; ii++ )
259 pt.x += segm_len *
sign;
260 aBuffer.push_back( pt );
267 aBuffer.back().x = aStartPoint.
x + radius *
sign;
278 for(
unsigned jj = 0; jj < aBuffer.size(); jj++ )
282 aBuffer.push_back( aEndPoint );
296 pattern.
m_Start = { aStart.
x, aStart.
y };
297 pattern.
m_End = { aEnd.
x, aEnd.
y };
299 wxString errorMessage;
304 if ( !inductorFP || !errorMessage.IsEmpty() )
306 if ( !errorMessage.IsEmpty() )
315 commit.Add( inductorFP.release() );
316 commit.Push(
_(
"Add Microwave Inductor" ) );
322 wxString& aErrorMessage )
362 aInductorPattern.
m_Length = min_len;
375 if( aInductorPattern.
m_Length < min_len )
377 aErrorMessage =
_(
"Requested length < minimum length" );
382 std::vector<VECTOR2I> buffer;
384 aInductorPattern.
m_End,
390 case INDUCTOR_S_SHAPE_RESULT::TOO_LONG:
391 aErrorMessage =
_(
"Requested length too large" );
393 case INDUCTOR_S_SHAPE_RESULT::TOO_SHORT:
394 aErrorMessage =
_(
"Requested length too small" );
396 case INDUCTOR_S_SHAPE_RESULT::NO_REPR:
397 aErrorMessage =
_(
"Requested length can't be represented" );
399 case INDUCTOR_S_SHAPE_RESULT::OK:
420 for(
unsigned jj = 1; jj < buffer.size(); jj++ )
424 seg->
SetEnd( buffer[jj] );
435 pad->SetNumber( wxT(
"1" ) );
436 pad->SetPosition( aInductorPattern.
m_End );
442 pad->SetAttribute( PAD_ATTRIB::SMD );
451 pad->SetNumber( wxT(
"2" ) );
constexpr int ARC_HIGH_DEF
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
int GetCurrentTrackWidth() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
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...
A base class for most all the KiCad significant classes used in schematics and boards.
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
void SetStart(const VECTOR2I &aStart)
void SetEnd(const VECTOR2I &aEnd)
VECTOR2I GetTextSize() const
A logical library item identifier and consists of various portions much like a URI.
LSET is a set of PCB_LAYER_IDs.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
FOOTPRINT * CreateNewFootprint(wxString aFootprintName, const wxString &aLibName)
Creates a new footprint, at position 0,0.
The main frame for Pcbnew.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStroke(const STROKE_PARAMS &aStroke) override
virtual void SetPosition(const VECTOR2I &aPos) override
Simple container to manage line stroke parameters.
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
int ValueFromString(const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aTextValue in aUnits to internal units used by the frame.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
void SetTextValidator(wxTextValidatorStyle style)
This file is part of the common library.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
static INDUCTOR_S_SHAPE_RESULT BuildCornersList_S_Shape(std::vector< VECTOR2I > &aBuffer, const VECTOR2I &aStartPoint, const VECTOR2I &aEndPoint, int aLength, int aWidth)
Function BuildCornersList_S_Shape Create a path like a S-shaped coil.
static void gen_arc(std::vector< VECTOR2I > &aBuffer, const VECTOR2I &aStartPoint, const VECTOR2I &aCenter, const EDA_ANGLE &a_ArcAngle)
Function gen_arc generates an arc using arc approximation by lines: Center aCenter Angle "angle" (in ...
@ TOO_SHORT
Requested length too long.
@ TOO_LONG
S-shape constructed.
@ NO_REPR
Requested length too short.
Parameters for construction of a microwave inductor.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
constexpr int sign(T val)
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D