From ca12278e9087b190c2ce6ce23622a372f5606a45 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 26 Sep 2011 16:32:56 -0400 Subject: [PATCH] PCB common library global variable removal and other minor fixes. * Move auto save time global variables into PCB_EDIT_FRAME object. * Move footprint library name list global variable int PCB_EDIT_FRAME object. * Improve library back up and temporary file error message strings and make them translatable. * PCBNew string unification. * Translate French code names and comments. * Coding style policy and Doxygen comment fixes. --- common/pcbcommon.cpp | 4 - gerbview/files.cpp | 23 +--- gerbview/gerbview_frame.h | 12 ++ include/pcbcommon.h | 11 +- include/wxBasePcbFrame.h | 11 +- include/wxPcbStruct.h | 57 ++++++-- pcbnew/controle.cpp | 4 +- pcbnew/dialogs/dialog_general_options.cpp | 31 +++-- pcbnew/dialogs/dialog_general_options.h | 7 +- .../dialog_pcbnew_config_libs_and_paths.cpp | 103 +++++++------- .../dialog_pcbnew_config_libs_and_paths.h | 5 +- pcbnew/files.cpp | 4 +- pcbnew/librairi.cpp | 35 +++-- pcbnew/loadcmp.cpp | 9 +- pcbnew/module_editor_frame.h | 129 +++++++++--------- pcbnew/pcbnew.cpp | 19 +-- pcbnew/pcbnew_config.cpp | 53 ++----- 17 files changed, 259 insertions(+), 258 deletions(-) diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index 51bf6020a4..a6dfbb8bda 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -73,8 +73,6 @@ wxString g_ViaType_Name[4] = { }; -wxArrayString g_LibName_List; // library list to load - DISPLAY_OPTIONS DisplayOpt; /* Display options for board items */ /* PCB file name extension definitions. */ @@ -90,8 +88,6 @@ const wxString ModuleFileWildcard( _( "Kicad footprint library files (*.mod)|*.m int g_CurrentVersionPCB = 1; int g_RotationAngle; -int g_TimeOut; // Timer for automatic saving -int g_SaveTime; // Time for next saving int g_AnchorColor = BLUE; int g_ModuleTextCMPColor = LIGHTGRAY; diff --git a/gerbview/files.cpp b/gerbview/files.cpp index 12413cfe09..1f0ce4faf6 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -1,6 +1,6 @@ -/*************/ -/* files.cpp */ -/*************/ +/** + * @file gerbview/files.cpp + */ #include "fctsys.h" #include "common.h" @@ -13,9 +13,6 @@ #include "class_gerbview_layer_widget.h" -/* Load a Gerber file selected from history list on current layer - * Previous data is deleted - */ void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event ) { wxString fn; @@ -29,9 +26,7 @@ void GERBVIEW_FRAME::OnGbrFileHistory( wxCommandEvent& event ) } } -/* Load a Drll (Excellon) file selected from history list on current layer - * Previous data is deleted - */ + void GERBVIEW_FRAME::OnDrlFileHistory( wxCommandEvent& event ) { wxString fn; @@ -180,7 +175,6 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) } Zoom_Automatique( false ); - g_SaveTime = time( NULL ); // Synchronize layers tools with actual active layer: setActiveLayer( getActiveLayer() ); @@ -265,7 +259,6 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) } Zoom_Automatique( false ); - g_SaveTime = time( NULL ); // Synchronize layers tools with actual active layer: setActiveLayer( getActiveLayer() ); @@ -276,14 +269,6 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) } -/* - * Read a DCode file (not used with RX274X files , just with RS274D old files). - * Note: there is no standard for DCode files. - * Just read a file format created by early versions of Pcbnew. - * Returns: - * false if file not read (cancellation of order ...) - * true if OK - */ bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName ) { wxString wildcard; diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 8e63754356..6cf6197188 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -412,7 +412,19 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title, GRTraceMode trace_mode ); void Files_io( wxCommandEvent& event ); + + /** + * Function OnGbrFileHistory + * deletes the current data and loads a Gerber file selected from history list on + * current layer. + */ void OnGbrFileHistory( wxCommandEvent& event ); + + /** + * Function OnDrlFileHistory + * deletes the current data and load a drill file in Excellon format selected from + * history list on current layer. + */ void OnDrlFileHistory( wxCommandEvent& event ); /** diff --git a/include/pcbcommon.h b/include/pcbcommon.h index 95a990eb44..f2d3e15e5f 100644 --- a/include/pcbcommon.h +++ b/include/pcbcommon.h @@ -29,8 +29,6 @@ extern int g_TabOneLayerMask[LAYER_COUNT]; /* Look up Table for conversion copper layer count -> general copper layer mask: */ extern int g_TabAllCopperLayerMask[NB_COPPER_LAYERS]; - -extern wxArrayString g_LibName_List; // library list to load extern DISPLAY_OPTIONS DisplayOpt; extern wxString g_SaveFileName; @@ -44,10 +42,7 @@ extern wxString g_ViaType_Name[4]; extern int g_CurrentVersionPCB; - -extern int g_RotationAngle; -extern int g_TimeOut; // Timer for automatic saving -extern int g_SaveTime; // Time for next saving +extern int g_RotationAngle; /// List of segments of the trace currently being drawn. extern DLIST g_CurrentTrackList; @@ -56,10 +51,10 @@ extern DLIST g_CurrentTrackList; #define g_FirstTrackSegment g_CurrentTrackList.GetFirst() ///< first segment created -extern BOARD* g_ModuleEditor_Pcb; +extern BOARD* g_ModuleEditor_Pcb; /* Pad editing */ -extern D_PAD g_Pad_Master; +extern D_PAD g_Pad_Master; #endif /* __PCBCOMMON_H__ */ diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 12936012b0..de37a71cf8 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -19,7 +19,7 @@ #endif -/* Forward declarations of classes. */ +/* Forward declarations of classes. */ class FOOTPRINT_EDIT_FRAME; class BOARD; class MODULE; @@ -31,10 +31,10 @@ class GENERAL_COLLECTOR; class GENERAL_COLLECTORS_GUIDE; -/******************************************************************/ -/* class PCB_BASE_FRAME: Basic class for pcbnew and gerbview */ -/******************************************************************/ - +/** + * class PCB_BASE_FRAME + * basic PCB main window class for PCBNew, Gerbview, and CvPcb footprint viewer. + */ class PCB_BASE_FRAME : public EDA_DRAW_FRAME { public: @@ -84,7 +84,6 @@ public: return m_Pcb; } - // General virtual void OnCloseWindow( wxCloseEvent& Event ) = 0; virtual void RedrawActiveWindow( wxDC* DC, bool EraseBg ) { } diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 6de0196d4e..08815687b5 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -42,13 +42,11 @@ class BOARD_ITEM; /** - * See also class PCB_BASE_FRAME(): Basic class for pcbnew and gerbview. + * class PCB_EDIT_FRAME + * the main frame for PCBNew + * + * See also class PCB_BASE_FRAME(): Basic class for PCBNew and Gerbview. */ - - -/*****************************************************/ -/* class PCB_EDIT_FRAME: the main frame for Pcbnew */ -/*****************************************************/ class PCB_EDIT_FRAME : public PCB_BASE_FRAME { friend class PCB_LAYER_WIDGET; @@ -59,6 +57,10 @@ class PCB_EDIT_FRAME : public PCB_BASE_FRAME int m_RecordingMacros; MACROS_RECORDED m_Macros[10]; + int m_saveInterval; ///< Time interval in seconds for automatic saving. + int m_lastSaveTime; ///< Last save time. + wxArrayString m_libraryNames; ///< List of footprint library names to load. + protected: PCB_LAYER_WIDGET* m_Layers; @@ -227,11 +229,31 @@ public: */ virtual void SetGridColor(int aColor); + void ResetAutoSaveTimeOut() { m_lastSaveTime = time( NULL ); } + + int GetAutoSaveTimeInterval() { return m_saveInterval; } + + void SetAutoSaveTimeInterval( int aInterval ) { m_saveInterval = aInterval; } + + wxArrayString& GetFootprintLibraryNames() { return m_libraryNames; } + // Configurations: void InstallConfigFrame(); void Process_Config( wxCommandEvent& event ); + /** + * Function GetProjectFileParameters + * returns the project file parameter list for PCBNew. + *

+ * Populate the project file parameter array specific to PCBNew if it hasn't + * already been populated and return a reference to the array to the caller. + * Creating the parameter list at run time has the advantage of being able + * to define local variables. The old method of statically building the array + * at compile time requiring global variable definitions by design. + *

+ */ PARAM_CFG_ARRAY& GetProjectFileParameters(); + void SaveProjectSettings(); /** @@ -244,14 +266,28 @@ public: bool LoadProjectSettings( const wxString& aProjectFileName ); /** - * Get the list of application specific settings. + * Function GetConfigurationSettings + * returns the PCBNew applications settings list. * + * This replaces the old statically define list that had the project + * file settings and the application settings mixed together. This + * was confusing and caused some settings to get saved and loaded + * incorrectly. Currently, only the settings that are needed at start + * up by the main window are defined here. There are other locally used + * settings are scattered throughout the PCBNew source code. If you need + * to define a configuration setting that need to be loaded at run time, + * this is the place to define it. + * + * @todo: Define the configuration variables as member variables instead of + * global variables or move them to the object class where they are + * used. * @return - Reference to the list of applications settings. */ PARAM_CFG_ARRAY& GetConfigurationSettings(); /** - * Load applications settings specific to PCBNew. + * Function LoadSettings + * loads applications settings specific to PCBNew. * * This overrides the base class PCB_BASE_FRAME::LoadSettings() to * handle settings specific common to the PCB layout application. It @@ -262,7 +298,8 @@ public: virtual void LoadSettings(); /** - * Save applications settings common to PCBNew. + * Function SaveSettings + * saves applications settings common to PCBNew. * * This overrides the base class PCB_BASE_FRAME::SaveSettings() to * save settings specific to the PCB layout application main window. It @@ -335,7 +372,7 @@ public: * An item can be placed only if there is this item currently edited * Only a footprint, a pad or a track can be placed * @param aDC = current device context - * @return true if an item was placedd + * @return true if an item was placed */ bool OnHotkeyPlaceItem( wxDC* aDC ); diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index 9074524cab..f5a29e28dc 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -247,10 +247,10 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH if( !GetScreen()->IsModify() || GetScreen()->IsSave() ) { /* If no change, reset the time out */ - g_SaveTime = CurrentTime; + m_lastSaveTime = CurrentTime; } - if( (CurrentTime - g_SaveTime) > g_TimeOut ) + if( (CurrentTime - m_lastSaveTime) > m_saveInterval ) { wxString tmpFileName = GetScreen()->GetFileName(); wxFileName fn = wxFileName( wxEmptyString, g_SaveFileName, PcbFileExtension ); diff --git a/pcbnew/dialogs/dialog_general_options.cpp b/pcbnew/dialogs/dialog_general_options.cpp index c1c061ed08..41b9b911cf 100644 --- a/pcbnew/dialogs/dialog_general_options.cpp +++ b/pcbnew/dialogs/dialog_general_options.cpp @@ -24,7 +24,6 @@ Dialog_GeneralOptions::Dialog_GeneralOptions( PCB_EDIT_FRAME* parent ) : DialogGeneralOptionsBoardEditor_base( parent ) { - m_Parent = parent; init(); m_buttonOK->SetDefault(); @@ -37,12 +36,12 @@ void Dialog_GeneralOptions::init() { SetFocus(); - m_Board = m_Parent->GetBoard(); + m_Board = GetParent()->GetBoard(); /* Set display options */ m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 ); m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 ); - m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 ); + m_CursorShape->SetSelection( GetParent()->m_CursorShape ? 1 : 0 ); switch( g_RotationAngle ) @@ -50,22 +49,23 @@ void Dialog_GeneralOptions::init() case 450: m_RotationAngle->SetSelection( 0 ); break; + default: m_RotationAngle->SetSelection( 1 ); } wxString timevalue; - timevalue << g_TimeOut / 60; + timevalue << GetParent()->GetAutoSaveTimeInterval() / 60; m_SaveTime->SetValue( timevalue ); m_MaxShowLinks->SetValue( g_MaxLinksShowed ); m_DrcOn->SetValue( Drc_On ); m_ShowModuleRatsnest->SetValue( g_Show_Module_Ratsnest ); - m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible(RATSNEST_VISIBLE) ); + m_ShowGlobalRatsnest->SetValue( m_Board->IsElementVisible( RATSNEST_VISIBLE ) ); m_TrackAutodel->SetValue( g_AutoDeleteOldTrack ); m_Track_45_Only_Ctrl->SetValue( g_Track_45_Only_Allowed ); m_Segments_45_Only_Ctrl->SetValue( Segments_45_Only ); - m_AutoPANOpt->SetValue( m_Parent->DrawPanel->m_AutoPAN_Enable ); + m_AutoPANOpt->SetValue( GetParent()->DrawPanel->m_AutoPAN_Enable ); m_Segments_45_Only_Ctrl->SetValue( Segments_45_Only ); m_Track_DoubleSegm_Ctrl->SetValue( g_TwoSegmentTrackBuild ); @@ -90,11 +90,10 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES; if( ii != g_UserUnit ) - m_Parent->ReCreateAuxiliaryToolbar(); - - m_Parent->m_CursorShape = m_CursorShape->GetSelection(); - g_TimeOut = 60 * m_SaveTime->GetValue(); + GetParent()->ReCreateAuxiliaryToolbar(); + GetParent()->m_CursorShape = m_CursorShape->GetSelection(); + GetParent()->SetAutoSaveTimeInterval( 60 * m_SaveTime->GetValue() ); g_RotationAngle = 10 * wxAtoi( m_RotationAngle->GetStringSelection() ); @@ -104,15 +103,15 @@ void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event ) if( m_Board->IsElementVisible(RATSNEST_VISIBLE) != m_ShowGlobalRatsnest->GetValue() ) { - m_Parent->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() ); - m_Parent->DrawPanel->Refresh( ); + GetParent()->SetElementVisibility(RATSNEST_VISIBLE, m_ShowGlobalRatsnest->GetValue() ); + GetParent()->DrawPanel->Refresh( ); } g_Show_Module_Ratsnest = m_ShowModuleRatsnest->GetValue(); g_AutoDeleteOldTrack = m_TrackAutodel->GetValue(); Segments_45_Only = m_Segments_45_Only_Ctrl->GetValue(); g_Track_45_Only_Allowed = m_Track_45_Only_Ctrl->GetValue(); - m_Parent->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); + GetParent()->DrawPanel->m_AutoPAN_Enable = m_AutoPANOpt->GetValue(); g_TwoSegmentTrackBuild = m_Track_DoubleSegm_Ctrl->GetValue(); g_MagneticPadOption = m_MagneticPadOptCtrl->GetSelection(); @@ -134,6 +133,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) { case ID_TB_OPTIONS_DRC_OFF: Drc_On = !state; + if( GetToolId() == ID_TRACK_BUTT ) { if( Drc_On ) @@ -141,14 +141,17 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) else DrawPanel->SetCursor( wxCURSOR_QUESTION_ARROW ); } + break; case ID_TB_OPTIONS_SHOW_RATSNEST: SetElementVisibility( RATSNEST_VISIBLE, state ); + if( state && (GetBoard()->m_Status_Pcb & LISTE_RATSNEST_ITEM_OK) == 0 ) { Compile_Ratsnest( NULL, true ); } + DrawPanel->Refresh(); break; @@ -204,7 +207,7 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event ) GetMenuBar()->SetLabel( ID_MENU_PCB_SHOW_HIDE_LAYERS_MANAGER_DIALOG, m_show_layer_manager_tools ? - _("Hide &Layers Manager" ) : _("Show &Layers Manager" ) ); + _( "Hide &Layers Manager" ) : _( "Show &Layers Manager" ) ); break; default: diff --git a/pcbnew/dialogs/dialog_general_options.h b/pcbnew/dialogs/dialog_general_options.h index 4538c0616b..4639d4a1af 100644 --- a/pcbnew/dialogs/dialog_general_options.h +++ b/pcbnew/dialogs/dialog_general_options.h @@ -3,13 +3,10 @@ #include "dialog_general_options_BoardEditor_base.h" -/***********************************************************************/ class Dialog_GeneralOptions : public DialogGeneralOptionsBoardEditor_base -/***********************************************************************/ { private: - PCB_EDIT_FRAME* m_Parent; - BOARD * m_Board; + BOARD* m_Board; void init(); @@ -18,6 +15,8 @@ public: ~Dialog_GeneralOptions() {}; void OnOkClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event ); + + PCB_EDIT_FRAME* GetParent() { return (PCB_EDIT_FRAME*) wxDialog::GetParent(); } }; diff --git a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp index 28216450c3..95bdaaac8c 100644 --- a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp +++ b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.cpp @@ -33,7 +33,6 @@ void PCB_EDIT_FRAME::InstallConfigFrame( ) DIALOG_PCBNEW_CONFIG_LIBS::DIALOG_PCBNEW_CONFIG_LIBS( PCB_EDIT_FRAME* parent ): DIALOG_PCBNEW_CONFIG_LIBS_FBP(parent) { - m_Parent = parent; m_Config = wxGetApp().m_EDA_CommonConfig; Init( ); @@ -47,9 +46,8 @@ DIALOG_PCBNEW_CONFIG_LIBS::DIALOG_PCBNEW_CONFIG_LIBS( PCB_EDIT_FRAME* parent ): GetSizer()->SetSizeHints( this ); } -/*************************************/ + void DIALOG_PCBNEW_CONFIG_LIBS::Init() -/*************************************/ { SetFocus(); @@ -57,7 +55,7 @@ void DIALOG_PCBNEW_CONFIG_LIBS::Init() m_LibPathChanged = false; m_UserLibDirBufferImg = g_UserLibDirBuffer; // Save the original lib path - m_ListLibr->InsertItems( g_LibName_List, 0 ); + m_ListLibr->InsertItems( GetParent()->GetFootprintLibraryNames(), 0 ); // Display current modules doc file: m_Config->Read( wxT( "module_doc_file" ), g_DocModulesFileName ); @@ -65,9 +63,11 @@ void DIALOG_PCBNEW_CONFIG_LIBS::Init() // Load user libs paths: wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) ); + while( Token.HasMoreTokens() ) { wxString path = Token.GetNextToken(); + if( wxFileName::DirExists( path ) ) m_listUserPaths->Append(path); } @@ -85,15 +85,14 @@ void DIALOG_PCBNEW_CONFIG_LIBS::Init() } -/******************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnCancelClick( wxCommandEvent& event ) -/******************************************************************/ { // Recreate the user lib path if ( m_LibPathChanged ) { - for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ ) - wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString(ii)) ; + for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ ) + wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString(ii) ); + wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1); } @@ -101,51 +100,46 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnCancelClick( wxCommandEvent& event ) } -/**************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnOkClick( wxCommandEvent& event ) -/**************************************************************/ { - m_Config->Write( wxT( "module_doc_file" ), - m_TextHelpModulesFileName->GetValue() ); + m_Config->Write( wxT( "module_doc_file" ), m_TextHelpModulesFileName->GetValue() ); // Recreate the user lib path if ( m_LibPathChanged ) { g_UserLibDirBuffer.Empty(); + for ( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii ++ ) { if ( ii > 0 ) g_UserLibDirBuffer << wxT(";"); + g_UserLibDirBuffer << m_listUserPaths->GetString(ii); } } - // Set new active library list if the lib list of if default path list - // was modified + // Set new active library list if the lib list of if default path list was modified if( m_LibListChanged || m_LibPathChanged ) { // Recreate lib list - g_LibName_List.Clear(); + GetParent()->GetFootprintLibraryNames().Clear(); + for ( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii ++ ) - g_LibName_List.Add(m_ListLibr->GetString(ii) ); + GetParent()->GetFootprintLibraryNames().Add( m_ListLibr->GetString(ii) ); } - m_Parent->SaveProjectSettings(); + GetParent()->SaveProjectSettings(); EndModal( wxID_OK ); } -/**************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnCloseWindow( wxCloseEvent& event ) -/**************************************************************/ { EndModal( wxID_CANCEL ); } -/********************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonUpClick( wxCommandEvent& event ) -/********************************************************************/ { wxArrayInt selections; @@ -163,6 +157,7 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonUpClick( wxCommandEvent& event ) int jj = selections[ii]; EXCHG( libnames[jj], libnames[jj-1]); } + m_ListLibr->Set(libnames); // Reselect previously selected names @@ -176,13 +171,12 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonUpClick( wxCommandEvent& event ) } -/*********************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonDownClick( wxCommandEvent& event ) -/*********************************************************************/ { wxArrayInt selections; m_ListLibr->GetSelections(selections); + if ( selections.GetCount() <= 0 ) // No selection. return; @@ -195,8 +189,9 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonDownClick( wxCommandEvent& event ) for( int ii = selections.GetCount()-1; ii >= 0; ii-- ) { int jj = selections[ii]; - EXCHG( libnames[jj], libnames[jj+1]); + EXCHG( libnames[jj], libnames[jj+1] ); } + m_ListLibr->Set(libnames); // Reselect previously selected names @@ -205,37 +200,34 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonDownClick( wxCommandEvent& event ) int jj = selections[ii]; m_ListLibr->SetSelection(jj+1); } + m_LibListChanged = TRUE; } -/*********************************************************************/ -void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveLibClick( wxCommandEvent& event ) -/*********************************************************************/ /* Remove a library to the library list. * The real list (g_LibName_List) is not changed, so the change can be canceled */ +void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveLibClick( wxCommandEvent& event ) { wxArrayInt selections; - m_ListLibr->GetSelections(selections); + m_ListLibr->GetSelections( selections ); + for( int ii = selections.GetCount()-1; ii >= 0; ii-- ) { - m_ListLibr->Delete(selections[ii] ); + m_ListLibr->Delete( selections[ii] ); m_LibListChanged = TRUE; } } -/**************************************************************************/ -void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event ) -/**************************************************************************/ - /* Insert or add a library to the library list: * The new library is put in list before (insert button) the selection, * or added (add button) to end of list * The real list (g_LibName_List) is not changed, so the change can be canceled */ +void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event ) { int ii = 0; wxString libfilename; @@ -245,6 +237,7 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event ) m_ListLibr->GetSelections(selections); ii = selections.GetCount(); + if( ii > 0 ) ii = selections[0]; else @@ -265,9 +258,10 @@ void DIALOG_PCBNEW_CONFIG_LIBS::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() ); @@ -279,15 +273,17 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event ) * path is a sub path of these default paths */ libfilename = wxGetApp().ReturnFilenameWithRelativePathInLibPath( fn.GetFullPath() ); + // Remove extension: fn = libfilename; - fn.SetExt(wxEmptyString); + fn.SetExt( wxEmptyString ); libfilename = fn.GetFullPath(); //Add or insert new library name, if not already in list if( m_ListLibr->FindString( libfilename, fn.IsCaseSensitive() ) == wxNOT_FOUND ) { m_LibListChanged = TRUE; + if( event.GetId() == ID_ADD_LIB ) m_ListLibr->Append( libfilename ); else @@ -296,16 +292,14 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event ) else { wxString msg = wxT( "<" ) + libfilename + wxT( "> : " ) + - _( "Library already in use" ); + _( "Library already in use" ); DisplayError( this, msg ); } } } -/***********************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertPath( wxCommandEvent& event ) -/***********************************************************************/ { wxString path = wxGetApp().ReturnLastVisitedLibraryPath(); @@ -323,24 +317,27 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertPath( wxCommandEvent& event ) if( m_listUserPaths->FindString( path ) == wxNOT_FOUND ) { int ipos = m_listUserPaths->GetCount(); + if ( event.GetId() == wxID_INSERT_PATH ) { - if ( ipos ) ipos--; + if ( ipos ) + ipos--; + int jj = m_listUserPaths->GetSelection(); + if ( jj >= 0 ) ipos = jj; } // Ask the user if this is a relative path - int diag = wxMessageBox( - _( "Use a relative path?" ), - _( "Path type" ), - wxYES_NO | wxICON_QUESTION, this ); + int diag = wxMessageBox( _( "Use a relative path?" ), + _( "Path type" ), + wxYES_NO | wxICON_QUESTION, this ); if( diag == wxYES ) { // Make it relative wxFileName fn = path; - fn.MakeRelativeTo( wxT(".") ); + fn.MakeRelativeTo( wxT( "." ) ); path = fn.GetPathWithSep() + fn.GetFullName(); } @@ -351,26 +348,28 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertPath( wxCommandEvent& event ) // Display actual libraries paths: wxPathList libpaths = wxGetApp().GetLibraryPathList(); m_DefaultLibraryPathslistBox->Clear(); + for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ ) { m_DefaultLibraryPathslistBox->Append( libpaths[ii]); } } - else - DisplayError(this, _("Path already in use") ); + { + DisplayError( this, _( "Path already in use" ) ); + } wxGetApp().SaveLastVisitedLibraryPath( path ); } -/***********************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveUserPath( wxCommandEvent& event ) -/***********************************************************************/ { int ii = m_listUserPaths->GetSelection(); + if ( ii < 0 ) ii = m_listUserPaths->GetCount()-1; + if ( ii >= 0 ) { wxGetApp().RemoveLibraryPath( m_listUserPaths->GetStringSelection() ); @@ -381,16 +380,15 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveUserPath( wxCommandEvent& event ) // Display actual libraries paths: wxPathList libpaths = wxGetApp().GetLibraryPathList(); m_DefaultLibraryPathslistBox->Clear(); + for( unsigned ii = 0; ii < libpaths.GetCount(); ii++ ) { - m_DefaultLibraryPathslistBox->Append( libpaths[ii]); + m_DefaultLibraryPathslistBox->Append( libpaths[ii] ); } } -/**************************************************************************/ void DIALOG_PCBNEW_CONFIG_LIBS::OnBrowseModDocFile( wxCommandEvent& event ) -/**************************************************************************/ { wxString FullFileName; wxString docpath, filename; @@ -398,8 +396,7 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnBrowseModDocFile( wxCommandEvent& event ) docpath = wxGetApp().ReturnLastVisitedLibraryPath(wxT( "doc" )); wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath, - wxEmptyString, PdfFileWildcard, - wxFD_DEFAULT_STYLE ); + wxEmptyString, PdfFileWildcard, wxFD_DEFAULT_STYLE ); if( FilesDialog.ShowModal() != wxID_OK ) return; diff --git a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.h b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.h index 644ce60772..620c5f97c8 100644 --- a/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.h +++ b/pcbnew/dialogs/dialog_pcbnew_config_libs_and_paths.h @@ -12,8 +12,7 @@ class DIALOG_PCBNEW_CONFIG_LIBS : public DIALOG_PCBNEW_CONFIG_LIBS_FBP { private: - PCB_EDIT_FRAME* m_Parent; - wxConfig * m_Config; + wxConfig* m_Config; bool m_LibListChanged; bool m_LibPathChanged; wxString m_UserLibDirBufferImg; // Copy of original g_UserLibDirBuffer @@ -38,6 +37,8 @@ private: public: DIALOG_PCBNEW_CONFIG_LIBS( PCB_EDIT_FRAME * parent ); ~DIALOG_PCBNEW_CONFIG_LIBS() {}; + + PCB_EDIT_FRAME* GetParent() { return (PCB_EDIT_FRAME*) wxDialog::GetParent(); } }; #endif // _DIALOG_PCBNEW_CONFIG_LIBS_H_ diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index faf5cbbb07..bdd52da23d 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -285,7 +285,7 @@ this file again." ) ); GetBoard()->DisplayInfo( this ); /* reset the auto save timer */ - g_SaveTime = time( NULL ); + m_lastSaveTime = time( NULL ); // Refresh the 3D view, if any if( m_Draw3DFrame ) @@ -407,7 +407,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName ) ClearMsgPanel(); AppendMsgPanel( upperTxt, lowerTxt, CYAN ); - g_SaveTime = time( NULL ); /* Reset timer for the automatic saving */ + m_lastSaveTime = time( NULL ); /* Reset timer for the automatic saving */ GetScreen()->ClrModify(); return true; diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index d9a7e44a63..6b61a998b7 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -1,6 +1,7 @@ -/****************************************/ -/* Manage module (footprint) libraries. */ -/****************************************/ +/** + * @file librairi.cpp + * @brief Manage module (footprint) libraries. + */ #include "fctsys.h" #include "appl_wxstruct.h" @@ -238,7 +239,8 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) { fclose( lib_module ); wxString msg; - msg.Printf( _( "%s is not a Library file" ), GetChars(oldFileName.GetFullPath()) ); + msg.Printf( _( "%s is not a valid footprint library file" ), + GetChars( oldFileName.GetFullPath() ) ); DisplayError( this, msg ); return; } @@ -324,14 +326,16 @@ void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname ) if( !wxRenameFile( oldFileName.GetFullPath(), backupFileName.GetFullPath() ) ) { - DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) ); + DisplayError( this, _( "Could not create library back up file <" ) + + backupFileName.GetFullName() + wxT( ">." ) ); return; } /* The temporary file is renamed as the previous library. */ if( !wxRenameFile( newFileName.GetFullPath(), oldFileName.GetFullPath() ) ) { - DisplayError( this, wxT( "Librairi.cpp: rename err 2" ) ); + DisplayError( this, _( "Could not create temporary library file <" ) + + oldFileName.GetFullName() + wxT( ">." ) ); return; } @@ -349,7 +353,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn if( GetBoard()->m_Modules == NULL ) { - DisplayInfoMessage( this, _( " No modules to archive!" ) ); + DisplayInfoMessage( this, _( "No modules to archive!" ) ); return; } @@ -498,7 +502,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, if( ! input_lib.IsLibrary() ) { fclose( lib_module ); - msg.Printf( _( "File %s is not a eeschema library" ), GetChars( aLibName ) ); + msg.Printf( _( "File %s is not an EESchema library" ), GetChars( aLibName ) ); DisplayError( this, msg ); return false; } @@ -616,12 +620,14 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName, wxRemoveFile( oldFileName.GetFullPath() ); if( !wxRenameFile( aLibName, oldFileName.GetFullPath() ) ) - DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) ); + DisplayError( this, _( "Could not create library back up file <" ) + + oldFileName.GetFullName() + wxT( ">." ) ); /* The new library file is renamed */ if( !wxRenameFile( newFileName.GetFullPath(), aLibName ) ) { - DisplayError( this, wxT( "Librairi.cpp: rename NewLib err" ) ); + DisplayError( this, _( "Could not create temporary library file <" ) + + aLibName + wxT( ">." ) ); return false; } @@ -656,6 +662,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) moduleName = dlg.GetValue(); } + moduleName.Trim( true ); moduleName.Trim( false ); @@ -698,11 +705,13 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName ) void FOOTPRINT_EDIT_FRAME::Select_Active_Library() { wxString msg; + PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent(); - if( g_LibName_List.GetCount() == 0 ) + if( parent->GetFootprintLibraryNames().GetCount() == 0 || parent == NULL ) return; - EDA_LIST_DIALOG dlg( this, _( "Select Active Library:" ), g_LibName_List, m_CurrentLib ); + EDA_LIST_DIALOG dlg( this, _( "Select Active Library:" ), + parent->GetFootprintLibraryNames(), m_CurrentLib ); if( dlg.ShowModal() != wxID_OK ) return; @@ -726,7 +735,7 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() } -int FOOTPRINT_EDIT_FRAME::Create_Librairie( const wxString& aLibName ) +int FOOTPRINT_EDIT_FRAME::CreateLibrary( const wxString& aLibName ) { FILE* lib_module; wxString msg; diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 031eaae761..db08718aee 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -193,13 +193,15 @@ MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryFullFilename, FILE* file = NULL; unsigned ii; bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true; + PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent(); - for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) + for( ii = 0; ii < parent->GetFootprintLibraryNames().GetCount(); ii++ ) { if( one_lib ) fn = aLibraryFullFilename; else - fn = wxFileName( wxEmptyString, g_LibName_List[ii], ModuleFileExtension ); + fn = wxFileName( wxEmptyString, parent->GetFootprintLibraryNames()[ii], + ModuleFileExtension ); tmp = wxGetApp().FindLibraryPath( fn ); @@ -300,9 +302,10 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow, wxString CmpName; wxString msg; wxArrayString libnames_list; + PCB_EDIT_FRAME* parent = (PCB_EDIT_FRAME*) GetParent(); if( aLibraryFullFilename.IsEmpty() ) - libnames_list = g_LibName_List; + libnames_list = parent->GetFootprintLibraryNames(); else libnames_list.Add( aLibraryFullFilename ); diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 0c7bbeffbf..a34d5170e7 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -1,8 +1,7 @@ - -/*****************************************************/ -/* class FOOTPRINT_EDIT_FRAME: public EDA_DRAW_FRAME */ -/* Class for the footprint editor */ -/*****************************************************/ +/** + * @file module_editor_frame.h + * @brief Definition of class FOOTPRINT_EDIT_FRAME. + */ #ifndef _MODULE_EDITOR_FRAME_H_ #define _MODULE_EDITOR_FRAME_H_ @@ -21,36 +20,36 @@ public: ~FOOTPRINT_EDIT_FRAME(); - void InstallOptionsFrame( const wxPoint& pos ); + void InstallOptionsFrame( const wxPoint& pos ); - void OnCloseWindow( wxCloseEvent& Event ); - void CloseModuleEditor( wxCommandEvent& Event ); + void OnCloseWindow( wxCloseEvent& Event ); + void CloseModuleEditor( wxCommandEvent& Event ); - void Process_Special_Functions( wxCommandEvent& event ); + void Process_Special_Functions( wxCommandEvent& event ); /** * Function RedrawActiveWindoow - * daws the footprint editor BOARD, and others elements such as axis and grid. + * draws the footprint editor BOARD, and others elements such as axis and grid. */ - void RedrawActiveWindow( wxDC* DC, bool EraseBg ); + void RedrawActiveWindow( wxDC* DC, bool EraseBg ); /** * Function ReCreateHToolbar * create the main horizontal toolbar for the footprint editor */ - void ReCreateHToolbar(); + void ReCreateHToolbar(); - void ReCreateVToolbar(); - void ReCreateOptToolbar(); - void ReCreateAuxiliaryToolbar(); - void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); + void ReCreateVToolbar(); + void ReCreateOptToolbar(); + void ReCreateAuxiliaryToolbar(); + void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); /** * Function OnLeftDClick * handles the double click in the footprint editor: * If the double clicked item is editable: call the corresponding editor. */ - void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); + void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ); /** * Function OnRightClick @@ -58,15 +57,15 @@ public: * Create the pop up menu * After this menu is built, the standard ZOOM menu is added */ - bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); + bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ); /** * @brief (Re)Create the menubar for the module editor frame */ - void ReCreateMenuBar(); + void ReCreateMenuBar(); - void ToolOnRightClick( wxCommandEvent& event ); - void OnSelectOptionToolbar( wxCommandEvent& event ); + void ToolOnRightClick( wxCommandEvent& event ); + void OnSelectOptionToolbar( wxCommandEvent& event ); /** * Function OnHotKey @@ -76,36 +75,35 @@ public: * case insensitive *

*/ - void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, - EDA_ITEM* aItem = NULL ); + void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL ); - bool OnHotkeyEditItem( int aIdCommand ); - bool OnHotkeyDeleteItem( int aIdCommand ); - bool OnHotkeyMoveItem( int aIdCommand ); - bool OnHotkeyRotateItem( int aIdCommand ); + bool OnHotkeyEditItem( int aIdCommand ); + bool OnHotkeyDeleteItem( int aIdCommand ); + bool OnHotkeyMoveItem( int aIdCommand ); + bool OnHotkeyRotateItem( int aIdCommand ); /** * Function Show3D_Frame * displays 3D view of the footprint (module) being edited. */ - void Show3D_Frame( wxCommandEvent& event ); + void Show3D_Frame( wxCommandEvent& event ); - void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); - void OnVerticalToolbar( wxCommandEvent& aEvent ); + void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); + void OnVerticalToolbar( wxCommandEvent& aEvent ); - void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ); - void OnUpdateLibSelected( wxUpdateUIEvent& aEvent ); - void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent ); - void OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent ); - void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent ); - void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent ); - void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent ); + void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ); + void OnUpdateLibSelected( wxUpdateUIEvent& aEvent ); + void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent ); + void OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent ); + void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent ); + void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent ); + void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent ); /** * Function LoadModuleFromBoard * called from the main toolbar to load a footprint from board mainly to edit it. */ - void LoadModuleFromBoard( wxCommandEvent& event ); + void LoadModuleFromBoard( wxCommandEvent& event ); /** * Virtual Function OnModify() @@ -120,7 +118,7 @@ public: * Function ToPrinter * Install the print dialog */ - void ToPrinter( wxCommandEvent& event ); + void ToPrinter( wxCommandEvent& event ); /** * Virtual function PrintPage @@ -141,10 +139,10 @@ public: * delete all and reinitialize the current board * @param aQuery = true to prompt user for confirmation, false to initialize silently */ - bool Clear_Pcb( bool aQuery ); + bool Clear_Pcb( bool aQuery ); /* handlers for block commands */ - virtual int ReturnBlockCommand( int key ); + virtual int ReturnBlockCommand( int key ); /** * Function HandleBlockPlace @@ -167,7 +165,7 @@ public: */ virtual bool HandleBlockEnd( wxDC* DC ); - BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 ); + BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 ); /* Undo and redo functions */ public: @@ -207,7 +205,7 @@ private: * - Place the current edited library component in Redo list * - Get old version of the current edited library component */ - void GetComponentFromUndoList( wxCommandEvent& event ); + void GetComponentFromUndoList( wxCommandEvent& event ); /** * Fucntion GetComponentFromRedoList @@ -215,25 +213,25 @@ private: * - Place the current edited library component in undo list * - Get old version of the current edited library component */ - void GetComponentFromRedoList( wxCommandEvent& event ); + void GetComponentFromRedoList( wxCommandEvent& event ); /** * Function UpdateTitle * updates window title according to m_CurrentLib. */ - void UpdateTitle(); + void UpdateTitle(); public: // Footprint edition - void Place_Ancre( MODULE* module ); - void RemoveStruct( EDA_ITEM* Item ); + void Place_Ancre( MODULE* module ); + void RemoveStruct( EDA_ITEM* Item ); /** * Function Transform * performs a geometric transform on the current footprint. */ - void Transform( MODULE* module, int transform ); + void Transform( MODULE* module, int transform ); // importing / exporting Footprint /** @@ -248,7 +246,7 @@ public: * @param aCreateSysLib : true = use default lib path to create lib * false = use current path or last used path to export the footprint */ - void Export_Module( MODULE* aModule, bool aCreateSysLib ); + void Export_Module( MODULE* aModule, bool aCreateSysLib ); /** * Function Import_Module @@ -263,11 +261,11 @@ public: /** * Function Load_Module_From_BOARD - * load in Modedit a footfrint from the main board + * load in Modedit a footprint from the main board * @param Module = the module to load. If NULL, a module reference will we asked to user * @return true if a module isloaded, false otherwise. */ - bool Load_Module_From_BOARD( MODULE* Module ); + bool Load_Module_From_BOARD( MODULE* Module ); /** * Function Select_1_Module_From_BOARD @@ -275,7 +273,7 @@ public: * @return a pointer to a module if this module is selected or NULL otherwise * @param aPcb = the board from modules can be loaded */ - MODULE* Select_1_Module_From_BOARD( BOARD* aPcb ); + MODULE* Select_1_Module_From_BOARD( BOARD* aPcb ); // functions to edit footprint edges @@ -286,7 +284,7 @@ public: * @param aEdge = edge to edit, or NULL. If aEdge == NULL change * the width of all footprint's edges */ - void Edit_Edge_Width( EDGE_MODULE* aEdge ); + void Edit_Edge_Width( EDGE_MODULE* aEdge ); /** * Function Edit_Edge_Layer @@ -294,14 +292,14 @@ public: * if Edge == NULL change the layer of the entire footprint edges * @param Edge = edge to edit, or NULL */ - void Edit_Edge_Layer( EDGE_MODULE* Edge ); + void Edit_Edge_Layer( EDGE_MODULE* Edge ); /** * Function Delete_Edge_Module * deletes EDGE_MODULE Edge * @param Edge = edge to delete */ - void Delete_Edge_Module( EDGE_MODULE* Edge ); + void Delete_Edge_Module( EDGE_MODULE* Edge ); /** * Function Begin_Edge_Module @@ -318,7 +316,7 @@ public: * Function End_Edge_Module * terminates a move or create edge function */ - void End_Edge_Module( EDGE_MODULE* Edge ); + void End_Edge_Module( EDGE_MODULE* Edge ); /** * Function Enter_Edge_Width @@ -328,23 +326,24 @@ public: * @param aEdge = edge to edit, or NULL * changes ModuleSegmentWidth (global) = new width */ - void Enter_Edge_Width( EDGE_MODULE* aEdge ); + void Enter_Edge_Width( EDGE_MODULE* aEdge ); - /* Function to initialise the move function params of a graphic item type DRAWSEGMENT */ - void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC ); + /* Function to initialize the move function params of a graphic item type DRAWSEGMENT */ + void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC ); /* Function to place a graphic item type EDGE_MODULE currently moved */ - void Place_EdgeMod( EDGE_MODULE* drawitem ); + void Place_EdgeMod( EDGE_MODULE* drawitem ); // handlers for libraries: - void Delete_Module_In_Library( const wxString& libname ); - int Create_Librairie( const wxString& LibName ); - void Select_Active_Library(); + void Delete_Module_In_Library( const wxString& libname ); - wxString GetCurrentLib() const { return m_CurrentLib; }; + int CreateLibrary( const wxString& LibName ); + + void Select_Active_Library(); + + wxString GetCurrentLib() const { return m_CurrentLib; }; DECLARE_EVENT_TABLE() }; #endif // #define _MODULE_EDITOR_FRAME_H_ - diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index a3fda27a65..36d303d04c 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -1,6 +1,7 @@ -/*************************/ -/* PCBNEW: main program */ -/*************************/ +/** + * @file pcbnew.cpp + * @file PCBNEW: main program. + */ #include "fctsys.h" #include "appl_wxstruct.h" @@ -48,7 +49,7 @@ int g_MaxLinksShowed; int g_MagneticPadOption = capture_cursor_in_track_tool; int g_MagneticTrackOption = capture_cursor_in_track_tool; -wxPoint g_Offset_Module; /* Offset de trace du modul en depl */ +wxPoint g_Offset_Module; /* Distance to offset module trace when moving. */ // Wildcard for footprint libraries filesnames const wxString g_FootprintLibFileWildcard( wxT( "Kicad footprint library file (*.mod)|*.mod" ) ); @@ -62,6 +63,7 @@ wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" ); IMPLEMENT_APP( EDA_APP ) + /* MacOSX: Needed for file association * http://wiki.wxwidgets.org/WxMac-specific_topics */ @@ -82,11 +84,11 @@ bool EDA_APP::OnInit() wxFileName fn; PCB_EDIT_FRAME* frame = NULL; - InitEDA_Appl( wxT( "PCBnew" ), APP_PCBNEW_T ); + InitEDA_Appl( wxT( "PCBNew" ), APP_PCBNEW_T ); if( m_Checker && m_Checker->IsAnotherRunning() ) { - if( !IsOK( NULL, _( "PCBnew is already running, Continue?" ) ) ) + if( !IsOK( NULL, _( "PCBNew is already running, Continue?" ) ) ) return false; } @@ -113,7 +115,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); /* Must be called before creating the main frame in order to * display the real hotkeys in menus or tool tips */ - ReadHotkeyConfig( wxT("PcbFrame"), g_Board_Editor_Hokeys_Descr ); + ReadHotkeyConfig( wxT( "PcbFrame" ), g_Board_Editor_Hokeys_Descr ); frame = new PCB_EDIT_FRAME( NULL, wxT( "PCBNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); frame->UpdateTitle(); @@ -147,7 +149,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); frame->UpdateTitle(); frame->UpdateFileHistory( frame->GetScreen()->GetFileName() ); frame->OnModify(); // Ready to save the new empty board - g_SaveTime = time( NULL ); // Init the time out to save the board + frame->ResetAutoSaveTimeOut(); wxString msg; msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ), @@ -157,6 +159,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); } frame->LoadProjectSettings( fn.GetFullPath() ); + // update the layer names in the listbox frame->ReCreateLayerBox( NULL ); diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index f1104ea9e6..fab3ef1837 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -135,14 +135,6 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) } -/** - * Read the project configuration file settings. - * - * @param aProjectFileName = The project file name to load. If aProjectFileName - * is not found load the default project file kicad.pro - * and initialize setting to their default value. - * @return Always returns true. - */ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) { wxFileName fn = aProjectFileName; @@ -153,17 +145,16 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer ); /* Initialize default values. */ - g_LibName_List.Clear(); + m_libraryNames.Clear(); wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false ); /* User library path takes precedent over default library search paths. */ wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); - /* Reset the items visibility flag when loading a new config - * Because it could creates SERIOUS mistakes for the user, - * if board items are not visible after loading a board... - * Grid and ratsnest can be left to their previous state + /* Reset the items visibility flag when loading a new configuration because it could + * create SERIOUS mistakes for the user f board items are not visible after loading + * a board. Grid and ratsnest can be left to their previous state. */ bool showGrid = IsElementVisible( GRID_VISIBLE ); bool showRats = IsElementVisible( RATSNEST_VISIBLE ); @@ -191,15 +182,6 @@ void PCB_EDIT_FRAME::SaveProjectSettings() } -/** - * Return project file parameter list for PCBNew. - * - * Populate the project file parameter array specific to PCBNew if it hasn't - * already been populated and return a reference to the array to the caller. - * Creating the parameter list at run time has the advantage of being able - * to define local variables. The old method of statically building the array - * at compile time requiring global variable definitions by design. - */ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() { if( !m_projectFileParams.empty() ) @@ -207,7 +189,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),&g_UserLibDirBuffer, GROUPLIB ) ); - m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), &g_LibName_List, + m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ), + &m_libraryNames, GROUPLIB ) ); m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "PadDrlX" ), &g_Pad_Master.m_Drill.x, 320, 0, 0x7FFF ) ); @@ -251,22 +234,6 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetProjectFileParameters() -/* - * Return the PCBNew applications settings list. - * - * This replaces the old statically define list that had the project - * file settings and the application settings mixed together. This - * was confusing and caused some settings to get saved and loaded - * incorrectly. Currently, only the settings that are needed at start - * up by the main window are defined here. There are other locally used - * settings are scattered throughout the PCBNew source code. If you need - * to define a configuration setting that need to be loaded at run time, - * this is the place to define it. - * - * @todo: Define the configuration variables as member variables instead of - * global variables or move them to the object class where they are - * used. - */ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() { if( !m_configSettings.empty() ) @@ -401,7 +368,7 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() // Miscellaneous: m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "RotationAngle" ), &g_RotationAngle, 900, 450, 900 ) ); - m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TimeOut" ), &g_TimeOut, + m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TimeOut" ), &m_saveInterval, 600, 0, 60000 ) ); m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "MaxLnkS" ), &g_MaxLinksShowed, 3, 0, 15 ) ); @@ -415,8 +382,6 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings() } -/** - */ void PCB_EDIT_FRAME::SaveMacros() { wxFileName fn; @@ -462,13 +427,11 @@ void PCB_EDIT_FRAME::SaveMacros() } } - xml.SetFileEncoding( wxT("UTF-8") ); + xml.SetFileEncoding( wxT( "UTF-8" ) ); xml.Save( dlg.GetFilename() ); } -/** - */ void PCB_EDIT_FRAME::ReadMacros() { wxString str;