2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: 3d_viewer.h
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2009-05-06 11:55:36 +00:00
|
|
|
|
|
|
|
#ifndef __3D_VIEWER_H__
|
|
|
|
#define __3D_VIEWER_H__
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#if !wxUSE_GLCANVAS
|
|
|
|
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/glcanvas.h"
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
# ifdef __DARWIN__
|
|
|
|
# include <OpenGL/glu.h>
|
|
|
|
# else
|
|
|
|
# include <glu.h>
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <GL/glu.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "pcbstruct.h"
|
|
|
|
#include "3d_struct.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "id.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
#define KICAD_DEFAULT_3D_DRAWFRAME_STYLE wxDEFAULT_FRAME_STYLE | wxWANTS_CHARS
|
2008-10-26 17:39:17 +00:00
|
|
|
|
2007-10-27 12:24:09 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
#define LIB3D_PATH wxT( "packages3d" )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-22 12:27:57 +00:00
|
|
|
/**
|
|
|
|
* Command IDs for the 3D viewer.
|
|
|
|
*
|
|
|
|
* Please add IDs that are unique to the 3D viewer here and not in the global
|
|
|
|
* id.h file. This will prevent the entire project from being rebuilt when
|
|
|
|
* adding new commands to the 3D viewer.
|
|
|
|
*/
|
|
|
|
enum id_3dview_frm
|
|
|
|
{
|
|
|
|
ID_START_COMMAND_3D = ID_END_LIST,
|
|
|
|
ID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D_UP,
|
|
|
|
ID_POPUP_MOVE3D_DOWN,
|
|
|
|
ID_POPUP_3D_VIEW_END
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
class Pcb3D_GLCanvas;
|
|
|
|
class WinEDA3D_DrawFrame;
|
|
|
|
class Info_3D_Visu;
|
|
|
|
class S3D_Vertex;
|
|
|
|
class SEGVIA;
|
|
|
|
|
|
|
|
|
|
|
|
#define m_ROTX m_Rot[0]
|
|
|
|
#define m_ROTY m_Rot[1]
|
|
|
|
#define m_ROTZ m_Rot[2]
|
|
|
|
|
|
|
|
/* information needed to display 3D board */
|
|
|
|
class Info_3D_Visu
|
|
|
|
{
|
|
|
|
public:
|
2009-11-04 20:46:53 +00:00
|
|
|
double m_Beginx, m_Beginy; /* position of mouse */
|
|
|
|
double m_Quat[4]; /* orientation of object */
|
|
|
|
double m_Rot[4]; /* man rotation of object */
|
|
|
|
double m_Zoom; /* field of view in degrees */
|
2009-04-05 20:49:15 +00:00
|
|
|
S3D_Color m_BgColor;
|
2009-11-04 20:46:53 +00:00
|
|
|
bool m_Draw3DAxis;
|
|
|
|
bool m_Draw3DModule;
|
|
|
|
bool m_Draw3DZone;
|
|
|
|
bool m_Draw3DComments;
|
|
|
|
bool m_Draw3DDrawings;
|
|
|
|
bool m_Draw3DEco1;
|
|
|
|
bool m_Draw3DEco2;
|
|
|
|
wxPoint m_BoardPos;
|
|
|
|
wxSize m_BoardSize;
|
|
|
|
int m_Layers;
|
2010-01-31 20:01:46 +00:00
|
|
|
BOARD_DESIGN_SETTINGS* m_BoardSettings; // Link to current board design
|
2009-11-04 20:46:53 +00:00
|
|
|
// settings
|
|
|
|
double m_Epoxy_Width; /* Epoxy thickness (normalized)
|
|
|
|
**/
|
|
|
|
|
|
|
|
double m_BoardScale; /* Normalization scale for coordinates:
|
|
|
|
* when scaled between -1.0 and +1.0 */
|
|
|
|
double m_LayerZcoord[32];
|
2009-11-16 13:18:20 +00:00
|
|
|
double m_ActZpos;
|
2009-11-04 20:46:53 +00:00
|
|
|
public: Info_3D_Visu();
|
2009-04-05 20:49:15 +00:00
|
|
|
~Info_3D_Visu();
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
class Pcb3D_GLCanvas : public wxGLCanvas
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA3D_DrawFrame* m_Parent;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
private:
|
2009-11-04 20:46:53 +00:00
|
|
|
bool m_init;
|
|
|
|
GLuint m_gllist;
|
2009-07-20 13:44:41 +00:00
|
|
|
#if wxCHECK_VERSION( 2, 9, 0 )
|
2009-07-13 15:25:41 +00:00
|
|
|
wxGLContext* m_glRC;
|
2009-07-20 13:44:41 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
public:
|
2009-11-04 20:46:53 +00:00
|
|
|
Pcb3D_GLCanvas( WinEDA3D_DrawFrame* parent );
|
2009-04-05 20:49:15 +00:00
|
|
|
~Pcb3D_GLCanvas();
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void ClearLists();
|
|
|
|
|
|
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
void OnEraseBackground( wxEraseEvent& event );
|
|
|
|
void OnChar( wxKeyEvent& event );
|
2010-01-11 14:44:49 +00:00
|
|
|
void OnMouseWheel( wxMouseEvent& event );
|
|
|
|
void OnMouseMove( wxMouseEvent& event );
|
2009-11-04 20:46:53 +00:00
|
|
|
void OnRightClick( wxMouseEvent& event );
|
|
|
|
void OnPopUpMenu( wxCommandEvent& event );
|
|
|
|
void TakeScreenshot( wxCommandEvent& event );
|
|
|
|
void SetView3D( int keycode );
|
|
|
|
void DisplayStatus();
|
|
|
|
void Redraw( bool finish = false );
|
2009-04-05 20:49:15 +00:00
|
|
|
GLuint DisplayCubeforTest();
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void OnEnterWindow( wxMouseEvent& event );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void Render();
|
2009-04-05 20:49:15 +00:00
|
|
|
GLuint CreateDrawGL_List();
|
2009-11-04 20:46:53 +00:00
|
|
|
void InitGL();
|
|
|
|
void SetLights();
|
|
|
|
void Draw3D_Track( TRACK* track );
|
2009-11-16 13:18:20 +00:00
|
|
|
/** Function Draw3D_SolidPolygonsInZones
|
|
|
|
* draw all solid polygons used as filles areas in a zone
|
|
|
|
* @param aZone_c = the zone to draw
|
|
|
|
*/
|
|
|
|
void Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone_c );
|
2009-11-04 20:46:53 +00:00
|
|
|
void Draw3D_Via( SEGVIA* via );
|
|
|
|
void Draw3D_DrawSegment( DRAWSEGMENT* segment );
|
|
|
|
void Draw3D_DrawText( TEXTE_PCB* text );
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
//int Get3DLayerEnable(int act_layer);
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
class WinEDA3D_DrawFrame : public wxFrame
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA_BasePcbFrame* m_Parent;
|
|
|
|
Pcb3D_GLCanvas* m_Canvas;
|
|
|
|
WinEDA_Toolbar* m_HToolBar;
|
|
|
|
WinEDA_Toolbar* m_VToolBar;
|
|
|
|
int m_InternalUnits;
|
|
|
|
wxPoint m_FramePos;
|
|
|
|
wxSize m_FrameSize;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxAuiManager m_auimgr;
|
|
|
|
~WinEDA3D_DrawFrame() { m_auimgr.UnInit(); };
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
private:
|
2009-11-04 20:46:53 +00:00
|
|
|
wxString m_FrameName; // name used for writing and reading setup
|
2009-04-05 20:49:15 +00:00
|
|
|
// It is "Frame3D"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
public:
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA3D_DrawFrame( WinEDA_BasePcbFrame* parent, const wxString& title,
|
2009-04-05 20:49:15 +00:00
|
|
|
long style = KICAD_DEFAULT_3D_DRAWFRAME_STYLE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void Exit3DFrame( wxCommandEvent& event );
|
|
|
|
void OnCloseWindow( wxCloseEvent& Event );
|
2009-04-05 20:49:15 +00:00
|
|
|
void ReCreateMenuBar();
|
|
|
|
void ReCreateHToolbar();
|
|
|
|
void ReCreateVToolbar();
|
|
|
|
void SetToolbars();
|
|
|
|
void GetSettings();
|
|
|
|
void SaveSettings();
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
|
|
|
|
void OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
|
|
|
|
void OnKeyEvent( wxKeyEvent& event );
|
|
|
|
int BestZoom();
|
|
|
|
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
|
|
|
void Process_Special_Functions( wxCommandEvent& event );
|
|
|
|
void Process_Zoom( wxCommandEvent& event );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
void NewDisplay();
|
|
|
|
void Set3DBgColor();
|
|
|
|
void Set3DAxisOnOff();
|
|
|
|
void Set3DModuleOnOff();
|
|
|
|
void Set3DPlaceOnOff();
|
|
|
|
void Set3DZoneOnOff();
|
|
|
|
void Set3DCommentsOnOff();
|
|
|
|
void Set3DDrawingsOnOff();
|
|
|
|
void Set3DEco1OnOff();
|
|
|
|
void Set3DEco2OnOff();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
void SetGLColor( int color );
|
|
|
|
void Set_Object_Data( const S3D_Vertex* coord, int nbcoord );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
extern Info_3D_Visu g_Parm_3D_Visu;
|
2009-11-04 20:46:53 +00:00
|
|
|
extern double g_Draw3d_dx, g_Draw3d_dy;
|
|
|
|
extern double ZBottom, ZTop;
|
|
|
|
extern double DataScale3D; // 3D scale units.
|
|
|
|
extern int gl_attrib[];
|
2009-05-06 11:55:36 +00:00
|
|
|
|
|
|
|
#endif /* __3D_VIEWER_H__ */
|