A bit more angle cleanup.
This commit is contained in:
parent
8ea66ee06e
commit
b828355206
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -144,14 +144,14 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
|
|||
if( aNrSidesPerCircle > 1 )
|
||||
{
|
||||
const float radius = 0.5f;
|
||||
const int delta = 3600 / aNrSidesPerCircle;
|
||||
const EDA_ANGLE delta = ANGLE_360 / aNrSidesPerCircle;
|
||||
|
||||
// Generate bottom
|
||||
glNormal3f( 0.0f, 0.0f,-1.0f );
|
||||
glBegin( GL_TRIANGLE_FAN );
|
||||
glVertex3f( 0.0, 0.0, 0.0 ); // This is the V0 of the FAN
|
||||
|
||||
for( int ii = 0; ii < 1800; ii += delta )
|
||||
for( EDA_ANGLE ii = ANGLE_0; ii < ANGLE_180; ii += delta )
|
||||
{
|
||||
SFVEC2D corner = SFVEC2D( 0.0, radius );
|
||||
RotatePoint( &corner.x, &corner.y, ii );
|
||||
|
@ -166,7 +166,7 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
|
|||
glBegin( GL_TRIANGLE_FAN );
|
||||
glVertex3f( 0.0, 0.0, 1.0 ); // This is the V0 of the FAN
|
||||
|
||||
for( int ii = 1800; ii > 0; ii -= delta )
|
||||
for( EDA_ANGLE ii = ANGLE_180; ii > ANGLE_0; ii -= delta )
|
||||
{
|
||||
SFVEC2D corner = SFVEC2D( 0.0, radius );
|
||||
|
||||
|
@ -180,7 +180,7 @@ void DrawHalfOpenCylinder( unsigned int aNrSidesPerCircle )
|
|||
// Generate contours
|
||||
glBegin( GL_QUAD_STRIP );
|
||||
|
||||
for( int ii = 1800; ii > 0; ii -= delta )
|
||||
for( EDA_ANGLE ii = ANGLE_180; ii > ANGLE_0; ii -= delta )
|
||||
{
|
||||
SFVEC2D corner = SFVEC2D( 0.0, radius );
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect, const EDA_ANGLE& aRotation ) c
|
|||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
VECTOR2I delta = corners[i] - rCentre;
|
||||
RotatePoint( delta, -rotation );
|
||||
RotatePoint( delta, -EDA_ANGLE( rotation, TENTHS_OF_A_DEGREE_T ) );
|
||||
delta += rCentre;
|
||||
|
||||
if( aRect.Contains( delta ) )
|
||||
|
@ -262,7 +262,7 @@ bool EDA_RECT::Intersects( const EDA_RECT& aRect, const EDA_ANGLE& aRotation ) c
|
|||
// Rotate and test each corner
|
||||
for( int j = 0; j < 4; j++ )
|
||||
{
|
||||
RotatePoint( corners[j], rotation );
|
||||
RotatePoint( corners[j], EDA_ANGLE( rotation, TENTHS_OF_A_DEGREE_T ) );
|
||||
corners[j] += rCentre;
|
||||
|
||||
if( Contains( corners[j] ) )
|
||||
|
|
|
@ -307,7 +307,7 @@ void SCH_BUS_ENTRY_BASE::MirrorHorizontally( int aCenter )
|
|||
|
||||
void SCH_BUS_ENTRY_BASE::Rotate( const VECTOR2I& aCenter )
|
||||
{
|
||||
RotatePoint( m_pos, aCenter, 900 );
|
||||
RotatePoint( m_pos, aCenter, ANGLE_90 );
|
||||
RotatePoint( &m_size.x, &m_size.y, ANGLE_90 );
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <vector>
|
||||
#include <math/vector2d.h>
|
||||
#include <geometry/eda_angle.h>
|
||||
|
||||
class SHAPE_POLY_SET;
|
||||
|
||||
|
@ -57,6 +58,6 @@ void BuildConvexHull( std::vector<VECTOR2I>& aResult, const SHAPE_POLY_SET& aPol
|
|||
* @param aRotation is the rotation of the convex hull.
|
||||
*/
|
||||
void BuildConvexHull( std::vector<VECTOR2I>& aResult, const SHAPE_POLY_SET& aPolygons,
|
||||
const VECTOR2I& aPosition, double aRotation );
|
||||
const VECTOR2I& aPosition, const EDA_ANGLE& aRotation );
|
||||
|
||||
#endif // __CONVEX_HULL_H
|
||||
|
|
|
@ -133,12 +133,12 @@ void BuildConvexHull( std::vector<VECTOR2I>& aResult, const std::vector<VECTOR2I
|
|||
|
||||
void BuildConvexHull( std::vector<VECTOR2I>& aResult, const SHAPE_POLY_SET& aPolygons )
|
||||
{
|
||||
BuildConvexHull( aResult, aPolygons, VECTOR2I( 0, 0 ), 0.0 );
|
||||
BuildConvexHull( aResult, aPolygons, VECTOR2I( 0, 0 ), ANGLE_0 );
|
||||
}
|
||||
|
||||
|
||||
void BuildConvexHull( std::vector<VECTOR2I>& aResult, const SHAPE_POLY_SET& aPolygons,
|
||||
const VECTOR2I& aPosition, double aRotation )
|
||||
const VECTOR2I& aPosition, const EDA_ANGLE& aRotation )
|
||||
{
|
||||
// Build the convex hull of the SHAPE_POLY_SET
|
||||
std::vector<VECTOR2I> buf;
|
||||
|
|
|
@ -622,7 +622,7 @@ void AR_MATRIX::traceArc( int ux0, int uy0, int ux1, int uy1, double ArcAngle, i
|
|||
|
||||
|
||||
void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double angle,
|
||||
LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic )
|
||||
LSET aLayerMask, int color, AR_MATRIX::CELL_OP op_logic )
|
||||
{
|
||||
int row, col;
|
||||
int cx, cy; // Center of rectangle
|
||||
|
@ -685,7 +685,7 @@ void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double
|
|||
{
|
||||
rotrow = row * m_GridRouting;
|
||||
rotcol = col * m_GridRouting;
|
||||
RotatePoint( &rotcol, &rotrow, cx, cy, -angle );
|
||||
RotatePoint( &rotcol, &rotrow, cx, cy, -EDA_ANGLE( angle, TENTHS_OF_A_DEGREE_T ) );
|
||||
|
||||
if( rotrow <= uy0 )
|
||||
continue;
|
||||
|
@ -710,7 +710,7 @@ void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, double
|
|||
|
||||
|
||||
void AR_MATRIX::TraceFilledRectangle( int ux0, int uy0, int ux1, int uy1, LSET aLayerMask,
|
||||
int color, AR_MATRIX::CELL_OP op_logic )
|
||||
int color, AR_MATRIX::CELL_OP op_logic )
|
||||
{
|
||||
int row, col;
|
||||
int row_min, row_max, col_min, col_max;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -39,7 +39,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
|
|||
wxString msg;
|
||||
wxString cmp_name;
|
||||
int pad_count = 2;
|
||||
int angle = 0;
|
||||
EDA_ANGLE angle = ANGLE_0;
|
||||
|
||||
PCB_EDIT_FRAME& editFrame = *getEditFrame<PCB_EDIT_FRAME>();
|
||||
|
||||
|
@ -89,8 +89,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
|
|||
|
||||
if( aFootprintShape == MICROWAVE_FOOTPRINT_SHAPE::STUB_ARC )
|
||||
{
|
||||
double fcoeff = 10.0, fval;
|
||||
msg.Printf( wxT( "%3.1f" ), angle / fcoeff );
|
||||
msg = wxT( "0.0" );
|
||||
WX_TEXT_ENTRY_DIALOG angledlg( &editFrame, _( "Angle in degrees:" ),
|
||||
_( "Create Microwave Footprint" ), msg );
|
||||
|
||||
|
@ -99,16 +98,21 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
|
|||
|
||||
msg = angledlg.GetValue();
|
||||
|
||||
double fval;
|
||||
|
||||
if( !msg.ToDouble( &fval ) )
|
||||
{
|
||||
DisplayError( &editFrame, _( "Incorrect number, abort" ) );
|
||||
abort = true;
|
||||
}
|
||||
|
||||
angle = std::abs( KiROUND( fval * fcoeff ) );
|
||||
angle = EDA_ANGLE( fval, DEGREES_T );
|
||||
|
||||
if( angle > 1800 )
|
||||
angle = 1800;
|
||||
if( angle < ANGLE_0 )
|
||||
angle = -angle;
|
||||
|
||||
if( angle > ANGLE_180 )
|
||||
angle = ANGLE_180;
|
||||
}
|
||||
|
||||
if( abort )
|
||||
|
@ -145,13 +149,13 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
|
|||
pad->SetShape( PAD_SHAPE::CUSTOM );
|
||||
pad->SetAnchorPadShape( PAD_SHAPE::RECT );
|
||||
|
||||
int numPoints = ( angle / 50 ) + 3; // Note: angles are in 0.1 degrees
|
||||
int numPoints = ( angle.AsDegrees() / 5.0 ) + 3;
|
||||
std::vector<VECTOR2I> polyPoints;
|
||||
polyPoints.reserve( numPoints );
|
||||
|
||||
polyPoints.emplace_back( wxPoint( 0, 0 ) );
|
||||
|
||||
int theta = -angle / 2;
|
||||
EDA_ANGLE theta = -angle / 2;
|
||||
|
||||
for( int ii = 1; ii < numPoints - 1; ii++ )
|
||||
{
|
||||
|
@ -159,7 +163,7 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint
|
|||
RotatePoint( &pt.x, &pt.y, theta );
|
||||
polyPoints.push_back( pt );
|
||||
|
||||
theta += 50;
|
||||
theta += EDA_ANGLE( 5.0, DEGREES_T );
|
||||
|
||||
if( theta > angle / 2 )
|
||||
theta = angle / 2;
|
||||
|
|
Loading…
Reference in New Issue