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

minor enhancements. Fixing a crash in build_BOM.cpp (temporary fix, until Dick...

minor enhancements. Fixing a crash in build_BOM.cpp (temporary fix, until Dick finishes fields rework)
parents fcbcb640 00008579
...@@ -106,9 +106,9 @@ Installation from source code ...@@ -106,9 +106,9 @@ Installation from source code
Some dependencies must be satisfied for the correct installation of KiCad: Some dependencies must be satisfied for the correct installation of KiCad:
wxWidgets >= 2.6.3.3 http://www.wxwidgets.org/ wxWidgets >= 2.8.11 http://www.wxwidgets.org/
CMake >= 2.4.6 http://www.cmake.org/ CMake >= 2.6.4 http://www.cmake.org/
Boost C++ Libraries http://www.boost.org/ Boost C++ Libraries (files used by kicad are provided in kicad sources) http://www.boost.org/
OpenGL OpenGL
Linux: Mesa 3D Graphics Library http://www.mesa3d.org/ Linux: Mesa 3D Graphics Library http://www.mesa3d.org/
Windows: built-in Windows: built-in
......
...@@ -9,7 +9,17 @@ set(BITMAP2COMPONENT_SRCS ...@@ -9,7 +9,17 @@ set(BITMAP2COMPONENT_SRCS
bitmap2cmp_gui bitmap2cmp_gui
) )
add_executable(bitmap2component WIN32 MACOSX_BUNDLE ${BITMAP2COMPONENT_SRCS} ${BITMAP2COMPONENT_RESOURCES}) if(WIN32)
if(MINGW)
# BITMAP2COMPONENT_RESOURCES variable is set by the macro.
mingw_resource_compiler(bitmap2component)
else(MINGW)
set(BITMAP2COMPONENT_RESOURCES bitmap2component.rc)
endif(MINGW)
endif(WIN32)
add_executable(bitmap2component WIN32 MACOSX_BUNDLE
${BITMAP2COMPONENT_SRCS}
${BITMAP2COMPONENT_RESOURCES})
target_link_libraries( bitmap2component target_link_libraries( bitmap2component
......
...@@ -23,17 +23,22 @@ ...@@ -23,17 +23,22 @@
*/ */
#include "wx/wx.h" #include "wx/wx.h"
#include "wx/config.h" #include "wx/config.h"
#include "wx/filename.h"
#include "bitmap2cmp_gui_base.h" #include "bitmap2cmp_gui_base.h"
#include "potracelib.h" #include "potracelib.h"
#include "bitmap_io.h" #include "bitmap_io.h"
#include "bitmap2component.xpm"
#define KEYWORD_FRAME_POSX wxT( "bmconverter_Pos_x" )
#define KEYWORD_FRAME_POSY wxT( "bmconverter_Pos_y" ) #define KEYWORD_FRAME_POSX wxT( "Bmconverter_Pos_x" )
#define KEYWORD_FRAME_SIZEX wxT( "bmconverter_Size_x" ) #define KEYWORD_FRAME_POSY wxT( "Bmconverter_Pos_y" )
#define KEYWORD_FRAME_SIZEY wxT( "bmconverter_Size_y" ) #define KEYWORD_FRAME_SIZEX wxT( "Bmconverter_Size_x" )
#define KEYWORD_FRAME_SIZEY wxT( "Bmconverter_Size_y" )
#define KEYWORD_LAST_INPUT_FILE wxT( "Last_input" )
#define KEYWORD_LAST_OUTPUT_FILE wxT( "Last_output" )
extern int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile, int aFormat ); extern int bitmap2component( potrace_bitmap_t* aPotrace_bitmap, FILE* aOutfile, int aFormat );
...@@ -49,7 +54,8 @@ private: ...@@ -49,7 +54,8 @@ private:
wxBitmap m_Greyscale_Bitmap; wxBitmap m_Greyscale_Bitmap;
wxImage m_NB_Image; wxImage m_NB_Image;
wxBitmap m_BN_Bitmap; wxBitmap m_BN_Bitmap;
wxString m_ImgFileName; wxString m_BitmapFileName;
wxString m_ConvertedFileName;
wxSize m_FrameSize; wxSize m_FrameSize;
wxPoint m_FramePos; wxPoint m_FramePos;
wxConfig * m_Config; wxConfig * m_Config;
...@@ -72,7 +78,6 @@ private: ...@@ -72,7 +78,6 @@ private:
void ExportFile( FILE* aOutfile, int aFormat ); void ExportFile( FILE* aOutfile, int aFormat );
}; };
BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
{ {
m_Config = new wxConfig(); m_Config = new wxConfig();
...@@ -80,11 +85,18 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL ) ...@@ -80,11 +85,18 @@ BM2CMP_FRAME::BM2CMP_FRAME() : BM2CMP_FRAME_BASE( NULL )
m_Config->Read( KEYWORD_FRAME_POSY, & m_FramePos.y, -1 ); m_Config->Read( KEYWORD_FRAME_POSY, & m_FramePos.y, -1 );
m_Config->Read( KEYWORD_FRAME_SIZEX, & m_FrameSize.x, -1 ); m_Config->Read( KEYWORD_FRAME_SIZEX, & m_FrameSize.x, -1 );
m_Config->Read( KEYWORD_FRAME_SIZEY, & m_FrameSize.y, -1 ); m_Config->Read( KEYWORD_FRAME_SIZEY, & m_FrameSize.y, -1 );
m_Config->Read( KEYWORD_LAST_INPUT_FILE, &m_BitmapFileName );
m_Config->Read( KEYWORD_LAST_OUTPUT_FILE, &m_ConvertedFileName );
#ifdef __WINDOWS__
SetIcon( wxICON( bitmap2component_icon ) );
#else
SetIcon( wxICON( bitmap2component ) );
#endif
wxString msg( wxT( " 0000 " ) ); wxString msg( wxT( "000000" ) );
m_gridInfo->SetCellValue( 0, 0, msg );
m_gridInfo->SetCellValue( 1, 0, msg ); m_gridInfo->SetCellValue( 1, 0, msg );
m_gridInfo->SetCellValue( 2, 0, msg );
if( GetSizer() ) if( GetSizer() )
{ {
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
...@@ -108,6 +120,8 @@ BM2CMP_FRAME::~BM2CMP_FRAME() ...@@ -108,6 +120,8 @@ BM2CMP_FRAME::~BM2CMP_FRAME()
m_Config->Write( KEYWORD_FRAME_POSY, (long) m_FramePos.y ); m_Config->Write( KEYWORD_FRAME_POSY, (long) m_FramePos.y );
m_Config->Write( KEYWORD_FRAME_SIZEX, (long) m_FrameSize.x ); m_Config->Write( KEYWORD_FRAME_SIZEX, (long) m_FrameSize.x );
m_Config->Write( KEYWORD_FRAME_SIZEY, (long) m_FrameSize.y ); m_Config->Write( KEYWORD_FRAME_SIZEY, (long) m_FrameSize.y );
m_Config->Write( KEYWORD_LAST_INPUT_FILE, m_BitmapFileName );
m_Config->Write( KEYWORD_LAST_OUTPUT_FILE, m_ConvertedFileName );
delete m_Config; delete m_Config;
...@@ -136,18 +150,24 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event ) ...@@ -136,18 +150,24 @@ void BM2CMP_FRAME::OnPaint( wxPaintEvent& event )
*/ */
void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event ) void BM2CMP_FRAME::OnLoadFile( wxCommandEvent& event )
{ {
wxFileDialog FileDlg( this, _( "Choose Image" ), ::wxGetCwd(), wxEmptyString, wxFileName fn(m_BitmapFileName);
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
path = wxGetCwd();
wxFileDialog FileDlg( this, _( "Choose Image" ), path, wxEmptyString,
_( "Image Files " ) + wxImage::GetImageExtWildcard(), _( "Image Files " ) + wxImage::GetImageExtWildcard(),
wxFD_OPEN ); wxFD_OPEN );
int diag = FileDlg.ShowModal(); int diag = FileDlg.ShowModal();
if( diag != wxID_OK ) if( diag != wxID_OK )
return; return;
m_ImgFileName = FileDlg.GetPath();
if( !m_Pict_Image.LoadFile( m_ImgFileName ) ) m_BitmapFileName = FileDlg.GetPath();
if( !m_Pict_Image.LoadFile( m_BitmapFileName ) )
{ {
wxMessageBox( _( "Couldn't load image from '%s'." ), m_ImgFileName.c_str() ); wxMessageBox( _( "Couldn't load image from <%s>" ), m_BitmapFileName.c_str() );
return; return;
} }
...@@ -236,22 +256,26 @@ void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event ) ...@@ -236,22 +256,26 @@ void BM2CMP_FRAME::OnThresholdChange( wxScrollEvent& event )
void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event )
{ {
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
path = ::wxGetCwd();
wxString msg = _( "Schematic lib file (*.lib)|*.lib" ); wxString msg = _( "Schematic lib file (*.lib)|*.lib" );
wxFileDialog FileDlg( this, _( "Create lib file" ), ::wxGetCwd(), wxEmptyString, wxFileDialog FileDlg( this, _( "Create lib file" ), path, wxEmptyString,
msg, msg,
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;
wxString filename = FileDlg.GetPath(); m_ConvertedFileName = FileDlg.GetPath();
FILE* outfile; FILE* outfile;
outfile = wxFopen( filename, wxT( "w" ) ); outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL ) if( outfile == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s could not be created" ), filename.c_str() ); msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() );
wxMessageBox( msg ); wxMessageBox( msg );
return; return;
} }
...@@ -263,22 +287,26 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event ) ...@@ -263,22 +287,26 @@ void BM2CMP_FRAME::OnExportEeschema( wxCommandEvent& event )
void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event ) void BM2CMP_FRAME::OnExportPcbnew( wxCommandEvent& event )
{ {
wxFileName fn(m_ConvertedFileName);
wxString path = fn.GetPath();
if( path.IsEmpty() || !wxDirExists(path) )
path = ::wxGetCwd();
wxString msg = _( "Footprint export file (*.emp)|*.emp" ); wxString msg = _( "Footprint export file (*.emp)|*.emp" );
wxFileDialog FileDlg( this, _( "Create footprint export file" ), ::wxGetCwd(), wxEmptyString, wxFileDialog FileDlg( this, _( "Create footprint export file" ), path, wxEmptyString,
msg, msg,
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;
wxString filename = FileDlg.GetPath(); m_ConvertedFileName = FileDlg.GetPath();
FILE* outfile; FILE* outfile;
outfile = wxFopen( filename, wxT( "w" ) ); outfile = wxFopen( m_ConvertedFileName, wxT( "w" ) );
if( outfile == NULL ) if( outfile == NULL )
{ {
wxString msg; wxString msg;
msg.Printf( _( "File %s could not be created" ), filename.c_str() ); msg.Printf( _( "File %s could not be created" ), m_ConvertedFileName.c_str() );
wxMessageBox( msg ); wxMessageBox( msg );
return; return;
} }
......
...@@ -32,10 +32,8 @@ ...@@ -32,10 +32,8 @@
#include <vector> #include <vector>
#include "potracelib.h" #include "potracelib.h"
//#include "bitmap_io.h"
#include "auxiliary.h" #include "auxiliary.h"
#ifndef max #ifndef max
#define max( a, b ) ( ( (a) > (b) ) ? (a) : (b) ) #define max( a, b ) ( ( (a) > (b) ) ? (a) : (b) )
#endif #endif
......
bitmap2component_icon ICON bitmap2component.ico
#include "wx/msw/wx.rc"
/* XPM */
const char *bitmap2component_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 16 1",
"@ c #592904",
"# c #974704",
"$ c #5455D0",
"o c #090915",
"- c #2E1604",
"+ c #4B4BB5",
"* c #222352",
"X c #0F1128",
": c #BE5904",
" c #0CFA0C",
"% c #FC7A04",
"= c #323378",
"; c #753704",
"O c #3C3B8F",
"& c #DF6904",
". c #050204",
/* pixels */
" . ..",
" .",
" ",
"........................ .. ",
"........................ .. ",
" X.oO ... ",
"+++X@#.X+ $ ... .",
"...o@%&@.*$$X.o= ... ..",
"....@%%%#-..-#;.... ........",
"....@%%&%&-.#%%-.... .......",
"....@%%%%;..;%&......====O+$ ",
"....@%%:-....o..............= ",
"....@&@.... +*O ......%%%%&#.X ",
"....-..... .....%%&%%%:...",
"OO O=+ . *.%%%%%&%@X ",
" ... =.%%%%%%%#..",
" . O.%%%%&%%;.=",
".......... .....%%%%%%%-..",
"....@@..... ......%%%%%%;...",
"....@%:-....X.........###;;-.= ",
"....@%%&#...-#@...........o*$ ",
"....@%%%%&-.#%%...... $ ",
"....@%%%%#..;%%..... .......",
"....@%%&-....-..... ........",
"XXXo@%;.X+ +*=$ ... ..",
" X-.oO ... .",
" X.= ... ",
"........................ .. ",
"........................ .. ",
" ",
" .",
" . .."
};
This diff is collapsed.
...@@ -797,6 +797,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( ...@@ -797,6 +797,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart(
// Store fields. Store non empty fields only. // Store fields. Store non empty fields only.
for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ ) for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ )
{ {
//Ensure fields exists in dummy component
if( dummyCmp.GetFieldCount() <= jj )
dummyCmp.AddField( *currCmp->GetField( jj ) );
// store useful data
if( !currCmp->GetField( jj )->m_Text.IsEmpty() ) if( !currCmp->GetField( jj )->m_Text.IsEmpty() )
dummyCmp.GetField( jj )->m_Text = currCmp->GetField( jj )->m_Text; dummyCmp.GetField( jj )->m_Text = currCmp->GetField( jj )->m_Text;
} }
...@@ -845,21 +849,27 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart( ...@@ -845,21 +849,27 @@ int DIALOG_BUILD_BOM::PrintComponentsListByPart(
CONV_TO_UTF8( currCmp->GetField( DATASHEET) ->m_Text ) ); CONV_TO_UTF8( currCmp->GetField( DATASHEET) ->m_Text ) );
#endif #endif
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( RNames ) );
// print fields, on demand // print fields, on demand
for( int jj = FIELD1; jj <= FIELD8 ; jj++ ) int last_nonempty_field_idx = 0;
for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
if ( !dummyCmp.GetField( jj )->m_Text.IsEmpty() )
last_nonempty_field_idx = jj;
for( int jj = FIELD1; jj <= last_nonempty_field_idx ; jj++ )
{ {
if ( IsFieldChecked( jj ) ) if ( IsFieldChecked( jj ) )
fprintf( f, "%c%4s", s_ExportSeparatorSymbol, fprintf( f, "%c%4s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) ); CONV_TO_UTF8( dummyCmp.GetField( jj )->m_Text ) );
} }
fprintf( f, "%c%s\n", s_ExportSeparatorSymbol, fprintf( f, "\n" );
CONV_TO_UTF8( RNames ) );
// Clear strings and values, to prepare next component // Clear strings and values, to prepare next component
qty = 0; qty = 0;
RNames.Empty(); RNames.Empty();
for( int jj = FOOTPRINT; jj < currCmp->GetFieldCount(); jj++ ) for( int jj = FOOTPRINT; jj < dummyCmp.GetFieldCount(); jj++ )
dummyCmp.GetField( jj )->m_Text.Empty(); dummyCmp.GetField( jj )->m_Text.Empty();
} }
......
...@@ -194,7 +194,7 @@ bool WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsN ...@@ -194,7 +194,7 @@ bool WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsN
GetChars( fn.GetFullPath() ), GetChars( fn.GetFullPath() ),
GetChars( errMsg ) ); GetChars( errMsg ) );
DisplayError( this, prompt ); DisplayError( this, prompt );
msg += wxT( " ->Error" ); msg += _( " ->Error" );
} }
PrintMsg( msg ); PrintMsg( msg );
......
...@@ -62,7 +62,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) ...@@ -62,7 +62,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event )
else else
{ {
wxString msg; wxString msg;
msg.Printf( _( "GerbView only supports a maximum of %d layers. You must first \ msg.Printf( _( "GerbView only supports a maximum of %d layers. You must first \
delete an existing layer to load any new layers." ), NB_LAYERS ); delete an existing layer to load any new layers." ), NB_LAYERS );
wxMessageBox( msg ); wxMessageBox( msg );
} }
......
...@@ -204,8 +204,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) ...@@ -204,8 +204,7 @@ void WinEDA_PcbFrame::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
if( PlaceModulesHorsPcb && !EdgeExists ) if( PlaceModulesHorsPcb && !EdgeExists )
{ {
DisplayError( this, DisplayError( this,
_( "Could not automatically place modules. No board \ _( "Could not automatically place modules. No board outlines detected." ) );
edges detected." ) );
return; return;
} }
......
...@@ -105,12 +105,10 @@ EDA_Rect EDGE_MODULE::GetBoundingBox() ...@@ -105,12 +105,10 @@ EDA_Rect EDGE_MODULE::GetBoundingBox()
if( Module ) if( Module )
{ {
RotatePoint( &pt.x, &pt.y, Module->m_Orient ); RotatePoint( &pt.x, &pt.y, Module->m_Orient );
pt.x += Module->m_Pos.x; pt += Module->m_Pos;
pt.y += Module->m_Pos.y;
} }
pt.x += m_Start0.x; pt += m_Start0;
pt.y += m_Start0.y;
bbox.m_Pos.x = MIN( bbox.m_Pos.x, pt.x ); bbox.m_Pos.x = MIN( bbox.m_Pos.x, pt.x );
bbox.m_Pos.y = MIN( bbox.m_Pos.y, pt.y ); bbox.m_Pos.y = MIN( bbox.m_Pos.y, pt.y );
p_end.x = MAX( p_end.x, pt.x ); p_end.x = MAX( p_end.x, pt.x );
......
...@@ -58,7 +58,7 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con ...@@ -58,7 +58,7 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con
int m_Choice_Drill_MapNChoices = sizeof( m_Choice_Drill_MapChoices ) / sizeof( wxString ); int m_Choice_Drill_MapNChoices = sizeof( m_Choice_Drill_MapChoices ) / sizeof( wxString );
m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Drill Sheet:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS ); m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Drill Sheet:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Map->SetSelection( 0 ); m_Choice_Drill_Map->SetSelection( 0 );
m_Choice_Drill_Map->SetToolTip( _("Creates a drill map in PSr HPGL or others formats") ); m_Choice_Drill_Map->SetToolTip( _("Creates a drill map in PS, HPGL or others formats") );
bMiddleBoxSizer->Add( m_Choice_Drill_Map, 0, wxALL|wxEXPAND, 5 ); bMiddleBoxSizer->Add( m_Choice_Drill_Map, 0, wxALL|wxEXPAND, 5 );
......
...@@ -335,7 +335,7 @@ ...@@ -335,7 +335,7 @@
<property name="size"></property> <property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property> <property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="tooltip">Creates a drill map in PSr HPGL or others formats</property> <property name="tooltip">Creates a drill map in PS, HPGL or others formats</property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
......
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