From 157298ba5b67be6d4e0720bb09a7e0b10f4f8f56 Mon Sep 17 00:00:00 2001 From: charras Date: Wed, 12 Mar 2008 11:49:16 +0000 Subject: [PATCH] minor changes --- pcbnew/gpcb_exchange.cpp | 6 ++-- pcbnew/librairi.cpp | 62 +++++++++++++++++++++++++++-------- polygon/math_for_graphics.cpp | 6 ++-- polygon/math_for_graphics.h | 4 +-- 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/pcbnew/gpcb_exchange.cpp b/pcbnew/gpcb_exchange.cpp index 70fb13c6ee..fbeb49f1b7 100644 --- a/pcbnew/gpcb_exchange.cpp +++ b/pcbnew/gpcb_exchange.cpp @@ -198,16 +198,16 @@ bool MODULE::Read_GPCB_Descr( const wxString& CmpFullFileName ) iprmcnt++; m_Doc = params[iprmcnt]; - // Read pcb-name (unused ) + // Read pcb-name (reference ) iprmcnt++; + m_Reference->m_Text = params[iprmcnt]; // Read value iprmcnt++; m_Value->m_Text = params[iprmcnt]; - iprmcnt++; - // Read other infos + iprmcnt++; for( int ii = 0; ii < 6; ii++ ) { if( iprmcnt < icnt_max ) diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 2800e4e37b..96490a9fd7 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -24,7 +24,7 @@ #define OLD_EXT wxT( ".bak" ) #define FILETMP_EXT wxT( ".$$$" ) - +#define EXPORT_IMPORT_LASTPATH_KEY wxT("import_last_path") /* Fonctions locales */ static bool CreateDocLibrary( const wxString& LibName ); @@ -33,9 +33,15 @@ static bool CreateDocLibrary( const wxString& LibName ); MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) /*********************************************************/ -/* - * Importation de modules Hors librairie - * Lit 1 fichier type Empreinte et place le module sur PCB +/** + * Function Import_Module + * Read a file containing only one footprint. + * Used to import (after exporting) a footprint + * Exported files have the standart ext .emp + * This is the same format as .mod files but restricted to only one footprint + * The import function can also read gpcb footprint file, in Newlib format + * (One footprint per file, Newlib files have no special ext.) + * @param DC = Current Device Context (can be NULL) */ { int NbLine = 0; @@ -45,10 +51,15 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) MODULE* module = NULL; bool Footprint_Is_GPCB_Format = false; wxString mask = wxT("*.*;"); mask += EXT_CMP_MASK; + wxString LastOpenedPathForLoading; + wxConfig* Config = m_Parent->m_EDA_Config; + if( Config ) + Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading ); + /* Lecture Fichier module */ CmpFullFileName = EDA_FileSelector( _( "Import Module:" ), - wxEmptyString, /* Chemin par defaut */ + LastOpenedPathForLoading, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ wxEmptyString, /* extension par defaut */ mask, /* Masque d'affichage */ @@ -67,8 +78,14 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) DisplayError( this, msg ); return NULL; } - - /* Lecture Entete */ + + if( Config ) // Save file path + { + LastOpenedPathForLoading = wxPathOnly( CmpFullFileName ); + Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading ); + } + + /* Read header and test file type */ GetLine( dest, Line, &NbLine ); if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 ) { @@ -82,7 +99,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) } } - /* Lecture du fichier: recherche du debut de la descr module */ + /* Read file: Search the description starting line (skip lib header)*/ if ( ! Footprint_Is_GPCB_Format ) { while( GetLine( dest, Line, &NbLine ) != NULL ) @@ -105,7 +122,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) fclose( dest ); } - /* Mise a jour du chainage */ + /* Insert footprint in list*/ if( m_Pcb->m_Modules ) { m_Pcb->m_Modules->Pback = module; @@ -114,7 +131,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) module->Pback = m_Pcb; m_Pcb->m_Modules = module; - /* Affichage des caracteristiques : */ + /* Display info : */ module->Display_Infos( this ); Place_Module( module, DC ); m_Pcb->m_Status_Pcb = 0; @@ -127,15 +144,23 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC ) /************************************************************************/ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) /************************************************************************/ - -/* - * Genere 1 fichier type Empreinte a partir de la description du module sur PCB +/** + * Function Export_Module + * Create a file containing only one footprint. + * Used to export a footprint + * Exported files have the standart ext .emp + * This is the same format as .mod files but restricted to only one footprint + * So Create a new lib (which will contains one module) and export a footprint is basically the same thing + * @param DC = Current Device Context (can be NULL) + * @param createlib : true = use default lib path to create lib + * false = use current path or last used path to export footprint */ { wxString FullFileName, Mask( wxT( "*" ) ); char Line[1025]; FILE* dest; wxString msg, path; + wxConfig* Config = m_Parent->m_EDA_Config; if( ptmod == NULL ) return; @@ -148,6 +173,9 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) if( createlib ) path = g_RealLibDirBuffer; + else if( Config ) + Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path ); + FullFileName = EDA_FileSelector( createlib ? _( "Create lib" ) : _( "Export Module:" ), path, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ @@ -161,7 +189,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) if( FullFileName.IsEmpty() ) return; - if( createlib && wxFileExists( FullFileName ) ) + if( wxFileExists( FullFileName ) ) { msg.Printf( _( "File %s exists, OK to replace ?" ), FullFileName.GetData() ); @@ -177,6 +205,12 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) return; } + if( ! createlib && Config ) // Save file path + { + path = wxPathOnly( FullFileName ); + Config->Write( EXPORT_IMPORT_LASTPATH_KEY, path ); + } + fprintf( dest, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) ); fputs( "$INDEX\n", dest ); diff --git a/polygon/math_for_graphics.cpp b/polygon/math_for_graphics.cpp index 724a194fe9..f77cdb6de7 100644 --- a/polygon/math_for_graphics.cpp +++ b/polygon/math_for_graphics.cpp @@ -454,7 +454,7 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int double * x1, double * y1, double * x2, double * y2, double * dist ) { - double xx, yy; + double xx = 0, yy = 0; //Init made to avoid C compil "uninitialized" warning bool bVert = false; if( b > DBL_MAX/10.0 ) bVert = true; @@ -531,7 +531,7 @@ int FindLineSegmentIntersection( double a, double b, int xi, int yi, int xf, int yyf = yf; } // find center and radii of ellipse - double xo, yo, rx, ry; + double xo = xxf, yo = yyi, rx, ry; // Init made to avoid C compil warnings if( xxf > xxi && yyf > yyi ) { xo = xxf; @@ -1337,7 +1337,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1, double s_start2 = th1; double s_end2 = th2; double dmin = DBL_MAX; - double xmin, ymin, smin, smin2; + double xmin = 0, ymin = 0, smin = 0, smin2 = 0; // Init made to avoid C compil warnings int nsteps = NSTEPS; int nsteps2 = NSTEPS; diff --git a/polygon/math_for_graphics.h b/polygon/math_for_graphics.h index 5a0ae7278a..51ec0edff1 100644 --- a/polygon/math_for_graphics.h +++ b/polygon/math_for_graphics.h @@ -3,11 +3,11 @@ typedef struct PointTag { double X,Y; -} Point; +} PointT; typedef struct EllipseTag { - Point Center; /* ellipse center */ + PointT Center; /* ellipse center */ // double MaxRad,MinRad; /* major and minor axis */ // double Phi; /* major axis rotation */ double xrad, yrad; // radii on x and y