Tear down the wxPoint trigo helpers
This commit is contained in:
parent
e4dbfcd92d
commit
726d873c53
|
@ -222,10 +222,10 @@ void FONT::getLinePositions( const UTF8& aText, const VECTOR2D& aPosition,
|
|||
case GR_TEXT_H_ALIGN_RIGHT: lineOffset.x = mirrorX * -lineSize.x; break;
|
||||
}
|
||||
|
||||
wxPoint pos( aPosition.x + lineOffset.x, aPosition.y + lineOffset.y );
|
||||
RotatePoint( &pos, origin, aAttrs.m_Angle );
|
||||
VECTOR2I pos( aPosition.x + lineOffset.x, aPosition.y + lineOffset.y );
|
||||
RotatePoint( pos, origin, aAttrs.m_Angle );
|
||||
|
||||
aPositions.push_back( pos );
|
||||
aPositions.push_back( (wxPoint) pos );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,9 +253,9 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int w
|
|||
int dx = x2 - x1;
|
||||
int dy = y2 - y1;
|
||||
double angle = -ArcTangente( dy, dx );
|
||||
wxPoint start;
|
||||
wxPoint end;
|
||||
wxPoint org( x1, y1 );
|
||||
VECTOR2I start;
|
||||
VECTOR2I end;
|
||||
VECTOR2I org( x1, y1 );
|
||||
int len = (int) hypot( dx, dy );
|
||||
|
||||
// We know if the DC is mirrored, to draw arcs
|
||||
|
@ -268,37 +268,37 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int w
|
|||
start.y = radius;
|
||||
end.x = len;
|
||||
end.y = radius;
|
||||
RotatePoint( &start, angle );
|
||||
RotatePoint( &end, angle );
|
||||
RotatePoint( start, angle );
|
||||
RotatePoint( end, angle );
|
||||
|
||||
start += org;
|
||||
end += org;
|
||||
|
||||
DC->DrawLine( start, end );
|
||||
DC->DrawLine( (wxPoint) start, (wxPoint) end );
|
||||
|
||||
// first rounded end
|
||||
end.x = 0;
|
||||
end.y = -radius;
|
||||
RotatePoint( &end, angle );
|
||||
RotatePoint( end, angle );
|
||||
end += org;
|
||||
|
||||
if( !mirrored )
|
||||
DC->DrawArc( end, start, org );
|
||||
DC->DrawArc( (wxPoint) end, (wxPoint) start, (wxPoint) org );
|
||||
else
|
||||
DC->DrawArc( start, end, org );
|
||||
DC->DrawArc( (wxPoint) start, (wxPoint) end, (wxPoint) org );
|
||||
|
||||
// second edge
|
||||
start.x = len;
|
||||
start.y = -radius;
|
||||
RotatePoint( &start, angle );
|
||||
RotatePoint( start, angle );
|
||||
start += org;
|
||||
|
||||
DC->DrawLine( start, end );
|
||||
DC->DrawLine( (wxPoint) start, (wxPoint) end );
|
||||
|
||||
// second rounded end
|
||||
end.x = len;
|
||||
end.y = radius;
|
||||
RotatePoint( &end, angle);
|
||||
RotatePoint( end, angle);
|
||||
end += org;
|
||||
|
||||
if( !mirrored )
|
||||
|
|
|
@ -2619,8 +2619,8 @@ void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextIte
|
|||
if( !aKiCadTextItem->GetText().IsEmpty() )
|
||||
{
|
||||
int txtAngleDecideg = aKiCadTextItem->GetTextAngle().AsTenthsOfADegree();
|
||||
wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
|
||||
RotatePoint( &positionOffset, txtAngleDecideg );
|
||||
VECTOR2I positionOffset( 0, aKiCadTextItem->GetInterline() );
|
||||
RotatePoint( positionOffset, txtAngleDecideg );
|
||||
|
||||
EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
|
||||
|
||||
|
|
|
@ -1919,20 +1919,20 @@ CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement( const NET_SCH& aNet,
|
|||
|
||||
SYMBOL sym = Schematic.Symbols.at( symid );
|
||||
SYMDEF_ID symdefid = sym.SymdefID;
|
||||
wxPoint symbolOrigin = sym.Origin;
|
||||
VECTOR2I symbolOrigin = sym.Origin;
|
||||
|
||||
if( Library.SymbolDefinitions.find( symdefid ) == Library.SymbolDefinitions.end() )
|
||||
return logUnknownNetElementError();
|
||||
|
||||
wxPoint libpinPosition =
|
||||
VECTOR2I libpinPosition =
|
||||
Library.SymbolDefinitions.at( symdefid ).Terminals.at( termid ).Position;
|
||||
wxPoint libOrigin = Library.SymbolDefinitions.at( symdefid ).Origin;
|
||||
VECTOR2I libOrigin = Library.SymbolDefinitions.at( symdefid ).Origin;
|
||||
|
||||
wxPoint pinOffset = libpinPosition - libOrigin;
|
||||
VECTOR2I pinOffset = libpinPosition - libOrigin;
|
||||
pinOffset.x = ( pinOffset.x * sym.ScaleRatioNumerator ) / sym.ScaleRatioDenominator;
|
||||
pinOffset.y = ( pinOffset.y * sym.ScaleRatioNumerator ) / sym.ScaleRatioDenominator;
|
||||
|
||||
wxPoint pinPosition = symbolOrigin + pinOffset;
|
||||
VECTOR2I pinPosition = symbolOrigin + pinOffset;
|
||||
|
||||
double compAngleDeciDeg = getAngleTenthDegree( sym.OrientAngle );
|
||||
|
||||
|
@ -1942,7 +1942,7 @@ CADSTAR_SCH_ARCHIVE_LOADER::getLocationOfNetElement( const NET_SCH& aNet,
|
|||
double adjustedOrientationDecideg;
|
||||
getComponentOrientation( compAngleDeciDeg, adjustedOrientationDecideg );
|
||||
|
||||
RotatePoint( &pinPosition, symbolOrigin, -adjustedOrientationDecideg );
|
||||
RotatePoint( pinPosition, symbolOrigin, -adjustedOrientationDecideg );
|
||||
|
||||
POINT retval;
|
||||
retval.x = pinPosition.x;
|
||||
|
|
|
@ -79,21 +79,11 @@ void RotatePoint( int *pX, int *pY, int cx, int cy, double angle );
|
|||
/*
|
||||
* Calculate the new coord point point for a rotation angle in (1/10 degree).
|
||||
*/
|
||||
inline void RotatePoint( wxPoint* point, double angle )
|
||||
{
|
||||
RotatePoint( &point->x, &point->y, angle );
|
||||
}
|
||||
|
||||
inline void RotatePoint( VECTOR2I& point, double angle )
|
||||
{
|
||||
RotatePoint( &point.x, &point.y, angle );
|
||||
}
|
||||
|
||||
inline void RotatePoint( wxPoint* point, EDA_ANGLE angle )
|
||||
{
|
||||
RotatePoint( &point->x, &point->y, angle.AsTenthsOfADegree() );
|
||||
}
|
||||
|
||||
inline void RotatePoint( VECTOR2I& point, EDA_ANGLE angle )
|
||||
{
|
||||
RotatePoint( &point.x, &point.y, angle.AsTenthsOfADegree() );
|
||||
|
@ -109,12 +99,6 @@ inline void RotatePoint( VECTOR2I& point, const VECTOR2I& centre, EDA_ANGLE angl
|
|||
/*
|
||||
* Calculate the new coord point point for a center rotation center and angle in (1/10 degree).
|
||||
*/
|
||||
void RotatePoint( wxPoint *point, const wxPoint & centre, double angle );
|
||||
|
||||
inline void RotatePoint( wxPoint *point, const wxPoint& centre, EDA_ANGLE angle )
|
||||
{
|
||||
RotatePoint( point, centre, angle.AsTenthsOfADegree() );
|
||||
}
|
||||
|
||||
void RotatePoint( double *pX, double *pY, double angle );
|
||||
|
||||
|
@ -161,21 +145,6 @@ const VECTOR2I CalcArcMid( const VECTOR2I& aStart, const VECTOR2I& aEnd, const V
|
|||
*/
|
||||
double ArcTangente( int dy, int dx );
|
||||
|
||||
//! @brief Euclidean norm of a 2D vector
|
||||
//! @param vector Two-dimensional vector
|
||||
//! @return Euclidean norm of the vector
|
||||
inline double EuclideanNorm( const wxPoint &vector )
|
||||
{
|
||||
// this is working with doubles
|
||||
return hypot( vector.x, vector.y );
|
||||
}
|
||||
|
||||
inline double EuclideanNorm( const wxSize &vector )
|
||||
{
|
||||
// this is working with doubles, too
|
||||
return hypot( vector.x, vector.y );
|
||||
}
|
||||
|
||||
inline double EuclideanNorm( const VECTOR2I& vector )
|
||||
{
|
||||
// this is working with doubles
|
||||
|
@ -218,15 +187,6 @@ inline bool HitTestPoints( const VECTOR2I& pointA, const VECTOR2I& pointB, doubl
|
|||
return sqdistance < threshold * threshold;
|
||||
}
|
||||
|
||||
//! @brief Determine the cross product
|
||||
//! @param vectorA Two-dimensional vector
|
||||
//! @param vectorB Two-dimensional vector
|
||||
inline double CrossProduct( const wxPoint& vectorA, const wxPoint& vectorB )
|
||||
{
|
||||
// As before the cast is to avoid int overflow
|
||||
return (double)vectorA.x * vectorB.y - (double)vectorA.y * vectorB.x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if \a aRefPoint is with \a aDistance on the line defined by \a aStart and \a aEnd..
|
||||
*
|
||||
|
@ -238,19 +198,6 @@ inline double CrossProduct( const wxPoint& vectorA, const wxPoint& vectorB )
|
|||
bool TestSegmentHit( const VECTOR2I& aRefPoint, const VECTOR2I& aStart, const VECTOR2I& aEnd,
|
||||
int aDist );
|
||||
|
||||
/**
|
||||
* Return the length of a line segment defined by \a aPointA and \a aPointB.
|
||||
*
|
||||
* See also EuclideanNorm and Distance for the single vector or four scalar versions.
|
||||
*
|
||||
* @return Length of a line (as double)
|
||||
*/
|
||||
inline double GetLineLength( const wxPoint& aPointA, const wxPoint& aPointB )
|
||||
{
|
||||
// Implicitly casted to double
|
||||
return hypot( aPointA.x - aPointB.x, aPointA.y - aPointB.y );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of a line segment defined by \a aPointA and \a aPointB.
|
||||
*
|
||||
|
|
|
@ -578,12 +578,12 @@ DIALOG_PAD_PRIMITIVES_TRANSFORM::DIALOG_PAD_PRIMITIVES_TRANSFORM( wxWindow* aPar
|
|||
|
||||
|
||||
// A helper function in geometry transform
|
||||
inline void geom_transf( wxPoint& aCoord, const wxPoint& aMove, double aScale, double aRotation )
|
||||
inline void geom_transf( VECTOR2I& aCoord, const VECTOR2I& aMove, double aScale, double aRotation )
|
||||
{
|
||||
aCoord.x = KiROUND( aCoord.x * aScale );
|
||||
aCoord.y = KiROUND( aCoord.y * aScale );
|
||||
aCoord += aMove;
|
||||
RotatePoint( &aCoord, aRotation );
|
||||
RotatePoint( aCoord, aRotation );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,10 +47,8 @@
|
|||
* @param aCenter = arc centre.
|
||||
* @param a_ArcAngle = arc length in 0.1 degrees.
|
||||
*/
|
||||
static void gen_arc( std::vector <wxPoint>& aBuffer,
|
||||
const wxPoint& aStartPoint,
|
||||
const wxPoint& aCenter,
|
||||
int a_ArcAngle )
|
||||
static void gen_arc( std::vector<VECTOR2I>& aBuffer, const VECTOR2I& aStartPoint,
|
||||
const VECTOR2I& aCenter, int a_ArcAngle )
|
||||
{
|
||||
auto first_point = aStartPoint - aCenter;
|
||||
auto radius = KiROUND( EuclideanNorm( first_point ) );
|
||||
|
@ -64,7 +62,7 @@ static void gen_arc( std::vector <wxPoint>& aBuffer,
|
|||
double rot_angle = increment_angle * ii;
|
||||
double fcos = cos( rot_angle );
|
||||
double fsin = sin( rot_angle );
|
||||
wxPoint currpt;
|
||||
VECTOR2I currpt;
|
||||
|
||||
// Rotate current point:
|
||||
currpt.x = KiROUND( ( first_point.x * fcos + first_point.y * fsin ) );
|
||||
|
@ -94,8 +92,10 @@ enum class INDUCTOR_S_SHAPE_RESULT
|
|||
* @param aLength = full length of the path
|
||||
* @param aWidth = segment width
|
||||
*/
|
||||
static INDUCTOR_S_SHAPE_RESULT BuildCornersList_S_Shape( std::vector<wxPoint>& aBuffer,
|
||||
const wxPoint& aStartPoint, const wxPoint& aEndPoint, int aLength, int aWidth )
|
||||
static INDUCTOR_S_SHAPE_RESULT BuildCornersList_S_Shape( std::vector<VECTOR2I>& aBuffer,
|
||||
const VECTOR2I& aStartPoint,
|
||||
const VECTOR2I& aEndPoint, int aLength,
|
||||
int aWidth )
|
||||
{
|
||||
/* We must determine:
|
||||
* segm_count = number of segments perpendicular to the direction
|
||||
|
@ -279,7 +279,7 @@ static INDUCTOR_S_SHAPE_RESULT BuildCornersList_S_Shape( std::vector<wxPoint>& a
|
|||
|
||||
for( unsigned jj = 0; jj < aBuffer.size(); jj++ )
|
||||
{
|
||||
RotatePoint( &aBuffer[jj], aStartPoint, angle );
|
||||
RotatePoint( aBuffer[jj], aStartPoint, angle );
|
||||
}
|
||||
|
||||
// push last point (end point)
|
||||
|
@ -385,7 +385,7 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
|
|||
}
|
||||
|
||||
// Calculate the elements.
|
||||
std::vector <wxPoint> buffer;
|
||||
std::vector<VECTOR2I> buffer;
|
||||
const INDUCTOR_S_SHAPE_RESULT res = BuildCornersList_S_Shape( buffer, aInductorPattern.m_Start,
|
||||
aInductorPattern.m_End,
|
||||
aInductorPattern.m_Length,
|
||||
|
@ -443,7 +443,7 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
|
|||
pad->SetPosition( aInductorPattern.m_End );
|
||||
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
|
||||
|
||||
pad->SetSize( wxSize( aInductorPattern.m_Width, aInductorPattern.m_Width ) );
|
||||
pad->SetSize( VECTOR2I( aInductorPattern.m_Width, aInductorPattern.m_Width ) );
|
||||
|
||||
pad->SetLayerSet( LSET( footprint->GetLayer() ) );
|
||||
pad->SetAttribute( PAD_ATTRIB::SMD );
|
||||
|
@ -460,10 +460,10 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN&
|
|||
pad->SetPos0( pad->GetPosition() - footprint->GetPosition() );
|
||||
|
||||
// Modify text positions.
|
||||
wxPoint refPos( ( aInductorPattern.m_Start.x + aInductorPattern.m_End.x ) / 2,
|
||||
VECTOR2I refPos( ( aInductorPattern.m_Start.x + aInductorPattern.m_End.x ) / 2,
|
||||
( aInductorPattern.m_Start.y + aInductorPattern.m_End.y ) / 2 );
|
||||
|
||||
wxPoint valPos = refPos;
|
||||
VECTOR2I valPos = refPos;
|
||||
|
||||
refPos.y -= footprint->Reference().GetTextSize().y;
|
||||
footprint->Reference().SetPosition( refPos );
|
||||
|
|
|
@ -1024,8 +1024,8 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad,
|
|||
csPadcode.Shape.Size = 1;
|
||||
}
|
||||
|
||||
wxPoint padOffset = { 0, 0 }; // offset of the pad origin (before rotating)
|
||||
wxPoint drillOffset = { 0, 0 }; // offset of the drill origin w.r.t. the pad (before rotating)
|
||||
VECTOR2I padOffset = { 0, 0 }; // offset of the pad origin (before rotating)
|
||||
VECTOR2I drillOffset = { 0, 0 }; // offset of the drill origin w.r.t. the pad (before rotating)
|
||||
|
||||
switch( csPadcode.Shape.ShapeType )
|
||||
{
|
||||
|
@ -1224,8 +1224,8 @@ PAD* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadPad( const COMPONENT_PAD& aCadstarPad,
|
|||
double padOrientation = getAngleTenthDegree( aCadstarPad.OrientAngle )
|
||||
+ getAngleTenthDegree( csPadcode.Shape.OrientAngle );
|
||||
|
||||
RotatePoint( &padOffset, padOrientation );
|
||||
RotatePoint( &drillOffset, padOrientation );
|
||||
RotatePoint( padOffset, padOrientation );
|
||||
RotatePoint( drillOffset, padOrientation );
|
||||
pad->SetPos0( getKiCadPoint( aCadstarPad.Position ) - aParent->GetPosition() - padOffset
|
||||
- drillOffset );
|
||||
pad->SetOrientation( padOrientation + getAngleTenthDegree( csPadcode.SlotOrientation ) );
|
||||
|
|
|
@ -874,13 +874,13 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
setKeepoutSettingsToZone( zone, c.layer );
|
||||
|
||||
// approximate circle as polygon with a edge every 10 degree
|
||||
wxPoint center( kicad_x( c.x ), kicad_y( c.y ) );
|
||||
VECTOR2I center( kicad_x( c.x ), kicad_y( c.y ) );
|
||||
int outlineRadius = radius + ( width / 2 );
|
||||
|
||||
for( int angle = 0; angle < 360; angle += 10 )
|
||||
{
|
||||
wxPoint rotatedPoint( outlineRadius, 0 );
|
||||
RotatePoint( &rotatedPoint, angle * 10. );
|
||||
VECTOR2I rotatedPoint( outlineRadius, 0 );
|
||||
RotatePoint( rotatedPoint, angle * 10. );
|
||||
zone->AppendCorner( center + rotatedPoint, -1 );
|
||||
}
|
||||
|
||||
|
@ -891,8 +891,8 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics )
|
|||
|
||||
for( int angle = 0; angle < 360; angle += 10 )
|
||||
{
|
||||
wxPoint rotatedPoint( innerRadius, 0 );
|
||||
RotatePoint( &rotatedPoint, angle * 10. );
|
||||
VECTOR2I rotatedPoint( innerRadius, 0 );
|
||||
RotatePoint( rotatedPoint, angle * 10. );
|
||||
zone->AppendCorner( center + rotatedPoint, 0 );
|
||||
}
|
||||
}
|
||||
|
@ -2221,13 +2221,13 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons
|
|||
setKeepoutSettingsToZone( zone, e.layer );
|
||||
|
||||
// approximate circle as polygon with a edge every 10 degree
|
||||
wxPoint center( kicad_x( e.x ), kicad_y( e.y ) );
|
||||
VECTOR2I center( kicad_x( e.x ), kicad_y( e.y ) );
|
||||
int outlineRadius = radius + ( width / 2 );
|
||||
|
||||
for( int angle = 0; angle < 360; angle += 10 )
|
||||
{
|
||||
wxPoint rotatedPoint( outlineRadius, 0 );
|
||||
RotatePoint( &rotatedPoint, angle * 10. );
|
||||
VECTOR2I rotatedPoint( outlineRadius, 0 );
|
||||
RotatePoint( rotatedPoint, angle * 10. );
|
||||
zone->AppendCorner( center + rotatedPoint, -1 );
|
||||
}
|
||||
|
||||
|
@ -2238,8 +2238,8 @@ void EAGLE_PLUGIN::packageCircle( FOOTPRINT* aFootprint, wxXmlNode* aTree ) cons
|
|||
|
||||
for( int angle = 0; angle < 360; angle += 10 )
|
||||
{
|
||||
wxPoint rotatedPoint( innerRadius, 0 );
|
||||
RotatePoint( &rotatedPoint, angle * 10. );
|
||||
VECTOR2I rotatedPoint( innerRadius, 0 );
|
||||
RotatePoint( rotatedPoint, angle * 10. );
|
||||
zone->AppendCorner( center + rotatedPoint, 0 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue