Swap some of the 3d viewer to VECTOR2I
This commit is contained in:
parent
44dc602d6b
commit
2d1357dc54
|
@ -90,8 +90,8 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
|
|||
if( PgmOrNull() )
|
||||
m_colors = Pgm().GetSettingsManager().GetColorSettings();
|
||||
|
||||
m_boardPos = wxPoint();
|
||||
m_boardSize = wxSize();
|
||||
m_boardPos = VECTOR2I();
|
||||
m_boardSize = VECTOR2I();
|
||||
m_boardCenter = SFVEC3F( 0.0f );
|
||||
|
||||
m_boardBoundingBox.Reset();
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <layer_ids.h>
|
||||
#include <pad.h>
|
||||
#include <pcb_track.h>
|
||||
#include <wx/gdicmn.h>
|
||||
#include <pcb_base_frame.h>
|
||||
#include <pcb_text.h>
|
||||
#include <pcb_shape.h>
|
||||
|
@ -182,7 +181,7 @@ public:
|
|||
*
|
||||
* @return size in BIU units.
|
||||
*/
|
||||
wxSize GetBoardSize() const noexcept
|
||||
VECTOR2I GetBoardSize() const noexcept
|
||||
{
|
||||
return m_boardSize;
|
||||
}
|
||||
|
@ -192,7 +191,7 @@ public:
|
|||
*
|
||||
* @return position in BIU units.
|
||||
*/
|
||||
wxPoint GetBoardPos() const noexcept
|
||||
VECTOR2I GetBoardPos() const noexcept
|
||||
{
|
||||
return m_boardPos;
|
||||
}
|
||||
|
@ -470,7 +469,7 @@ private:
|
|||
int aClearanceValue );
|
||||
|
||||
void createPadWithClearance( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayer, const wxSize& aClearanceValue ) const;
|
||||
PCB_LAYER_ID aLayer, const VECTOR2I& aClearanceValue ) const;
|
||||
|
||||
OBJECT_2D* createPadWithDrill( const PAD* aPad, int aInflateValue );
|
||||
|
||||
|
@ -496,7 +495,7 @@ private:
|
|||
void addSolidAreasShapes( const ZONE* aZoneContainer, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayerId );
|
||||
|
||||
void transformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart, double aArcAngle,
|
||||
void transformArcToSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart, double aArcAngle,
|
||||
int aCircleToSegmentsCount, int aWidth,
|
||||
CONTAINER_2D_BASE* aDstContainer, const BOARD_ITEM& aBoardItem );
|
||||
|
||||
|
@ -544,8 +543,8 @@ private:
|
|||
S3D_CACHE* m_3dModelManager;
|
||||
COLOR_SETTINGS* m_colors;
|
||||
|
||||
wxPoint m_boardPos; ///< Board center position in board internal units.
|
||||
wxSize m_boardSize; ///< Board size in board internal units.
|
||||
VECTOR2I m_boardPos; ///< Board center position in board internal units.
|
||||
VECTOR2I m_boardSize; ///< Board size in board internal units.
|
||||
SFVEC3F m_boardCenter; ///< 3D center position of the board in 3D units.
|
||||
BBOX_3D m_boardBoundingBox; ///< 3D bounding box of the board in 3D units.
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData )
|
|||
void BOARD_ADAPTER::addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayerId, int aClearanceValue )
|
||||
{
|
||||
wxSize size = aText->GetTextSize();
|
||||
VECTOR2I size = aText->GetTextSize();
|
||||
|
||||
if( aText->IsMirrored() )
|
||||
size.x = -size.x;
|
||||
|
@ -234,7 +234,7 @@ void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint
|
|||
callbackData.m_BiuTo3Dunits = m_biuTo3Dunits;
|
||||
callbackData.m_TextWidth = text->GetEffectiveTextPenWidth() + ( 2 * aInflateValue );
|
||||
|
||||
wxSize size = text->GetTextSize();
|
||||
VECTOR2I size = text->GetTextSize();
|
||||
bool isBold = text->IsBold();
|
||||
int penWidth = text->GetEffectiveTextPenWidth();
|
||||
|
||||
|
@ -294,7 +294,7 @@ void BOARD_ADAPTER::createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDs
|
|||
}
|
||||
}
|
||||
|
||||
transformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
|
||||
transformArcToSegments( VECTOR2I( center.x, center.y ), arc->GetStart(),
|
||||
arc_angle, circlesegcount,
|
||||
arc->GetWidth() + 2 * aClearanceValue, aDstContainer, *arc );
|
||||
break;
|
||||
|
@ -329,11 +329,11 @@ void BOARD_ADAPTER::createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDs
|
|||
|
||||
void BOARD_ADAPTER::createPadWithClearance( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
|
||||
PCB_LAYER_ID aLayer,
|
||||
const wxSize& aClearanceValue ) const
|
||||
const VECTOR2I& aClearanceValue ) const
|
||||
{
|
||||
SHAPE_POLY_SET poly;
|
||||
int maxError = GetBoard()->GetDesignSettings().m_MaxError;
|
||||
wxSize clearance = aClearanceValue;
|
||||
VECTOR2I clearance = aClearanceValue;
|
||||
|
||||
// Our shape-based builder can't handle negative or differing x:y clearance values (the
|
||||
// former are common for solder paste while the later get generated when a relative paste
|
||||
|
@ -345,13 +345,13 @@ void BOARD_ADAPTER::createPadWithClearance( const PAD* aPad, CONTAINER_2D_BASE*
|
|||
if( ( clearance.x < 0 || clearance.x != clearance.y )
|
||||
&& aPad->GetShape() != PAD_SHAPE::CUSTOM )
|
||||
{
|
||||
wxSize dummySize = aPad->GetSize() + clearance + clearance;
|
||||
VECTOR2I dummySize = VECTOR2I( aPad->GetSize() ) + clearance + clearance;
|
||||
|
||||
if( dummySize.x <= 0 || dummySize.y <= 0 )
|
||||
return;
|
||||
|
||||
PAD dummy( *aPad );
|
||||
dummy.SetSize( dummySize );
|
||||
dummy.SetSize( wxSize( dummySize.x, dummySize.y ) );
|
||||
dummy.TransformShapeWithClearanceToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
|
||||
clearance = { 0, 0 };
|
||||
}
|
||||
|
@ -471,7 +471,7 @@ void BOARD_ADAPTER::createPadWithClearance( const PAD* aPad, CONTAINER_2D_BASE*
|
|||
|
||||
OBJECT_2D* BOARD_ADAPTER::createPadWithDrill( const PAD* aPad, int aInflateValue )
|
||||
{
|
||||
wxSize drillSize = aPad->GetDrillSize();
|
||||
VECTOR2I drillSize = aPad->GetDrillSize();
|
||||
|
||||
if( !drillSize.x || !drillSize.y )
|
||||
{
|
||||
|
@ -557,7 +557,7 @@ void BOARD_ADAPTER::addPadsWithClearance( const FOOTPRINT* aFootprint,
|
|||
if( aSkipNonPlatedPads && !isPlated )
|
||||
continue;
|
||||
|
||||
wxSize margin( aInflateValue, aInflateValue );
|
||||
VECTOR2I margin( aInflateValue, aInflateValue );
|
||||
|
||||
switch( aLayerId )
|
||||
{
|
||||
|
@ -583,19 +583,19 @@ void BOARD_ADAPTER::addPadsWithClearance( const FOOTPRINT* aFootprint,
|
|||
|
||||
// based on TransformArcToPolygon function from
|
||||
// common/convert_basic_shapes_to_polygon.cpp
|
||||
void BOARD_ADAPTER::transformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart,
|
||||
void BOARD_ADAPTER::transformArcToSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
||||
double aArcAngle, int aCircleToSegmentsCount,
|
||||
int aWidth, CONTAINER_2D_BASE* aDstContainer,
|
||||
const BOARD_ITEM& aBoardItem )
|
||||
{
|
||||
wxPoint arc_start, arc_end;
|
||||
VECTOR2I arc_start, arc_end;
|
||||
int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
|
||||
|
||||
arc_end = arc_start = aStart;
|
||||
|
||||
if( aArcAngle != 3600 )
|
||||
{
|
||||
RotatePoint( &arc_end, aCentre, -aArcAngle );
|
||||
RotatePoint( arc_end, aCentre, -aArcAngle );
|
||||
}
|
||||
|
||||
if( aArcAngle < 0 )
|
||||
|
@ -605,13 +605,13 @@ void BOARD_ADAPTER::transformArcToSegments( const wxPoint& aCentre, const wxPoin
|
|||
}
|
||||
|
||||
// Compute the ends of segments and creates poly
|
||||
wxPoint curr_end = arc_start;
|
||||
wxPoint curr_start = arc_start;
|
||||
VECTOR2I curr_end = arc_start;
|
||||
VECTOR2I curr_start = arc_start;
|
||||
|
||||
for( int ii = delta; ii < aArcAngle; ii += delta )
|
||||
{
|
||||
curr_end = arc_start;
|
||||
RotatePoint( &curr_end, aCentre, -ii );
|
||||
RotatePoint( curr_end, aCentre, -ii );
|
||||
|
||||
const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
|
||||
const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
|
||||
|
|
|
@ -450,7 +450,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
{
|
||||
for( PAD* pad : footprint->Pads() )
|
||||
{
|
||||
const wxSize padHole = pad->GetDrillSize();
|
||||
const VECTOR2I padHole = pad->GetDrillSize();
|
||||
|
||||
if( !padHole.x ) // Not drilled pad like SMD pad
|
||||
continue;
|
||||
|
@ -480,7 +480,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
|
|||
{
|
||||
for( PAD* pad : footprint->Pads() )
|
||||
{
|
||||
const wxSize padHole = pad->GetDrillSize();
|
||||
const VECTOR2I padHole = pad->GetDrillSize();
|
||||
|
||||
if( !padHole.x ) // Not drilled pad like SMD pad
|
||||
continue;
|
||||
|
|
|
@ -53,7 +53,7 @@ void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& a
|
|||
const VECTOR2I& a = path.CPoint( ii );
|
||||
const VECTOR2I& b = path.CPoint( ii + 1 );
|
||||
|
||||
TransformOvalToPolygon( aCornerBuffer, (wxPoint) a, (wxPoint) b, aWidth, ARC_HIGH_DEF,
|
||||
TransformOvalToPolygon( aCornerBuffer, a, b, aWidth, ARC_HIGH_DEF,
|
||||
ERROR_INSIDE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1218,7 +1218,7 @@ void RENDER_3D_OPENGL::renderFootprint( const FOOTPRINT* aFootprint, bool aRende
|
|||
|
||||
glPushMatrix();
|
||||
|
||||
wxPoint pos = aFootprint->GetPosition();
|
||||
VECTOR2I pos = aFootprint->GetPosition();
|
||||
|
||||
glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
|
||||
zpos );
|
||||
|
@ -1373,8 +1373,8 @@ void RENDER_3D_OPENGL::generate3dGrid( GRID3D_TYPE aGridType )
|
|||
|
||||
glNormal3f( 0.0, 0.0, 1.0 );
|
||||
|
||||
const wxSize brd_size = m_boardAdapter.GetBoardSize();
|
||||
wxPoint brd_center_pos = m_boardAdapter.GetBoardPos();
|
||||
const VECTOR2I brd_size = m_boardAdapter.GetBoardSize();
|
||||
VECTOR2I brd_center_pos = m_boardAdapter.GetBoardPos();
|
||||
|
||||
brd_center_pos.y = -brd_center_pos.y;
|
||||
|
||||
|
|
|
@ -994,8 +994,8 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
|
|||
else
|
||||
objColor = m_boardAdapter.GetItemColor( LAYER_PADS_TH );
|
||||
|
||||
const wxSize drillsize = aPad->GetDrillSize();
|
||||
const bool hasHole = drillsize.x && drillsize.y;
|
||||
const VECTOR2I drillsize = aPad->GetDrillSize();
|
||||
const bool hasHole = drillsize.x && drillsize.y;
|
||||
|
||||
if( !hasHole )
|
||||
return;
|
||||
|
@ -1053,7 +1053,7 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
|
|||
}
|
||||
else // Oblong hole
|
||||
{
|
||||
wxPoint ends_offset;
|
||||
VECTOR2I ends_offset;
|
||||
int width;
|
||||
|
||||
if( drillsize.x > drillsize.y ) // Horizontal oval
|
||||
|
@ -1067,10 +1067,10 @@ void RENDER_3D_RAYTRACE::insertHole( const PAD* aPad )
|
|||
width = drillsize.x;
|
||||
}
|
||||
|
||||
RotatePoint( &ends_offset, aPad->GetOrientation() );
|
||||
RotatePoint( ends_offset, aPad->GetOrientation() );
|
||||
|
||||
wxPoint start = aPad->GetPosition() + ends_offset;
|
||||
wxPoint end = aPad->GetPosition() - ends_offset;
|
||||
VECTOR2I start = VECTOR2I( aPad->GetPosition() ) + ends_offset;
|
||||
VECTOR2I end = VECTOR2I( aPad->GetPosition() ) - ends_offset;
|
||||
|
||||
ROUND_SEGMENT_2D* innerSeg =
|
||||
new ROUND_SEGMENT_2D( SFVEC2F( start.x * m_boardAdapter.BiuTo3dUnits(),
|
||||
|
@ -1210,7 +1210,7 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
|
|||
{
|
||||
double zpos = m_boardAdapter.GetFootprintZPos( fp->IsFlipped() );
|
||||
|
||||
wxPoint pos = fp->GetPosition();
|
||||
VECTOR2I pos = fp->GetPosition();
|
||||
|
||||
glm::mat4 fpMatrix = glm::mat4( 1.0f );
|
||||
|
||||
|
|
Loading…
Reference in New Issue