3D view: now displays polygons used in footprint shapes, like logos. Fixed very minor issues (minor warnings in debug mode)
This commit is contained in:
parent
ba3e69dd72
commit
3820154aed
|
@ -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 );
|
||||
|
@ -363,7 +365,7 @@ void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track )
|
|||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
||||
return;
|
||||
|
||||
int color = g_ColorsSettings.GetLayerColor(layer);
|
||||
int color = g_ColorsSettings.GetLayerColor( layer );
|
||||
|
||||
if( layer == LAST_COPPER_LAYER )
|
||||
layer = g_Parm_3D_Visu.m_Layers - 1;
|
||||
|
@ -384,7 +386,7 @@ void Pcb3D_GLCanvas::Draw3D_Track( TRACK* track )
|
|||
/** Function Draw3D_SolidPolygonsInZones
|
||||
* draw all solid polygons used as filles areas in a zone
|
||||
* @param aZone_c = the zone to draw
|
||||
*/
|
||||
*/
|
||||
void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* zone_c )
|
||||
{
|
||||
double zpos;
|
||||
|
@ -393,7 +395,7 @@ void Pcb3D_GLCanvas::Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* zone_c )
|
|||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
||||
return;
|
||||
|
||||
int color = g_ColorsSettings.GetLayerColor(layer);
|
||||
int color = g_ColorsSettings.GetLayerColor( layer );
|
||||
|
||||
if( layer == LAST_COPPER_LAYER )
|
||||
layer = g_Parm_3D_Visu.m_Layers - 1;
|
||||
|
@ -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 )
|
||||
|
@ -467,14 +469,14 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via )
|
|||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ==
|
||||
false )
|
||||
continue;
|
||||
color = g_ColorsSettings.GetLayerColor(layer);
|
||||
color = g_ColorsSettings.GetLayerColor( layer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( LAYER_N_FRONT ) ==
|
||||
false )
|
||||
continue;
|
||||
color = g_ColorsSettings.GetLayerColor(LAYER_N_FRONT);
|
||||
color = g_ColorsSettings.GetLayerColor( LAYER_N_FRONT );
|
||||
}
|
||||
|
||||
SetGLColor( color );
|
||||
|
@ -491,7 +493,7 @@ void Pcb3D_GLCanvas::Draw3D_Via( SEGVIA* via )
|
|||
}
|
||||
|
||||
// Drawing hole:
|
||||
color = g_ColorsSettings.GetItemColor(VIAS_VISIBLE + via->m_Shape);
|
||||
color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->m_Shape );
|
||||
SetGLColor( color );
|
||||
height = g_Parm_3D_Visu.m_LayerZcoord[top_layer] -
|
||||
g_Parm_3D_Visu.m_LayerZcoord[bottom_layer];
|
||||
|
@ -510,7 +512,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment )
|
|||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) == false )
|
||||
return;
|
||||
|
||||
int color = g_ColorsSettings.GetLayerColor(layer);
|
||||
int color = g_ColorsSettings.GetLayerColor( layer );
|
||||
|
||||
SetGLColor( color );
|
||||
w = segment->m_Width * g_Parm_3D_Visu.m_BoardScale;
|
||||
|
@ -596,7 +598,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawText( TEXTE_PCB* text )
|
|||
if( !Get3DLayerEnable( layer ) )
|
||||
return;
|
||||
|
||||
int color = g_ColorsSettings.GetLayerColor(layer);
|
||||
int color = g_ColorsSettings.GetLayerColor( layer );
|
||||
|
||||
|
||||
SetGLColor( color );
|
||||
|
@ -712,17 +714,16 @@ 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;
|
||||
|
||||
int color = g_ColorsSettings.GetLayerColor(m_Layer);
|
||||
int color = g_ColorsSettings.GetLayerColor( m_Layer );
|
||||
|
||||
|
||||
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 ) ); )
|
||||
|
@ -825,7 +846,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
|
|||
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER)
|
||||
&& !Both )
|
||||
continue;
|
||||
color = g_ColorsSettings.GetLayerColor(layer);
|
||||
color = g_ColorsSettings.GetLayerColor( layer );
|
||||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ==
|
||||
false )
|
||||
continue;
|
||||
|
@ -877,7 +898,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
|
|||
if( (layer > FIRST_COPPER_LAYER)
|
||||
&& (layer < LAST_COPPER_LAYER) && !Both )
|
||||
continue;
|
||||
color = g_ColorsSettings.GetLayerColor(layer);
|
||||
color = g_ColorsSettings.GetLayerColor( layer );
|
||||
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
||||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ==
|
||||
false )
|
||||
|
@ -921,8 +942,8 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
|
|||
coord[ii][0] += ux0;
|
||||
coord[ii][1] += uy0;
|
||||
ll = ii * 2;
|
||||
fcoord[ll][0] = coord[ii][0] * scale;
|
||||
fcoord[ll][1] = coord[ii][1] * scale;
|
||||
fcoord[ll][0] = coord[ii][0] *scale;
|
||||
fcoord[ll][1] = coord[ii][1] *scale;
|
||||
}
|
||||
|
||||
for( ii = 0; ii < 7; ii += 2 )
|
||||
|
@ -955,7 +976,7 @@ void D_PAD::Draw3D( Pcb3D_GLCanvas* glcanvas )
|
|||
if( (layer > FIRST_COPPER_LAYER) && (layer < LAST_COPPER_LAYER)
|
||||
&& !Both )
|
||||
continue;
|
||||
color = g_ColorsSettings.GetLayerColor(layer);
|
||||
color = g_ColorsSettings.GetLayerColor( layer );
|
||||
glNormal3f( 0.0, 0.0, (layer == LAYER_N_BACK) ? -1.0 : 1.0 );
|
||||
if( g_Parm_3D_Visu.m_BoardSettings->IsLayerVisible( layer ) ==
|
||||
false )
|
||||
|
@ -1198,7 +1219,7 @@ static void Draw3D_ArcSegment( double startx, double starty, double centrex,
|
|||
int imax = (int) ( (double) arc_angle * slice / 3600.0 );
|
||||
if( imax < 0 )
|
||||
imax = -imax;
|
||||
if (imax == 0 )
|
||||
if( imax == 0 )
|
||||
imax = 1;
|
||||
|
||||
// Adjust delta_angle to have exactly imax segments in arc_angle
|
||||
|
@ -1212,11 +1233,11 @@ static void Draw3D_ArcSegment( double startx, double starty, double centrex,
|
|||
angle += arcStart_Angle + 900;
|
||||
double dx = hole;
|
||||
double dy = 0.0;
|
||||
RotatePoint( &dx, &dy, (int)angle );
|
||||
RotatePoint( &dx, &dy, (int) angle );
|
||||
glVertex3f( dx + startx, dy + starty, zpos );
|
||||
dx = rayon;
|
||||
dy = 0.0;
|
||||
RotatePoint( &dx, &dy, (int)angle );
|
||||
RotatePoint( &dx, &dy, (int) angle );
|
||||
glVertex3f( dx + startx, dy + starty, zpos );
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,13 @@ public:
|
|||
* @param aZone_c = the zone to draw
|
||||
*/
|
||||
void Draw3D_SolidPolygonsInZones( ZONE_CONTAINER* aZone_c );
|
||||
|
||||
/** Function 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 Draw3D_Polygon( std::vector<wxPoint>& aCornersList, double aZpos );
|
||||
void Draw3D_Via( SEGVIA* via );
|
||||
void Draw3D_DrawSegment( DRAWSEGMENT* segment );
|
||||
void Draw3D_DrawText( TEXTE_PCB* text );
|
||||
|
|
|
@ -115,7 +115,7 @@ WinEDA_ExecBlockCmdFrame::WinEDA_ExecBlockCmdFrame( WinEDA_BasePcbFrame* parent,
|
|||
|
||||
/* Sizer 1 creation */
|
||||
wxFlexGridSizer* fgSizer1;
|
||||
fgSizer1 = new wxFlexGridSizer( 1, 1, 0, 0 );
|
||||
fgSizer1 = new wxFlexGridSizer( 7, 1, 0, 0 );
|
||||
fgSizer1->SetFlexibleDirection( wxBOTH );
|
||||
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ DIALOG_MODULE_BOARD_EDITOR_BASE::DIALOG_MODULE_BOARD_EDITOR_BASE( wxWindow* pare
|
|||
sbSizerLocalProperties->Add( m_staticTextInfo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||
|
||||
wxFlexGridSizer* fgSizerClearances;
|
||||
fgSizerClearances = new wxFlexGridSizer( 3, 3, 0, 0 );
|
||||
fgSizerClearances = new wxFlexGridSizer( 5, 3, 0, 0 );
|
||||
fgSizerClearances->SetFlexibleDirection( wxBOTH );
|
||||
fgSizerClearances->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
|
|
|
@ -1466,7 +1466,7 @@
|
|||
<property name="name">fgSizerClearances</property>
|
||||
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="rows">3</property>
|
||||
<property name="rows">5</property>
|
||||
<property name="vgap">0</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
|
|
Loading…
Reference in New Issue