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>
|
2020-12-13 23:02:57 +00:00
|
|
|
* Copyright (C) 2015-2020 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-01-03 22:23:00 +00:00
|
|
|
* @file render_3d_legacy.h
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
#ifndef RENDER_3D_LEGACY_H_
|
|
|
|
#define RENDER_3D_LEGACY_H_
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "../render_3d_base.h"
|
|
|
|
#include "layer_triangles.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "../3d_render_raytracing/shapes2D/polygon_2d.h"
|
|
|
|
#include "../3d_render_raytracing/shapes2D/triangle_2d.h"
|
|
|
|
#include "../3d_render_raytracing/shapes2D/4pt_polygon_2d.h"
|
|
|
|
#include "../3d_render_raytracing/shapes2D/filled_circle_2d.h"
|
|
|
|
#include "../3d_render_raytracing/shapes2D/ring_2d.h"
|
|
|
|
#include "../3d_render_raytracing/shapes2D/round_segment_2d.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "3d_model.h"
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
#include "3d_cache/3d_info.h"
|
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
typedef std::map< PCB_LAYER_ID, OPENGL_RENDER_LIST* > MAP_OGL_DISP_LISTS;
|
|
|
|
typedef std::list<TRIANGLE_DISPLAY_LIST* > LIST_TRIANGLES;
|
|
|
|
typedef std::map< wxString, MODEL_3D* > MAP_3DMODEL;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
#define SIZE_OF_CIRCLE_TEXTURE 1024
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-13 23:02:57 +00:00
|
|
|
* Object to render the board using openGL legacy mode.
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
class RENDER_3D_LEGACY : public RENDER_3D_BASE
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-02 21:05:29 +00:00
|
|
|
explicit RENDER_3D_LEGACY( BOARD_ADAPTER& aAdapter, CAMERA& aCamera );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
~RENDER_3D_LEGACY();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void SetCurWindowSize( const wxSize& aSize ) override;
|
2020-06-03 23:00:40 +00:00
|
|
|
bool Redraw( bool aIsMoving, REPORTER* aStatusReporter, REPORTER* aWarningReporter ) override;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
int GetWaitForEditingTimeOut() override;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-11-29 20:00:16 +00:00
|
|
|
void SetCurrentIntersectedBoardItem( BOARD_ITEM* aCurrentIntersectedBoardItem )
|
|
|
|
{
|
|
|
|
m_currentIntersectedBoardItem = aCurrentIntersectedBoardItem;
|
|
|
|
}
|
2020-09-04 00:00:56 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
private:
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* generateHoles( const LIST_OBJECT2D& aListHolesObject2d,
|
|
|
|
const SHAPE_POLY_SET& aPoly, float aZtop,
|
|
|
|
float aZbot, bool aInvertFaces,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* generateLayerList( const BVH_CONTAINER_2D* aContainer,
|
|
|
|
const SHAPE_POLY_SET* aPolyList,
|
|
|
|
PCB_LAYER_ID aLayerId,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void addTopAndBottomTriangles( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0,
|
|
|
|
const SFVEC2F& v1, const SFVEC2F& v2, float top, float bot );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void addObjectTriangles( const RING_2D* aRing, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void addObjectTriangles( const POLYGON_4PT_2D* aPoly, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void addObjectTriangles( const FILLED_CIRCLE_2D* aFilledCircle,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void addObjectTriangles( const TRIANGLE_2D* aTri, TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void addObjectTriangles( const ROUND_SEGMENT_2D* aSeg,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPosition,
|
|
|
|
bool aDrawMiddleSegments, bool aSkipRenderHoles );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void renderBoardBody( bool aSkipRenderHoles );
|
2020-08-25 20:33:51 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void getLayerZPos( PCB_LAYER_ID aLayerID, float& aOutZtop, float& aOutZbot ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void generateRing( const SFVEC2F& aCenter, float aInnerRadius, float aOuterRadius,
|
|
|
|
unsigned int aNr_sides_per_circle,
|
|
|
|
std::vector< SFVEC2F >& aInnerContourResult,
|
|
|
|
std::vector< SFVEC2F >& aOuterContourResult, bool aInvertOrder );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void generateCylinder( const SFVEC2F& aCenter, float aInnerRadius, float aOuterRadius,
|
|
|
|
float aZtop, float aZbot, unsigned int aNr_sides_per_circle,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void generateViasAndPads();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
/**
|
|
|
|
* Load footprint models from the cache and load it to openGL lists in the form of
|
2021-01-02 21:05:29 +00:00
|
|
|
* #MODEL_3D objects.
|
2020-12-13 23:02:57 +00:00
|
|
|
*
|
|
|
|
* This map of models will work as a local cache for this render. (cache based on
|
2021-01-02 21:05:29 +00:00
|
|
|
* MODEL_3D with associated openGL lists in GPU memory)
|
2020-12-13 23:02:57 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
void load3dModels( REPORTER* aStatusReporter );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-13 23:02:57 +00:00
|
|
|
* @param aRenderTopOrBot true will render Top, false will render bottom
|
|
|
|
* @param aRenderTransparentOnly true will render only the transparent objects, false will
|
|
|
|
* render opaque
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
void render3dModels( bool aRenderTopOrBot, bool aRenderTransparentOnly );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void render3dModelsSelected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
|
|
|
|
bool aRenderSelectedOnly );
|
2020-09-02 16:22:12 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void renderFootprint( const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
|
|
|
|
bool aIsSelected );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void setLightFront( bool enabled );
|
|
|
|
void setLightTop( bool enabled );
|
|
|
|
void setLightBottom( bool enabled );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void render3dArrows();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
/**
|
|
|
|
* Create a 3D grid to an OpenGL display list.
|
|
|
|
*
|
|
|
|
* A horizontal grid (XY plane and Z = 0, and a vertical grid (XZ plane and Y = 0).
|
|
|
|
*/
|
2021-01-05 22:19:00 +00:00
|
|
|
void generate3dGrid( GRID3D_TYPE aGridType );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Materials
|
|
|
|
void setupMaterials();
|
|
|
|
|
2020-09-06 19:09:43 +00:00
|
|
|
void setCopperMaterial();
|
|
|
|
void setPlatedCopperAndDepthOffset( PCB_LAYER_ID aLayer_id );
|
|
|
|
void unsetDepthOffset();
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void setLayerMaterial( PCB_LAYER_ID aLayerID );
|
|
|
|
SFVEC4F getLayerColor( PCB_LAYER_ID aLayerID );
|
2020-12-13 23:02:57 +00:00
|
|
|
|
|
|
|
bool initializeOpenGL();
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST* createBoard( const SHAPE_POLY_SET& aBoardPoly,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
|
2020-12-13 23:02:57 +00:00
|
|
|
void reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void setArrowMaterial();
|
2020-12-13 23:02:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void freeAllLists();
|
2020-12-13 23:02:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
SMATERIAL m_Paste;
|
2020-01-22 22:38:30 +00:00
|
|
|
SMATERIAL m_SilkSBot;
|
|
|
|
SMATERIAL m_SilkSTop;
|
2020-08-21 08:56:15 +00:00
|
|
|
SMATERIAL m_SolderMask;
|
2016-07-19 17:35:25 +00:00
|
|
|
SMATERIAL m_EpoxyBoard;
|
2020-09-06 19:09:43 +00:00
|
|
|
SMATERIAL m_NonPlatedCopper; // raw copper
|
2016-07-19 17:35:25 +00:00
|
|
|
SMATERIAL m_Copper;
|
|
|
|
SMATERIAL m_Plastic;
|
|
|
|
SMATERIAL m_GrayMaterial;
|
2020-12-13 23:02:57 +00:00
|
|
|
} m_materials;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
MAP_OGL_DISP_LISTS m_layers;
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* m_platedPadsFront;
|
|
|
|
OPENGL_RENDER_LIST* m_platedPadsBack;
|
|
|
|
MAP_OGL_DISP_LISTS m_outerLayerHoles;
|
|
|
|
MAP_OGL_DISP_LISTS m_innerLayerHoles;
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST* m_board;
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* m_boardWithHoles;
|
|
|
|
OPENGL_RENDER_LIST* m_antiBoard;
|
|
|
|
OPENGL_RENDER_LIST* m_outerThroughHoles;
|
|
|
|
OPENGL_RENDER_LIST* m_outerViaThroughHoles;
|
|
|
|
OPENGL_RENDER_LIST* m_outerThroughHoleRings;
|
2020-12-13 23:02:57 +00:00
|
|
|
|
|
|
|
LIST_TRIANGLES m_triangles; ///< store pointers so can be deleted latter
|
2021-01-05 22:19:00 +00:00
|
|
|
GLuint m_circleTexture;
|
2020-12-13 23:02:57 +00:00
|
|
|
|
|
|
|
GLuint m_grid; ///< oGL list that stores current grid
|
2021-01-05 22:19:00 +00:00
|
|
|
GRID3D_TYPE m_lastGridType; ///< Stores the last grid type.
|
2020-12-13 23:02:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST* m_vias;
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* m_padHoles;
|
2020-12-13 23:02:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
MAP_3DMODEL m_3dModelMap;
|
2020-12-13 23:02:57 +00:00
|
|
|
|
|
|
|
BOARD_ITEM* m_currentIntersectedBoardItem;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
SHAPE_POLY_SET m_antiBoardPolys; ///< The negative polygon representation of the board outline.
|
2015-12-08 07:31:57 +00:00
|
|
|
};
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
#endif // RENDER_3D_LEGACY_H_
|