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:102
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:590
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 182 of file create_3Dgraphic_brd_items.cpp.

184{
186
187 if( aFootprint->Reference().GetLayer() == aLayerId && aFootprint->Reference().IsVisible() )
188 addText( &aFootprint->Reference(), aContainer, &aFootprint->Reference() );
189
190 if( aFootprint->Value().GetLayer() == aLayerId && aFootprint->Value().IsVisible() )
191 addText( &aFootprint->Value(), aContainer, &aFootprint->Value() );
192
193 for( BOARD_ITEM* item : aFootprint->GraphicalItems() )
194 {
195 switch( item->Type() )
196 {
197 case PCB_FP_TEXT_T:
198 {
199 FP_TEXT* text = static_cast<FP_TEXT*>( item );
200
201 if( text->GetLayer() == aLayerId && text->IsVisible() )
202 addText( text, aContainer, text );
203
204 break;
205 }
206
207 case PCB_FP_TEXTBOX_T:
208 {
209 FP_TEXTBOX* textbox = static_cast<FP_TEXTBOX*>( item );
210
211 if( textbox->GetLayer() == aLayerId )
212 {
213 addShape( textbox, aContainer, aFootprint );
214 addText( textbox, aContainer, aFootprint );
215 }
216
217 break;
218 }
219
225 {
226 PCB_DIMENSION_BASE* dimension = static_cast<PCB_DIMENSION_BASE*>( item );
227
228 if( dimension->GetLayer() == aLayerId )
229 addShape( dimension, aContainer, aFootprint );
230
231 break;
232 }
233
234 case PCB_FP_SHAPE_T:
235 {
236 FP_SHAPE* shape = static_cast<FP_SHAPE*>( item );
237
238 if( shape->GetLayer() == aLayerId )
239 addShape( shape, aContainer, aFootprint );
240
241 break;
242 }
243
244 default:
245 break;
246 }
247 }
248}
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:70
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
virtual bool IsVisible() const
Definition: eda_text.h:136
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.
@ 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 490 of file create_3Dgraphic_brd_items.cpp.

493{
494 for( PAD* pad : aFootprint->Pads() )
495 {
496 if( !pad->IsOnLayer( aLayerId ) )
497 continue;
498
499 // Skip pad annulus when not connected on this layer (if removing is enabled)
500 if( !pad->FlashLayer( aLayerId ) && IsCopperLayer( aLayerId ) )
501 continue;
502
503 // NPTH pads are not drawn on layers if the shape size and pos is the same as their hole:
504 if( aSkipNPTHPadsWihNoCopper && ( pad->GetAttribute() == PAD_ATTRIB::NPTH ) )
505 {
506 if( pad->GetDrillSize() == pad->GetSize() && pad->GetOffset() == VECTOR2I( 0, 0 ) )
507 {
508 switch( pad->GetShape() )
509 {
511 if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
512 continue;
513
514 break;
515
516 case PAD_SHAPE::OVAL:
517 if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
518 continue;
519
520 break;
521
522 default:
523 break;
524 }
525 }
526 }
527
528 VECTOR2I margin( 0, 0 );
529
530 switch( aLayerId )
531 {
532 case F_Cu:
533 if( aSkipPlatedPads && pad->FlashLayer( F_Mask ) )
534 continue;
535
536 if( aSkipNonPlatedPads && !pad->FlashLayer( F_Mask ) )
537 continue;
538
539 break;
540
541 case B_Cu:
542 if( aSkipPlatedPads && pad->FlashLayer( B_Mask ) )
543 continue;
544
545 if( aSkipNonPlatedPads && !pad->FlashLayer( B_Mask ) )
546 continue;
547
548 break;
549
550 case F_Mask:
551 case B_Mask:
552 margin.x += pad->GetSolderMaskExpansion();
553 margin.y += pad->GetSolderMaskExpansion();
554 break;
555
556 case F_Paste:
557 case B_Paste:
558 margin += pad->GetSolderPasteMargin();
559 break;
560
561 default:
562 break;
563 }
564
565 createPadWithMargin( pad, aContainer, aLayerId, margin );
566 }
567}
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:60
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:827
@ 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 145 of file create_3Dgraphic_brd_items.cpp.

147{
148 addText( aDimension, aContainer, aDimension );
149
150 const int linewidth = aDimension->GetLineThickness();
151
152 for( const std::shared_ptr<SHAPE>& shape : aDimension->GetShapes() )
153 {
154 switch( shape->Type() )
155 {
156 case SH_SEGMENT:
157 {
158 const SEG& seg = static_cast<const SHAPE_SEGMENT*>( shape.get() )->GetSeg();
159
160 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( seg.A ), TO_SFVEC2F( seg.B ),
161 TO_3DU( linewidth ), *aOwner ) );
162 break;
163 }
164
165 case SH_CIRCLE:
166 {
167 int radius = static_cast<const SHAPE_CIRCLE*>( shape.get() )->GetRadius();
168 int delta = aDimension->GetLineThickness() / 2;
169
170 aContainer->Add( new RING_2D( TO_SFVEC2F( shape->Centre() ), TO_3DU( radius - delta ),
171 TO_3DU( radius + delta ), *aOwner ) );
172 break;
173 }
174
175 default:
176 break;
177 }
178 }
179}
int GetLineThickness() const
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:48
@ SH_SEGMENT
line segment
Definition: shape.h:46
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, 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 629 of file create_3Dgraphic_brd_items.cpp.

631{
632 // The full width of the lines to create
633 // The extra 1 protects the inner/outer radius values from degeneracy
634 const int linewidth = aShape->GetWidth() + 1;
635 PLOT_DASH_TYPE lineStyle = aShape->GetStroke().GetPlotStyle();
636
637 if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
638 {
639 switch( aShape->GetShape() )
640 {
641 case SHAPE_T::CIRCLE:
642 {
643 const SFVEC2F center3DU = TO_SFVEC2F( aShape->GetCenter() );
644 float inner_radius3DU = TO_3DU( aShape->GetRadius() - linewidth / 2 );
645 float outer_radius3DU = TO_3DU( aShape->GetRadius() + linewidth / 2 );
646
647 if( inner_radius3DU < 0 )
648 inner_radius3DU = 0.0;
649
650 if( outer_radius3DU == 0.0 )
651 {
652 // Don't attempt to render degenerate shapes
653 }
654 else if( aShape->IsFilled() )
655 {
656 aContainer->Add( new FILLED_CIRCLE_2D( center3DU, outer_radius3DU,
657 *aOwner ) );
658 }
659 else
660 {
661 aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU,
662 *aOwner ) );
663 }
664
665 break;
666 }
667
668 case SHAPE_T::RECT:
669 if( aShape->IsFilled() )
670 {
671 SHAPE_POLY_SET polyList;
672
674 ERROR_INSIDE );
675
677
678 ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
679 }
680 else
681 {
682 std::vector<VECTOR2I> pts = aShape->GetRectCorners();
683
684 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[0] ), TO_SFVEC2F( pts[1] ),
685 TO_3DU( linewidth ), *aOwner ) );
686 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[1] ), TO_SFVEC2F( pts[2] ),
687 TO_3DU( linewidth ), *aOwner ) );
688 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[2] ), TO_SFVEC2F( pts[3] ),
689 TO_3DU( linewidth ), *aOwner ) );
690 aContainer->Add( new ROUND_SEGMENT_2D( TO_SFVEC2F( pts[3] ), TO_SFVEC2F( pts[0] ),
691 TO_3DU( linewidth ), *aOwner ) );
692 }
693 break;
694
695 case SHAPE_T::ARC:
696 {
697 unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
698
699 transformArcToSegments( aShape->GetCenter(), aShape->GetStart(), aShape->GetArcAngle(),
700 segCount, linewidth, aContainer, *aOwner );
701 break;
702 }
703
704 case SHAPE_T::SEGMENT:
705 {
706 const SFVEC2F start3DU = TO_SFVEC2F( aShape->GetStart() );
707 const SFVEC2F end3DU = TO_SFVEC2F( aShape->GetEnd() );
708 const double linewidth3DU = TO_3DU( linewidth );
709
710 if( linewidth3DU == 0.0 )
711 {
712 // Don't attempt to render degenerate shapes
713 }
714 else if( Is_segment_a_circle( start3DU, end3DU ) )
715 {
716 // Cannot add segments that have the same start and end point
717 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, linewidth3DU / 2, *aOwner ) );
718 }
719 else
720 {
721 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, linewidth3DU, *aOwner ) );
722 }
723
724 break;
725 }
726
727 case SHAPE_T::BEZIER:
728 case SHAPE_T::POLY:
729 {
730 SHAPE_POLY_SET polyList;
731
733 ERROR_INSIDE );
734
735 if( polyList.IsEmpty() ) // Just for caution
736 break;
737
738 ConvertPolygonToTriangles( polyList, *aContainer, m_biuTo3Dunits, *aOwner );
739 break;
740 }
741
742 default:
743 wxFAIL_MSG( wxT( "BOARD_ADAPTER::addShape no implementation for " )
744 + aShape->SHAPE_T_asString() );
745 break;
746 }
747 }
748 else if( linewidth > 0 )
749 {
750 std::vector<SHAPE*> shapes = aShape->MakeEffectiveShapes( true );
751 SFVEC2F a3DU;
752 SFVEC2F b3DU;
753 double width3DU = TO_3DU( linewidth );
754
755 const PCB_PLOT_PARAMS& plotParams = aShape->GetBoard()->GetPlotOptions();
756 KIGFX::PCB_RENDER_SETTINGS renderSettings;
757
758 renderSettings.SetDashLengthRatio( plotParams.GetDashedLineDashRatio() );
759 renderSettings.SetGapLengthRatio( plotParams.GetDashedLineGapRatio() );
760
761 for( SHAPE* shape : shapes )
762 {
763 STROKE_PARAMS::Stroke( shape, lineStyle, linewidth, &renderSettings,
764 [&]( const VECTOR2I& a, const VECTOR2I& b )
765 {
766 a3DU = TO_SFVEC2F( a );
767 b3DU = TO_SFVEC2F( b );
768
769 if( Is_segment_a_circle( a3DU, b3DU ) )
770 aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aOwner ) );
771 else
772 aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aOwner ) );
773 } );
774 }
775
776 for( SHAPE* shape : shapes )
777 delete shape;
778 }
779}
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:635
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:585
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:523
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:1035
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:390
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:124
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 782 of file create_3Dgraphic_brd_items.cpp.

784{
785 // This convert the poly in outline and holes
786 ConvertPolygonToTriangles( *aZone->GetFilledPolysList( aLayerId ), *aContainer,
787 m_biuTo3Dunits, *aZone );
788}
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:608

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( penWidth_3DU == 0.0 )
116 {
117 // Don't attempt to render degenerate shapes
118 }
119 else if( Is_segment_a_circle( pt1_3DU, pt2_3DU ) )
120 {
121 // Cannot add segments that have the same start and end point
122 aContainer->Add( new FILLED_CIRCLE_2D( pt1_3DU, penWidth_3DU / 2,
123 *aOwner ) );
124 }
125 else
126 {
127 aContainer->Add( new ROUND_SEGMENT_2D( pt1_3DU, pt2_3DU, penWidth_3DU,
128 *aOwner ) );
129 }
130 },
131 // Triangulation callback
132 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
133 {
134 aContainer->Add( new TRIANGLE_2D( TO_SFVEC2F( aPt1 ), TO_SFVEC2F( aPt2 ),
135 TO_SFVEC2F( aPt3 ), *aOwner ) );
136 } );
137
138 attrs.m_Angle = aText->GetDrawRotation();
139
140 font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs );
141 }
142}
virtual bool IsKnockout() const
Definition: board_item.h:262
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:947
bool IsItalic() const
Definition: eda_text.h:130
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:317
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:318
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
bool IsBold() const
Definition: eda_text.h:133
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:138
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:232
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 knocking out text.
Definition: gr_text.h:104

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()

◆ 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:704
VECTOR2I ShapePos() const
Definition: pad.cpp:770
PAD_SHAPE GetShape() const
Definition: pad.h:195
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:361
const VECTOR2I & GetSize() const
Definition: pad.h:258
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 791 of file create_3Dgraphic_brd_items.cpp.

793{
794 if( aPad->GetShape() == PAD_SHAPE::CIRCLE ) // Draw a ring
795 {
796 const SFVEC2F center3DU = TO_SFVEC2F( aPad->ShapePos() );
797 const int radius = aPad->GetSize().x / 2;
798 const float inner_radius3DU = TO_3DU( radius - aWidth / 2 );
799 const float outer_radius3DU = TO_3DU( radius + aWidth / 2 );
800
801 aContainer->Add( new RING_2D( center3DU, inner_radius3DU, outer_radius3DU, *aPad ) );
802
803 return;
804 }
805
806 // For other shapes, add outlines as thick segments in polygon buffer
807 const std::shared_ptr<SHAPE_POLY_SET>& corners = aPad->GetEffectivePolygon();
808 const SHAPE_LINE_CHAIN& path = corners->COutline( 0 );
809
810 for( int j = 0; j < path.PointCount(); j++ )
811 {
812 SFVEC2F start3DU = TO_SFVEC2F( path.CPoint( j ) );
813 SFVEC2F end3DU = TO_SFVEC2F( path.CPoint( j + 1 ) );
814
815 if( aWidth == 0 )
816 {
817 // Don't attempt to render degenerate shapes
818 }
819 else if( Is_segment_a_circle( start3DU, end3DU ) )
820 {
821 // Cannot add segments that have the same start and end point
822 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), *aPad ) );
823 }
824 else
825 {
826 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), *aPad ) );
827 }
828 }
829}

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 // max dist from one endPt to next startPt
675 int chainingEpsilon = m_board->GetOutlinesChainingEpsilon();
676
679 chainingEpsilon );
680
681 // Make polygon strictly simple to avoid issues (especially in 3D viewer)
683
684 if( !success && aErrorMsg )
685 {
686 *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
687 "a full analysis." );
688 }
689 }
690 else
691 {
693
694 if( !success && aErrorMsg )
695 *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
696 }
697
698 return success;
699}
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:299
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:403
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:1972
int GetOutlinesChainingEpsilon()
Definition: board.h:668
#define _(s)

References _, BuildFootprintPolygonOutlines(), BOARD::GetBoardPolygonOutlines(), BOARD::GetDesignSettings(), BOARD::GetFirstFootprint(), BOARD::GetOutlinesChainingEpsilon(), BOARD::IsFootprintHolder(), m_board, m_board_poly, BOARD_DESIGN_SETTINGS::m_MaxError, 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 // Add hole objects
283 BVH_CONTAINER_2D *layerHoleContainer = nullptr;
284
285 // Check if the layer is already created
286 if( m_layerHoleMap.find( layer ) == m_layerHoleMap.end() )
287 {
288 // not found, create a new container
289 layerHoleContainer = new BVH_CONTAINER_2D;
290 m_layerHoleMap[layer] = layerHoleContainer;
291 }
292 else
293 {
294 // found
295 layerHoleContainer = m_layerHoleMap[layer];
296 }
297
298 // Add a hole for this layer
299 layerHoleContainer->Add( new FILLED_CIRCLE_2D( via_center,
300 hole_inner_radius + thickness,
301 *track ) );
302 }
303 else if( layer == layer_ids[0] ) // it only adds once the THT holes
304 {
305 // Add through hole object
306 m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
307 hole_inner_radius + thickness,
308 *track ) );
310 hole_inner_radius + thickness,
311 *track ) );
312
315 && ring_radius > 0.0 )
316 {
318 ring_radius,
319 *track ) );
320 }
321
322 if( hole_inner_radius > 0.0 )
323 {
324 m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center,
325 hole_inner_radius,
326 *track ) );
327 }
328 }
329 }
330 }
331 }
332
333 // Create VIAS and THTs objects and add it to holes containers
334 for( PCB_LAYER_ID layer : layer_ids )
335 {
336 // ADD TRACKS
337 const unsigned int nTracks = trackList.size();
338
339 for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
340 {
341 const PCB_TRACK *track = trackList[trackIdx];
342
343 if( !track->IsOnLayer( layer ) )
344 continue;
345
346 // ADD VIAS and THT
347 if( track->Type() == PCB_VIA_T )
348 {
349 const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
350 const VIATYPE viatype = via->GetViaType();
351
352 if( viatype != VIATYPE::THROUGH )
353 {
354 // Add PCB_VIA hole contours
355
356 // Add outer holes of VIAs
357 SHAPE_POLY_SET *layerOuterHolesPoly = nullptr;
358 SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
359
360 // Check if the layer is already created
361 if( m_layerHoleOdPolys.find( layer ) == m_layerHoleOdPolys.end() )
362 {
363 // not found, create a new container
364 layerOuterHolesPoly = new SHAPE_POLY_SET;
365 m_layerHoleOdPolys[layer] = layerOuterHolesPoly;
366
367 wxASSERT( m_layerHoleIdPolys.find( layer ) == m_layerHoleIdPolys.end() );
368
369 layerInnerHolesPoly = new SHAPE_POLY_SET;
370 m_layerHoleIdPolys[layer] = layerInnerHolesPoly;
371 }
372 else
373 {
374 // found
375 layerOuterHolesPoly = m_layerHoleOdPolys[layer];
376
377 wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
378
379 layerInnerHolesPoly = m_layerHoleIdPolys[layer];
380 }
381
382 const int holediameter = via->GetDrillValue();
383 const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
384
385 TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
386 hole_outer_radius, maxError, ERROR_INSIDE );
387
388 TransformCircleToPolygon( *layerInnerHolesPoly, via->GetStart(),
389 holediameter / 2, maxError, ERROR_INSIDE );
390 }
391 else if( layer == layer_ids[0] ) // it only adds once the THT holes
392 {
393 const int holediameter = via->GetDrillValue();
394 const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
395 const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
396
397 // Add through hole contours
399 hole_outer_radius, maxError, ERROR_INSIDE );
400
401 // Add same thing for vias only
403 hole_outer_radius, maxError, ERROR_INSIDE );
404
406 {
408 hole_outer_ring_radius, maxError, ERROR_INSIDE );
409 }
410 }
411 }
412 }
413 }
414
415 // Creates vertical outline contours of the tracks and add it to the poly of the layer
417 {
418 for( PCB_LAYER_ID layer : layer_ids )
419 {
420 wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
421
422 SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
423
424 // ADD TRACKS
425 unsigned int nTracks = trackList.size();
426
427 for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
428 {
429 const PCB_TRACK *track = trackList[trackIdx];
430
431 if( !track->IsOnLayer( layer ) )
432 continue;
433
434 // Skip vias annulus when not connected on this layer (if removing is enabled)
435 const PCB_VIA *via = dyn_cast<const PCB_VIA*>( track );
436
437 if( via && !via->FlashLayer( layer ) && IsCopperLayer( layer ) )
438 continue;
439
440 // Add the track/via contour
441 track->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
442 }
443 }
444 }
445
446 // Add holes of footprints
447 for( FOOTPRINT* footprint : m_board->Footprints() )
448 {
449 for( PAD* pad : footprint->Pads() )
450 {
451 const VECTOR2I padHole = pad->GetDrillSize();
452
453 if( !padHole.x ) // Not drilled pad like SMD pad
454 continue;
455
456 // The hole in the body is inflated by copper thickness, if not plated, no copper
457 const int inflate = ( pad->GetAttribute () != PAD_ATTRIB::NPTH ) ?
458 GetHolePlatingThickness() / 2 : 0;
459
460 m_holeCount++;
461 m_averageHoleDiameter += ( ( pad->GetDrillSize().x +
462 pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
463
465
468
470 }
471 }
472
473 if( m_holeCount )
475
476 // Add contours of the pad holes (pads can be Circle or Segment holes)
477 for( FOOTPRINT* footprint : m_board->Footprints() )
478 {
479 for( PAD* pad : footprint->Pads() )
480 {
481 const VECTOR2I padHole = pad->GetDrillSize();
482
483 if( !padHole.x ) // Not drilled pad like SMD pad
484 continue;
485
486 // The hole in the body is inflated by copper thickness.
487 const int inflate = GetHolePlatingThickness();
488
489 if( pad->GetAttribute () != PAD_ATTRIB::NPTH )
490 {
492 {
493 pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, inflate, maxError,
494 ERROR_INSIDE );
495 }
496
497 pad->TransformHoleToPolygon( m_throughHoleOdPolys, inflate, maxError,
498 ERROR_INSIDE );
499 }
500 else
501 {
502 // If not plated, no copper.
504 {
505 pad->TransformHoleToPolygon( m_throughHoleAnnularRingPolys, 0, maxError,
506 ERROR_INSIDE );
507 }
508
509 pad->TransformHoleToPolygon( m_nonPlatedThroughHoleOdPolys, 0, maxError,
510 ERROR_INSIDE );
511 }
512 }
513 }
514
515 const bool renderPlatedPadsAsPlated = m_Cfg->m_Render.renderPlatedPadsAsPlated
517
518 // Add footprints PADs objects to containers
519 for( PCB_LAYER_ID layer : layer_ids )
520 {
521 wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
522
523 BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
524
525 // ADD PADS
526 for( FOOTPRINT* footprint : m_board->Footprints() )
527 {
528 // Note: NPTH pads are not drawn on copper layers when the pad has the same shape
529 // as its hole
530 addPads( footprint, layerContainer, layer, true, renderPlatedPadsAsPlated, false );
531
532 // Micro-wave footprints may have items on copper layers
533 addFootprintShapes( footprint, layerContainer, layer );
534 }
535 }
536
537 if( renderPlatedPadsAsPlated )
538 {
539 // ADD PLATED PADS
540 for( FOOTPRINT* footprint : m_board->Footprints() )
541 {
542 addPads( footprint, m_platedPadsFront, F_Cu, true, false, true );
543 addPads( footprint, m_platedPadsBack, B_Cu, true, false, true );
544 }
545
548 }
549
550 // Add footprints PADs poly contours (vertical outlines)
552 {
553 for( PCB_LAYER_ID layer : layer_ids )
554 {
555 wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
556
557 SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
558
559 // Add pads to polygon list
560 for( FOOTPRINT* footprint : m_board->Footprints() )
561 {
562 // Note: NPTH pads are not drawn on copper layers when the pad has same shape as
563 // its hole
564 footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE,
565 true, renderPlatedPadsAsPlated, false );
566
567 transformFPShapesToPolySet( footprint, layer, *layerPoly );
568 }
569 }
570
571 if( renderPlatedPadsAsPlated )
572 {
573 // ADD PLATED PADS contours
574 for( FOOTPRINT* footprint : m_board->Footprints() )
575 {
576 footprint->TransformPadsToPolySet( *m_frontPlatedPadPolys, F_Cu, 0, maxError,
577 ERROR_INSIDE, true, false, true );
578
579 footprint->TransformPadsToPolySet( *m_backPlatedPadPolys, B_Cu, 0, maxError,
580 ERROR_INSIDE, true, false, true );
581 }
582 }
583 }
584
585 // Add graphic item on copper layers to object containers
586 for( PCB_LAYER_ID layer : layer_ids )
587 {
588 wxASSERT( m_layerMap.find( layer ) != m_layerMap.end() );
589
590 BVH_CONTAINER_2D *layerContainer = m_layerMap[layer];
591
592 // Add graphic items on copper layers (texts and other graphics)
593 for( BOARD_ITEM* item : m_board->Drawings() )
594 {
595 if( !item->IsOnLayer( layer ) )
596 continue;
597
598 switch( item->Type() )
599 {
600 case PCB_SHAPE_T:
601 addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
602 break;
603
604 case PCB_TEXT_T:
605 addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
606 break;
607
608 case PCB_TEXTBOX_T:
609 addText( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
610 addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
611 break;
612
614 case PCB_DIM_CENTER_T:
615 case PCB_DIM_RADIAL_T:
617 case PCB_DIM_LEADER_T:
618 addShape( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer, item );
619 break;
620
621 default:
622 wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
623 item->Type() );
624 break;
625 }
626 }
627 }
628
629 // Add graphic item on copper layers to poly contours (vertical outlines)
631 {
632 for( PCB_LAYER_ID layer : layer_ids )
633 {
634 wxASSERT( m_layers_poly.find( layer ) != m_layers_poly.end() );
635
636 SHAPE_POLY_SET *layerPoly = m_layers_poly[layer];
637
638 // Add graphic items on copper layers (texts and other )
639 for( BOARD_ITEM* item : m_board->Drawings() )
640 {
641 if( !item->IsOnLayer( layer ) )
642 continue;
643
644 switch( item->Type() )
645 {
646 case PCB_SHAPE_T:
647 item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
648 break;
649
650 case PCB_TEXT_T:
651 {
652 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
653
654 text->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
655 break;
656 }
657
658 case PCB_TEXTBOX_T:
659 {
660 PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
661
662 textbox->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
663 break;
664 }
665
666 default:
667 wxLogTrace( m_logTrace, wxT( "createLayers: item type: %d not implemented" ),
668 item->Type() );
669 break;
670 }
671 }
672 }
673 }
674
676 {
677 if( aStatusReporter )
678 aStatusReporter->Report( _( "Create zones" ) );
679
680 std::vector<std::pair<ZONE*, PCB_LAYER_ID>> zones;
681 std::unordered_map<PCB_LAYER_ID, std::unique_ptr<std::mutex>> layer_lock;
682
683 for( ZONE* zone : m_board->Zones() )
684 {
685 for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
686 {
687 zones.emplace_back( std::make_pair( zone, layer ) );
688 layer_lock.emplace( layer, std::make_unique<std::mutex>() );
689 }
690 }
691
692 // Add zones objects
693 std::atomic<size_t> nextZone( 0 );
694 std::atomic<size_t> threadsFinished( 0 );
695
696 size_t parallelThreadCount = std::min<size_t>( zones.size(),
697 std::max<size_t>( std::thread::hardware_concurrency(), 2 ) );
698
699 for( size_t ii = 0; ii < parallelThreadCount; ++ii )
700 {
701 std::thread t = std::thread( [&]()
702 {
703 for( size_t areaId = nextZone.fetch_add( 1 );
704 areaId < zones.size();
705 areaId = nextZone.fetch_add( 1 ) )
706 {
707 ZONE* zone = zones[areaId].first;
708
709 if( zone == nullptr )
710 break;
711
712 PCB_LAYER_ID layer = zones[areaId].second;
713
714 auto layerContainer = m_layerMap.find( layer );
715 auto layerPolyContainer = m_layers_poly.find( layer );
716
717 if( layerContainer != m_layerMap.end() )
718 addSolidAreasShapes( zone, layerContainer->second, layer );
719
720 if( m_Cfg->m_Render.opengl_copper_thickness
721 && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL
722 && layerPolyContainer != m_layers_poly.end() )
723 {
724 auto mut_it = layer_lock.find( layer );
725
726 std::lock_guard< std::mutex > lock( *( mut_it->second ) );
727 zone->TransformSolidAreasShapesToPolygon( layer, *layerPolyContainer->second );
728 }
729 }
730
731 threadsFinished++;
732 } );
733
734 t.detach();
735 }
736
737 while( threadsFinished < parallelThreadCount )
738 std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
739
740 }
741
742 // Simplify layer polygons
743
744 if( aStatusReporter )
745 aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
746
748 {
749 if( renderPlatedPadsAsPlated )
750 {
751 if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
752 {
753 if( aStatusReporter )
754 aStatusReporter->Report( _( "Simplifying polygons on F_Cu" ) );
755
756 SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
758
760 }
761
762 if( m_backPlatedPadPolys && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
763 {
764 if( aStatusReporter )
765 aStatusReporter->Report( _( "Simplifying polygons on B_Cu" ) );
766
767 SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
769
771 }
772 }
773
774 std::vector<PCB_LAYER_ID> &selected_layer_id = layer_ids;
775 std::vector<PCB_LAYER_ID> layer_id_without_F_and_B;
776
777 if( renderPlatedPadsAsPlated )
778 {
779 layer_id_without_F_and_B.clear();
780 layer_id_without_F_and_B.reserve( layer_ids.size() );
781
782 for( PCB_LAYER_ID layer: layer_ids )
783 {
784 if( layer != F_Cu && layer != B_Cu )
785 layer_id_without_F_and_B.push_back( layer );
786 }
787
788 selected_layer_id = layer_id_without_F_and_B;
789 }
790
791 if( selected_layer_id.size() > 0 )
792 {
793 if( aStatusReporter )
794 {
795 aStatusReporter->Report( wxString::Format( _( "Simplifying %d copper layers" ),
796 (int) selected_layer_id.size() ) );
797 }
798
799 std::atomic<size_t> nextItem( 0 );
800 std::atomic<size_t> threadsFinished( 0 );
801
802 size_t parallelThreadCount = std::min<size_t>(
803 std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
804 selected_layer_id.size() );
805
806 for( size_t ii = 0; ii < parallelThreadCount; ++ii )
807 {
808 std::thread t = std::thread(
809 [&nextItem, &threadsFinished, &selected_layer_id, this]()
810 {
811 for( size_t i = nextItem.fetch_add( 1 );
812 i < selected_layer_id.size();
813 i = nextItem.fetch_add( 1 ) )
814 {
815 auto layerPoly = m_layers_poly.find( selected_layer_id[i] );
816
817 if( layerPoly != m_layers_poly.end() )
818 // This will make a union of all added contours
819 layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
820 }
821
822 threadsFinished++;
823 } );
824
825 t.detach();
826 }
827
828 while( threadsFinished < parallelThreadCount )
829 std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
830 }
831 }
832
833 // Simplify holes polygon contours
834 if( aStatusReporter )
835 aStatusReporter->Report( _( "Simplify holes contours" ) );
836
837 for( PCB_LAYER_ID layer : layer_ids )
838 {
839 if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
840 {
841 // found
842 SHAPE_POLY_SET *polyLayer = m_layerHoleOdPolys[layer];
843 polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
844
845 wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
846
847 polyLayer = m_layerHoleIdPolys[layer];
848 polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
849 }
850 }
851
852 // End Build Copper layers
853
854 // This will make a union of all added contours
859
860 // Build Tech layers
861 // Based on:
862 // https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
863 if( aStatusReporter )
864 aStatusReporter->Report( _( "Build Tech layers" ) );
865
866 // draw graphic items, on technical layers
867
868 // Vertical walls (layer thickness) around shapes is really time consumming
869 // They are built on request
870 bool buildVerticalWallsForTechLayers = m_Cfg->m_Render.opengl_copper_thickness
872
873 static const PCB_LAYER_ID techLayerList[] = {
874 B_Adhes,
875 F_Adhes,
876 B_Paste,
877 F_Paste,
878 B_SilkS,
879 F_SilkS,
880 B_Mask,
881 F_Mask,
882
883 // Aux Layers
884 Dwgs_User,
885 Cmts_User,
886 Eco1_User,
887 Eco2_User,
888 Edge_Cuts,
889 Margin
890 };
891
892 // User layers are not drawn here, only technical layers
893 for( LSEQ seq = LSET::AllNonCuMask().Seq( techLayerList, arrayDim( techLayerList ) );
894 seq;
895 ++seq )
896 {
897 const PCB_LAYER_ID layer = *seq;
898
899 if( !Is3dLayerEnabled( layer ) )
900 continue;
901
902 if( aStatusReporter )
903 aStatusReporter->Report( wxString::Format( _( "Build Tech layer %d" ), (int) layer ) );
904
905 BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
906 m_layerMap[layer] = layerContainer;
907
908 SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
909 m_layers_poly[layer] = layerPoly;
910
911 // Add drawing objects
912 for( BOARD_ITEM* item : m_board->Drawings() )
913 {
914 if( !item->IsOnLayer( layer ) )
915 continue;
916
917 switch( item->Type() )
918 {
919 case PCB_SHAPE_T:
920 addShape( static_cast<PCB_SHAPE*>( item ), layerContainer, item );
921 break;
922
923 case PCB_TEXT_T:
924 addText( static_cast<PCB_TEXT*>( item ), layerContainer, item );
925 break;
926
927 case PCB_TEXTBOX_T:
928 addText( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
929 addShape( static_cast<PCB_TEXTBOX*>( item ), layerContainer, item );
930 break;
931
933 case PCB_DIM_CENTER_T:
934 case PCB_DIM_RADIAL_T:
936 case PCB_DIM_LEADER_T:
937 addShape( static_cast<PCB_DIMENSION_BASE*>( item ), layerContainer, item );
938 break;
939
940 default:
941 break;
942 }
943 }
944
945 // Add drawing contours (vertical walls)
946 if( buildVerticalWallsForTechLayers )
947 {
948 for( BOARD_ITEM* item : m_board->Drawings() )
949 {
950 if( !item->IsOnLayer( layer ) )
951 continue;
952
953 switch( item->Type() )
954 {
955 case PCB_SHAPE_T:
956 item->TransformShapeToPolygon( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
957 break;
958
959 case PCB_TEXT_T:
960 {
961 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
962
963 text->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
964 break;
965 }
966
967 case PCB_TEXTBOX_T:
968 {
969 PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( item );
970
971 textbox->TransformTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
972 break;
973 }
974
975 default:
976 break;
977 }
978 }
979 }
980
981 // Add footprints tech layers - objects
982 for( FOOTPRINT* footprint : m_board->Footprints() )
983 {
984 if( layer == F_SilkS || layer == B_SilkS )
985 {
987
988 for( PAD* pad : footprint->Pads() )
989 {
990 if( !pad->IsOnLayer( layer ) )
991 continue;
992
993 buildPadOutlineAsSegments( pad, layerContainer, linewidth );
994 }
995 }
996 else
997 {
998 addPads( footprint, layerContainer, layer, false, false, false );
999 }
1000
1001 addFootprintShapes( footprint, layerContainer, layer );
1002 }
1003
1004
1005 // Add footprints tech layers - contours (vertical walls)
1006 if( buildVerticalWallsForTechLayers )
1007 {
1008 for( FOOTPRINT* footprint : m_board->Footprints() )
1009 {
1010 if( layer == F_SilkS || layer == B_SilkS )
1011 {
1013
1014 for( PAD* pad : footprint->Pads() )
1015 {
1016 if( !pad->IsOnLayer( layer ) )
1017 continue;
1018
1019 buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
1020 }
1021 }
1022 else
1023 {
1024 footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
1025 }
1026
1027 // On tech layers, use a poor circle approximation, only for texts (stroke font)
1028 footprint->TransformFPTextToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE );
1029
1030 // Add the remaining things with dynamic seg count for circles
1031 transformFPShapesToPolySet( footprint, layer, *layerPoly );
1032 }
1033 }
1034
1035 // Draw non copper zones
1037 {
1038 for( ZONE* zone : m_board->Zones() )
1039 {
1040 if( zone->IsOnLayer( layer ) )
1041 addSolidAreasShapes( zone, layerContainer, layer );
1042 }
1043
1044 if( buildVerticalWallsForTechLayers )
1045 {
1046 for( ZONE* zone : m_board->Zones() )
1047 {
1048
1049 if( zone->IsOnLayer( layer ) )
1050 zone->TransformSolidAreasShapesToPolygon( layer, *layerPoly );
1051 }
1052 }
1053 }
1054
1055 // This will make a union of all added contours
1056 layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1057 }
1058 // End Build Tech layers
1059
1060 // Build BVH (Bounding volume hierarchy) for holes and vias
1061
1062 if( aStatusReporter )
1063 aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
1064
1068
1069 if( !m_layerHoleMap.empty() )
1070 {
1071 for( std::pair<const PCB_LAYER_ID, BVH_CONTAINER_2D*>& hole : m_layerHoleMap )
1072 hole.second->BuildBVH();
1073 }
1074
1075 // We only need the Solder mask to initialize the BVH
1076 // because..?
1077 if( m_layerMap[B_Mask] )
1078 m_layerMap[B_Mask]->BuildBVH();
1079
1080 if( m_layerMap[F_Mask] )
1081 m_layerMap[F_Mask]->BuildBVH();
1082}
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, bool aIncludeCourtyards=false) const
Test to see if this object is on the given layer.
Definition: board_item.h:257
ZONES & Zones()
Definition: board.h:317
FOOTPRINTS & Footprints()
Definition: board.h:311
TRACKS & Tracks()
Definition: board.h:308
DRAWINGS & Drawings()
Definition: board.h:314
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:493
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
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:1212
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:65
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 464 of file create_3Dgraphic_brd_items.cpp.

465{
466 if( !aPad->HasHole() )
467 {
468 wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
469 return nullptr;
470 }
471
472 std::shared_ptr<SHAPE_SEGMENT> slot = aPad->GetEffectiveHoleShape();
473
474 if( slot->GetSeg().A == slot->GetSeg().B )
475 {
476 return new FILLED_CIRCLE_2D( TO_SFVEC2F( slot->GetSeg().A ),
477 TO_3DU( slot->GetWidth() / 2 + aInflateValue ),
478 *aPad );
479 }
480 else
481 {
482 return new ROUND_SEGMENT_2D( TO_SFVEC2F( slot->GetSeg().A ),
483 TO_SFVEC2F( slot->GetSeg().B ),
484 TO_3DU( slot->GetWidth() + aInflateValue * 2 ),
485 *aPad );
486 }
487}
bool HasHole() const override
Definition: pad.h:107
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition: pad.cpp:407

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 322 of file create_3Dgraphic_brd_items.cpp.

324{
325 SHAPE_POLY_SET poly;
326 int maxError = GetBoard()->GetDesignSettings().m_MaxError;
327 VECTOR2I clearance = aMargin;
328
329 // Our shape-based builder can't handle negative or differing x:y clearance values (the
330 // former are common for solder paste while the later get generated when a relative paste
331 // margin is used with an oblong pad). So we apply this huge hack and fake a larger pad to
332 // run the general-purpose polygon builder on.
333 // Of course being a hack it falls down when dealing with custom shape pads (where the size
334 // is only the size of the anchor), so for those we punt and just use aMargin.x.
335
336 if( ( clearance.x < 0 || clearance.x != clearance.y )
337 && aPad->GetShape() != PAD_SHAPE::CUSTOM )
338 {
339 VECTOR2I dummySize = VECTOR2I( aPad->GetSize() ) + clearance + clearance;
340
341 if( dummySize.x <= 0 || dummySize.y <= 0 )
342 return;
343
344 PAD dummy( *aPad );
345 dummy.SetSize( VECTOR2I( dummySize.x, dummySize.y ) );
346 dummy.TransformShapeToPolygon( poly, aLayer, 0, maxError, ERROR_INSIDE );
347 clearance = { 0, 0 };
348 }
349 else
350 {
351 auto padShapes = std::static_pointer_cast<SHAPE_COMPOUND>( aPad->GetEffectiveShape() );
352
353 for( const SHAPE* shape : padShapes->Shapes() )
354 {
355 switch( shape->Type() )
356 {
357 case SH_SEGMENT:
358 {
359 const SHAPE_SEGMENT* seg = static_cast<const SHAPE_SEGMENT*>( shape );
360
361 const SFVEC2F a3DU = TO_SFVEC2F( seg->GetSeg().A );
362 const SFVEC2F b3DU = TO_SFVEC2F( seg->GetSeg().B );
363 const double width3DU = TO_3DU( seg->GetWidth() + clearance.x * 2 );
364
365 if( width3DU == 0.0 )
366 {
367 // Don't attempt to render degenerate shapes
368 }
369 else if( Is_segment_a_circle( a3DU, b3DU ) )
370 {
371 // Cannot add segments that have the same start and end point
372 aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
373 }
374 else
375 {
376 aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
377 }
378
379 break;
380 }
381
382 case SH_CIRCLE:
383 {
384 const SHAPE_CIRCLE* circle = static_cast<const SHAPE_CIRCLE*>( shape );
385
386 const double radius3DU = TO_3DU( circle->GetRadius() + clearance.x );
387 const SFVEC2F center3DU = TO_SFVEC2F( circle->GetCenter() );
388
389 // Don't render zero radius circles
390 if( radius3DU > 0.0 )
391 aContainer->Add( new FILLED_CIRCLE_2D( center3DU, radius3DU, *aPad ) );
392
393 break;
394 }
395
396 case SH_RECT:
397 {
398 const SHAPE_RECT* rect = static_cast<const SHAPE_RECT*>( shape );
399
400 poly.NewOutline();
401 poly.Append( rect->GetPosition() );
402 poly.Append( rect->GetPosition().x + rect->GetSize().x, rect->GetPosition().y );
403 poly.Append( rect->GetPosition() + rect->GetSize() );
404 poly.Append( rect->GetPosition().x, rect->GetPosition().y + rect->GetSize().y );
405 break;
406 }
407
408 case SH_SIMPLE:
409 poly.AddOutline( static_cast<const SHAPE_SIMPLE*>( shape )->Vertices() );
410 break;
411
412 case SH_POLY_SET:
413 poly = *(SHAPE_POLY_SET*) shape;
414 break;
415
416 case SH_ARC:
417 {
418 const SHAPE_ARC* arc = static_cast<const SHAPE_ARC*>( shape );
419 SHAPE_LINE_CHAIN l = arc->ConvertToPolyline( maxError );
420
421 for( int i = 0; i < l.SegmentCount(); i++ )
422 {
423 SHAPE_SEGMENT seg( l.Segment( i ).A, l.Segment( i ).B, arc->GetWidth() );
424 const SFVEC2F a3DU = TO_SFVEC2F( seg.GetSeg().A );
425 const SFVEC2F b3DU = TO_SFVEC2F( seg.GetSeg().B );
426 const double width3DU = TO_3DU( arc->GetWidth() + clearance.x * 2 );
427
428 if( width3DU == 0.0 )
429 {
430 // Don't attempt to render degenerate shapes
431 }
432 else if( Is_segment_a_circle( a3DU, b3DU ) )
433 {
434 // Cannot add segments that have the same start and end point
435 aContainer->Add( new FILLED_CIRCLE_2D( a3DU, width3DU / 2, *aPad ) );
436 }
437 else
438 {
439 aContainer->Add( new ROUND_SEGMENT_2D( a3DU, b3DU, width3DU, *aPad ) );
440 }
441 }
442
443 break;
444 }
445
446 default:
447 UNIMPLEMENTED_FOR( SHAPE_TYPE_asString( shape->Type() ) );
448 break;
449 }
450 }
451 }
452
453 if( !poly.IsEmpty() )
454 {
455 if( clearance.x )
456 poly.Inflate( clearance.x, 32 );
457
458 // Add the PAD polygon
459 ConvertPolygonToTriangles( poly, *aContainer, m_biuTo3Dunits, *aPad );
460 }
461}
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:370
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:470
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
@ SH_POLY_SET
set of polygons (with holes, etc.)
Definition: shape.h:50
@ SH_RECT
axis-aligned rectangle
Definition: shape.h:45
@ SH_SIMPLE
simple polygon
Definition: shape.h:49
@ SH_ARC
circular arc
Definition: shape.h:52
static wxString SHAPE_TYPE_asString(SHAPE_TYPE a)
Definition: shape.h:57
std::vector< FAB_LAYER_COLOR > dummy

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 251 of file create_3Dgraphic_brd_items.cpp.

252{
253 SFVEC2F start3DU = TO_SFVEC2F( aTrack->GetStart() );
254 SFVEC2F end3DU = TO_SFVEC2F( aTrack->GetEnd() );
255
256 switch( aTrack->Type() )
257 {
258 case PCB_VIA_T:
259 {
260 const float radius3DU = TO_3DU( aTrack->GetWidth() / 2 );
261
262 if( radius3DU > 0.0 )
263 aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius3DU, *aTrack ) );
264
265 break;
266 }
267
268 case PCB_ARC_T:
269 {
270 const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
271
272 VECTOR2D center( arc->GetCenter() );
273 EDA_ANGLE arc_angle = arc->GetAngle();
274 double radius = arc->GetRadius();
275 int arcsegcount = GetArcToSegmentCount( radius, ARC_HIGH_DEF, arc_angle );
276 int circlesegcount;
277
278 // We need a circle to segment count. However, the arc angle can be small, and the
279 // radius very big. so we calculate a reasonable value for circlesegcount.
280 if( arcsegcount <= 1 ) // The arc will be approximated by a segment
281 {
282 circlesegcount = 1;
283 }
284 else
285 {
286 circlesegcount = KiROUND( arcsegcount * 360.0 / std::abs( arc_angle.AsDegrees() ) );
287 circlesegcount = std::max( 1, std::min( circlesegcount, 128 ) );
288 }
289
290 transformArcToSegments( VECTOR2I( center.x, center.y ), arc->GetStart(), arc_angle,
291 circlesegcount, arc->GetWidth(), aDstContainer, *arc );
292 break;
293 }
294
295 case PCB_TRACE_T: // Track is a usual straight segment
296 {
297 if( aTrack->GetWidth() == 0 )
298 {
299 // Don't attempt to render degenerate shapes
300 }
301 else if( Is_segment_a_circle( start3DU, end3DU ) )
302 {
303 // Cannot add segments that have the same start and end point
304 aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aTrack->GetWidth() / 2 ),
305 *aTrack ) );
306 }
307 else
308 {
309 aDstContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aTrack->GetWidth() ),
310 *aTrack ) );
311 }
312
313 break;
314 }
315
316 default:
317 break;
318 }
319}
double AsDegrees() const
Definition: eda_angle.h:149
double GetRadius() const
Definition: pcb_track.cpp:1140
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1146
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_track.h:322
int GetWidth() const
Definition: pcb_track.h:108
const VECTOR2I & GetStart() const
Definition: pcb_track.h:114
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:111
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
@ 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:427

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 737 of file board_adapter.cpp.

738{
739 return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
740}
double r
Red component.
Definition: color4d.h:372
double g
Green component.
Definition: color4d.h:373
double a
Alpha component.
Definition: color4d.h:375
double b
Blue component.
Definition: color4d.h:374

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(), RENDER_3D_OPENGL::renderOpaqueModels(), and RENDER_3D_OPENGL::renderTransparentModels().

◆ 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 702 of file board_adapter.cpp.

703{
704 if( aIsFlipped )
705 {
708 else
710 }
711 else
712 {
715 else
717 }
718}

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_OPENGL::get3dModelsFromFootprint(), and RENDER_3D_RAYTRACE::load3DModels().

◆ 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 731 of file board_adapter.cpp.

732{
733 return GetColor( m_colors->GetColor( aItemId ) );
734}
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 721 of file board_adapter.cpp.

722{
723 wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
724
725 const COLOR4D color = m_colors->GetColor( aLayerId );
726
727 return SFVEC4F( color.r, color.g, color.b, color.a );
728}
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 743 of file board_adapter.cpp.

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

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}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
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:1253
int GetCopperLayerCount() const
Definition: board.cpp:563
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:293
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
@ LAYER_3D_SOLDERMASK_TOP
Definition: layer_ids.h:444
@ LAYER_3D_COPPER
Definition: layer_ids.h:440
@ LAYER_3D_BACKGROUND_TOP
Definition: layer_ids.h:438
@ LAYER_3D_SOLDERMASK_BOTTOM
Definition: layer_ids.h:443
@ LAYER_3D_BOARD
Definition: layer_ids.h:439
@ LAYER_3D_SILKSCREEN_TOP
Definition: layer_ids.h:442
@ LAYER_3D_SOLDERPASTE
Definition: layer_ids.h:445
@ LAYER_3D_BACKGROUND_BOTTOM
Definition: layer_ids.h:437
@ LAYER_3D_SILKSCREEN_BOTTOM
Definition: layer_ids.h:441
@ 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.
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

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:613
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:593

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_OPENGL::get3dModelsSelected(), and RENDER_3D_RAYTRACE::load3DModels().

◆ 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 572 of file create_3Dgraphic_brd_items.cpp.

576{
577 // Don't attempt to render degenerate shapes
578 if( aWidth == 0 )
579 return;
580
581 VECTOR2I arc_start, arc_end;
582 EDA_ANGLE arcAngle( aArcAngle );
583 EDA_ANGLE delta = ANGLE_360 / aCircleToSegmentsCount; // rotate angle
584
585 arc_end = arc_start = aStart;
586
587 if( arcAngle != ANGLE_360 )
588 RotatePoint( arc_end, aCentre, -arcAngle );
589
590 if( arcAngle < ANGLE_0 )
591 {
592 std::swap( arc_start, arc_end );
593 arcAngle = -arcAngle;
594 }
595
596 // Compute the ends of segments and creates poly
597 VECTOR2I curr_end = arc_start;
598 VECTOR2I curr_start = arc_start;
599
600 for( EDA_ANGLE ii = delta; ii < arcAngle; ii += delta )
601 {
602 curr_end = arc_start;
603 RotatePoint( curr_end, aCentre, -ii );
604
605 const SFVEC2F start3DU = TO_SFVEC2F( curr_start );
606 const SFVEC2F end3DU = TO_SFVEC2F( curr_end );
607
608 if( Is_segment_a_circle( start3DU, end3DU ) )
609 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
610 else
611 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
612
613 curr_start = curr_end;
614 }
615
616 if( curr_end != arc_end )
617 {
618 const SFVEC2F start3DU = TO_SFVEC2F( curr_end );
619 const SFVEC2F end3DU = TO_SFVEC2F( arc_end );
620
621 if( Is_segment_a_circle( start3DU, end3DU ) )
622 aContainer->Add( new FILLED_CIRCLE_2D( start3DU, TO_3DU( aWidth / 2 ), aOwner ) );
623 else
624 aContainer->Add( new ROUND_SEGMENT_2D( start3DU, end3DU, TO_3DU( aWidth ), aOwner ) );
625 }
626}
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:435
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429
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(), RENDER_3D_OPENGL::get3dModelsSelected(), 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_RAYTRACE::renderAntiAliasPackets(), RENDER_3D_RAYTRACE::renderBlockTracing(), RENDER_3D_OPENGL::renderModel(), RENDER_3D_OPENGL::renderOpaqueModels(), RENDER_3D_OPENGL::renderTransparentModels(), 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: