51 static void gen_arc( std::vector <wxPoint>& aBuffer,
52 const wxPoint& aStartPoint,
53 const wxPoint& aCenter,
56 auto first_point = aStartPoint - aCenter;
60 double increment_angle = (double) a_ArcAngle * M_PI / 1800 / seg_count;
63 for(
int ii = 1; ii <= seg_count; ii++ )
65 double rot_angle = increment_angle * ii;
66 double fcos = cos( rot_angle );
67 double fsin = sin( rot_angle );
71 currpt.x =
KiROUND( ( first_point.x * fcos + first_point.y * fsin ) );
72 currpt.y =
KiROUND( ( first_point.y * fcos - first_point.x * fsin ) );
74 auto corner = aCenter + currpt;
75 aBuffer.push_back( corner );
99 const wxPoint& aStartPoint,
const wxPoint& aEndPoint,
int aLength,
int aWidth )
140 #define ADJUST_SIZE 0.988 142 auto pt = aEndPoint - aStartPoint;
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 );
232 gen_arc( aBuffer, pt, centre, -900 );
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++ )
257 arc_angle = 1800 *
sign;
260 gen_arc( aBuffer, pt, centre, arc_angle );
262 pt.x += segm_len *
sign;
263 aBuffer.push_back( pt );
270 aBuffer.back().x = aStartPoint.x + radius *
sign;
281 for(
unsigned jj = 0; jj < aBuffer.size(); jj++ )
287 aBuffer.push_back( aEndPoint );
301 pattern.
m_Start = { aStart.
x, aStart.
y };
302 pattern.
m_End = { aEnd.
x, aEnd.
y };
304 wxString errorMessage;
309 if ( !inductorFP || !errorMessage.IsEmpty() )
311 if ( !errorMessage.IsEmpty() )
320 commit.
Add( inductorFP.release() );
321 commit.
Push(
_(
"Add microwave inductor" ) );
327 wxString& aErrorMessage )
367 auto pt = aInductorPattern.
m_End - aInductorPattern.
m_Start;
369 aInductorPattern.
m_Length = min_len;
375 if( dlg.ShowQuasiModal() != wxID_OK )
378 msg = dlg.GetValue();
382 if( aInductorPattern.
m_Length < min_len )
384 aErrorMessage =
_(
"Requested length < minimum length" );
389 std::vector <wxPoint> buffer;
391 aInductorPattern.
m_End,
398 aErrorMessage =
_(
"Requested length too large" );
401 aErrorMessage =
_(
"Requested length too small" );
404 aErrorMessage =
_(
"Requested length can't be represented" );
426 for(
unsigned jj = 1; jj < buffer.size(); jj++ )
431 seg->
SetEnd( buffer[jj] );
455 PAD* newpad =
new PAD( *pad );
466 wxPoint refPos( ( aInductorPattern.
m_Start.x + aInductorPattern.
m_End.x ) / 2,
467 ( aInductorPattern.
m_Start.y + aInductorPattern.
m_End.y ) / 2 );
469 wxPoint valPos = refPos;
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
void SetEnd0(const wxPoint &aPoint)
virtual void SetPosition(const wxPoint &aPos) override
int GetCurrentTrackWidth() const
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
A KICAD version of wxTextEntryDialog which supports the various improvments/work-arounds from DIALOG_...
void SetTextValidator(wxTextValidatorStyle style)
Smd pad, appears on the solder paste layer (default)
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
usual segment : line with rounded ends
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void SetSize(const wxSize &aSize)
void RotatePoint(int *pX, int *pY, double angle)
A logical library item identifier and consists of various portions much like a URI.
static INDUCTOR_S_SHAPE_RESULT BuildCornersList_S_Shape(std::vector< wxPoint > &aBuffer, const wxPoint &aStartPoint, const wxPoint &aEndPoint, int aLength, int aWidth)
Function BuildCornersList_S_Shape Create a path like a S-shaped coil.
LSET is a set of PCB_LAYER_IDs.
void SetPos0(const wxPoint &aPos)
void SetShape(PCB_SHAPE_TYPE_T aShape)
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
const wxSize & GetTextSize() const
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
static void gen_arc(std::vector< wxPoint > &aBuffer, const wxPoint &aStartPoint, const wxPoint &aCenter, int a_ArcAngle)
Function gen_arc generates an arc using arc approximation by lines: Center aCenter Angle "angle" (in ...
a few functions useful in geometry calculations.
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
void SetStart0(const wxPoint &aPoint)
FOOTPRINT * CreateNewFootprint(const wxString &aFootprintName)
Creates a new footprint, at position 0,0.
void SetLayerSet(LSET aLayers) override
wxPoint GetPosition() const override
void SetStart(const wxPoint &aStart)
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void SetPosition(const wxPoint &aPos) override
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
The main frame for Pcbnew.
void SetWidth(int aWidth)
Requested length too short.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
double ArcTangente(int dy, int dx)
Requested length too long.
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
Custom text control validator definitions.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
void SetEnd(const wxPoint &aEnd)
Parameters for construction of a microwave inductor.
void SetAttribute(PAD_ATTR_T aAttribute)