2012-12-15 08:52:02 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file 3d_viewer.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _3D_CANVAS_H_
|
|
|
|
#define _3D_CANVAS_H_
|
|
|
|
|
|
|
|
#include <wx/glcanvas.h>
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
# ifdef __DARWIN__
|
|
|
|
# include <OpenGL/glu.h>
|
|
|
|
# else
|
|
|
|
# include <glu.h>
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <GL/glu.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <3d_struct.h>
|
|
|
|
|
|
|
|
class BOARD_DESIGN_SETTINGS;
|
|
|
|
class EDA_3D_FRAME;
|
|
|
|
class S3D_VERTEX;
|
2014-04-25 06:00:04 +00:00
|
|
|
class VIA;
|
2014-01-30 08:18:47 +00:00
|
|
|
class D_PAD;
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2014-03-08 19:04:23 +00:00
|
|
|
// We are using GL lists to store layers and other items
|
|
|
|
// to draw or not
|
|
|
|
// GL_LIST_ID are the GL lists indexes in m_glLists
|
|
|
|
enum GL_LIST_ID
|
|
|
|
{
|
|
|
|
GL_ID_BEGIN = 0,
|
|
|
|
GL_ID_AXIS = GL_ID_BEGIN, // list id for 3D axis
|
|
|
|
GL_ID_GRID, // list id for 3D grid
|
|
|
|
GL_ID_BOARD, // List id for copper layers
|
|
|
|
GL_ID_TECH_LAYERS, // List id for non copper layers (masks...)
|
|
|
|
GL_ID_AUX_LAYERS, // List id for user layers (draw, eco, comment)
|
|
|
|
GL_ID_3DSHAPES_SOLID, // List id for 3D shapes, non transparent entities
|
|
|
|
GL_ID_3DSHAPES_TRANSP, // List id for 3D shapes, transparent entities
|
|
|
|
GL_ID_END
|
|
|
|
};
|
2012-12-15 08:52:02 +00:00
|
|
|
|
|
|
|
class EDA_3D_CANVAS : public wxGLCanvas
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
bool m_init;
|
2014-03-08 19:04:23 +00:00
|
|
|
GLuint m_glLists[GL_ID_END]; // GL lists
|
2012-12-15 08:52:02 +00:00
|
|
|
wxGLContext* m_glRC;
|
2014-03-08 19:04:23 +00:00
|
|
|
wxRealPoint m_draw3dOffset; // offset to draw the 3D mesh.
|
2012-12-15 08:52:02 +00:00
|
|
|
double m_ZBottom; // position of the back layer
|
|
|
|
double m_ZTop; // position of the front layer
|
|
|
|
|
|
|
|
public:
|
|
|
|
EDA_3D_CANVAS( EDA_3D_FRAME* parent, int* attribList = 0 );
|
|
|
|
~EDA_3D_CANVAS();
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
EDA_3D_FRAME* Parent() const { return static_cast<EDA_3D_FRAME*>( GetParent() ); }
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2014-03-08 19:04:23 +00:00
|
|
|
BOARD* GetBoard() { return Parent()->GetBoard(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ClearLists
|
|
|
|
* Clear the display list.
|
|
|
|
* @param aGlList = the list to clear.
|
|
|
|
* if 0 (default) all lists are cleared
|
|
|
|
*/
|
|
|
|
void ClearLists( GLuint aGlList = 0 );
|
2012-12-15 08:52:02 +00:00
|
|
|
|
|
|
|
// Event functions:
|
|
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
void OnEraseBackground( wxEraseEvent& event );
|
|
|
|
void OnChar( wxKeyEvent& event );
|
|
|
|
void OnMouseWheel( wxMouseEvent& event );
|
|
|
|
void OnMouseMove( wxMouseEvent& event );
|
|
|
|
void OnRightClick( wxMouseEvent& event );
|
|
|
|
void OnPopUpMenu( wxCommandEvent& event );
|
|
|
|
void TakeScreenshot( wxCommandEvent& event );
|
|
|
|
void OnEnterWindow( wxMouseEvent& event );
|
|
|
|
|
|
|
|
// Display functions
|
|
|
|
void SetView3D( int keycode );
|
|
|
|
void DisplayStatus();
|
2014-03-05 17:40:23 +00:00
|
|
|
void Redraw();
|
2012-12-15 08:52:02 +00:00
|
|
|
void Render();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CreateDrawGL_List
|
2013-05-01 19:01:14 +00:00
|
|
|
* Prepares the parameters of the OpenGL draw list
|
|
|
|
* creates the OpenGL draw list items (board, grid ...
|
2012-12-15 08:52:02 +00:00
|
|
|
*/
|
2014-03-08 19:04:23 +00:00
|
|
|
void CreateDrawGL_List();
|
2012-12-15 08:52:02 +00:00
|
|
|
void InitGL();
|
|
|
|
void SetLights();
|
|
|
|
void SetOffset(double aPosX, double aPosY)
|
|
|
|
{
|
|
|
|
m_draw3dOffset.x = aPosX;
|
|
|
|
m_draw3dOffset.y = aPosY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-01 19:01:14 +00:00
|
|
|
* Function BuildBoard3DView
|
|
|
|
* Called by CreateDrawGL_List()
|
2014-03-08 19:04:23 +00:00
|
|
|
* Populates the OpenGL GL_ID_BOARD draw list with board items only on copper layers.
|
|
|
|
* 3D footprint shapes, tech layers and aux layers are not on this list
|
2012-12-15 08:52:02 +00:00
|
|
|
*/
|
2013-05-01 19:01:14 +00:00
|
|
|
void BuildBoard3DView();
|
2012-12-15 08:52:02 +00:00
|
|
|
|
2014-03-08 19:04:23 +00:00
|
|
|
/**
|
|
|
|
* Function BuildTechLayers3DView
|
|
|
|
* Called by CreateDrawGL_List()
|
|
|
|
* Populates the OpenGL GL_ID_BOARD draw list with items on tech layers
|
|
|
|
*/
|
|
|
|
void BuildTechLayers3DView();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function BuildFootprintShape3DList
|
|
|
|
* Called by CreateDrawGL_List()
|
|
|
|
* Fills the OpenGL GL_ID_3DSHAPES_SOLID and GL_ID_3DSHAPES_TRANSP
|
|
|
|
* draw lists with 3D footprint shapes
|
|
|
|
* @param aOpaqueList is the gl list for non transparent items
|
|
|
|
* @param aTransparentList is the gl list for non transparent items,
|
|
|
|
* which need to be drawn after all other items
|
|
|
|
*/
|
|
|
|
void BuildFootprintShape3DList( GLuint aOpaqueList,
|
|
|
|
GLuint aTransparentList);
|
|
|
|
/**
|
|
|
|
* Function BuildBoard3DAuxLayers
|
|
|
|
* Called by CreateDrawGL_List()
|
|
|
|
* Fills the OpenGL GL_ID_AUX_LAYERS draw list
|
|
|
|
* with items on aux layers only
|
|
|
|
*/
|
|
|
|
void BuildBoard3DAuxLayers();
|
|
|
|
|
|
|
|
void Draw3DGrid( double aGriSizeMM );
|
|
|
|
void Draw3DAxis();
|
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
void Draw3DViaHole( const VIA * aVia );
|
|
|
|
void Draw3DPadHole( const D_PAD * aPad );
|
2012-12-15 08:52:02 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _3D_CANVAS_H_ */
|