From 20cb87a8b738e37a49cd7a2cb25d6e4151a349df Mon Sep 17 00:00:00 2001 From: charras Date: Tue, 14 Apr 2009 16:45:22 +0000 Subject: [PATCH] better handling of libraries paths (removed g_RealLibraryBuffer that had no sense with the new code), mainly in Eeschema TODO: better handling of user lib paths (more than one path) --- common/about_kicad.cpp | 2 +- common/common.cpp | 6 +- common/edaappl.cpp | 71 +++++- common/gr_basic.cpp | 61 ----- common/projet_config.cpp | 24 +- cvpcb/menucfg.cpp | 46 +++- eeschema/class_pin.cpp | 1 + eeschema/controle.cpp | 3 +- eeschema/dialog_eeschema_config.cpp | 38 ++- eeschema/dialog_eeschema_config_fbp.cpp | 41 +++- eeschema/dialog_eeschema_config_fbp.fbp | 296 +++++++++++++++--------- eeschema/dialog_eeschema_config_fbp.h | 6 +- eeschema/edit_component_in_lib.cpp | 11 +- eeschema/eeschema.cpp | 4 - eeschema/find.cpp | 179 +++++++------- eeschema/libedit.cpp | 3 +- eeschema/libfield.cpp | 46 +++- eeschema/onleftclick.cpp | 2 +- eeschema/onrightclick.cpp | 7 +- eeschema/symbedit.cpp | 13 +- eeschema/viewlibs.cpp | 2 +- include/appl_wxstruct.h | 22 +- include/common.h | 8 +- include/gr_basic.h | 9 - pcbnew/dialog_edit_module.cpp | 5 +- pcbnew/librairi.cpp | 10 +- 26 files changed, 563 insertions(+), 353 deletions(-) diff --git a/common/about_kicad.cpp b/common/about_kicad.cpp index 7234cbcec5..4a014f6879 100644 --- a/common/about_kicad.cpp +++ b/common/about_kicad.cpp @@ -8,7 +8,7 @@ #include "appl_wxstruct.h" -#define BUILD_VERSION wxT("(20090406-unstable)") +#define BUILD_VERSION wxT("(20090414-unstable)") wxString g_BuildVersion diff --git a/common/common.cpp b/common/common.cpp index 727c5ffea6..c5c97e9124 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -66,7 +66,6 @@ const wxString AllFilesWildcard( _( "All files (*)|*") ); wxString g_ProductName = wxT( "KiCad E.D.A. " ); bool g_ShowPageLimits = true; int g_GridColor = DARKGRAY; -wxString g_RealLibDirBuffer; wxString g_UserLibDirBuffer; int g_DebugLevel; int g_MouseOldButtons; @@ -96,6 +95,11 @@ int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2 /* Draw color for moving objects: */ int g_GhostColor; +/* predefined colors used in kicad. + * Please: if you change a value, remember these values are carefully chosen + * to have good results in pcbnew, that uses the ORed value of basic colors + * when displaying superimposed objects + */ StructColors ColorRefs[NBCOLOR] = { { 0, 0, 0, BLACK, wxT("BLACK"), DARKDARKGRAY}, diff --git a/common/edaappl.cpp b/common/edaappl.cpp index c626def9e8..5f857848a1 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -700,7 +700,7 @@ void WinEDA_App::SaveSettings() m_EDA_Config->Write( wxT( "SdtFontType" ), g_StdFont->GetFaceName() ); #if wxCHECK_VERSION( 2, 9, 0 ) -#warning under wxWidgets 3.0, see how to replace the next lines +#warning TODO: under wxWidgets 3.0, see how to replace the next lines #else m_EDA_Config->Write( wxT( "SdtFontStyle" ), g_StdFont->GetStyle() ); m_EDA_Config->Write( wxT( "SdtFontWeight" ), g_StdFont->GetWeight() ); @@ -1030,23 +1030,78 @@ wxString WinEDA_App::GetLibraryFile( const wxString& filename ) return FindFileInSearchPaths( filename, &subdirs ); } +/** ReturnLastVisitedLibraryPath + * Returns the last visited library directory, or (if void) the first + * path in lib path list ( but not the CWD ) + * @param aSubPathToSearch = Prefered sub path to search in path list (defualt = empty string) + */ +wxString s_LastVisitedLibPath; // Last lib directoty used when adding libraries +wxString WinEDA_App::ReturnLastVisitedLibraryPath( const wxString & aSubPathToSearch ) +{ + if ( ! s_LastVisitedLibPath.IsEmpty() ) + return s_LastVisitedLibPath; -/** + wxString path; + + /* Initialize default path to the main default lib path + * this is the second path in list (the first is the project path) + */ + unsigned pcount = wxGetApp().GetLibraryPathList().GetCount(); + if ( pcount ) + { + unsigned ipath = 0; + if ( wxGetApp().GetLibraryPathList()[0] == wxGetCwd() ) + ipath = 1; + + // First choice fo path: + if ( ipath < pcount ) + path = wxGetApp().GetLibraryPathList()[ipath]; + + // Search a sub path matching aSubPathToSearch + if ( ! aSubPathToSearch.IsEmpty() ) + { + for ( ; ipath < pcount; ipath++ ) + { + if ( wxGetApp().GetLibraryPathList()[ipath].Contains( aSubPathToSearch ) ) + { + path = wxGetApp().GetLibraryPathList()[ipath]; + break; + } + } + } + } + + if ( path.IsEmpty() ) + path = wxGetCwd(); + return path; +} + +void WinEDA_App::SaveLastVisitedLibraryPath( const wxString & aPath) +{ + s_LastVisitedLibPath = aPath; +} + + +/** FindLibraryPath * Kicad saves user defined library files that are not in the standard * library search path list with the full file path. Calling the library * search path list with a user library file will fail. This helper method * solves that problem. - * - * Returns a wxEmptyString if library file is not found. + * @param fileName + * @return a wxEmptyString if library file is not found. */ -wxString WinEDA_App::FindLibraryPath( const wxString& fileName ) +wxString WinEDA_App::FindLibraryPath( const wxString& aFileName ) { - if( wxFileName::FileExists( fileName ) ) - return fileName; + if( wxFileName::FileExists( aFileName ) ) + return aFileName; else - return m_libSearchPaths.FindValidPath( fileName ); + return m_libSearchPaths.FindValidPath( aFileName ); } +/** Function RemoveLibraryPath + * Removes the given ptah from the libary path list + * @param path = the path to remove + */ void WinEDA_App::RemoveLibraryPath( const wxString& path ) { if( m_libSearchPaths.Index( path, wxFileName::IsCaseSensitive() ) != wxNOT_FOUND ) diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 80620d20a9..0da0c349d5 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -1462,67 +1462,6 @@ void GRSFilledRect( EDA_Rect* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, } -/*******************************/ -/* Routines used to draw texts */ -/*******************************/ - -/*********************************************/ -void GRSetFont( wxDC* DC, wxFont* Font ) -/*********************************************/ -/* Routine to set the current font */ -{ - DC->SetFont( *Font ); -} - - -/*********************************************************/ -void GRSetTextFgColor( wxDC* DC, int Color ) -/*********************************************************/ -/* Set the foreground color used to draw texts */ -{ - DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) ); -} - - -void GRSetTextFgColor( wxDC* DC, wxFont*, int Color ) -{ - DC->SetTextForeground( wxColour( ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) ); -} - - -/********************************/ -void GRResetTextFgColor( wxDC* DC ) -/********************************/ -/* Set the foreground color used to draw texts to the default value */ -{ - GRSetTextFgColor( DC, Text_Color ); -} - - -/*********************************************************/ -void GRSetTextBgColor( wxDC* DC, int Color ) -/*********************************************************/ -/* Set the background color used to draw texts */ -{ - Color &= MASKCOLOR; // keep only the bits used to select the color - DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) ); -} - - -void GRSetTextBgColor( wxDC* DC, wxFont*, int Color ) -{ - Color &= MASKCOLOR; // keep only the bits used to select the color - DC->SetTextBackground( wxColour( ColorRefs[Color].m_Red, - ColorRefs[Color].m_Green, - ColorRefs[Color].m_Blue ) ); -} - #ifdef USE_CLIP_FILLED_POLYGONS /** Function ClipAndDrawFilledPoly diff --git a/common/projet_config.cpp b/common/projet_config.cpp index a5c5d5a9e4..8e2e312a23 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -340,7 +340,7 @@ PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam, /** ReadParam - * read the value of parameter thi stored in aConfig + * read the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that store the parameter */ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) @@ -357,7 +357,7 @@ void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) /** SaveParam - * the the value of parameter thi stored in aConfig + * save the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that can store the parameter */ void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) @@ -394,7 +394,7 @@ PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, /** ReadParam - * read the value of parameter thi stored in aConfig + * read the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that store the parameter */ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) @@ -410,7 +410,7 @@ void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) /** SaveParam - * the the value of parameter thi stored in aConfig + * save the the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that can store the parameter */ void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) @@ -451,7 +451,7 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup, /** ReadParam - * read the value of parameter thi stored in aConfig + * read the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that store the parameter */ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) @@ -475,7 +475,7 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) /** SaveParam - * the the value of parameter thi stored in aConfig + * save the the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that can store the parameter */ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) @@ -511,7 +511,7 @@ PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, /** ReadParam - * read the value of parameter thi stored in aConfig + * read the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that store the parameter */ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) @@ -525,7 +525,7 @@ void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) /** SaveParam - * the the value of parameter thi stored in aConfig + * save the the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that can store the parameter */ void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) @@ -557,7 +557,7 @@ PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident, /** ReadParam - * read the value of parameter thi stored in aConfig + * read the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that store the parameter */ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) @@ -569,7 +569,7 @@ void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) /** SaveParam - * the the value of parameter thi stored in aConfig + * save the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that can store the parameter */ void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) @@ -591,7 +591,7 @@ PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident, /** ReadParam - * read the value of parameter thi stored in aConfig + * read the value of parameter this stored in aConfig * @param aConfig = the wxConfigBase that store the parameter */ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) @@ -615,7 +615,7 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) /** SaveParam - * the the value of parameter thi stored in aConfig + * save the value of parameter this in aConfig (list of parameters) * @param aConfig = the wxConfigBase that can store the parameter */ void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) diff --git a/cvpcb/menucfg.cpp b/cvpcb/menucfg.cpp index c673efbb86..3289315a3a 100644 --- a/cvpcb/menucfg.cpp +++ b/cvpcb/menucfg.cpp @@ -14,7 +14,6 @@ #include "protos.h" #include "cvstruct.h" - /*****************************************/ /* classe pour la frame de Configuration */ /*****************************************/ @@ -202,7 +201,24 @@ void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event ) Update(); - wxFileDialog dlg( this, _( "Foot Print Library Files" ), g_RealLibDirBuffer, + wxString libpath = m_LibDirCtrl->GetValue(); + if ( libpath.IsEmpty() ) + libpath = wxGetApp().ReturnLastVisitedLibraryPath(); + + if ( libpath.IsEmpty() ) + { /* Initialize default path to the main default lib path + * this is the second path in list (the first is the project path) + */ + ii = wxGetApp().GetLibraryPathList().GetCount(); + if ( ii > 2 ) + ii = 2; + if ( ii > 0 ) + libpath = wxGetApp().GetLibraryPathList()[ii-1]; + else + libpath = wxGetCwd(); + } + + wxFileDialog dlg( this, _( "Foot Print Library Files" ), libpath, wxEmptyString, ModuleFileWildcard, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST ); @@ -218,7 +234,10 @@ void KiConfigCvpcbFrame::LibAddFct( wxCommandEvent& event ) { fn = Filenames[jj]; - /* If the library path is already in the library search paths + if ( jj == 0 ) + wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); + + /* If the library path is already in the library search paths * list, just add the library name to the list. Otherwise, add * the library name with the full path. */ if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) == wxNOT_FOUND ) @@ -281,8 +300,24 @@ void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event ) Update(); + wxString libpath = m_LibDirCtrl->GetValue(); + if ( libpath.IsEmpty() ) + libpath = wxGetApp().ReturnLastVisitedLibraryPath(); + + if ( libpath.IsEmpty() ) + { /* Initialize default path to the main default lib path + * this is the second path in list (the first is the project path) + */ + ii = wxGetApp().GetLibraryPathList().GetCount(); + if ( ii > 2 ) + ii = 2; + if ( ii > 0 ) + libpath = wxGetApp().GetLibraryPathList()[ii-1]; + else + libpath = wxGetCwd(); + } wxFileDialog dlg( this, _( "Open Footprint Alias Files" ), - g_RealLibDirBuffer, wxEmptyString, EquivFileWildcard, + libpath, wxEmptyString, EquivFileWildcard, wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) @@ -298,6 +333,9 @@ void KiConfigCvpcbFrame::EquAddFct( wxCommandEvent& event ) { fn = Filenames[jj]; + if ( jj == 0 ) + wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); + /* Use the file name without extension if the library path is * already in the default library search path. Otherwise, use * the full path and file name without the extension. */ diff --git a/eeschema/class_pin.cpp b/eeschema/class_pin.cpp index 28cf63da65..2df86c6fe0 100644 --- a/eeschema/class_pin.cpp +++ b/eeschema/class_pin.cpp @@ -1037,6 +1037,7 @@ void LibDrawPin::DisplayInfo( WinEDA_DrawFrame* frame ) } frame->MsgPanel->Affiche_1_Parametre( 62, _( "Orient" ), Text, MAGENTA ); +wxMessageBox(wxT("Pin!")); } diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index b3ed34b1c0..cf64be5ebd 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -77,6 +77,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include if( Pin ) { + /* Force display pin infos (the previous display could be a component info) */ Pin->Display_Infos( this ); if( LibItem ) @@ -187,7 +188,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin LibItem->GetRef( GetSheet() ), LibItem->GetField( VALUE )->m_Text, CYAN ); - if( IncludePin == TRUE ) + if( IncludePin ) return LibItem; } diff --git a/eeschema/dialog_eeschema_config.cpp b/eeschema/dialog_eeschema_config.cpp index a085ca44a2..f1a2f80997 100644 --- a/eeschema/dialog_eeschema_config.cpp +++ b/eeschema/dialog_eeschema_config.cpp @@ -33,15 +33,16 @@ private: private: - // Virtual event handlers, overide them in your derived class + // event handlers, overiding the fbp handlers void Init(); - virtual void OnCloseWindow( wxCloseEvent& event ); - virtual void OnSaveCfgClick( wxCommandEvent& event ); - virtual void OnRemoveLibClick( wxCommandEvent& event ); - virtual void OnAddOrInsertLibClick( wxCommandEvent& event ); - virtual void OnLibPathSelClick( wxCommandEvent& event ); - virtual void OnOkClick( wxCommandEvent& event ); - virtual void OnCancelClick( wxCommandEvent& event ); + void OnCloseWindow( wxCloseEvent& event ); + void OnSaveCfgClick( wxCommandEvent& event ); + void OnRemoveLibClick( wxCommandEvent& event ); + void OnAddOrInsertLibClick( wxCommandEvent& event ); + void OnLibPathSelClick( wxCommandEvent& event ); + void OnOkClick( wxCommandEvent& event ); + void OnCancelClick( wxCommandEvent& event ); + void OnRemoveUserPath( wxCommandEvent& event ); public: @@ -154,8 +155,9 @@ void DIALOG_EESCHEMA_CONFIG::OnOkClick( wxCommandEvent& event ) // Set new default path lib if ( g_UserLibDirBuffer != m_LibDirCtrl->GetValue() ) { + wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer ); g_UserLibDirBuffer = m_LibDirCtrl->GetValue(); - wxGetApp().SetDefaultSearchPaths( ); + wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); m_LibListChanged = true; } @@ -223,7 +225,7 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) wxString libpath = m_LibDirCtrl->GetValue(); if ( libpath.IsEmpty() ) - libpath = g_RealLibDirBuffer; + libpath = wxGetApp().ReturnLastVisitedLibraryPath(); wxFileDialog FilesDialog( this, _( "Library files:" ), libpath, wxEmptyString, CompLibFileWildcard, @@ -235,9 +237,11 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) wxArrayString Filenames; FilesDialog.GetPaths( Filenames ); - for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ ) + for( unsigned jj = 0; jj < Filenames.GetCount(); jj++ ) { fn = Filenames[jj]; + if ( jj == 0 ) + wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); /* If the library path is already in the library search paths * list, just add the library name to the list. Otherwise, add @@ -296,7 +300,7 @@ void DIALOG_EESCHEMA_CONFIG::OnLibPathSelClick( wxCommandEvent& event ) { wxString path = m_LibDirCtrl->GetValue(); if ( path.IsEmpty() ) - path = g_RealLibDirBuffer; + path = wxGetApp().ReturnLastVisitedLibraryPath(); bool select = EDA_DirectorySelector( _( " Default Path for libraries" ), /* Titre de la fenetre */ path, /* Chemin par defaut */ @@ -308,4 +312,14 @@ void DIALOG_EESCHEMA_CONFIG::OnLibPathSelClick( wxCommandEvent& event ) return; m_LibDirCtrl->SetValue( path ); + wxGetApp().SaveLastVisitedLibraryPath( path ); + } + + +/***********************************************************************/ +void DIALOG_EESCHEMA_CONFIG::OnRemoveUserPath( wxCommandEvent& event ) +/***********************************************************************/ +{ + m_LibDirCtrl->Clear( ); + } diff --git a/eeschema/dialog_eeschema_config_fbp.cpp b/eeschema/dialog_eeschema_config_fbp.cpp index ee27395872..4d46162b5e 100644 --- a/eeschema/dialog_eeschema_config_fbp.cpp +++ b/eeschema/dialog_eeschema_config_fbp.cpp @@ -82,11 +82,11 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind wxBoxSizer* bRightSizer; bRightSizer = new wxBoxSizer( wxVERTICAL ); - m_buttonRemove = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); - m_buttonRemove->SetForegroundColour( wxColour( 186, 1, 38 ) ); - m_buttonRemove->SetToolTip( _("Unload the selected library") ); + m_buttonRemoveLib = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); + m_buttonRemoveLib->SetForegroundColour( wxColour( 186, 1, 38 ) ); + m_buttonRemoveLib->SetToolTip( _("Unload the selected library") ); - bRightSizer->Add( m_buttonRemove, 0, wxALL, 5 ); + bRightSizer->Add( m_buttonRemoveLib, 0, wxALL, 5 ); m_buttonAdd = new wxButton( this, ID_ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonAdd->SetForegroundColour( wxColour( 13, 118, 1 ) ); @@ -124,26 +124,45 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 ); wxStaticBoxSizer* sbLibPathSizer; - sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Libraries Files Main Default Path:") ), wxVERTICAL ); + sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Path for Libraries Files:") ), wxVERTICAL ); wxBoxSizer* bUserLibPathSizer; bUserLibPathSizer = new wxBoxSizer( wxHORIZONTAL ); + wxStaticBoxSizer* sbSizer4; + sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User Path:") ), wxHORIZONTAL ); + + wxBoxSizer* bUserListSizer; + bUserListSizer = new wxBoxSizer( wxVERTICAL ); + m_LibDirCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_LibDirCtrl->SetToolTip( _("Default path to search libraries which have no absolute path in name,\nor a name which does not start by ./ or ../\nIf void, the default path is kicad/share/library") ); - bUserLibPathSizer->Add( m_LibDirCtrl, 1, wxALL, 5 ); + bUserListSizer->Add( m_LibDirCtrl, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); + + sbSizer4->Add( bUserListSizer, 1, wxALIGN_CENTER_VERTICAL, 5 ); + + wxBoxSizer* bUserPathsButtonsSizer; + bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL ); m_buttonBrowse = new wxButton( this, ID_LIB_PATH_SEL, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 ); - bUserLibPathSizer->Add( m_buttonBrowse, 0, wxALL, 5 ); + bUserPathsButtonsSizer->Add( m_buttonBrowse, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonRemovePath = new wxButton( this, wxID_ANY, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 ); + bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL, 5 ); + + sbSizer4->Add( bUserPathsButtonsSizer, 0, wxEXPAND, 5 ); + + bUserLibPathSizer->Add( sbSizer4, 1, wxEXPAND, 5 ); sbLibPathSizer->Add( bUserLibPathSizer, 1, wxEXPAND, 5 ); - m_staticTextcurrenpaths = new wxStaticText( this, wxID_ANY, _("Current Libraries Full Paths in Use:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextcurrenpaths = new wxStaticText( this, wxID_ANY, _("Current Full Paths (for Libraries and Doc Files) in Use:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextcurrenpaths->Wrap( -1 ); sbLibPathSizer->Add( m_staticTextcurrenpaths, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_DefaultLibraryPathslistBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB ); + m_DefaultLibraryPathslistBox->SetToolTip( _("Paths (system paths and user paths) used to search and load libraries files and component doc files.\nSorted by decreasing priority order.") ); m_DefaultLibraryPathslistBox->SetMinSize( wxSize( -1,70 ) ); sbLibPathSizer->Add( m_DefaultLibraryPathslistBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); @@ -155,24 +174,26 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCloseWindow ) ); - m_buttonRemove->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this ); + m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this ); m_buttonAdd->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this ); m_buttonIns->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this ); m_buttonOk->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnOkClick ), NULL, this ); m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCancelClick ), NULL, this ); m_buttonSave->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnSaveCfgClick ), NULL, this ); m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnLibPathSelClick ), NULL, this ); + m_buttonRemovePath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveUserPath ), NULL, this ); } DIALOG_EESCHEMA_CONFIG_FBP::~DIALOG_EESCHEMA_CONFIG_FBP() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCloseWindow ) ); - m_buttonRemove->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this ); + m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this ); m_buttonAdd->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this ); m_buttonIns->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this ); m_buttonOk->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnOkClick ), NULL, this ); m_buttonCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCancelClick ), NULL, this ); m_buttonSave->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnSaveCfgClick ), NULL, this ); m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnLibPathSelClick ), NULL, this ); + m_buttonRemovePath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveUserPath ), NULL, this ); } diff --git a/eeschema/dialog_eeschema_config_fbp.fbp b/eeschema/dialog_eeschema_config_fbp.fbp index f76d66fc4e..e87e9aad53 100644 --- a/eeschema/dialog_eeschema_config_fbp.fbp +++ b/eeschema/dialog_eeschema_config_fbp.fbp @@ -32,7 +32,7 @@ DIALOG_EESCHEMA_CONFIG_FBP - 593,445 + 593,500 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER @@ -630,7 +630,7 @@ Remove - m_buttonRemove + m_buttonRemoveLib protected @@ -995,7 +995,7 @@ 0 wxID_ANY - Libraries Files Main Default Path: + Path for Libraries Files: sbLibPathSizer wxVERTICAL @@ -1012,109 +1012,197 @@ none 5 - wxALL + wxEXPAND 1 - - - - 1 - - - 0 + wxID_ANY - - 0 + User Path: - m_LibDirCtrl - protected - - - - - Default path to search libraries which have no absolute path in name, or a name which does not start by ./ or ../ If void, the default path is kicad/share/library - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 - - - - 0 - 1 - - - 0 - ID_LIB_PATH_SEL - Browse - - - m_buttonBrowse - protected - - - - - - - - - OnLibPathSelClick - - - - - - - - - - - - - - - - - - - - - - + sbSizer4 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER_VERTICAL + 1 + + + bUserListSizer + wxVERTICAL + none + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 0 + + + + 1 + + + 0 + wxID_ANY + + 0 + + m_LibDirCtrl + protected + + + + + Default path to search libraries which have no absolute path in name, or a name which does not start by ./ or ../ If void, the default path is kicad/share/library + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 0 + + + bUserPathsButtonsSizer + wxVERTICAL + none + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL + 0 + + + + 0 + 1 + + + 0 + ID_LIB_PATH_SEL + Browse + + + m_buttonBrowse + protected + + + + + + + + + OnLibPathSelClick + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 0 + 1 + + + 0 + wxID_ANY + Remove + + + m_buttonRemovePath + protected + + + + + + + + + OnRemoveUserPath + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1131,7 +1219,7 @@ 0 wxID_ANY - Current Libraries Full Paths in Use: + Current Full Paths (for Libraries and Doc Files) in Use: m_staticTextcurrenpaths @@ -1191,7 +1279,7 @@ wxLB_NEEDED_SB - + Paths (system paths and user paths) used to search and load libraries files and component doc files. Sorted by decreasing priority order. diff --git a/eeschema/dialog_eeschema_config_fbp.h b/eeschema/dialog_eeschema_config_fbp.h index 83d81dbf9a..3f8dda9128 100644 --- a/eeschema/dialog_eeschema_config_fbp.h +++ b/eeschema/dialog_eeschema_config_fbp.h @@ -52,7 +52,7 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog wxStaticText* m_InfoSchFileExt; wxStaticText* m_staticTextlibList; wxListBox* m_ListLibr; - wxButton* m_buttonRemove; + wxButton* m_buttonRemoveLib; wxButton* m_buttonAdd; wxButton* m_buttonIns; @@ -62,6 +62,7 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog wxStaticLine* m_staticline1; wxTextCtrl* m_LibDirCtrl; wxButton* m_buttonBrowse; + wxButton* m_buttonRemovePath; wxStaticText* m_staticTextcurrenpaths; wxListBox* m_DefaultLibraryPathslistBox; @@ -73,10 +74,11 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnSaveCfgClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnLibPathSelClick( wxCommandEvent& event ){ event.Skip(); } + virtual void OnRemoveUserPath( wxCommandEvent& event ){ event.Skip(); } public: - DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 593,445 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 593,500 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_EESCHEMA_CONFIG_FBP(); }; diff --git a/eeschema/edit_component_in_lib.cpp b/eeschema/edit_component_in_lib.cpp index a3b382d681..833d002085 100644 --- a/eeschema/edit_component_in_lib.cpp +++ b/eeschema/edit_component_in_lib.cpp @@ -3,7 +3,6 @@ /**************************************************************/ #include "fctsys.h" -#include "gr_basic.h" #include "appl_wxstruct.h" #include "common.h" #include "confirm.h" @@ -753,12 +752,11 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event ) /****************************************************************************/ { wxString FullFileName, mask; + wxString docpath, filename; - wxString docpath( g_RealLibDirBuffer ), filename; + docpath = wxGetApp().ReturnLastVisitedLibraryPath(wxT( "doc" )); - docpath += wxT( "doc" ); - docpath += STRING_DIR_SEP; - mask = wxT( "*" ); + mask = wxT( "*" ); FullFileName = EDA_FileSelector( _( "Doc Files" ), docpath, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ @@ -771,8 +769,6 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event ) if( FullFileName.IsEmpty() ) return; - // Suppression du chemin par defaut pour le fichier de doc: - /* If the library path is already in the library search paths * list, just add the library name to the list. Otherwise, add * the library name with the full or relative path. @@ -781,6 +777,7 @@ void WinEDA_PartPropertiesFrame::BrowseAndSelectDocFile( wxCommandEvent& event ) * */ wxFileName fn = FullFileName; + wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); int pathlen = -1; // path len, used to find the better subpath within defualts paths if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case filename = fn.GetName(); diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index c8bbaca441..391ebfef66 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -2,10 +2,6 @@ /* eeschema.cpp - module principal */ /***********************************/ -#ifdef __GNUG__ -#pragma implementation -#endif - #include "fctsys.h" #include "appl_wxstruct.h" #include "common.h" diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 280447ccef..a3b3482be0 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -8,7 +8,9 @@ * in current sheet or whole the project */ #include "fctsys.h" -#include "gr_basic.h" + +//#include "gr_basic.h" +#include "appl_wxstruct.h" #include "common.h" #include "class_drawpanel.h" #include "confirm.h" @@ -49,7 +51,7 @@ void WinEDA_FindFrame::FindMarker( wxCommandEvent& event ) /************************************************************************/ -SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( +SCH_ITEM* WinEDA_SchematicFrame::FindComponentAndItem( const wxString& component_reference, bool Find_in_hierarchy, int SearchType, const wxString& text_to_find, @@ -71,17 +73,17 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( * @param mouseWarp If true, then move the mouse cursor to the item. */ { - DrawSheetPath* sheet, * SheetWithComponentFound = NULL; - SCH_ITEM* DrawList = NULL; - SCH_COMPONENT* Component = NULL; - wxSize DrawAreaSize = DrawPanel->GetClientSize(); - wxPoint pos, curpos; - bool DoCenterAndRedraw = FALSE; - bool NotFound = true; - wxString msg; - LibDrawPin* pin; + DrawSheetPath* sheet, * SheetWithComponentFound = NULL; + SCH_ITEM* DrawList = NULL; + SCH_COMPONENT* Component = NULL; + wxSize DrawAreaSize = DrawPanel->GetClientSize(); + wxPoint pos, curpos; + bool DoCenterAndRedraw = FALSE; + bool NotFound = true; + wxString msg; + LibDrawPin* pin; - EDA_SheetList SheetList; + EDA_SheetList SheetList; sheet = SheetList.GetFirst(); if( !Find_in_hierarchy ) @@ -96,7 +98,7 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( { SCH_COMPONENT* pSch; pSch = (SCH_COMPONENT*) DrawList; - if( component_reference.CmpNoCase( pSch->GetRef(sheet) ) == 0 ) + if( component_reference.CmpNoCase( pSch->GetRef( sheet ) ) == 0 ) { Component = pSch; SheetWithComponentFound = sheet; @@ -146,23 +148,23 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; - ActiveScreen = m_CurrentSheet->LastScreen(); + ActiveScreen = m_CurrentSheet->LastScreen(); m_CurrentSheet->UpdateAllScreenReferences(); - DoCenterAndRedraw = TRUE; + DoCenterAndRedraw = TRUE; } wxPoint delta; - pos -= Component->m_Pos; - delta = TransformCoordinate( Component->m_Transform, pos); - pos = delta + Component->m_Pos; + pos -= Component->m_Pos; + delta = TransformCoordinate( Component->m_Transform, pos ); + pos = delta + Component->m_Pos; - wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur; + wxPoint old_cursor_position = sheet->LastScreen()->m_Curseur; sheet->LastScreen()->m_Curseur = pos; curpos = DrawPanel->CursorScreenPosition(); DrawPanel->GetViewStart( &( GetScreen()->m_StartVisu.x ), - &( GetScreen()->m_StartVisu.y )); + &( GetScreen()->m_StartVisu.y ) ); // calcul des coord curseur avec origine = screen curpos -= GetScreen()->m_StartVisu; @@ -176,11 +178,11 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( } #undef MARGIN - if ( DoCenterAndRedraw ) + if( DoCenterAndRedraw ) Recadre_Trace( mouseWarp ); else { - wxClientDC dc( DrawPanel ); + wxClientDC dc( DrawPanel ); DrawPanel->PrepareGraphicContext( &dc ); @@ -255,7 +257,7 @@ SCH_ITEM * WinEDA_SchematicFrame::FindComponentAndItem( /*****************************************************************/ -SCH_ITEM * WinEDA_SchematicFrame::FindMarker( int SearchType ) +SCH_ITEM* WinEDA_SchematicFrame::FindMarker( int SearchType ) /*****************************************************************/ /* Search markers in whole the hierarchy. @@ -263,9 +265,9 @@ SCH_ITEM * WinEDA_SchematicFrame::FindMarker( int SearchType ) * SearchType = 0: search the first marker, else search next marker */ { - DrawSheetPath* sheet, * FirstSheet = NULL; - SCH_ITEM* DrawList, * FirstStruct = NULL, * Struct = NULL; - DrawMarkerStruct * Marker = NULL; + DrawSheetPath* sheet, * FirstSheet = NULL; + SCH_ITEM* DrawList, * FirstStruct = NULL, * Struct = NULL; + DrawMarkerStruct* Marker = NULL; int StartCount; bool NotFound; wxPoint firstpos, pos; @@ -295,7 +297,7 @@ SCH_ITEM * WinEDA_SchematicFrame::FindMarker( int SearchType ) pos = Marker->m_Pos; if( FirstSheet == NULL ) /* First item found */ { - FirstSheet = sheet; firstpos = pos; + FirstSheet = sheet; firstpos = pos; FirstStruct = DrawList; } @@ -317,7 +319,8 @@ SCH_ITEM * WinEDA_SchematicFrame::FindMarker( int SearchType ) } if( NotFound && FirstSheet ) // markers are found, but we have reach the last marker */ - { // After the last marker, the first marker is used */ + { + // After the last marker, the first marker is used */ NotFound = FALSE; sheet = FirstSheet; Struct = FirstStruct; pos = firstpos; s_MarkerCount = 1; @@ -329,18 +332,18 @@ SCH_ITEM * WinEDA_SchematicFrame::FindMarker( int SearchType ) { sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *sheet; - ActiveScreen = m_CurrentSheet->LastScreen(); + ActiveScreen = m_CurrentSheet->LastScreen(); m_CurrentSheet->UpdateAllScreenReferences(); - DoCenterAndRedraw = TRUE; + DoCenterAndRedraw = TRUE; } old_cursor_position = sheet->LastScreen()->m_Curseur; - sheet->LastScreen()->m_Curseur = pos; + sheet->LastScreen()->m_Curseur = pos; curpos = DrawPanel->CursorScreenPosition(); // calcul des coord curseur avec origine = screen DrawPanel->GetViewStart( &m_CurrentSheet->LastScreen()->m_StartVisu.x, - &m_CurrentSheet->LastScreen()->m_StartVisu.y ); + &m_CurrentSheet->LastScreen()->m_StartVisu.y ); curpos.x -= m_CurrentSheet->LastScreen()->m_StartVisu.x; curpos.y -= m_CurrentSheet->LastScreen()->m_StartVisu.y; @@ -417,16 +420,16 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( * @param mouseWarp If true, then move the mouse cursor to the item. */ { - DrawSheetPath* Sheet, * FirstSheet = NULL; - SCH_ITEM* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL; - int StartCount; - bool NotFound; - wxPoint firstpos, pos, old_cursor_position; - static int Find_in_hierarchy; - wxSize DrawAreaSize = DrawPanel->GetClientSize(); - wxPoint curpos; - bool DoCenterAndRedraw = FALSE; - wxString msg, WildText; + DrawSheetPath* Sheet, * FirstSheet = NULL; + SCH_ITEM* DrawList = NULL, * FirstStruct = NULL, * Struct = NULL; + int StartCount; + bool NotFound; + wxPoint firstpos, pos, old_cursor_position; + static int Find_in_hierarchy; + wxSize DrawAreaSize = DrawPanel->GetClientSize(); + wxPoint curpos; + bool DoCenterAndRedraw = FALSE; + wxString msg, WildText; g_LastSearchIsMarker = FALSE; @@ -457,7 +460,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( for( ; Sheet != NULL; Sheet = SheetList.GetNext() ) { - DrawList = (SCH_ITEM*)Sheet->LastDrawList(); + DrawList = (SCH_ITEM*) Sheet->LastDrawList(); while( DrawList ) { switch( DrawList->Type() ) @@ -465,7 +468,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( case TYPE_SCH_COMPONENT: SCH_COMPONENT * pSch; pSch = (SCH_COMPONENT*) DrawList; - if( WildCompareString( WildText, pSch->GetRef(Sheet), FALSE ) ) + if( WildCompareString( WildText, pSch->GetRef( Sheet ), FALSE ) ) { NotFound = FALSE; pos = pSch->GetField( REFERENCE )->m_Pos; @@ -497,9 +500,9 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( if( NotFound == FALSE ) /* Item found ! */ { - if( FirstSheet == NULL ) /* First Item found */ + if( FirstSheet == NULL ) /* First Item found */ { - FirstSheet = Sheet; + FirstSheet = Sheet; firstpos = pos; FirstStruct = DrawList; } @@ -531,7 +534,7 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( if( NotFound && FirstSheet ) { NotFound = FALSE; - Sheet = FirstSheet; + Sheet = FirstSheet; Struct = FirstStruct; pos = firstpos; s_ItemsCount = 1; @@ -543,9 +546,9 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( { Sheet->LastScreen()->SetZoom( GetScreen()->GetZoom() ); *m_CurrentSheet = *Sheet; - ActiveScreen = m_CurrentSheet->LastScreen(); + ActiveScreen = m_CurrentSheet->LastScreen(); m_CurrentSheet->UpdateAllScreenReferences(); - DoCenterAndRedraw = TRUE; + DoCenterAndRedraw = TRUE; } /* the struct is a TYPE_SCH_COMPONENT type, @@ -556,18 +559,18 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( SCH_COMPONENT* pSch = (SCH_COMPONENT*) Struct; pos -= pSch->m_Pos; - pos = TransformCoordinate( pSch->m_Transform, pos ); + pos = TransformCoordinate( pSch->m_Transform, pos ); pos += pSch->m_Pos; } old_cursor_position = Sheet->LastScreen()->m_Curseur; - Sheet->LastScreen()->m_Curseur = pos; + Sheet->LastScreen()->m_Curseur = pos; curpos = DrawPanel->CursorScreenPosition(); DrawPanel->GetViewStart( - &( GetScreen()->m_StartVisu.x ), - &( GetScreen()->m_StartVisu.y )); + &( GetScreen()->m_StartVisu.x ), + &( GetScreen()->m_StartVisu.y ) ); // calcul des coord curseur avec origine = screen curpos -= m_CurrentSheet->LastScreen()->m_StartVisu; @@ -577,14 +580,14 @@ SCH_ITEM* WinEDA_SchematicFrame::FindSchematicItem( if( (curpos.x <= MARGIN) || (curpos.x >= DrawAreaSize.x - MARGIN) || (curpos.y <= MARGIN) || (curpos.y >= DrawAreaSize.y - MARGIN) ) { - DoCenterAndRedraw = true; + DoCenterAndRedraw = true; } - if ( DoCenterAndRedraw ) + if( DoCenterAndRedraw ) Recadre_Trace( mouseWarp ); else { - wxClientDC dc( DrawPanel ); + wxClientDC dc( DrawPanel ); DrawPanel->PrepareGraphicContext( &dc ); @@ -712,39 +715,26 @@ int WinEDA_FindFrame::ExploreAllLibraries( const wxString& wildmask, wxString& F FILE* file; int nbitems = 0, LineNum = 0; char Line[2048], * name; + wxString path; - FullFileName = wxFindFirstFile( g_RealLibDirBuffer + wxT( "*." ) + - CompLibFileExtension ); - - while( !FullFileName.IsEmpty() ) + for( unsigned ii; ii < wxGetApp().GetLibraryPathList().GetCount(); ii++ ) { - file = wxFopen( FullFileName, wxT( "rt" ) ); - if( file == NULL ) - continue; + path = wxGetApp().GetLibraryPathList()[ii]; + FullFileName = wxFindFirstFile( path + wxT( "*." ) + CompLibFileExtension ); - while( GetLine( file, Line, &LineNum, sizeof(Line) ) ) + while( !FullFileName.IsEmpty() ) { - if( strnicmp( Line, "DEF", 3 ) == 0 ) + file = wxFopen( FullFileName, wxT( "rt" ) ); + if( file == NULL ) + continue; + + while( GetLine( file, Line, &LineNum, sizeof(Line) ) ) { - /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */ - strtok( Line, " \t\r\n" ); - name = strtok( NULL, " \t\r\n" ); - wxString st_name = CONV_FROM_UTF8( name ); - if( WildCompareString( wildmask, st_name, FALSE ) ) - { - nbitems++; - if( !FindList.IsEmpty() ) - FindList += wxT( "\n" ); - FindList << _( "Found " ) << CONV_FROM_UTF8( name ) - << _( " in lib " ) << FullFileName; - } - } - else if( strnicmp( Line, "ALIAS", 5 ) == 0 ) - { - /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */ - strtok( Line, " \t\r\n" ); - while( ( name = strtok( NULL, " \t\r\n" ) ) != NULL ) + if( strnicmp( Line, "DEF", 3 ) == 0 ) { + /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */ + strtok( Line, " \t\r\n" ); + name = strtok( NULL, " \t\r\n" ); wxString st_name = CONV_FROM_UTF8( name ); if( WildCompareString( wildmask, st_name, FALSE ) ) { @@ -755,11 +745,28 @@ int WinEDA_FindFrame::ExploreAllLibraries( const wxString& wildmask, wxString& F << _( " in lib " ) << FullFileName; } } + else if( strnicmp( Line, "ALIAS", 5 ) == 0 ) + { + /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */ + strtok( Line, " \t\r\n" ); + while( ( name = strtok( NULL, " \t\r\n" ) ) != NULL ) + { + wxString st_name = CONV_FROM_UTF8( name ); + if( WildCompareString( wildmask, st_name, FALSE ) ) + { + nbitems++; + if( !FindList.IsEmpty() ) + FindList += wxT( "\n" ); + FindList << _( "Found " ) << CONV_FROM_UTF8( name ) + << _( " in lib " ) << FullFileName; + } + } + } } - } - fclose( file ); - FullFileName = wxFindNextFile(); + fclose( file ); + FullFileName = wxFindNextFile(); + } } return nbitems; diff --git a/eeschema/libedit.cpp b/eeschema/libedit.cpp index d612527bed..fc141869ee 100644 --- a/eeschema/libedit.cpp +++ b/eeschema/libedit.cpp @@ -258,8 +258,7 @@ void WinEDA_LibeditFrame::SaveActiveLibrary() return; } - fn = wxFileName( g_RealLibDirBuffer, CurrentLib->m_Name, - CompLibFileExtension ); + fn = wxFileName( CurrentLib->m_FullFileName ); msg = _( "Modify Library File \"" ) + fn.GetFullPath() + _( "\"?" ); diff --git a/eeschema/libfield.cpp b/eeschema/libfield.cpp index 181c6826a4..eb56e96a53 100644 --- a/eeschema/libfield.cpp +++ b/eeschema/libfield.cpp @@ -21,7 +21,10 @@ /* Routines locales */ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); - +/* if the field is the reference, return reference like schematic, i.e U -> U? or U?A + * or the field text for others + */ +static wxString ReturnFieldFullText( LibDrawField* aField); /* Variables locales */ extern int CurrentUnit; @@ -76,6 +79,33 @@ void WinEDA_LibeditFrame::StartMoveField( wxDC* DC, LibDrawField* field ) } +/* if the field is the reference, return reference like schematic, i.e U -> U? or U?A + * or the field text for others + */ +static wxString ReturnFieldFullText( LibDrawField* aField) +{ + if ( aField->m_FieldId != REFERENCE ) + return aField->m_Text; + + wxString text = aField->m_Text; + + if( CurrentLibEntry->m_UnitCount > 1 ) + { +#if defined(KICAD_GOST) + text.Printf( wxT( "%s?.%c" ), + aField->m_Text.m_Text.GetData(), CurrentUnit + '1' - 1 ); +#else + + text.Printf( wxT( "%s?%c" ), + aField->m_Text.GetData(), CurrentUnit + 'A' - 1 ); +#endif + } + else + text << wxT( "?" ); + + return text; +} + /*****************************************************************/ /* Routine d'affichage du texte 'Field' en cours de deplacement. */ /* Routine normalement attachee au curseur */ @@ -103,9 +133,7 @@ static void ShowMoveField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) break; } - wxString text = Field->m_Text; - if( Field->m_FieldId == REFERENCE ) - text << wxT( "?" ); + wxString text = ReturnFieldFullText( Field ); int TransMat[2][2]; TransMat[0][0] = 1; TransMat[1][1] = -1; @@ -166,7 +194,7 @@ void WinEDA_LibeditFrame::PlaceField( wxDC* DC, LibDrawField* Field ) GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE ); DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), - color, Field->m_Text, + color, ReturnFieldFullText( Field ), Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, Field->m_Size, Field->m_HJustify, Field->m_VJustify, LineWidth ); @@ -218,7 +246,7 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field ) GRSetDrawMode( DC, g_XorMode ); DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), - color, Field->m_Text, + color, ReturnFieldFullText( Field ), Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, Field->m_Size, Field->m_HJustify, Field->m_VJustify, LineWidth ); @@ -235,7 +263,7 @@ void WinEDA_LibeditFrame::EditField( wxDC* DC, LibDrawField* Field ) GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE ); DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), - color, Field->m_Text, + color, ReturnFieldFullText( Field ), Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, Field->m_Size, Field->m_HJustify, Field->m_VJustify, LineWidth ); @@ -286,7 +314,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field ) GRSetDrawMode( DC, g_XorMode ); int LineWidth = MAX( Field->m_Width, g_DrawMinimunLineWidth ); DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), - color, Field->m_Text, + color, ReturnFieldFullText( Field ), Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, Field->m_Size, Field->m_HJustify, Field->m_VJustify, LineWidth ); @@ -300,7 +328,7 @@ void WinEDA_LibeditFrame::RotateField( wxDC* DC, LibDrawField* Field ) GRSetDrawMode( DC, GR_DEFAULT_DRAWMODE ); DrawGraphicText( DrawPanel, DC, wxPoint( Field->m_Pos.x, -Field->m_Pos.y ), - color, Field->m_Text, + color, ReturnFieldFullText( Field ), Field->m_Orient ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ, Field->m_Size, Field->m_HJustify, Field->m_VJustify, LineWidth ); diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 44da185ed4..8bf5cfb1cf 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -71,7 +71,7 @@ void WinEDA_SchematicFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos ) } else { - DrawStruct = SchematicGeneralLocateAndDisplay(); + DrawStruct = SchematicGeneralLocateAndDisplay(true); } } diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index 16f97cad11..c4d34e9eb5 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -78,10 +78,9 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, return true; } - // Simple localisation des elements si possible if( (DrawStruct == NULL) || (DrawStruct->m_Flags == 0) ) - { - DrawStruct = SchematicGeneralLocateAndDisplay( FALSE ); + { // Just try to locate items at cursor position + DrawStruct = SchematicGeneralLocateAndDisplay( false ); if( DrawStruct && (DrawStruct->Type() == DRAW_SHEET_STRUCT_TYPE) ) { Hierarchical_PIN_Sheet_Struct* slabel; @@ -92,7 +91,7 @@ bool WinEDA_SchematicFrame::OnRightClick( const wxPoint& MousePos, } } - // If Command in progress: put the menu "cancel" and "end tool" + // If Command in progress: add "cancel" and "end tool" menu if( m_ID_current_state ) { if( DrawStruct && DrawStruct->m_Flags ) diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index 2418209451..0ca1268ead 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -9,6 +9,7 @@ #include "fctsys.h" #include "gr_basic.h" +#include "appl_wxstruct.h" #include "common.h" #include "class_drawpanel.h" #include "confirm.h" @@ -54,8 +55,10 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) DrawPanel->m_IgnoreMouseEvents = TRUE; mask = wxT( "*" ) + g_SymbolExtBuffer; + wxString default_lib_path = wxGetApp().ReturnLastVisitedLibraryPath(); + FullFileName = EDA_FileSelector( _( "Import symbol drawings:" ), - g_RealLibDirBuffer, /* Chemin par defaut */ + default_lib_path, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ g_SymbolExtBuffer, /* extension par defaut */ mask, /* Masque d'affichage */ @@ -71,6 +74,8 @@ void WinEDA_LibeditFrame::LoadOneSymbol( void ) if( FullFileName.IsEmpty() ) return; + wxFileName fn = FullFileName; + wxGetApp().SaveLastVisitedLibraryPath(fn.GetPath() ); /* Load data */ ImportFile = wxFopen( FullFileName, wxT( "rt" ) ); @@ -159,9 +164,10 @@ void WinEDA_LibeditFrame::SaveOneSymbol() return; /* Creation du fichier symbole */ + wxString default_lib_path = wxGetApp().ReturnLastVisitedLibraryPath(); mask = wxT( "*" ) + g_SymbolExtBuffer; FullFileName = EDA_FileSelector( _( "Export symbol drawings:" ), - g_RealLibDirBuffer, /* Chemin par defaut */ + default_lib_path, /* Chemin par defaut */ wxEmptyString, /* nom fichier par defaut */ g_SymbolExtBuffer, /* extension par defaut */ mask, /* Masque d'affichage */ @@ -172,6 +178,9 @@ void WinEDA_LibeditFrame::SaveOneSymbol() if( FullFileName.IsEmpty() ) return; + wxFileName fn = FullFileName; + wxGetApp().SaveLastVisitedLibraryPath(fn.GetPath() ); + ExportFile = wxFopen( FullFileName, wxT( "wt" ) ); if( ExportFile == NULL ) { diff --git a/eeschema/viewlibs.cpp b/eeschema/viewlibs.cpp index a41cb726a1..286a6fa97e 100644 --- a/eeschema/viewlibs.cpp +++ b/eeschema/viewlibs.cpp @@ -124,7 +124,7 @@ void WinEDA_ViewlibFrame::DisplayLibInfos() msg << wxT( " [" ); if( Lib ) - msg << g_CurrentViewLibraryName; + msg << Lib->m_FullFileName; else msg += _( "none selected" ); diff --git a/include/appl_wxstruct.h b/include/appl_wxstruct.h index 6ac16a57bf..e66fa4fc08 100644 --- a/include/appl_wxstruct.h +++ b/include/appl_wxstruct.h @@ -86,7 +86,7 @@ public: /** Function InitEDA_Appl * initialise some general parameters - * - Default paths (help, libs, bin)and configuration flies names + * - Default paths (help, libs, bin)and configuration files names * - Language and locale * - fonts * @param aName : used as paths in configuration files @@ -157,12 +157,32 @@ public: wxPathList& GetLibraryPathList() { return m_libSearchPaths; } wxString FindLibraryPath( const wxString& fileName ); + /** FindLibraryPath + * Kicad saves user defined library files that are not in the standard + * library search path list with the full file path. Calling the library + * search path list with a user library file will fail. This helper method + * solves that problem. + * @param fileName + * @return a wxEmptyString if library file is not found. + */ wxString FindLibraryPath( const wxFileName& fileName ) { return FindLibraryPath( fileName.GetFullPath() ); } + /** ReturnLastVisitedLibraryPath + * Returns the last visited library directory, or (if void) the first + * path in lib path list ( but not the CWD ) + * @param aSubPathToSearch = Prefered sub path to search in path list + */ + wxString ReturnLastVisitedLibraryPath( const wxString & aSubPathToSearch = wxEmptyString); + void SaveLastVisitedLibraryPath( const wxString & aPath); + + /** Function RemoveLibraryPath + * Removes the given ptah from the libary path list + * @param path = the path to remove + */ void RemoveLibraryPath( const wxString& path ); void InsertLibraryPath( const wxString& path, size_t index ); }; diff --git a/include/common.h b/include/common.h index 9e075687f4..a9c84b75e9 100644 --- a/include/common.h +++ b/include/common.h @@ -146,12 +146,8 @@ extern Ki_PageDescr* g_SheetSizeList[]; extern wxString g_ProductName; -/* Gestion des librairies */ -extern wxString g_RealLibDirBuffer; // Chemin reel des librairies de module -// = UserLibDirBuffer si non vide -// = chemin par defaut sinon -extern wxString g_UserLibDirBuffer; // Chemin des librairies de module donne par -// le file de config +/* Default user lib path can be left void, if the standard lib path is used */ +extern wxString g_UserLibDirBuffer; extern int g_DebugLevel; // 0= Pas de debug */ extern int g_MouseOldButtons; diff --git a/include/gr_basic.h b/include/gr_basic.h index 78e3ac6c22..cc16bcca03 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -187,15 +187,6 @@ void GRSRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, void GRSRect(EDA_Rect * ClipBox, wxDC * DC, int x1, int y1, int x2, int y2, int width, int Color); -/* Routines relatives a l'affichage des textes */ -void GRSetFont(wxDC * DC, wxFont * Font); -void GRResetTextFgColor(wxDC * DC); -void GRSetTextFgColor(wxDC * DC, int Color); -void GRSetTextFgColor(wxDC * DC, wxFont * Font, int Color); -int GRGetTextFgColor(wxDC * DC, wxFont * Font); -void GRSetTextBgColor(wxDC * DC, int Color); -void GRSetTextBgColor(wxDC * DC, wxFont * Font, int Color); -int GRGetTextBgColor(wxDC * DC, wxFont * Font); #endif /* define GR_BASIC */ diff --git a/pcbnew/dialog_edit_module.cpp b/pcbnew/dialog_edit_module.cpp index 90f7be1c29..189869abd6 100644 --- a/pcbnew/dialog_edit_module.cpp +++ b/pcbnew/dialog_edit_module.cpp @@ -5,6 +5,7 @@ /************************************************/ #include "confirm.h" +#include "appl_wxstruct.h" #include "dialog_edit_module.h" #include @@ -484,10 +485,10 @@ void Panel3D_Ctrl::Browse3DLib( wxCommandEvent& event ) /***************************************************/ { wxString fullfilename, shortfilename; - wxString fullpath = g_RealLibDirBuffer; + wxString fullpath; wxString mask = wxT( "*" ); - fullpath += LIB3D_PATH; + fullpath = wxGetApp().ReturnLastVisitedLibraryPath(LIB3D_PATH); mask += g_Shapes3DExtBuffer; #ifdef __WINDOWS__ fullpath.Replace( wxT( "/" ), wxT( "\\" ) ); diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 33b24ffbde..519cba3332 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -168,7 +168,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) fn.SetExt( createlib ? ModuleFileExtension : ModExportFileExtension ); if( createlib ) - path = g_RealLibDirBuffer; + path = wxGetApp().ReturnLastVisitedLibraryPath(); else if( Config ) Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &path ); @@ -182,6 +182,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib ) return; fn = dlg.GetPath(); + wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); /* Generation du fichier Empreinte */ if( ( file = wxFopen( fn.GetFullPath(), wxT( "wt" ) ) ) == NULL ) @@ -401,7 +402,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, int ii, NbModules = 0; float Pas; MODULE* Module; - wxString fileName = LibName; + wxString fileName = LibName, path; if( GetBoard()->m_Modules == NULL ) { @@ -409,9 +410,10 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, return; } + path = wxGetApp().ReturnLastVisitedLibraryPath(); if( LibName.IsEmpty() ) { - wxFileDialog dlg( this, _( "Library" ), g_RealLibDirBuffer, + wxFileDialog dlg( this, _( "Library" ), path, wxEmptyString, ModuleFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); @@ -421,6 +423,8 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName, fileName = dlg.GetPath(); } + wxFileName fn(fileName); + wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); bool file_exists = wxFileExists( fileName ); if( !NewModulesOnly && file_exists )