2011-11-10 15:55:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-08-11 12:52:13 +00:00
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-11-10 15:55:05 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
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 <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 <colors_selection.h>
|
2012-08-23 19:15:58 +00:00
|
|
|
#include <convert_basic_shapes_to_polygon.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <3d_viewer.h>
|
2012-12-15 08:52:02 +00:00
|
|
|
#include <3d_canvas.h>
|
2012-08-11 12:52:13 +00:00
|
|
|
#include <info3d_visu.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <trackball.h>
|
2012-08-26 13:59:55 +00:00
|
|
|
#include <3d_draw_basic_functions.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Imported function:
|
|
|
|
extern void SetGLColor( int color );
|
|
|
|
extern void Set_Object_Data( std::vector< S3D_VERTEX >& aVertices, double aBiuTo3DUnits );
|
2010-10-29 07:40:02 +00:00
|
|
|
extern void CheckGLError();
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
|
|
|
|
/* returns true if aLayer should be displayed, false otherwise
|
|
|
|
*/
|
|
|
|
static bool Is3DLayerEnabled( int aLayer );
|
|
|
|
|
|
|
|
/* returns the Z orientation parmeter 1.0 or -1.0 for aLayer
|
|
|
|
* Z orientation is 1.0 for all layers but "back" layers:
|
|
|
|
* LAYER_N_BACK , ADHESIVE_N_BACK, SOLDERPASTE_N_BACK ), SILKSCREEN_N_BACK
|
|
|
|
* used to calculate the Z orientation parmeter for glNormal3f
|
|
|
|
*/
|
|
|
|
static GLfloat Get3DLayer_Z_Orientation( int aLayer );
|
|
|
|
|
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;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
SetCurrent( *m_glRC );
|
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();
|
2012-08-11 12:52:13 +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-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 );
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Build 3D board parameters:
|
|
|
|
g_Parm_3D_Visu.InitSettings( pcb );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
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
|
2012-04-09 09:16:47 +00:00
|
|
|
if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_AXIS])
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
// move the board in order to draw it with its center at 0,0 3D coordinates
|
2012-08-26 13:59:55 +00:00
|
|
|
glTranslatef( -g_Parm_3D_Visu.m_BoardPos.x * g_Parm_3D_Visu.m_BiuTo3Dunits,
|
|
|
|
-g_Parm_3D_Visu.m_BoardPos.y * g_Parm_3D_Visu.m_BiuTo3Dunits,
|
2009-02-02 12:12:18 +00:00
|
|
|
0.0F );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-02-02 17:45:37 +00:00
|
|
|
// draw tracks and vias :
|
2012-08-21 10:45:54 +00:00
|
|
|
for( TRACK* 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
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
int layer = track->GetLayer();
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
|
|
|
|
Draw3D_Track( track );
|
2009-11-16 13:18:20 +00:00
|
|
|
}
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
2009-11-16 13:18:20 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if (g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_ZONE])
|
|
|
|
{
|
|
|
|
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
|
2009-02-02 12:12:18 +00:00
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
int layer = pcb->GetArea( ii )->GetLayer();
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) )
|
|
|
|
Draw3D_Zone( pcb->GetArea( ii ) );
|
2009-02-02 12:12:18 +00:00
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
}
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
|
|
|
|
// Draw epoxy limits: TODO
|
|
|
|
|
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:
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
|
|
|
DRAWSEGMENT* segment = (DRAWSEGMENT*) PtStruct;
|
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( segment->GetLayer() ) )
|
|
|
|
Draw3D_DrawSegment( segment );
|
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
|
|
|
TEXTE_PCB* text = (TEXTE_PCB*) PtStruct;
|
|
|
|
if( Is3DLayerEnabled( text->GetLayer() ) )
|
|
|
|
Draw3D_DrawText( text );
|
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
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 );
|
2012-08-11 12:52:13 +00:00
|
|
|
|
|
|
|
// Draw grid
|
|
|
|
if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_GRID] )
|
|
|
|
DrawGrid( g_Parm_3D_Visu.m_3D_Grid );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
/* Draw a zone (solid copper areas in aZone)
|
|
|
|
*/
|
|
|
|
void EDA_3D_CANVAS::Draw3D_Zone( ZONE_CONTAINER* aZone )
|
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
int layer = aZone->GetLayer();
|
2012-08-21 10:45:54 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2012-08-27 07:06:52 +00:00
|
|
|
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
|
2012-08-21 10:45:54 +00:00
|
|
|
|
|
|
|
if( layer == LAST_COPPER_LAYER )
|
|
|
|
layer = g_Parm_3D_Visu.m_CopperLayersCount - 1;
|
|
|
|
|
2012-08-27 11:41:22 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
2012-08-21 10:45:54 +00:00
|
|
|
|
|
|
|
SetGLColor( color );
|
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
|
|
|
|
|
|
|
if( aZone->m_FillMode == 0 )
|
|
|
|
{
|
|
|
|
// solid polygons only are used to fill areas
|
|
|
|
if( aZone->GetFilledPolysList().size() > 3 )
|
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
Draw3D_SolidHorizontalPolyPolygons( aZone->GetFilledPolysList(),
|
|
|
|
g_Parm_3D_Visu.GetLayerZcoordBIU( layer ),
|
|
|
|
thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// segments are used to fill areas
|
|
|
|
for( unsigned iseg = 0; iseg < aZone->m_FillSegmList.size(); iseg++ )
|
2012-08-23 19:15:58 +00:00
|
|
|
Draw3D_SolidSegment( aZone->m_FillSegmList[iseg].m_Start,
|
|
|
|
aZone->m_FillSegmList[iseg].m_End,
|
2012-08-26 13:59:55 +00:00
|
|
|
aZone->m_ZoneMinThickness, thickness, zpos,
|
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Draw copper area outlines
|
|
|
|
std::vector<CPolyPt> polysList = aZone->GetFilledPolysList();
|
|
|
|
|
|
|
|
if( polysList.size() == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if( aZone->m_ZoneMinThickness <= 1 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
int imax = polysList.size() - 1;
|
|
|
|
CPolyPt* firstcorner = &polysList[0];
|
|
|
|
CPolyPt* begincorner = firstcorner;
|
|
|
|
|
|
|
|
for( int ic = 1; ic <= imax; ic++ )
|
|
|
|
{
|
|
|
|
CPolyPt* endcorner = &polysList[ic];
|
|
|
|
|
|
|
|
if( begincorner->m_utility == 0 )
|
|
|
|
{
|
|
|
|
// Draw only basic outlines, not extra segments
|
2012-08-23 19:15:58 +00:00
|
|
|
wxPoint start( begincorner->x, begincorner->y );
|
|
|
|
wxPoint end( endcorner->x, endcorner->y );
|
|
|
|
Draw3D_SolidSegment( start, end,
|
2012-08-26 13:59:55 +00:00
|
|
|
aZone->m_ZoneMinThickness, thickness, zpos,
|
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( (endcorner->end_contour) || (ic == imax) )
|
|
|
|
{
|
|
|
|
// the last corner of a filled area is found: draw it
|
|
|
|
if( endcorner->m_utility == 0 )
|
|
|
|
{
|
|
|
|
// Draw only basic outlines, not extra segments
|
2012-08-23 19:15:58 +00:00
|
|
|
wxPoint start( endcorner->x, endcorner->y );
|
|
|
|
wxPoint end( firstcorner->x, firstcorner->y );
|
|
|
|
Draw3D_SolidSegment( start, end,
|
2012-08-26 13:59:55 +00:00
|
|
|
aZone->m_ZoneMinThickness, thickness, zpos,
|
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ic++;
|
|
|
|
|
|
|
|
if( ic < imax - 1 )
|
|
|
|
begincorner = firstcorner = &polysList[ic];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
begincorner = endcorner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-01 05:27:31 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// draw a 3D grid: an horizontal grid (XY plane and Z = 0,
|
|
|
|
// and a vertical grid (XZ plane and Y = 0)
|
2012-08-11 12:52:13 +00:00
|
|
|
void EDA_3D_CANVAS::DrawGrid( double aGriSizeMM )
|
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
double zpos = 0.0;
|
2012-08-11 12:52:13 +00:00
|
|
|
int gridcolor = DARKGRAY; // Color of grid lines
|
|
|
|
int gridcolor_marker = LIGHTGRAY; // Color of grid lines every 5 lines
|
2012-08-26 13:59:55 +00:00
|
|
|
double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
|
2012-08-11 12:52:13 +00:00
|
|
|
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 );
|
|
|
|
|
|
|
|
wxSize brd_size = g_Parm_3D_Visu.m_BoardSize;
|
|
|
|
wxPoint brd_center_pos = g_Parm_3D_Visu.m_BoardPos;
|
|
|
|
NEGATE( brd_center_pos.y );
|
|
|
|
|
|
|
|
int xsize = std::max( brd_size.x, Millimeter2iu( 100 ) );
|
|
|
|
int ysize = std::max( brd_size.y, Millimeter2iu( 100 ) );
|
|
|
|
|
|
|
|
// Grid limits, in 3D units
|
|
|
|
double xmin = (brd_center_pos.x - xsize/2) * scale;
|
|
|
|
double xmax = (brd_center_pos.x + xsize/2) * scale;
|
|
|
|
double ymin = (brd_center_pos.y - ysize/2) * scale;
|
|
|
|
double ymax = (brd_center_pos.y + ysize/2) * scale;
|
|
|
|
double zmin = Millimeter2iu( -50 ) * scale;
|
|
|
|
double zmax = Millimeter2iu( 100 ) * scale;
|
|
|
|
|
|
|
|
// Draw horizontal grid centered on 3D origin (center of the board)
|
|
|
|
for( int ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( (ii % 5) )
|
|
|
|
SetGLColor( gridcolor );
|
|
|
|
else
|
|
|
|
SetGLColor( gridcolor_marker );
|
|
|
|
|
|
|
|
int delta = KiROUND( ii * aGriSizeMM * IU_PER_MM );
|
|
|
|
|
|
|
|
if( delta <= xsize/2 ) // Draw grid lines parallel to X axis
|
|
|
|
{
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f( (brd_center_pos.x + delta) * scale, -ymin, zpos );
|
|
|
|
glVertex3f( (brd_center_pos.x + delta) * scale, -ymax, zpos );
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
if( ii != 0 )
|
|
|
|
{
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f( (brd_center_pos.x - delta) * scale, -ymin, zpos );
|
|
|
|
glVertex3f( (brd_center_pos.x - delta) * scale, -ymax, zpos );
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( delta <= ysize/2 ) // Draw grid lines parallel to Y axis
|
|
|
|
{
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f( xmin, -(brd_center_pos.y + delta) * scale, zpos );
|
|
|
|
glVertex3f( xmax, -(brd_center_pos.y + delta) * scale, zpos );
|
|
|
|
glEnd();
|
|
|
|
if( ii != 0 )
|
|
|
|
{
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f( xmin, -(brd_center_pos.y - delta) * scale, zpos );
|
|
|
|
glVertex3f( xmax, -(brd_center_pos.y - delta) * scale, zpos );
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( delta > ysize/2 ) && ( delta > xsize/2 ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw vertical grid n Z axis
|
|
|
|
glNormal3f( 0.0, -1.0, 0.0 );
|
|
|
|
|
|
|
|
// Draw vertical grid lines (parallel to Z axis)
|
|
|
|
for( int ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( (ii % 5) )
|
|
|
|
SetGLColor( gridcolor );
|
|
|
|
else
|
|
|
|
SetGLColor( gridcolor_marker );
|
|
|
|
|
|
|
|
double delta = ii * aGriSizeMM * IU_PER_MM;
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmin );
|
|
|
|
glVertex3f( (brd_center_pos.x + delta) * scale, -brd_center_pos.y * scale, zmax );
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
if( ii != 0 )
|
|
|
|
{
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmin );
|
|
|
|
glVertex3f( (brd_center_pos.x - delta) * scale, -brd_center_pos.y * scale, zmax );
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( delta > xsize/2 )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw horizontal grid lines on Z axis
|
|
|
|
for( int ii = 0; ; ii++ )
|
|
|
|
{
|
|
|
|
if( (ii % 5) )
|
|
|
|
SetGLColor( gridcolor );
|
|
|
|
else
|
|
|
|
SetGLColor( gridcolor_marker );
|
|
|
|
double delta = ii * aGriSizeMM * IU_PER_MM * scale;
|
|
|
|
|
|
|
|
if( delta <= zmax )
|
|
|
|
{ // Draw grid lines on Z axis (positive Z axis coordinates)
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f(xmin, -brd_center_pos.y * scale, delta);
|
|
|
|
glVertex3f(xmax, -brd_center_pos.y * scale, delta);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( delta <= -zmin && ( ii != 0 ) )
|
|
|
|
{ // Draw grid lines on Z axis (negative Z axis coordinates)
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex3f(xmin, -brd_center_pos.y * scale, -delta);
|
|
|
|
glVertex3f(xmax, -brd_center_pos.y * scale, -delta);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ( delta > zmax ) && ( delta > -zmin ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
void EDA_3D_CANVAS::Draw3D_Track( TRACK* aTrack )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-08-28 06:51:18 +00:00
|
|
|
int layer = aTrack->GetLayer();
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2012-08-26 13:59:55 +00:00
|
|
|
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2008-03-03 08:00:26 +00:00
|
|
|
if( layer == LAST_COPPER_LAYER )
|
2012-08-11 12:52:13 +00:00
|
|
|
layer = g_Parm_3D_Visu.m_CopperLayersCount - 1;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-27 11:41:22 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
SetGLColor( color );
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
Draw3D_SolidSegment( aTrack->GetStart(), aTrack->GetEnd(),
|
|
|
|
aTrack->GetWidth(), thickness, zpos,
|
2012-08-26 13:59:55 +00:00
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
int layer, top_layer, bottom_layer;
|
|
|
|
int color;
|
2012-08-26 13:59:55 +00:00
|
|
|
double biu_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits ;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
int outer_radius = via->GetWidth() / 2;
|
2012-08-26 13:59:55 +00:00
|
|
|
int inner_radius = via->GetDrillValue() / 2;
|
|
|
|
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
via->ReturnLayerPair( &top_layer, &bottom_layer );
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Drawing horizontal thick rings:
|
2012-08-11 12:52:13 +00:00
|
|
|
for( layer = bottom_layer; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2012-08-27 11:41:22 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
2011-09-17 15:31:21 +00:00
|
|
|
|
2012-08-11 12:52:13 +00:00
|
|
|
if( layer < g_Parm_3D_Visu.m_CopperLayersCount - 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 );
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
Draw3D_ZaxisCylinder( via->GetStart(), (outer_radius + inner_radius)/2,
|
2012-08-26 13:59:55 +00:00
|
|
|
thickness, outer_radius - inner_radius,
|
2012-08-28 06:51:18 +00:00
|
|
|
zpos, biu_to_3Dunits );
|
2008-03-03 08:00:26 +00:00
|
|
|
if( layer >= top_layer )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Drawing via hole:
|
2013-01-13 00:04:00 +00:00
|
|
|
color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->GetShape() );
|
2008-08-17 18:37:03 +00:00
|
|
|
SetGLColor( color );
|
2012-08-26 13:59:55 +00:00
|
|
|
int height = g_Parm_3D_Visu.GetLayerZcoordBIU(top_layer) -
|
2012-08-28 06:51:18 +00:00
|
|
|
g_Parm_3D_Visu.GetLayerZcoordBIU( bottom_layer );
|
2012-08-26 13:59:55 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(bottom_layer) + thickness/2;
|
|
|
|
|
2013-01-13 00:04:00 +00:00
|
|
|
Draw3D_ZaxisCylinder( via->GetStart(), inner_radius + thickness/2, height,
|
2012-08-26 13:59:55 +00:00
|
|
|
thickness, zpos, biu_to_3Dunits );
|
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
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
int layer = segment->GetLayer();
|
2010-08-19 14:21:05 +00:00
|
|
|
int color = g_ColorsSettings.GetLayerColor( layer );
|
2012-08-27 07:06:52 +00:00
|
|
|
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( 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
|
|
|
|
2009-10-10 01:25:53 +00:00
|
|
|
if( layer == EDGE_N )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2012-08-11 12:52:13 +00:00
|
|
|
for( layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2012-08-26 18:10:28 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(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:
|
2012-08-26 18:10:28 +00:00
|
|
|
Draw3D_ArcSegment( segment->GetCenter(), segment->GetArcStart(),
|
|
|
|
segment->GetAngle(), segment->GetWidth(), thickness,
|
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
2012-08-26 13:59:55 +00:00
|
|
|
{
|
|
|
|
int radius = KiROUND( hypot( double(segment->GetStart().x - segment->GetEnd().x),
|
|
|
|
double(segment->GetStart().y - segment->GetEnd().y) )
|
|
|
|
);
|
|
|
|
Draw3D_ZaxisCylinder( segment->GetStart(), radius,
|
|
|
|
thickness, segment->GetWidth(),
|
2012-08-26 18:10:28 +00:00
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-26 13:59:55 +00:00
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-08-23 19:15:58 +00:00
|
|
|
Draw3D_SolidSegment( segment->GetStart(), segment->GetEnd(),
|
2012-08-26 13:59:55 +00:00
|
|
|
segment->GetWidth(), thickness,
|
2012-08-26 18:10:28 +00:00
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2012-08-26 18:10:28 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(layer);
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( Is3DLayerEnabled( 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:
|
2012-08-26 18:10:28 +00:00
|
|
|
Draw3D_ArcSegment( segment->GetCenter(), segment->GetArcStart(),
|
|
|
|
segment->GetAngle(), segment->GetWidth(), thickness,
|
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
int radius = KiROUND( hypot( double(segment->GetStart().x - segment->GetEnd().x),
|
|
|
|
double(segment->GetStart().y - segment->GetEnd().y) )
|
|
|
|
);
|
|
|
|
Draw3D_ZaxisCylinder( segment->GetStart(), radius,
|
|
|
|
thickness, segment->GetWidth(),
|
2012-08-26 18:10:28 +00:00
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
2008-08-17 18:37:03 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-08-23 19:15:58 +00:00
|
|
|
Draw3D_SolidSegment( segment->GetStart(), segment->GetEnd(),
|
2012-08-26 13:59:55 +00:00
|
|
|
segment->GetWidth(), thickness,
|
2012-08-26 18:10:28 +00:00
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2008-08-17 18:37:03 +00:00
|
|
|
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
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
// These variables are used in Draw3dTextSegm.
|
|
|
|
// But Draw3dTextSegm is a call back function, so we cannot send them as arguments,
|
|
|
|
// so they are static.
|
2012-08-26 13:59:55 +00:00
|
|
|
int s_Text3DWidth, s_Text3DZPos, s_thickness;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
|
|
|
// This is a call back function, used by DrawGraphicText to draw the 3D text shape:
|
2008-12-16 19:44:57 +00:00
|
|
|
static void Draw3dTextSegm( int x0, int y0, int xf, int yf )
|
2008-08-16 17:42:40 +00:00
|
|
|
{
|
2012-08-23 19:15:58 +00:00
|
|
|
Draw3D_SolidSegment( wxPoint( x0, y0), wxPoint( xf, yf ),
|
2012-08-26 13:59:55 +00:00
|
|
|
s_Text3DWidth, s_thickness, s_Text3DZPos,
|
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
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();
|
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 );
|
2012-08-27 11:41:22 +00:00
|
|
|
s_Text3DZPos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
2012-08-23 19:15:58 +00:00
|
|
|
s_Text3DWidth = text->GetThickness();
|
2012-08-21 10:45:54 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2009-07-05 12:09:41 +00:00
|
|
|
wxSize size = text->m_Size;
|
2012-08-27 07:06:52 +00:00
|
|
|
s_thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( layer );
|
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 );
|
2012-03-26 23:47:08 +00:00
|
|
|
DrawGraphicText( NULL, NULL, pos, (EDA_COLOR_T) 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
|
|
|
{
|
2012-03-26 23:47:08 +00:00
|
|
|
DrawGraphicText( NULL, NULL, text->m_Pos, (EDA_COLOR_T) 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-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
|
|
|
|
2012-08-27 11:41:22 +00:00
|
|
|
if( g_Parm_3D_Visu.m_DrawFlags[g_Parm_3D_Visu.FL_MODULE] )
|
2008-08-17 18:37:03 +00:00
|
|
|
{
|
2012-08-27 11:41:22 +00:00
|
|
|
double zpos;
|
2012-09-11 19:03:21 +00:00
|
|
|
if( IsFlipped() )
|
2012-08-27 11:41:22 +00:00
|
|
|
zpos = g_Parm_3D_Visu.GetModulesZcoord3DIU( true );
|
|
|
|
else
|
|
|
|
zpos = g_Parm_3D_Visu.GetModulesZcoord3DIU( false );
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
glPushMatrix();
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
glTranslatef( m_Pos.x * g_Parm_3D_Visu.m_BiuTo3Dunits,
|
|
|
|
-m_Pos.y * g_Parm_3D_Visu.m_BiuTo3Dunits,
|
2012-08-27 11:41:22 +00:00
|
|
|
zpos );
|
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
|
|
|
|
2012-09-11 19:03:21 +00:00
|
|
|
if( IsFlipped() )
|
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-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;
|
|
|
|
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
|
|
|
{
|
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 );
|
2008-03-03 08:00:26 +00:00
|
|
|
SetGLColor( color );
|
|
|
|
|
2012-08-27 07:06:52 +00:00
|
|
|
// for outline shape = S_POLYGON:
|
|
|
|
// We must compute true coordinates from m_PolyPoints
|
|
|
|
// which are relative to module position and module orientation = 0
|
|
|
|
std::vector<CPolyPt> polycorners;
|
|
|
|
|
|
|
|
if( m_Shape == S_POLYGON )
|
|
|
|
{
|
|
|
|
polycorners.reserve( m_PolyPoints.size() );
|
|
|
|
MODULE* module = (MODULE*) m_Parent;
|
|
|
|
|
|
|
|
CPolyPt corner;
|
|
|
|
for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
|
|
|
|
{
|
|
|
|
corner.x = m_PolyPoints[ii].x;
|
|
|
|
corner.y = m_PolyPoints[ii].y;
|
|
|
|
|
|
|
|
RotatePoint( &corner.x, &corner.y, module->GetOrientation() );
|
|
|
|
if( module )
|
|
|
|
{
|
|
|
|
corner.x += module->m_Pos.x;
|
|
|
|
corner.y += module->m_Pos.y;
|
|
|
|
}
|
|
|
|
polycorners.push_back( corner );
|
|
|
|
}
|
|
|
|
|
|
|
|
polycorners.back().end_contour = true;
|
|
|
|
}
|
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
if( m_Layer == EDGE_N )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2012-08-11 12:52:13 +00:00
|
|
|
for( int layer = 0; layer < g_Parm_3D_Visu.m_CopperLayersCount; layer++ )
|
2011-02-16 20:58:39 +00:00
|
|
|
{
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2012-08-26 18:10:28 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
2012-08-27 07:06:52 +00:00
|
|
|
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( m_Layer );
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2012-08-23 19:15:58 +00:00
|
|
|
Draw3D_SolidSegment( m_Start, m_End, m_Width,
|
2012-08-26 18:10:28 +00:00
|
|
|
thickness, zpos,
|
2012-08-26 13:59:55 +00:00
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2011-02-16 20:58:39 +00:00
|
|
|
break;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
case S_CIRCLE:
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
int radius = KiROUND( hypot( double(m_Start.x - m_End.x),
|
|
|
|
double(m_Start.y - m_End.y) )
|
|
|
|
);
|
|
|
|
Draw3D_ZaxisCylinder( m_Start, radius,
|
|
|
|
thickness, GetWidth(),
|
2012-08-26 18:10:28 +00:00
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
2011-02-16 20:58:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ARC:
|
2012-08-26 18:10:28 +00:00
|
|
|
Draw3D_ArcSegment( GetCenter(), GetArcStart(),
|
|
|
|
GetAngle(), GetWidth(), thickness,
|
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2011-02-16 20:58:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
2012-08-27 07:06:52 +00:00
|
|
|
Draw3D_SolidHorizontalPolyPolygons( polycorners, zpos, thickness,
|
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits);
|
|
|
|
break;
|
2008-03-11 22:48:52 +00:00
|
|
|
|
2011-02-16 20:58:39 +00:00
|
|
|
default:
|
2012-08-26 18:10:28 +00:00
|
|
|
D( printf( "Error: Shape nr %d not implemented!\n", m_Shape ); )
|
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
|
|
|
{
|
2012-08-27 07:06:52 +00:00
|
|
|
int thickness = g_Parm_3D_Visu.GetLayerObjectThicknessBIU( m_Layer );
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( m_Layer ) );
|
2012-08-26 18:10:28 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU(m_Layer);
|
2011-02-16 20:58:39 +00:00
|
|
|
|
|
|
|
switch( m_Shape )
|
|
|
|
{
|
|
|
|
case S_SEGMENT:
|
2012-08-23 19:15:58 +00:00
|
|
|
Draw3D_SolidSegment( m_Start, m_End, m_Width,
|
2012-08-26 18:10:28 +00:00
|
|
|
thickness, zpos,
|
2012-08-26 13:59:55 +00:00
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2011-02-16 20:58:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_CIRCLE:
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
int radius = KiROUND( hypot( double(m_Start.x - m_End.x),
|
|
|
|
double(m_Start.y - m_End.y) )
|
|
|
|
);
|
|
|
|
Draw3D_ZaxisCylinder( m_Start, radius,
|
|
|
|
thickness, GetWidth(),
|
2012-08-26 18:10:28 +00:00
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
2010-08-19 14:21:05 +00:00
|
|
|
break;
|
2011-02-16 20:58:39 +00:00
|
|
|
|
|
|
|
case S_ARC:
|
2012-08-26 18:10:28 +00:00
|
|
|
Draw3D_ArcSegment( GetCenter(), GetArcStart(),
|
|
|
|
GetAngle(), GetWidth(), thickness,
|
|
|
|
zpos, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2011-02-16 20:58:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case S_POLYGON:
|
2012-08-27 07:06:52 +00:00
|
|
|
Draw3D_SolidHorizontalPolyPolygons( polycorners, zpos, thickness,
|
|
|
|
g_Parm_3D_Visu.m_BiuTo3Dunits );
|
|
|
|
break;
|
2011-02-16 20:58:39 +00:00
|
|
|
|
|
|
|
default:
|
2012-08-26 18:10:28 +00:00
|
|
|
D( printf( "Error: Shape nr %d not implemented!\n", m_Shape ); )
|
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
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
double scale = g_Parm_3D_Visu.m_BiuTo3Dunits;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Calculate the center of the pad shape.
|
2012-08-21 10:45:54 +00:00
|
|
|
wxPoint shape_pos = ReturnShapePos();
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
int height = g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_FRONT) -
|
|
|
|
g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_BACK);
|
|
|
|
int thickness = g_Parm_3D_Visu.GetCopperThicknessBIU();
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Store here the points to approximate hole by segments
|
|
|
|
std::vector <CPolyPt> holecornersBuffer;
|
|
|
|
const int slice = 12; // number of segments to approximate a circle
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
// Draw the pad hole
|
2012-08-26 13:59:55 +00:00
|
|
|
bool hasHole = m_Drill.x && m_Drill.y;
|
|
|
|
|
|
|
|
if( hasHole )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
SetGLColor( DARKGRAY );
|
2012-08-26 13:59:55 +00:00
|
|
|
int holeZpoz = g_Parm_3D_Visu.GetLayerZcoordBIU(LAYER_N_BACK) + thickness/2;
|
|
|
|
int holeHeight = height - thickness;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
if( m_Drill.x == m_Drill.y ) // usual round hole
|
|
|
|
{
|
|
|
|
Draw3D_ZaxisCylinder( m_Pos, (m_Drill.x + thickness) / 2, holeHeight,
|
|
|
|
thickness, holeZpoz, scale );
|
|
|
|
TransformCircleToPolygon( holecornersBuffer, m_Pos, m_Drill.x/2, slice );
|
|
|
|
}
|
|
|
|
else // Oblong hole
|
2012-08-21 10:45:54 +00:00
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
wxPoint ends_offset;
|
|
|
|
int width;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
if( m_Drill.x > m_Drill.y ) // Horizontal oval
|
|
|
|
{
|
|
|
|
ends_offset.x = ( m_Drill.x - m_Drill.y ) / 2;
|
|
|
|
width = m_Drill.y;
|
|
|
|
}
|
|
|
|
else // Vertical oval
|
|
|
|
{
|
|
|
|
ends_offset.y = ( m_Drill.y - m_Drill.x ) / 2;
|
|
|
|
width = m_Drill.x;
|
|
|
|
}
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
RotatePoint( &ends_offset, m_Orient );
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
wxPoint start = m_Pos + ends_offset;
|
|
|
|
wxPoint end = m_Pos - ends_offset;
|
|
|
|
int hole_radius = ( width + thickness ) / 2;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Prepare the shape creation
|
|
|
|
TransformRoundedEndsSegmentToPolygon( holecornersBuffer, start, end, slice, width );
|
|
|
|
|
|
|
|
// Draw the hole
|
|
|
|
Draw3D_ZaxisOblongCylinder( start, end, hole_radius, holeHeight,
|
|
|
|
thickness, holeZpoz, scale );
|
2012-08-21 10:45:54 +00:00
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
|
2012-08-26 13:59:55 +00:00
|
|
|
|
2012-10-04 17:47:28 +00:00
|
|
|
int nlmax = g_Parm_3D_Visu.m_CopperLayersCount - 1;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// Store here the points to approximate pad shape by segments
|
|
|
|
std::vector<CPolyPt> polyPadShape;
|
|
|
|
|
|
|
|
switch( GetShape() )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
2012-10-04 17:47:28 +00:00
|
|
|
for( int 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
|
|
|
|
2012-10-04 17:47:28 +00:00
|
|
|
if( !IsOnLayer( layer ) )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
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
|
|
|
|
2012-10-04 17:47:28 +00:00
|
|
|
SetGLColor( g_ColorsSettings.GetLayerColor( layer ) );
|
2012-08-26 13:59:55 +00:00
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
|
|
|
int ring_radius = (m_Size.x + m_Drill.x) / 4;
|
|
|
|
if( thickness == 0 )
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2012-08-26 13:59:55 +00:00
|
|
|
|
|
|
|
Draw3D_ZaxisCylinder(shape_pos, ring_radius,
|
|
|
|
thickness, ( m_Size.x - m_Drill.x) / 2,
|
|
|
|
zpos - (thickness/2), scale );
|
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
wxPoint ends_offset;
|
|
|
|
int width;
|
|
|
|
if( m_Size.x > m_Size.y ) // Horizontal ellipse
|
|
|
|
{
|
|
|
|
ends_offset.x = ( m_Size.x - m_Size.y ) / 2;
|
|
|
|
width = m_Size.y;
|
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
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
ends_offset.y = ( m_Size.y - m_Size.x ) / 2;
|
|
|
|
width = m_Size.x;
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
RotatePoint( &ends_offset, m_Orient );
|
|
|
|
wxPoint start = shape_pos + ends_offset;
|
|
|
|
wxPoint end = shape_pos - ends_offset;
|
|
|
|
TransformRoundedEndsSegmentToPolygon( polyPadShape, start, end, slice, width );
|
|
|
|
if( hasHole )
|
|
|
|
polyPadShape.insert( polyPadShape.end(), holecornersBuffer.begin(), holecornersBuffer.end() );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
wxPoint coord[5];
|
|
|
|
BuildPadPolygon( coord, wxSize(0,0), m_Orient );
|
|
|
|
for( int ii = 0; ii < 4; ii ++ )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
CPolyPt pt( coord[ii].x + shape_pos.x, coord[ii].y+ shape_pos.y );
|
|
|
|
polyPadShape.push_back( pt );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2012-08-26 13:59:55 +00:00
|
|
|
polyPadShape.back().end_contour = true;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
if( hasHole )
|
|
|
|
polyPadShape.insert( polyPadShape.end(), holecornersBuffer.begin(), holecornersBuffer.end() );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
2012-08-26 13:59:55 +00:00
|
|
|
break;
|
2008-03-03 08:00:26 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( polyPadShape.size() )
|
|
|
|
{
|
2012-10-04 17:47:28 +00:00
|
|
|
for( int 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
|
|
|
|
2012-10-04 17:47:28 +00:00
|
|
|
if( !IsOnLayer( layer ) )
|
2008-03-03 08:00:26 +00:00
|
|
|
continue;
|
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
|
|
|
|
2012-10-04 17:47:28 +00:00
|
|
|
SetGLColor( g_ColorsSettings.GetLayerColor( layer ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
if( thickness == 0 )
|
2012-08-28 06:51:18 +00:00
|
|
|
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
// If not hole: draw a single polygon
|
|
|
|
int zpos = g_Parm_3D_Visu.GetLayerZcoordBIU( layer );
|
|
|
|
if( hasHole )
|
2008-03-03 08:00:26 +00:00
|
|
|
{
|
2012-08-26 13:59:55 +00:00
|
|
|
Draw3D_SolidHorizontalPolygonWithHoles( polyPadShape, zpos,
|
|
|
|
thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
|
2012-08-26 13:59:55 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Draw3D_SolidHorizontalPolyPolygons( polyPadShape, zpos,
|
|
|
|
thickness, g_Parm_3D_Visu.m_BiuTo3Dunits );
|
|
|
|
}
|
2008-03-03 08:00:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-19 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
bool Is3DLayerEnabled( int aLayer )
|
2008-08-16 17:42:40 +00:00
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
int flg = -1;
|
2012-04-09 09:16:47 +00:00
|
|
|
// see if layer needs to be shown
|
|
|
|
// check the flags
|
2012-08-21 10:45:54 +00:00
|
|
|
switch (aLayer)
|
2012-04-09 09:16:47 +00:00
|
|
|
{
|
|
|
|
case DRAW_N:
|
2012-08-21 10:45:54 +00:00
|
|
|
flg=g_Parm_3D_Visu.FL_DRAWINGS;
|
2012-04-09 09:16:47 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-09 09:16:47 +00:00
|
|
|
case COMMENT_N:
|
2012-08-21 10:45:54 +00:00
|
|
|
flg=g_Parm_3D_Visu.FL_COMMENTS;
|
2012-04-09 09:16:47 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-09 09:16:47 +00:00
|
|
|
case ECO1_N:
|
2012-08-21 10:45:54 +00:00
|
|
|
flg=g_Parm_3D_Visu.FL_ECO1;
|
2012-04-09 09:16:47 +00:00
|
|
|
break;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-04-09 09:16:47 +00:00
|
|
|
case ECO2_N:
|
2012-08-21 10:45:54 +00:00
|
|
|
flg=g_Parm_3D_Visu.FL_ECO2;
|
2012-04-09 09:16:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// the layer was not a layer with a flag, so show it
|
2012-08-21 10:45:54 +00:00
|
|
|
if( flg < 0 )
|
2012-04-09 09:16:47 +00:00
|
|
|
return true;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2012-04-09 09:16:47 +00:00
|
|
|
// if the layer has a flag, return the flag
|
2012-08-21 10:45:54 +00:00
|
|
|
return g_Parm_3D_Visu.m_DrawFlags[flg];
|
2008-08-16 17:42:40 +00:00
|
|
|
}
|
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
GLfloat Get3DLayer_Z_Orientation( int aLayer )
|
2008-08-16 17:42:40 +00:00
|
|
|
{
|
2012-08-21 10:45:54 +00:00
|
|
|
double nZ;
|
2008-08-17 18:37:03 +00:00
|
|
|
|
|
|
|
nZ = 1.0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-08-21 10:45:54 +00:00
|
|
|
if( ( aLayer == LAYER_N_BACK )
|
|
|
|
|| ( aLayer == ADHESIVE_N_BACK )
|
|
|
|
|| ( aLayer == SOLDERPASTE_N_BACK )
|
|
|
|
|| ( aLayer == SILKSCREEN_N_BACK )
|
|
|
|
|| ( aLayer == SOLDERMASK_N_BACK ) )
|
2008-08-17 18:37:03 +00:00
|
|
|
nZ = -1.0;
|
2012-08-21 10:45:54 +00:00
|
|
|
|
2008-08-17 18:37:03 +00:00
|
|
|
return nZ;
|
2008-08-16 17:42:40 +00:00
|
|
|
}
|