Skip to content

Commit

Permalink
Remove some more wxPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
marekr committed Jan 1, 2022
1 parent a0d708e commit c91d3e3
Show file tree
Hide file tree
Showing 22 changed files with 90 additions and 113 deletions.
10 changes: 5 additions & 5 deletions eeschema/sch_screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class SCH_SCREEN : public BASE_SCREEN
void SetFileExists( bool aFileExists ) { m_fileExists = aFileExists; }
bool FileExists() const { return m_fileExists; }

const wxPoint& GetAuxOrigin() const { return m_aux_origin; }
void SetAuxOrigin( const wxPoint& aPosition ) { m_aux_origin = aPosition; }
const VECTOR2I& GetAuxOrigin() const { return m_aux_origin; }
void SetAuxOrigin( const VECTOR2I& aPosition ) { m_aux_origin = aPosition; }

const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }

Expand Down Expand Up @@ -410,7 +410,7 @@ class SCH_SCREEN : public BASE_SCREEN
/**
* Return a line item located at \a aPosition.
*
* @param[in] aPosition The wxPoint to test for a line item.
* @param[in] aPosition The VECTOR2I to test for a line item.
* @param aAccuracy Amount to inflate the item hit test bounding box.
* @param aLayer The layer the line is drawn upon.
* @param aSearchType Additional line test criteria.
Expand All @@ -435,7 +435,7 @@ class SCH_SCREEN : public BASE_SCREEN
/**
* Return a label item located at \a aPosition.
*
* @param[in] aPosition The wxPoint to test for label items.
* @param[in] aPosition The VECTOR2I to test for label items.
* @param aAccuracy Amount to inflate the item hit test bounding box.
* @return The SCH_TEXT* of the label item found at \a aPosition or NULL if item not
* found.
Expand Down Expand Up @@ -534,7 +534,7 @@ class SCH_SCREEN : public BASE_SCREEN

PAGE_INFO m_paper; // The size of the paper to print or plot on.
TITLE_BLOCK m_titles;
wxPoint m_aux_origin; // Origin used for drill & place files by Pcbnew.
VECTOR2I m_aux_origin; // Origin used for drill & place files by Pcbnew.
EE_RTREE m_rtree;

int m_modification_sync; // Inequality with SYMBOL_LIBS::GetModificationHash()
Expand Down
4 changes: 2 additions & 2 deletions eeschema/sch_symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class SCH_SYMBOL : public SCH_ITEM
* Print a symbol.
*
* @param aDC is the device context (can be null).
* @param aOffset is the drawing offset (usually wxPoint(0,0), but can be different when
* @param aOffset is the drawing offset (usually VECTOR2I(0,0), but can be different when
* moving an object)
*/
void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
Expand Down Expand Up @@ -563,7 +563,7 @@ class SCH_SYMBOL : public SCH_ITEM

void Move( const VECTOR2I& aMoveVector ) override
{
if( aMoveVector == wxPoint( 0, 0 ) )
if( aMoveVector == VECTOR2I( 0, 0 ) )
return;

m_pos += aMoveVector;
Expand Down
10 changes: 4 additions & 6 deletions eeschema/tools/ee_grid_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ VECTOR2I EE_GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, int aLayer,
else if( snapPoint )
{
m_snapItem = nearest;
m_viewSnapPoint.SetPosition( (wxPoint) pt );
m_viewSnapLine.SetPosition( (wxPoint) pt );
m_viewSnapPoint.SetPosition( pt );
m_viewSnapLine.SetPosition( pt );

m_toolMgr->GetView()->SetVisible( &m_viewSnapLine, false );

Expand Down Expand Up @@ -316,16 +316,14 @@ void EE_GRID_HELPER::computeAnchors( SCH_ITEM *aItem, const VECTOR2I &aRefPos, b
{
VECTOR2I possible( line->GetStartPoint().x, pt.y );

if( TestSegmentHit( wxPoint( possible ), line->GetStartPoint(), line->GetEndPoint(),
0 ) )
if( TestSegmentHit( possible, line->GetStartPoint(), line->GetEndPoint(), 0 ) )
addAnchor( possible, SNAPPABLE | VERTICAL, aItem );
}
else if( line->GetStartPoint().y == line->GetEndPoint().y )
{
VECTOR2I possible( pt.x, line->GetStartPoint().y );

if( TestSegmentHit( wxPoint( possible ), line->GetStartPoint(), line->GetEndPoint(),
0 ) )
if( TestSegmentHit( possible, line->GetStartPoint(), line->GetEndPoint(), 0 ) )
addAnchor( possible, SNAPPABLE | HORIZONTAL, aItem );
}

Expand Down
24 changes: 12 additions & 12 deletions gerbview/am_primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ extern int scaletoIU( double aCoord, bool isMetric );
*
* @return The GerbView coordinate system vector.
*/
static wxPoint mapPt( double x, double y, bool isMetric )
static VECTOR2I mapPt( double x, double y, bool isMetric )
{
wxPoint ret( scaletoIU( x, isMetric ), scaletoIU( y, isMetric ) );
VECTOR2I ret( scaletoIU( x, isMetric ), scaletoIU( y, isMetric ) );

return ret;
}
Expand Down Expand Up @@ -377,7 +377,7 @@ void AM_PRIMITIVE::DrawBasicShape( const GERBER_DRAW_ITEM* aParent, SHAPE_POLY_S
// the shape rotation is the last param of list, after corners
int last_prm = params.size() - 1;
rotation = params[last_prm].GetValue( tool ) * 10.0;
wxPoint pos;
VECTOR2I pos;

// Read points.
// Note: numCorners is the polygon corner count, following the first corner
Expand Down Expand Up @@ -498,17 +498,17 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,
case AMP_LINE2:
case AMP_LINE20: // Line with rectangle ends. (Width, start and end pos + rotation)
{
int width = scaletoIU( params[1].GetValue( tool ), m_GerbMetric );
wxPoint start = mapPt( params[2].GetValue( tool ),
params[3].GetValue( tool ), m_GerbMetric );
wxPoint end = mapPt( params[4].GetValue( tool ),
params[5].GetValue( tool ), m_GerbMetric );
wxPoint delta = end - start;
int width = scaletoIU( params[1].GetValue( tool ), m_GerbMetric );
VECTOR2I start =
mapPt( params[2].GetValue( tool ), params[3].GetValue( tool ), m_GerbMetric );
VECTOR2I end =
mapPt( params[4].GetValue( tool ), params[5].GetValue( tool ), m_GerbMetric );
VECTOR2I delta = end - start;
int len = KiROUND( EuclideanNorm( delta ) );

// To build the polygon, we must create a horizontal polygon starting to "start"
// and rotate it to have the end point to "end"
wxPoint currpt;
VECTOR2I currpt;
currpt.y += width / 2; // Upper left
aBuffer.push_back( currpt );
currpt.x = len; // Upper right
Expand Down Expand Up @@ -676,8 +676,8 @@ void AM_PRIMITIVE::ConvertShapeToPolygon( const GERBER_DRAW_ITEM* aParent,

for( int ii = 0; ii <= vertexcount; ii++ )
{
wxPoint pos( radius, 0);
RotatePoint( &pos, ii * 3600 / vertexcount );
VECTOR2I pos( radius, 0 );
RotatePoint( pos, ii * 3600 / vertexcount );
aBuffer.push_back( pos );
}

Expand Down
8 changes: 4 additions & 4 deletions gerbview/excellon_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,25 @@ struct EXCELLON_ROUTE_COORD
m_rmode( 0 ), m_arc_type_info( 0 )
{}

EXCELLON_ROUTE_COORD( const wxPoint& aPos ):
EXCELLON_ROUTE_COORD( const VECTOR2I& aPos ) :
m_x( aPos.x ), m_y( aPos.y ),
m_cx( 0 ), m_cy( 0 ), m_radius( 0 ), m_rmode( 0 ),
m_arc_type_info( ARC_INFO_TYPE_NONE )
{}

EXCELLON_ROUTE_COORD( const wxPoint& aPos, const wxPoint& aCenter, int aMode ):
EXCELLON_ROUTE_COORD( const VECTOR2I& aPos, const VECTOR2I& aCenter, int aMode ) :
m_x( aPos.x ), m_y( aPos.y ),
m_cx( aCenter.x ), m_cy( aCenter.y ), m_radius( 0 ), m_rmode( aMode ),
m_arc_type_info( ARC_INFO_TYPE_CENTER )
{}

EXCELLON_ROUTE_COORD( const wxPoint& aPos, int aRadius, int aMode ):
EXCELLON_ROUTE_COORD( const VECTOR2I& aPos, int aRadius, int aMode ) :
m_x( aPos.x ), m_y( aPos.y ),
m_cx( 0 ), m_cy( 0 ), m_radius( aRadius ), m_rmode( aMode ),
m_arc_type_info( ARC_INFO_TYPE_RADIUS )
{}

wxPoint GetPos() { return wxPoint( m_x, m_y ); }
VECTOR2I GetPos() { return VECTOR2I( m_x, m_y ); }
};

/**
Expand Down
6 changes: 3 additions & 3 deletions gerbview/gbr_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class GBR_LAYOUT : public EDA_ITEM
// which handles the list of gerber files (and drill files) images loaded
GERBER_FILE_IMAGE_LIST* GetImagesList() const;

const wxPoint& GetAuxOrigin() const { return m_originAxisPosition; }
void SetAuxOrigin( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
const VECTOR2I& GetAuxOrigin() const { return m_originAxisPosition; }
void SetAuxOrigin( const VECTOR2I& aPosition ) { m_originAxisPosition = aPosition; }

TITLE_BLOCK& GetTitleBlock() { return m_titles; }
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
Expand Down Expand Up @@ -87,7 +87,7 @@ class GBR_LAYOUT : public EDA_ITEM
private:
mutable EDA_RECT m_BoundingBox;
TITLE_BLOCK m_titles;
wxPoint m_originAxisPosition;
VECTOR2I m_originAxisPosition;
};

#endif // #ifndef GBR_LAYOUT_H
4 changes: 2 additions & 2 deletions gerbview/gerber_draw_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ class GERBER_DRAW_ITEM : public EDA_ITEM
bool m_swapAxis; // false if A = X, B = Y; true if A =Y, B = Y
bool m_mirrorA; // true: mirror / axis A
bool m_mirrorB; // true: mirror / ax's B
wxRealPoint m_drawScale; // A and B scaling factor
wxPoint m_layerOffset; // Offset for A and B axis, from OF parameter
VECTOR2I m_drawScale; // A and B scaling factor
VECTOR2I m_layerOffset; // Offset for A and B axis, from OF parameter
double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
GBR_NETLIST_METADATA m_netAttributes; ///< the string given by a %TO attribute set in aperture
///< (dcode). Stored in each item, because %TO is
Expand Down
18 changes: 9 additions & 9 deletions gerbview/gerber_file_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ class GERBER_FILE_IMAGE : public EDA_ITEM
* it forces truncation of a digit string to a maximum length because the exact coordinate
* format is not always known.
*/
wxPoint ReadXYCoord( char*& aText, bool aExcellonMode = false );
VECTOR2I ReadXYCoord( char*& aText, bool aExcellonMode = false );

/**
* Return the current coordinate type pointed to by InnJnn Text (InnnnJmmmm)
*
* These coordinates are relative, so if coordinate is absent, its value
* defaults to 0
*/
wxPoint ReadIJCoord( char*& Text );
VECTOR2I ReadIJCoord( char*& Text );

// functions to read G commands or D commands:
int GCodeNumber( char*& Text );
Expand Down Expand Up @@ -377,13 +377,13 @@ class GERBER_FILE_IMAGE : public EDA_ITEM
bool m_ImageJustifyYCenter;

///< Image Justify Offset on XY axis (default = 0,0).
wxPoint m_ImageJustifyOffset;
VECTOR2I m_ImageJustifyOffset;
bool m_GerbMetric; // false = Inches, true = metric

///< false = absolute Coord, true = relative Coord.
bool m_Relative;
bool m_NoTrailingZeros; // true: remove tailing zeros.
wxPoint m_ImageOffset; // Coord Offset, from IO command
VECTOR2I m_ImageOffset; // Coord Offset, from IO command

///< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
wxSize m_FmtScale;
Expand All @@ -397,8 +397,8 @@ class GERBER_FILE_IMAGE : public EDA_ITEM
///< Local rotation in degrees added to m_ImageRotation.
///< @note This value is stored in 0.1 degrees.
double m_LocalRotation;
wxPoint m_Offset; // Coord Offset, from OF command
wxRealPoint m_Scale; // scale (X and Y) of layer.
VECTOR2I m_Offset; // Coord Offset, from OF command
VECTOR2I m_Scale; // scale (X and Y) of layer.
bool m_SwapAxis; // false (default) if A = X and B = Y
// true if A = Y, B = X
bool m_MirrorA; // true: mirror / axis A (X)
Expand All @@ -412,9 +412,9 @@ class GERBER_FILE_IMAGE : public EDA_ITEM

///< Line number of the gerber file while reading.
int m_LineNum;
wxPoint m_CurrentPos; // current specified coord for plot
wxPoint m_PreviousPos; // old current specified coord for plot
wxPoint m_IJPos; // IJ coord (for arcs & circles )
VECTOR2I m_CurrentPos; // current specified coord for plot
VECTOR2I m_PreviousPos; // old current specified coord for plot
VECTOR2I m_IJPos; // IJ coord (for arcs & circles )

///< True if a IJ coord was read (for arcs & circles ).
bool m_LastCoordIsIJPos;
Expand Down
16 changes: 8 additions & 8 deletions gerbview/rs274_read_XY_and_IJ_coordinates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ int scaletoIU( double aCoord, bool isMetric )
}


wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& Text, bool aExcellonMode )
VECTOR2I GERBER_FILE_IMAGE::ReadXYCoord( char*& Text, bool aExcellonMode )
{
wxPoint pos;
int type_coord = 0, current_coord, nbdigits;
bool is_float = false;
char* text;
char line[256];
VECTOR2I pos;
int type_coord = 0, current_coord, nbdigits;
bool is_float = false;
char* text;
char line[256];


if( m_Relative )
Expand Down Expand Up @@ -190,9 +190,9 @@ wxPoint GERBER_FILE_IMAGE::ReadXYCoord( char*& Text, bool aExcellonMode )
}


wxPoint GERBER_FILE_IMAGE::ReadIJCoord( char*& Text )
VECTOR2I GERBER_FILE_IMAGE::ReadIJCoord( char*& Text )
{
wxPoint pos( 0, 0 );
VECTOR2I pos( 0, 0 );

int type_coord = 0, current_coord, nbdigits;
bool is_float = false;
Expand Down
2 changes: 1 addition & 1 deletion include/board_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class BOARD_ITEM : public EDA_ITEM
/**
* A value of wxPoint(0,0) which can be passed to the Draw() functions.
*/
static wxPoint ZeroOffset;
static VECTOR2I ZeroOffset;

/**
* Some pad shapes can be complex (rounded/chamfered rectangle), even without considering
Expand Down
3 changes: 1 addition & 2 deletions libs/kimath/include/trigo.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ void RotatePoint( double *pX, double *pY, double cx, double cy, double angle );
*/
const VECTOR2I CalcArcCenter( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd );
const VECTOR2D CalcArcCenter( const VECTOR2D& aStart, const VECTOR2D& aMid, const VECTOR2D& aEnd );
const wxPoint CalcArcCenter( const wxPoint& aStart, const wxPoint& aMid, const wxPoint& aEnd );
const wxPoint CalcArcCenter( const VECTOR2I& aStart, const VECTOR2I& aEnd, double aAngle );
const VECTOR2I CalcArcCenter( const VECTOR2I& aStart, const VECTOR2I& aEnd, double aAngle );

/**
* Return the subtended angle for a given arc.
Expand Down
23 changes: 1 addition & 22 deletions libs/kimath/src/trigo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void RotatePoint( double* pX, double* pY, double angle )
}


const wxPoint CalcArcCenter( const VECTOR2I& aStart, const VECTOR2I& aEnd, double aAngle )
const VECTOR2I CalcArcCenter( const VECTOR2I& aStart, const VECTOR2I& aEnd, double aAngle )
{
VECTOR2I start = aStart;
VECTOR2I end = aEnd;
Expand Down Expand Up @@ -472,27 +472,6 @@ const VECTOR2I CalcArcCenter( const VECTOR2I& aStart, const VECTOR2I& aMid, cons
}


const wxPoint CalcArcCenter( const wxPoint& aStart, const wxPoint& aMid, const wxPoint& aEnd )
{
VECTOR2D dStart( static_cast<double>( aStart.x ), static_cast<double>( aStart.y ) );
VECTOR2D dMid( static_cast<double>( aMid.x ), static_cast<double>( aMid.y ) );
VECTOR2D dEnd( static_cast<double>( aEnd.x ), static_cast<double>( aEnd.y ) );
VECTOR2D dCenter = CalcArcCenter( dStart, dMid, dEnd );

wxPoint iCenter;

iCenter.x = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
dCenter.x,
double( std::numeric_limits<int>::max() / 2.0 ) ) );

iCenter.y = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
dCenter.y,
double( std::numeric_limits<int>::max() / 2.0 ) ) );

return iCenter;
}


double CalcArcAngle( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I& aEnd )
{
VECTOR2I center = CalcArcCenter( aStart, aMid, aEnd );
Expand Down
8 changes: 4 additions & 4 deletions pcbnew/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

// This is an odd place for this, but CvPcb won't link if it's in board_item.cpp like I first
// tried it.
wxPoint BOARD_ITEM::ZeroOffset( 0, 0 );
VECTOR2I BOARD_ITEM::ZeroOffset( 0, 0 );


BOARD::BOARD() :
Expand Down Expand Up @@ -1747,7 +1747,7 @@ std::tuple<int, double, double> BOARD::GetTrackLength( const PCB_TRACK& aTrack )
}


FOOTPRINT* BOARD::GetFootprint( const wxPoint& aPosition, PCB_LAYER_ID aActiveLayer,
FOOTPRINT* BOARD::GetFootprint( const VECTOR2I& aPosition, PCB_LAYER_ID aActiveLayer,
bool aVisibleOnly, bool aIgnoreLocked ) const
{
FOOTPRINT* footprint = nullptr;
Expand Down Expand Up @@ -1832,7 +1832,7 @@ std::list<ZONE*> BOARD::GetZoneList( bool aIncludeZonesInFootprints ) const


ZONE* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer,
wxPoint aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch )
VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch )
{
ZONE* new_area = new ZONE( this );

Expand Down Expand Up @@ -1882,7 +1882,7 @@ bool BOARD::NormalizeAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList, ZONE* aCurr
// Create new copper area and copy poly into it
SHAPE_POLY_SET* new_p = new SHAPE_POLY_SET( aCurrArea->Outline()->UnitSet( ip ) );
NewArea = AddArea( aNewZonesList, aCurrArea->GetNetCode(), aCurrArea->GetLayer(),
wxPoint(0, 0), aCurrArea->GetHatchStyle() );
VECTOR2I( 0, 0 ), aCurrArea->GetHatchStyle() );

// remove the poly that was automatically created for the new area
// and replace it with a poly from NormalizeAreaOutlines
Expand Down
Loading

0 comments on commit c91d3e3

Please sign in to comment.