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 int aLength,
int aWidth )
139 #define ADJUST_SIZE 0.988
141 auto pt = aEndPoint - aStartPoint;
143 int min_len = pt.EuclideanNorm();
158 size.x = min_len / 2;
162 int radius = std::min( aWidth * 5, size.x / 4 );
168 for( segm_count = 0; ; segm_count++ )
170 stubs_len = ( size.y - (
radius * 2 * (segm_count + 2 ) ) ) / 2;
172 if( stubs_len < size.y / 10 )
174 stubs_len = size.y / 10;
175 radius = ( size.y - (2 * stubs_len) ) / ( 2 * (segm_count + 2) );
184 segm_len = size.x - (
radius * 2 );
185 full_len = 2 * stubs_len;
186 full_len += segm_len * segm_count;
188 full_len += segm_len - (2 *
radius);
191 if( full_len >= aLength )
196 int delta_size = full_len - aLength;
199 segm_len -= delta_size / (segm_count + 1);
207 if( min_total_length > aLength )
214 if( segm_len - 2 *
radius < 0 )
227 aBuffer.push_back( pt );
229 aBuffer.push_back( pt );
236 int half_size_seg_len = segm_len / 2 -
radius;
238 if( half_size_seg_len )
240 pt.x -= half_size_seg_len;
241 aBuffer.push_back( pt );
249 for( ii = 0; ii < segm_count; ii++ )
260 pt.x += segm_len *
sign;
261 aBuffer.push_back( pt );
279 for(
unsigned jj = 0; jj < aBuffer.size(); jj++ )
283 aBuffer.push_back( aEndPoint );
297 pattern.
m_Start = { aStart.
x, aStart.
y };
298 pattern.
m_End = { aEnd.
x, aEnd.
y };
300 wxString errorMessage;
305 if ( !inductorFP || !errorMessage.IsEmpty() )
307 if ( !errorMessage.IsEmpty() )
316 commit.Add( inductorFP.release() );
317 commit.Push(
_(
"Add Microwave Inductor" ) );
323 wxString& aErrorMessage )
363 aInductorPattern.
m_Length = min_len;
376 if( aInductorPattern.
m_Length < min_len )
378 aErrorMessage =
_(
"Requested length < minimum length" );
383 std::vector<VECTOR2I> buffer;
385 aInductorPattern.
m_End,
391 case INDUCTOR_S_SHAPE_RESULT::TOO_LONG:
392 aErrorMessage =
_(
"Requested length too large" );
394 case INDUCTOR_S_SHAPE_RESULT::TOO_SHORT:
395 aErrorMessage =
_(
"Requested length too small" );
397 case INDUCTOR_S_SHAPE_RESULT::NO_REPR:
398 aErrorMessage =
_(
"Requested length can't be represented" );
400 case INDUCTOR_S_SHAPE_RESULT::OK:
406 WX_TEXT_ENTRY_DIALOG cmpdlg( editFrame,
_(
"Component value:" ),
_(
"Create Microwave Footprint" ), msg );
421 for(
unsigned jj = 1; jj < buffer.size(); jj++ )
425 seg->
SetEnd( buffer[jj] );
436 pad->SetNumber( wxT(
"1" ) );
437 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)
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
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
FOOTPRINT * CreateNewFootprint(wxString aFootprintName, const wxString &aLibName)
Create 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(const wxTextValidator &validator)
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