46#define DEFAULT_BOARD_THICKNESS pcbIUScale.mmToIU( 1.6 )
47#define DEFAULT_COPPER_THICKNESS pcbIUScale.mmToIU( 0.035 )
49#define DEFAULT_TECH_LAYER_THICKNESS pcbIUScale.mmToIU( 0.025 )
52#define SOLDERPASTE_LAYER_THICKNESS pcbIUScale.mmToIU( 0.04 )
89 m_IsBoardView( true ),
90 m_MousewheelPanning( true ),
91 m_IsPreviewer( false ),
93 m_3dModelManager( nullptr ),
98 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::BOARD_ADAPTER" ) );
154#define ADD_COLOR( list, r, g, b, a, name ) \
155 list.emplace_back( r/255.0, g/255.0, b/255.0, a, name )
236 catch(
const std::runtime_error& e )
238 wxFAIL_MSG( e.what() );
250 const std::bitset<LAYER_3D_END>& aVisibilityFlags )
const
289 if( aFPAttributes &
FP_DNP )
295 if( aFPAttributes &
FP_SMD )
314 wxASSERT( aDiameter3DU > 0.0f );
322 wxASSERT( aDiameterBIU > 0 );
330 wxLogTrace(
m_logTrace, wxT(
"BOARD_ADAPTER::InitSettings" ) );
332 if( aStatusReporter )
333 aStatusReporter->
Report(
_(
"Build board outline" ) );
339 if( aWarningReporter )
344 aWarningReporter->
Report( wxEmptyString );
397 switch( item->GetType() )
400 for(
int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
401 thickness += item->GetThickness( sublayer );
408 int copper_thickness = std::max( item->GetThickness(),
pcbIUScale.
mmToIU( 0.001 ) );
410 if( item->GetBrdLayerId() ==
F_Cu )
412 else if( item->GetBrdLayerId() ==
B_Cu )
414 else if( item->IsEnabled() )
415 thickness += copper_thickness;
450 case F_Cu: layer_pos = 0;
break;
452 default: layer_pos = ( layer_id -
B_Cu )/2;
break;
465 #define layerThicknessMargin 1.1
489 float zposBottom = 0.0;
494 zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
499 zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
504 zposBottom = zpos_copperTop_back;
509 zposBottom = zpos_copperTop_back;
514 zposBottom = zpos_copperTop_front;
519 zposBottom = zpos_copperTop_front;
524 zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
529 zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
555#ifdef PRINT_STATISTICS_3D_VIEWER
559 if( aStatusReporter )
560 aStatusReporter->
Report(
_(
"Create layers" ) );
567 return SFVEC4F( src.r, src.g, src.b, src.a );
590 std::map<int, COLOR4D> colors;
631 std::map<int, COLOR4D> colors;
635 colors = preset->colors;
642 colors[ layer ] = settings->
GetColor( layer );
653 if( aColorName.StartsWith( wxT(
"#" ) ) )
661 if(
color.m_ColorName == aColorName )
662 return color.m_Color;
671 wxString colorName = stackupItem->GetColor();
673 switch( stackupItem->GetType() )
676 if( stackupItem->GetBrdLayerId() ==
F_SilkS )
684 if( stackupItem->GetBrdLayerId() ==
F_Mask )
695 if( bodyColor ==
COLOR4D( 0, 0, 0, 0 ) )
696 bodyColor = layerColor;
698 bodyColor = bodyColor.
Mix( layerColor, 1.0 - layerColor.
a );
700 bodyColor.
a += ( 1.0 - bodyColor.
a ) * layerColor.
a / 2;
709 if( bodyColor !=
COLOR4D( 0, 0, 0, 0 ) )
714 if( finishName.EndsWith( wxT(
"OSP" ) ) )
718 else if( finishName.EndsWith( wxT(
"IG" ) )
719 || finishName.EndsWith( wxT(
"gold" ) ) )
723 else if( finishName.StartsWith( wxT(
"HAL" ) )
724 || finishName.StartsWith( wxT(
"HASL" ) )
725 || finishName.EndsWith( wxT(
"tin" ) )
726 || finishName.EndsWith( wxT(
"nickel" ) ) )
730 else if( finishName.EndsWith( wxT(
"silver" ) ) )
749 for(
const auto& [ layer,
color ] : aColors )
790 std::bitset<LAYER_3D_END> ret;
870 ret = preset->layers;
899 std::bitset<LAYER_3D_END> ret;
947 *aErrorMsg =
_(
"No footprint loaded." );
962 if( !success && aErrorMsg )
964 *aErrorMsg =
_(
"Footprint outline is missing or malformed. Run Footprint Checker for "
965 "a full analysis." );
972 if( !success && aErrorMsg )
973 *aErrorMsg =
_(
"Board outline is missing or malformed. Run DRC for a full analysis." );
1015 return SFVEC4F( aColor.
r, aColor.
g, aColor.
b, aColor.
a );
1025 sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
1026 sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
1028 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
#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
BVH_CONTAINER_2D * m_offboardPadsBack
SFVEC4F m_BgColorTop
background top color
void SetVisibleLayers(const std::bitset< LAYER_3D_END > &aLayers)
float m_solderPasteLayerThickness3DU
std::map< PCB_LAYER_ID, float > m_layerZcoordBottom
Bottom (Start) Z position of each layer in 3D units.
void createLayers(REPORTER *aStatusReporter)
VECTOR2I m_boardPos
Board center position in board internal units.
float m_backCopperThickness3DU
static KIGFX::COLOR4D g_DefaultComments
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
std::map< int, COLOR4D > GetLayerColors() const
Build a color list which is used to store colors layers.
SHAPE_POLY_SET * m_frontPlatedCopperPolys
BVH_CONTAINER_2D m_TH_ODs
List of PTH outer diameters.
SHAPE_POLY_SET * m_frontPlatedPadAndGraphicPolys
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
in realistic mode: solder mask color ( bot )
bool m_IsPreviewer
true if we're 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.
static KIGFX::COLOR4D g_DefaultECOs
SFVEC4F m_SolderMaskColorTop
in realistic mode: solder mask color ( top )
SFVEC4F GetColor(const COLOR4D &aColor) const
BVH_CONTAINER_2D * m_offboardPadsFront
float m_averageViaHoleDiameter
static KIGFX::COLOR4D g_DefaultBackgroundTop
static CUSTOM_COLORS_LIST g_SilkColors
float m_averageHoleDiameter
static KIGFX::COLOR4D g_DefaultSurfaceFinish
SFVEC4F m_CopperColor
in realistic mode: copper color
void ReloadColorSettings() noexcept
SFVEC2F GetSphericalCoord(int i) const
BVH_CONTAINER_2D * m_platedPadsBack
std::bitset< LAYER_3D_END > GetDefaultVisibleLayers() const
std::map< PCB_LAYER_ID, float > m_layerZcoordTop
Top (End) Z position 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
static KIGFX::COLOR4D g_DefaultSolderPaste
float m_boardBodyThickness3DU
static CUSTOM_COLORS_LIST g_BoardColors
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
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
BVH_CONTAINER_2D m_viaAnnuli
List of via annular rings.
SFVEC4F m_BoardBodyColor
in realistic mode: FR4 board color
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.
SHAPE_POLY_SET * m_backPlatedPadAndGraphicPolys
static KIGFX::COLOR4D g_DefaultBackgroundBot
SFVEC4F GetLayerColor(PCB_LAYER_ID aLayerId) const
Get the technical color of a layer.
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer, const std::bitset< LAYER_3D_END > &aVisibilityFlags) const
Check if a layer is enabled.
SFVEC4F m_UserDrawingsColor
void GetBoardEditorCopperLayerColors(PCBNEW_SETTINGS *aCfg)
Build the copper color list used by the board editor, and store it in m_BoardEditorColors.
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
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.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
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.
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
int GetCopperLayerCount() const
const PCB_PLOT_PARAMS & GetPlotOptions() 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
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
LAYER_PRESET_3D * FindPreset(const wxString &aName)
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.
LSET is a set of PCB_LAYER_IDs.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Parameters and options when plotting/printing a board.
LSET GetLayerSelection() const
bool GetPlotReference() const
LSET GetPlotOnAllLayersSelection() const
bool GetPlotValue() const
bool GetPlotFPText() const
virtual SETTINGS_MANAGER & GetSettingsManager() const
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.
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void SaveColorSettings(COLOR_SETTINGS *aSettings, const std::string &aNamespace="")
Safely saves a COLOR_SETTINGS to disk, preserving any changes outside the given namespace.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
bool BuildFootprintPolygonOutlines(BOARD *aBoard, SHAPE_POLY_SET &aOutlines, int aErrorMax, int aChainingEpsilon, OUTLINE_ERROR_HANDLER *aErrorHandler)
Extract a board outline for a footprint view.
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
#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.
@ LAYER_3D_SOLDERMASK_TOP
@ LAYER_3D_BOUNDING_BOXES
@ LAYER_3D_BACKGROUND_TOP
@ LAYER_3D_SOLDERMASK_BOTTOM
@ 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)
Tests 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:
PGM_BASE & Pgm()
The global Program "get" accessor.
PGM_BASE * PgmOrNull()
similar to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
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
bool show_silkscreen_bottom
std::vector< int > raytrace_lightAzimuth
bool show_footprints_not_in_posfile
bool show_footprints_insert
bool show_soldermask_bottom
constexpr int mmToIU(double mm) const
VECTOR2< int32_t > VECTOR2I