25#include "../3d_rendering/camera.h"
42#define DEFAULT_BOARD_THICKNESS pcbIUScale.mmToIU( 1.6 )
43#define DEFAULT_COPPER_THICKNESS pcbIUScale.mmToIU( 0.035 )
45#define DEFAULT_TECH_LAYER_THICKNESS pcbIUScale.mmToIU( 0.025 )
48#define SOLDERPASTE_LAYER_THICKNESS pcbIUScale.mmToIU( 0.04 )
83 m_IsBoardView( true ),
84 m_MousewheelPanning( true ),
85 m_IsPreviewer( false ),
87 m_3dModelManager( nullptr ),
88 m_renderSettings( nullptr ),
93 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::BOARD_ADAPTER" ) );
96 m_colors =
Pgm().GetSettingsManager().GetColorSettings();
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 )
274 if( aFPAttributes &
FP_SMD )
293 wxASSERT( aDiameter3DU > 0.0f );
301 wxASSERT( aDiameterBIU > 0 );
309 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::InitSettings" ) );
311 if( aStatusReporter )
312 aStatusReporter->
Report(
_(
"Build board outline" ) );
318 if( aWarningReporter )
323 aWarningReporter->
Report( wxEmptyString );
374 switch( item->GetType() )
377 for(
int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
378 thickness += item->GetThickness( sublayer );
382 if( item->GetBrdLayerId() ==
F_Cu )
384 else if( item->GetBrdLayerId() ==
B_Cu )
386 else if( item->IsEnabled() )
387 thickness += item->GetThickness();
427 #define layerThicknessMargin 1.1
451 zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
456 zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
461 zposBottom = zpos_copperTop_back;
466 zposBottom = zpos_copperTop_back;
471 zposBottom = zpos_copperTop_front;
476 zposBottom = zpos_copperTop_front;
481 zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
486 zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
492 zposTop = zpos_copperTop_front + (layer_id -
MAX_CU_LAYERS + 3.0f) * zpos_offset;
515#ifdef PRINT_STATISTICS_3D_VIEWER
519 if( aStatusReporter )
520 aStatusReporter->
Report(
_(
"Create layers" ) );
529 return SFVEC4F( src.r, src.g, src.b, src.a );
544 if( aColorName.StartsWith( wxT(
"#" ) ) )
552 if(
color.m_ColorName == aColorName )
553 return color.m_Color;
569 wxString colorName = stackupItem->GetColor();
571 switch( stackupItem->GetType() )
574 if( stackupItem->GetBrdLayerId() ==
F_SilkS )
581 if( stackupItem->GetBrdLayerId() ==
F_Mask )
592 if( bodyColor ==
COLOR4D( 0, 0, 0, 0 ) )
593 bodyColor = layerColor;
595 bodyColor = bodyColor.
Mix( layerColor, 1.0 - layerColor.
a );
597 bodyColor.
a += ( 1.0 - bodyColor.
a ) * layerColor.
a / 2;
606 if( bodyColor !=
COLOR4D( 0, 0, 0, 0 ) )
613 if( finishName.EndsWith( wxT(
"OSP" ) ) )
617 else if( finishName.EndsWith( wxT(
"IG" ) )
618 || finishName.EndsWith( wxT(
"gold" ) ) )
622 else if( finishName.StartsWith( wxT(
"HAL" ) )
623 || finishName.StartsWith( wxT(
"HASL" ) )
624 || finishName.EndsWith( wxT(
"tin" ) )
625 || finishName.EndsWith( wxT(
"nickel" ) ) )
629 else if( finishName.EndsWith( wxT(
"silver" ) ) )
651 int aErrorMax,
int aChainingEpsilon,
669 *aErrorMsg =
_(
"No footprint loaded." );
684 if( !success && aErrorMsg )
686 *aErrorMsg =
_(
"Footprint outline is missing or malformed. Run Footprint Checker for "
687 "a full analysis." );
694 if( !success && aErrorMsg )
695 *aErrorMsg =
_(
"Board outline is missing or malformed. Run DRC for a full analysis." );
739 return SFVEC4F( aColor.
r, aColor.
g, aColor.
b, aColor.
a );
749 sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
750 sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
752 return sphericalCoord;
Defines math related functions.
Defines math related functions.
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
#define SOLDERPASTE_LAYER_THICKNESS
#define ADD_COLOR(list, r, g, b, a, name)
float g_BevelThickness3DU
#define DEFAULT_TECH_LAYER_THICKNESS
#define DEFAULT_BOARD_THICKNESS
#define layerThicknessMargin
static bool g_ColorsLoaded
#define DEFAULT_COPPER_THICKNESS
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.
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
@ BS_ITEM_TYPE_SILKSCREEN
@ BS_ITEM_TYPE_DIELECTRIC
@ BS_ITEM_TYPE_SOLDERMASK
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
SFVEC4F m_BgColorTop
background top color
float m_solderPasteLayerThickness3DU
void createLayers(REPORTER *aStatusReporter)
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
COLOR_SETTINGS * m_colors
bool IsFootprintShown(FOOTPRINT_ATTR_T aFPAttributes) const
Test if footprint should be displayed in relation to attributes and the flags.
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
SHAPE_POLY_SET m_board_poly
Board outline polygon.
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
int GetHolePlatingThickness() const noexcept
Get the hole plating thickness (NB: in BOARD UNITS!).
void InitSettings(REPORTER *aStatusReporter, REPORTER *aWarningReporter)
Function to be called by the render when it need to reload the settings for the board.
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
SFVEC4F GetColor(const COLOR4D &aColor) const
float m_averageViaHoleDiameter
static KIGFX::COLOR4D g_DefaultBackgroundTop
float m_averageHoleDiameter
static KIGFX::COLOR4D g_DefaultSurfaceFinish
SFVEC4F m_CopperColor
in realistic mode: copper color
SFVEC2F GetSphericalCoord(int i) const
BVH_CONTAINER_2D * m_platedPadsBack
float GetFootprintZPos(bool aIsFlipped) const
Get the position of the footprint in 3d integer units considering if it is flipped or not.
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 )
SFVEC4F GetItemColor(int aItemId) const
Get the technical color of a layer.
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
float m_nonCopperLayerThickness3DU
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
bool createBoardPolygon(wxString *aErrorMsg)
Create the board outline polygon.
unsigned int m_copperLayersCount
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
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
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
Container for design settings for a BOARD object.
int GetHolePlatingThickness() const
Pad & via drills are finish size.
BOARD_STACKUP & GetStackupDescriptor()
Manage one layer needed to make a physical board.
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
wxString m_FinishType
The name of external copper finish.
Information pertinent to a Pcbnew printed circuit board.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
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...
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
int GetCopperLayerCount() const
int GetOutlinesChainingEpsilon()
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
coord_type GetHeight() const
coord_type GetWidth() const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
const Vec & GetSize() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
bool GetUseBoardStackupColors() const
A color representation with 4 components: red, green, blue, alpha.
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Represent a set of closed polygons.
void Simplify(POLYGON_MODE aFastMode)
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
static constexpr EDA_ANGLE & FULL_CIRCLE
a few functions useful in geometry calculations.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
static const wxChar * m_logTrace
Trace mask used to enable or disable debug output for this class.
@ LAYER_3D_SOLDERMASK_TOP
@ LAYER_3D_BACKGROUND_TOP
@ LAYER_3D_SOLDERMASK_BOTTOM
@ LAYER_3D_SILKSCREEN_TOP
@ LAYER_3D_BACKGROUND_BOTTOM
@ LAYER_3D_SILKSCREEN_BOTTOM
PCB_LAYER_ID
A quick note on layer IDs:
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxString NotSpecifiedPrm()
Manage a bounding box defined by two SFVEC3F min max points.
void Reset()
Reset the bounding box to zero and de-initialize it.
A class to handle a custom color (predefined color) for the color picker dialog.
std::vector< int > raytrace_lightElevation
bool show_footprints_normal
bool show_footprints_virtual
std::vector< int > raytrace_lightAzimuth
bool show_footprints_not_in_posfile
bool show_footprints_insert
constexpr int mmToIU(double mm) const