Commit d979a35d authored by jean-pierre charras's avatar jean-pierre charras

3D view: now displays polygons used in footprint shapes, like logos.

Removed useless messages in debug mode.
Fixed very minor issues (minor warnings in debug mode)
3D export: Added patch from Lorenzo Marcantonio.
Fixed issue in VRML export dialog.
parents 92d58ffe 3820154a
......@@ -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,14 +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;
D( printf( "Tess gluTessVertex(%f,%f,%f)\n", v_data[0], v_data[1], v_data[2] ); )
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 )
......@@ -468,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 );
......@@ -492,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];
......@@ -511,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;
......@@ -597,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 );
......@@ -643,19 +644,6 @@ void MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
{
D_PAD* pad = m_Pads;
#if 0
if( !DisplayOpt.Show_Modules_Cmp )
{
if( m_Layer == LAYER_N_FRONT )
return;
}
if( !DisplayOpt.Show_Modules_Cu )
{
if( m_Layer == LAYER_N_BACK )
return;
}
#endif
/* Draw pads */
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
glNormal3f( 0.0, 0.0, 1.0 ); // Normal is Z axis
......@@ -726,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;
......@@ -762,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 ) ); )
......@@ -839,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;
......@@ -891,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 )
......@@ -935,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 )
......@@ -969,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 )
......@@ -1212,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
......@@ -1226,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 );
}
......@@ -1262,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;
......@@ -1302,32 +1349,32 @@ static GLfloat Get3DLayerSide( int act_layer )
void CALLBACK tessBeginCB( GLenum which )
{
glBegin( which );
// DEBUG //
D( printf( "Tess glBegin()\n" ); )
}
void CALLBACK tessEndCB()
{
glEnd();
// DEBUG //
D( printf( "Tess glEnd()\n" ); )
}
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 );
}
// DEBUG //
D( printf( "TessVertex glVertex3d(%d,%d,%f)\n", (*ptr).x, (*ptr).y, 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>
......
......@@ -24,7 +24,7 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow
m_staticText1->Wrap( -1 );
bUpperSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Save VRML Board File"), wxT("*.wrl"), wxDefaultPosition, wxDefaultSize, wxFLP_DEFAULT_STYLE|wxFLP_SAVE );
m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Save VRML Board File"), wxT("*.wrl"), wxDefaultPosition, wxDefaultSize, wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
bUpperSizer->Add( m_filePicker, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_staticText3 = new wxStaticText( this, wxID_ANY, _("Vrml 3D footprints shapes subdir:"), wxDefaultPosition, wxDefaultSize, 0 );
......
......@@ -154,7 +154,7 @@
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxFLP_DEFAULT_STYLE|wxFLP_SAVE</property>
<property name="style">wxFLP_SAVE|wxFLP_USE_TEXTCTRL</property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="value"></property>
......
......@@ -1085,7 +1085,7 @@ static void export_vrml_module( BOARD* aPcb, MODULE* aModule,
-vrmlm->m_MatPosition.y - aModule->m_Pos.y,
vrmlm->m_MatPosition.z + layer_z[aModule->GetLayer()] );
fprintf( aOutputFile,
" children [\n Inline {\n url [ \"%s\" ]\n } ]\n",
" children [\n Inline {\n url \"%s\"\n } ]\n",
CONV_TO_UTF8( fname ) );
fprintf( aOutputFile, " }\n" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment