2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2022-10-21 12:48:45 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
#ifndef BOARD_ADAPTER_H
|
|
|
|
#define BOARD_ADAPTER_H
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-03-25 13:13:03 +00:00
|
|
|
#include <array>
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <vector>
|
2021-10-21 13:29:19 +00:00
|
|
|
#include "../3d_rendering/raytracing/accelerators/container_2d.h"
|
|
|
|
#include "../3d_rendering/raytracing/accelerators/container_3d.h"
|
|
|
|
#include "../3d_rendering/raytracing/shapes3D/bbox_3d.h"
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "../3d_rendering/camera.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
#include "../3d_enums.h"
|
|
|
|
#include "../3d_cache/3d_cache.h"
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "../common_ogl/ogl_attr_list.h"
|
2021-08-30 20:30:18 +00:00
|
|
|
#include "../3d_viewer/eda_3d_viewer_settings.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <pad.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2020-10-04 23:34:59 +00:00
|
|
|
#include <pcb_text.h>
|
|
|
|
#include <pcb_shape.h>
|
2021-06-11 16:59:28 +00:00
|
|
|
#include <pcb_dimension.h>
|
2020-11-11 23:05:59 +00:00
|
|
|
#include <zone.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <footprint.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <reporter.h>
|
2021-08-05 20:47:23 +00:00
|
|
|
#include <dialogs/dialog_color_picker.h>
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
class COLOR_SETTINGS;
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
/// A type that stores a container of 2d objects for each layer id
|
2021-08-30 20:30:18 +00:00
|
|
|
typedef std::map<PCB_LAYER_ID, BVH_CONTAINER_2D*> MAP_CONTAINER_2D_BASE;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/// A type that stores polysets for each layer id
|
2021-08-30 20:30:18 +00:00
|
|
|
typedef std::map<PCB_LAYER_ID, SHAPE_POLY_SET*> MAP_POLY;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/// This defines the range that all coord will have to be rendered.
|
|
|
|
/// It will use this value to convert to a normalized value between
|
|
|
|
/// -(RANGE_SCALE_3D/2) .. +(RANGE_SCALE_3D/2)
|
|
|
|
#define RANGE_SCALE_3D 8.0f
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Helper class to handle information needed to display 3D board.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2020-03-26 14:05:20 +00:00
|
|
|
class BOARD_ADAPTER
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2020-12-16 22:10:42 +00:00
|
|
|
public:
|
2020-03-26 14:05:20 +00:00
|
|
|
BOARD_ADAPTER();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
~BOARD_ADAPTER();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Update the cache manager pointer.
|
|
|
|
*
|
|
|
|
* @param aCachePointer: the pointer to the 3D cache manager.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
void Set3dCacheManager( S3D_CACHE* aCacheMgr ) noexcept { m_3dModelManager = aCacheMgr; }
|
|
|
|
S3D_CACHE* Get3dCacheManager() const noexcept { return m_3dModelManager; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Check if a layer is enabled.
|
|
|
|
*
|
|
|
|
* @param aLayer layer ID to get status.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
bool Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Test if footprint should be displayed in relation to attributes and the flags.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
bool IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Set current board to be rendered.
|
|
|
|
*
|
|
|
|
* @param aBoard board to process.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
void SetBoard( BOARD* aBoard ) noexcept { m_board = aBoard; }
|
|
|
|
const BOARD* GetBoard() const noexcept { return m_board; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2023-05-01 14:51:01 +00:00
|
|
|
void ReloadColorSettings() noexcept;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Function to be called by the render when it need to reload the settings for the board.
|
|
|
|
*
|
|
|
|
* @param aStatusReporter the pointer for the status reporter.
|
|
|
|
* @param aWarningReporter pointer for the warning reporter.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2020-06-03 23:00:40 +00:00
|
|
|
void InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Board integer units To 3D units.
|
|
|
|
*
|
|
|
|
* @return the conversion factor to transform a position from the board to 3D units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
double BiuTo3dUnits() const noexcept { return m_biuTo3Dunits; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* Get the board outling bounding box.
|
2020-12-16 22:10:42 +00:00
|
|
|
*
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return the board bounding box in 3D units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
const BBOX_3D& GetBBox() const noexcept { return m_boardBoundingBox; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-03 14:14:50 +00:00
|
|
|
* Get the board body thickness, including internal copper layers (in 3D units).
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-12-03 14:14:50 +00:00
|
|
|
float GetBoardBodyThickness() const noexcept { return m_boardBodyThickness3DU; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-03 14:14:50 +00:00
|
|
|
* Get the non copper layers thickness (in 3D units).
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-12-03 14:14:50 +00:00
|
|
|
float GetNonCopperLayerThickness() const noexcept { return m_nonCopperLayerThickness3DU; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-03 14:14:50 +00:00
|
|
|
* Get the copper layer thicknesses (in 3D units).
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-12-03 14:14:50 +00:00
|
|
|
float GetFrontCopperThickness() const noexcept { return m_frontCopperThickness3DU; }
|
|
|
|
float GetBackCopperThickness() const noexcept { return m_backCopperThickness3DU; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-12-03 14:14:50 +00:00
|
|
|
* Get the hole plating thickness (NB: in BOARD UNITS!).
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
int GetHolePlatingThickness() const noexcept;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the board size.
|
|
|
|
*
|
|
|
|
* @return size in BIU units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
VECTOR2I GetBoardSize() const noexcept { return m_boardSize; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the board center.
|
|
|
|
*
|
|
|
|
* @return position in BIU units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
VECTOR2I GetBoardPos() const noexcept { return m_boardPos; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* The board center position in 3D units.
|
|
|
|
*
|
|
|
|
* @return board center vector position in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
const SFVEC3F& GetBoardCenter() const noexcept { return m_boardCenter; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the position of the footprint in 3d integer units considering if it is flipped or not.
|
|
|
|
*
|
|
|
|
* @param aIsFlipped true for use in footprints on Front (top) layer, false
|
|
|
|
* if footprint is on back (bottom) layer.
|
|
|
|
* @return the Z position of 3D shapes, in 3D integer units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
float GetFootprintZPos( bool aIsFlipped ) const ;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the current polygon of the epoxy board.
|
|
|
|
*
|
2015-12-08 07:31:57 +00:00
|
|
|
* @return the shape polygon
|
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
const SHAPE_POLY_SET& GetBoardPoly() const noexcept { return m_board_poly; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the technical color of a layer.
|
|
|
|
*
|
|
|
|
* @param aLayerId the layer to get the color information.
|
|
|
|
* @return the color in SFVEC3F format.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2020-08-21 08:56:15 +00:00
|
|
|
SFVEC4F GetLayerColor( PCB_LAYER_ID aLayerId ) const;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the technical color of a layer.
|
|
|
|
*
|
|
|
|
* @param aItemId the item id to get the color information.
|
|
|
|
* @return the color in SFVEC3F format.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2020-08-21 08:56:15 +00:00
|
|
|
SFVEC4F GetItemColor( int aItemId ) const;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2021-07-26 17:28:37 +00:00
|
|
|
* @param[in] aColor is the color mapped.
|
2016-07-19 17:35:25 +00:00
|
|
|
* @return the color in SFVEC3F format
|
|
|
|
*/
|
2021-07-26 17:28:37 +00:00
|
|
|
SFVEC4F GetColor( const COLOR4D& aColor ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
SFVEC2F GetSphericalCoord( int i ) const;
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the top z position.
|
|
|
|
*
|
|
|
|
* @param aLayerId layer id.
|
|
|
|
* @return position in 3D units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
float GetLayerTopZPos( PCB_LAYER_ID aLayerId ) const noexcept
|
2020-03-24 01:01:23 +00:00
|
|
|
{
|
|
|
|
return m_layerZcoordTop[aLayerId];
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* Get the bottom z position.
|
|
|
|
*
|
|
|
|
* @param aLayerId layer id.
|
|
|
|
* @return position in 3D units.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
float GetLayerBottomZPos( PCB_LAYER_ID aLayerId ) const noexcept
|
2020-03-24 01:01:23 +00:00
|
|
|
{
|
|
|
|
return m_layerZcoordBottom[aLayerId];
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* Get the map of containers that have the objects per layer.
|
2020-12-16 22:10:42 +00:00
|
|
|
*
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return the map containers of this board.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
const MAP_CONTAINER_2D_BASE& GetLayerMap() const noexcept { return m_layerMap; }
|
|
|
|
const BVH_CONTAINER_2D* GetPlatedPadsFront() const noexcept { return m_platedPadsFront; }
|
|
|
|
const BVH_CONTAINER_2D* GetPlatedPadsBack() const noexcept { return m_platedPadsBack; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
const MAP_CONTAINER_2D_BASE& GetLayerHoleMap() const noexcept { return m_layerHoleMap; }
|
|
|
|
const BVH_CONTAINER_2D& GetThroughHoleIds() const noexcept { return m_throughHoleIds; }
|
|
|
|
const BVH_CONTAINER_2D& GetThroughHoleOds() const noexcept { return m_throughHoleOds; }
|
2020-07-16 22:36:06 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
/**
|
|
|
|
* Get through hole outside diameter 2D polygons.
|
|
|
|
*
|
|
|
|
* The outside diameter 2D polygon is the hole diameter plus the plating thickness.
|
|
|
|
*
|
|
|
|
* @return a container with through hold outside diameter 2D polygons.
|
|
|
|
*/
|
|
|
|
const SHAPE_POLY_SET& GetThroughHoleOdPolys() const noexcept
|
2020-04-16 16:11:21 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
return m_throughHoleOdPolys;
|
2020-04-16 16:11:21 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
const BVH_CONTAINER_2D& GetThroughHoleAnnularRings() const noexcept
|
|
|
|
{
|
|
|
|
return m_throughHoleAnnularRings;
|
|
|
|
}
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const SHAPE_POLY_SET& GetThroughHoleAnnularRingPolys() const noexcept
|
2020-10-01 00:13:04 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
return m_throughHoleAnnularRingPolys;
|
2020-10-01 00:13:04 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const SHAPE_POLY_SET& GetOuterNonPlatedThroughHolePoly() const noexcept
|
2020-03-24 01:01:23 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
return m_nonPlatedThroughHoleOdPolys;
|
2020-03-24 01:01:23 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return a container with through hole via hole outside diameters.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
const BVH_CONTAINER_2D& GetThroughHoleViaOds() const noexcept
|
2020-04-16 16:11:21 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
return m_throughHoleViaOds;
|
2020-04-16 16:11:21 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const SHAPE_POLY_SET& GetThroughHoleViaOdPolys() const noexcept
|
2020-03-24 01:01:23 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
return m_throughHoleViaOdPolys;
|
2020-03-24 01:01:23 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
unsigned int GetViaCount() const noexcept { return m_viaCount; }
|
|
|
|
unsigned int GetHoleCount() const noexcept { return m_holeCount; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return via hole average diameter dimension in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
float GetAverageViaHoleDiameter() const noexcept { return m_averageViaHoleDiameter; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return the average diameter of through holes in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
float GetAverageHoleDiameter() const noexcept { return m_averageHoleDiameter; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return average track width in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
float GetAverageTrackWidth() const noexcept { return m_averageTrackWidth; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* @param aDiameter3DU diameter in 3DU.
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return number of sides that should be used in a circle with \a aDiameter3DU.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
unsigned int GetCircleSegmentCount( float aDiameter3DU ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-16 22:10:42 +00:00
|
|
|
* @param aDiameterBIU diameter in board internal units.
|
2021-01-05 22:19:00 +00:00
|
|
|
* @return number of sides that should be used in circle with \a aDiameterBIU.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
unsigned int GetCircleSegmentCount( int aDiameterBIU ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-05 22:19:00 +00:00
|
|
|
* Get map of polygon's layers.
|
2020-12-16 22:10:42 +00:00
|
|
|
*
|
|
|
|
* @return the map with polygon's layers.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2022-02-17 17:49:03 +00:00
|
|
|
const MAP_POLY& GetPolyMap() const noexcept { return m_layers_poly; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
const SHAPE_POLY_SET* GetFrontPlatedPadPolys() { return m_frontPlatedPadPolys; }
|
|
|
|
const SHAPE_POLY_SET* GetBackPlatedPadPolys() { return m_backPlatedPadPolys; }
|
|
|
|
const MAP_POLY& GetHoleIdPolysMap() const noexcept { return m_layerHoleIdPolys; }
|
|
|
|
const MAP_POLY& GetHoleOdPolysMap() const noexcept { return m_layerHoleOdPolys; }
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
private:
|
2020-02-03 22:09:14 +00:00
|
|
|
/**
|
|
|
|
* Create the board outline polygon.
|
|
|
|
*
|
|
|
|
* @return false if the outline could not be created
|
|
|
|
*/
|
2020-08-17 20:07:27 +00:00
|
|
|
bool createBoardPolygon( wxString* aErrorMsg );
|
2020-06-03 23:00:40 +00:00
|
|
|
void createLayers( REPORTER* aStatusReporter );
|
2015-12-08 07:31:57 +00:00
|
|
|
void destroyLayers();
|
|
|
|
|
|
|
|
// Helper functions to create the board
|
2022-01-10 14:03:53 +00:00
|
|
|
void createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-10 14:03:53 +00:00
|
|
|
void createPadWithMargin( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
|
|
|
|
PCB_LAYER_ID aLayer, const VECTOR2I& aMargin ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
OBJECT_2D* createPadWithDrill( const PAD* aPad, int aInflateValue );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-10 14:03:53 +00:00
|
|
|
void addPads( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
|
2023-04-08 14:02:48 +00:00
|
|
|
PCB_LAYER_ID aLayerId, bool aSkipPlatedPads, bool aSkipNonPlatedPads );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-10 14:03:53 +00:00
|
|
|
void addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
|
|
|
|
PCB_LAYER_ID aLayerId );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
void addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
|
|
|
|
const BOARD_ITEM* aOwner );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
void addShape( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aContainer,
|
|
|
|
const BOARD_ITEM* aOwner );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
void addShape( const PCB_DIMENSION_BASE* aDimension, CONTAINER_2D_BASE* aDstContainer,
|
|
|
|
const BOARD_ITEM* aOwner );
|
2017-02-01 13:52:17 +00:00
|
|
|
|
2022-01-30 10:52:52 +00:00
|
|
|
void addSolidAreasShapes( const ZONE* aZone, CONTAINER_2D_BASE* aDstContainer,
|
2021-01-05 22:19:00 +00:00
|
|
|
PCB_LAYER_ID aLayerId );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-01-16 21:15:20 +00:00
|
|
|
void transformArcToSegments( const VECTOR2I& aCentre, const VECTOR2I& aStart,
|
|
|
|
const EDA_ANGLE& aArcAngle, int aCircleToSegmentsCount, int aWidth,
|
2022-01-30 10:52:52 +00:00
|
|
|
CONTAINER_2D_BASE* aDstContainer, const BOARD_ITEM& aOwner );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer, int aWidth );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Helper functions to create poly contours
|
2022-10-21 12:48:45 +00:00
|
|
|
void buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aBuffer, int aWidth) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-10-21 12:48:45 +00:00
|
|
|
void transformFPShapesToPolySet( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
|
|
|
|
SHAPE_POLY_SET& aBuffer ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-05 20:47:23 +00:00
|
|
|
public:
|
|
|
|
static CUSTOM_COLORS_LIST g_SilkscreenColors;
|
|
|
|
static CUSTOM_COLORS_LIST g_MaskColors;
|
|
|
|
static CUSTOM_COLORS_LIST g_PasteColors;
|
|
|
|
static CUSTOM_COLORS_LIST g_FinishColors;
|
|
|
|
static CUSTOM_COLORS_LIST g_BoardColors;
|
|
|
|
|
|
|
|
static KIGFX::COLOR4D g_DefaultBackgroundTop;
|
|
|
|
static KIGFX::COLOR4D g_DefaultBackgroundBot;
|
|
|
|
static KIGFX::COLOR4D g_DefaultSilkscreen;
|
|
|
|
static KIGFX::COLOR4D g_DefaultSolderMask;
|
|
|
|
static KIGFX::COLOR4D g_DefaultSolderPaste;
|
|
|
|
static KIGFX::COLOR4D g_DefaultSurfaceFinish;
|
|
|
|
static KIGFX::COLOR4D g_DefaultBoardBody;
|
|
|
|
|
2019-05-17 13:16:15 +00:00
|
|
|
public:
|
2021-08-30 20:30:18 +00:00
|
|
|
EDA_3D_VIEWER_SETTINGS* m_Cfg;
|
2022-02-17 17:49:03 +00:00
|
|
|
|
|
|
|
bool m_IsBoardView;
|
|
|
|
bool m_MousewheelPanning;
|
|
|
|
bool m_IsPreviewer; ///< true if the board adaptater is living in a 3D
|
|
|
|
///< preview panel, false for the standard 3D viewer
|
|
|
|
|
|
|
|
SFVEC4F m_BgColorBot; ///< background bottom color
|
|
|
|
SFVEC4F m_BgColorTop; ///< background top color
|
|
|
|
SFVEC4F m_BoardBodyColor; ///< in realistic mode: FR4 board color
|
|
|
|
SFVEC4F m_SolderMaskColorBot; ///< in realistic mode: solder mask color ( bot )
|
|
|
|
SFVEC4F m_SolderMaskColorTop; ///< in realistic mode: solder mask color ( top )
|
|
|
|
SFVEC4F m_SolderPasteColor; ///< in realistic mode: solder paste color
|
|
|
|
SFVEC4F m_SilkScreenColorBot; ///< in realistic mode: SilkScreen color ( bot )
|
|
|
|
SFVEC4F m_SilkScreenColorTop; ///< in realistic mode: SilkScreen color ( top )
|
|
|
|
SFVEC4F m_CopperColor; ///< in realistic mode: copper color
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-05-17 13:16:15 +00:00
|
|
|
private:
|
2021-08-30 20:30:18 +00:00
|
|
|
BOARD* m_board;
|
|
|
|
S3D_CACHE* m_3dModelManager;
|
2022-02-17 17:49:03 +00:00
|
|
|
RENDER_SETTINGS* m_renderSettings;
|
2021-08-30 20:30:18 +00:00
|
|
|
COLOR_SETTINGS* m_colors;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
VECTOR2I m_boardPos; ///< Board center position in board internal units.
|
|
|
|
VECTOR2I m_boardSize; ///< Board size in board internal units.
|
|
|
|
SFVEC3F m_boardCenter; ///< 3D center position of the board in 3D units.
|
|
|
|
BBOX_3D m_boardBoundingBox; ///< 3D bounding box of the board in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
MAP_POLY m_layers_poly; ///< Amalgamated polygon contours for various types of
|
|
|
|
///< items
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
SHAPE_POLY_SET* m_frontPlatedPadPolys;
|
|
|
|
SHAPE_POLY_SET* m_backPlatedPadPolys;
|
2020-09-06 19:09:43 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
MAP_POLY m_layerHoleOdPolys; ///< Hole outer diameters (per layer)
|
|
|
|
MAP_POLY m_layerHoleIdPolys; ///< Hole inner diameters (per layer)
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys; ///< NPTH outer diameters
|
|
|
|
SHAPE_POLY_SET m_throughHoleOdPolys; ///< PTH outer diameters
|
|
|
|
SHAPE_POLY_SET m_throughHoleViaOdPolys; ///< Via hole outer diameters
|
|
|
|
SHAPE_POLY_SET m_throughHoleAnnularRingPolys; ///< Via annular ring outer diameters
|
2020-07-16 22:36:06 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
SHAPE_POLY_SET m_board_poly; ///< Board outline polygon.
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2022-02-17 17:49:03 +00:00
|
|
|
MAP_CONTAINER_2D_BASE m_layerMap; ///< 2D elements for each layer.
|
|
|
|
MAP_CONTAINER_2D_BASE m_layerHoleMap; ///< Holes for each layer.
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
BVH_CONTAINER_2D* m_platedPadsFront;
|
|
|
|
BVH_CONTAINER_2D* m_platedPadsBack;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
BVH_CONTAINER_2D m_throughHoleOds; ///< List of PTH outer diameters
|
|
|
|
BVH_CONTAINER_2D m_throughHoleIds; ///< List of PTH inner diameters
|
|
|
|
BVH_CONTAINER_2D m_throughHoleAnnularRings; ///< List of via annular rings
|
|
|
|
BVH_CONTAINER_2D m_throughHoleViaOds; ///< List of via hole outer diameters
|
|
|
|
BVH_CONTAINER_2D m_throughHoleViaIds; ///< List of via hole inner diameters
|
2021-03-26 17:02:30 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
unsigned int m_copperLayersCount;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
double m_biuTo3Dunits; ///< Scale factor to convert board internal units to
|
|
|
|
///< 3D units normalized between -1.0 and 1.0.
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordTop; ///< Top (End) Z position of each
|
|
|
|
///< layer in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
std::array<float, PCB_LAYER_ID_COUNT> m_layerZcoordBottom; ///< Bottom (Start) Z position of
|
|
|
|
///< each layer in 3D units.
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-12-03 14:14:50 +00:00
|
|
|
float m_frontCopperThickness3DU;
|
|
|
|
float m_backCopperThickness3DU;
|
|
|
|
float m_boardBodyThickness3DU;
|
2021-08-30 20:30:18 +00:00
|
|
|
float m_nonCopperLayerThickness3DU;
|
|
|
|
float m_solderPasteLayerThickness3DU;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-08-30 20:30:18 +00:00
|
|
|
unsigned int m_trackCount;
|
|
|
|
float m_averageTrackWidth;
|
|
|
|
unsigned int m_viaCount;
|
|
|
|
float m_averageViaHoleDiameter;
|
|
|
|
unsigned int m_holeCount;
|
|
|
|
float m_averageHoleDiameter;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2021-08-30 20:30:18 +00:00
|
|
|
* Trace mask used to enable or disable debug output for this class. Output can be turned
|
|
|
|
* on by setting the WXTRACE environment variable to "KI_TRACE_EDA_CINFO3D_VISU". See the
|
|
|
|
* wxWidgets documentation on wxLogTrace for more information.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
static const wxChar* m_logTrace;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-03-24 01:01:23 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
class EDA_3D_BOARD_HOLDER
|
2020-03-24 01:01:23 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-03-26 14:05:20 +00:00
|
|
|
virtual BOARD_ADAPTER& GetAdapter() = 0;
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual CAMERA& GetCurrentCamera() = 0;
|
2020-04-19 00:51:49 +00:00
|
|
|
|
|
|
|
virtual ~EDA_3D_BOARD_HOLDER() {};
|
2020-03-24 01:01:23 +00:00
|
|
|
};
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-03-26 14:05:20 +00:00
|
|
|
#endif // BOARD_ADAPTER_H
|