KiCad PCB EDA Suite
BOARD_ADAPTER Class Reference

Helper class to handle information needed to display 3D board. More...

#include <board_adapter.h>

Public Member Functions

 BOARD_ADAPTER ()
 
 ~BOARD_ADAPTER ()
 
void Set3dCacheManager (S3D_CACHE *aCacheMgr) noexcept
 Update the cache manager pointer. More...
 
S3D_CACHEGet3dCacheManager () const noexcept
 
bool Is3dLayerEnabled (PCB_LAYER_ID aLayer) const
 Check if a layer is enabled. More...
 
bool IsFootprintShown (FOOTPRINT_ATTR_T aFPAttributes) const
 Test if footprint should be displayed in relation to attributes and the flags. More...
 
void SetBoard (BOARD *aBoard) noexcept
 Set current board to be rendered. More...
 
const BOARDGetBoard () const noexcept
 
void SetColorSettings (COLOR_SETTINGS *aSettings) noexcept
 
void InitSettings (REPORTER *aStatusReporter, REPORTER *aWarningReporter)
 Function to be called by the render when it need to reload the settings for the board. More...
 
double BiuTo3dUnits () const noexcept
 Board integer units To 3D units. More...
 
const BBOX_3DGetBBox () const noexcept
 Get the board outling bounding box. More...
 
float GetBoardBodyThickness () const noexcept
 Get the board body thickness, including internal copper layers (in 3D units). More...
 
float GetNonCopperLayerThickness () const noexcept
 Get the non copper layers thickness (in 3D units). More...
 
float GetFrontCopperThickness () const noexcept
 Get the copper layer thicknesses (in 3D units). More...
 
float GetBackCopperThickness () const noexcept
 
int GetHolePlatingThickness () const noexcept
 Get the hole plating thickness (NB: in BOARD UNITS!). More...
 
VECTOR2I GetBoardSize () const noexcept
 Get the board size. More...
 
VECTOR2I GetBoardPos () const noexcept
 Get the board center. More...
 
const SFVEC3FGetBoardCenter () const noexcept
 The board center position in 3D units. More...
 
float GetFootprintZPos (bool aIsFlipped) const
 Get the position of the footprint in 3d integer units considering if it is flipped or not. More...
 
const SHAPE_POLY_SETGetBoardPoly () const noexcept
 Get the current polygon of the epoxy board. More...
 
SFVEC4F GetLayerColor (PCB_LAYER_ID aLayerId) const
 Get the technical color of a layer. More...
 
SFVEC4F GetItemColor (int aItemId) const
 Get the technical color of a layer. More...
 
SFVEC4F GetColor (const COLOR4D &aColor) const
 
SFVEC2F GetSphericalCoord (int i) const
 
float GetLayerTopZPos (PCB_LAYER_ID aLayerId) const noexcept
 Get the top z position. More...
 
float GetLayerBottomZPos (PCB_LAYER_ID aLayerId) const noexcept
 Get the bottom z position. More...
 
const MAP_CONTAINER_2D_BASEGetLayerMap () const noexcept
 Get the map of containers that have the objects per layer. More...
 
const BVH_CONTAINER_2DGetPlatedPadsFront () const noexcept
 
const BVH_CONTAINER_2DGetPlatedPadsBack () const noexcept
 
const MAP_CONTAINER_2D_BASEGetLayerHoleMap () const noexcept
 
const BVH_CONTAINER_2DGetThroughHoleIds () const noexcept
 
const BVH_CONTAINER_2DGetThroughHoleOds () const noexcept
 
const SHAPE_POLY_SETGetThroughHoleOdPolys () const noexcept
 Get through hole outside diameter 2D polygons. More...
 
const BVH_CONTAINER_2DGetThroughHoleAnnularRings () const noexcept
 
const SHAPE_POLY_SETGetThroughHoleAnnularRingPolys () const noexcept
 
const SHAPE_POLY_SETGetOuterNonPlatedThroughHolePoly () const noexcept
 
const BVH_CONTAINER_2DGetThroughHoleViaOds () const noexcept
 
const SHAPE_POLY_SETGetThroughHoleViaOdPolys () const noexcept
 
unsigned int GetViaCount () const noexcept
 
unsigned int GetHoleCount () const noexcept
 
float GetAverageViaHoleDiameter () const noexcept
 
float GetAverageHoleDiameter () const noexcept
 
float GetAverageTrackWidth () const noexcept
 
unsigned int GetCircleSegmentCount (float aDiameter3DU) const
 
unsigned int GetCircleSegmentCount (int aDiameterBIU) const
 
const MAP_POLYGetPolyMap () const noexcept
 Get map of polygon's layers. More...
 
const SHAPE_POLY_SETGetFrontPlatedPadPolys ()
 
const SHAPE_POLY_SETGetBackPlatedPadPolys ()
 
const MAP_POLYGetHoleIdPolysMap () const noexcept
 
const MAP_POLYGetHoleOdPolysMap () const noexcept
 

Public Attributes

EDA_3D_VIEWER_SETTINGSm_Cfg
 
bool m_IsBoardView
 
bool m_MousewheelPanning
 
bool m_IsPreviewer
 true if the board adaptater is living in a 3D preview panel, false for the standard 3D viewer More...
 
SFVEC4F m_BgColorBot
 background bottom color More...
 
SFVEC4F m_BgColorTop
 background top color More...
 
SFVEC4F m_BoardBodyColor
 in realistic mode: FR4 board color More...
 
SFVEC4F m_SolderMaskColorBot
 in realistic mode: solder mask color ( bot ) More...
 
SFVEC4F m_SolderMaskColorTop
 in realistic mode: solder mask color ( top ) More...
 
SFVEC4F m_SolderPasteColor
 in realistic mode: solder paste color More...
 
SFVEC4F m_SilkScreenColorBot
 in realistic mode: SilkScreen color ( bot ) More...
 
SFVEC4F m_SilkScreenColorTop
 in realistic mode: SilkScreen color ( top ) More...
 
SFVEC4F m_CopperColor
 in realistic mode: copper color More...
 

Static Public Attributes

static CUSTOM_COLORS_LIST g_SilkscreenColors
 
static CUSTOM_COLORS_LIST g_MaskColors
 
static CUSTOM_COLORS_LIST g_PasteColors
 
static CUSTOM_COLORS_LIST g_FinishColors
 
static CUSTOM_COLORS_LIST g_BoardColors
 
static KIGFX::COLOR4D g_DefaultBackgroundTop
 
static KIGFX::COLOR4D g_DefaultBackgroundBot
 
static KIGFX::COLOR4D g_DefaultSilkscreen
 
static KIGFX::COLOR4D g_DefaultSolderMask
 
static KIGFX::COLOR4D g_DefaultSolderPaste
 
static KIGFX::COLOR4D g_DefaultSurfaceFinish
 
static KIGFX::COLOR4D g_DefaultBoardBody
 

Private Member Functions

bool createBoardPolygon (wxString *aErrorMsg)
 Create the board outline polygon. More...
 
void createLayers (REPORTER *aStatusReporter)
 
void destroyLayers ()
 
void createTrack (const PCB_TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer)
 
void createPadWithMargin (const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const VECTOR2I &aMargin) const
 
OBJECT_2DcreatePadWithDrill (const PAD *aPad, int aInflateValue)
 
void addPads (const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
 
void addFootprintShapes (const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
 
void addText (const EDA_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM *aOwner)
 
void addShape (const PCB_SHAPE *aShape, CONTAINER_2D_BASE *aContainer, const BOARD_ITEM *aOwner)
 
void addShape (const PCB_DIMENSION_BASE *aDimension, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM *aOwner)
 
void addSolidAreasShapes (const ZONE *aZone, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
 
void transformArcToSegments (const VECTOR2I &aCentre, const VECTOR2I &aStart, const EDA_ANGLE &aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aOwner)
 
void buildPadOutlineAsSegments (const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aWidth)
 
void buildPadOutlineAsPolygon (const PAD *aPad, SHAPE_POLY_SET &aBuffer, int aWidth) const
 
void transformFPShapesToPolySet (const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aBuffer) const
 

Private Attributes

BOARDm_board
 
S3D_CACHEm_3dModelManager
 
RENDER_SETTINGSm_renderSettings
 
COLOR_SETTINGSm_colors
 
VECTOR2I m_boardPos
 Board center position in board internal units. More...
 
VECTOR2I m_boardSize
 Board size in board internal units. More...
 
SFVEC3F m_boardCenter
 3D center position of the board in 3D units. More...
 
BBOX_3D m_boardBoundingBox
 3D bounding box of the board in 3D units. More...
 
MAP_POLY m_layers_poly
 Amalgamated polygon contours for various types of items. More...
 
SHAPE_POLY_SETm_frontPlatedPadPolys
 
SHAPE_POLY_SETm_backPlatedPadPolys
 
MAP_POLY m_layerHoleOdPolys
 Hole outer diameters (per layer) More...
 
MAP_POLY m_layerHoleIdPolys
 Hole inner diameters (per layer) More...
 
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
 NPTH outer diameters. More...
 
SHAPE_POLY_SET m_throughHoleOdPolys
 PTH outer diameters. More...
 
SHAPE_POLY_SET m_throughHoleViaOdPolys
 Via hole outer diameters. More...
 
SHAPE_POLY_SET m_throughHoleAnnularRingPolys
 Via annular ring outer diameters. More...
 
SHAPE_POLY_SET m_board_poly
 Board outline polygon. More...
 
MAP_CONTAINER_2D_BASE m_layerMap
 2D elements for each layer. More...
 
MAP_CONTAINER_2D_BASE m_layerHoleMap
 Holes for each layer. More...
 
BVH_CONTAINER_2Dm_platedPadsFront
 
BVH_CONTAINER_2Dm_platedPadsBack
 
BVH_CONTAINER_2D m_throughHoleOds
 List of PTH outer diameters. More...
 
BVH_CONTAINER_2D m_throughHoleIds
 List of PTH inner diameters. More...
 
BVH_CONTAINER_2D m_throughHoleAnnularRings
 List of via annular rings. More...
 
BVH_CONTAINER_2D m_throughHoleViaOds
 List of via hole outer diameters. More...
 
BVH_CONTAINER_2D m_throughHoleViaIds
 List of via hole inner diameters. More...
 
unsigned int m_copperLayersCount
 
double m_biuTo3Dunits
 Scale factor to convert board internal units to 3D units normalized between -1.0 and 1.0. More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordTop
 Top (End) Z position of each layer in 3D units. More...
 
std::array< float, PCB_LAYER_ID_COUNTm_layerZcoordBottom
 Bottom (Start) Z position of each layer in 3D units. More...
 
float m_frontCopperThickness3DU
 
float m_backCopperThickness3DU
 
float m_boardBodyThickness3DU
 
float m_nonCopperLayerThickness3DU
 
float m_solderPasteLayerThickness3DU
 
unsigned int m_trackCount
 
float m_averageTrackWidth
 
unsigned int m_viaCount
 
float m_averageViaHoleDiameter
 
unsigned int m_holeCount
 
float m_averageHoleDiameter
 

Static Private Attributes

static const wxChar * m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" )
 Trace mask used to enable or disable debug output for this class. More...
 

Detailed Description

Helper class to handle information needed to display 3D board.

Definition at line 68 of file board_adapter.h.

Constructor & Destructor Documentation

◆ BOARD_ADAPTER()

BOARD_ADAPTER::BOARD_ADAPTER ( )

Definition at line 81 of file board_adapter.cpp.

81 :
82 m_Cfg( nullptr ),
83 m_IsBoardView( true ),
84 m_MousewheelPanning( true ),
85 m_IsPreviewer( false ),
86 m_board( nullptr ),
87 m_3dModelManager( nullptr ),
88 m_renderSettings( nullptr ),
89 m_colors( nullptr ),
92{
93 wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
94
95 if( PgmOrNull() )
96 m_colors = Pgm().GetSettingsManager().GetColorSettings();
97
100 m_boardCenter = SFVEC3F( 0.0f );
101
103
107
109
110 m_biuTo3Dunits = 1.0;
116
117 m_trackCount = 0;
118 m_viaCount = 0;
120 m_holeCount = 0;
122 m_averageTrackWidth = 0.0f;
123
124 m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
125 m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
126 m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
127 m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
128 m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
129 m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
130 m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
131 m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
132 m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
133
134 m_platedPadsFront = nullptr;
135 m_platedPadsBack = nullptr;
136
137 m_frontPlatedPadPolys = nullptr;
138 m_backPlatedPadPolys = nullptr;
139
140 if( !g_ColorsLoaded )
141 {
142#define ADD_COLOR( list, r, g, b, a, name ) \
143 list.emplace_back( r/255.0, g/255.0, b/255.0, a, name )
144
145 ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
146 ADD_COLOR( g_SilkscreenColors, 20, 51, 36, 1.0, wxT( "Green" ) );
147 ADD_COLOR( g_SilkscreenColors, 181, 19, 21, 1.0, wxT( "Red" ) );
148 ADD_COLOR( g_SilkscreenColors, 2, 59, 162, 1.0, wxT( "Blue" ) );
149 ADD_COLOR( g_SilkscreenColors, 11, 11, 11, 1.0, wxT( "Black" ) );
150 ADD_COLOR( g_SilkscreenColors, 245, 245, 245, 1.0, wxT( "White" ) );
151 ADD_COLOR( g_SilkscreenColors, 32, 2, 53, 1.0, wxT( "Purple" ) );
152 ADD_COLOR( g_SilkscreenColors, 194, 195, 0, 1.0, wxT( "Yellow" ) );
153
154 ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, NotSpecifiedPrm() ); // Green
155 ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, wxT( "Green" ) );
156 ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, wxT( "Light Green" ) );
157 ADD_COLOR( g_MaskColors, 13, 104, 11, 0.83, wxT( "Saturated Green" ) );
158 ADD_COLOR( g_MaskColors, 181, 19, 21, 0.83, wxT( "Red" ) );
159 ADD_COLOR( g_MaskColors, 210, 40, 14, 0.83, wxT( "Light Red" ) );
160 ADD_COLOR( g_MaskColors, 239, 53, 41, 0.83, wxT( "Red/Orange" ) );
161 ADD_COLOR( g_MaskColors, 2, 59, 162, 0.83, wxT( "Blue" ) );
162 ADD_COLOR( g_MaskColors, 54, 79, 116, 0.83, wxT( "Light Blue 1" ) );
163 ADD_COLOR( g_MaskColors, 61, 85, 130, 0.83, wxT( "Light Blue 2" ) );
164 ADD_COLOR( g_MaskColors, 21, 70, 80, 0.83, wxT( "Green/Blue" ) );
165 ADD_COLOR( g_MaskColors, 11, 11, 11, 0.83, wxT( "Black" ) );
166 ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, wxT( "White" ) );
167 ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, wxT( "Purple" ) );
168 ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, wxT( "Light Purple" ) );
169 ADD_COLOR( g_MaskColors, 194, 195, 0, 0.83, wxT( "Yellow" ) );
170
171 ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, wxT( "Grey" ) );
172 ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, wxT( "Dark Grey" ) );
173 ADD_COLOR( g_PasteColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
174
175 ADD_COLOR( g_FinishColors, 184, 115, 50, 1.0, wxT( "Copper" ) );
176 ADD_COLOR( g_FinishColors, 178, 156, 0, 1.0, wxT( "Gold" ) );
177 ADD_COLOR( g_FinishColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
178 ADD_COLOR( g_FinishColors, 160, 160, 160, 1.0, wxT( "Tin" ) );
179
180 ADD_COLOR( g_BoardColors, 51, 43, 22, 0.83, wxT( "FR4 natural, dark" ) );
181 ADD_COLOR( g_BoardColors, 109, 116, 75, 0.83, wxT( "FR4 natural" ) );
182 ADD_COLOR( g_BoardColors, 252, 252, 250, 0.90, wxT( "PTFE natural" ) );
183 ADD_COLOR( g_BoardColors, 205, 130, 0, 0.68, wxT( "Polyimide" ) );
184 ADD_COLOR( g_BoardColors, 92, 17, 6, 0.90, wxT( "Phenolic natural" ) );
185 ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 1" ) );
186 ADD_COLOR( g_BoardColors, 160, 123, 54, 0.83, wxT( "Brown 2" ) );
187 ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 3" ) );
188 ADD_COLOR( g_BoardColors, 213, 213, 213, 1.0, wxT( "Aluminum" ) );
189
190 g_DefaultBackgroundTop = COLOR4D( 0.80, 0.80, 0.90, 1.0 );
191 g_DefaultBackgroundBot = COLOR4D( 0.40, 0.40, 0.50, 1.0 );
192
193 g_DefaultSilkscreen = COLOR4D( 0.94, 0.94, 0.94, 1.0 );
194 g_DefaultSolderMask = COLOR4D( 0.08, 0.20, 0.14, 0.83 );
195 g_DefaultSolderPaste = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
196 g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
197 g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
198
199 g_ColorsLoaded = true;
200 }
201#undef ADD_COLOR
202}
#define SOLDERPASTE_LAYER_THICKNESS
#define ADD_COLOR(list, r, g, b, a, name)
#define DEFAULT_TECH_LAYER_THICKNESS
#define DEFAULT_BOARD_THICKNESS
static bool g_ColorsLoaded
#define DEFAULT_COPPER_THICKNESS
SFVEC4F m_BgColorTop
background top color
float m_solderPasteLayerThickness3DU
S3D_CACHE * m_3dModelManager
VECTOR2I m_boardPos
Board center position in board internal units.
float m_backCopperThickness3DU
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
static CUSTOM_COLORS_LIST g_PasteColors
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.
static CUSTOM_COLORS_LIST g_FinishColors
static KIGFX::COLOR4D g_DefaultBoardBody
unsigned int m_viaCount
COLOR_SETTINGS * m_colors
static KIGFX::COLOR4D g_DefaultSolderMask
BVH_CONTAINER_2D m_throughHoleOds
List of PTH outer diameters.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Bottom (Start) Z position of each layer in 3D units.
static CUSTOM_COLORS_LIST g_SilkscreenColors
BVH_CONTAINER_2D m_throughHoleIds
List of PTH inner diameters.
unsigned int m_trackCount
float m_averageTrackWidth
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of via annular rings.
bool m_IsPreviewer
true if the board adaptater is living in a 3D preview panel, false for the standard 3D viewer
static CUSTOM_COLORS_LIST g_MaskColors
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
float m_averageViaHoleDiameter
static KIGFX::COLOR4D g_DefaultBackgroundTop
float m_averageHoleDiameter
static KIGFX::COLOR4D g_DefaultSurfaceFinish
SFVEC4F m_CopperColor
in realistic mode: copper color
BVH_CONTAINER_2D * m_platedPadsBack
float m_frontCopperThickness3DU
static KIGFX::COLOR4D g_DefaultSolderPaste
float m_boardBodyThickness3DU
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Top (End) Z position of each layer in 3D units.
static CUSTOM_COLORS_LIST g_BoardColors
VECTOR2I m_boardSize
Board size in board internal units.
SHAPE_POLY_SET * m_backPlatedPadPolys
EDA_3D_VIEWER_SETTINGS * m_Cfg
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
float m_nonCopperLayerThickness3DU
RENDER_SETTINGS * m_renderSettings
unsigned int m_holeCount
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
unsigned int m_copperLayersCount
bool m_MousewheelPanning
static KIGFX::COLOR4D g_DefaultSilkscreen
BVH_CONTAINER_2D * m_platedPadsFront
SFVEC3F m_boardCenter
3D center position of the board in 3D units.
static KIGFX::COLOR4D g_DefaultBackgroundBot
double m_biuTo3Dunits
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
SFVEC4F m_BgColorBot
background bottom color
SHAPE_POLY_SET * m_frontPlatedPadPolys
void Clear() override
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
Definition: cvpcb.cpp:125
static const wxChar * m_logTrace
Trace mask used to enable or disable debug output for this class.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
wxString NotSpecifiedPrm()
void Reset()
Reset the bounding box to zero and de-initialize it.
Definition: bbox_3d.cpp:95
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
glm::vec4 SFVEC4F
Definition: xv3d_types.h:46

References ADD_COLOR, BVH_CONTAINER_2D::Clear(), DEFAULT_BOARD_THICKNESS, DEFAULT_COPPER_THICKNESS, DEFAULT_TECH_LAYER_THICKNESS, g_BoardColors, g_ColorsLoaded, g_DefaultBackgroundBot, g_DefaultBackgroundTop, g_DefaultBoardBody, g_DefaultSilkscreen, g_DefaultSolderMask, g_DefaultSolderPaste, g_DefaultSurfaceFinish, g_FinishColors, g_MaskColors, g_PasteColors, g_SilkscreenColors, m_averageHoleDiameter, m_averageTrackWidth, m_averageViaHoleDiameter, m_backCopperThickness3DU, m_backPlatedPadPolys, m_BgColorBot, m_BgColorTop, m_biuTo3Dunits, m_BoardBodyColor, m_boardBodyThickness3DU, m_boardBoundingBox, m_boardCenter, m_boardPos, m_boardSize, m_colors, m_CopperColor, m_copperLayersCount, m_frontCopperThickness3DU, m_frontPlatedPadPolys, m_holeCount, m_logTrace, m_nonCopperLayerThickness3DU, m_platedPadsBack, m_platedPadsFront, m_SilkScreenColorBot, m_SilkScreenColorTop, m_SolderMaskColorBot, m_SolderMaskColorTop, m_SolderPasteColor, m_solderPasteLayerThickness3DU, m_throughHoleAnnularRings, m_throughHoleIds, m_throughHoleOds, m_trackCount, m_viaCount, NotSpecifiedPrm(), Pgm(), PgmOrNull(), BBOX_3D::Reset(), and SOLDERPASTE_LAYER_THICKNESS.

◆ ~BOARD_ADAPTER()

BOARD_ADAPTER::~BOARD_ADAPTER ( )

Definition at line 205 of file board_adapter.cpp.

206{
208}

References destroyLayers().

Member Function Documentation

◆ addFootprintShapes()

void BOARD_ADAPTER::addFootprintShapes ( const FOOTPRINT aFootprint,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId 
)
private

Definition at line 177 of file create_3Dgraphic_brd_items.cpp.

179{
181
182 if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
183 addText( &aFootprint->Reference(), aContainer, &aFootprint->Reference() );
184
185 if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
186 addText( &aFootprint->Value(), aContainer, &aFootprint->Value() );
187
188 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
189 {
190 switch( item->Type() )
191 {
192 case PCB_FP_TEXT_T:
193 {
194 FP_TEXT* text = static_cast<FP_TEXT*>( item );
195
196 if( text->GetLayer() == aLayerId && text->IsVisible() )
197 addText( text, aContainer, text );
198
199 break;
200 }
201
202 case PCB_FP_TEXTBOX_T:
203 {
204 FP_TEXTBOX* textbox = static_cast<FP_TEXTBOX*>( item );
205
206 if( textbox->GetLayer() == aLayerId )
207 {
208 addShape( textbox, aContainer, aFootprint );
209 addText( textbox, aContainer, aFootprint );
210 }
211
212 break;
213 }
214
220 {
221 PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
222
223 if( dimension->GetLayer() == aLayerId )
224 addShape( dimension, aContainer, aFootprint );
225
226 break;
227 }
228
229 case PCB_FP_SHAPE_T:
230 {
231 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
232
233 if( shape->GetLayer() == aLayerId )
234 addShape( shape, aContainer, aFootprint );
235
236 break;
237 }
238
239 default:
240 break;
241 }
242 }
243}
void addShape(const PCB_SHAPE *aShape, CONTAINER_2D_BASE *aContainer, const BOARD_ITEM *aOwner)
void addText(const EDA_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM *aOwner)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
virtual bool IsVisible() const
Definition: eda_text.h:129
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:568
Abstract dimension API.
Definition: pcb_dimension.h:96
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92

References addShape(), addText(), BOARD_ITEM::GetLayer(), FOOTPRINT::GraphicalItems(), EDA_TEXT::IsVisible(), PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, FOOTPRINT::Reference(), text, and FOOTPRINT::Value().

Referenced by createLayers().

◆ addPads()

void BOARD_ADAPTER::addPads ( const FOOTPRINT aFootprint,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId,
bool  aSkipNPTHPadsWihNoCopper,
bool  aSkipPlatedPads,
bool  aSkipNonPlatedPads 
)
private

Definition at line 459 of file create_3Dgraphic_brd_items.cpp.

462{
463 for( PAD* pad : aFootprint->Pads() )
464 {
465 if( !pad->IsOnLayer( aLayerId ) )
466 continue;
467
468 // Skip pad annulus when not connected on this layer (if removing is enabled)
469 if( !pad->FlashLayer( aLayerId ) && IsCopperLayer( aLayerId ) )
470 continue;
471
472 // NPTH pads are not drawn on layers if the shape size and pos is the same as their hole:
473 if( aSkipNPTHPadsWihNoCopper && ( pad->GetAttribute() == PAD_ATTRIB::NPTH ) )
474 {
475 if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == wxPoint( 0, 0 ) )
476 {
477 switch( pad->GetShape() )
478 {
480 if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
481 continue;
482
483 break;
484
485 case PAD_SHAPE::OVAL:
486 if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
487 continue;
488
489 break;
490
491 default:
492 break;
493 }
494 }
495 }
496
497 VECTOR2I margin( 0, 0 );
498
499 switch( aLayerId )
500 {
501 case F_Cu:
502 if( aSkipPlatedPads && pad->FlashLayer( F_Mask ) )
503 continue;
504
505 if( aSkipNonPlatedPads && !pad->FlashLayer( F_Mask ) )
506 continue;
507
508 break;
509
510 case B_Cu:
511 if( aSkipPlatedPads && pad->FlashLayer( B_Mask ) )
512 continue;
513
514 if( aSkipNonPlatedPads && !pad->FlashLayer( B_Mask ) )
515 continue;
516
517 break;
518
519 case F_Mask:
520 case B_Mask:
521 margin.x += pad->GetSolderMaskExpansion();
522 margin.y += pad->GetSolderMaskExpansion();
523 break;
524
525 case F_Paste:
526 case B_Paste:
527 margin += pad->GetSolderPasteMargin();
528 break;
529
530 default:
531 break;
532 }
533
534 createPadWithMargin( pad, aContainer, aLayerId, margin );
535 }
536}
void createPadWithMargin(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayer, const VECTOR2I &aMargin) const
PADS & Pads()
Definition: footprint.h:170
Definition: pad.h:59
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
@ F_Paste
Definition: layer_ids.h:101
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ B_Paste
Definition: layer_ids.h:100
@ F_Cu
Definition: layer_ids.h:64
@ NPTH
like PAD_PTH, but not plated
@ PAD_DRILL_SHAPE_CIRCLE
Definition: pad_shapes.h:70

References B_Cu, B_Mask, B_Paste, CIRCLE, createPadWithMargin(), F_Cu, F_Mask, F_Paste, IsCopperLayer(), NPTH, OVAL, pad, PAD_DRILL_SHAPE_CIRCLE, FOOTPRINT::Pads(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ addShape() [1/2]

void BOARD_ADAPTER::addShape ( const PCB_DIMENSION_BASE aDimension,
CONTAINER_2D_BASE aDstContainer,
const BOARD_ITEM aOwner 
)
private

Definition at line 140 of file create_3Dgraphic_brd_items.cpp.

142{
143 addText( &aDimension->Text(), aContainer, aDimension );
144
145 const int linewidth = aDimension->GetLineThickness();
146
147 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
148 {
149 switch( shape->Type() )
150 {
151 case SH_SEGMENT:
152 {
153 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
154
155 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( seg.A ), TO_SFVEC2F( seg.B ),
156 TO_3DU( linewidth ), *aOwner ) );
157 break;
158 }
159
160 case SH_CIRCLE:
161 {
162 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
163 int delta = aDimension->GetLineThickness() / 2;
164
165 aContainer->Add( new RING_2D( TO_SFVEC2F( shape->Centre() ), TO_3DU( radius - delta ),
166 TO_3DU( radius + delta ), *aOwner ) );
167 break;
168 }
169
170 default:
171 break;
172 }
173 }
174}
int GetLineThickness() const
PCB_TEXT & Text()
const std::vector< std::shared_ptr< SHAPE > > & GetShapes() const
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
#define TO_3DU(x)
#define TO_SFVEC2F(vec)
@ SH_CIRCLE
circle
Definition: shape.h:47
@ SH_SEGMENT
line segment
Definition: shape.h:45
constexpr int delta

References SEG::A, CONTAINER_2D_BASE::Add(), addText(), SEG::B, delta, PCB_DIMENSION_BASE::GetLineThickness(), PCB_DIMENSION_BASE::GetShapes(), SH_CIRCLE, SH_SEGMENT, PCB_DIMENSION_BASE::Text(), TO_3DU, and TO_SFVEC2F.

◆ addShape() [2/2]

void BOARD_ADAPTER::addShape ( const PCB_SHAPE aShape,
CONTAINER_2D_BASE aContainer,
const BOARD_ITEM aOwner 
)
private

Definition at line 594 of file create_3Dgraphic_brd_items.cpp.

596{
597 // The full width of the lines to create
598 // The extra 1 protects the inner/outer radius values from degeneracy
599 const int linewidth = aShape->GetWidth() + 1;
600 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
601
602 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
603 {
604 switch( aShape->GetShape() )
605 {
606 case SHAPE_T::CIRCLE:
607 {
608 const SFVEC2F center3DU = TO_SFVEC2F( aShape->GetCenter() );
609 float inner_radius3DU = TO_3DU( aShape->GetRadius() - linewidth / 2 );
610 float outer_radius3DU = TO_3DU( aShape->GetRadius() + linewidth / 2 );
611
612 if( inner_radius3DU < 0 )
613 inner_radius3DU = 0;
614
615 if( aShape->IsFilled() )
616 aContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius3DU, *aOwner ) );
617 else
618 aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU, *aOwner ) );
619
620 break;
621 }
622
623 case SHAPE_T::RECT:
624 if( aShape->IsFilled() )
625 {
626 SHAPE_POLY_SET polyList;
627
629 ERROR_INSIDE );
630
632
633 ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
634 }
635 else
636 {
637 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
638
639 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[0] ), TO_SFVEC2F( pts[1] ),
640 TO_3DU( linewidth ), *aOwner ) );
641 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[1] ), TO_SFVEC2F( pts[2] ),
642 TO_3DU( linewidth ), *aOwner ) );
643 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[2] ), TO_SFVEC2F( pts[3] ),
644 TO_3DU( linewidth ), *aOwner ) );
645 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[3] ), TO_SFVEC2F( pts[0] ),
646 TO_3DU( linewidth ), *aOwner ) );
647 }
648 break;
649
650 case SHAPE_T::ARC:
651 {
652 unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
653
654 transformArcToSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
655 segCount, linewidth, aContainer, *aOwner );
656 }
657 break;
658
659 case SHAPE_T::SEGMENT:
660 {
661 const SFVEC2F start3DU = TO_SFVEC2F( aShape->GetStart() );
662 const SFVEC2F end3DU = TO_SFVEC2F( aShape->GetEnd() );
663 const double linewidth3DU = TO_3DU( linewidth );
664
665 if( Is_segment_a_circle( start3DU, end3DU ) )
666 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, linewidth3DU / 2, *aOwner ) );
667 else
668 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth3DU, *aOwner ) );
669 }
670 break;
671
672 case SHAPE_T::BEZIER:
673 case SHAPE_T::POLY:
674 {
675 SHAPE_POLY_SET polyList;
676
678 ERROR_INSIDE );
679
680 if( polyList.IsEmpty() ) // Just for caution
681 break;
682
683 ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
684 }
685 break;
686
687 default:
688 wxFAIL_MSG( wxT( "BOARD_ADAPTER::addShape no implementation for " )
689 + aShape->SHAPE_T_asString() );
690 break;
691 }
692 }
693 else
694 {
695 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
696 SFVEC2F a3DU;
697 SFVEC2F b3DU;
698 double width3DU = TO_3DU( linewidth );
699
700 const PCB_PLOT_PARAMS& plotParams = aShape->GetBoard()->GetPlotOptions();
701 KIGFX::PCB_RENDER_SETTINGS renderSettings;
702
703 renderSettings.SetDashLengthRatio( plotParams.GetDashedLineDashRatio() );
704 renderSettings.SetGapLengthRatio( plotParams.GetDashedLineGapRatio() );
705
706 for( SHAPE* shape : shapes )
707 {
708 STROKE_PARAMS::Stroke( shape, lineStyle, linewidth, &renderSettings,
709 [&]( const VECTOR2I& a, const VECTOR2I& b )
710 {
711 a3DU = TO_SFVEC2F( a );
712 b3DU = TO_SFVEC2F( b );
713
714 if( Is_segment_a_circle( a3DU, b3DU ) )
715 aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aOwner ) );
716 else
717 aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aOwner ) );
718 } );
719 }
720
721 for( SHAPE* shape : shapes )
722 delete shape;
723 }
724}
constexpr int ARC_HIGH_DEF
Definition: base_units.h:121
void transformArcToSegments(const VECTOR2I &aCentre, const VECTOR2I &aStart, const EDA_ANGLE &aArcAngle, int aCircleToSegmentsCount, int aWidth, CONTAINER_2D_BASE *aDstContainer, const BOARD_ITEM &aOwner)
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:629
int GetSizeMax() const
Definition: box2.h:200
void Add(OBJECT_2D *aObject)
Definition: container_2d.h:49
EDA_ANGLE GetArcAngle() const
Definition: eda_shape.cpp:573
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.h:289
bool IsFilled() const
Definition: eda_shape.h:90
int GetRadius() const
Definition: eda_shape.cpp:511
SHAPE_T GetShape() const
Definition: eda_shape.h:113
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1023
int GetWidth() const
Definition: eda_shape.h:109
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:75
PCB specific render settings.
Definition: pcb_painter.h:72
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
Parameters and options when plotting/printing a board.
double GetDashedLineGapRatio() const
double GetDashedLineDashRatio() const
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:101
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:67
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:388
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
Represent a set of closed polygons.
bool IsEmpty() const
void Simplify(POLYGON_MODE aFastMode)
An abstract shape on 2D plane.
Definition: shape.h:123
static void Stroke(const SHAPE *aShape, PLOT_DASH_TYPE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, std::function< void(const VECTOR2I &a, const VECTOR2I &b)> aStroker)
PLOT_DASH_TYPE GetPlotStyle() const
@ ERROR_INSIDE
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Check if segment start and end is very close to each other.
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
void ConvertPolygonToTriangles(const SHAPE_POLY_SET &aPolyList, CONTAINER_2D_BASE &aDstContainer, float aBiuTo3dUnitsScale, const BOARD_ITEM &aBoardItem)
glm::vec2 SFVEC2F
Definition: xv3d_types.h:42

References CONTAINER_2D_BASE::Add(), ARC, ARC_HIGH_DEF, BEZIER, CIRCLE, ConvertPolygonToTriangles(), ERROR_INSIDE, FIRST_TYPE, EDA_SHAPE::GetArcAngle(), BOARD_ITEM::GetBoard(), PCB_SHAPE::GetBoundingBox(), PCB_SHAPE::GetCenter(), GetCircleSegmentCount(), PCB_PLOT_PARAMS::GetDashedLineDashRatio(), PCB_PLOT_PARAMS::GetDashedLineGapRatio(), EDA_SHAPE::GetEnd(), BOARD::GetPlotOptions(), STROKE_PARAMS::GetPlotStyle(), EDA_SHAPE::GetRadius(), EDA_SHAPE::GetRectCorners(), EDA_SHAPE::GetShape(), BOX2< Vec >::GetSizeMax(), EDA_SHAPE::GetStart(), PCB_SHAPE::GetStroke(), EDA_SHAPE::GetWidth(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), EDA_SHAPE::IsFilled(), m_biuTo3Dunits, EDA_SHAPE::MakeEffectiveShapes(), SHAPE_POLY_SET::PM_FAST, POLY, RECT, SEGMENT, KIGFX::RENDER_SETTINGS::SetDashLengthRatio(), KIGFX::RENDER_SETTINGS::SetGapLengthRatio(), EDA_SHAPE::SHAPE_T_asString(), SHAPE_POLY_SET::Simplify(), STROKE_PARAMS::Stroke(), TO_3DU, TO_SFVEC2F, transformArcToSegments(), PCB_SHAPE::TransformShapeToPolygon(), and UNDEFINED_LAYER.

Referenced by addFootprintShapes(), and createLayers().

◆ addSolidAreasShapes()

void BOARD_ADAPTER::addSolidAreasShapes ( const ZONE aZone,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayerId 
)
private

Definition at line 727 of file create_3Dgraphic_brd_items.cpp.

729{
730 // This convert the poly in outline and holes
731 ConvertPolygonToTriangles( *aZone->GetFilledPolysList( aLayerId ), *aContainer,
732 m_biuTo3Dunits, *aZone );
733}
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:602

References ConvertPolygonToTriangles(), ZONE::GetFilledPolysList(), and m_biuTo3Dunits.

◆ addText()

void BOARD_ADAPTER::addText ( const EDA_TEXT aText,
CONTAINER_2D_BASE aDstContainer,
const BOARD_ITEM aOwner 
)
private

Definition at line 66 of file create_3Dgraphic_brd_items.cpp.

68{
70 TEXT_ATTRIBUTES attrs = aText->GetAttributes();
71 float penWidth_3DU = TO_3DU( aText->GetEffectiveTextPenWidth() );
72 KIFONT::FONT* font = aText->GetFont();
73
74 if( !font )
75 font = KIFONT::FONT::GetFont( wxEmptyString, aText->IsBold(), aText->IsItalic() );
76
77 if( aOwner && aOwner->IsKnockout() )
78 {
79 SHAPE_POLY_SET knockouts;
80
81 CALLBACK_GAL callback_gal( empty_opts,
82 // Polygon callback
83 [&]( const SHAPE_LINE_CHAIN& aPoly )
84 {
85 knockouts.AddOutline( aPoly );
86 } );
87
89 attrs.m_Angle = aText->GetDrawRotation();
90
91 callback_gal.SetIsFill( font->IsOutline() );
92 callback_gal.SetIsStroke( font->IsStroke() );
93 callback_gal.SetLineWidth( attrs.m_StrokeWidth );
94 font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs );
95
96 SHAPE_POLY_SET finalPoly;
97 int margin = attrs.m_StrokeWidth * 1.5 +
99
100 aText->TransformBoundingBoxToPolygon( &finalPoly, margin );
101 finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
103
104 ConvertPolygonToTriangles( finalPoly, *aContainer, m_biuTo3Dunits, *aOwner );
105 }
106 else
107 {
108 CALLBACK_GAL callback_gal( empty_opts,
109 // Stroke callback
110 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
111 {
112 const SFVEC2F pt1_3DU = TO_SFVEC2F( aPt1 );
113 const SFVEC2F pt2_3DU = TO_SFVEC2F( aPt2 );
114
115 if( Is_segment_a_circle( pt1_3DU, pt2_3DU ) )
116 {
117 aContainer->Add( new FILLED_CIRCLE_2D( pt1_3DU, penWidth_3DU / 2,
118 *aOwner ) );
119 }
120 else
121 {
122 aContainer->Add( new ROUND_SEGMENT_2D( pt1_3DU, pt2_3DU, penWidth_3DU,
123 *aOwner ) );
124 }
125 },
126 // Triangulation callback
127 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
128 {
129 aContainer->Add( new TRIANGLE_2D( TO_SFVEC2F( aPt1 ), TO_SFVEC2F( aPt2 ),
130 TO_SFVEC2F( aPt3 ), *aOwner ) );
131 } );
132
133 attrs.m_Angle = aText->GetDrawRotation();
134
135 font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs );
136 }
137}
virtual bool IsKnockout() const
Definition: board_item.h:250
void TransformBoundingBoxToPolygon(SHAPE_POLY_SET *aBuffer, int aClearance) const
Convert the text bounding box to a rectangular polygon depending on the text orientation,...
Definition: eda_text.cpp:945
bool IsItalic() const
Definition: eda_text.h:123
KIFONT::FONT * GetFont() const
Definition: eda_text.h:181
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:310
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:311
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:165
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
bool IsBold() const
Definition: eda_text.h:126
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false)
Definition: font.cpp:65
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:159
virtual bool IsStroke() const
Definition: font.h:112
virtual bool IsOutline() const
Definition: font.h:113
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
void Fracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Returns the margin for knockout text.
Definition: gr_text.h:97

References CONTAINER_2D_BASE::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::BooleanSubtract(), ConvertPolygonToTriangles(), KIFONT::FONT::Draw(), SHAPE_POLY_SET::Fracture(), EDA_TEXT::GetAttributes(), EDA_TEXT::GetDrawPos(), EDA_TEXT::GetDrawRotation(), EDA_TEXT::GetEffectiveTextPenWidth(), EDA_TEXT::GetFont(), KIFONT::FONT::GetFont(), GetKnockoutTextMargin(), EDA_TEXT::GetShownText(), Is_segment_a_circle(), EDA_TEXT::IsBold(), EDA_TEXT::IsItalic(), BOARD_ITEM::IsKnockout(), KIFONT::FONT::IsOutline(), KIFONT::FONT::IsStroke(), TEXT_ATTRIBUTES::m_Angle, m_biuTo3Dunits, TEXT_ATTRIBUTES::m_Size, TEXT_ATTRIBUTES::m_StrokeWidth, SHAPE_POLY_SET::PM_FAST, TO_3DU, TO_SFVEC2F, and EDA_TEXT::TransformBoundingBoxToPolygon().

Referenced by addFootprintShapes(), addShape(), and createLayers().

◆ BiuTo3dUnits()

double BOARD_ADAPTER::BiuTo3dUnits ( ) const
inlinenoexcept

◆ buildPadOutlineAsPolygon()

void BOARD_ADAPTER::buildPadOutlineAsPolygon ( const PAD aPad,
SHAPE_POLY_SET aBuffer,
int  aWidth 
) const
private

Definition at line 41 of file create_layer_poly.cpp.

43{
44 int maxError = m_board->GetDesignSettings().m_MaxError;
45
46 if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
47 {
48 TransformRingToPolygon( aBuffer, aPad->ShapePos(), aPad->GetSize().x / 2, aWidth, maxError,
50 return;
51 }
52
53 // For other shapes, add outlines as thick segments in polygon buffer
54 const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
55 const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
56
57 for( int ii = 0; ii < path.PointCount(); ++ii )
58 {
59 const VECTOR2I& a = path.CPoint( ii );
60 const VECTOR2I& b = path.CPoint( ii + 1 );
61
62 TransformOvalToPolygon( aBuffer, a, b, aWidth, maxError, ERROR_INSIDE );
63 }
64}
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:643
VECTOR2I ShapePos() const
Definition: pad.cpp:757
PAD_SHAPE GetShape() const
Definition: pad.h:189
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:348
const VECTOR2I & GetSize() const
Definition: pad.h:252
void TransformRingToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aCentre, int aRadius, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arcs to multiple straight segments.
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.

References CIRCLE, ERROR_INSIDE, BOARD::GetDesignSettings(), PAD::GetEffectivePolygon(), PAD::GetShape(), PAD::GetSize(), m_board, BOARD_DESIGN_SETTINGS::m_MaxError, path, PAD::ShapePos(), TransformOvalToPolygon(), TransformRingToPolygon(), and VECTOR2< T >::x.

◆ buildPadOutlineAsSegments()

void BOARD_ADAPTER::buildPadOutlineAsSegments ( const PAD aPad,
CONTAINER_2D_BASE aDstContainer,
int  aWidth 
)
private

Definition at line 736 of file create_3Dgraphic_brd_items.cpp.

738{
739 if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
740 {
741 const SFVEC2F center3DU = TO_SFVEC2F( aPad->ShapePos() );
742 const int radius = aPad->GetSize().x / 2;
743 const float inner_radius3DU = TO_3DU( radius - aWidth / 2 );
744 const float outer_radius3DU = TO_3DU( radius + aWidth / 2 );
745
746 aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU, *aPad ) );
747
748 return;
749 }
750
751 // For other shapes, add outlines as thick segments in polygon buffer
752 const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
753 const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
754
755 for( int j = 0; j < path.PointCount(); j++ )
756 {
757 SFVEC2F start3DU = TO_SFVEC2F( path.CPoint( j ) );
758 SFVEC2F end3DU = TO_SFVEC2F( path.CPoint( j + 1 ) );
759
760 if( Is_segment_a_circle( start3DU, end3DU ) )
761 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), *aPad ) );
762 else
763 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), *aPad ) );
764 }
765}

References CONTAINER_2D_BASE::Add(), CIRCLE, PAD::GetEffectivePolygon(), PAD::GetShape(), PAD::GetSize(), Is_segment_a_circle(), path, PAD::ShapePos(), TO_3DU, TO_SFVEC2F, and VECTOR2< T >::x.

◆ createBoardPolygon()

bool BOARD_ADAPTER::createBoardPolygon ( wxString *  aErrorMsg)
private

Create the board outline polygon.

Returns
false if the outline could not be created

Definition at line 655 of file board_adapter.cpp.

656{
658
659 if( !m_board )
660 return false;
661
662 bool success;
663
665 {
666 if( !m_board->GetFirstFootprint() )
667 {
668 if( aErrorMsg )
669 *aErrorMsg = _( "No footprint loaded." );
670
671 return false;
672 }
673
674 int chainingEpsilon = pcbIUScale.mmToIU( 0.02 ); // max dist from one endPt to next startPt
675
678 chainingEpsilon );
679
680 // Make polygon strictly simple to avoid issues (especially in 3D viewer)
682
683 if( !success && aErrorMsg )
684 {
685 *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
686 "a full analysis." );
687 }
688 }
689 else
690 {
692
693 if( !success && aErrorMsg )
694 *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
695 }
696
697 return success;
698}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
bool BuildFootprintPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
This function is used to extract a board outline for a footprint view.
SHAPE_POLY_SET m_board_poly
Board outline polygon.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
Definition: board.h:295
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:397
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition: board.cpp:1911
#define _(s)
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

References _, BuildFootprintPolygonOutlines(), BOARD::GetBoardPolygonOutlines(), BOARD::GetDesignSettings(), BOARD::GetFirstFootprint(), BOARD::IsFootprintHolder(), m_board, m_board_poly, BOARD_DESIGN_SETTINGS::m_MaxError, EDA_IU_SCALE::mmToIU(), pcbIUScale, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_POLY_SET::RemoveAllContours(), and SHAPE_POLY_SET::Simplify().

Referenced by InitSettings().

◆ createLayers()

void BOARD_ADAPTER::createLayers ( REPORTER aStatusReporter)
private

Definition at line 124 of file create_layer_items.cpp.

125{
127
128 // Build Copper layers
129 // Based on:
130 // https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
131
132#ifdef PRINT_STATISTICS_3D_VIEWER
133 unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
134
135 unsigned start_Time = stats_startCopperLayersTime;
136#endif
137
140
141 m_trackCount = 0;
143 m_viaCount = 0;
145 m_holeCount = 0;
147
148 if( !m_board )
149 return;
150
151 // Prepare track list, convert in a vector. Calc statistic for the holes
152 std::vector<const PCB_TRACK*> trackList;
153 trackList.clear();
154 trackList.reserve( m_board->Tracks().size() );
155
156 int maxError = m_board->GetDesignSettings().m_MaxError;
157
158 for( PCB_TRACK* track : m_board->Tracks() )
159 {
160 if( !Is3dLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
161 continue;
162
163 // Note: a PCB_TRACK holds normal segment tracks and also vias circles (that have also
164 // drill values)
165 trackList.push_back( track );
166
167 if( track->Type() == PCB_VIA_T )
168 {
169 const PCB_VIA *via = static_cast< const PCB_VIA*>( track );
170 m_viaCount++;
171 m_averageViaHoleDiameter += via->GetDrillValue() * m_biuTo3Dunits;
172 }
173 else
174 {
175 m_trackCount++;
176 }
177
178 m_averageTrackWidth += track->GetWidth() * m_biuTo3Dunits;
179 }
180
181 if( m_trackCount )
183
184 if( m_viaCount )
186
187 // Prepare copper layers index and containers
188 std::vector<PCB_LAYER_ID> layer_ids;
189 layer_ids.clear();
190 layer_ids.reserve( m_copperLayersCount );
191
192 for( unsigned i = 0; i < arrayDim( cu_seq ); ++i )
193 cu_seq[i] = ToLAYER_ID( B_Cu - i );
194
195 for( LSEQ cu = cu_set.Seq( cu_seq, arrayDim( cu_seq ) ); cu; ++cu )
196 {
197 const PCB_LAYER_ID layer = *cu;
198
199 if( !Is3dLayerEnabled( layer ) ) // Skip non enabled layers
200 continue;
201
202 layer_ids.push_back( layer );
203
204 BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
205 m_layerMap[layer] = layerContainer;
206
209 {
210 SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
211 m_layers_poly[layer] = layerPoly;
212 }
213 }
214
216 {
219
222
223 }
224
225 if( aStatusReporter )
226 aStatusReporter->Report( _( "Create tracks and vias" ) );
227
228 // Create tracks as objects and add it to container
229 for( PCB_LAYER_ID layer : layer_ids )
230 {
231 wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
232
233 BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
234
235 for( const PCB_TRACK* track : trackList )
236 {
237 // NOTE: Vias can be on multiple layers
238 if( !track->IsOnLayer( layer ) )
239 continue;
240
241 // Skip vias annulus when not connected on this layer (if removing is enabled)
242 const PCB_VIA *via = dyn_cast< const PCB_VIA*>( track );
243
244 if( via && IsCopperLayer( layer ) && !via->FlashLayer( layer ) )
245 continue;
246
247 // Add object item to layer container
248 createTrack( track, layerContainer );
249 }
250 }
251
252 // Create VIAS and THTs objects and add it to holes containers
253 for( PCB_LAYER_ID layer : layer_ids )
254 {
255 // ADD TRACKS
256 unsigned int nTracks = trackList.size();
257
258 for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
259 {
260 const PCB_TRACK *track = trackList[trackIdx];
261
262 if( !track->IsOnLayer( layer ) )
263 continue;
264
265 // ADD VIAS and THT
266 if( track->Type() == PCB_VIA_T )
267 {
268 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
269 const VIATYPE viatype = via->GetViaType();
270 const float holediameter = via->GetDrillValue() * BiuTo3dUnits();
271
272 // holes and layer copper extend half info cylinder wall to hide transition
273 const float thickness = GetHolePlatingThickness() * BiuTo3dUnits() / 2.0f;
274 const float hole_inner_radius = holediameter / 2.0f;
275 const float ring_radius = via->GetWidth() * BiuTo3dUnits() / 2.0f;
276
277 const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
278 -via->GetStart().y * m_biuTo3Dunits );
279
280 if( viatype != VIATYPE::THROUGH )
281 {
282
283 // Add hole objects
284 BVH_CONTAINER_2D *layerHoleContainer = nullptr;
285
286 // Check if the layer is already created
287 if( m_layerHoleMap.find( layer ) == m_layerHoleMap.end() )
288 {
289 // not found, create a new container
290 layerHoleContainer = new BVH_CONTAINER_2D;
291 m_layerHoleMap[layer] = layerHoleContainer;
292 }
293 else
294 {
295 // found
296 layerHoleContainer = m_layerHoleMap[layer];
297 }
298
299 // Add a hole for this layer
300 layerHoleContainer->Add( new FILLED_CIRCLE_2D( via_center,
301 hole_inner_radius + thickness,
302 *track ) );
303 }
304 else if( layer == layer_ids[0] ) // it only adds once the THT holes
305 {
306 // Add through hole object
307 m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
308 hole_inner_radius + thickness,
309 *track ) );
311 hole_inner_radius + thickness,
312 *track ) );
313
315 {
317 ring_radius,
318 *track ) );
319 }
320
321 m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius,
322 *track ) );
323 }
324 }
325 }
326 }
327
328 // Create VIAS and THTs objects and add it to holes containers
329 for( PCB_LAYER_ID layer : layer_ids )
330 {
331 // ADD TRACKS
332 const unsigned int nTracks = trackList.size();
333
334 for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
335 {
336 const PCB_TRACK *track = trackList[trackIdx];
337
338 if( !track->IsOnLayer( layer ) )
339 continue;
340
341 // ADD VIAS and THT
342 if( track->Type() == PCB_VIA_T )
343 {
344 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
345 const VIATYPE viatype = via->GetViaType();
346
347 if( viatype != VIATYPE::THROUGH )
348 {
349 // Add PCB_VIA hole contours
350
351 // Add outer holes of VIAs
352 SHAPE_POLY_SET *layerOuterHolesPoly = nullptr;
353 SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
354
355 // Check if the layer is already created
356 if( m_layerHoleOdPolys.find( layer ) == m_layerHoleOdPolys.end() )
357 {
358 // not found, create a new container
359 layerOuterHolesPoly = new SHAPE_POLY_SET;
360 m_layerHoleOdPolys[layer] = layerOuterHolesPoly;
361
362 wxASSERT( m_layerHoleIdPolys.find( layer ) == m_layerHoleIdPolys.end() );
363
364 layerInnerHolesPoly = new SHAPE_POLY_SET;
365 m_layerHoleIdPolys[layer] = layerInnerHolesPoly;
366 }
367 else
368 {
369 // found
370 layerOuterHolesPoly = m_layerHoleOdPolys[layer];
371
372 wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
373
374 layerInnerHolesPoly = m_layerHoleIdPolys[layer];
375 }
376
377 const int holediameter = via->GetDrillValue();
378 const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
379
380 TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
381 hole_outer_radius, maxError, ERROR_INSIDE );
382
383 TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
384 holediameter / 2, maxError, ERROR_INSIDE );
385 }
386 else if( layer == layer_ids[0] ) // it only adds once the THT holes
387 {
388 const int holediameter = via->GetDrillValue();
389 const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
390 const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
391
392 // Add through hole contours
394 hole_outer_radius, maxError, ERROR_INSIDE );
395
396 // Add same thing for vias only
398 hole_outer_radius, maxError, ERROR_INSIDE );
399
401 {
403 hole_outer_ring_radius, maxError, ERROR_INSIDE );
404 }
405 }
406 }
407 }
408 }
409
410 // Creates vertical outline contours of the tracks and add it to the poly of the layer
412 {
413 for( PCB_LAYER_ID layer : layer_ids )
414 {
415 wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
416
417 SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
418
419 // ADD TRACKS
420 unsigned int nTracks = trackList.size();
421
422 for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
423 {
424 const PCB_TRACK *track = trackList[trackIdx];
425
426 if( !track->IsOnLayer( layer ) )
427 continue;
428
429 // Skip vias annulus when not connected on this layer (if removing is enabled)
430 const PCB_VIA *via = dyn_cast<const PCB_VIA*>( track );
431
432 if( via && !via->FlashLayer( layer ) && IsCopperLayer( layer ) )
433 continue;
434
435 // Add the track/via contour
436 track->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
437 }
438 }
439 }
440
441 // Add holes of footprints
442 for( FOOTPRINT* footprint : m_board->Footprints() )
443 {
444 for( PAD* pad : footprint->Pads() )
445 {
446 const VECTOR2I padHole = pad->GetDrillSize();
447
448 if( !padHole.x ) // Not drilled pad like SMD pad
449 continue;
450
451 // The hole in the body is inflated by copper thickness, if not plated, no copper
452 const int inflate = ( pad->GetAttribute () != PAD_ATTRIB::NPTH ) ?
453 GetHolePlatingThickness() / 2 : 0;
454
455 m_holeCount++;
456 m_averageHoleDiameter += ( ( pad->GetDrillSize().x +
457 pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
458
460
463
465 }
466 }
467
468 if( m_holeCount )
470
471 // Add contours of the pad holes (pads can be Circle or Segment holes)
472 for( FOOTPRINT* footprint : m_board->Footprints() )
473 {
474 for( PAD* pad : footprint->Pads() )
475 {
476 const VECTOR2I padHole = pad->GetDrillSize();
477
478 if( !padHole.x ) // Not drilled pad like SMD pad
479 continue;
480
481 // The hole in the body is inflated by copper thickness.
482 const int inflate = GetHolePlatingThickness();
483
484 if( pad->GetAttribute () != PAD_ATTRIB::NPTH )
485 {
487 {
488 pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, inflate, maxError,
489 ERROR_INSIDE );
490 }
491
492 pad->TransformHoleToPolygon( m_throughHoleOdPolys, inflate, maxError,
493 ERROR_INSIDE );
494 }
495 else
496 {
497 // If not plated, no copper.
499 {
500 pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, 0, maxError,
501 ERROR_INSIDE );
502 }
503
504 pad->TransformHoleToPolygon( m_nonPlatedThroughHoleOdPolys, 0, maxError,
505 ERROR_INSIDE );
506 }
507 }
508 }
509
510 const bool renderPlatedPadsAsPlated = m_Cfg->m_Render.renderPlatedPadsAsPlated
512
513 // Add footprints PADs objects to containers
514 for( PCB_LAYER_ID layer : layer_ids )
515 {
516 wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
517
518 BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
519
520 // ADD PADS
521 for( FOOTPRINT* footprint : m_board->Footprints() )
522 {
523 // Note: NPTH pads are not drawn on copper layers when the pad has the same shape
524 // as its hole
525 addPads( footprint, layerContainer, layer, true, renderPlatedPadsAsPlated, false );
526
527 // Micro-wave footprints may have items on copper layers
528 addFootprintShapes( footprint, layerContainer, layer );
529 }
530 }
531
532 if( renderPlatedPadsAsPlated )
533 {
534 // ADD PLATED PADS
535 for( FOOTPRINT* footprint : m_board->Footprints() )
536 {
537 addPads( footprint, m_platedPadsFront, F_Cu, true, false, true );
538 addPads( footprint, m_platedPadsBack, B_Cu, true, false, true );
539 }
540
543 }
544
545 // Add footprints PADs poly contours (vertical outlines)
547 {
548 for( PCB_LAYER_ID layer : layer_ids )
549 {
550 wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
551
552 SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
553
554 // Add pads to polygon list
555 for( FOOTPRINT* footprint : m_board->Footprints() )
556 {
557 // Note: NPTH pads are not drawn on copper layers when the pad has same shape as
558 // its hole
559 footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE,
560 true, renderPlatedPadsAsPlated, false );
561
562 transformFPShapesToPolySet( footprint, layer, *layerPoly );
563 }
564 }
565
566 if( renderPlatedPadsAsPlated )
567 {
568 // ADD PLATED PADS contours
569 for( FOOTPRINT* footprint : m_board->Footprints() )
570 {
571 footprint->TransformPadsToPolySet( *m_frontPlatedPadPolys, F_Cu, 0, maxError,
572 ERROR_INSIDE, true, false, true );
573
574 footprint->TransformPadsToPolySet( *m_backPlatedPadPolys, B_Cu, 0, maxError,
575 ERROR_INSIDE, true, false, true );
576 }
577 }
578 }
579
580 // Add graphic item on copper layers to object containers
581 for( PCB_LAYER_ID layer : layer_ids )
582 {
583 wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
584
585 BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
586
587 // Add graphic items on copper layers (texts and other graphics)
588 for( BOARD_ITEM* item : m_board->Drawings() )
589 {
590 if( !item->IsOnLayer( layer ) )
591 continue;
592
593 switch( item->Type() )
594 {
595 case PCB_SHAPE_T:
596 addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
597 break;
598
599 case PCB_TEXT_T:
600 addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
601 break;
602
603 case PCB_TEXTBOX_T:
604 addText( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
605 addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
606 break;
607
609 case PCB_DIM_CENTER_T:
610 case PCB_DIM_RADIAL_T:
612 case PCB_DIM_LEADER_T:
613 addShape( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer, item );
614 break;
615
616 default:
617 wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
618 item->Type() );
619 break;
620 }
621 }
622 }
623
624 // Add graphic item on copper layers to poly contours (vertical outlines)
626 {
627 for( PCB_LAYER_ID layer : layer_ids )
628 {
629 wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
630
631 SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
632
633 // Add graphic items on copper layers (texts and other )
634 for( BOARD_ITEM* item : m_board->Drawings() )
635 {
636 if( !item->IsOnLayer( layer ) )
637 continue;
638
639 switch( item->Type() )
640 {
641 case PCB_SHAPE_T:
642 item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
643 break;
644
645 case PCB_TEXT_T:
646 {
647 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
648
649 text->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
650 break;
651 }
652
653 case PCB_TEXTBOX_T:
654 {
655 PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
656
657 textbox->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
658 break;
659 }
660
661 default:
662 wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
663 item->Type() );
664 break;
665 }
666 }
667 }
668 }
669
671 {
672 if( aStatusReporter )
673 aStatusReporter->Report( _( "Create zones" ) );
674
675 std::vector<std::pair<ZONE*, PCB_LAYER_ID>> zones;
676 std::unordered_map<PCB_LAYER_ID, std::unique_ptr<std::mutex>> layer_lock;
677
678 for( ZONE* zone : m_board->Zones() )
679 {
680 for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
681 {
682 zones.emplace_back( std::make_pair( zone, layer ) );
683 layer_lock.emplace( layer, std::make_unique<std::mutex>() );
684 }
685 }
686
687 // Add zones objects
688 std::atomic<size_t> nextZone( 0 );
689 std::atomic<size_t> threadsFinished( 0 );
690
691 size_t parallelThreadCount = std::min<size_t>( zones.size(),
692 std::max<size_t>( std::thread::hardware_concurrency(), 2 ) );
693
694 for( size_t ii = 0; ii < parallelThreadCount; ++ii )
695 {
696 std::thread t = std::thread( [&]()
697 {
698 for( size_t areaId = nextZone.fetch_add( 1 );
699 areaId < zones.size();
700 areaId = nextZone.fetch_add( 1 ) )
701 {
702 ZONE* zone = zones[areaId].first;
703
704 if( zone == nullptr )
705 break;
706
707 PCB_LAYER_ID layer = zones[areaId].second;
708
709 auto layerContainer = m_layerMap.find( layer );
710 auto layerPolyContainer = m_layers_poly.find( layer );
711
712 if( layerContainer != m_layerMap.end() )
713 addSolidAreasShapes( zone, layerContainer->second, layer );
714
715 if( m_Cfg->m_Render.opengl_copper_thickness
716 && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL
717 && layerPolyContainer != m_layers_poly.end() )
718 {
719 auto mut_it = layer_lock.find( layer );
720
721 std::lock_guard< std::mutex > lock( *( mut_it->second ) );
722 zone->TransformSolidAreasShapesToPolygon( layer, *layerPolyContainer->second );
723 }
724 }
725
726 threadsFinished++;
727 } );
728
729 t.detach();
730 }
731
732 while( threadsFinished < parallelThreadCount )
733 std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
734
735 }
736
737 // Simplify layer polygons
738
739 if( aStatusReporter )
740 aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
741
743 {
744 if( renderPlatedPadsAsPlated )
745 {
746 if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
747 {
748 if( aStatusReporter )
749 aStatusReporter->Report( _( "Simplifying polygons on F_Cu" ) );
750
751 SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
753
755 }
756
757 if( m_backPlatedPadPolys && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
758 {
759 if( aStatusReporter )
760 aStatusReporter->Report( _( "Simplifying polygons on B_Cu" ) );
761
762 SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
764
766 }
767 }
768
769 std::vector<PCB_LAYER_ID> &selected_layer_id = layer_ids;
770 std::vector<PCB_LAYER_ID> layer_id_without_F_and_B;
771
772 if( renderPlatedPadsAsPlated )
773 {
774 layer_id_without_F_and_B.clear();
775 layer_id_without_F_and_B.reserve( layer_ids.size() );
776
777 for( PCB_LAYER_ID layer: layer_ids )
778 {
779 if( layer != F_Cu && layer != B_Cu )
780 layer_id_without_F_and_B.push_back( layer );
781 }
782
783 selected_layer_id = layer_id_without_F_and_B;
784 }
785
786 if( selected_layer_id.size() > 0 )
787 {
788 if( aStatusReporter )
789 {
790 aStatusReporter->Report( wxString::Format( _( "Simplifying %d copper layers" ),
791 (int) selected_layer_id.size() ) );
792 }
793
794 std::atomic<size_t> nextItem( 0 );
795 std::atomic<size_t> threadsFinished( 0 );
796
797 size_t parallelThreadCount = std::min<size_t>(
798 std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
799 selected_layer_id.size() );
800
801 for( size_t ii = 0; ii < parallelThreadCount; ++ii )
802 {
803 std::thread t = std::thread(
804 [&nextItem, &threadsFinished, &selected_layer_id, this]()
805 {
806 for( size_t i = nextItem.fetch_add( 1 );
807 i < selected_layer_id.size();
808 i = nextItem.fetch_add( 1 ) )
809 {
810 auto layerPoly = m_layers_poly.find( selected_layer_id[i] );
811
812 if( layerPoly != m_layers_poly.end() )
813 // This will make a union of all added contours
814 layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
815 }
816
817 threadsFinished++;
818 } );
819
820 t.detach();
821 }
822
823 while( threadsFinished < parallelThreadCount )
824 std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
825 }
826 }
827
828 // Simplify holes polygon contours
829 if( aStatusReporter )
830 aStatusReporter->Report( _( "Simplify holes contours" ) );
831
832 for( PCB_LAYER_ID layer : layer_ids )
833 {
834 if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
835 {
836 // found
837 SHAPE_POLY_SET *polyLayer = m_layerHoleOdPolys[layer];
838 polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
839
840 wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
841
842 polyLayer = m_layerHoleIdPolys[layer];
843 polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
844 }
845 }
846
847 // End Build Copper layers
848
849 // This will make a union of all added contours
854
855 // Build Tech layers
856 // Based on:
857 // https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
858 if( aStatusReporter )
859 aStatusReporter->Report( _( "Build Tech layers" ) );
860
861 // draw graphic items, on technical layers
862
863 // Vertical walls (layer thickness) around shapes is really time consumming
864 // They are built on request
865 bool buildVerticalWallsForTechLayers = m_Cfg->m_Render.opengl_copper_thickness
867
868 static const PCB_LAYER_ID techLayerList[] = {
869 B_Adhes,
870 F_Adhes,
871 B_Paste,
872 F_Paste,
873 B_SilkS,
874 F_SilkS,
875 B_Mask,
876 F_Mask,
877
878 // Aux Layers
879 Dwgs_User,
880 Cmts_User,
881 Eco1_User,
882 Eco2_User,
883 Edge_Cuts,
884 Margin
885 };
886
887 // User layers are not drawn here, only technical layers
888 for( LSEQ seq = LSET::AllNonCuMask().Seq( techLayerList, arrayDim( techLayerList ) );
889 seq;
890 ++seq )
891 {
892 const PCB_LAYER_ID layer = *seq;
893
894 if( !Is3dLayerEnabled( layer ) )
895 continue;
896
897 if( aStatusReporter )
898 aStatusReporter->Report( wxString::Format( _( "Build Tech layer %d" ), (int) layer ) );
899
900 BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
901 m_layerMap[layer] = layerContainer;
902
903 SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
904 m_layers_poly[layer] = layerPoly;
905
906 // Add drawing objects
907 for( BOARD_ITEM* item : m_board->Drawings() )
908 {
909 if( !item->IsOnLayer( layer ) )
910 continue;
911
912 switch( item->Type() )
913 {
914 case PCB_SHAPE_T:
915 addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
916 break;
917
918 case PCB_TEXT_T:
919 addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
920 break;
921
922 case PCB_TEXTBOX_T:
923 addText( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
924 addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
925 break;
926
928 case PCB_DIM_CENTER_T:
929 case PCB_DIM_RADIAL_T:
931 case PCB_DIM_LEADER_T:
932 addShape( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer, item );
933 break;
934
935 default:
936 break;
937 }
938 }
939
940 // Add drawing contours (vertical walls)
941 if( buildVerticalWallsForTechLayers )
942 {
943 for( BOARD_ITEM* item : m_board->Drawings() )
944 {
945 if( !item->IsOnLayer( layer ) )
946 continue;
947
948 switch( item->Type() )
949 {
950 case PCB_SHAPE_T:
951 item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
952 break;
953
954 case PCB_TEXT_T:
955 {
956 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
957
958 text->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
959 break;
960 }
961
962 case PCB_TEXTBOX_T:
963 {
964 PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
965
966 textbox->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
967 break;
968 }
969
970 default:
971 break;
972 }
973 }
974 }
975
976 // Add footprints tech layers - objects
977 for( FOOTPRINT* footprint : m_board->Footprints() )
978 {
979 if( layer == F_SilkS || layer == B_SilkS )
980 {
982
983 for( PAD* pad : footprint->Pads() )
984 {
985 if( !pad->IsOnLayer( layer ) )
986 continue;
987
988 buildPadOutlineAsSegments( pad, layerContainer, linewidth );
989 }
990 }
991 else
992 {
993 addPads( footprint, layerContainer, layer, false, false, false );
994 }
995
996 addFootprintShapes( footprint, layerContainer, layer );
997 }
998
999
1000 // Add footprints tech layers - contours (vertical walls)
1001 if( buildVerticalWallsForTechLayers )
1002 {
1003 for( FOOTPRINT* footprint : m_board->Footprints() )
1004 {
1005 if( layer == F_SilkS || layer == B_SilkS )
1006 {
1008
1009 for( PAD* pad : footprint->Pads() )
1010 {
1011 if( !pad->IsOnLayer( layer ) )
1012 continue;
1013
1014 buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
1015 }
1016 }
1017 else
1018 {
1019 footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
1020 }
1021
1022 // On tech layers, use a poor circle approximation, only for texts (stroke font)
1023 footprint->TransformFPTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
1024
1025 // Add the remaining things with dynamic seg count for circles
1026 transformFPShapesToPolySet( footprint, layer, *layerPoly );
1027 }
1028 }
1029
1030 // Draw non copper zones
1032 {
1033 for( ZONE* zone : m_board->Zones() )
1034 {
1035 if( zone->IsOnLayer( layer ) )
1036 addSolidAreasShapes( zone, layerContainer, layer );
1037 }
1038
1039 if( buildVerticalWallsForTechLayers )
1040 {
1041 for( ZONE* zone : m_board->Zones() )
1042 {
1043
1044 if( zone->IsOnLayer( layer ) )
1045 zone->TransformSolidAreasShapesToPolygon( layer, *layerPoly );
1046 }
1047 }
1048 }
1049
1050 // This will make a union of all added contours
1051 layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1052 }
1053 // End Build Tech layers
1054
1055 // Build BVH (Bounding volume hierarchy) for holes and vias
1056
1057 if( aStatusReporter )
1058 aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1059
1063
1064 if( !m_layerHoleMap.empty() )
1065 {
1066 for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& hole : m_layerHoleMap )
1067 hole.second->BuildBVH();
1068 }
1069
1070 // We only need the Solder mask to initialize the BVH
1071 // because..?
1072 if( m_layerMap[B_Mask] )
1073 m_layerMap[B_Mask]->BuildBVH();
1074
1075 if( m_layerMap[F_Mask] )
1076 m_layerMap[F_Mask]->BuildBVH();
1077}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
@ LAYER_CLASS_SILK
MAP_CONTAINER_2D_BASE m_layerHoleMap
Holes for each layer.
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
void buildPadOutlineAsPolygon(const PAD *aPad, SHAPE_POLY_SET &aBuffer, int aWidth) const
void addPads(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
void addFootprintShapes(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
MAP_POLY m_layerHoleOdPolys
Hole outer diameters (per layer)
void addSolidAreasShapes(const ZONE *aZone, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
MAP_CONTAINER_2D_BASE m_layerMap
2D elements for each layer.
MAP_POLY m_layerHoleIdPolys
Hole inner diameters (per layer)
int GetHolePlatingThickness() const noexcept
Get the hole plating thickness (NB: in BOARD UNITS!).
SHAPE_POLY_SET m_throughHoleOdPolys
PTH outer diameters.
SHAPE_POLY_SET m_throughHoleViaOdPolys
Via hole outer diameters.
BVH_CONTAINER_2D m_throughHoleViaOds
List of via hole outer diameters.
SHAPE_POLY_SET m_throughHoleAnnularRingPolys
Via annular ring outer diameters.
void buildPadOutlineAsSegments(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aWidth)
void createTrack(const PCB_TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer)
MAP_POLY m_layers_poly
Amalgamated polygon contours for various types of items.
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
NPTH outer diameters.
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
void transformFPShapesToPolySet(const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aBuffer) const
OBJECT_2D * createPadWithDrill(const PAD *aPad, int aInflateValue)
int m_LineThickness[LAYER_CLASS_COUNT]
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:245
ZONES & Zones()
Definition: board.h:313
FOOTPRINTS & Footprints()
Definition: board.h:307
TRACKS & Tracks()
Definition: board.h:304
DRAWINGS & Drawings()
Definition: board.h:310
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:794
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeToPolygon Convert the track shape to a closed polygon Used in filling zones ca...
Definition: pcb_track.cpp:1177
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
#define MAX_CU_LAYERS
Definition: layer_ids.h:140
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Adhes
Definition: layer_ids.h:97
@ Edge_Cuts
Definition: layer_ids.h:113
@ Dwgs_User
Definition: layer_ids.h:109
@ Cmts_User
Definition: layer_ids.h:110
@ F_Adhes
Definition: layer_ids.h:98
@ Eco1_User
Definition: layer_ids.h:111
@ Margin
Definition: layer_ids.h:114
@ F_SilkS
Definition: layer_ids.h:104
@ Eco2_User
Definition: layer_ids.h:112
@ B_SilkS
Definition: layer_ids.h:103
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
VIATYPE
Definition: pcb_track.h:63
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109

References _, CONTAINER_2D_BASE::Add(), addFootprintShapes(), addPads(), addShape(), addText(), LSET::AllCuMask(), arrayDim(), B_Cu, BiuTo3dUnits(), BVH_CONTAINER_2D::BuildBVH(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::clip_silk_on_via_annulus, createPadWithDrill(), createTrack(), destroyLayers(), BOARD::Drawings(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::engine, ERROR_INSIDE, F_Cu, BOARD::Footprints(), BOARD::GetDesignSettings(), GetHolePlatingThickness(), GetRunningMicroSecs(), Is3dLayerEnabled(), IsCopperLayer(), BOARD_ITEM::IsOnLayer(), m_averageHoleDiameter, m_averageTrackWidth, m_averageViaHoleDiameter, m_backPlatedPadPolys, m_biuTo3Dunits, m_board, m_Cfg, m_copperLayersCount, m_frontPlatedPadPolys, m_holeCount, m_layerHoleIdPolys, m_layerHoleMap, m_layerHoleOdPolys, m_layerMap, m_layers_poly, m_logTrace, BOARD_DESIGN_SETTINGS::m_MaxError, m_nonPlatedThroughHoleOdPolys, m_platedPadsBack, m_platedPadsFront, EDA_3D_VIEWER_SETTINGS::m_Render, m_throughHoleAnnularRingPolys, m_throughHoleAnnularRings, m_throughHoleIds, m_throughHoleOdPolys, m_throughHoleOds, m_throughHoleViaOdPolys, m_throughHoleViaOds, m_trackCount, m_viaCount, MAX_CU_LAYERS, NPTH, OPENGL, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::opengl_copper_thickness, pad, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_SHAPE_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_VIA_T, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::renderPlatedPadsAsPlated, REPORTER::Report(), LSET::Seq(), EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_zones, text, THROUGH, ToLAYER_ID(), BOARD::Tracks(), TransformCircleToPolygon(), transformFPShapesToPolySet(), PCB_TRACK::TransformShapeToPolygon(), PCB_TEXTBOX::TransformTextToPolySet(), EDA_ITEM::Type(), via, VECTOR2< T >::x, and BOARD::Zones().

Referenced by InitSettings().

◆ createPadWithDrill()

OBJECT_2D * BOARD_ADAPTER::createPadWithDrill ( const PAD aPad,
int  aInflateValue 
)
private

Definition at line 433 of file create_3Dgraphic_brd_items.cpp.

434{
435 if( !aPad->HasHole() )
436 {
437 wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
438 return nullptr;
439 }
440
441 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
442
443 if( slot->GetSeg().A == slot->GetSeg().B )
444 {
445 return new FILLED_CIRCLE_2D( TO_SFVEC2F( slot->GetSeg().A ),
446 TO_3DU( slot->GetWidth() / 2 + aInflateValue ),
447 *aPad );
448 }
449 else
450 {
451 return new ROUND_SEGMENT_2D( TO_SFVEC2F( slot->GetSeg().A ),
452 TO_SFVEC2F( slot->GetSeg().B ),
453 TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
454 *aPad );
455 }
456}
bool HasHole() const override
Definition: pad.h:106
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:394

References PAD::GetEffectiveHoleShape(), PAD::HasHole(), m_logTrace, TO_3DU, and TO_SFVEC2F.

Referenced by createLayers().

◆ createPadWithMargin()

void BOARD_ADAPTER::createPadWithMargin ( const PAD aPad,
CONTAINER_2D_BASE aDstContainer,
PCB_LAYER_ID  aLayer,
const VECTOR2I aMargin 
) const
private

Definition at line 310 of file create_3Dgraphic_brd_items.cpp.

312{
313 SHAPE_POLY_SET poly;
314 int maxError = GetBoard()->GetDesignSettings().m_MaxError;
315 VECTOR2I clearance = aMargin;
316
317 // Our shape-based builder can't handle negative or differing x:y clearance values (the
318 // former are common for solder paste while the later get generated when a relative paste
319 // margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
320 // run the general-purpose polygon builder on.
321 // Of course being a hack it falls down when dealing with custom shape pads (where the size
322 // is only the size of the anchor), so for those we punt and just use aMargin.x.
323
324 if( ( clearance.x < 0 || clearance.x != clearance.y )
325 && aPad->GetShape() != PAD_SHAPE::CUSTOM )
326 {
327 VECTOR2I dummySize = VECTOR2I( aPad->GetSize() ) + clearance + clearance;
328
329 if( dummySize.x <= 0 || dummySize.y <= 0 )
330 return;
331
332 PAD dummy( *aPad );
333 dummy.SetSize( wxSize( dummySize.x, dummySize.y ) );
334 dummy.TransformShapeToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
335 clearance = { 0, 0 };
336 }
337 else
338 {
339 auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
340
341 for( const SHAPE* shape : padShapes->Shapes() )
342 {
343 switch( shape->Type() )
344 {
345 case SH_SEGMENT:
346 {
347 const SHAPE_SEGMENT* seg = static_cast<const SHAPE_SEGMENT*>( shape );
348
349 const SFVEC2F a3DU = TO_SFVEC2F( seg->GetSeg().A );
350 const SFVEC2F b3DU = TO_SFVEC2F( seg->GetSeg().B );
351 const double width3DU = TO_3DU( seg->GetWidth() + clearance.x * 2 );
352
353 // Cannot add segments that have the same start and end point
354 if( Is_segment_a_circle( a3DU, b3DU ) )
355 aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
356 else
357 aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
358 }
359 break;
360
361 case SH_CIRCLE:
362 {
363 const SHAPE_CIRCLE* circle = static_cast<const SHAPE_CIRCLE*>( shape );
364
365 const double radius3DU = TO_3DU( circle->GetRadius() + clearance.x );
366 const SFVEC2F center3DU = TO_SFVEC2F( circle->GetCenter() );
367
368 // Don't render zero radius circles
369 if( radius3DU != 0.0 )
370 aContainer->Add( new FILLED_CIRCLE_2D( center3DU, radius3DU, *aPad ) );
371 }
372 break;
373
374 case SH_RECT:
375 {
376 const SHAPE_RECT* rect = static_cast<const SHAPE_RECT*>( shape );
377
378 poly.NewOutline();
379 poly.Append( rect->GetPosition() );
380 poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
381 poly.Append( rect->GetPosition() + rect->GetSize() );
382 poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
383 }
384 break;
385
386 case SH_SIMPLE:
387 poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
388 break;
389
390 case SH_POLY_SET:
391 poly = *(SHAPE_POLY_SET*) shape;
392 break;
393
394 case SH_ARC:
395 {
396 const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( shape );
397 SHAPE_LINE_CHAIN l = arc->ConvertToPolyline( maxError );
398
399 for( int i = 0; i < l.SegmentCount(); i++ )
400 {
401 SHAPE_SEGMENT seg( l.Segment( i ).A, l.Segment( i ).B, arc->GetWidth() );
402 const SFVEC2F a3DU = TO_SFVEC2F( seg.GetSeg().A );
403 const SFVEC2F b3DU = TO_SFVEC2F( seg.GetSeg().B );
404 const double width3DU = TO_3DU( arc->GetWidth() + clearance.x * 2 );
405
406 // Cannot add segments that have the same start and end point
407 if( Is_segment_a_circle( a3DU, b3DU ) )
408 aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
409 else
410 aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
411 }
412 }
413 break;
414
415 default:
416 UNIMPLEMENTED_FOR( SHAPE_TYPE_asString( shape->Type() ) );
417 break;
418 }
419 }
420 }
421
422 if( !poly.IsEmpty() )
423 {
424 if( clearance.x )
425 poly.Inflate( clearance.x, 32 );
426
427 // Add the PAD polygon
428 ConvertPolygonToTriangles( poly, *aContainer, m_biuTo3Dunits, *aPad );
429 }
430}
const BOARD * GetBoard() const noexcept
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING flashPTHPads=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:357
int GetWidth() const
Definition: shape_arc.h:157
const SHAPE_LINE_CHAIN ConvertToPolyline(double aAccuracy=DefaultAccuracyForPCB(), double *aEffectiveAccuracy=nullptr) const
Construct a SHAPE_LINE_CHAIN of segments from a given arc.
Definition: shape_arc.cpp:464
int GetRadius() const
Definition: shape_circle.h:108
const VECTOR2I GetCenter() const
Definition: shape_circle.h:113
int SegmentCount() const
Return the number of segments in this line chain.
SEG Segment(int aIndex)
Return a copy of the aIndex-th segment in the line chain.
void Inflate(int aAmount, int aCircleSegCount, CORNER_STRATEGY aCornerStrategy=ROUND_ALL_CORNERS)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
int NewOutline()
Creates a new hole in a given outline.
const VECTOR2I & GetPosition() const
Definition: shape_rect.h:127
const VECTOR2I GetSize() const
Definition: shape_rect.h:135
const SEG & GetSeg() const
int GetWidth() const
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:42
const SHAPE_LINE_CHAIN & Vertices() const
Return the list of vertices defining this simple polygon.
Definition: shape_simple.h:124
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
@ SH_POLY_SET
set of polygons (with holes, etc.)
Definition: shape.h:49
@ SH_RECT
axis-aligned rectangle
Definition: shape.h:44
@ SH_SIMPLE
simple polygon
Definition: shape.h:48
@ SH_ARC
circular arc
Definition: shape.h:51
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Definition: shape.h:56

References SEG::A, CONTAINER_2D_BASE::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::Append(), SEG::B, ConvertPolygonToTriangles(), SHAPE_ARC::ConvertToPolyline(), CUSTOM, dummy(), ERROR_INSIDE, GetBoard(), SHAPE_CIRCLE::GetCenter(), BOARD::GetDesignSettings(), PAD::GetEffectiveShape(), SHAPE_RECT::GetPosition(), SHAPE_CIRCLE::GetRadius(), SHAPE_SEGMENT::GetSeg(), PAD::GetShape(), SHAPE_RECT::GetSize(), PAD::GetSize(), SHAPE_ARC::GetWidth(), SHAPE_SEGMENT::GetWidth(), SHAPE_POLY_SET::Inflate(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), m_biuTo3Dunits, BOARD_DESIGN_SETTINGS::m_MaxError, SHAPE_POLY_SET::NewOutline(), SHAPE_LINE_CHAIN::Segment(), SHAPE_LINE_CHAIN::SegmentCount(), SH_ARC, SH_CIRCLE, SH_POLY_SET, SH_RECT, SH_SEGMENT, SH_SIMPLE, SHAPE_TYPE_asString(), TO_3DU, TO_SFVEC2F, UNIMPLEMENTED_FOR, SHAPE_SIMPLE::Vertices(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by addPads().

◆ createTrack()

void BOARD_ADAPTER::createTrack ( const PCB_TRACK aTrack,
CONTAINER_2D_BASE aDstContainer 
)
private

Definition at line 246 of file create_3Dgraphic_brd_items.cpp.

247{
248 SFVEC2F start3DU = TO_SFVEC2F( aTrack->GetStart() );
249 SFVEC2F end3DU = TO_SFVEC2F( aTrack->GetEnd() );
250
251 switch( aTrack->Type() )
252 {
253 case PCB_VIA_T:
254 {
255 const float radius3DU = TO_3DU( aTrack->GetWidth() / 2 );
256 aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius3DU, *aTrack ) );
257 break;
258 }
259
260 case PCB_ARC_T:
261 {
262 const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
263
264 VECTOR2D center( arc->GetCenter() );
265 EDA_ANGLE arc_angle = arc->GetAngle();
266 double radius = arc->GetRadius();
267 int arcsegcount = GetArcToSegmentCount( radius, ARC_HIGH_DEF, arc_angle );
268 int circlesegcount;
269
270 // We need a circle to segment count. However, the arc angle can be small, and the
271 // radius very big. so we calculate a reasonable value for circlesegcount.
272 if( arcsegcount <= 1 ) // The arc will be approximated by a segment
273 {
274 circlesegcount = 1;
275 }
276 else
277 {
278 circlesegcount = KiROUND( arcsegcount * 360.0 / std::abs( arc_angle.AsDegrees() ) );
279 circlesegcount = std::max( 1, std::min( circlesegcount, 128 ) );
280 }
281
282 transformArcToSegments( VECTOR2I( center.x, center.y ), arc->GetStart(), arc_angle,
283 circlesegcount, arc->GetWidth(), aDstContainer, *arc );
284 break;
285 }
286
287 case PCB_TRACE_T: // Track is a usual straight segment
288 {
289 // Cannot add segments that have the same start and end point
290 if( Is_segment_a_circle( start3DU, end3DU ) )
291 {
292 aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aTrack->GetWidth() / 2 ),
293 *aTrack ) );
294 }
295 else
296 {
297 aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aTrack->GetWidth() ),
298 *aTrack ) );
299 }
300
301 break;
302 }
303
304 default:
305 break;
306 }
307}
double AsDegrees() const
Definition: eda_angle.h:149
double GetRadius() const
Definition: pcb_track.cpp:1105
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1111
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_track.h:319
int GetWidth() const
Definition: pcb_track.h:106
const VECTOR2I & GetStart() const
Definition: pcb_track.h:112
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:109
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References std::abs(), CONTAINER_2D_BASE::Add(), ARC_HIGH_DEF, EDA_ANGLE::AsDegrees(), PCB_ARC::GetAngle(), GetArcToSegmentCount(), PCB_ARC::GetCenter(), PCB_TRACK::GetEnd(), PCB_ARC::GetRadius(), PCB_TRACK::GetStart(), PCB_TRACK::GetWidth(), Is_segment_a_circle(), KiROUND(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, TO_3DU, TO_SFVEC2F, transformArcToSegments(), EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers().

◆ destroyLayers()

void BOARD_ADAPTER::destroyLayers ( )
private

Definition at line 57 of file create_layer_items.cpp.

58{
59 if( !m_layers_poly.empty() )
60 {
61 for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layers_poly )
62 delete poly.second;
63
64 m_layers_poly.clear();
65 }
66
68 m_frontPlatedPadPolys = nullptr;
69
71 m_backPlatedPadPolys = nullptr;
72
73 if( !m_layerHoleIdPolys.empty() )
74 {
75 for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layerHoleIdPolys )
76 delete poly.second;
77
78 m_layerHoleIdPolys.clear();
79 }
80
81 if( !m_layerHoleOdPolys.empty() )
82 {
83 for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET*>& poly : m_layerHoleOdPolys )
84 delete poly.second;
85
86 m_layerHoleOdPolys.clear();
87 }
88
89 if( !m_layerMap.empty() )
90 {
91 for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& poly : m_layerMap )
92 delete poly.second;
93
94 m_layerMap.clear();
95 }
96
97 delete m_platedPadsFront;
98 m_platedPadsFront = nullptr;
99
100 delete m_platedPadsBack;
101 m_platedPadsBack = nullptr;
102
103 if( !m_layerHoleMap.empty() )
104 {
105 for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& poly : m_layerHoleMap )
106 delete poly.second;
107
108 m_layerHoleMap.clear();
109 }
110
118
121}
BVH_CONTAINER_2D m_throughHoleViaIds
List of via hole inner diameters.

References BVH_CONTAINER_2D::Clear(), m_backPlatedPadPolys, m_frontPlatedPadPolys, m_layerHoleIdPolys, m_layerHoleMap, m_layerHoleOdPolys, m_layerMap, m_layers_poly, m_nonPlatedThroughHoleOdPolys, m_platedPadsBack, m_platedPadsFront, m_throughHoleAnnularRingPolys, m_throughHoleAnnularRings, m_throughHoleIds, m_throughHoleOdPolys, m_throughHoleOds, m_throughHoleViaIds, m_throughHoleViaOdPolys, m_throughHoleViaOds, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by createLayers(), and ~BOARD_ADAPTER().

◆ Get3dCacheManager()

S3D_CACHE * BOARD_ADAPTER::Get3dCacheManager ( ) const
inlinenoexcept

Definition at line 81 of file board_adapter.h.

81{ return m_3dModelManager; }

References m_3dModelManager.

Referenced by RENDER_3D_RAYTRACE::load3DModels(), and RENDER_3D_OPENGL::load3dModels().

◆ GetAverageHoleDiameter()

float BOARD_ADAPTER::GetAverageHoleDiameter ( ) const
inlinenoexcept
Returns
the average diameter of through holes in 3D units.

Definition at line 295 of file board_adapter.h.

295{ return m_averageHoleDiameter; }

References m_averageHoleDiameter.

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ GetAverageTrackWidth()

float BOARD_ADAPTER::GetAverageTrackWidth ( ) const
inlinenoexcept
Returns
average track width in 3D units.

Definition at line 300 of file board_adapter.h.

300{ return m_averageTrackWidth; }

References m_averageTrackWidth.

◆ GetAverageViaHoleDiameter()

float BOARD_ADAPTER::GetAverageViaHoleDiameter ( ) const
inlinenoexcept
Returns
via hole average diameter dimension in 3D units.

Definition at line 290 of file board_adapter.h.

290{ return m_averageViaHoleDiameter; }

References m_averageViaHoleDiameter.

Referenced by RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::Reload().

◆ GetBackCopperThickness()

float BOARD_ADAPTER::GetBackCopperThickness ( ) const
inlinenoexcept

◆ GetBackPlatedPadPolys()

const SHAPE_POLY_SET * BOARD_ADAPTER::GetBackPlatedPadPolys ( )
inline

Definition at line 322 of file board_adapter.h.

322{ return m_backPlatedPadPolys; }

References m_backPlatedPadPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetBBox()

const BBOX_3D & BOARD_ADAPTER::GetBBox ( ) const
inlinenoexcept

Get the board outling bounding box.

Returns
the board bounding box in 3D units.

Definition at line 125 of file board_adapter.h.

125{ return m_boardBoundingBox; }

References m_boardBoundingBox.

Referenced by NL_3D_VIEWER_PLUGIN_IMPL::GetHitLookAt(), NL_3D_VIEWER_PLUGIN_IMPL::GetModelExtents(), EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position(), and RENDER_3D_RAYTRACE::Reload().

◆ GetBoard()

◆ GetBoardBodyThickness()

float BOARD_ADAPTER::GetBoardBodyThickness ( ) const
inlinenoexcept

Get the board body thickness, including internal copper layers (in 3D units).

Definition at line 130 of file board_adapter.h.

130{ return m_boardBodyThickness3DU; }

References m_boardBodyThickness3DU.

Referenced by RENDER_3D_OPENGL::renderBoardBody().

◆ GetBoardCenter()

const SFVEC3F & BOARD_ADAPTER::GetBoardCenter ( ) const
inlinenoexcept

The board center position in 3D units.

Returns
board center vector position in 3D units.

Definition at line 167 of file board_adapter.h.

167{ return m_boardCenter; }

References m_boardCenter.

Referenced by RENDER_3D_OPENGL::reload(), and RENDER_3D_RAYTRACE::Reload().

◆ GetBoardPoly()

const SHAPE_POLY_SET & BOARD_ADAPTER::GetBoardPoly ( ) const
inlinenoexcept

Get the current polygon of the epoxy board.

Returns
the shape polygon

Definition at line 183 of file board_adapter.h.

183{ return m_board_poly; }

References m_board_poly.

Referenced by RENDER_3D_OPENGL::reload(), and RENDER_3D_RAYTRACE::Reload().

◆ GetBoardPos()

VECTOR2I BOARD_ADAPTER::GetBoardPos ( ) const
inlinenoexcept

Get the board center.

Returns
position in BIU units.

Definition at line 160 of file board_adapter.h.

160{ return m_boardPos; }

References m_boardPos.

Referenced by RENDER_3D_OPENGL::generate3dGrid().

◆ GetBoardSize()

VECTOR2I BOARD_ADAPTER::GetBoardSize ( ) const
inlinenoexcept

Get the board size.

Returns
size in BIU units.

Definition at line 153 of file board_adapter.h.

153{ return m_boardSize; }

References m_boardSize.

Referenced by RENDER_3D_OPENGL::generate3dGrid().

◆ GetCircleSegmentCount() [1/2]

unsigned int BOARD_ADAPTER::GetCircleSegmentCount ( float  aDiameter3DU) const
Parameters
aDiameter3DUdiameter in 3DU.
Returns
number of sides that should be used in a circle with aDiameter3DU.

Definition at line 291 of file board_adapter.cpp.

292{
293 wxASSERT( aDiameter3DU > 0.0f );
294
295 return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
296}

References GetCircleSegmentCount(), and m_biuTo3Dunits.

Referenced by RENDER_3D_OPENGL::addObjectTriangles(), addShape(), RENDER_3D_OPENGL::generateViasAndPads(), and GetCircleSegmentCount().

◆ GetCircleSegmentCount() [2/2]

unsigned int BOARD_ADAPTER::GetCircleSegmentCount ( int  aDiameterBIU) const
Parameters
aDiameterBIUdiameter in board internal units.
Returns
number of sides that should be used in circle with aDiameterBIU.

Definition at line 299 of file board_adapter.cpp.

300{
301 wxASSERT( aDiameterBIU > 0 );
302
303 return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, FULL_CIRCLE );
304}
static constexpr EDA_ANGLE & FULL_CIRCLE
Definition: eda_angle.h:410

References ARC_HIGH_DEF, FULL_CIRCLE, and GetArcToSegmentCount().

◆ GetColor()

SFVEC4F BOARD_ADAPTER::GetColor ( const COLOR4D aColor) const
Parameters
[in]aColoris the color mapped.
Returns
the color in SFVEC3F format

Definition at line 736 of file board_adapter.cpp.

737{
738 return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
739}
double r
Red component.
Definition: color4d.h:384
double g
Green component.
Definition: color4d.h:385
double a
Alpha component.
Definition: color4d.h:387
double b
Blue component.
Definition: color4d.h:386

References KIGFX::COLOR4D::a, KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, and KIGFX::COLOR4D::r.

Referenced by RENDER_3D_OPENGL::generate3dGrid(), GetItemColor(), RENDER_3D_RAYTRACE::Reload(), and RENDER_3D_OPENGL::renderFootprint().

◆ GetFootprintZPos()

float BOARD_ADAPTER::GetFootprintZPos ( bool  aIsFlipped) const

Get the position of the footprint in 3d integer units considering if it is flipped or not.

Parameters
aIsFlippedtrue for use in footprints on Front (top) layer, false if footprint is on back (bottom) layer.
Returns
the Z position of 3D shapes, in 3D integer units.

Definition at line 701 of file board_adapter.cpp.

702{
703 if( aIsFlipped )
704 {
707 else
709 }
710 else
711 {
714 else
716 }
717}

References B_Paste, B_SilkS, F_Paste, F_SilkS, m_Cfg, m_layerZcoordBottom, m_layerZcoordTop, EDA_3D_VIEWER_SETTINGS::m_Render, and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_solderpaste.

Referenced by RENDER_3D_RAYTRACE::load3DModels(), and RENDER_3D_OPENGL::renderFootprint().

◆ GetFrontCopperThickness()

float BOARD_ADAPTER::GetFrontCopperThickness ( ) const
inlinenoexcept

Get the copper layer thicknesses (in 3D units).

Definition at line 140 of file board_adapter.h.

References m_frontCopperThickness3DU.

Referenced by RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_RAYTRACE::Reload().

◆ GetFrontPlatedPadPolys()

const SHAPE_POLY_SET * BOARD_ADAPTER::GetFrontPlatedPadPolys ( )
inline

Definition at line 321 of file board_adapter.h.

321{ return m_frontPlatedPadPolys; }

References m_frontPlatedPadPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetHoleCount()

unsigned int BOARD_ADAPTER::GetHoleCount ( ) const
inlinenoexcept

Definition at line 285 of file board_adapter.h.

285{ return m_holeCount; }

References m_holeCount.

Referenced by RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::Reload().

◆ GetHoleIdPolysMap()

const MAP_POLY & BOARD_ADAPTER::GetHoleIdPolysMap ( ) const
inlinenoexcept

Definition at line 323 of file board_adapter.h.

323{ return m_layerHoleIdPolys; }

References m_layerHoleIdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetHoleOdPolysMap()

const MAP_POLY & BOARD_ADAPTER::GetHoleOdPolysMap ( ) const
inlinenoexcept

Definition at line 324 of file board_adapter.h.

324{ return m_layerHoleOdPolys; }

References m_layerHoleOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetHolePlatingThickness()

int BOARD_ADAPTER::GetHolePlatingThickness ( ) const
noexcept

Get the hole plating thickness (NB: in BOARD UNITS!).

Definition at line 284 of file board_adapter.cpp.

285{
288}
int GetHolePlatingThickness() const
Pad & via drills are finish size.

References DEFAULT_COPPER_THICKNESS, BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetHolePlatingThickness(), and m_board.

Referenced by createLayers(), RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::insertHole().

◆ GetItemColor()

SFVEC4F BOARD_ADAPTER::GetItemColor ( int  aItemId) const

Get the technical color of a layer.

Parameters
aItemIdthe item id to get the color information.
Returns
the color in SFVEC3F format.

Definition at line 730 of file board_adapter.cpp.

731{
732 return GetColor( m_colors->GetColor( aItemId ) );
733}
SFVEC4F GetColor(const COLOR4D &aColor) const
COLOR4D GetColor(int aLayer) const

References GetColor(), COLOR_SETTINGS::GetColor(), and m_colors.

Referenced by RENDER_3D_RAYTRACE::insertHole().

◆ GetLayerBottomZPos()

float BOARD_ADAPTER::GetLayerBottomZPos ( PCB_LAYER_ID  aLayerId) const
inlinenoexcept

Get the bottom z position.

Parameters
aLayerIdlayer id.
Returns
position in 3D units.

Definition at line 226 of file board_adapter.h.

227 {
228 return m_layerZcoordBottom[aLayerId];
229 }

References m_layerZcoordBottom.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_OPENGL::getLayerZPos(), RENDER_3D_RAYTRACE::insertHole(), RENDER_3D_OPENGL::Redraw(), and RENDER_3D_RAYTRACE::Reload().

◆ GetLayerColor()

SFVEC4F BOARD_ADAPTER::GetLayerColor ( PCB_LAYER_ID  aLayerId) const

Get the technical color of a layer.

Parameters
aLayerIdthe layer to get the color information.
Returns
the color in SFVEC3F format.

Definition at line 720 of file board_adapter.cpp.

721{
722 wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
723
724 const COLOR4D color = m_colors->GetColor( aLayerId );
725
726 return SFVEC4F( color.r, color.g, color.b, color.a );
727}
int color
Definition: DXF_plotter.cpp:57
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137

References color, COLOR_SETTINGS::GetColor(), m_colors, and PCB_LAYER_ID_COUNT.

Referenced by RENDER_3D_OPENGL::getLayerColor(), and RENDER_3D_RAYTRACE::Reload().

◆ GetLayerHoleMap()

const MAP_CONTAINER_2D_BASE & BOARD_ADAPTER::GetLayerHoleMap ( ) const
inlinenoexcept

Definition at line 240 of file board_adapter.h.

240{ return m_layerHoleMap; }

References m_layerHoleMap.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), and RENDER_3D_OPENGL::reload().

◆ GetLayerMap()

const MAP_CONTAINER_2D_BASE & BOARD_ADAPTER::GetLayerMap ( ) const
inlinenoexcept

Get the map of containers that have the objects per layer.

Returns
the map containers of this board.

Definition at line 236 of file board_adapter.h.

236{ return m_layerMap; }

References m_layerMap.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_OPENGL::reload(), and RENDER_3D_RAYTRACE::Reload().

◆ GetLayerTopZPos()

float BOARD_ADAPTER::GetLayerTopZPos ( PCB_LAYER_ID  aLayerId) const
inlinenoexcept

Get the top z position.

Parameters
aLayerIdlayer id.
Returns
position in 3D units.

Definition at line 215 of file board_adapter.h.

216 {
217 return m_layerZcoordTop[aLayerId];
218 }

References m_layerZcoordTop.

Referenced by RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_OPENGL::getLayerZPos(), RENDER_3D_OPENGL::Redraw(), and RENDER_3D_RAYTRACE::Reload().

◆ GetNonCopperLayerThickness()

float BOARD_ADAPTER::GetNonCopperLayerThickness ( ) const
inlinenoexcept

Get the non copper layers thickness (in 3D units).

Definition at line 135 of file board_adapter.h.

References m_nonCopperLayerThickness3DU.

Referenced by RENDER_3D_OPENGL::renderSolderMaskLayer(), and RENDER_3D_RAYTRACE::shadeHit().

◆ GetOuterNonPlatedThroughHolePoly()

const SHAPE_POLY_SET & BOARD_ADAPTER::GetOuterNonPlatedThroughHolePoly ( ) const
inlinenoexcept

Definition at line 266 of file board_adapter.h.

267 {
269 }

References m_nonPlatedThroughHoleOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetPlatedPadsBack()

const BVH_CONTAINER_2D * BOARD_ADAPTER::GetPlatedPadsBack ( ) const
inlinenoexcept

Definition at line 238 of file board_adapter.h.

238{ return m_platedPadsBack; }

References m_platedPadsBack.

Referenced by RENDER_3D_OPENGL::reload(), and RENDER_3D_RAYTRACE::Reload().

◆ GetPlatedPadsFront()

const BVH_CONTAINER_2D * BOARD_ADAPTER::GetPlatedPadsFront ( ) const
inlinenoexcept

Definition at line 237 of file board_adapter.h.

237{ return m_platedPadsFront; }

References m_platedPadsFront.

Referenced by RENDER_3D_OPENGL::reload(), and RENDER_3D_RAYTRACE::Reload().

◆ GetPolyMap()

const MAP_POLY & BOARD_ADAPTER::GetPolyMap ( ) const
inlinenoexcept

Get map of polygon's layers.

Returns
the map with polygon's layers.

Definition at line 319 of file board_adapter.h.

319{ return m_layers_poly; }

References m_layers_poly.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetSphericalCoord()

SFVEC2F BOARD_ADAPTER::GetSphericalCoord ( int  i) const

Definition at line 742 of file board_adapter.cpp.

743{
744 SFVEC2F sphericalCoord =
745 SFVEC2F( ( m_Cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
746 m_Cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
747
748 sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
749 sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
750
751 return sphericalCoord;
752}

References m_Cfg, EDA_3D_VIEWER_SETTINGS::m_Render, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::raytrace_lightAzimuth, and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::raytrace_lightElevation.

Referenced by RENDER_3D_RAYTRACE::Reload().

◆ GetThroughHoleAnnularRingPolys()

const SHAPE_POLY_SET & BOARD_ADAPTER::GetThroughHoleAnnularRingPolys ( ) const
inlinenoexcept

Definition at line 261 of file board_adapter.h.

262 {
264 }

References m_throughHoleAnnularRingPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetThroughHoleAnnularRings()

const BVH_CONTAINER_2D & BOARD_ADAPTER::GetThroughHoleAnnularRings ( ) const
inlinenoexcept

◆ GetThroughHoleIds()

const BVH_CONTAINER_2D & BOARD_ADAPTER::GetThroughHoleIds ( ) const
inlinenoexcept

Definition at line 241 of file board_adapter.h.

241{ return m_throughHoleIds; }

References m_throughHoleIds.

Referenced by RENDER_3D_RAYTRACE::insertHole(), and RENDER_3D_OPENGL::reload().

◆ GetThroughHoleOdPolys()

const SHAPE_POLY_SET & BOARD_ADAPTER::GetThroughHoleOdPolys ( ) const
inlinenoexcept

Get through hole outside diameter 2D polygons.

The outside diameter 2D polygon is the hole diameter plus the plating thickness.

Returns
a container with through hold outside diameter 2D polygons.

Definition at line 251 of file board_adapter.h.

252 {
254 }

References m_throughHoleOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetThroughHoleOds()

const BVH_CONTAINER_2D & BOARD_ADAPTER::GetThroughHoleOds ( ) const
inlinenoexcept

◆ GetThroughHoleViaOdPolys()

const SHAPE_POLY_SET & BOARD_ADAPTER::GetThroughHoleViaOdPolys ( ) const
inlinenoexcept

Definition at line 279 of file board_adapter.h.

280 {
282 }

References m_throughHoleViaOdPolys.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetThroughHoleViaOds()

const BVH_CONTAINER_2D & BOARD_ADAPTER::GetThroughHoleViaOds ( ) const
inlinenoexcept
Returns
a container with through hole via hole outside diameters.

Definition at line 274 of file board_adapter.h.

275 {
276 return m_throughHoleViaOds;
277 }

References m_throughHoleViaOds.

Referenced by RENDER_3D_OPENGL::reload().

◆ GetViaCount()

unsigned int BOARD_ADAPTER::GetViaCount ( ) const
inlinenoexcept

Definition at line 284 of file board_adapter.h.

284{ return m_viaCount; }

References m_viaCount.

Referenced by RENDER_3D_OPENGL::generateViasAndPads(), and RENDER_3D_RAYTRACE::Reload().

◆ InitSettings()

void BOARD_ADAPTER::InitSettings ( REPORTER aStatusReporter,
REPORTER aWarningReporter 
)

Function to be called by the render when it need to reload the settings for the board.

Parameters
aStatusReporterthe pointer for the status reporter.
aWarningReporterpointer for the warning reporter.

Definition at line 307 of file board_adapter.cpp.

308{
309 wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
310
311 if( aStatusReporter )
312 aStatusReporter->Report( _( "Build board outline" ) );
313
314 wxString msg;
315
316 const bool haveOutline = createBoardPolygon( &msg );
317
318 if( aWarningReporter )
319 {
320 if( !haveOutline )
321 aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
322 else
323 aWarningReporter->Report( wxEmptyString );
324 }
325
326 BOX2I bbbox;
327
328 if( m_board )
329 {
332 && haveOutline );
333 }
334
335 // Gives a non null size to avoid issues in zoom / scale calculations
336 if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
337 bbbox.Inflate( pcbIUScale.mmToIU( 10 ) );
338
339 m_boardSize = bbbox.GetSize();
340 m_boardPos = bbbox.Centre();
341
342 wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
343
344 m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
345
347
348 // Ensure the board has 2 sides for 3D views, because it is hard to find
349 // a *really* single side board in the true life...
350 if( m_copperLayersCount < 2 )
352
353 // Calculate the conversion to apply to all positions.
355
361
362 g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 ) * m_biuTo3Dunits;
363
364 if( m_board )
365 {
367
368 if( bds.GetStackupDescriptor().GetCount() )
369 {
370 int thickness = 0;
371
372 for( BOARD_STACKUP_ITEM* item : bds.GetStackupDescriptor().GetList() )
373 {
374 switch( item->GetType() )
375 {
377 for( int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
378 thickness += item->GetThickness( sublayer );
379 break;
380
382 if( item->GetBrdLayerId() == F_Cu )
383 m_frontCopperThickness3DU = item->GetThickness() * m_biuTo3Dunits;
384 else if( item->GetBrdLayerId() == B_Cu )
385 m_backCopperThickness3DU = item->GetThickness() * m_biuTo3Dunits;
386 else if( item->IsEnabled() )
387 thickness += item->GetThickness();
388
389 break;
390
391 default:
392 break;
393 }
394 }
395
397 }
398 }
399
400 // Init Z position of each layer
401 // calculate z position for each copper layer
402 // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
403 // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
404
405 // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
406 // | | Top = Bottom + m_copperThickness
407 // |__________________________________|
408 // == == == == <- Bottom = -m_epoxyThickness / 2.0,
409 // Top = Bottom - m_copperThickness
410
411 unsigned int layer;
412
413 for( layer = 0; layer < m_copperLayersCount; ++layer )
414 {
415 // This approximates internal layer positions (because we're treating all the dielectric
416 // layers as having the same thickness). But we don't render them anyway so it doesn't
417 // really matter.
420
421 if( layer < (m_copperLayersCount / 2) )
423 else
425 }
426
427 #define layerThicknessMargin 1.1
428 const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
429
430 // Fill remaining unused copper layers and back layer zpos with -m_boardBodyThickness / 2.0
431 for( ; layer < MAX_CU_LAYERS; layer++ )
432 {
433 m_layerZcoordBottom[layer] = -( m_boardBodyThickness3DU / 2.0f );
435 }
436
437 // This is the top of the copper layer thickness.
438 const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
439 const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
440
441 // calculate z position for each non copper layer
442 // Solder mask and Solder paste have the same Z position
443 for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
444 {
445 float zposTop;
446 float zposBottom;
447
448 switch( layer_id )
449 {
450 case B_Adhes:
451 zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
452 zposTop = zposBottom - m_nonCopperLayerThickness3DU;
453 break;
454
455 case F_Adhes:
456 zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
457 zposTop = zposBottom + m_nonCopperLayerThickness3DU;
458 break;
459
460 case B_Mask:
461 zposBottom = zpos_copperTop_back;
462 zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
463 break;
464
465 case B_Paste:
466 zposBottom = zpos_copperTop_back;
467 zposTop = zpos_copperTop_back - m_solderPasteLayerThickness3DU;
468 break;
469
470 case F_Mask:
471 zposBottom = zpos_copperTop_front;
472 zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
473 break;
474
475 case F_Paste:
476 zposBottom = zpos_copperTop_front;
477 zposTop = zpos_copperTop_front + m_solderPasteLayerThickness3DU;
478 break;
479
480 case B_SilkS:
481 zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
482 zposTop = zposBottom - m_nonCopperLayerThickness3DU;
483 break;
484
485 case F_SilkS:
486 zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
487 zposTop = zposBottom + m_nonCopperLayerThickness3DU;
488 break;
489
490 // !TODO: review
491 default:
492 zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
493 zposBottom = zposTop - m_nonCopperLayerThickness3DU;
494 break;
495 }
496
497 m_layerZcoordTop[layer_id] = zposTop;
498 m_layerZcoordBottom[layer_id] = zposBottom;
499 }
500
502
504 0.0f );
505 boardSize /= 2.0f;
506
507 SFVEC3F boardMin = ( m_boardCenter - boardSize );
508 SFVEC3F boardMax = ( m_boardCenter + boardSize );
509
510 boardMin.z = m_layerZcoordTop[B_Adhes];
511 boardMax.z = m_layerZcoordTop[F_Adhes];
512
513 m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
514
515#ifdef PRINT_STATISTICS_3D_VIEWER
516 unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
517#endif
518
519 if( aStatusReporter )
520 aStatusReporter->Report( _( "Create layers" ) );
521
522 createLayers( aStatusReporter );
523
524 COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
525
526 auto to_SFVEC4F =
527 []( const COLOR4D& src )
528 {
529 return SFVEC4F( src.r, src.g, src.b, src.a );
530 };
531
532 m_BgColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_TOP ) );
533 m_BgColorBot = to_SFVEC4F( colors->GetColor( LAYER_3D_BACKGROUND_BOTTOM ) );
534
535 m_SolderPasteColor = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERPASTE ) );
536
537 if( m_board && colors->GetUseBoardStackupColors() )
538 {
540
541 auto findColor =
542 []( const wxString& aColorName, const CUSTOM_COLORS_LIST& aColorSet )
543 {
544 if( aColorName.StartsWith( wxT( "#" ) ) )
545 {
546 return KIGFX::COLOR4D( aColorName );
547 }
548 else
549 {
550 for( const CUSTOM_COLOR_ITEM& color : aColorSet )
551 {
552 if( color.m_ColorName == aColorName )
553 return color.m_Color;
554 }
555 }
556
557 return KIGFX::COLOR4D();
558 };
559
564
565 KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
566
567 for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
568 {
569 wxString colorName = stackupItem->GetColor();
570
571 switch( stackupItem->GetType() )
572 {
574 if( stackupItem->GetBrdLayerId() == F_SilkS )
575 m_SilkScreenColorTop = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
576 else
577 m_SilkScreenColorBot = to_SFVEC4F( findColor( colorName, g_SilkscreenColors ) );
578 break;
579
581 if( stackupItem->GetBrdLayerId() == F_Mask )
582 m_SolderMaskColorTop = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
583 else
584 m_SolderMaskColorBot = to_SFVEC4F( findColor( colorName, g_MaskColors ) );
585
586 break;
587
589 {
590 KIGFX::COLOR4D layerColor = findColor( colorName, g_BoardColors );
591
592 if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
593 bodyColor = layerColor;
594 else
595 bodyColor = bodyColor.Mix( layerColor, 1.0 - layerColor.a );
596
597 bodyColor.a += ( 1.0 - bodyColor.a ) * layerColor.a / 2;
598 break;
599 }
600
601 default:
602 break;
603 }
604 }
605
606 if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
607 m_BoardBodyColor = to_SFVEC4F( bodyColor );
608 else
609 m_BoardBodyColor = to_SFVEC4F( g_DefaultBoardBody );
610
611 const wxString& finishName = stackup.m_FinishType;
612
613 if( finishName.EndsWith( wxT( "OSP" ) ) )
614 {
615 m_CopperColor = to_SFVEC4F( findColor( wxT( "Copper" ), g_FinishColors ) );
616 }
617 else if( finishName.EndsWith( wxT( "IG" ) )
618 || finishName.EndsWith( wxT( "gold" ) ) )
619 {
620 m_CopperColor = to_SFVEC4F( findColor( wxT( "Gold" ), g_FinishColors ) );
621 }
622 else if( finishName.StartsWith( wxT( "HAL" ) )
623 || finishName.StartsWith( wxT( "HASL" ) )
624 || finishName.EndsWith( wxT( "tin" ) )
625 || finishName.EndsWith( wxT( "nickel" ) ) )
626 {
627 m_CopperColor = to_SFVEC4F( findColor( wxT( "Tin" ), g_FinishColors ) );
628 }
629 else if( finishName.EndsWith( wxT( "silver" ) ) )
630 {
631 m_CopperColor = to_SFVEC4F( findColor( wxT( "Silver" ), g_FinishColors ) );
632 }
633 else
634 {
636 }
637 }
638 else
639 {
641 m_SilkScreenColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SILKSCREEN_TOP ) );
643 m_SolderMaskColorTop = to_SFVEC4F( colors->GetColor( LAYER_3D_SOLDERMASK_TOP ) );
644 m_CopperColor = to_SFVEC4F( colors->GetColor( LAYER_3D_COPPER ) );
645 m_BoardBodyColor = to_SFVEC4F( colors->GetColor( LAYER_3D_BOARD ) );
646 }
647}
float g_BevelThickness3DU
#define layerThicknessMargin
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: board_adapter.h:62
@ BS_ITEM_TYPE_COPPER
Definition: board_stackup.h:43
@ BS_ITEM_TYPE_SILKSCREEN
Definition: board_stackup.h:49
@ BS_ITEM_TYPE_DIELECTRIC
Definition: board_stackup.h:44
@ BS_ITEM_TYPE_SOLDERMASK
Definition: board_stackup.h:47
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void createLayers(REPORTER *aStatusReporter)
bool createBoardPolygon(wxString *aErrorMsg)
Create the board outline polygon.
Container for design settings for a BOARD object.
BOARD_STACKUP & GetStackupDescriptor()
Manage one layer needed to make a physical board.
Definition: board_stackup.h:91
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
int GetCount() const
wxString m_FinishType
The name of external copper finish.
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Definition: board.cpp:1192
int GetCopperLayerCount() const
Definition: board.cpp:502
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
Vec Centre() const
Definition: box2.h:70
const Vec & GetSize() const
Definition: box2.h:179
Color settings are a bit different than most of the settings objects in that there can be more than o...
bool GetUseBoardStackupColors() const
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:305
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
@ LAYER_3D_SOLDERMASK_TOP
Definition: layer_ids.h:442
@ LAYER_3D_COPPER
Definition: layer_ids.h:438
@ LAYER_3D_BACKGROUND_TOP
Definition: layer_ids.h:436
@ LAYER_3D_SOLDERMASK_BOTTOM
Definition: layer_ids.h:441
@ LAYER_3D_BOARD
Definition: layer_ids.h:437
@ LAYER_3D_SILKSCREEN_TOP
Definition: layer_ids.h:440
@ LAYER_3D_SOLDERPASTE
Definition: layer_ids.h:443
@ LAYER_3D_BACKGROUND_BOTTOM
Definition: layer_ids.h:435
@ LAYER_3D_SILKSCREEN_BOTTOM
Definition: layer_ids.h:439
@ RPT_SEVERITY_WARNING
Manage a bounding box defined by two SFVEC3F min max points.
Definition: bbox_3d.h:42
A class to handle a custom color (predefined color) for the color picker dialog.

References _, KIGFX::COLOR4D::a, B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, BS_ITEM_TYPE_COPPER, BS_ITEM_TYPE_DIELECTRIC, BS_ITEM_TYPE_SILKSCREEN, BS_ITEM_TYPE_SOLDERMASK, BOX2< Vec >::Centre(), color, BOARD::ComputeBoundingBox(), createBoardPolygon(), createLayers(), DEFAULT_BOARD_THICKNESS, DEFAULT_COPPER_THICKNESS, DEFAULT_TECH_LAYER_THICKNESS, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, g_BevelThickness3DU, g_BoardColors, g_DefaultBoardBody, g_DefaultSilkscreen, g_DefaultSolderMask, g_DefaultSurfaceFinish, g_FinishColors, g_MaskColors, g_SilkscreenColors, ADVANCED_CFG::GetCfg(), COLOR_SETTINGS::GetColor(), BOARD::GetCopperLayerCount(), BOARD_STACKUP::GetCount(), BOARD::GetDesignSettings(), BOX2< Vec >::GetHeight(), BOARD_STACKUP::GetList(), GetRunningMicroSecs(), BOX2< Vec >::GetSize(), BOARD_DESIGN_SETTINGS::GetStackupDescriptor(), COLOR_SETTINGS::GetUseBoardStackupColors(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), BOARD::IsFootprintHolder(), LAYER_3D_BACKGROUND_BOTTOM, LAYER_3D_BACKGROUND_TOP, LAYER_3D_BOARD, LAYER_3D_COPPER, LAYER_3D_SILKSCREEN_BOTTOM, LAYER_3D_SILKSCREEN_TOP, LAYER_3D_SOLDERMASK_BOTTOM, LAYER_3D_SOLDERMASK_TOP, LAYER_3D_SOLDERPASTE, layerThicknessMargin, m_backCopperThickness3DU, m_BgColorBot, m_BgColorTop, m_biuTo3Dunits, m_board, m_BoardBodyColor, m_boardBodyThickness3DU, m_boardBoundingBox, m_boardCenter, m_boardPos, m_boardSize, m_Cfg, m_CopperColor, m_copperLayersCount, BOARD_STACKUP::m_FinishType, m_frontCopperThickness3DU, m_layerZcoordBottom, m_layerZcoordTop, m_logTrace, m_nonCopperLayerThickness3DU, EDA_3D_VIEWER_SETTINGS::m_Render, m_SilkScreenColorBot, m_SilkScreenColorTop, m_SolderMaskColorBot, m_SolderMaskColorTop, m_SolderPasteColor, m_solderPasteLayerThickness3DU, MAX_CU_LAYERS, KIGFX::COLOR4D::Mix(), EDA_IU_SCALE::mmToIU(), PCB_LAYER_ID_COUNT, pcbIUScale, Pgm(), RANGE_SCALE_3D, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic, REPORTER::Report(), RPT_SEVERITY_WARNING, SOLDERPASTE_LAYER_THICKNESS, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by RENDER_3D_OPENGL::reload(), and RENDER_3D_RAYTRACE::Reload().

◆ Is3dLayerEnabled()

bool BOARD_ADAPTER::Is3dLayerEnabled ( PCB_LAYER_ID  aLayer) const

Check if a layer is enabled.

Parameters
aLayerlayer ID to get status.

Definition at line 211 of file board_adapter.cpp.

212{
213 wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
214
215 if( m_board && !m_board->IsLayerEnabled( aLayer ) )
216 return false;
217
218 // see if layer needs to be shown
219 // check the flags
220 switch( aLayer )
221 {
222 case B_Adhes:
223 case F_Adhes:
225
226 case B_Paste:
227 case F_Paste:
229
230 case B_SilkS:
231 case F_SilkS:
233
234 case B_Mask:
235 case F_Mask:
237
238 case Dwgs_User:
239 case Cmts_User:
241
242 case Eco1_User:
243 case Eco2_User:
245
246 case Edge_Cuts:
248
249 case Margin:
250 return !m_Cfg->m_Render.realistic;
251
252 case B_Cu:
253 case F_Cu:
254 return !m_board || m_board->IsLayerVisible( aLayer ) || m_Cfg->m_Render.realistic;
255
256 default:
257 // the layer is an internal copper layer, used the visibility
258 return m_board && m_board->IsLayerVisible( aLayer );
259 }
260}
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:552
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
Definition: board.cpp:532

References B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, BOARD::IsLayerEnabled(), BOARD::IsLayerVisible(), m_board, m_Cfg, EDA_3D_VIEWER_SETTINGS::m_Render, Margin, PCB_LAYER_ID_COUNT, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::realistic, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_adhesive, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_board_body, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_comments, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_eco, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_silkscreen, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_soldermask, and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_solderpaste.

Referenced by createLayers(), and RENDER_3D_OPENGL::reload().

◆ IsFootprintShown()

bool BOARD_ADAPTER::IsFootprintShown ( FOOTPRINT_ATTR_T  aFPAttributes) const

Test if footprint should be displayed in relation to attributes and the flags.

Definition at line 263 of file board_adapter.cpp.

264{
265 if( m_IsPreviewer ) // In panel Preview, footprints are always shown, of course
266 return true;
267
268 if( aFPAttributes & FP_EXCLUDE_FROM_POS_FILES )
269 {
271 return false;
272 }
273
274 if( aFPAttributes & FP_SMD )
276
277 if( aFPAttributes & FP_THROUGH_HOLE )
279
281}
@ FP_SMD
Definition: footprint.h:69
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:70
@ FP_THROUGH_HOLE
Definition: footprint.h:68

References FP_EXCLUDE_FROM_POS_FILES, FP_SMD, FP_THROUGH_HOLE, m_Cfg, m_IsPreviewer, EDA_3D_VIEWER_SETTINGS::m_Render, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_insert, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_normal, EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_not_in_posfile, and EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS::show_footprints_virtual.

Referenced by RENDER_3D_RAYTRACE::load3DModels(), and RENDER_3D_OPENGL::render3dModelsSelected().

◆ Set3dCacheManager()

void BOARD_ADAPTER::Set3dCacheManager ( S3D_CACHE aCacheMgr)
inlinenoexcept

Update the cache manager pointer.

Parameters
aCachePointerthe pointer to the 3D cache manager.

Definition at line 80 of file board_adapter.h.

80{ m_3dModelManager = aCacheMgr; }

References m_3dModelManager.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ SetBoard()

void BOARD_ADAPTER::SetBoard ( BOARD aBoard)
inlinenoexcept

Set current board to be rendered.

Parameters
aBoardboard to process.

Definition at line 100 of file board_adapter.h.

100{ m_board = aBoard; }

References m_board.

Referenced by PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), and EDA_3D_CANVAS::ReloadRequest().

◆ SetColorSettings()

void BOARD_ADAPTER::SetColorSettings ( COLOR_SETTINGS aSettings)
inlinenoexcept

Definition at line 103 of file board_adapter.h.

103{ m_colors = aSettings; }

References m_colors.

Referenced by EDA_3D_CANVAS::ReloadRequest().

◆ transformArcToSegments()

void BOARD_ADAPTER::transformArcToSegments ( const VECTOR2I aCentre,
const VECTOR2I aStart,
const EDA_ANGLE aArcAngle,
int  aCircleToSegmentsCount,
int  aWidth,
CONTAINER_2D_BASE aDstContainer,
const BOARD_ITEM aOwner 
)
private

Definition at line 541 of file create_3Dgraphic_brd_items.cpp.

545{
546 VECTOR2I arc_start, arc_end;
547 EDA_ANGLE arcAngle( aArcAngle );
548 EDA_ANGLE delta = ANGLE_360 / aCircleToSegmentsCount; // rotate angle
549
550 arc_end = arc_start = aStart;
551
552 if( arcAngle != ANGLE_360 )
553 RotatePoint( arc_end, aCentre, -arcAngle );
554
555 if( arcAngle < ANGLE_0 )
556 {
557 std::swap( arc_start, arc_end );
558 arcAngle = -arcAngle;
559 }
560
561 // Compute the ends of segments and creates poly
562 VECTOR2I curr_end = arc_start;
563 VECTOR2I curr_start = arc_start;
564
565 for( EDA_ANGLE ii = delta; ii < arcAngle; ii += delta )
566 {
567 curr_end = arc_start;
568 RotatePoint( curr_end, aCentre, -ii );
569
570 const SFVEC2F start3DU = TO_SFVEC2F( curr_start );
571 const SFVEC2F end3DU = TO_SFVEC2F( curr_end );
572
573 if( Is_segment_a_circle( start3DU, end3DU ) )
574 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
575 else
576 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
577
578 curr_start = curr_end;
579 }
580
581 if( curr_end != arc_end )
582 {
583 const SFVEC2F start3DU = TO_SFVEC2F( curr_end );
584 const SFVEC2F end3DU = TO_SFVEC2F( arc_end );
585
586 if( Is_segment_a_circle( start3DU, end3DU ) )
587 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
588 else
589 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
590 }
591}
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:418
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References CONTAINER_2D_BASE::Add(), ANGLE_0, ANGLE_360, delta, Is_segment_a_circle(), RotatePoint(), TO_3DU, and TO_SFVEC2F.

Referenced by addShape(), and createTrack().

◆ transformFPShapesToPolySet()

void BOARD_ADAPTER::transformFPShapesToPolySet ( const FOOTPRINT aFootprint,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aBuffer 
) const
private

Definition at line 67 of file create_layer_poly.cpp.

69{
70 int maxError = m_board->GetDesignSettings().m_MaxError;
71
72 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
73 {
74 if( item->Type() == PCB_FP_SHAPE_T )
75 {
76 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
77
78 if( shape->GetLayer() == aLayer )
79 shape->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
80 }
81 else if( BaseType( item->Type() ) == PCB_DIMENSION_T )
82 {
83 PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
84
85 if( dimension->GetLayer() == aLayer )
86 dimension->TransformShapeToPolygon( aBuffer, aLayer, 0, maxError, ERROR_INSIDE );
87 }
88 }
89}
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
Definition: typeinfo.h:253
@ PCB_DIMENSION_T
class PCB_DIMENSION_BASE: abstract dimension meta-type
Definition: typeinfo.h:105

References BaseType(), ERROR_INSIDE, BOARD::GetDesignSettings(), BOARD_ITEM::GetLayer(), FOOTPRINT::GraphicalItems(), m_board, BOARD_DESIGN_SETTINGS::m_MaxError, PCB_DIMENSION_T, PCB_FP_SHAPE_T, PCB_DIMENSION_BASE::TransformShapeToPolygon(), and PCB_SHAPE::TransformShapeToPolygon().

Referenced by createLayers().

Member Data Documentation

◆ g_BoardColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_BoardColors
static

Definition at line 380 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultBackgroundBot

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundBot
static

Definition at line 383 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultBackgroundTop

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBackgroundTop
static

Definition at line 382 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultBoardBody

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultBoardBody
static

Definition at line 388 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSilkscreen

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSilkscreen
static

Definition at line 384 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSolderMask

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderMask
static

Definition at line 385 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSolderPaste

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSolderPaste
static

Definition at line 386 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_DefaultSurfaceFinish

KIGFX::COLOR4D BOARD_ADAPTER::g_DefaultSurfaceFinish
static

Definition at line 387 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_FinishColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_FinishColors
static

Definition at line 379 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_MaskColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_MaskColors
static

Definition at line 377 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_PasteColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_PasteColors
static

Definition at line 378 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ g_SilkscreenColors

CUSTOM_COLORS_LIST BOARD_ADAPTER::g_SilkscreenColors
static

Definition at line 376 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), InitSettings(), and PANEL_3D_COLORS::PANEL_3D_COLORS().

◆ m_3dModelManager

S3D_CACHE* BOARD_ADAPTER::m_3dModelManager
private

Definition at line 410 of file board_adapter.h.

Referenced by Get3dCacheManager(), and Set3dCacheManager().

◆ m_averageHoleDiameter

float BOARD_ADAPTER::m_averageHoleDiameter
private

Definition at line 469 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetAverageHoleDiameter().

◆ m_averageTrackWidth

float BOARD_ADAPTER::m_averageTrackWidth
private

Definition at line 465 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetAverageTrackWidth().

◆ m_averageViaHoleDiameter

float BOARD_ADAPTER::m_averageViaHoleDiameter
private

Definition at line 467 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetAverageViaHoleDiameter().

◆ m_backCopperThickness3DU

float BOARD_ADAPTER::m_backCopperThickness3DU
private

Definition at line 459 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBackCopperThickness(), and InitSettings().

◆ m_backPlatedPadPolys

SHAPE_POLY_SET* BOARD_ADAPTER::m_backPlatedPadPolys
private

Definition at line 423 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetBackPlatedPadPolys().

◆ m_BgColorBot

◆ m_BgColorTop

◆ m_biuTo3Dunits

double BOARD_ADAPTER::m_biuTo3Dunits
private

Scale factor to convert board internal units to 3D units normalized between -1.0 and 1.0.

Definition at line 449 of file board_adapter.h.

Referenced by addShape(), addSolidAreasShapes(), addText(), BiuTo3dUnits(), BOARD_ADAPTER(), createLayers(), createPadWithMargin(), GetCircleSegmentCount(), and InitSettings().

◆ m_board

◆ m_board_poly

SHAPE_POLY_SET BOARD_ADAPTER::m_board_poly
private

Board outline polygon.

Definition at line 433 of file board_adapter.h.

Referenced by createBoardPolygon(), and GetBoardPoly().

◆ m_BoardBodyColor

◆ m_boardBodyThickness3DU

float BOARD_ADAPTER::m_boardBodyThickness3DU
private

Definition at line 460 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardBodyThickness(), and InitSettings().

◆ m_boardBoundingBox

BBOX_3D BOARD_ADAPTER::m_boardBoundingBox
private

3D bounding box of the board in 3D units.

Definition at line 417 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBBox(), and InitSettings().

◆ m_boardCenter

SFVEC3F BOARD_ADAPTER::m_boardCenter
private

3D center position of the board in 3D units.

Definition at line 416 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardCenter(), and InitSettings().

◆ m_boardPos

VECTOR2I BOARD_ADAPTER::m_boardPos
private

Board center position in board internal units.

Definition at line 414 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardPos(), and InitSettings().

◆ m_boardSize

VECTOR2I BOARD_ADAPTER::m_boardSize
private

Board size in board internal units.

Definition at line 415 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetBoardSize(), and InitSettings().

◆ m_Cfg

EDA_3D_VIEWER_SETTINGS* BOARD_ADAPTER::m_Cfg

Definition at line 391 of file board_adapter.h.

Referenced by RENDER_3D_RAYTRACE::addModels(), EDA_3D_VIEWER_FRAME::applyViewport(), RENDER_3D_RAYTRACE::createItemsFromContainer(), createLayers(), EDA_3D_CANVAS::DoRePaint(), RENDER_3D_OPENGL::generateViasAndPads(), GetFootprintZPos(), RENDER_3D_OPENGL::getLayerColor(), RENDER_3D_RAYTRACE::getModelMaterial(), GetSphericalCoord(), EDA_3D_CONDITIONS::gridSizeFunction(), InitSettings(), RENDER_3D_RAYTRACE::insertHole(), Is3dLayerEnabled(), IsFootprintShown(), RENDER_3D_RAYTRACE::load3DModels(), RENDER_3D_OPENGL::load3dModels(), PANEL_PREVIEW_3D_MODEL::loadSettings(), EDA_3D_VIEWER_FRAME::LoadSettings(), EDA_3D_CONTROLLER::On3DGridSelection(), EDA_3D_VIEWER_FRAME::onDisableRayTracing(), EDA_3D_CANVAS::OnMouseMove(), EDA_3D_VIEWER_FRAME::onRenderEngineSelection(), RENDER_3D_RAYTRACE::postProcessBlurFinish(), RENDER_3D_RAYTRACE::postProcessShading(), EDA_3D_VIEWER_FRAME::Redraw(), RENDER_3D_OPENGL::Redraw(), EDA_3D_VIEWER_FRAME::refreshRender(), RENDER_3D_OPENGL::reload(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_RAYTRACE::render(), RENDER_3D_OPENGL::render3dModelsSelected(), RENDER_3D_RAYTRACE::renderAntiAliasPackets(), RENDER_3D_RAYTRACE::renderBlockTracing(), RENDER_3D_OPENGL::renderFootprint(), EDA_3D_CONTROLLER::RotateView(), EDA_3D_VIEWER_FRAME::SaveSettings(), RENDER_3D_OPENGL::setLayerMaterial(), EDA_3D_CONTROLLER::SetMaterial(), RENDER_3D_OPENGL::setupMaterials(), RENDER_3D_RAYTRACE::setupMaterials(), EDA_3D_VIEWER_FRAME::setupUIConditions(), RENDER_3D_RAYTRACE::shadeHit(), EDA_3D_CONTROLLER::ToggleOrtho(), and EDA_3D_CONTROLLER::ToggleVisibility().

◆ m_colors

COLOR_SETTINGS* BOARD_ADAPTER::m_colors
private

Definition at line 412 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetItemColor(), GetLayerColor(), and SetColorSettings().

◆ m_CopperColor

◆ m_copperLayersCount

unsigned int BOARD_ADAPTER::m_copperLayersCount
private

Definition at line 447 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and InitSettings().

◆ m_frontCopperThickness3DU

float BOARD_ADAPTER::m_frontCopperThickness3DU
private

Definition at line 458 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetFrontCopperThickness(), and InitSettings().

◆ m_frontPlatedPadPolys

SHAPE_POLY_SET* BOARD_ADAPTER::m_frontPlatedPadPolys
private

◆ m_holeCount

unsigned int BOARD_ADAPTER::m_holeCount
private

Definition at line 468 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetHoleCount().

◆ m_IsBoardView

◆ m_IsPreviewer

bool BOARD_ADAPTER::m_IsPreviewer

true if the board adaptater is living in a 3D preview panel, false for the standard 3D viewer

Definition at line 395 of file board_adapter.h.

Referenced by IsFootprintShown(), and PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL().

◆ m_layerHoleIdPolys

MAP_POLY BOARD_ADAPTER::m_layerHoleIdPolys
private

Hole inner diameters (per layer)

Definition at line 426 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetHoleIdPolysMap().

◆ m_layerHoleMap

MAP_CONTAINER_2D_BASE BOARD_ADAPTER::m_layerHoleMap
private

Holes for each layer.

Definition at line 436 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetLayerHoleMap().

◆ m_layerHoleOdPolys

MAP_POLY BOARD_ADAPTER::m_layerHoleOdPolys
private

Hole outer diameters (per layer)

Definition at line 425 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetHoleOdPolysMap().

◆ m_layerMap

MAP_CONTAINER_2D_BASE BOARD_ADAPTER::m_layerMap
private

2D elements for each layer.

Definition at line 435 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetLayerMap().

◆ m_layers_poly

MAP_POLY BOARD_ADAPTER::m_layers_poly
private

Amalgamated polygon contours for various types of items.

Definition at line 419 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetPolyMap().

◆ m_layerZcoordBottom

std::array<float, PCB_LAYER_ID_COUNT> BOARD_ADAPTER::m_layerZcoordBottom
private

Bottom (Start) Z position of each layer in 3D units.

Definition at line 455 of file board_adapter.h.

Referenced by GetFootprintZPos(), GetLayerBottomZPos(), and InitSettings().

◆ m_layerZcoordTop

std::array<float, PCB_LAYER_ID_COUNT> BOARD_ADAPTER::m_layerZcoordTop
private

Top (End) Z position of each layer in 3D units.

Definition at line 452 of file board_adapter.h.

Referenced by GetFootprintZPos(), GetLayerTopZPos(), and InitSettings().

◆ m_MousewheelPanning

bool BOARD_ADAPTER::m_MousewheelPanning

◆ m_nonCopperLayerThickness3DU

float BOARD_ADAPTER::m_nonCopperLayerThickness3DU
private

Definition at line 461 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), GetNonCopperLayerThickness(), and InitSettings().

◆ m_nonPlatedThroughHoleOdPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_nonPlatedThroughHoleOdPolys
private

NPTH outer diameters.

Definition at line 428 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetOuterNonPlatedThroughHolePoly().

◆ m_platedPadsBack

BVH_CONTAINER_2D* BOARD_ADAPTER::m_platedPadsBack
private

Definition at line 439 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetPlatedPadsBack().

◆ m_platedPadsFront

BVH_CONTAINER_2D* BOARD_ADAPTER::m_platedPadsFront
private

Definition at line 438 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetPlatedPadsFront().

◆ m_renderSettings

RENDER_SETTINGS* BOARD_ADAPTER::m_renderSettings
private

Definition at line 411 of file board_adapter.h.

◆ m_SilkScreenColorBot

SFVEC4F BOARD_ADAPTER::m_SilkScreenColorBot

◆ m_SilkScreenColorTop

◆ m_SolderMaskColorBot

SFVEC4F BOARD_ADAPTER::m_SolderMaskColorBot

in realistic mode: solder mask color ( bot )

Definition at line 401 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), RENDER_3D_OPENGL::getLayerColor(), InitSettings(), PANEL_PREVIEW_3D_MODEL::loadSettings(), and RENDER_3D_RAYTRACE::Reload().

◆ m_SolderMaskColorTop

SFVEC4F BOARD_ADAPTER::m_SolderMaskColorTop

◆ m_SolderPasteColor

◆ m_solderPasteLayerThickness3DU

float BOARD_ADAPTER::m_solderPasteLayerThickness3DU
private

Definition at line 462 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and InitSettings().

◆ m_throughHoleAnnularRingPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_throughHoleAnnularRingPolys
private

Via annular ring outer diameters.

Definition at line 431 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleAnnularRingPolys().

◆ m_throughHoleAnnularRings

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleAnnularRings
private

List of via annular rings.

Definition at line 443 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetThroughHoleAnnularRings().

◆ m_throughHoleIds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleIds
private

List of PTH inner diameters.

Definition at line 442 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetThroughHoleIds().

◆ m_throughHoleOdPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_throughHoleOdPolys
private

PTH outer diameters.

Definition at line 429 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleOdPolys().

◆ m_throughHoleOds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleOds
private

List of PTH outer diameters.

Definition at line 441 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), destroyLayers(), and GetThroughHoleOds().

◆ m_throughHoleViaIds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleViaIds
private

List of via hole inner diameters.

Definition at line 445 of file board_adapter.h.

Referenced by destroyLayers().

◆ m_throughHoleViaOdPolys

SHAPE_POLY_SET BOARD_ADAPTER::m_throughHoleViaOdPolys
private

Via hole outer diameters.

Definition at line 430 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleViaOdPolys().

◆ m_throughHoleViaOds

BVH_CONTAINER_2D BOARD_ADAPTER::m_throughHoleViaOds
private

List of via hole outer diameters.

Definition at line 444 of file board_adapter.h.

Referenced by createLayers(), destroyLayers(), and GetThroughHoleViaOds().

◆ m_trackCount

unsigned int BOARD_ADAPTER::m_trackCount
private

Definition at line 464 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), and createLayers().

◆ m_viaCount

unsigned int BOARD_ADAPTER::m_viaCount
private

Definition at line 466 of file board_adapter.h.

Referenced by BOARD_ADAPTER(), createLayers(), and GetViaCount().


The documentation for this class was generated from the following files: