25 #include "../3d_rendering/camera.h" 71 m_3dModelManager( nullptr ),
76 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::BOARD_ADAPTER" ) );
83 m_colors =
Pgm().GetSettingsManager().GetColorSettings();
163 #define ADD_COLOR( list, r, g, b, a, name ) \ 164 list.push_back( CUSTOM_COLOR_ITEM( r/255.0, g/255.0, b/255.0, a, name ) ) 315 if( aFPAttributes &
FP_SMD )
325 #define COPPER_THICKNESS Millimeter2iu( 0.035 ) // for 35 um 327 #define TECH_LAYER_THICKNESS Millimeter2iu( 0.025 ) 330 #define SOLDERPASTE_LAYER_THICKNESS Millimeter2iu( 0.04 ) 341 wxASSERT( aDiameter3DU > 0.0f );
349 wxASSERT( aDiameterBIU > 0 );
357 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::InitSettings" ) );
359 if( aStatusReporter )
360 aStatusReporter->
Report(
_(
"Build board outline" ) );
366 if( aWarningReporter )
368 if( !succeedToGetBoardPolygon )
371 aWarningReporter->
Report( wxEmptyString );
376 bool boardEdgesOnly =
true;
379 || !succeedToGetBoardPolygon )
381 boardEdgesOnly =
false;
444 #define layerThicknessMargin 1.1 469 zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
474 zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
479 zposBottom = zpos_copperTop_back;
484 zposBottom = zpos_copperTop_back;
489 zposBottom = zpos_copperTop_front;
494 zposBottom = zpos_copperTop_front;
499 zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
504 zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
510 zposTop = zpos_copperTop_front + (layer_id -
MAX_CU_LAYERS + 3.0f) * zpos_offset;
533 #ifdef PRINT_STATISTICS_3D_VIEWER 537 if( aStatusReporter )
538 aStatusReporter->
Report(
_(
"Create layers" ) );
547 return SFVEC4F( src.r, src.g, src.b, src.a );
562 if( aColorName.StartsWith( wxT(
"#" ) ) )
570 if(
color.m_ColorName == aColorName )
571 return color.m_Color;
587 wxString colorName = stackupItem->GetColor();
589 switch( stackupItem->GetType() )
592 if( stackupItem->GetBrdLayerId() ==
F_SilkS )
599 if( stackupItem->GetBrdLayerId() ==
F_Mask )
609 const wxString& materialName = stackupItem->GetMaterial();
611 if( materialName.StartsWith( wxT(
"FR4" ) ) )
613 layerColor = findColor( wxT(
"FR4 natural" ),
g_BoardColors );
615 else if( materialName.IsSameAs( wxT(
"PTFE" ) )
616 || materialName.IsSameAs( wxT(
"Teflon" ) ) )
618 layerColor = findColor( wxT(
"PTFE natural" ),
g_BoardColors );
620 else if( materialName.IsSameAs( wxT(
"Polyimide" ) )
621 || materialName.IsSameAs( wxT(
"Kapton" ) ) )
625 else if( materialName.IsSameAs( wxT(
"Al" ) ) )
632 layerColor = findColor( wxT(
"FR4 natural" ),
g_BoardColors );
635 if( bodyColor ==
COLOR4D( 0, 0, 0, 0 ) )
636 bodyColor = layerColor;
638 bodyColor = bodyColor.
Mix( layerColor, 1.0 - layerColor.
a );
640 bodyColor.
a += ( 1.0 - bodyColor.
a ) * layerColor.
a / 2;
649 if( bodyColor !=
COLOR4D( 0, 0, 0, 0 ) )
656 if( finishName.EndsWith( wxT(
"OSP" ) ) )
660 else if( finishName.EndsWith( wxT(
"IG" ) )
661 || finishName.EndsWith( wxT(
"gold" ) ) )
665 else if( finishName.StartsWith( wxT(
"HAL" ) )
666 || finishName.StartsWith( wxT(
"HASL" ) )
667 || finishName.EndsWith( wxT(
"tin" ) )
668 || finishName.EndsWith( wxT(
"nickel" ) ) )
672 else if( finishName.EndsWith( wxT(
"silver" ) ) )
694 int aErrorMax,
int aChainingEpsilon,
712 *aErrorMsg =
_(
"No footprint loaded." );
726 if( !success && aErrorMsg )
728 *aErrorMsg =
_(
"Footprint outline is missing or malformed. Run Footprint Checker for " 729 "a full analysis." );
736 if( !success && aErrorMsg )
737 *aErrorMsg =
_(
"Board outline is missing or malformed. Run DRC for a full analysis." );
781 return SFVEC4F( aColor.
r, aColor.
g, aColor.
b, aColor.
a );
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BVH_CONTAINER_2D * m_platedPadsFront
static bool g_ColorsLoaded
int m_RtShadowSampleCount
Defines math related functions.
#define TECH_LAYER_THICKNESS
SFVEC4F m_SilkScreenColorBot
in realistic mode: SilkScreen color ( bot )
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...
bool GetUseBoardStackupColors() const
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_backPlatedPadPolys
Polygon contours for hole outer diameters for each layer.
float m_solderPasteLayerThickness3DU
Number of tracks in the board.
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.
Manage layers needed to make a physical board.
bool IsFootprintShown(FOOTPRINT_ATTR_T aFPAttributes) const
Test if footprint should be displayed in relation to attributes and the flags.
float m_nonCopperLayerThickness3DU
solder paste layers thickness in 3D units.
SHAPE_POLY_SET * m_frontPlatedPadPolys
wxString m_FinishType
The name of external copper finish.
Manage a bounding box defined by two SFVEC3F min max points.
SFVEC4F GetColor(const COLOR4D &aColor) const
float m_averageHoleDiameter
int GetHolePlatingThickness() const
Pad & via drills are finish size.
static KIGFX::COLOR4D g_DefaultSilkscreen
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
Set the status of a flag.
COLOR_SETTINGS * m_colors
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
static KIGFX::COLOR4D g_DefaultSurfaceFinish
BVH_CONTAINER_2D m_throughHoleOds
List of plated through hole annular rings.
void InitSettings(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
Function to be called by the render when it need to reload the settings for the board.
int GetBoardThickness() const
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
SFVEC4F m_SolderPasteColor
in realistic mode: solder paste color
#define layerThicknessMargin
float m_averageTrackWidth
Number of through hole vias in the board.
A class to handle a custom color (predefined color) for the color picker dialog.
SFVEC4F m_SolderMaskColorBot
in realistic mode: solder mask color ( bot )
wxPoint m_boardPos
Board center position in board internal units.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
A pure virtual class used to derive REPORTER objects from.
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordBottom
Copper thickness in 3D units.
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
float m_epoxyThickness3DU
Non copper layers thickness in 3D units.
static CUSTOM_COLORS_LIST g_BoardColors
float m_copperThickness3DU
Epoxy thickness in 3D units.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
static KIGFX::COLOR4D g_DefaultBackgroundBot
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
float m_RtSpreadRefractions
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
static CUSTOM_COLORS_LIST g_FinishColors
static CUSTOM_COLORS_LIST g_PasteColors
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
static KIGFX::COLOR4D g_DefaultSolderMask
BOARD_STACKUP & GetStackupDescriptor()
static KIGFX::COLOR4D g_DefaultBoardBody
int m_RtRecursiveReflectionCount
float m_RtSpreadReflections
SFVEC4F m_BgColorTop
background top color
unsigned int m_trackCount
Track average width.
std::vector< bool > m_drawFlags
std::array< float, PCB_LAYER_ID_COUNT > m_layerZcoordTop
Bottom (Start) Z position of each layer in 3D units.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
#define ADD_COLOR(list, r, g, b, a, name)
SHAPE_POLY_SET m_board_poly
Board outline polygon.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
BVH_CONTAINER_2D * m_platedPadsBack
The holes per each layer.
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.
wxString NotSpecifiedPrm()
Represent a set of closed polygons.
constexpr double PCB_IU_PER_MM
Use all material properties from model file.
static KIGFX::COLOR4D g_DefaultBackgroundTop
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
SFVEC4F m_BgColorBot
background bottom color
a few functions useful in geometry calculations.
void Simplify(POLYGON_MODE aFastMode)
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of through hole inner diameters.
unsigned int m_viaCount
Computed average diameter of the via holes in 3D units.
int m_RtRecursiveRefractionCount
Manage one layer needed to make a physical board.
int m_RtRefractionSampleCount
SFVEC4F GetItemColor(int aItemId) const
Get the technical color of a layer.
void createLayers(REPORTER *aStatusReporter)
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
#define SOLDERPASTE_LAYER_THICKNESS
float GetFootprintZPos(bool aIsFlipped) const
Get the position of the footprint in 3d integer units considering if it is flipped or not.
DISPLAY3D_FLG
Flags used in rendering options.
RENDER_ENGINE m_renderEngine
COLOR4D GetColor(int aLayer) const
wxSize m_boardSize
Board size in board internal units.
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
MATERIAL_MODE m_materialMode
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Information pertinent to a Pcbnew printed circuit board.
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
static KIGFX::COLOR4D g_DefaultSolderPaste
PCB_LAYER_ID
A quick note on layer IDs:
unsigned int m_copperLayersCount
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
bool createBoardPolygon(wxString *aErrorMsg)
Create the board outline polygon.
SFVEC4F m_CopperColor
in realistic mode: copper color
int GetCopperLayerCount() const
Handle the component boundary box.
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
Defines math related functions.
Color settings are a bit different than most of the settings objects in that there can be more than o...
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const wxPoint &pt)> OUTLINE_ERROR_HANDLER
SFVEC4F m_SilkScreenColorTop
in realistic mode: SilkScreen color ( top )
static CUSTOM_COLORS_LIST g_MaskColors
ANTIALIASING_MODE m_antiAliasingMode
static CUSTOM_COLORS_LIST g_SilkscreenColors
SFVEC3F m_boardCenter
3D center position of the board in 3D units.
float m_averageViaHoleDiameter
Number of holes in the board.
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
static constexpr int Millimeter2iu(double mm)
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
void Reset()
Reset the bounding box to zero and de-initialize it.
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
int m_RtReflectionSampleCount
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
unsigned int m_holeCount
Computed average diameter of the holes in 3D units.
const wxSize GetSize() const
int GetHolePlatingThickness() const noexcept
Get the current copper layer thickness.
A color representation with 4 components: red, green, blue, alpha.