50#define DEFAULT_BOARD_THICKNESS pcbIUScale.mmToIU( 1.6 )
51#define DEFAULT_COPPER_THICKNESS pcbIUScale.mmToIU( 0.035 )
53#define DEFAULT_TECH_LAYER_THICKNESS pcbIUScale.mmToIU( 0.025 )
56#define SOLDERPASTE_LAYER_THICKNESS pcbIUScale.mmToIU( 0.04 )
104 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::BOARD_ADAPTER" ) );
153 for(
int ii = 0; ii < 45; ++ii )
168#define ADD_COLOR( list, r, g, b, a, name ) \
169 list.emplace_back( r/255.0, g/255.0, b/255.0, a, name )
255 const std::bitset<LAYER_3D_END>& aVisibilityFlags )
const
287 return aVisibilityFlags.test( layer3D );
303 const wxString variantName =
m_board ?
m_board->GetCurrentVariant() : wxString();
308 if( excludedFromPos )
310 if( !
m_Cfg->m_Render.show_footprints_not_in_posfile )
316 if( !
m_Cfg->m_Render.show_footprints_dnp )
321 return m_Cfg->m_Render.show_footprints_insert;
324 return m_Cfg->m_Render.show_footprints_normal;
326 return m_Cfg->m_Render.show_footprints_virtual;
333 return wxEmptyString;
337 if( libraryName.empty() )
338 return wxEmptyString;
347 return wxEmptyString;
354 return wxEmptyString;
357 std::optional<LIBRARY_TABLE_ROW*> fpRow = adapter->
GetRow( libraryName );
367 return wxEmptyString;
373 return m_board ?
m_board->GetDesignSettings().GetHolePlatingThickness()
380 wxASSERT( aDiameter3DU > 0.0f );
388 wxASSERT( aDiameterBIU > 0 );
395 std::shared_ptr<REPORTER> aWarningReporter )
397 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::InitSettings" ) );
399 if( aStatusReporter )
400 aStatusReporter->Report(
_(
"Build board outline" ) );
406 if( aWarningReporter )
411 aWarningReporter->Report( wxEmptyString );
417 bbbox =
m_board->ComputeBoundingBox( !
m_board->IsFootprintHolder() && haveOutline,
true );
463 int body_thickness = 0;
467 switch( item->GetType() )
470 for(
int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
471 body_thickness += item->GetThickness( sublayer );
479 int copper_thickness = std::max( item->GetThickness(),
pcbIUScale.mmToIU( 0.001 ) );
481 if( item->GetBrdLayerId() ==
F_Cu )
483 else if( item->GetBrdLayerId() ==
B_Cu )
485 else if( item->IsEnabled() )
486 body_thickness += copper_thickness;
495 int mask_thickness = std::max( item->GetThickness(),
pcbIUScale.mmToIU( 0.001 ) );
497 if( item->GetBrdLayerId() ==
F_Mask )
499 else if( item->GetBrdLayerId() ==
B_Mask )
536 case F_Cu: layer_pos = 0;
break;
538 default: layer_pos = ( layer_id -
B_Cu )/2;
break;
550 #define layerThicknessMargin 1.1
571 zposBottom = zpos_copperTop_back;
576 zposBottom = zpos_copperTop_back;
581 zposBottom = zpos_copperTop_front;
586 zposBottom = zpos_copperTop_front;
591 zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
596 zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
601 if(
m_board->IsBackLayer( layer_id ) )
603 zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
608 zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
635#ifdef PRINT_STATISTICS_3D_VIEWER
639 if( aStatusReporter )
640 aStatusReporter->Report(
_(
"Create layers" ) );
647 return SFVEC4F( src.r, src.g, src.b, src.a );
678 std::map<int, COLOR4D> colors;
703 colors[ layer ] = settings->
GetColor( layer );
711 std::map<int, COLOR4D> colors;
715 colors = preset->colors;
722 colors[ layer ] = settings->
GetColor( layer );
732 [](
const wxString& aName,
const std::vector<CUSTOM_COLOR_ITEM>& aColorSet ) ->
const KIGFX::COLOR4D
734 if( aName.StartsWith( wxT(
"#" ) ) )
742 if( color.m_ColorName == aName )
743 return color.m_Color;
752 wxString colorName = stackupItem->GetColor();
754 switch( stackupItem->GetType() )
757 if( stackupItem->GetBrdLayerId() ==
F_SilkS )
765 if( stackupItem->GetBrdLayerId() ==
F_Mask )
776 if( bodyColor ==
COLOR4D( 0, 0, 0, 0 ) )
777 bodyColor = layerColor;
779 bodyColor = bodyColor.
Mix( layerColor, 1.0 - layerColor.
a );
781 bodyColor.
a += ( 1.0 - bodyColor.
a ) * layerColor.
a / 2;
790 if( bodyColor !=
COLOR4D( 0, 0, 0, 0 ) )
795 if( finishName.EndsWith( wxT(
"OSP" ) ) )
799 else if( finishName.EndsWith( wxT(
"IG" ) )
800 || finishName.EndsWith( wxT(
"gold" ) ) )
804 else if( finishName.StartsWith( wxT(
"HAL" ) )
805 || finishName.StartsWith( wxT(
"HASL" ) )
806 || finishName.EndsWith( wxT(
"tin" ) )
807 || finishName.EndsWith( wxT(
"nickel" ) ) )
811 else if( finishName.EndsWith( wxT(
"silver" ) ) )
830 for(
const auto& [ layer, color ] : aColors )
891 std::bitset<LAYER_3D_END> ret;
898 if(
m_Cfg->m_Preview.show_board_body )
924 ret.set( layer,
true );
1009 ret.set( layer,
m_board->IsElementVisible( layer ) );
1020 layers.
set( commonLayer );
1051 ret = preset->layers;
1060 std::bitset<LAYER_3D_END> ret;
1068 ret.set( layer,
true );
1086 ret.set( layer,
false );
1108 return m_Cfg->m_Render.use_board_editor_copper_colors && !
m_board->IsFootprintHolder();
1121 if(
m_board->IsFootprintHolder() )
1123 if( !
m_board->GetFirstFootprint() )
1126 *aErrorMsg =
_(
"No footprint loaded." );
1132 int chainingEpsilon =
m_board->GetOutlinesChainingEpsilon();
1135 m_board->GetDesignSettings().m_MaxError,
1139 if( !success && aErrorMsg )
1141 *aErrorMsg =
_(
"Footprint outline is missing or malformed. Run Footprint Checker for "
1142 "a full analysis." );
1149 if( !success && aErrorMsg )
1150 *aErrorMsg =
_(
"Board outline is missing or malformed. Run DRC for a full analysis." );
1177 glm::mat4 matrix( 1.0f );
1185 SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1190 matrix = glm::rotate( matrix, glm::pi<float>(),
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
1191 matrix = glm::rotate( matrix, glm::pi<float>(),
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
1211 return SFVEC4F( aColor.
r, aColor.
g, aColor.
b, aColor.
a );
1217 SFVEC2F sphericalCoord =
SFVEC2F( (
m_Cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
1218 m_Cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
1220 sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
1221 sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
1223 return sphericalCoord;
Defines math related functions.
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
#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
Define an abstract camera.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString m_ColorTheme
Active color theme name.
BASE_SET & set(size_t pos)
std::map< int, COLOR4D > m_BoardEditorColors
list of colors used by the board editor
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
BVH_CONTAINER_2D * m_offboardPadsBack
SFVEC4F m_BgColorTop
background top color
void SetVisibleLayers(const std::bitset< LAYER_3D_END > &aLayers)
static std::vector< CUSTOM_COLOR_ITEM > g_PasteColors
float m_solderPasteLayerThickness3DU
SFVEC4F GetLayerColor(int aLayerId) const
Get the technical color of a layer.
std::map< PCB_LAYER_ID, float > m_layerZcoordBottom
Bottom (Start) Z pos of each layer.
void CreateLayers(std::shared_ptr< REPORTER > aStatusReporter, std::stop_token aStop=std::stop_token())
Creates the layers for the board, should be called after InitSettings.
S3D_CACHE * m_3dModelManager
VECTOR2I m_boardPos
Board center position in board internal units.
float m_backCopperThickness3DU
bool GetUseBoardEditorCopperLayerColors() const
static KIGFX::COLOR4D g_DefaultComments
SFVEC4F m_SolderPasteColor
BBOX_3D m_boardBoundingBox
3D bounding box of the board in 3D units.
void createLayers(std::shared_ptr< REPORTER > aStatusReporter, std::stop_token aStop)
static KIGFX::COLOR4D g_DefaultBoardBody
SFVEC4F m_UserDefinedLayerColor[45]
static KIGFX::COLOR4D g_DefaultAdhesive
static KIGFX::COLOR4D g_DefaultFabColor
static KIGFX::COLOR4D g_DefaultSolderMask
std::map< int, COLOR4D > GetLayerColors() const
Build a color list which is used to store colors layers.
static std::vector< CUSTOM_COLOR_ITEM > g_BoardColors
std::optional< std::bitset< LAYER_3D_END > > m_visibilityOverride
static std::vector< CUSTOM_COLOR_ITEM > g_MaskColors
static std::vector< CUSTOM_COLOR_ITEM > g_SilkColors
SHAPE_POLY_SET * m_frontPlatedCopperPolys
BVH_CONTAINER_2D m_TH_ODs
List of PTH outer diameters.
float m_frontMaskThickness3DU
unsigned int m_trackCount
float m_averageTrackWidth
SHAPE_POLY_SET m_board_poly
Board outline polygon.
std::bitset< LAYER_3D_END > GetVisibleLayers() const
SFVEC4F m_SolderMaskColorBot
bool m_IsPreviewer
true if we're in a 3D preview panel, false for the standard 3D viewer
int GetHolePlatingThickness() const noexcept
Get the hole plating thickness (NB: in BOARD UNITS!).
static KIGFX::COLOR4D g_DefaultECOs
SFVEC4F m_SolderMaskColorTop
SFVEC4F GetColor(const COLOR4D &aColor) const
BVH_CONTAINER_2D * m_offboardPadsFront
float m_averageViaHoleDiameter
static KIGFX::COLOR4D g_DefaultBackgroundTop
glm::mat4 GetFootprintMatrix(const FOOTPRINT &aFootprint) const
Build the transform from footprint-local model units to 3D world units.
float m_averageHoleDiameter
static KIGFX::COLOR4D g_DefaultSurfaceFinish
void ReloadColorSettings() noexcept
static std::vector< CUSTOM_COLOR_ITEM > g_FinishColors
SFVEC2F GetSphericalCoord(int i) const
BVH_CONTAINER_2D * m_platedPadsBack
std::bitset< LAYER_3D_END > GetDefaultVisibleLayers() const
SFVEC4F m_BCourtyardColor
void InitSettings(std::shared_ptr< REPORTER > aStatusReporter, std::shared_ptr< REPORTER > aWarningReporter)
Function to be called by the render when it need to reload the settings for the board.
std::map< PCB_LAYER_ID, float > m_layerZcoordTop
Top (End) Z pos of each layer in 3D units.
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
float m_backMaskThickness3DU
static KIGFX::COLOR4D g_DefaultSolderPaste
wxString GetFootprintLibraryPath(const FOOTPRINT *aFootprint) const
Return the directory of aFootprint's library.
float m_boardBodyThickness3DU
VECTOR2I m_boardSize
Board size in board internal units.
SHAPE_POLY_SET * m_backPlatedCopperPolys
void SetLayerColors(const std::map< int, COLOR4D > &aColors)
EDA_3D_VIEWER_SETTINGS * m_Cfg
std::map< int, COLOR4D > m_ColorOverrides
allows to override color scheme colors
SFVEC4F m_SilkScreenColorTop
SFVEC4F m_SilkScreenColorBot
bool IsFootprintShown(const FOOTPRINT *aFootprint) const
Test if footprint should be displayed in relation to attributes and the flags.
unsigned int GetCircleSegmentCount(float aDiameter3DU) const
SFVEC4F m_FCourtyardColor
static KIGFX::COLOR4D g_DefaultCourtyardColor
float m_nonCopperLayerThickness3DU
BVH_CONTAINER_2D m_viaAnnuli
List of via annular rings.
bool createBoardPolygon(wxString *aErrorMsg)
Create the board outline polygon.
unsigned int m_copperLayersCount
std::map< int, COLOR4D > GetDefaultColors() const
BVH_CONTAINER_2D m_TH_IDs
List of PTH inner diameters.
SFVEC4F m_UserCommentsColor
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
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer, const std::bitset< LAYER_3D_END > &aVisibilityFlags) const
Check if a layer is enabled.
SFVEC4F m_UserDrawingsColor
double m_biuTo3Dunits
Scale factor to convert board internal units.
SFVEC4F m_BgColorBot
background bottom color
Container for design settings for a BOARD object.
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.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr size_type GetHeight() const
constexpr const SizeVec & GetSize() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetColor(int aLayer, const COLOR4D &aColor)
COLOR4D GetColor(int aLayer) 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.
std::optional< LIBRARY_TABLE_ROW * > GetRow(const wxString &aNickname, LIBRARY_TABLE_SCOPE aScope=LIBRARY_TABLE_SCOPE::BOTH) const
Like LIBRARY_MANAGER::GetRow but filtered to the LIBRARY_TABLE_TYPE of this adapter.
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
LSET is a set of PCB_LAYER_IDs.
Parameters and options when plotting/printing a board.
LSEQ GetPlotOnAllLayersSequence() const
LSET GetLayerSelection() const
bool GetPlotReference() const
bool GetPlotValue() const
bool GetPlotFPText() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely save a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
bool BuildFootprintPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler)
Extract a board outline for a footprint view.
#define FOLLOW_PLOT_SETTINGS
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.
PCB_LAYER_ID Map3DLayerToPCBLayer(int aLayer)
int MapPCBLayerTo3DLayer(PCB_LAYER_ID aLayer)
@ LAYER_3D_COPPER_INNER_30
@ LAYER_3D_SOLDERMASK_TOP
@ LAYER_3D_BOUNDING_BOXES
@ LAYER_3D_BACKGROUND_TOP
@ LAYER_3D_SOLDERMASK_BOTTOM
@ LAYER_3D_PLATED_BARRELS
@ LAYER_3D_COPPER_INNER_1
@ LAYER_3D_SILKSCREEN_TOP
@ LAYER_3D_VIRTUAL_MODELS
@ LAYER_3D_MODELS_MARKED_DNP
@ LAYER_3D_OFF_BOARD_SILK
@ LAYER_3D_MODELS_NOT_IN_POS
@ LAYER_3D_BACKGROUND_BOTTOM
@ LAYER_3D_SILKSCREEN_BOTTOM
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
PGM_BASE & Pgm()
The global program "get" accessor.
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
wxString NotSpecifiedPrm()
Manage a bounding box defined by two SFVEC3F min max points.
A class to handle a custom color (predefined color) for the color picker dialog.
VECTOR2< int32_t > VECTOR2I