|
|
|
@ -45,10 +45,11 @@ static GLfloat Get3DLayerSide( int act_layer ); |
|
|
|
#endif
|
|
|
|
|
|
|
|
// CALLBACK functions for GLU_TESS
|
|
|
|
void CALLBACK tessBeginCB( GLenum which ); |
|
|
|
void CALLBACK tessEndCB(); |
|
|
|
void CALLBACK tessErrorCB( GLenum errorCode ); |
|
|
|
void CALLBACK tessVertexCB( const GLvoid* data ); |
|
|
|
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 ); |
|
|
|
|
|
|
|
void Pcb3D_GLCanvas::Redraw( bool finish ) |
|
|
|
{ |
|
|
|
@ -241,7 +242,8 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() |
|
|
|
{ |
|
|
|
ZONE_CONTAINER* curr_zone = pcb->GetArea( ii ); |
|
|
|
if( curr_zone->m_FillMode == 0 ) |
|
|
|
{ // solid polygons only are used to fill areas
|
|
|
|
{ |
|
|
|
// solid polygons only are used to fill areas
|
|
|
|
if( curr_zone->m_FilledPolysList.size() > 3 ) |
|
|
|
{ |
|
|
|
Draw3D_SolidPolygonsInZones( curr_zone ); |
|
|
|
@ -249,7 +251,7 @@ GLuint Pcb3D_GLCanvas::CreateDrawGL_List() |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// segments are used to fill ares
|
|
|
|
// segments are used to fill areas
|
|
|
|
for( unsigned iseg = 0; iseg < curr_zone->m_FillSegmList.size(); iseg++ ) |
|
|
|
{ |
|
|
|
SEGZONE dummysegment( pcb ); |
|
|
|
@ -408,9 +410,10 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* zone_c ) |
|
|
|
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*)() )tessVertexCB ); |
|
|
|
gluTessCallback( tess, GLU_TESS_VERTEX, ( void (CALLBACK*)() )tessCPolyPt2Vertex ); |
|
|
|
|
|
|
|
GLdouble v_data[3]; |
|
|
|
v_data[2] = zpos; |
|
|
|
|
|
|
|
//gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO);
|
|
|
|
|
|
|
|
@ -420,13 +423,12 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* zone_c ) |
|
|
|
{ |
|
|
|
if( StartContour == 1 ) |
|
|
|
{ |
|
|
|
gluTessBeginPolygon( tess, 0 ); |
|
|
|
gluTessBeginPolygon( tess, NULL ); |
|
|
|
gluTessBeginContour( tess ); |
|
|
|
StartContour = 0; |
|
|
|
} |
|
|
|
v_data[0] = zone_c->m_FilledPolysList[ii].x * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
v_data[1] = zone_c->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale * -1; |
|
|
|
v_data[2] = zpos; |
|
|
|
v_data[1] = -zone_c->m_FilledPolysList[ii].y * g_Parm_3D_Visu.m_BoardScale; |
|
|
|
gluTessVertex( tess, v_data, &zone_c->m_FilledPolysList[ii] ); |
|
|
|
|
|
|
|
if( zone_c->m_FilledPolysList[ii].end_contour == 1 ) |
|
|
|
@ -712,7 +714,7 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
{ |
|
|
|
wxString s; |
|
|
|
int dx, dy; |
|
|
|
double scale, x, y, fx, fy, w, zpos; |
|
|
|
double x, y, fx, fy, w, zpos; |
|
|
|
|
|
|
|
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( m_Layer ) == false ) |
|
|
|
return; |
|
|
|
@ -722,7 +724,6 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
|
|
|
|
SetGLColor( color ); |
|
|
|
glNormal3f( 0.0, 0.0, (m_Layer == LAYER_N_BACK) ? -1.0 : 1.0 ); |
|
|
|
scale = g_Parm_3D_Visu.m_BoardScale; |
|
|
|
|
|
|
|
dx = m_End.x; |
|
|
|
dy = m_End.y; |
|
|
|
@ -748,6 +749,26 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas ) |
|
|
|
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]; |
|
|
|
|
|
|
|
RotatePoint( &pt.x, &pt.y, module->m_Orient ); |
|
|
|
pt += module->m_Pos; |
|
|
|
} |
|
|
|
|
|
|
|
glcanvas->Draw3D_Polygon( points, zpos ); |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
s.Printf( wxT( "Error: Shape nr %d not implemented!\n" ), m_Shape ); |
|
|
|
D( printf( "%s", CONV_TO_UTF8( s ) ); ) |
|
|
|
@ -1248,6 +1269,46 @@ static void Draw3D_CircleSegment( double startx, double starty, double endx, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Function Pcb3D_GLCanvas::Draw3D_Polygon
|
|
|
|
* draw one solid polygon |
|
|
|
* @param aCornersList = a std::vector<wxPoint> liste of corners, in physical coordinates |
|
|
|
* @param aZpos = the z position in 3D units |
|
|
|
*/ |
|
|
|
void Pcb3D_GLCanvas::Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos ) |
|
|
|
{ |
|
|
|
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 ); |
|
|
|
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 ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int Get3DLayerEnable( int act_layer ) |
|
|
|
{ |
|
|
|
bool enablelayer; |
|
|
|
@ -1297,13 +1358,22 @@ void CALLBACK tessEndCB() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CALLBACK tessVertexCB( const GLvoid* data ) |
|
|
|
void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ) |
|
|
|
{ |
|
|
|
// cast back to double type
|
|
|
|
const CPolyPt* ptr = (const CPolyPt*) data; |
|
|
|
|
|
|
|
glVertex3f( (*ptr).x * g_Parm_3D_Visu.m_BoardScale, |
|
|
|
(*ptr).y * g_Parm_3D_Visu.m_BoardScale * -1, |
|
|
|
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 ); |
|
|
|
} |
|
|
|
|
|
|
|
|