Commit b9b341dc authored by Wayne Stambaugh's avatar Wayne Stambaugh

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.
parent de96452c
......@@ -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;
......
/*************/
/* 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;
......
......@@ -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 );
/**
......
......@@ -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<TRACK> g_CurrentTrackList;
......@@ -56,10 +51,10 @@ extern DLIST<TRACK> 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__ */
......@@ -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 ) { }
......
......@@ -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.
* <p>
* 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.
* </p>
*/
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 );
......
......@@ -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 );
......
......@@ -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:
......
......@@ -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(); }
};
......
......@@ -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_
......@@ -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;
......
/****************************************/
/* 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;
......
......@@ -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 );
......
This diff is collapsed.
/*************************/
/* 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 );
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment