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

3d-viewer: code cleaning; bitmap2component: minor fix and code cleanup

parent eec819a2
...@@ -488,7 +488,7 @@ void EDA_3D_CANVAS::Redraw() ...@@ -488,7 +488,7 @@ void EDA_3D_CANVAS::Redraw()
glMateriali ( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value ); glMateriali ( GL_FRONT_AND_BACK, GL_SHININESS, shininess_value );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x ); glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, &specular.x );
if( isEnabled( FL_RENDER_TEXTURES ) && isRealisticMode() ) if( isRealisticMode() && isEnabled( FL_RENDER_TEXTURES ) )
{ {
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
} }
...@@ -684,6 +684,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) ...@@ -684,6 +684,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
bool remove_Holes = isEnabled( FL_RENDER_SHOW_HOLES_IN_ZONES ); bool remove_Holes = isEnabled( FL_RENDER_SHOW_HOLES_IN_ZONES );
bool realistic_mode = isRealisticMode(); bool realistic_mode = isRealisticMode();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
// Number of segments to convert a circle to polygon // Number of segments to convert a circle to polygon
// Boost polygon (at least v 1.54, v1.55 and previous) in very rare cases crashes // Boost polygon (at least v 1.54, v1.55 and previous) in very rare cases crashes
...@@ -886,7 +887,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) ...@@ -886,7 +887,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
bufferPolys.ImportFrom( currLayerPolyset ); bufferPolys.ImportFrom( currLayerPolyset );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, thickness,
GetPrm3DVisu().m_BiuTo3Dunits ); GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
if( isEnabled( FL_USE_COPPER_THICKNESS ) == true ) if( isEnabled( FL_USE_COPPER_THICKNESS ) == true )
{ {
...@@ -898,7 +899,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) ...@@ -898,7 +899,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if( bufferZonesPolys.GetCornersCount() ) if( bufferZonesPolys.GetCornersCount() )
Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferZonesPolys, zpos,
thickness, thickness,
GetPrm3DVisu().m_BiuTo3Dunits ); GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
throughHolesListBuilt = true; throughHolesListBuilt = true;
} }
...@@ -973,7 +974,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) ...@@ -973,7 +974,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
if( bufferPcbOutlines.GetCornersCount() ) if( bufferPcbOutlines.GetCornersCount() )
{ {
Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2.0, Draw3D_SolidHorizontalPolyPolygons( bufferPcbOutlines, zpos + board_thickness/2.0,
board_thickness, GetPrm3DVisu().m_BiuTo3Dunits ); board_thickness, GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
} }
glEndList(); glEndList();
...@@ -983,6 +984,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList) ...@@ -983,6 +984,7 @@ void EDA_3D_CANVAS::BuildBoard3DView(GLuint aBoardList, GLuint aBodyOnlyList)
void EDA_3D_CANVAS::BuildTechLayers3DView() void EDA_3D_CANVAS::BuildTechLayers3DView()
{ {
BOARD* pcb = GetBoard(); BOARD* pcb = GetBoard();
bool useTextures = isRealisticMode() && isEnabled( FL_RENDER_TEXTURES );
// Number of segments to draw a circle using segments // Number of segments to draw a circle using segments
const int segcountforcircle = 18; const int segcountforcircle = 18;
...@@ -1185,7 +1187,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView() ...@@ -1185,7 +1187,7 @@ void EDA_3D_CANVAS::BuildTechLayers3DView()
setGLTechLayersColor( layer ); setGLTechLayersColor( layer );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, GetPrm3DVisu().m_BiuTo3Dunits ); thickness, GetPrm3DVisu().m_BiuTo3Dunits, useTextures );
} }
} }
...@@ -1287,7 +1289,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers() ...@@ -1287,7 +1289,7 @@ void EDA_3D_CANVAS::BuildBoard3DAuxLayers()
setGLTechLayersColor( layer ); setGLTechLayersColor( layer );
glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) );
Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos,
thickness, GetPrm3DVisu().m_BiuTo3Dunits ); thickness, GetPrm3DVisu().m_BiuTo3Dunits, false );
} }
} }
......
...@@ -42,6 +42,12 @@ ...@@ -42,6 +42,12 @@
#define CALLBACK #define CALLBACK
#endif #endif
// Variables used to pass a value to call back openGL functions
static float s_textureScale;
static double s_currentZpos;
static double s_biuTo3Dunits;
bool s_useTextures;
// CALLBACK functions for GLU_TESS // CALLBACK functions for GLU_TESS
static void CALLBACK tessBeginCB( GLenum which ); static void CALLBACK tessBeginCB( GLenum which );
static void CALLBACK tessEndCB(); static void CALLBACK tessEndCB();
...@@ -136,13 +142,11 @@ void SetGLColor( S3D_COLOR& aColor, float aTransparency ) ...@@ -136,13 +142,11 @@ void SetGLColor( S3D_COLOR& aColor, float aTransparency )
} }
static float m_texture_scale;
void SetGLTexture( GLuint text_id, float scale ) void SetGLTexture( GLuint text_id, float scale )
{ {
glEnable( GL_TEXTURE_2D ); glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, text_id ); glBindTexture( GL_TEXTURE_2D, text_id );
m_texture_scale = scale; s_textureScale = scale; // for Tess callback functions
} }
...@@ -155,8 +159,13 @@ void SetGLTexture( GLuint text_id, float scale ) ...@@ -155,8 +159,13 @@ void SetGLTexture( GLuint text_id, float scale )
* The bottom side is located at aZpos - aThickness / 2 * The bottom side is located at aZpos - aThickness / 2
*/ */
void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits ) int aZpos, int aThickness, double aBiuTo3DUnits,
bool aUseTextures )
{ {
// for Tess callback functions:
s_biuTo3Dunits = aBiuTo3DUnits;
s_useTextures = aUseTextures;
GLUtesselator* tess = gluNewTess(); GLUtesselator* tess = gluNewTess();
gluTessCallback( tess, GLU_TESS_BEGIN, ( void (CALLBACK*) () )tessBeginCB ); gluTessCallback( tess, GLU_TESS_BEGIN, ( void (CALLBACK*) () )tessBeginCB );
...@@ -166,7 +175,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -166,7 +175,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
GLdouble v_data[3]; GLdouble v_data[3];
double zpos = ( aZpos + (aThickness / 2.0) ) * aBiuTo3DUnits; double zpos = ( aZpos + (aThickness / 2.0) ) * aBiuTo3DUnits;
g_Parm_3D_Visu.m_CurrentZpos = zpos; s_currentZpos = zpos; // for Tess callback functions
v_data[2] = aZpos + (aThickness / 2.0); v_data[2] = aZpos + (aThickness / 2.0);
// Set normal toward positive Z axis, for a solid object on the top side // Set normal toward positive Z axis, for a solid object on the top side
...@@ -219,7 +228,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -219,7 +228,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
// Prepare the bottom side of solid areas // Prepare the bottom side of solid areas
zpos = ( aZpos - (aThickness / 2.0) ) * aBiuTo3DUnits; zpos = ( aZpos - (aThickness / 2.0) ) * aBiuTo3DUnits;
g_Parm_3D_Visu.m_CurrentZpos = zpos; s_currentZpos = zpos; // for Tess callback functions
v_data[2] = zpos; v_data[2] = zpos;
// Set normal toward negative Z axis, for a solid object on bottom side // Set normal toward negative Z axis, for a solid object on bottom side
SetNormalZneg(); SetNormalZneg();
...@@ -249,12 +258,12 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -249,12 +258,12 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
*/ */
void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList, void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, int aZpos, int aThickness,
double aBiuTo3DUnits ) double aBiuTo3DUnits, bool aUseTextures )
{ {
CPOLYGONS_LIST polygon; CPOLYGONS_LIST polygon;
ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon ); ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon );
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits, aUseTextures );
} }
...@@ -301,13 +310,13 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, ...@@ -301,13 +310,13 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius,
ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon );
// draw top (front) horizontal ring // draw top (front) horizontal ring
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits, false );
if( aHeight ) if( aHeight )
{ {
// draw bottom (back) horizontal ring // draw bottom (back) horizontal ring
SetNormalZneg(); SetNormalZneg();
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits, false );
} }
} }
...@@ -361,13 +370,13 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, ...@@ -361,13 +370,13 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos,
// draw top (front) horizontal side (ring) // draw top (front) horizontal side (ring)
SetNormalZpos(); SetNormalZpos();
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos + aHeight, 0, aBiuTo3DUnits, false );
if( aHeight ) if( aHeight )
{ {
// draw bottom (back) horizontal side (ring) // draw bottom (back) horizontal side (ring)
SetNormalZneg(); SetNormalZneg();
Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, 0, aBiuTo3DUnits, false );
} }
} }
...@@ -389,7 +398,7 @@ void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd, ...@@ -389,7 +398,7 @@ void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd,
TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth ); TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth );
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits, false );
} }
...@@ -403,7 +412,7 @@ void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint, ...@@ -403,7 +412,7 @@ void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint,
TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle, TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle,
slice, aWidth ); slice, aWidth );
Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( cornerBuffer, aZpos, aThickness, aBiuTo3DUnits, false );
} }
...@@ -428,15 +437,13 @@ void CALLBACK tessCPolyPt2Vertex( const GLvoid* data ) ...@@ -428,15 +437,13 @@ void CALLBACK tessCPolyPt2Vertex( const GLvoid* data )
// cast back to double type // cast back to double type
const CPolyPt* ptr = (const CPolyPt*) data; const CPolyPt* ptr = (const CPolyPt*) data;
if( g_Parm_3D_Visu.IsRealisticMode() && g_Parm_3D_Visu.GetFlag( FL_RENDER_TEXTURES ) ) if( s_useTextures )
{ {
glTexCoord2f( ptr->x* g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale, glTexCoord2f( ptr->x * s_biuTo3Dunits * s_textureScale,
-ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits * m_texture_scale); -ptr->y * s_biuTo3Dunits * s_textureScale);
} }
glVertex3d( ptr->x * g_Parm_3D_Visu.m_BiuTo3Dunits, glVertex3d( ptr->x * s_biuTo3Dunits, -ptr->y * s_biuTo3Dunits, s_currentZpos );
-ptr->y * g_Parm_3D_Visu.m_BiuTo3Dunits,
g_Parm_3D_Visu.m_CurrentZpos );
} }
......
...@@ -36,13 +36,15 @@ ...@@ -36,13 +36,15 @@
* @param aZpos = z position in board internal units * @param aZpos = z position in board internal units
* @param aThickness = thickness in board internal units * @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value * @param aBiuTo3DUnits = board internal units to 3D units scaling value
* @param aUseTextures = true to use textxures for the polygons
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos. * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness > 0, a solid object is drawn. * If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2 * The bottom side is located at aZpos - aThickness / 2
*/ */
void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits ); int aZpos, int aThickness, double aBiuTo3DUnits,
bool aUseTextures );
/** draw the solid polygon found in aPolysList /** draw the solid polygon found in aPolysList
* The first polygonj is the main polygon, others are holes * The first polygonj is the main polygon, others are holes
...@@ -50,13 +52,15 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, ...@@ -50,13 +52,15 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
* @param aZpos = z position in board internal units * @param aZpos = z position in board internal units
* @param aThickness = thickness in board internal units * @param aThickness = thickness in board internal units
* @param aBiuTo3DUnits = board internal units to 3D units scaling value * @param aBiuTo3DUnits = board internal units to 3D units scaling value
* @param aUseTextures = true to use textxures for the polygons
* If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos. * If aThickness = 0, a polygon area is drawn in a XY plane at Z position = aZpos.
* If aThickness > 0, a solid object is drawn. * If aThickness > 0, a solid object is drawn.
* The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2
* The bottom side is located at aZpos - aThickness / 2 * The bottom side is located at aZpos - aThickness / 2
*/ */
void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList, void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList,
int aZpos, int aThickness, double aBiuTo3DUnits ); int aZpos, int aThickness, double aBiuTo3DUnits,
bool aUseTextures );
/** draw a thick segment using 3D primitives, in a XY plane /** draw a thick segment using 3D primitives, in a XY plane
* @param aStart = YX position of start point in board units * @param aStart = YX position of start point in board units
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#ifdef USE_OPENMP #ifdef USE_OPENMP
#include <omp.h> #include <omp.h>
#endif /* USE_OPENMP */ #endif // USE_OPENMP
S3D_MESH::S3D_MESH() S3D_MESH::S3D_MESH()
{ {
......
...@@ -104,9 +104,7 @@ public: ...@@ -104,9 +104,7 @@ public:
double m_BiuTo3Dunits; // Normalization scale to convert board double m_BiuTo3Dunits; // Normalization scale to convert board
// internal units to 3D units // internal units to 3D units
// to scale 3D units between -1.0 and +1.0 // to normalize 3D units between -1.0 and +1.0
double m_CurrentZpos; // temporary storage of current value of Z position,
// used in some calculation
double zpos_offset; double zpos_offset;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <wxstruct.h> #include <wxstruct.h>
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <wildcards_and_files_ext.h>
#include <bitmap2cmp_gui_base.h> #include <bitmap2cmp_gui_base.h>
#include <bitmap2component.h> #include <bitmap2component.h>
...@@ -278,14 +279,7 @@ bool BM2CMP_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int ...@@ -278,14 +279,7 @@ bool BM2CMP_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int
if( !m_Pict_Image.LoadFile( m_BitmapFileName ) ) if( !m_Pict_Image.LoadFile( m_BitmapFileName ) )
{ {
/* LoadFile has its own UI, no need for further failure notification here // LoadFile has its own UI, no need for further failure notification here
wxString msg = wxString::Format(
_( "Could not load image '%s'" ),
GetChars( aFilename )
);
wxMessageBox( msg );
*/
return false; return false;
} }
...@@ -468,25 +462,18 @@ void BM2CMP_FRAME::OnExportLogo() ...@@ -468,25 +462,18 @@ void BM2CMP_FRAME::OnExportLogo()
if( path.IsEmpty() || !wxDirExists(path) ) if( path.IsEmpty() || !wxDirExists(path) )
path = ::wxGetCwd(); path = ::wxGetCwd();
wxString msg = _( "Logo file (*.kicad_wks)|*.kicad_wks" ); wxFileDialog fileDlg( this, _( "Create a logo file" ),
wxFileDialog fileDlg( this, _( "Create a logo file" ), path, wxEmptyString, path, wxEmptyString,
msg, wxGetTranslation( PageLayoutDescrFileWildcard ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = fileDlg.ShowModal(); int diag = fileDlg.ShowModal();
if( diag != wxID_OK ) if( diag != wxID_OK )
return; return;
m_ConvertedFileName = fileDlg.GetPath(); fn = fileDlg.GetPath();
fn.SetExt( PageLayoutDescrFileExtension );
if( m_ConvertedFileName.size() > 1 m_ConvertedFileName = fn.GetFullPath();
&& m_ConvertedFileName.Right( 10 ).compare( _( ".kicad_wks") ) )
{
if( m_ConvertedFileName.Right( 1 ).compare( _( "." ) ) )
m_ConvertedFileName += _( ".kicad_wks" );
else
m_ConvertedFileName += _( "kicad_wks" );
}
FILE* outfile; FILE* outfile;
outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
...@@ -494,7 +481,7 @@ void BM2CMP_FRAME::OnExportLogo() ...@@ -494,7 +481,7 @@ void BM2CMP_FRAME::OnExportLogo()
if( outfile == NULL ) if( outfile == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); msg.Printf( _( "File '%s' could not be created" ), GetChars(m_ConvertedFileName) );
wxMessageBox( msg ); wxMessageBox( msg );
return; return;
} }
...@@ -512,9 +499,9 @@ void BM2CMP_FRAME::OnExportPostScript() ...@@ -512,9 +499,9 @@ void BM2CMP_FRAME::OnExportPostScript()
if( path.IsEmpty() || !wxDirExists( path ) ) if( path.IsEmpty() || !wxDirExists( path ) )
path = ::wxGetCwd(); path = ::wxGetCwd();
wxString msg = _( "Postscript file (*.ps)|*.ps" ); wxFileDialog fileDlg( this, _( "Create a Postscript file" ),
wxFileDialog fileDlg( this, _( "Create a Postscript file" ), path, wxEmptyString, path, wxEmptyString,
msg, wxGetTranslation( PSFileWildcard ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = fileDlg.ShowModal(); int diag = fileDlg.ShowModal();
...@@ -522,16 +509,9 @@ void BM2CMP_FRAME::OnExportPostScript() ...@@ -522,16 +509,9 @@ void BM2CMP_FRAME::OnExportPostScript()
if( diag != wxID_OK ) if( diag != wxID_OK )
return; return;
m_ConvertedFileName = fileDlg.GetPath(); fn = fileDlg.GetPath();
fn.SetExt( wxT( "ps" ) );
if( m_ConvertedFileName.size() > 1 m_ConvertedFileName = fn.GetFullPath();
&& m_ConvertedFileName.Right( 3 ).compare( _( ".ps") ) )
{
if( m_ConvertedFileName.Right( 1 ).compare( _( "." ) ) )
m_ConvertedFileName += _( ".ps" );
else
m_ConvertedFileName += _( "ps" );
}
FILE* outfile; FILE* outfile;
outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
...@@ -539,7 +519,7 @@ void BM2CMP_FRAME::OnExportPostScript() ...@@ -539,7 +519,7 @@ void BM2CMP_FRAME::OnExportPostScript()
if( outfile == NULL ) if( outfile == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); msg.Printf( _( "File '%s' could not be created" ), GetChars( m_ConvertedFileName ) );
wxMessageBox( msg ); wxMessageBox( msg );
return; return;
} }
...@@ -557,10 +537,9 @@ void BM2CMP_FRAME::OnExportEeschema() ...@@ -557,10 +537,9 @@ void BM2CMP_FRAME::OnExportEeschema()
if( path.IsEmpty() || !wxDirExists(path) ) if( path.IsEmpty() || !wxDirExists(path) )
path = ::wxGetCwd(); path = ::wxGetCwd();
wxString msg = _( "Schematic lib file (*.lib)|*.lib" ); wxFileDialog fileDlg( this, _( "Create a lib file for Eeschema" ),
path, wxEmptyString,
wxFileDialog fileDlg( this, _( "Create a lib file for Eeschema" ), path, wxEmptyString, wxGetTranslation( SchematicLibraryFileWildcard ),
msg,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = fileDlg.ShowModal(); int diag = fileDlg.ShowModal();
...@@ -568,23 +547,16 @@ void BM2CMP_FRAME::OnExportEeschema() ...@@ -568,23 +547,16 @@ void BM2CMP_FRAME::OnExportEeschema()
if( diag != wxID_OK ) if( diag != wxID_OK )
return; return;
m_ConvertedFileName = fileDlg.GetPath(); fn = fileDlg.GetPath();
fn.SetExt( SchematicLibraryFileExtension );
if( m_ConvertedFileName.size() > 1 m_ConvertedFileName = fn.GetFullPath();
&& m_ConvertedFileName.Right( 4 ).compare( _( ".lib") ) )
{
if( m_ConvertedFileName.Right( 1 ).compare( _( "." ) ) )
m_ConvertedFileName += _( ".lib" );
else
m_ConvertedFileName += _( "lib" );
}
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL ) if( outfile == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); msg.Printf( _( "File '%s' could not be created" ), GetChars( m_ConvertedFileName ) );
wxMessageBox( msg ); wxMessageBox( msg );
return; return;
} }
...@@ -602,11 +574,9 @@ void BM2CMP_FRAME::OnExportPcbnew() ...@@ -602,11 +574,9 @@ void BM2CMP_FRAME::OnExportPcbnew()
if( path.IsEmpty() || !wxDirExists( path ) ) if( path.IsEmpty() || !wxDirExists( path ) )
path = ::wxGetCwd(); path = ::wxGetCwd();
wxString msg = _( "Footprint file (*.kicad_mod)|*.kicad_mod" );
wxFileDialog fileDlg( this, _( "Create a footprint file for PcbNew" ), wxFileDialog fileDlg( this, _( "Create a footprint file for PcbNew" ),
path, wxEmptyString, path, wxEmptyString,
msg, wxGetTranslation( KiCadFootprintLibFileWildcard ),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
int diag = fileDlg.ShowModal(); int diag = fileDlg.ShowModal();
...@@ -614,23 +584,16 @@ void BM2CMP_FRAME::OnExportPcbnew() ...@@ -614,23 +584,16 @@ void BM2CMP_FRAME::OnExportPcbnew()
if( diag != wxID_OK ) if( diag != wxID_OK )
return; return;
m_ConvertedFileName = fileDlg.GetPath(); fn = fileDlg.GetPath();
fn.SetExt( KiCadFootprintFileExtension );
if( m_ConvertedFileName.size() > 1 m_ConvertedFileName = fn.GetFullPath();
&& m_ConvertedFileName.Right( 10 ).compare( _( ".kicad_mod") ) )
{
if( m_ConvertedFileName.Right( 1 ).compare( _( "." ) ) )
m_ConvertedFileName += _( ".kicad_mod" );
else
m_ConvertedFileName += _( "kicad_mod" );
}
FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) ); FILE* outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL ) if( outfile == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() ); msg.Printf( _( "File '%s' could not be created" ), GetChars( m_ConvertedFileName ) );
wxMessageBox( msg ); wxMessageBox( msg );
return; return;
} }
......
...@@ -75,7 +75,7 @@ const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.b ...@@ -75,7 +75,7 @@ const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.b
const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) ); const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.brd" ) );
const wxString PCadPcbFileWildcard( _( "P-Cad 200x ASCII PCB files (*.pcb)|*.pcb" ) ); const wxString PCadPcbFileWildcard( _( "P-Cad 200x ASCII PCB files (*.pcb)|*.pcb" ) );
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) ); const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) );
const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) ); const wxString KiCadFootprintLibFileWildcard( _( "KiCad footprint s-expre file (*.kicad_mod)|*.kicad_mod" ) );
const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) ); const wxString KiCadFootprintLibPathWildcard( _( "KiCad footprint s-expre library path (*.pretty)|*.pretty" ) );
const wxString LegacyFootprintLibPathWildcard( _( "Legacy footprint library file (*.mod)|*.mod" ) ); const wxString LegacyFootprintLibPathWildcard( _( "Legacy footprint library file (*.mod)|*.mod" ) );
const wxString EagleFootprintLibPathWildcard( _( "Eagle ver. 6.x XML library files (*.lbr)|*.lbr" ) ); const wxString EagleFootprintLibPathWildcard( _( "Eagle ver. 6.x XML library files (*.lbr)|*.lbr" ) );
......
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