KiCad PCB EDA Suite
c3d_render_ogl_legacy.h
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-2016 Mario Luzeiro <mrluzeiro@ua.pt>
5  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
30 #ifndef C3D_RENDER_OGL_LEGACY_H_
31 #define C3D_RENDER_OGL_LEGACY_H_
32 
33 #include "../c3d_render_base.h"
34 #include "clayer_triangles.h"
35 
36 #include "../3d_render_raytracing/shapes2D/cpolygon2d.h"
37 #include "../3d_render_raytracing/shapes2D/ctriangle2d.h"
38 #include "../3d_render_raytracing/shapes2D/cpolygon4pts2d.h"
39 #include "../3d_render_raytracing/shapes2D/cfilledcircle2d.h"
40 #include "../3d_render_raytracing/shapes2D/cring2d.h"
41 #include "../3d_render_raytracing/shapes2D/croundsegment2d.h"
42 
43 #include "c_ogl_3dmodel.h"
44 
45 #include "3d_cache/3d_info.h"
46 
47 #include <map>
48 
49 
50 typedef std::map< PCB_LAYER_ID, CLAYERS_OGL_DISP_LISTS* > MAP_OGL_DISP_LISTS;
51 typedef std::map< PCB_LAYER_ID, CLAYER_TRIANGLES * > MAP_TRIANGLES;
52 typedef std::map< wxString, C_OGL_3DMODEL * > MAP_3DMODEL;
53 
54 #define SIZE_OF_CIRCLE_TEXTURE 1024
55 
60 {
61 public:
62  explicit C3D_RENDER_OGL_LEGACY( CINFO3D_VISU &aSettings );
63 
65 
66  // Imported from C3D_RENDER_BASE
67  void SetCurWindowSize( const wxSize &aSize ) override;
68  bool Redraw( bool aIsMoving, REPORTER *aStatusTextReporter ) override;
69 
70  int GetWaitForEditingTimeOut() override;
71 
72 private:
73  bool initializeOpenGL();
74  void reload( REPORTER *aStatusTextReporter );
75 
77 
85 
86  // User for body render
88 
90  //CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_inner; // Not in use
91 
92  // This is for pads holes of the modules
93  //CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_vias_and_pad_holes_inner_contourn_and_caps;
95 
97 
99 
101 
103 
106 
108 
109 private:
112 
114  const SHAPE_POLY_SET &aPoly,
115  float aZtop,
116  float aZbot,
117  bool aInvertFaces );
118 
120  const SFVEC2F &v0,
121  const SFVEC2F &v1,
122  const SFVEC2F &v2,
123  float top,
124  float bot );
125 
126  void add_object_to_triangle_layer( const CRING2D *aRing,
127  CLAYER_TRIANGLES *aDstLayer,
128  float aZtop,
129  float aZbot );
130 
131  void add_object_to_triangle_layer( const CPOLYGON4PTS2D *aPoly,
132  CLAYER_TRIANGLES *aDstLayer,
133  float aZtop,
134  float aZbot );
135 
136  void add_object_to_triangle_layer( const CFILLEDCIRCLE2D *aFilledCircle,
137  CLAYER_TRIANGLES *aDstLayer,
138  float aZtop,
139  float aZbot );
140 
141  void add_object_to_triangle_layer( const CTRIANGLE2D *aTri,
142  CLAYER_TRIANGLES *aDstLayer,
143  float aZtop,
144  float aZbot );
145 
147  CLAYER_TRIANGLES *aDstLayer,
148  float aZtop,
149  float aZbot );
150 
151  void render_solder_mask_layer( PCB_LAYER_ID aLayerID,
152  float aZPosition,
153  bool aIsRenderingOnPreviewMode );
154 
155  void get_layer_z_pos( PCB_LAYER_ID aLayerID,
156  float &aOutZtop,
157  float &aOutZbot ) const;
158 
159  void generate_ring_contour( const SFVEC2F &aCenter,
160  float aInnerRadius,
161  float aOuterRadius,
162  unsigned int aNr_sides_per_circle,
163  std::vector< SFVEC2F > &aInnerContourResult,
164  std::vector< SFVEC2F > &aOuterContourResult,
165  bool aInvertOrder );
166 
167  void generate_cylinder( const SFVEC2F &aCenter,
168  float aInnerRadius,
169  float aOuterRadius,
170  float aZtop,
171  float aZbot,
172  unsigned int aNr_sides_per_circle,
173  CLAYER_TRIANGLES *aDstLayer );
174 
176 
177  void load_3D_models();
178 
185  void render_3D_models( bool aRenderTopOrBot, bool aRenderTransparentOnly );
186 
187  void render_3D_module( const MODULE* module, bool aRenderTransparentOnly );
188 
189  void setLight_Front( bool enabled );
190  void setLight_Top( bool enabled );
191  void setLight_Bottom( bool enabled );
192 
193  void render_3D_arrows();
194 
195  void generate_new_3DGrid( GRID3D_TYPE aGridType );
196 
197  // Materials
198  void setupMaterials();
199 
200  struct
201  {
209  }m_materials;
210 
211  void set_layer_material( PCB_LAYER_ID aLayerID );
213 
214 public:
216  const CLAYERS_OGL_DISP_LISTS *GetLayerDispList( PCB_LAYER_ID aLayerId ) const { return m_ogl_disp_lists_layers.at( aLayerId ); }
218 };
219 
220 #endif // C3D_RENDER_OGL_LEGACY_H_
221 
void generate_ring_contour(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, bool aInvertOrder)
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers
void generate_new_3DGrid(GRID3D_TYPE aGridType)
void add_object_to_triangle_layer(const CRING2D *aRing, CLAYER_TRIANGLES *aDstLayer, float aZtop, float aZbot)
implement a legacy 3dmodel render
The CLAYER_TRIANGLES class stores arrays of triangles to be used to create display lists...
struct C3D_RENDER_OGL_LEGACY::@29 m_materials
void generate_through_inner_holes()
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer
void render_3D_models(bool aRenderTopOrBot, bool aRenderTransparentOnly)
render_3D_models
const CLAYERS_OGL_DISP_LISTS * GetLayerDispList(PCB_LAYER_ID aLayerId) const
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
defines the basic data associated with a single 3D model.
void setLight_Top(bool enabled)
GRID3D_TYPE m_last_grid_type
Stores the last grid computed.
int GetWaitForEditingTimeOut() override
GetWaitForEditingTimeOut - Give the interface the time (in ms) that it should wait for editing or mov...
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_inner
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer
PCB_LAYER_ID
A quick note on layer IDs:
void setLight_Front(bool enabled)
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
void generate_through_outer_holes()
void render_3D_module(const MODULE *module, bool aRenderTransparentOnly)
void setLight_Bottom(bool enabled)
Class SHAPE_POLY_SET.
C3D_RENDER_OGL_LEGACY(CINFO3D_VISU &aSettings)
Class CINFO3D_VISU Helper class to handle information needed to display 3D board. ...
Definition: cinfo3d_visu.h:70
void SetCurWindowSize(const wxSize &aSize) override
SetCurWindowSize - Before each render, the canvas will tell the render what is the size of its window...
void render_solder_mask_layer(PCB_LAYER_ID aLayerID, float aZPosition, bool aIsRenderingOnPreviewMode)
std::map< PCB_LAYER_ID, CLAYER_TRIANGLES * > MAP_TRIANGLES
void reload(REPORTER *aStatusTextReporter)
bool Redraw(bool aIsMoving, REPORTER *aStatusTextReporter) override
Redraw - Ask to redraw the view.
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_vias_outer
void get_layer_z_pos(PCB_LAYER_ID aLayerID, float &aOutZtop, float &aOutZbot) const
GRID3D_TYPE
Grid types.
Definition: 3d_enums.h:72
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_via
GLuint m_ogl_disp_list_grid
oGL list that stores current grid
std::map< PCB_LAYER_ID, CLAYERS_OGL_DISP_LISTS * > MAP_OGL_DISP_LISTS
const MAP_OGL_DISP_LISTS & GetLayerDispListMap() const
MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner
The CLAYERS_OGL_DISP_LISTS class stores the openGL display lists to related with a layer...
std::map< wxString, C_OGL_3DMODEL * > MAP_3DMODEL
The C3D_RENDER_OGL_LEGACY class render the board using openGL legacy mode.
CLAYERS_OGL_DISP_LISTS * generate_holes_display_list(const LIST_OBJECT2D &aListHolesObject2d, const SHAPE_POLY_SET &aPoly, float aZtop, float aZbot, bool aInvertFaces)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_through_holes_outer_with_npth
This handles simple polygons with 4 points.
std::list< COBJECT2D * > LIST_OBJECT2D
Definition: ccontainer2d.h:36
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
const CLAYERS_OGL_DISP_LISTS * GetBoardDispList() const
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_board
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps
void set_layer_material(PCB_LAYER_ID aLayerID)
void add_triangle_top_bot(CLAYER_TRIANGLES *aDst, const SFVEC2F &v0, const SFVEC2F &v1, const SFVEC2F &v2, float top, float bot)
CLAYERS_OGL_DISP_LISTS * m_ogl_disp_list_pads_holes
SFVEC3F get_layer_color(PCB_LAYER_ID aLayerID)
void generate_cylinder(const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, float aZtop, float aZbot, unsigned int aNr_sides_per_circle, CLAYER_TRIANGLES *aDstLayer)
This is a base class to hold data and functions for render targets.