KiCad PCB EDA Suite
Loading...
Searching...
No Matches
board_adapter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2023 Mario Luzeiro <[email protected]>
5 * Copyright (C) 2023 CERN
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "board_adapter.h"
27
28#include <wx/log.h>
29
30#include <gal/3d/camera.h>
35#include <board.h>
37#include <footprint.h>
38#include <layer_range.h>
39#include <3d_math.h>
40#include "3d_fastmath.h"
42#include <lset.h>
43#include <pgm_base.h>
46#include <pcb_track.h>
47#include <pcbnew_settings.h>
48#include <advanced_config.h>
49
50
51#define DEFAULT_BOARD_THICKNESS pcbIUScale.mmToIU( 1.6 )
52#define DEFAULT_COPPER_THICKNESS pcbIUScale.mmToIU( 0.035 ) // for 35 um
53// The solder mask layer (and silkscreen) thickness
54#define DEFAULT_TECH_LAYER_THICKNESS pcbIUScale.mmToIU( 0.025 )
55// The solder paste thickness is chosen bigger than the solder mask layer
56// to be sure is covers the mask when overlapping.
57#define SOLDERPASTE_LAYER_THICKNESS pcbIUScale.mmToIU( 0.04 )
58
59
65
75
76// To be used in Raytracing render to create bevels on layer items
78
79static bool g_ColorsLoaded = false;
80
89const wxChar *BOARD_ADAPTER::m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" );
90
91
93 m_Cfg( nullptr ),
94 m_IsBoardView( true ),
95 m_MousewheelPanning( true ),
96 m_IsPreviewer( false ),
97 m_board( nullptr ),
98 m_3dModelManager( nullptr ),
101{
102 wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
103
106 m_boardCenter = SFVEC3F( 0.0f );
107
108 m_boardBoundingBox.Reset();
109
110 m_TH_IDs.Clear();
111 m_TH_ODs.Clear();
112 m_viaAnnuli.Clear();
113
115
116 m_biuTo3Dunits = 1.0;
124
125 m_trackCount = 0;
126 m_viaCount = 0;
128 m_holeCount = 0;
130 m_averageTrackWidth = 0.0f;
131
132 m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
133 m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
134 m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
135 m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
136 m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
137 m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
138 m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
139 m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
140 m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
141 m_UserDrawingsColor = SFVEC4F( 0.85, 0.85, 0.85, 1.0 );
142 m_UserCommentsColor = SFVEC4F( 0.85, 0.85, 0.85, 1.0 );
143 m_ECO1Color = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
144 m_ECO2Color = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
145
146 for( int ii = 0; ii < 45; ++ii )
147 m_UserDefinedLayerColor[ii] = SFVEC4F( 0.70, 0.10, 0.10, 1.0 );
148
149 m_platedPadsFront = nullptr;
150 m_platedPadsBack = nullptr;
151 m_offboardPadsFront = nullptr;
152 m_offboardPadsBack = nullptr;
153
154 m_frontPlatedCopperPolys = nullptr;
155 m_backPlatedCopperPolys = nullptr;
156
158
159 if( !g_ColorsLoaded )
160 {
161#define ADD_COLOR( list, r, g, b, a, name ) \
162 list.emplace_back( r/255.0, g/255.0, b/255.0, a, name )
163
164 ADD_COLOR( g_SilkColors, 245, 245, 245, 1.0, NotSpecifiedPrm() ); // White
165 ADD_COLOR( g_SilkColors, 20, 51, 36, 1.0, wxT( "Green" ) );
166 ADD_COLOR( g_SilkColors, 181, 19, 21, 1.0, wxT( "Red" ) );
167 ADD_COLOR( g_SilkColors, 2, 59, 162, 1.0, wxT( "Blue" ) );
168 ADD_COLOR( g_SilkColors, 11, 11, 11, 1.0, wxT( "Black" ) );
169 ADD_COLOR( g_SilkColors, 245, 245, 245, 1.0, wxT( "White" ) );
170 ADD_COLOR( g_SilkColors, 32, 2, 53, 1.0, wxT( "Purple" ) );
171 ADD_COLOR( g_SilkColors, 194, 195, 0, 1.0, wxT( "Yellow" ) );
172
173 ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, NotSpecifiedPrm() ); // Green
174 ADD_COLOR( g_MaskColors, 20, 51, 36, 0.83, wxT( "Green" ) );
175 ADD_COLOR( g_MaskColors, 91, 168, 12, 0.83, wxT( "Light Green" ) );
176 ADD_COLOR( g_MaskColors, 13, 104, 11, 0.83, wxT( "Saturated Green" ) );
177 ADD_COLOR( g_MaskColors, 181, 19, 21, 0.83, wxT( "Red" ) );
178 ADD_COLOR( g_MaskColors, 210, 40, 14, 0.83, wxT( "Light Red" ) );
179 ADD_COLOR( g_MaskColors, 239, 53, 41, 0.83, wxT( "Red/Orange" ) );
180 ADD_COLOR( g_MaskColors, 2, 59, 162, 0.83, wxT( "Blue" ) );
181 ADD_COLOR( g_MaskColors, 54, 79, 116, 0.83, wxT( "Light Blue 1" ) );
182 ADD_COLOR( g_MaskColors, 61, 85, 130, 0.83, wxT( "Light Blue 2" ) );
183 ADD_COLOR( g_MaskColors, 21, 70, 80, 0.83, wxT( "Green/Blue" ) );
184 ADD_COLOR( g_MaskColors, 11, 11, 11, 0.83, wxT( "Black" ) );
185 ADD_COLOR( g_MaskColors, 245, 245, 245, 0.83, wxT( "White" ) );
186 ADD_COLOR( g_MaskColors, 32, 2, 53, 0.83, wxT( "Purple" ) );
187 ADD_COLOR( g_MaskColors, 119, 31, 91, 0.83, wxT( "Light Purple" ) );
188 ADD_COLOR( g_MaskColors, 194, 195, 0, 0.83, wxT( "Yellow" ) );
189
190 ADD_COLOR( g_PasteColors, 128, 128, 128, 1.0, wxT( "Grey" ) );
191 ADD_COLOR( g_PasteColors, 90, 90, 90, 1.0, wxT( "Dark Grey" ) );
192 ADD_COLOR( g_PasteColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
193
194 ADD_COLOR( g_FinishColors, 184, 115, 50, 1.0, wxT( "Copper" ) );
195 ADD_COLOR( g_FinishColors, 178, 156, 0, 1.0, wxT( "Gold" ) );
196 ADD_COLOR( g_FinishColors, 213, 213, 213, 1.0, wxT( "Silver" ) );
197 ADD_COLOR( g_FinishColors, 160, 160, 160, 1.0, wxT( "Tin" ) );
198
199 ADD_COLOR( g_BoardColors, 51, 43, 22, 0.83, wxT( "FR4 natural, dark" ) );
200 ADD_COLOR( g_BoardColors, 109, 116, 75, 0.83, wxT( "FR4 natural" ) );
201 ADD_COLOR( g_BoardColors, 252, 252, 250, 0.90, wxT( "PTFE natural" ) );
202 ADD_COLOR( g_BoardColors, 205, 130, 0, 0.68, wxT( "Polyimide" ) );
203 ADD_COLOR( g_BoardColors, 92, 17, 6, 0.90, wxT( "Phenolic natural" ) );
204 ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 1" ) );
205 ADD_COLOR( g_BoardColors, 160, 123, 54, 0.83, wxT( "Brown 2" ) );
206 ADD_COLOR( g_BoardColors, 146, 99, 47, 0.83, wxT( "Brown 3" ) );
207 ADD_COLOR( g_BoardColors, 213, 213, 213, 1.0, wxT( "Aluminum" ) );
208
209 g_DefaultBackgroundTop = COLOR4D( 0.80, 0.80, 0.90, 1.0 );
210 g_DefaultBackgroundBot = COLOR4D( 0.40, 0.40, 0.50, 1.0 );
211
212 g_DefaultSilkscreen = COLOR4D( 0.94, 0.94, 0.94, 1.0 );
213 g_DefaultSolderMask = COLOR4D( 0.08, 0.20, 0.14, 0.83 );
214 g_DefaultSolderPaste = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
215 g_DefaultSurfaceFinish = COLOR4D( 0.75, 0.61, 0.23, 1.0 );
216 g_DefaultBoardBody = COLOR4D( 0.43, 0.45, 0.30, 0.90 );
217
218 g_DefaultComments = COLOR4D( 0.85, 0.85, 0.85, 1.0 );
219 g_DefaultECOs = COLOR4D( 0.70, 0.10, 0.10, 1.0 );
220
221 g_ColorsLoaded = true;
222 }
223#undef ADD_COLOR
224}
225
226
231
232
234{
237
238 for( int layer = F_Cu; layer < PCB_LAYER_ID_COUNT; ++layer )
239 m_BoardEditorColors[ layer ] = cs->GetColor( layer );
240}
241
242
244 const std::bitset<LAYER_3D_END>& aVisibilityFlags ) const
245{
246 wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
247
248 if( m_board && !m_board->IsLayerEnabled( aLayer ) )
249 return false;
250
251 switch( aLayer )
252 {
253 case B_Cu: return aVisibilityFlags.test( LAYER_3D_COPPER_BOTTOM );
254 case F_Cu: return aVisibilityFlags.test( LAYER_3D_COPPER_TOP );
255 case B_Adhes: return aVisibilityFlags.test( LAYER_3D_ADHESIVE );
256 case F_Adhes: return aVisibilityFlags.test( LAYER_3D_ADHESIVE );
257 case B_Paste: return aVisibilityFlags.test( LAYER_3D_SOLDERPASTE );
258 case F_Paste: return aVisibilityFlags.test( LAYER_3D_SOLDERPASTE );
259 case B_SilkS: return aVisibilityFlags.test( LAYER_3D_SILKSCREEN_BOTTOM );
260 case F_SilkS: return aVisibilityFlags.test( LAYER_3D_SILKSCREEN_TOP );
261 case B_Mask: return aVisibilityFlags.test( LAYER_3D_SOLDERMASK_BOTTOM );
262 case F_Mask: return aVisibilityFlags.test( LAYER_3D_SOLDERMASK_TOP );
263 case Dwgs_User: return aVisibilityFlags.test( LAYER_3D_USER_DRAWINGS );
264 case Cmts_User: return aVisibilityFlags.test( LAYER_3D_USER_COMMENTS );
265 case Eco1_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO1 );
266 case Eco2_User: return aVisibilityFlags.test( LAYER_3D_USER_ECO2 );
267 default:
268 {
269 int layer3D = MapPCBLayerTo3DLayer( aLayer );
270
271 if( layer3D != UNDEFINED_LAYER )
272 return aVisibilityFlags.test( layer3D );
273
274 return m_board && m_board->IsLayerVisible( aLayer );
275 }
276 }
277}
278
279
280bool BOARD_ADAPTER::IsFootprintShown( const FOOTPRINT* aFootprint ) const
281{
282 if( m_IsPreviewer ) // In panel Preview, footprints are always shown, of course
283 return true;
284
285 if( !aFootprint )
286 return false;
287
288 const wxString variantName = m_board ? m_board->GetCurrentVariant() : wxString();
289 const bool excludedFromPos = aFootprint->GetExcludedFromPosFilesForVariant( variantName );
290 const bool dnp = aFootprint->GetDNPForVariant( variantName );
291 const auto attributes = static_cast<FOOTPRINT_ATTR_T>( aFootprint->GetAttributes() );
292
293 if( excludedFromPos )
294 {
295 if( !m_Cfg->m_Render.show_footprints_not_in_posfile )
296 return false;
297 }
298
299 if( dnp )
300 {
301 if( !m_Cfg->m_Render.show_footprints_dnp )
302 return false;
303 }
304
305 if( attributes & FP_SMD )
306 return m_Cfg->m_Render.show_footprints_insert;
307
308 if( attributes & FP_THROUGH_HOLE )
309 return m_Cfg->m_Render.show_footprints_normal;
310
311 return m_Cfg->m_Render.show_footprints_virtual;
312}
313
314
316{
317 return m_board ? m_board->GetDesignSettings().GetHolePlatingThickness()
319}
320
321
322unsigned int BOARD_ADAPTER::GetCircleSegmentCount( float aDiameter3DU ) const
323{
324 wxASSERT( aDiameter3DU > 0.0f );
325
326 return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
327}
328
329
330unsigned int BOARD_ADAPTER::GetCircleSegmentCount( int aDiameterBIU ) const
331{
332 wxASSERT( aDiameterBIU > 0 );
333
334 return GetArcToSegmentCount( aDiameterBIU / 2, m_board->GetDesignSettings().m_MaxError, FULL_CIRCLE );
335}
336
337
338void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
339{
340 wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) );
341
342 if( aStatusReporter )
343 aStatusReporter->Report( _( "Build board outline" ) );
344
345 wxString msg;
346
347 const bool haveOutline = createBoardPolygon( &msg );
348
349 if( aWarningReporter )
350 {
351 if( !haveOutline )
352 aWarningReporter->Report( msg, RPT_SEVERITY_WARNING );
353 else
354 aWarningReporter->Report( wxEmptyString );
355 }
356
357 BOX2I bbbox;
358
359 if( m_board )
360 bbbox = m_board->ComputeBoundingBox( !m_board->IsFootprintHolder() && haveOutline, true );
361
362 // Gives a non null size to avoid issues in zoom / scale calculations
363 if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
364 bbbox.Inflate( pcbIUScale.mmToIU( 10 ) );
365
366 m_boardSize = bbbox.GetSize();
367 m_boardPos = bbbox.Centre();
368
369 wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
370
371 m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
372
373 m_copperLayersCount = m_board ? m_board->GetCopperLayerCount() : 2;
374
375 // Ensure the board has 2 sides for 3D views, because it is hard to find
376 // a *really* single side board in the true life...
377 if( m_copperLayersCount < 2 )
379
380 // Calculate the conversion to apply to all positions.
382
383 // Hack to keep "home" zoom from being too small.
384 if( !m_board || !m_board->IsFootprintHolder() )
385 m_biuTo3Dunits *= 1.6f;
386
388
396
397 g_BevelThickness3DU = pcbIUScale.mmToIU( ADVANCED_CFG::GetCfg().m_3DRT_BevelHeight_um / 1000.0 )
399
400 if( m_board )
401 {
402 const BOARD_DESIGN_SETTINGS& bds = m_board->GetDesignSettings();
403
404 if( bds.GetStackupDescriptor().GetCount() )
405 {
406 int body_thickness = 0;
407
408 for( BOARD_STACKUP_ITEM* item : bds.GetStackupDescriptor().GetList() )
409 {
410 switch( item->GetType() )
411 {
413 for( int sublayer = 0; sublayer < item->GetSublayersCount(); sublayer++ )
414 body_thickness += item->GetThickness( sublayer );
415
416 break;
417
419 {
420 // The copper thickness must be > 0 to avoid draw issues (divide by 0 for
421 // instance). We use a minimal arbitrary value = 1 micrometer here:
422 int copper_thickness = std::max( item->GetThickness(), pcbIUScale.mmToIU( 0.001 ) );
423
424 if( item->GetBrdLayerId() == F_Cu )
425 m_frontCopperThickness3DU = copper_thickness * m_biuTo3Dunits;
426 else if( item->GetBrdLayerId() == B_Cu )
427 m_backCopperThickness3DU = copper_thickness * m_biuTo3Dunits;
428 else if( item->IsEnabled() )
429 body_thickness += copper_thickness;
430
431 break;
432 }
433
435 {
436 // The mask thickness must be > 0 to avoid draw issues (divide by 0 for
437 // instance). We use a minimal arbitrary value = 1 micrometer here:
438 int mask_thickness = std::max( item->GetThickness(), pcbIUScale.mmToIU( 0.001 ) );
439
440 if( item->GetBrdLayerId() == F_Mask )
441 m_frontMaskThickness3DU = mask_thickness * m_biuTo3Dunits;
442 else if( item->GetBrdLayerId() == B_Mask )
443 m_backMaskThickness3DU = mask_thickness * m_biuTo3Dunits;
444 }
445
446 default:
447 break;
448 }
449 }
450
451 m_boardBodyThickness3DU = body_thickness * m_biuTo3Dunits;
452 }
453 }
454
455 // Init Z position of each layer
456 // calculate z position for each copper layer
457 // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer)
458 // (layer id = B_Cu)
459 // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer)
460 // (layer id = F_Cu)
461
462 // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
463 // | | Top = Bottom + m_copperThickness
464 // |__________________________________|
465 // == == == == <- Bottom = -m_epoxyThickness / 2.0,
466 // Top = Bottom - m_copperThickness
467
468 // Generate the Z position of copper layers
469 // A copper layer Z position has 2 values: its top Z position and its bottom Z position
470 for( auto layer_id : LAYER_RANGE( F_Cu, B_Cu, m_copperLayersCount ) )
471 {
472 // This approximates internal layer positions (because we're treating all the dielectric
473 // layers as having the same thickness). But we don't render them anyway so it doesn't
474 // really matter.
475 int layer_pos; // the position of the copper layer from board top to bottom
476
477 switch( layer_id )
478 {
479 case F_Cu: layer_pos = 0; break;
480 case B_Cu: layer_pos = m_copperLayersCount - 1; break;
481 default: layer_pos = ( layer_id - B_Cu )/2; break;
482 };
483
485 - ( m_boardBodyThickness3DU * layer_pos / ( m_copperLayersCount - 1 ) );
486
487 if( layer_pos < (m_copperLayersCount / 2) )
489 else
491 }
492
493 #define layerThicknessMargin 1.1
494 const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
495
496 // This is the top of the copper layer thickness.
497 const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
498 const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
499
500 // Fill not copper layers zpos
501 for( int layer = 0; layer < PCB_LAYER_ID_COUNT; layer++ )
502 {
503 PCB_LAYER_ID layer_id = ToLAYER_ID( layer );
504
505 if( IsCopperLayer( layer_id ) )
506 continue;
507
508 float zposBottom;
509 float zposTop;
510
511 switch( layer_id )
512 {
513 case B_Mask:
514 zposBottom = zpos_copperTop_back;
515 zposTop = zpos_copperTop_back - m_backMaskThickness3DU;
516 break;
517
518 case B_Paste:
519 zposBottom = zpos_copperTop_back;
520 zposTop = zpos_copperTop_back - m_solderPasteLayerThickness3DU;
521 break;
522
523 case F_Mask:
524 zposBottom = zpos_copperTop_front;
525 zposTop = zpos_copperTop_front + m_frontMaskThickness3DU;
526 break;
527
528 case F_Paste:
529 zposBottom = zpos_copperTop_front;
530 zposTop = zpos_copperTop_front + m_solderPasteLayerThickness3DU;
531 break;
532
533 case B_SilkS:
534 zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
535 zposTop = zposBottom - m_nonCopperLayerThickness3DU;
536 break;
537
538 case F_SilkS:
539 zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
540 zposTop = zposBottom + m_nonCopperLayerThickness3DU;
541 break;
542
543 default:
544 if( m_board->IsBackLayer( layer_id ) )
545 {
546 zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
547 zposTop = zposBottom - m_nonCopperLayerThickness3DU;
548 }
549 else
550 {
551 zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
552 zposTop = zposBottom + m_nonCopperLayerThickness3DU;
553 }
554 break;
555 }
556
557 m_layerZcoordTop[layer_id] = zposTop;
558 m_layerZcoordBottom[layer_id] = zposBottom;
559 }
560
562
564 boardSize /= 2.0f;
565
566 SFVEC3F boardMin = ( m_boardCenter - boardSize );
567 SFVEC3F boardMax = ( m_boardCenter + boardSize );
568
569 boardMin.z = m_layerZcoordTop[B_Adhes];
570 boardMax.z = m_layerZcoordTop[F_Adhes];
571
572 m_boardBoundingBox = BBOX_3D( boardMin, boardMax );
573
574#ifdef PRINT_STATISTICS_3D_VIEWER
575 int64_t stats_startCreateBoardPolyTime = GetRunningMicroSecs();
576#endif
577
578 if( aStatusReporter )
579 aStatusReporter->Report( _( "Create layers" ) );
580
581 createLayers( aStatusReporter );
582
583 auto to_SFVEC4F =
584 []( const COLOR4D& src )
585 {
586 return SFVEC4F( src.r, src.g, src.b, src.a );
587 };
588
589 std::map<int, COLOR4D> colors = GetLayerColors();
590
591 m_BgColorTop = to_SFVEC4F( colors[ LAYER_3D_BACKGROUND_TOP ] );
592 m_BgColorBot = to_SFVEC4F( colors[ LAYER_3D_BACKGROUND_BOTTOM ] );
593 m_SolderPasteColor = to_SFVEC4F( colors[ LAYER_3D_SOLDERPASTE ] );
594 m_SilkScreenColorBot = to_SFVEC4F( colors[ LAYER_3D_SILKSCREEN_BOTTOM ] );
595 m_SilkScreenColorTop = to_SFVEC4F( colors[ LAYER_3D_SILKSCREEN_TOP ] );
596 m_SolderMaskColorBot = to_SFVEC4F( colors[ LAYER_3D_SOLDERMASK_BOTTOM ] );
597 m_SolderMaskColorTop = to_SFVEC4F( colors[ LAYER_3D_SOLDERMASK_TOP ] );
598 m_CopperColor = to_SFVEC4F( colors[ LAYER_3D_COPPER_TOP ] );
599 m_BoardBodyColor = to_SFVEC4F( colors[ LAYER_3D_BOARD ] );
600 m_UserDrawingsColor = to_SFVEC4F( colors[ LAYER_3D_USER_DRAWINGS ] );
601 m_UserCommentsColor = to_SFVEC4F( colors[ LAYER_3D_USER_COMMENTS ] );
602 m_ECO1Color = to_SFVEC4F( colors[ LAYER_3D_USER_ECO1 ] );
603 m_ECO2Color = to_SFVEC4F( colors[ LAYER_3D_USER_ECO2 ] );
604
605 for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
606 m_UserDefinedLayerColor[ layer - LAYER_3D_USER_1 ] = to_SFVEC4F( colors[ layer ] );
607}
608
609
636
637
638std::map<int, COLOR4D> BOARD_ADAPTER::GetLayerColors() const
639{
640 std::map<int, COLOR4D> colors;
641
642 if( LAYER_PRESET_3D* preset = m_Cfg->FindPreset( m_Cfg->m_CurrentPreset ) )
643 {
644 colors = preset->colors;
645 }
646 else
647 {
649
650 for( const auto& [ layer, defaultColor /* unused */ ] : GetDefaultColors() )
651 colors[ layer ] = settings->GetColor( layer );
652 }
653
654 if( m_Cfg->m_UseStackupColors && m_board )
655 {
656 const BOARD_STACKUP& stackup = m_board->GetDesignSettings().GetStackupDescriptor();
657 KIGFX::COLOR4D bodyColor( 0, 0, 0, 0 );
658
659 // Can't do a const KIGFX::COLOR4D& return type here because there are temporary variables
660 auto findColor =
661 []( const wxString& aColorName,
662 const CUSTOM_COLORS_LIST& aColorSet ) -> const KIGFX::COLOR4D
663 {
664 if( aColorName.StartsWith( wxT( "#" ) ) )
665 {
666 return KIGFX::COLOR4D( aColorName );
667 }
668 else
669 {
670 for( const CUSTOM_COLOR_ITEM& color : aColorSet )
671 {
672 if( color.m_ColorName == aColorName )
673 return color.m_Color;
674 }
675 }
676
677 return KIGFX::COLOR4D();
678 };
679
680 for( const BOARD_STACKUP_ITEM* stackupItem : stackup.GetList() )
681 {
682 wxString colorName = stackupItem->GetColor();
683
684 switch( stackupItem->GetType() )
685 {
687 if( stackupItem->GetBrdLayerId() == F_SilkS )
688 colors[ LAYER_3D_SILKSCREEN_TOP ] = findColor( colorName, g_SilkColors );
689 else
690 colors[ LAYER_3D_SILKSCREEN_BOTTOM ] = findColor( colorName, g_SilkColors );
691
692 break;
693
695 if( stackupItem->GetBrdLayerId() == F_Mask )
696 colors[ LAYER_3D_SOLDERMASK_TOP ] = findColor( colorName, g_MaskColors );
697 else
698 colors[ LAYER_3D_SOLDERMASK_BOTTOM ] = findColor( colorName, g_MaskColors );
699
700 break;
701
703 {
704 KIGFX::COLOR4D layerColor = findColor( colorName, g_BoardColors );
705
706 if( bodyColor == COLOR4D( 0, 0, 0, 0 ) )
707 bodyColor = layerColor;
708 else
709 bodyColor = bodyColor.Mix( layerColor, 1.0 - layerColor.a );
710
711 bodyColor.a += ( 1.0 - bodyColor.a ) * layerColor.a / 2;
712 break;
713 }
714
715 default:
716 break;
717 }
718 }
719
720 if( bodyColor != COLOR4D( 0, 0, 0, 0 ) )
721 colors[ LAYER_3D_BOARD ] = bodyColor;
722
723 const wxString& finishName = stackup.m_FinishType;
724
725 if( finishName.EndsWith( wxT( "OSP" ) ) )
726 {
727 colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Copper" ), g_FinishColors );
728 }
729 else if( finishName.EndsWith( wxT( "IG" ) )
730 || finishName.EndsWith( wxT( "gold" ) ) )
731 {
732 colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Gold" ), g_FinishColors );
733 }
734 else if( finishName.StartsWith( wxT( "HAL" ) )
735 || finishName.StartsWith( wxT( "HASL" ) )
736 || finishName.EndsWith( wxT( "tin" ) )
737 || finishName.EndsWith( wxT( "nickel" ) ) )
738 {
739 colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Tin" ), g_FinishColors );
740 }
741 else if( finishName.EndsWith( wxT( "silver" ) ) )
742 {
743 colors[ LAYER_3D_COPPER_TOP ] = findColor( wxT( "Silver" ), g_FinishColors );
744 }
745 }
746
747 colors[ LAYER_3D_COPPER_BOTTOM ] = colors[ LAYER_3D_COPPER_TOP ];
748
749 for( const auto& [layer, val] : m_ColorOverrides )
750 colors[layer] = val;
751
752 return colors;
753}
754
755
756void BOARD_ADAPTER::SetLayerColors( const std::map<int, COLOR4D>& aColors )
757{
759
760 for( const auto& [ layer, color ] : aColors )
761 {
762 settings->SetColor( layer, color );
763
764 if( layer >= LAYER_3D_USER_1 && layer <= LAYER_3D_USER_45 )
766 }
767
768 Pgm().GetSettingsManager().SaveColorSettings( settings, "3d_viewer" );
769}
770
771
772void BOARD_ADAPTER::SetVisibleLayers( const std::bitset<LAYER_3D_END>& aLayers )
773{
774 m_Cfg->m_Render.show_board_body = aLayers.test( LAYER_3D_BOARD );
775 m_Cfg->m_Render.show_plated_barrels = aLayers.test( LAYER_3D_PLATED_BARRELS );
776 m_Cfg->m_Render.show_copper_top = aLayers.test( LAYER_3D_COPPER_TOP );
777 m_Cfg->m_Render.show_copper_bottom = aLayers.test( LAYER_3D_COPPER_BOTTOM );
778 m_Cfg->m_Render.show_silkscreen_top = aLayers.test( LAYER_3D_SILKSCREEN_TOP );
779 m_Cfg->m_Render.show_silkscreen_bottom = aLayers.test( LAYER_3D_SILKSCREEN_BOTTOM );
780 m_Cfg->m_Render.show_soldermask_top = aLayers.test( LAYER_3D_SOLDERMASK_TOP );
781 m_Cfg->m_Render.show_soldermask_bottom = aLayers.test( LAYER_3D_SOLDERMASK_BOTTOM );
782 m_Cfg->m_Render.show_solderpaste = aLayers.test( LAYER_3D_SOLDERPASTE );
783 m_Cfg->m_Render.show_adhesive = aLayers.test( LAYER_3D_ADHESIVE );
784 m_Cfg->m_Render.show_comments = aLayers.test( LAYER_3D_USER_COMMENTS );
785 m_Cfg->m_Render.show_drawings = aLayers.test( LAYER_3D_USER_DRAWINGS );
786 m_Cfg->m_Render.show_eco1 = aLayers.test( LAYER_3D_USER_ECO1 );
787 m_Cfg->m_Render.show_eco2 = aLayers.test( LAYER_3D_USER_ECO2 );
788
789 for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
790 m_Cfg->m_Render.show_user[ layer - LAYER_3D_USER_1 ] = aLayers.test( layer );
791
792 m_Cfg->m_Render.show_footprints_normal = aLayers.test( LAYER_3D_TH_MODELS );
793 m_Cfg->m_Render.show_footprints_insert = aLayers.test( LAYER_3D_SMD_MODELS );
794 m_Cfg->m_Render.show_footprints_virtual = aLayers.test( LAYER_3D_VIRTUAL_MODELS );
795 m_Cfg->m_Render.show_footprints_not_in_posfile = aLayers.test( LAYER_3D_MODELS_NOT_IN_POS );
796 m_Cfg->m_Render.show_footprints_dnp = aLayers.test( LAYER_3D_MODELS_MARKED_DNP );
797
798 m_Cfg->m_Render.show_fp_references = aLayers.test( LAYER_FP_REFERENCES );
799 m_Cfg->m_Render.show_fp_values = aLayers.test( LAYER_FP_VALUES );
800 m_Cfg->m_Render.show_fp_text = aLayers.test( LAYER_FP_TEXT );
801
802 m_Cfg->m_Render.show_model_bbox = aLayers.test( LAYER_3D_BOUNDING_BOXES );
803 m_Cfg->m_Render.show_off_board_silk = aLayers.test( LAYER_3D_OFF_BOARD_SILK );
804 m_Cfg->m_Render.show_navigator = aLayers.test( LAYER_3D_NAVIGATOR );
805}
806
807
808std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetVisibleLayers() const
809{
810 std::bitset<LAYER_3D_END> ret;
811
812 if( m_IsPreviewer )
813 {
814 if( m_Cfg->m_Render.preview_show_board_body )
815 {
816 ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
817 ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
818 ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
819 ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
820 ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
821 }
822
823 ret.set( LAYER_3D_PLATED_BARRELS, true );
824 ret.set( LAYER_3D_COPPER_TOP, true );
825 ret.set( LAYER_3D_COPPER_BOTTOM, true );
826 ret.set( LAYER_3D_SILKSCREEN_TOP, true );
827 ret.set( LAYER_3D_SILKSCREEN_BOTTOM, true );
828 ret.set( LAYER_3D_USER_COMMENTS, true );
829 ret.set( LAYER_3D_USER_DRAWINGS, true );
830 ret.set( LAYER_3D_USER_ECO1, true );
831 ret.set( LAYER_3D_USER_ECO2, true );
832
833 for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
834 ret.set( layer, true );
835
836 ret.set( LAYER_FP_REFERENCES, true );
837 ret.set( LAYER_FP_VALUES, true );
838 ret.set( LAYER_FP_TEXT, true );
839
840 ret.set( LAYER_3D_TH_MODELS, true );
841 ret.set( LAYER_3D_SMD_MODELS, true );
842 ret.set( LAYER_3D_VIRTUAL_MODELS, true );
843 ret.set( LAYER_3D_MODELS_NOT_IN_POS, true );
844 ret.set( LAYER_3D_MODELS_MARKED_DNP, true );
845
846 ret.set( LAYER_3D_BOUNDING_BOXES, m_Cfg->m_Render.show_model_bbox );
847 ret.set( LAYER_3D_OFF_BOARD_SILK, m_Cfg->m_Render.show_off_board_silk );
848 ret.set( LAYER_3D_NAVIGATOR, m_Cfg->m_Render.show_navigator );
849
850 return ret;
851 }
852
853 ret.set( LAYER_3D_BOARD, m_Cfg->m_Render.show_board_body );
854 ret.set( LAYER_3D_PLATED_BARRELS, m_Cfg->m_Render.show_plated_barrels );
855 ret.set( LAYER_3D_COPPER_TOP, m_Cfg->m_Render.show_copper_top );
856 ret.set( LAYER_3D_COPPER_BOTTOM, m_Cfg->m_Render.show_copper_bottom );
857 ret.set( LAYER_3D_SILKSCREEN_TOP, m_Cfg->m_Render.show_silkscreen_top );
858 ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_Cfg->m_Render.show_silkscreen_bottom );
859 ret.set( LAYER_3D_SOLDERMASK_TOP, m_Cfg->m_Render.show_soldermask_top );
860 ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_Cfg->m_Render.show_soldermask_bottom );
861 ret.set( LAYER_3D_SOLDERPASTE, m_Cfg->m_Render.show_solderpaste );
862 ret.set( LAYER_3D_ADHESIVE, m_Cfg->m_Render.show_adhesive );
863 ret.set( LAYER_3D_USER_COMMENTS, m_Cfg->m_Render.show_comments );
864 ret.set( LAYER_3D_USER_DRAWINGS, m_Cfg->m_Render.show_drawings );
865 ret.set( LAYER_3D_USER_ECO1, m_Cfg->m_Render.show_eco1 );
866 ret.set( LAYER_3D_USER_ECO2, m_Cfg->m_Render.show_eco2 );
867
868 for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
869 ret.set( layer, m_Cfg->m_Render.show_user[ layer - LAYER_3D_USER_1 ] );
870
871 ret.set( LAYER_FP_REFERENCES, m_Cfg->m_Render.show_fp_references );
872 ret.set( LAYER_FP_VALUES, m_Cfg->m_Render.show_fp_values );
873 ret.set( LAYER_FP_TEXT, m_Cfg->m_Render.show_fp_text );
874
875 ret.set( LAYER_3D_TH_MODELS, m_Cfg->m_Render.show_footprints_normal );
876 ret.set( LAYER_3D_SMD_MODELS, m_Cfg->m_Render.show_footprints_insert );
877 ret.set( LAYER_3D_VIRTUAL_MODELS, m_Cfg->m_Render.show_footprints_virtual );
878 ret.set( LAYER_3D_MODELS_NOT_IN_POS, m_Cfg->m_Render.show_footprints_not_in_posfile );
879 ret.set( LAYER_3D_MODELS_MARKED_DNP, m_Cfg->m_Render.show_footprints_dnp );
880
881 ret.set( LAYER_3D_BOUNDING_BOXES, m_Cfg->m_Render.show_model_bbox );
882 ret.set( LAYER_3D_OFF_BOARD_SILK, m_Cfg->m_Render.show_off_board_silk );
883 ret.set( LAYER_3D_NAVIGATOR, m_Cfg->m_Render.show_navigator );
884
885 if( m_Cfg->m_CurrentPreset == FOLLOW_PCB )
886 {
887 if( !m_board )
888 return ret;
889
890 ret.set( LAYER_3D_BOARD, true );
891 ret.set( LAYER_3D_COPPER_TOP, m_board->IsLayerVisible( F_Cu ) );
892 ret.set( LAYER_3D_COPPER_BOTTOM, m_board->IsLayerVisible( B_Cu ) );
893 ret.set( LAYER_3D_SILKSCREEN_TOP, m_board->IsLayerVisible( F_SilkS ) );
894 ret.set( LAYER_3D_SILKSCREEN_BOTTOM, m_board->IsLayerVisible( B_SilkS ) );
895 ret.set( LAYER_3D_SOLDERMASK_TOP, m_board->IsLayerVisible( F_Mask ) );
896 ret.set( LAYER_3D_SOLDERMASK_BOTTOM, m_board->IsLayerVisible( B_Mask ) );
897 ret.set( LAYER_3D_SOLDERPASTE, m_board->IsLayerVisible( F_Paste ) );
898 ret.set( LAYER_3D_ADHESIVE, m_board->IsLayerVisible( F_Adhes ) );
899 ret.set( LAYER_3D_USER_COMMENTS, m_board->IsLayerVisible( Cmts_User ) );
900 ret.set( LAYER_3D_USER_DRAWINGS, m_board->IsLayerVisible( Dwgs_User ) );
901 ret.set( LAYER_3D_USER_ECO1, m_board->IsLayerVisible( Eco1_User ) );
902 ret.set( LAYER_3D_USER_ECO2, m_board->IsLayerVisible( Eco2_User ) );
903
905 ret.set( layer, m_board->IsElementVisible( layer ) );
906 }
907 else if( m_Cfg->m_CurrentPreset == FOLLOW_PLOT_SETTINGS )
908 {
909 if( !m_board )
910 return ret;
911
912 const PCB_PLOT_PARAMS& plotParams = m_board->GetPlotOptions();
913 LSET layers = plotParams.GetLayerSelection();
914
915 for( PCB_LAYER_ID commonLayer : plotParams.GetPlotOnAllLayersSequence() )
916 layers.set( commonLayer );
917
918 ret.set( LAYER_3D_BOARD, true );
919 ret.set( LAYER_3D_COPPER_TOP, layers.test( F_Cu ) );
920 ret.set( LAYER_3D_COPPER_BOTTOM, layers.test( B_Cu ) );
921 ret.set( LAYER_3D_SILKSCREEN_TOP, layers.test( F_SilkS ) );
922 ret.set( LAYER_3D_SILKSCREEN_BOTTOM, layers.test( B_SilkS ) );
923 ret.set( LAYER_3D_SOLDERMASK_TOP, layers.test( F_Mask ) );
924 ret.set( LAYER_3D_SOLDERMASK_BOTTOM, layers.test( B_Mask ) );
925 ret.set( LAYER_3D_SOLDERPASTE, layers.test( F_Paste ) );
926 ret.set( LAYER_3D_ADHESIVE, layers.test( F_Adhes ) );
927 ret.set( LAYER_3D_USER_COMMENTS, layers.test( Cmts_User ) );
928 ret.set( LAYER_3D_USER_DRAWINGS, layers.test( Dwgs_User ) );
929 ret.set( LAYER_3D_USER_ECO1, layers.test( Eco1_User ) );
930 ret.set( LAYER_3D_USER_ECO2, layers.test( Eco2_User ) );
931
932 for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
933 ret.set( layer, layers.test( Map3DLayerToPCBLayer( layer ) ) );
934
935 ret.set( LAYER_FP_REFERENCES, plotParams.GetPlotReference() );
936 ret.set( LAYER_FP_VALUES, plotParams.GetPlotValue() );
937 ret.set( LAYER_FP_TEXT, plotParams.GetPlotFPText() );
938 }
939 else if( LAYER_PRESET_3D* preset = m_Cfg->FindPreset( m_Cfg->m_CurrentPreset ) )
940 {
941 ret = preset->layers;
942 }
943
944 return ret;
945}
946
947
948std::bitset<LAYER_3D_END> BOARD_ADAPTER::GetDefaultVisibleLayers() const
949{
950 std::bitset<LAYER_3D_END> ret;
951
952 ret.set( LAYER_3D_BOARD, true );
953 ret.set( LAYER_3D_PLATED_BARRELS, true );
954 ret.set( LAYER_3D_COPPER_TOP, true );
955 ret.set( LAYER_3D_COPPER_BOTTOM, true );
956 ret.set( LAYER_3D_SILKSCREEN_TOP, true );
957 ret.set( LAYER_3D_SILKSCREEN_BOTTOM, true );
958 ret.set( LAYER_3D_SOLDERMASK_TOP, true );
959 ret.set( LAYER_3D_SOLDERMASK_BOTTOM, true );
960 ret.set( LAYER_3D_SOLDERPASTE, true );
961 ret.set( LAYER_3D_ADHESIVE, true );
962 ret.set( LAYER_3D_USER_COMMENTS, false );
963 ret.set( LAYER_3D_USER_DRAWINGS, false );
964 ret.set( LAYER_3D_USER_ECO1, false );
965 ret.set( LAYER_3D_USER_ECO2, false );
966
967 for( int layer = LAYER_3D_USER_1; layer <= LAYER_3D_USER_45; ++layer )
968 ret.set( layer, false );
969
970 ret.set( LAYER_FP_REFERENCES, true );
971 ret.set( LAYER_FP_VALUES, true );
972 ret.set( LAYER_FP_TEXT, true );
973
974 ret.set( LAYER_3D_TH_MODELS, true );
975 ret.set( LAYER_3D_SMD_MODELS, true );
976 ret.set( LAYER_3D_VIRTUAL_MODELS, true );
977 ret.set( LAYER_3D_MODELS_NOT_IN_POS, false );
978 ret.set( LAYER_3D_MODELS_MARKED_DNP, false );
979
980 ret.set( LAYER_3D_BOUNDING_BOXES, false );
981 ret.set( LAYER_3D_OFF_BOARD_SILK, false );
982 ret.set( LAYER_3D_NAVIGATOR, true );
983
984 return ret;
985}
986
987
989{
990 return m_Cfg->m_Render.use_board_editor_copper_colors && !m_board->IsFootprintHolder();
991}
992
993
994bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
995{
996 m_board_poly.RemoveAllContours();
997
998 if( !m_board )
999 return false;
1000
1001 bool success;
1002
1003 if( m_board->IsFootprintHolder() )
1004 {
1005 if( !m_board->GetFirstFootprint() )
1006 {
1007 if( aErrorMsg )
1008 *aErrorMsg = _( "No footprint loaded." );
1009
1010 return false;
1011 }
1012
1013 // max dist from one endPt to next startPt
1014 int chainingEpsilon = m_board->GetOutlinesChainingEpsilon();
1015
1017 m_board->GetDesignSettings().m_MaxError,
1018 chainingEpsilon );
1019 m_board_poly.Simplify();
1020
1021 if( !success && aErrorMsg )
1022 {
1023 *aErrorMsg = _( "Footprint outline is missing or malformed. Run Footprint Checker for "
1024 "a full analysis." );
1025 }
1026 }
1027 else
1028 {
1029 success = m_board->GetBoardPolygonOutlines( m_board_poly, true, nullptr, false, true );
1030
1031 if( !success && aErrorMsg )
1032 *aErrorMsg = _( "Board outline is missing or malformed. Run DRC for a full analysis." );
1033 }
1034
1035 return success;
1036}
1037
1038
1039float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const
1040{
1041 if( aIsFlipped )
1042 {
1043 if( auto it = m_layerZcoordBottom.find( B_Paste ); it != m_layerZcoordBottom.end() )
1044 return it->second;
1045 }
1046 else
1047 {
1048 if( auto it = m_layerZcoordTop.find( F_Paste ); it != m_layerZcoordTop.end() )
1049 return it->second;
1050 }
1051
1052 return 0.0;
1053}
1054
1055
1057{
1058 if( aLayerId >= LAYER_3D_USER_1 && aLayerId <= LAYER_3D_USER_45 )
1059 aLayerId = Map3DLayerToPCBLayer( aLayerId );
1060
1061 wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
1062
1063 return GetColor( m_BoardEditorColors.at( aLayerId ) );
1064}
1065
1066
1068{
1069 return SFVEC4F( aColor.r, aColor.g, aColor.b, aColor.a );
1070}
1071
1072
1074{
1075 SFVEC2F sphericalCoord = SFVEC2F( ( m_Cfg->m_Render.raytrace_lightElevation[i] + 90.0f ) / 180.0f,
1076 m_Cfg->m_Render.raytrace_lightAzimuth[i] / 180.0f );
1077
1078 sphericalCoord.x = glm::clamp( sphericalCoord.x, 0.0f, 1.0f );
1079 sphericalCoord.y = glm::clamp( sphericalCoord.y, 0.0f, 2.0f );
1080
1081 return sphericalCoord;
1082}
Defines math related functions.
Defines math related functions.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
#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_COPPER
@ BS_ITEM_TYPE_SILKSCREEN
@ BS_ITEM_TYPE_DIELECTRIC
@ BS_ITEM_TYPE_SOLDERMASK
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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)
Definition base_set.h:116
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
SFVEC4F m_ECO2Color
void SetVisibleLayers(const std::bitset< LAYER_3D_END > &aLayers)
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.
S3D_CACHE * m_3dModelManager
void createLayers(REPORTER *aStatusReporter)
VECTOR2I m_boardPos
Board center position in board internal units.
float m_backCopperThickness3DU
bool GetUseBoardEditorCopperLayerColors() const
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
SFVEC4F m_UserDefinedLayerColor[45]
unsigned int m_viaCount
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.
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
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 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
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 )
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
float m_nonCopperLayerThickness3DU
unsigned int m_holeCount
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.
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_ECO1Color
SFVEC4F m_UserDrawingsColor
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.
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
int GetCount() 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.
Definition box2.h:558
constexpr size_type GetWidth() const
Definition box2.h:214
constexpr Vec Centre() const
Definition box2.h:97
constexpr size_type GetHeight() const
Definition box2.h:215
constexpr const SizeVec & GetSize() const
Definition box2.h:206
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
int GetAttributes() const
Definition footprint.h:417
bool GetDNPForVariant(const wxString &aVariantName) const
Get the DNP status for a specific variant.
bool GetExcludedFromPosFilesForVariant(const wxString &aVariantName) const
Get the exclude-from-position-files status for a specific variant.
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:105
double r
Red component.
Definition color4d.h:393
double g
Green component.
Definition color4d.h:394
double a
Alpha component.
Definition color4d.h:396
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:296
double b
Blue component.
Definition color4d.h:395
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
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
Definition pgm_base.h:131
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
Definition reporter.h:102
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.
std::vector< CUSTOM_COLOR_ITEM > CUSTOM_COLORS_LIST
#define _(s)
#define FOLLOW_PLOT_SETTINGS
#define FOLLOW_PCB
static constexpr EDA_ANGLE FULL_CIRCLE
Definition eda_angle.h:409
FOOTPRINT_ATTR_T
The set of attributes allowed within a FOOTPRINT, using FOOTPRINT::SetAttributes() and FOOTPRINT::Get...
Definition footprint.h:83
@ FP_SMD
Definition footprint.h:85
@ FP_THROUGH_HOLE
Definition footprint.h:84
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)
Definition layer_id.cpp:268
int MapPCBLayerTo3DLayer(PCB_LAYER_ID aLayer)
Definition layer_id.cpp:334
@ LAYER_3D_USER_1
Definition layer_ids.h:567
@ LAYER_3D_SOLDERMASK_TOP
Definition layer_ids.h:560
@ LAYER_3D_NAVIGATOR
Definition layer_ids.h:617
@ LAYER_3D_BOUNDING_BOXES
Definition layer_ids.h:618
@ LAYER_3D_ADHESIVE
Definition layer_ids.h:562
@ LAYER_3D_SMD_MODELS
Definition layer_ids.h:613
@ LAYER_3D_BACKGROUND_TOP
Definition layer_ids.h:553
@ LAYER_3D_USER_COMMENTS
Definition layer_ids.h:563
@ LAYER_3D_SOLDERMASK_BOTTOM
Definition layer_ids.h:559
@ LAYER_3D_BOARD
Definition layer_ids.h:554
@ LAYER_3D_PLATED_BARRELS
Definition layer_ids.h:620
@ LAYER_3D_USER_ECO1
Definition layer_ids.h:565
@ LAYER_3D_USER_ECO2
Definition layer_ids.h:566
@ LAYER_3D_TH_MODELS
Definition layer_ids.h:612
@ LAYER_3D_SILKSCREEN_TOP
Definition layer_ids.h:558
@ LAYER_3D_VIRTUAL_MODELS
Definition layer_ids.h:614
@ LAYER_3D_MODELS_MARKED_DNP
Definition layer_ids.h:616
@ LAYER_3D_COPPER_TOP
Definition layer_ids.h:555
@ LAYER_3D_SOLDERPASTE
Definition layer_ids.h:561
@ LAYER_3D_OFF_BOARD_SILK
Definition layer_ids.h:619
@ LAYER_3D_MODELS_NOT_IN_POS
Definition layer_ids.h:615
@ LAYER_3D_USER_45
Definition layer_ids.h:611
@ LAYER_3D_USER_DRAWINGS
Definition layer_ids.h:564
@ LAYER_3D_COPPER_BOTTOM
Definition layer_ids.h:556
@ LAYER_3D_BACKGROUND_BOTTOM
Definition layer_ids.h:552
@ LAYER_3D_SILKSCREEN_BOTTOM
Definition layer_ids.h:557
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:677
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
Definition layer_ids.h:266
@ LAYER_FP_TEXT
Definition layer_ids.h:240
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
Definition layer_ids.h:263
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ B_Adhes
Definition layer_ids.h:103
@ Dwgs_User
Definition layer_ids.h:107
@ F_Paste
Definition layer_ids.h:104
@ Cmts_User
Definition layer_ids.h:108
@ F_Adhes
Definition layer_ids.h:102
@ B_Mask
Definition layer_ids.h:98
@ B_Cu
Definition layer_ids.h:65
@ Eco1_User
Definition layer_ids.h:109
@ F_Mask
Definition layer_ids.h:97
@ B_Paste
Definition layer_ids.h:105
@ F_SilkS
Definition layer_ids.h:100
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ Eco2_User
Definition layer_ids.h:110
@ B_SilkS
Definition layer_ids.h:101
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:171
@ F_Cu
Definition layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:754
PGM_BASE & Pgm()
The global program "get" accessor.
see class PGM_BASE
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
@ RPT_SEVERITY_WARNING
#define DEFAULT_THEME
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
T * GetAppSettings(const char *aFilename)
wxString NotSpecifiedPrm()
Manage a bounding box defined by two SFVEC3F min max points.
Definition bbox_3d.h:43
A class to handle a custom color (predefined color) for the color picker dialog.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
glm::vec2 SFVEC2F
Definition xv3d_types.h:42
glm::vec3 SFVEC3F
Definition xv3d_types.h:44
glm::vec4 SFVEC4F
Definition xv3d_types.h:46