2011-11-10 15:55:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
* Copyright (C) 1992-2011 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
|
|
|
|
*/
|
|
|
|
|
2011-05-22 19:08:34 +00:00
|
|
|
/**
|
|
|
|
* @file 3d_draw.cpp
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <trigo.h>
|
|
|
|
#include <pcbstruct.h>
|
|
|
|
#include <drawtxt.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_zone.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_pcb_text.h>
|
|
|
|
#include <class_board_design_settings.h>
|
|
|
|
#include <class_marker_pcb.h>
|
|
|
|
#include <colors_selection.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <3d_viewer.h>
|
|
|
|
#include <trackball.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
#if !wxUSE_GLCANVAS
|
|
|
|
#error Please set wxUSE_GLCANVAS to 1 in setup.h.
|
|
|
|
#endif
|
|
|
|
|
2010-10-29 07:40:02 +00:00
|
|
|
extern void CheckGLError();
|
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
static void Draw3D_FilledCircle( double posx, double posy, double rayon,
|
|
|
|
double hole_rayon, double zpos );
|
|
|
|
static void Draw3D_FilledSegment( double startx, double starty,
|
|
|
|
double endx, double endy,
|
|
|
|
double width, double zpos );
|
|
|
|
static void Draw3D_FilledCylinder( double posx, double posy, double rayon,
|
|
|
|
double height, double zpos );
|
|
|
|
static void Draw3D_FilledSegmentWithHole( double startx, double starty,
|
|
|
|
double endx, double endy,
|
|
|
|
double width, double holex,
|
|
|
|
double holey, double holeradius,
|
|
|
|
double zpos );
|
2010-06-06 16:48:23 +00:00
|
|
|
static void Draw3D_ArcSegment( double startx, double starty, double centrex,
|
|
|
|
double centrey, double arc_angle, double width, double zpos );
|
2009-11-16 13:18:20 +00:00
|
|
|
static void Draw3D_CircleSegment( double startx, double starty, double endx,
|
|
|
|
double endy, double width, double zpos );
|
2008-08-17 18:37:03 +00:00
|
|
|
static int Get3DLayerEnable( int act_layer );
|
|
|
|
static GLfloat Get3DLayerSide( int act_layer );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
#ifndef CALLBACK
|
|
|
|
#define CALLBACK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// CALLBACK functions for GLU_TESS
|
2010-08-19 14:21:05 +00:00
|
|
|
static void CALLBACK tessBeginCB( GLenum which );
|
|
|
|
static void CALLBACK tessEndCB();
|
|
|
|
static void CALLBACK tessErrorCB( GLenum errorCode );
|
|
|
|
static void CALLBACK tessCPolyPt2Vertex( const GLvoid* data );
|
|
|
|
static void CALLBACK tesswxPoint2Vertex( const GLvoid* data );
|
2009-11-16 13:18:20 +00:00
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Redraw( bool finish )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-02 17:45:37 +00:00
|
|
|
// SwapBuffer requires the window to be shown before calling
|
2011-01-29 10:19:54 +00:00
|
|
|
if( !IsShown() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
#if wxCHECK_VERSION( 2, 7, 0 )
|
2009-11-04 20:46:53 +00:00
|
|
|
SetCurrent( *m_glRC );
|
2009-07-20 13:44:41 +00:00
|
|
|
#else
|
2009-11-04 20:46:53 +00:00
|
|
|
SetCurrent();
|
2009-07-20 13:44:41 +00:00
|
|
|
#endif
|
2009-08-04 18:21:32 +00:00
|
|
|
|
|
|
|
// Set the OpenGL viewport according to the client size of this canvas.
|
|
|
|
// This is done here rather than in a wxSizeEvent handler because our
|
|
|
|
// OpenGL rendering context (and thus viewport setting) is used with
|
|
|
|
// multiple canvases: If we updated the viewport in the wxSizeEvent
|
|
|
|
// handler, changing the size of one canvas causes a viewport setting that
|
|
|
|
// is wrong when next another canvas is repainted.
|
|
|
|
const wxSize ClientSize = GetClientSize();
|
2009-08-20 11:44:06 +00:00
|
|
|
|
|
|
|
// *MUST* be called *after* SetCurrent( ):
|
2009-08-04 18:21:32 +00:00
|
|
|
glViewport( 0, 0, ClientSize.x, ClientSize.y );
|
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
InitGL();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
glMatrixMode( GL_MODELVIEW ); // position viewer
|
|
|
|
// transformations
|
2007-05-06 16:03:28 +00:00
|
|
|
GLfloat mat[4][4];
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Translate motion first, so rotations don't mess up the orientation...
|
2012-02-25 19:55:40 +00:00
|
|
|
glTranslatef( m_draw3dOffset.x, m_draw3dOffset.y, 0.0F );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
build_rotmatrix( mat, g_Parm_3D_Visu.m_Quat );
|
|
|
|
glMultMatrixf( &mat[0][0] );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
glRotatef( g_Parm_3D_Visu.m_Rot[0], 1.0, 0.0, 0.0 );
|
|
|
|
glRotatef( g_Parm_3D_Visu.m_Rot[1], 0.0, 1.0, 0.0 );
|
|
|
|
glRotatef( g_Parm_3D_Visu.m_Rot[2], 0.0, 0.0, 1.0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( m_gllist )
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
glCallList( m_gllist );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
else
|
|
|
|
{
|
2008-07-21 13:44:01 +00:00
|
|
|
CreateDrawGL_List();
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
glFlush();
|
2011-01-29 10:19:54 +00:00
|
|
|
if( finish );
|
2008-03-03 08:00:26 +00:00
|
|
|
glFinish();
|
2011-01-29 10:19:54 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
SwapBuffers();
|
2007-11-01 05:27:31 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
GLuint EDA_3D_CANVAS::CreateDrawGL_List()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-02-25 19:55:40 +00:00
|
|
|
PCB_BASE_FRAME* pcbframe = Parent()->Parent();
|
2009-01-05 05:21:35 +00:00
|
|
|
BOARD* pcb = pcbframe->GetBoard();
|
2008-12-16 19:44:57 +00:00
|
|
|
TRACK* track;
|
2009-11-16 13:18:20 +00:00
|
|
|
SEGZONE* segzone;
|
2008-12-16 19:44:57 +00:00
|
|
|
int ii;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
wxBusyCursor dummy;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2008-07-21 13:44:01 +00:00
|
|
|
m_gllist = glGenLists( 1 );
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
EDA_RECT bbbox = pcbframe->GetBoardBoundingBox();
|
|
|
|
|
|
|
|
g_Parm_3D_Visu.m_BoardSettings = &pcb->GetDesignSettings();
|
|
|
|
|
|
|
|
g_Parm_3D_Visu.m_BoardSize = bbbox.GetSize();
|
|
|
|
g_Parm_3D_Visu.m_BoardPos = bbbox.Centre();
|
|
|
|
|
|
|
|
g_Parm_3D_Visu.m_BoardPos.y = -g_Parm_3D_Visu.m_BoardPos.y;
|
|
|
|
g_Parm_3D_Visu.m_Layers = pcb->GetCopperLayerCount();
|
2009-05-28 08:42:24 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Ensure the board has 2 sides for 3D views, because it is hard to find
|
|
|
|
// a *really* single side board in the true life...
|
|
|
|
if( g_Parm_3D_Visu.m_Layers < 2 )
|
2009-03-03 19:42:49 +00:00
|
|
|
g_Parm_3D_Visu.m_Layers = 2;
|
|
|
|
|
2012-01-10 20:12:46 +00:00
|
|
|
g_Parm_3D_Visu.m_BoardScale = 2.0 / max( g_Parm_3D_Visu.m_BoardSize.x,
|
2009-02-02 12:12:18 +00:00
|
|
|
g_Parm_3D_Visu.m_BoardSize.y );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-03-03 19:42:49 +00:00
|
|
|
// @TODO: epoxy_width (board thickness) must be set by user,
|
|
|
|
// because all boards thickness no not match with this setup:
|
2009-11-04 20:46:53 +00:00
|
|
|
// double epoxy_width = 1.6; // epoxy width in mm
|
2009-06-19 20:13:22 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
g_Parm_3D_Visu.m_Epoxy_Width = pcb->GetDesignSettings().m_BoardThickness
|
2008-03-03 08:00:26 +00:00
|
|
|
* g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// calculate z position for each layer
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii < 32; ii++ )
|
|
|
|
{
|
|
|
|
if( ii < g_Parm_3D_Visu.m_Layers )
|
2011-09-07 19:41:04 +00:00
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width
|
|
|
|
* ii / (g_Parm_3D_Visu.m_Layers - 1);
|
2008-03-03 08:00:26 +00:00
|
|
|
else
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[ii] = g_Parm_3D_Visu.m_Epoxy_Width;
|
|
|
|
}
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
GLfloat zpos_cu = 10 * g_Parm_3D_Visu.m_BoardScale;
|
2008-03-03 08:00:26 +00:00
|
|
|
GLfloat zpos_cmp = g_Parm_3D_Visu.m_Epoxy_Width + zpos_cu;
|
2009-12-21 17:56:25 +00:00
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_BACK] = -zpos_cu * 2;
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[ADHESIVE_N_FRONT] = zpos_cmp + zpos_cu;
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_BACK] = -zpos_cu;
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[SILKSCREEN_N_FRONT] = zpos_cmp;
|
2008-03-03 08:00:26 +00:00
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[DRAW_N] = zpos_cmp + zpos_cu;
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[COMMENT_N] = zpos_cmp + zpos_cu;
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[ECO1_N] = zpos_cmp + zpos_cu;
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[ECO2_N] = zpos_cmp + zpos_cu;
|
|
|
|
|
2008-07-21 13:44:01 +00:00
|
|
|
glNewList( m_gllist, GL_COMPILE_AND_EXECUTE );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// draw axis
|
2008-08-17 18:37:03 +00:00
|
|
|
if( g_Parm_3D_Visu.m_Draw3DAxis )
|
|
|
|
{
|
|
|
|
glEnable( GL_COLOR_MATERIAL );
|
|
|
|
SetGLColor( WHITE );
|
|
|
|
glBegin( GL_LINES );
|
2009-11-04 20:46:53 +00:00
|
|
|
glNormal3f( 0.0f, 0.0f, 1.0f ); // Normal is Z axis
|
2009-05-21 17:42:42 +00:00
|
|
|
glVertex3f( 0.0f, 0.0f, 0.0f );
|
2009-11-04 20:46:53 +00:00
|
|
|
glVertex3f( 1.0f, 0.0f, 0.0f ); // X axis
|
2009-05-21 17:42:42 +00:00
|
|
|
glVertex3f( 0.0f, 0.0f, 0.0f );
|
2009-11-04 20:46:53 +00:00
|
|
|
glVertex3f( 0.0f, -1.0f, 0.0f ); // Y axis
|
|
|
|
glNormal3f( 1.0f, 0.0f, 0.0f ); // Normal is Y axis
|
2009-05-21 17:42:42 +00:00
|
|
|
glVertex3f( 0.0f, 0.0f, 0.0f );
|
2009-11-04 20:46:53 +00:00
|
|
|
glVertex3f( 0.0f, 0.0f, 0.3f ); // Z axis
|
2008-08-17 18:37:03 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Draw epoxy limits (do not use, works and test in progress)
|
2007-05-06 16:03:28 +00:00
|
|
|
#if 0
|
2008-03-03 08:00:26 +00:00
|
|
|
glEnable( GL_FOG );
|
|
|
|
GLfloat param;
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
// param = GL_LINEAR;
|
|
|
|
// glFogfv(GL_FOG_MODE, & param);
|
2008-03-03 08:00:26 +00:00
|
|
|
param = 0.2;
|
|
|
|
glFogfv( GL_FOG_DENSITY, ¶m );
|
|
|
|
param = g_Parm_3D_Visu.m_LayerZcoord[15];
|
|
|
|
glFogfv( GL_FOG_END, ¶m );
|
|
|
|
glBegin( GL_QUADS );
|
2009-12-07 03:46:13 +00:00
|
|
|
SetGLColor( g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[LAYER_N_FRONT] );
|
2008-03-03 08:00:26 +00:00
|
|
|
double sx = DataScale3D * g_Parm_3D_Visu.m_BoardSize.x / 2;
|
|
|
|
double sy = DataScale3D * g_Parm_3D_Visu.m_BoardSize.y / 2;
|
|
|
|
double zpos = g_Parm_3D_Visu.m_LayerZcoord[15];
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
|
|
|
sx = sy = 0.5;
|
|
|
|
glVertex3f( -sx, -sy, zpos );
|
|
|
|
glVertex3f( -sx, sy, zpos );
|
|
|
|
glVertex3f( sx, sy, zpos );
|
|
|
|
glVertex3f( sx, -sy, zpos );
|
|
|
|
glEnd();
|
|
|
|
glBegin( GL_QUADS );
|
2009-12-07 03:46:13 +00:00
|
|
|
SetGLColor( g_Parm_3D_Visu.m_BoardSettings->m_LayerColor[LAYER_N_BACK] );
|
2008-03-03 08:00:26 +00:00
|
|
|
glNormal3f( 0.0, 0.0, -1.0 ); // Normal is -Z axis
|
|
|
|
glVertex3f( -sx, -sy, 0 );
|
|
|
|
glVertex3f( -sx, sy, 0 );
|
|
|
|
glVertex3f( sx, sy, 0 );
|
|
|
|
glVertex3f( sx, -sy, 0 );
|
|
|
|
glEnd();
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// move the board in order to draw it with its center at 0,0 3D coordinates
|
2008-03-03 08:00:26 +00:00
|
|
|
glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BoardScale,
|
2009-02-02 12:12:18 +00:00
|
|
|
-g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BoardScale,
|
|
|
|
0.0F );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
2011-10-01 19:24:27 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// draw tracks and vias :
|
2008-08-17 18:37:03 +00:00
|
|
|
for( track = pcb->m_Track; track != NULL; track = track->Next() )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( track->Type() == PCB_VIA_T )
|
2008-08-17 18:37:03 +00:00
|
|
|
Draw3D_Via( (SEGVIA*) track );
|
2008-03-03 08:00:26 +00:00
|
|
|
else
|
2008-08-17 18:37:03 +00:00
|
|
|
Draw3D_Track( track );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
if( g_Parm_3D_Visu.m_Draw3DZone )
|
|
|
|
{
|
2009-11-16 13:18:20 +00:00
|
|
|
// Draw segments used to fill copper areas. outdated!
|
2008-08-17 18:37:03 +00:00
|
|
|
for( segzone = pcb->m_Zone; segzone != NULL; segzone = segzone->Next() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
if( segzone->Type() == PCB_ZONE_T )
|
2008-08-17 18:37:03 +00:00
|
|
|
Draw3D_Track( segzone );
|
|
|
|
}
|
2009-02-02 12:12:18 +00:00
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
// Draw new segments
|
|
|
|
for( ii = 0; ii < pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* curr_zone = pcb->GetArea( ii );
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
if( curr_zone->m_FillMode == 0 )
|
2010-08-19 14:21:05 +00:00
|
|
|
{
|
|
|
|
// solid polygons only are used to fill areas
|
2009-11-16 13:18:20 +00:00
|
|
|
if( curr_zone->m_FilledPolysList.size() > 3 )
|
|
|
|
{
|
|
|
|
Draw3D_SolidPolygonsInZones( curr_zone );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-19 14:21:05 +00:00
|
|
|
// segments are used to fill areas
|
2009-11-16 13:18:20 +00:00
|
|
|
for( unsigned iseg = 0; iseg < curr_zone->m_FillSegmList.size(); iseg++ )
|
|
|
|
{
|
|
|
|
SEGZONE dummysegment( pcb );
|
|
|
|
dummysegment.SetLayer( curr_zone->GetLayer() );
|
|
|
|
dummysegment.m_Width = curr_zone->m_ZoneMinThickness;
|
|
|
|
|
|
|
|
dummysegment.m_Start.x = curr_zone->m_FillSegmList[iseg].m_Start.x;
|
|
|
|
dummysegment.m_Start.y = curr_zone->m_FillSegmList[iseg].m_Start.y;
|
|
|
|
dummysegment.m_End.x = curr_zone->m_FillSegmList[iseg].m_End.x;
|
|
|
|
dummysegment.m_End.y = curr_zone->m_FillSegmList[iseg].m_End.y;
|
|
|
|
Draw3D_Track( &dummysegment );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
// Draw copper areas outlines
|
|
|
|
for( ii = 0; ii < pcb->GetAreaCount(); ii++ )
|
|
|
|
{
|
|
|
|
ZONE_CONTAINER* zone = pcb->GetArea( ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
if( zone->m_FilledPolysList.size() == 0 )
|
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
if( zone->m_ZoneMinThickness <= 1 )
|
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
int imax = zone->m_FilledPolysList.size() - 1;
|
|
|
|
CPolyPt* firstcorner = &zone->m_FilledPolysList[0];
|
|
|
|
CPolyPt* begincorner = firstcorner;
|
2009-11-04 20:46:53 +00:00
|
|
|
SEGZONE dummysegment( pcb );
|
2009-02-02 12:12:18 +00:00
|
|
|
dummysegment.SetLayer( zone->GetLayer() );
|
2009-11-04 20:46:53 +00:00
|
|
|
dummysegment.m_Width = zone->m_ZoneMinThickness;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
for( int ic = 1; ic <= imax; ic++ )
|
|
|
|
{
|
|
|
|
CPolyPt* endcorner = &zone->m_FilledPolysList[ic];
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( begincorner->utility == 0 )
|
2009-02-02 12:12:18 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
// Draw only basic outlines, not extra segments
|
2009-02-02 12:12:18 +00:00
|
|
|
dummysegment.m_Start.x = begincorner->x;
|
|
|
|
dummysegment.m_Start.y = begincorner->y;
|
|
|
|
dummysegment.m_End.x = endcorner->x;
|
|
|
|
dummysegment.m_End.y = endcorner->y;
|
|
|
|
Draw3D_Track( &dummysegment );
|
|
|
|
}
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( (endcorner->end_contour) || (ic == imax) )
|
2009-02-02 12:12:18 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
// the last corner of a filled area is found: draw it
|
|
|
|
if( endcorner->utility == 0 )
|
2009-02-02 12:12:18 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
// Draw only basic outlines, not extra segments
|
2009-02-02 12:12:18 +00:00
|
|
|
dummysegment.m_Start.x = endcorner->x;
|
|
|
|
dummysegment.m_Start.y = endcorner->y;
|
|
|
|
dummysegment.m_End.x = firstcorner->x;
|
|
|
|
dummysegment.m_End.y = firstcorner->y;
|
|
|
|
|
|
|
|
Draw3D_Track( &dummysegment );
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
ic++;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-02-02 12:12:18 +00:00
|
|
|
if( ic < imax - 1 )
|
2011-09-07 19:41:04 +00:00
|
|
|
begincorner = firstcorner = &zone->m_FilledPolysList[ic];
|
2009-02-02 12:12:18 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2009-02-02 12:12:18 +00:00
|
|
|
begincorner = endcorner;
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2009-02-02 12:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// draw graphic items
|
2010-12-08 20:12:46 +00:00
|
|
|
EDA_ITEM* PtStruct;
|
|
|
|
|
|
|
|
for( PtStruct = pcb->m_Drawings; PtStruct != NULL; PtStruct = PtStruct->Next() )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2008-08-17 18:37:03 +00:00
|
|
|
switch( PtStruct->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2008-08-17 18:37:03 +00:00
|
|
|
Draw3D_DrawSegment( (DRAWSEGMENT*) PtStruct );
|
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2008-08-17 18:37:03 +00:00
|
|
|
Draw3D_DrawText( (TEXTE_PCB*) PtStruct );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// draw footprints
|
2008-12-16 19:44:57 +00:00
|
|
|
MODULE* Module = pcb->m_Modules;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
for( ; Module != NULL; Module = Module->Next() )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
Module->Draw3D( this );
|
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
glEndList();
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Test for errors
|
2010-10-29 07:40:02 +00:00
|
|
|
CheckGLError();
|
|
|
|
|
2008-07-21 13:44:01 +00:00
|
|
|
return m_gllist;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_Track( TRACK* track )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
double zpos;
|
|
|
|
int layer = track->GetLayer();
|
|
|
|
double ox, oy, fx, fy;
|
|
|
|
double w;
|
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
2008-03-03 08:00:26 +00:00
|
|
|
return;
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( layer == LAST_COPPER_LAYER )
|
|
|
|
layer = g_Parm_3D_Visu.m_Layers - 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
|
|
|
|
|
|
|
SetGLColor( color );
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
w = track->m_Width * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
ox = track->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
oy = track->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
fx = track->m_End.x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
fy = track->m_End.y * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
Draw3D_FilledSegment( ox, -oy, fx, -fy, w, zpos );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone )
|
2009-11-16 13:18:20 +00:00
|
|
|
{
|
|
|
|
double zpos;
|
2010-12-29 17:47:32 +00:00
|
|
|
int layer = aZone->GetLayer();
|
2009-11-16 13:18:20 +00:00
|
|
|
|
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
|
|
|
return;
|
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2009-11-16 13:18:20 +00:00
|
|
|
|
|
|
|
if( layer == LAST_COPPER_LAYER )
|
|
|
|
layer = g_Parm_3D_Visu.m_Layers - 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
|
|
|
g_Parm_3D_Visu.m_ActZpos = zpos;
|
|
|
|
|
|
|
|
|
|
|
|
SetGLColor( color );
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2009-11-16 13:18:20 +00:00
|
|
|
|
|
|
|
GLUtesselator* tess = gluNewTess();
|
|
|
|
gluTessCallback( tess, GLU_TESS_BEGIN, ( void (CALLBACK*)() )tessBeginCB );
|
|
|
|
gluTessCallback( tess, GLU_TESS_END, ( void (CALLBACK*)() )tessEndCB );
|
|
|
|
gluTessCallback( tess, GLU_TESS_ERROR, ( void (CALLBACK*)() )tessErrorCB );
|
2010-08-19 14:21:05 +00:00
|
|
|
gluTessCallback( tess, GLU_TESS_VERTEX, ( void (CALLBACK*)() )tessCPolyPt2Vertex );
|
2009-11-16 13:18:20 +00:00
|
|
|
|
|
|
|
GLdouble v_data[3];
|
2010-08-19 14:21:05 +00:00
|
|
|
v_data[2] = zpos;
|
2009-11-16 13:18:20 +00:00
|
|
|
|
|
|
|
//gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
|
2009-12-07 03:46:13 +00:00
|
|
|
|
2009-11-16 13:18:20 +00:00
|
|
|
// Draw solid areas contained in this zone
|
2010-08-19 14:21:05 +00:00
|
|
|
int StartContour = 1;
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
for( unsigned ii = 0; ii < aZone->m_FilledPolysList.size(); ii++ )
|
2009-11-16 13:18:20 +00:00
|
|
|
{
|
|
|
|
if( StartContour == 1 )
|
|
|
|
{
|
2010-08-19 14:21:05 +00:00
|
|
|
gluTessBeginPolygon( tess, NULL );
|
2009-11-16 13:18:20 +00:00
|
|
|
gluTessBeginContour( tess );
|
|
|
|
StartContour = 0;
|
|
|
|
}
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
v_data[0] = aZone->m_FilledPolysList[ii].x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
v_data[1] = -aZone->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
gluTessVertex( tess, v_data, &aZone->m_FilledPolysList[ii] );
|
2009-11-16 13:18:20 +00:00
|
|
|
|
2010-12-29 17:47:32 +00:00
|
|
|
if( aZone->m_FilledPolysList[ii].end_contour == 1 )
|
2009-11-16 13:18:20 +00:00
|
|
|
{
|
|
|
|
gluTessEndContour( tess );
|
|
|
|
gluTessEndPolygon( tess );
|
|
|
|
StartContour = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gluDeleteTess( tess );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_Via( SEGVIA* via )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
double x, y, r, hole;
|
|
|
|
int layer, top_layer, bottom_layer;
|
|
|
|
double zpos, height;
|
|
|
|
int color;
|
|
|
|
|
|
|
|
r = via->m_Width * g_Parm_3D_Visu.m_BoardScale / 2;
|
|
|
|
hole = via->GetDrillValue();
|
|
|
|
hole *= g_Parm_3D_Visu.m_BoardScale / 2;
|
2008-12-16 19:44:57 +00:00
|
|
|
x = via->m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
y = via->m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
via->ReturnLayerPair( &top_layer, &bottom_layer );
|
|
|
|
|
|
|
|
// Drawing filled circles:
|
|
|
|
for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_Layers; layer++ )
|
|
|
|
{
|
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( layer < g_Parm_3D_Visu.m_Layers - 1 )
|
2009-10-10 01:25:53 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
2009-10-10 01:25:53 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
color = g_ColorsSettings.GetLayerColor( layer );
|
2009-10-10 01:25:53 +00:00
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
else
|
2009-10-10 01:25:53 +00:00
|
|
|
{
|
2011-09-07 19:41:04 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( LAYER_N_FRONT ) == false )
|
2009-10-10 01:25:53 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
color = g_ColorsSettings.GetLayerColor( LAYER_N_FRONT );
|
2009-10-10 01:25:53 +00:00
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
SetGLColor( color );
|
2008-12-16 19:44:57 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
// SetGLColor( LIGHTGRAY );
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer == LAYER_N_BACK )
|
2008-08-17 18:37:03 +00:00
|
|
|
zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
else
|
|
|
|
zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
Draw3D_FilledCircle( x, -y, r, hole, zpos );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( layer >= top_layer )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Drawing hole:
|
2010-08-19 14:21:05 +00:00
|
|
|
color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->m_Shape );
|
2008-08-17 18:37:03 +00:00
|
|
|
SetGLColor( color );
|
2011-09-07 19:41:04 +00:00
|
|
|
height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] - g_Parm_3D_Visu.m_LayerZcoord[bottom_layer];
|
|
|
|
Draw3D_FilledCylinder( x, -y, hole, height, g_Parm_3D_Visu.m_LayerZcoord[bottom_layer] );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_DrawSegment( DRAWSEGMENT* segment )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
double x, y, xf, yf;
|
|
|
|
double zpos, w;
|
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
int layer = segment->GetLayer();
|
2009-10-28 11:48:47 +00:00
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
2008-03-03 08:00:26 +00:00
|
|
|
return;
|
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
SetGLColor( color );
|
2011-12-14 04:29:25 +00:00
|
|
|
|
|
|
|
w = segment->GetWidth() * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
|
|
|
|
x = segment->GetStart().x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
y = segment->GetStart().y * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
|
|
|
|
xf = segment->GetEnd().x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
yf = segment->GetEnd().y * g_Parm_3D_Visu.m_BoardScale;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
if( layer == EDGE_N )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
for( layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ )
|
|
|
|
{
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2008-03-03 08:00:26 +00:00
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2011-12-14 04:29:25 +00:00
|
|
|
switch( segment->GetShape() )
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
|
|
|
case S_ARC:
|
2011-12-14 04:29:25 +00:00
|
|
|
Draw3D_ArcSegment( x, -y, xf, -yf, segment->GetAngle(), w, zpos );
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
|
|
|
|
break;
|
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-17 18:37:03 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) );
|
2008-08-16 17:42:40 +00:00
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( Get3DLayerEnable( layer ) )
|
|
|
|
{
|
2011-12-14 04:29:25 +00:00
|
|
|
switch( segment->GetShape() )
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
|
|
|
case S_ARC:
|
2011-12-14 04:29:25 +00:00
|
|
|
Draw3D_ArcSegment( x, -y, xf, -yf, segment->GetAngle(), w, zpos );
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
Draw3D_CircleSegment( x, -y, xf, -yf, w, zpos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Draw3D_FilledSegment( x, -y, xf, -yf, w, zpos );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
static double s_Text3DWidth, s_Text3DZPos;
|
|
|
|
static void Draw3dTextSegm( int x0, int y0, int xf, int yf )
|
2008-08-16 17:42:40 +00:00
|
|
|
{
|
2008-12-16 19:44:57 +00:00
|
|
|
double startx = x0 * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
double starty = y0 * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
double endx = xf * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
double endy = yf * g_Parm_3D_Visu.m_BoardScale;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2011-09-07 19:41:04 +00:00
|
|
|
Draw3D_FilledSegment( startx, -starty, endx, -endy, s_Text3DWidth, s_Text3DZPos );
|
2008-12-16 19:44:57 +00:00
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_DrawText( TEXTE_PCB* text )
|
2008-12-16 19:44:57 +00:00
|
|
|
{
|
2008-12-16 20:13:30 +00:00
|
|
|
int layer = text->GetLayer();
|
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
if( !Get3DLayerEnable( layer ) )
|
|
|
|
return;
|
2008-12-16 20:13:30 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2008-12-16 19:44:57 +00:00
|
|
|
SetGLColor( color );
|
|
|
|
s_Text3DZPos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2011-11-29 17:25:30 +00:00
|
|
|
s_Text3DWidth = text->GetThickness() * g_Parm_3D_Visu.m_BoardScale;
|
2008-12-16 19:44:57 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayerSide( layer ) );
|
2009-07-05 12:09:41 +00:00
|
|
|
wxSize size = text->m_Size;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-07-05 12:09:41 +00:00
|
|
|
if( text->m_Mirror )
|
2009-11-04 20:46:53 +00:00
|
|
|
NEGATE( size.x );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
if( text->m_MultilineAllowed )
|
|
|
|
{
|
|
|
|
wxPoint pos = text->m_Pos;
|
|
|
|
wxArrayString* list = wxStringSplit( text->m_Text, '\n' );
|
|
|
|
wxPoint offset;
|
|
|
|
|
|
|
|
offset.y = text->GetInterline();
|
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
RotatePoint( &offset, text->GetOrientation() );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
for( unsigned i = 0; i<list->Count(); i++ )
|
|
|
|
{
|
|
|
|
wxString txt = list->Item( i );
|
|
|
|
DrawGraphicText( NULL, NULL, pos, (EDA_Colors) color,
|
2011-11-29 17:25:30 +00:00
|
|
|
txt, text->GetOrientation(), size,
|
2009-11-04 20:46:53 +00:00
|
|
|
text->m_HJustify, text->m_VJustify,
|
2011-11-29 17:25:30 +00:00
|
|
|
text->GetThickness(), text->m_Italic,
|
2009-11-04 20:46:53 +00:00
|
|
|
true, Draw3dTextSegm );
|
2009-05-28 08:42:24 +00:00
|
|
|
pos += offset;
|
|
|
|
}
|
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
delete list;
|
2009-05-28 08:42:24 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-07 19:41:04 +00:00
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_Colors) color,
|
2011-11-29 17:25:30 +00:00
|
|
|
text->m_Text, text->GetOrientation(), size,
|
2009-11-04 20:46:53 +00:00
|
|
|
text->m_HJustify, text->m_VJustify,
|
2011-11-29 17:25:30 +00:00
|
|
|
text->GetThickness(), text->m_Italic,
|
2009-11-04 20:46:53 +00:00
|
|
|
true,
|
|
|
|
Draw3dTextSegm );
|
2011-09-07 19:41:04 +00:00
|
|
|
}
|
2008-08-16 17:42:40 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
D_PAD* pad = m_Pads;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Draw pads
|
2008-03-03 08:00:26 +00:00
|
|
|
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; pad != NULL; pad = pad->Next() )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
pad->Draw3D( glcanvas );
|
|
|
|
}
|
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Draw module shape: 3D shape if exists (or module outlines if not exists)
|
2008-12-06 08:21:54 +00:00
|
|
|
S3D_MASTER* Struct3D = m_3D_Drawings;
|
2011-09-17 15:31:21 +00:00
|
|
|
bool As3dShape = false;
|
2011-02-16 21:51:35 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( g_Parm_3D_Visu.m_Draw3DModule )
|
|
|
|
{
|
|
|
|
glPushMatrix();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BoardScale,
|
2009-02-02 12:12:18 +00:00
|
|
|
-m_Pos.y * g_Parm_3D_Visu.m_BoardScale,
|
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[m_Layer] );
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( m_Orient )
|
|
|
|
{
|
|
|
|
glRotatef( (double) m_Orient / 10, 0.0, 0.0, 1.0 );
|
|
|
|
}
|
2011-02-16 21:51:35 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( m_Layer == LAYER_N_BACK )
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
|
|
|
glRotatef( 180.0, 0.0, 1.0, 0.0 );
|
|
|
|
glRotatef( 180.0, 0.0, 0.0, 1.0 );
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
DataScale3D = g_Parm_3D_Visu.m_BoardScale * UNITS3D_TO_UNITSPCB;
|
|
|
|
|
2008-11-24 06:53:43 +00:00
|
|
|
for( ; Struct3D != NULL; Struct3D = Struct3D->Next() )
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
|
|
|
if( !Struct3D->m_Shape3DName.IsEmpty() )
|
|
|
|
{
|
2011-09-17 15:31:21 +00:00
|
|
|
As3dShape = true;
|
2008-08-17 18:37:03 +00:00
|
|
|
Struct3D->ReadData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
2011-02-16 21:51:35 +00:00
|
|
|
EDA_ITEM* Struct = m_Drawings;
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
|
|
|
|
|
|
|
for( ; Struct != NULL; Struct = Struct->Next() )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2011-02-16 21:51:35 +00:00
|
|
|
switch( Struct->Type() )
|
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_TEXT_T:
|
2011-02-16 21:51:35 +00:00
|
|
|
break;
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2011-02-16 21:51:35 +00:00
|
|
|
EDGE_MODULE* edge = (EDGE_MODULE*) Struct;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2011-02-16 21:51:35 +00:00
|
|
|
// Draw module edges when no 3d shape exists.
|
|
|
|
// Always draw pcb edges.
|
|
|
|
if( !As3dShape || edge->GetLayer() == EDGE_N )
|
|
|
|
edge->Draw3D( glcanvas );
|
|
|
|
}
|
|
|
|
break;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2011-02-16 21:51:35 +00:00
|
|
|
default:
|
|
|
|
break;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDGE_MODULE::Draw3D( EDA_3D_CANVAS* glcanvas )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-08-17 18:37:03 +00:00
|
|
|
wxString s;
|
|
|
|
int dx, dy;
|
2010-08-19 14:21:05 +00:00
|
|
|
double x, y, fx, fy, w, zpos;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( m_Layer ) == false )
|
2008-03-03 08:00:26 +00:00
|
|
|
return;
|
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( m_Layer );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
SetGLColor( color );
|
|
|
|
|
|
|
|
dx = m_End.x;
|
|
|
|
dy = m_End.y;
|
|
|
|
w = m_Width * g_Parm_3D_Visu.m_BoardScale;
|
2008-08-17 18:37:03 +00:00
|
|
|
x = m_Start.x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
y = m_Start.y * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
fx = dx * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
fy = dy * g_Parm_3D_Visu.m_BoardScale;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2008-03-11 22:48:52 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
if( m_Layer == EDGE_N )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2011-02-16 20:58:39 +00:00
|
|
|
for( int layer = 0; layer < g_Parm_3D_Visu.m_Layers; layer++ )
|
|
|
|
{
|
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
|
|
|
Draw3D_FilledSegment( x, -y, fx, -fy, w, zpos );
|
|
|
|
break;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
case S_CIRCLE:
|
|
|
|
Draw3D_CircleSegment( x, -y, fx, -fy, w, zpos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
|
|
|
Draw3D_ArcSegment( x, -y, fx, -fy, (double) m_Angle, w, zpos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
|
|
|
{
|
|
|
|
// We must compute true coordinates from m_PolyPoints
|
|
|
|
// which are relative to module position and module orientation = 0
|
|
|
|
std::vector<wxPoint> points = m_PolyPoints;
|
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
|
|
|
|
|
|
|
if( module == NULL )
|
|
|
|
break;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < points.size(); ii++ )
|
|
|
|
{
|
|
|
|
wxPoint& pt = points[ii];
|
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
|
2011-02-16 20:58:39 +00:00
|
|
|
pt += module->m_Pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
glcanvas->Draw3D_Polygon( points, zpos );
|
|
|
|
}
|
|
|
|
break;
|
2008-03-11 22:48:52 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
default:
|
|
|
|
s.Printf( wxT( "Error: Shape nr %d not implemented!\n" ), m_Shape );
|
2011-02-28 18:36:19 +00:00
|
|
|
D( printf( "%s", TO_UTF8( s ) ); )
|
2011-09-07 19:41:04 +00:00
|
|
|
break;
|
2011-02-16 20:58:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2010-08-19 14:21:05 +00:00
|
|
|
{
|
2011-02-16 20:58:39 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (m_Layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[m_Layer];
|
|
|
|
|
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
|
|
|
Draw3D_FilledSegment( x, -y, fx, -fy, w, zpos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
|
|
|
Draw3D_CircleSegment( x, -y, fx, -fy, w, zpos );
|
2010-08-19 14:21:05 +00:00
|
|
|
break;
|
2011-02-16 20:58:39 +00:00
|
|
|
|
|
|
|
case S_ARC:
|
|
|
|
Draw3D_ArcSegment( x, -y, fx, -fy, (double) m_Angle, w, zpos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
2010-08-19 14:21:05 +00:00
|
|
|
{
|
2011-02-16 20:58:39 +00:00
|
|
|
// We must compute true coordinates from m_PolyPoints
|
|
|
|
// which are relative to module position and module orientation = 0
|
|
|
|
std::vector<wxPoint> points = m_PolyPoints;
|
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
2010-08-19 14:21:05 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
if( module == NULL )
|
|
|
|
break;
|
2010-08-19 14:21:05 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
for( unsigned ii = 0; ii < points.size(); ii++ )
|
|
|
|
{
|
|
|
|
wxPoint& pt = points[ii];
|
|
|
|
|
2011-11-29 17:25:30 +00:00
|
|
|
RotatePoint( &pt.x, &pt.y, module->GetOrientation() );
|
2011-02-16 20:58:39 +00:00
|
|
|
pt += module->m_Pos;
|
|
|
|
}
|
2010-08-19 14:21:05 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
glcanvas->Draw3D_Polygon( points, zpos );
|
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
2011-02-16 20:58:39 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
s.Printf( wxT( "Error: Shape nr %d not implemented!\n" ), m_Shape );
|
2011-02-28 18:36:19 +00:00
|
|
|
D( printf( "%s", TO_UTF8( s ) ); )
|
2011-09-07 19:41:04 +00:00
|
|
|
break;
|
2011-02-16 20:58:39 +00:00
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Draw 3D pads.
|
2011-09-17 15:31:21 +00:00
|
|
|
void D_PAD::Draw3D( EDA_3D_CANVAS* glcanvas )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
int ii, ll, layer, nlmax;
|
|
|
|
int ux0, uy0,
|
|
|
|
dx, dx0, dy, dy0,
|
|
|
|
delta_cx, delta_cy,
|
|
|
|
xc, yc;
|
2011-08-18 19:25:12 +00:00
|
|
|
int angle;
|
2008-12-16 19:44:57 +00:00
|
|
|
double scale;
|
2008-03-03 08:00:26 +00:00
|
|
|
double zpos;
|
|
|
|
wxPoint shape_pos;
|
|
|
|
double x, y, r, w, hole, holeX, holeY;
|
|
|
|
double drillx, drilly;
|
|
|
|
bool Oncu, Oncmp, Both;
|
|
|
|
int color;
|
|
|
|
|
|
|
|
scale = g_Parm_3D_Visu.m_BoardScale;
|
2011-11-24 17:32:51 +00:00
|
|
|
holeX = (double) m_Drill.x * scale / 2;
|
|
|
|
holeY = (double) m_Drill.y * scale / 2;
|
2012-01-10 20:12:46 +00:00
|
|
|
hole = fmin( holeX, holeY );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Calculate the center of the pad.
|
2007-05-06 16:03:28 +00:00
|
|
|
shape_pos = ReturnShapePos();
|
2008-03-03 08:00:26 +00:00
|
|
|
ux0 = shape_pos.x;
|
|
|
|
uy0 = shape_pos.y;
|
|
|
|
xc = ux0;
|
|
|
|
yc = uy0;
|
|
|
|
|
2011-11-24 17:32:51 +00:00
|
|
|
dx = dx0 = m_Size.x >> 1;
|
|
|
|
dy = dy0 = m_Size.y >> 1;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
angle = m_Orient;
|
2011-11-24 17:32:51 +00:00
|
|
|
drillx = m_Pos.x * scale;
|
|
|
|
drilly = m_Pos.y * scale;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Draw the pad hole (TODO: draw OBLONG hole)
|
2008-03-03 08:00:26 +00:00
|
|
|
if( holeX && holeY )
|
|
|
|
{
|
|
|
|
SetGLColor( DARKGRAY );
|
2009-02-04 15:25:03 +00:00
|
|
|
Draw3D_FilledCylinder( drillx, -drilly, hole,
|
2009-12-07 03:46:13 +00:00
|
|
|
g_Parm_3D_Visu.m_LayerZcoord[LAYER_N_FRONT], 0.0 );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
|
|
|
nlmax = g_Parm_3D_Visu.m_Layers - 1;
|
2011-09-17 15:31:21 +00:00
|
|
|
Oncu = (m_layerMask & LAYER_BACK) ? true : false;
|
|
|
|
Oncmp = (m_layerMask & LAYER_FRONT) ? true : false;
|
2008-03-03 08:00:26 +00:00
|
|
|
Both = Oncu && Oncmp;
|
|
|
|
|
|
|
|
switch( m_PadShape & 0x7F )
|
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
|
|
|
x = xc * scale;
|
|
|
|
y = yc * scale;
|
|
|
|
r = (double) dx * scale;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
|
|
|
|
{
|
|
|
|
if( layer && (layer == nlmax) )
|
2009-12-07 03:46:13 +00:00
|
|
|
layer = LAYER_N_FRONT;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (layer == LAYER_N_FRONT) && !Oncmp )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (layer == LAYER_N_BACK) && !Oncu )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
color = g_ColorsSettings.GetLayerColor( layer );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
SetGLColor( color );
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2008-03-03 08:00:26 +00:00
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer == LAYER_N_BACK )
|
2008-08-17 18:37:03 +00:00
|
|
|
zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
else
|
|
|
|
zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
Draw3D_FilledCircle( x, -y, r, hole, zpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
2012-02-02 17:45:37 +00:00
|
|
|
if( dx > dy ) // Horizontal ellipse
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
delta_cx = dx - dy;
|
|
|
|
delta_cy = 0;
|
2011-11-24 17:32:51 +00:00
|
|
|
w = m_Size.y * scale;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2012-02-02 17:45:37 +00:00
|
|
|
else // Vertical ellipse
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
delta_cx = 0;
|
|
|
|
delta_cy = dy - dx;
|
2011-11-24 17:32:51 +00:00
|
|
|
w = m_Size.x * scale;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
RotatePoint( &delta_cx, &delta_cy, angle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
double ox, oy, fx, fy;
|
2008-12-16 19:44:57 +00:00
|
|
|
ox = (double) ( ux0 + delta_cx ) * scale;
|
|
|
|
oy = (double) ( uy0 + delta_cy ) * scale;
|
|
|
|
fx = (double) ( ux0 - delta_cx ) * scale;
|
|
|
|
fy = (double) ( uy0 - delta_cy ) * scale;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
if( layer && (layer == nlmax) )
|
2009-12-07 03:46:13 +00:00
|
|
|
layer = LAYER_N_FRONT;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (layer == LAYER_N_FRONT) && !Oncmp )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (layer == LAYER_N_BACK) && !Oncu )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
color = g_ColorsSettings.GetLayerColor( layer );
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
SetGLColor( color );
|
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer == LAYER_N_BACK )
|
2008-08-17 18:37:03 +00:00
|
|
|
zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
else
|
|
|
|
zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
Draw3D_FilledSegmentWithHole( ox, -oy, fx, -fy, w, drillx, -drilly, hole, zpos );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
{
|
2010-10-29 07:40:02 +00:00
|
|
|
wxPoint coord[5];
|
|
|
|
wxRealPoint fcoord[8], f_hole_coord[8];
|
|
|
|
BuildPadPolygon( coord, wxSize(0,0), angle );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
2010-10-29 07:40:02 +00:00
|
|
|
coord[ii].x += ux0;
|
|
|
|
coord[ii].y += uy0;
|
2008-03-03 08:00:26 +00:00
|
|
|
ll = ii * 2;
|
2010-10-29 07:40:02 +00:00
|
|
|
fcoord[ll].x = coord[ii].x *scale;
|
|
|
|
fcoord[ll].y = coord[ii].y *scale;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( ii = 0; ii < 7; ii += 2 )
|
|
|
|
{
|
|
|
|
ll = ii + 2;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( ll > 7 )
|
|
|
|
ll -= 8;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-10-29 07:40:02 +00:00
|
|
|
fcoord[ii + 1].x = (fcoord[ii].x + fcoord[ll].x) / 2;
|
|
|
|
fcoord[ii + 1].y = (fcoord[ii].y + fcoord[ll].y) / 2;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( ii = 0; ii < 8; ii++ )
|
|
|
|
{
|
2010-10-29 07:40:02 +00:00
|
|
|
f_hole_coord[ii].x = -hole * 0.707;
|
|
|
|
f_hole_coord[ii].y = hole * 0.707;
|
|
|
|
RotatePoint( &f_hole_coord[ii].x, &f_hole_coord[ii].y, angle - (ii * 450) );
|
|
|
|
f_hole_coord[ii].x += drillx;
|
|
|
|
f_hole_coord[ii].y += drilly;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for( layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; layer++ )
|
|
|
|
{
|
|
|
|
if( layer && (layer == nlmax) )
|
2009-12-07 03:46:13 +00:00
|
|
|
layer = LAYER_N_FRONT;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (layer == LAYER_N_FRONT) && !Oncmp )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( (layer == LAYER_N_BACK) && !Oncu )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER) && !Both )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
color = g_ColorsSettings.GetLayerColor( layer );
|
2009-12-07 03:46:13 +00:00
|
|
|
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
SetGLColor( color );
|
2008-03-03 08:00:26 +00:00
|
|
|
zpos = g_Parm_3D_Visu.m_LayerZcoord[layer];
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-12-07 03:46:13 +00:00
|
|
|
if( layer == LAYER_N_BACK )
|
2008-08-17 18:37:03 +00:00
|
|
|
zpos = zpos - 5 * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
else
|
|
|
|
zpos = zpos + 5 * g_Parm_3D_Visu.m_BoardScale;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
glBegin( GL_QUAD_STRIP );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii < 8; ii++ )
|
|
|
|
{
|
2010-10-29 07:40:02 +00:00
|
|
|
glVertex3f( f_hole_coord[ii].x, -f_hole_coord[ii].y, zpos );
|
|
|
|
glVertex3f( fcoord[ii].x, -fcoord[ii].y, zpos );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-29 07:40:02 +00:00
|
|
|
glVertex3f( f_hole_coord[0].x, -f_hole_coord[0].y, zpos );
|
|
|
|
glVertex3f( fcoord[0].x, -fcoord[0].y, zpos );
|
2008-03-03 08:00:26 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
2008-12-16 19:44:57 +00:00
|
|
|
break;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
void SetGLColor( int color )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
double red, green, blue;
|
|
|
|
StructColors colordata = ColorRefs[color & MASKCOLOR];
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
red = colordata.m_Red / 255.0;
|
|
|
|
blue = colordata.m_Blue / 255.0;
|
|
|
|
green = colordata.m_Green / 255.0;
|
|
|
|
glColor3f( red, green, blue );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
static void Draw3D_FilledCircle( double posx, double posy,
|
|
|
|
double rayon, double hole, double zpos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
int ii, slice = 16;
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
glBegin( GL_QUAD_STRIP );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii <= slice; ii++ )
|
|
|
|
{
|
|
|
|
x = hole;
|
|
|
|
y = 0.0;
|
|
|
|
RotatePoint( &x, &y, ii * 225 );
|
|
|
|
glVertex3f( x + posx, y + posy, zpos );
|
|
|
|
x = rayon;
|
|
|
|
y = 0.0;
|
|
|
|
RotatePoint( &x, &y, ii * 225 );
|
|
|
|
glVertex3f( x + posx, y + posy, zpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
static void Draw3D_FilledCylinder( double posx, double posy, double rayon,
|
|
|
|
double height, double zpos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
int ii;
|
|
|
|
double x, y;
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
#define NB_SEGM 12
|
2011-11-10 15:55:05 +00:00
|
|
|
std::vector< S3D_Vertex > coords;
|
|
|
|
coords.resize( 4 );
|
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
double tmp = DataScale3D;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
DataScale3D = 1.0; // Coordinate is already in range for Set_Object_Data();
|
2008-03-03 08:00:26 +00:00
|
|
|
coords[0].x = coords[1].x = posx + rayon;
|
|
|
|
coords[0].y = coords[1].y = posy;
|
|
|
|
coords[0].z = coords[3].z = zpos;
|
|
|
|
coords[1].z = coords[2].z = zpos + height;
|
|
|
|
|
|
|
|
for( ii = 0; ii <= NB_SEGM; ii++ )
|
|
|
|
{
|
|
|
|
x = rayon;
|
|
|
|
y = 0.0;
|
|
|
|
RotatePoint( &x, &y, ii * (3600 / NB_SEGM) );
|
|
|
|
coords[2].x = coords[3].x = posx + x;
|
|
|
|
coords[2].y = coords[3].y = posy + y;
|
2011-11-10 15:55:05 +00:00
|
|
|
Set_Object_Data( coords );
|
2008-03-03 08:00:26 +00:00
|
|
|
coords[0].x = coords[2].x;
|
|
|
|
coords[0].y = coords[2].y;
|
|
|
|
coords[1].x = coords[3].x;
|
|
|
|
coords[1].y = coords[3].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
|
|
|
DataScale3D = tmp;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// Draw a polygon similar to a segment has rounded tips
|
2009-11-04 20:46:53 +00:00
|
|
|
static void Draw3D_FilledSegment( double startx, double starty, double endx,
|
|
|
|
double endy, double width, double zpos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
double dx, dy, x, y, firstx = 0, firsty = 0;
|
|
|
|
int ii, angle;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Calculate the coordinates of the segment assumed horizontal.
|
|
|
|
// Then turn the strips of the desired angle.
|
2008-03-03 08:00:26 +00:00
|
|
|
dx = endx - startx;
|
|
|
|
dy = endy - starty;
|
|
|
|
angle = (int) ( ( atan2( dy, dx ) * 1800 / M_PI ) + 0.5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
RotatePoint( &dx, &dy, angle );
|
2008-03-03 08:00:26 +00:00
|
|
|
width /= 2;
|
|
|
|
|
|
|
|
glBegin( GL_POLYGON );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Trace the flare to right (1st half polygon at the end of the segment)
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii <= 8; ii++ )
|
|
|
|
{
|
|
|
|
x = 0.0;
|
|
|
|
y = -width;
|
|
|
|
RotatePoint( &x, &y, -ii * 225 );
|
|
|
|
x += dx;
|
|
|
|
RotatePoint( &x, &y, -angle );
|
|
|
|
glVertex3f( startx + x, starty + y, zpos );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( ii == 0 )
|
|
|
|
{
|
|
|
|
firstx = startx + x;
|
|
|
|
firsty = starty + y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Rounding the left (2nd half polygon is the origin of the segment)
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii <= 8; ii++ )
|
|
|
|
{
|
|
|
|
int jj = ii * 225;
|
|
|
|
x = 0.0;
|
|
|
|
y = width;
|
|
|
|
RotatePoint( &x, &y, -angle - jj );
|
|
|
|
glVertex3f( startx + x, starty + y, zpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
glVertex3f( firstx, firsty, zpos );
|
|
|
|
glEnd();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
/* Draw a polygon similar to a segment ends with round hole
|
2007-11-01 05:27:31 +00:00
|
|
|
*/
|
2009-11-04 20:46:53 +00:00
|
|
|
static void Draw3D_FilledSegmentWithHole( double startx, double starty,
|
|
|
|
double endx, double endy,
|
|
|
|
double width, double holex,
|
|
|
|
double holey, double holeradius,
|
|
|
|
double zpos )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-03 08:00:26 +00:00
|
|
|
double x, y, xin, yin;
|
|
|
|
double firstx = 0, firsty = 0, firstxin = 0, firstyin = 0;
|
|
|
|
int ii, angle, theta;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Calculate the coordinates of the segment assumed horizontal
|
|
|
|
// Then turn the strips of the desired angle
|
|
|
|
// All calculations are done with startx, starty as the origin of the route
|
2008-03-03 08:00:26 +00:00
|
|
|
endx -= startx;
|
|
|
|
endy -= starty;
|
|
|
|
holex -= startx;
|
|
|
|
holey -= starty;
|
|
|
|
angle = (int) ( ( atan2( endy, endx ) * 1800 / M_PI ) + 0.5 );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
RotatePoint( &endx, &endy, angle );
|
2008-03-03 08:00:26 +00:00
|
|
|
RotatePoint( &holex, &holey, angle );
|
|
|
|
width /= 2;
|
|
|
|
|
|
|
|
glBegin( GL_QUAD_STRIP );
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Path of the flare to right (1st half polygon at the end of the segment)
|
|
|
|
// around the half-hole drilling
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii <= 8; ii++ )
|
|
|
|
{
|
|
|
|
x = 0.0;
|
|
|
|
y = -width;
|
|
|
|
xin = 0.0;
|
|
|
|
yin = -holeradius;
|
|
|
|
theta = -ii * 225;
|
|
|
|
RotatePoint( &x, &y, theta );
|
|
|
|
RotatePoint( &xin, &yin, theta );
|
|
|
|
x += endx;
|
|
|
|
RotatePoint( &x, &y, -angle );
|
|
|
|
xin += holex;
|
|
|
|
RotatePoint( &xin, &yin, -angle );
|
|
|
|
glVertex3f( startx + xin, starty + yin, zpos );
|
|
|
|
glVertex3f( startx + x, starty + y, zpos );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( ii == 0 )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
firstx = startx + x;
|
|
|
|
firsty = starty + y;
|
|
|
|
firstxin = startx + xin;
|
|
|
|
firstyin = starty + yin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
// Layout of the rounded left (2nd half polygon is the origin of the
|
|
|
|
// segment)
|
2008-03-03 08:00:26 +00:00
|
|
|
for( ii = 0; ii <= 8; ii++ )
|
|
|
|
{
|
|
|
|
theta = -ii * 225;
|
2008-12-16 19:44:57 +00:00
|
|
|
x = 0.0;
|
|
|
|
y = width;
|
2008-03-03 08:00:26 +00:00
|
|
|
RotatePoint( &x, &y, -angle + theta );
|
|
|
|
xin = 0.0;
|
|
|
|
yin = holeradius;
|
|
|
|
RotatePoint( &xin, &yin, theta );
|
|
|
|
xin += holex;
|
|
|
|
RotatePoint( &xin, &yin, -angle );
|
|
|
|
glVertex3f( startx + xin, starty + yin, zpos );
|
|
|
|
glVertex3f( startx + x, starty + y, zpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
glVertex3f( firstxin, firstyin, zpos );
|
|
|
|
glVertex3f( firstx, firsty, zpos );
|
|
|
|
glEnd();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2008-03-10 22:46:44 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2010-06-06 16:48:23 +00:00
|
|
|
static void Draw3D_ArcSegment( double startx, double starty, double centrex,
|
|
|
|
double centrey, double arc_angle, double width, double zpos )
|
2008-03-10 22:46:44 +00:00
|
|
|
{
|
2010-06-06 16:48:23 +00:00
|
|
|
int ii;
|
|
|
|
int slice = 36; // Number of segments to approximate a circle by segments
|
|
|
|
double hole, rayon;
|
2010-08-19 14:21:05 +00:00
|
|
|
double arcStart_Angle;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2010-06-06 16:48:23 +00:00
|
|
|
arcStart_Angle = (atan2( startx - centrex, starty - centrey ) * 1800 / M_PI );
|
|
|
|
rayon = hypot( startx - centrex, starty - centrey ) + ( width / 2);
|
2008-08-17 18:37:03 +00:00
|
|
|
hole = rayon - width;
|
|
|
|
|
2010-06-06 16:48:23 +00:00
|
|
|
// Calculate the number of segments to approximate this arc
|
|
|
|
int imax = (int) ( (double) arc_angle * slice / 3600.0 );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-06-06 16:48:23 +00:00
|
|
|
if( imax < 0 )
|
|
|
|
imax = -imax;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
if( imax == 0 )
|
2010-06-06 16:48:23 +00:00
|
|
|
imax = 1;
|
|
|
|
|
|
|
|
// Adjust delta_angle to have exactly imax segments in arc_angle
|
|
|
|
// i.e. arc_angle = imax delta_agnle.
|
|
|
|
double delta_angle = (double) arc_angle / imax;
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
glBegin( GL_QUAD_STRIP );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-06-06 16:48:23 +00:00
|
|
|
for( ii = 0; ii <= imax; ii++ )
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
2010-06-06 16:48:23 +00:00
|
|
|
double angle = (double) ii * delta_angle;
|
|
|
|
angle += arcStart_Angle + 900;
|
|
|
|
double dx = hole;
|
|
|
|
double dy = 0.0;
|
2010-08-19 14:21:05 +00:00
|
|
|
RotatePoint( &dx, &dy, (int) angle );
|
2010-06-06 16:48:23 +00:00
|
|
|
glVertex3f( dx + startx, dy + starty, zpos );
|
|
|
|
dx = rayon;
|
|
|
|
dy = 0.0;
|
2010-08-19 14:21:05 +00:00
|
|
|
RotatePoint( &dx, &dy, (int) angle );
|
2010-06-06 16:48:23 +00:00
|
|
|
glVertex3f( dx + startx, dy + starty, zpos );
|
2008-08-17 18:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
2008-03-10 22:46:44 +00:00
|
|
|
}
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
static void Draw3D_CircleSegment( double startx, double starty, double endx,
|
|
|
|
double endy, double width, double zpos )
|
2008-03-10 22:46:44 +00:00
|
|
|
{
|
2008-08-17 18:37:03 +00:00
|
|
|
int ii, slice = 36;
|
|
|
|
double x, y, hole, rayon;
|
|
|
|
|
|
|
|
rayon = hypot( startx - endx, starty - endy ) + ( width / 2);
|
|
|
|
hole = rayon - width;
|
|
|
|
|
|
|
|
glBegin( GL_QUAD_STRIP );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
for( ii = 0; ii <= slice; ii++ )
|
|
|
|
{
|
|
|
|
x = hole; y = 0.0;
|
|
|
|
RotatePoint( &x, &y, ii * 3600 / slice );
|
|
|
|
glVertex3f( x + startx, y + starty, zpos );
|
|
|
|
x = rayon; y = 0.0;
|
|
|
|
RotatePoint( &x, &y, ii * 3600 / slice );
|
|
|
|
glVertex3f( x + startx, y + starty, zpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnd();
|
2008-03-10 22:46:44 +00:00
|
|
|
}
|
2008-08-16 17:42:40 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos )
|
2010-08-19 14:21:05 +00:00
|
|
|
{
|
|
|
|
g_Parm_3D_Visu.m_ActZpos = aZpos;
|
|
|
|
|
|
|
|
GLUtesselator* tess = gluNewTess();
|
|
|
|
gluTessCallback( tess, GLU_TESS_BEGIN, ( void (CALLBACK*)() )tessBeginCB );
|
|
|
|
gluTessCallback( tess, GLU_TESS_END, ( void (CALLBACK*)() )tessEndCB );
|
|
|
|
gluTessCallback( tess, GLU_TESS_ERROR, ( void (CALLBACK*)() )tessErrorCB );
|
|
|
|
gluTessCallback( tess, GLU_TESS_VERTEX, ( void (CALLBACK*)() )tesswxPoint2Vertex );
|
|
|
|
|
|
|
|
GLdouble v_data[3];
|
|
|
|
v_data[2] = aZpos;
|
|
|
|
|
|
|
|
//gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
|
|
|
|
|
|
|
|
// Draw solid polygon
|
|
|
|
gluTessBeginPolygon( tess, NULL );
|
|
|
|
gluTessBeginContour( tess );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
for( unsigned ii = 0; ii < aCornersList.size(); ii++ )
|
|
|
|
{
|
|
|
|
v_data[0] = aCornersList[ii].x * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
v_data[1] = -aCornersList[ii].y * g_Parm_3D_Visu.m_BoardScale;
|
|
|
|
// gluTessVertex store pointers on data, not data, so do not store
|
|
|
|
// different corners values in a temporary variable
|
|
|
|
// but send pointer on each corner value in aCornersList
|
|
|
|
gluTessVertex( tess, v_data, &aCornersList[ii] );
|
|
|
|
}
|
|
|
|
|
|
|
|
gluTessEndContour( tess );
|
|
|
|
gluTessEndPolygon( tess );
|
|
|
|
|
|
|
|
gluDeleteTess( tess );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
static int Get3DLayerEnable( int act_layer )
|
2008-08-16 17:42:40 +00:00
|
|
|
{
|
2008-08-17 18:37:03 +00:00
|
|
|
bool enablelayer;
|
|
|
|
|
2011-09-17 15:31:21 +00:00
|
|
|
enablelayer = true;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( act_layer == DRAW_N && !g_Parm_3D_Visu.m_Draw3DDrawings )
|
2011-09-17 15:31:21 +00:00
|
|
|
enablelayer = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( act_layer == COMMENT_N && !g_Parm_3D_Visu.m_Draw3DComments )
|
2011-09-17 15:31:21 +00:00
|
|
|
enablelayer = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( act_layer == ECO1_N && !g_Parm_3D_Visu.m_Draw3DEco1 )
|
2011-09-17 15:31:21 +00:00
|
|
|
enablelayer = false;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
if( act_layer == ECO2_N && !g_Parm_3D_Visu.m_Draw3DEco2 )
|
2011-09-17 15:31:21 +00:00
|
|
|
enablelayer = false;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
return enablelayer;
|
2008-08-16 17:42:40 +00:00
|
|
|
}
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
static GLfloat Get3DLayerSide( int act_layer )
|
2008-08-16 17:42:40 +00:00
|
|
|
{
|
2008-08-17 18:37:03 +00:00
|
|
|
GLfloat nZ;
|
|
|
|
|
|
|
|
nZ = 1.0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
if( ( act_layer <= LAST_COPPER_LAYER - 1 )
|
2009-12-21 17:56:25 +00:00
|
|
|
|| ( act_layer == ADHESIVE_N_BACK )
|
|
|
|
|| ( act_layer == SOLDERPASTE_N_BACK )
|
|
|
|
|| ( act_layer == SILKSCREEN_N_BACK )
|
|
|
|
|| ( act_layer == SOLDERMASK_N_BACK ) )
|
2008-08-17 18:37:03 +00:00
|
|
|
nZ = -1.0;
|
|
|
|
return nZ;
|
2008-08-16 17:42:40 +00:00
|
|
|
}
|
2009-11-16 13:18:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// GLU_TESS CALLBACKS
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CALLBACK tessBeginCB( GLenum which )
|
|
|
|
{
|
|
|
|
glBegin( which );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CALLBACK tessEndCB()
|
|
|
|
{
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
|
2009-11-16 13:18:20 +00:00
|
|
|
{
|
|
|
|
// cast back to double type
|
|
|
|
const CPolyPt* ptr = (const CPolyPt*) data;
|
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
glVertex3f( ptr->x * g_Parm_3D_Visu.m_BoardScale,
|
|
|
|
-ptr->y * g_Parm_3D_Visu.m_BoardScale,
|
|
|
|
g_Parm_3D_Visu.m_ActZpos );
|
|
|
|
}
|
|
|
|
|
|
|
|
void CALLBACK tesswxPoint2Vertex( const GLvoid* data )
|
|
|
|
{
|
|
|
|
const wxPoint* ptr = (const wxPoint*) data;
|
|
|
|
|
|
|
|
glVertex3f( ptr->x * g_Parm_3D_Visu.m_BoardScale,
|
|
|
|
-ptr->y * g_Parm_3D_Visu.m_BoardScale,
|
|
|
|
g_Parm_3D_Visu.m_ActZpos );
|
2009-11-16 13:18:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CALLBACK tessErrorCB( GLenum errorCode )
|
|
|
|
{
|
2012-01-10 20:12:46 +00:00
|
|
|
#if defined(DEBUG)
|
2009-11-16 13:18:20 +00:00
|
|
|
const GLubyte* errorStr;
|
|
|
|
|
|
|
|
errorStr = gluErrorString( errorCode );
|
|
|
|
|
|
|
|
// DEBUG //
|
|
|
|
D( printf( "Tess ERROR: %s\n", errorStr ); )
|
2012-01-10 20:12:46 +00:00
|
|
|
#endif
|
2009-11-16 13:18:20 +00:00
|
|
|
}
|