Commit 6fcd9eb8 authored by jean-pierre charras's avatar jean-pierre charras

Eechema: fix bug : when saving the schematic project, the lib cache was saved...

Eechema: fix bug : when saving the schematic project, the lib cache was saved under the current sheet opened, not the root sheet.
Pcbnew: clamp default plot line width between 0.02 and 2 mm. the other bug (saving this parameter in internal units instead of mm is not fixed)
parent 69b7c2a1
...@@ -388,7 +388,7 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event ) ...@@ -388,7 +388,7 @@ void EDA_BASE_FRAME::OnSelectPreferredEditor( wxCommandEvent& event )
wildcard += wxT( ".exe" ); wildcard += wxT( ".exe" );
#endif #endif
wildcard.Printf( _( "Executable file (%s)|%s" ), wildcard.Printf( _( "Executable file (%s)|%s" ),
GetChars( wildcard ), GetChars( wildcard ) ); GetChars( wildcard ), GetChars( wildcard ) );
wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(), wxFileDialog dlg( this, _( "Select Preferred Editor" ), fn.GetPath(),
......
...@@ -68,6 +68,10 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" ); ...@@ -68,6 +68,10 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" );
// Default font size // Default font size
#define FONT_DEFAULT_SIZE 10 // Default font size. #define FONT_DEFAULT_SIZE 10 // Default font size.
// some key strings used to store parameters in config
static wxString backgroundColorKey( wxT( "BackgroundColor" ) );
static wxString showPageLimitsKey( wxT( "ShowPageLimits" ) );
static wxString workingDirKey( wxT( "WorkingDir" ) ) ;
static wxString languageCfgKey( wxT( "LanguageID" ) ); static wxString languageCfgKey( wxT( "LanguageID" ) );
...@@ -649,22 +653,23 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory ) ...@@ -649,22 +653,23 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
m_fileHistory.Load( *m_settings ); m_fileHistory.Load( *m_settings );
m_settings->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits ); m_settings->Read( showPageLimitsKey, &g_ShowPageLimits );
if( aReopenLastUsedDirectory ) if( aReopenLastUsedDirectory )
{ {
if( m_settings->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) ) if( m_settings->Read( workingDirKey, &Line ) && wxDirExists( Line ) )
{ {
wxSetWorkingDirectory( Line ); wxSetWorkingDirectory( Line );
} }
} }
int draw_bg_color;
// FIXME OSX Mountain Lion (10.8) // FIXME OSX Mountain Lion (10.8)
// Seems that Read doesn't found anything and ColorFromInt Asserts - I'm unable to reproduce on 10.7 // Seems that Read doesn't found anything and ColorFromInt Asserts - I'm unable to reproduce on 10.7
// In general terms i think is better have a failsafe BLACK default than an uninit variable // In general terms i think is better have a failsafe default than an uninit variable
m_settings->Read( wxT( "BgColor" ), &draw_bg_color , BLACK ); int draw_bg_color = (int)BLACK; // Default for all apps but Eeschema
if( m_Id == APP_EESCHEMA_T )
draw_bg_color = (int)WHITE; // Default for Eeschema
m_settings->Read( backgroundColorKey, &draw_bg_color );
g_DrawBgColor = ColorFromInt( draw_bg_color ); g_DrawBgColor = ColorFromInt( draw_bg_color );
// Load per-user search paths from settings file // Load per-user search paths from settings file
...@@ -689,9 +694,9 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory ) ...@@ -689,9 +694,9 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
void EDA_APP::SaveSettings() void EDA_APP::SaveSettings()
{ {
wxASSERT( m_settings != NULL ); wxASSERT( m_settings != NULL );
m_settings->Write( wxT( "ShowPageLimits" ), g_ShowPageLimits ); m_settings->Write( showPageLimitsKey, g_ShowPageLimits );
m_settings->Write( wxT( "WorkingDir" ), wxGetCwd() ); m_settings->Write( workingDirKey, wxGetCwd() );
m_settings->Write( wxT( "BgColor" ), (long) g_DrawBgColor ); m_settings->Write( backgroundColorKey, (long) g_DrawBgColor );
// Save the file history list // Save the file history list
m_fileHistory.Save( *m_settings ); m_fileHistory.Save( *m_settings );
......
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2013 CERN (www.cern.ch) * Copyright (C) 2013 CERN (www.cern.ch)
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -55,11 +55,11 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo ...@@ -55,11 +55,11 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
if( aScreen == NULL ) if( aScreen == NULL )
aScreen = GetScreen(); aScreen = GetScreen();
/* If no name exists in the window yet - save as new. */ // If no name exists in the window yet - save as new.
if( aScreen->GetFileName().IsEmpty() ) if( aScreen->GetFileName().IsEmpty() )
aSaveUnderNewName = true; aSaveUnderNewName = true;
/* Construct the name of the file to be saved */ // Construct the name of the file to be saved
schematicFileName = aScreen->GetFileName(); schematicFileName = aScreen->GetFileName();
if( aSaveUnderNewName ) if( aSaveUnderNewName )
...@@ -79,9 +79,10 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo ...@@ -79,9 +79,10 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
else else
{ {
// Sheet file names are relative to the root sheet path which is the current // Sheet file names are relative to the root sheet path which is the current
// working directory. The IsWritable funtion expects the path to be set. // working directory. The IsWritable function expects the path to be set.
if( schematicFileName.GetPath().IsEmpty() ) if( schematicFileName.GetPath().IsEmpty() )
schematicFileName.Assign( wxFileName::GetCwd(), schematicFileName.GetFullName() ); schematicFileName.Assign( wxFileName::GetCwd(),
schematicFileName.GetFullName() );
} }
if( !IsWritable( schematicFileName ) ) if( !IsWritable( schematicFileName ) )
...@@ -167,7 +168,7 @@ void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event ) ...@@ -167,7 +168,7 @@ void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event )
case ID_SAVE_ONE_SHEET_UNDER_NEW_NAME: case ID_SAVE_ONE_SHEET_UNDER_NEW_NAME:
if( SaveEEFile( NULL, true ) ) if( SaveEEFile( NULL, true ) )
{ {
CreateArchiveLibraryCacheFile(); CreateArchiveLibraryCacheFile( true );
} }
break; break;
} }
...@@ -468,7 +469,13 @@ void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent ) ...@@ -468,7 +469,13 @@ void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent )
SCH_SCREENS ScreenList; SCH_SCREENS ScreenList;
fn = g_RootSheet->GetFileName(); fn = g_RootSheet->GetFileName();
tmp.AssignDir( fn.GetPath() );
// Ensure a path exists. if no path, assume the cwd is used
// The IsWritable function expects the path to be set
if( !fn.GetPath().IsEmpty() )
tmp.AssignDir( fn.GetPath() );
else
tmp.AssignDir( wxGetCwd() );
if( !IsWritable( tmp ) ) if( !IsWritable( tmp ) )
return; return;
......
...@@ -44,9 +44,15 @@ ...@@ -44,9 +44,15 @@
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile() bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile( bool aUseCurrentSheetFilename )
{ {
wxFileName fn = GetScreen()->GetFileName(); wxFileName fn;
if( aUseCurrentSheetFilename )
fn = GetScreen()->GetFileName();
else
fn = g_RootSheet->GetScreen()->GetFileName();
fn.SetName( fn.GetName() + wxT( "-cache" ) ); fn.SetName( fn.GetName() + wxT( "-cache" ) );
fn.SetExt( SchematicLibraryFileExtension ); fn.SetExt( SchematicLibraryFileExtension );
...@@ -102,7 +108,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) ...@@ -102,7 +108,7 @@ bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName )
} }
catch( ... /* IO_ERROR ioe */ ) catch( ... /* IO_ERROR ioe */ )
{ {
msg.Printf( _( "Failed to create component library file <%s>" ), msg.Printf( _( "Failed to create component library file <%s>" ),
GetChars( aFileName ) ); GetChars( aFileName ) );
DisplayError( this, msg ); DisplayError( this, msg );
return false; return false;
......
...@@ -1201,9 +1201,11 @@ public: ...@@ -1201,9 +1201,11 @@ public:
* creates a library file with the name of the root document plus the '-cache' suffix, * creates a library file with the name of the root document plus the '-cache' suffix,
* That file will contain all components used in the current schematic. * That file will contain all components used in the current schematic.
* *
* @return True if the file was written successfully. * @param aUseCurrentSheetFilename = false to use the root shhet filename
* (default) or true to use the currently opened sheet.
* @return true if the file was written successfully.
*/ */
bool CreateArchiveLibraryCacheFile( void ); bool CreateArchiveLibraryCacheFile( bool aUseCurrentSheetFilename = false );
/** /**
* Function CreateArchiveLibrary * Function CreateArchiveLibrary
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include <convert_to_biu.h> #include <convert_to_biu.h>
#define PLOT_LINEWIDTH_MIN 0 #define PLOT_LINEWIDTH_MIN (0.02*IU_PER_MM) // min value for default line thickness
#define PLOT_LINEWIDTH_MAX (200*IU_PER_MILS) #define PLOT_LINEWIDTH_MAX (2*IU_PER_MM) // max value for default line thickness
#define HPGL_PEN_DIAMETER_MIN 0 #define HPGL_PEN_DIAMETER_MIN 0
#define HPGL_PEN_DIAMETER_MAX 100 // Unit = mil #define HPGL_PEN_DIAMETER_MAX 100 // Unit = mil
#define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s #define HPGL_PEN_SPEED_MIN 1 // this param is always in cm/s
...@@ -40,15 +40,14 @@ ...@@ -40,15 +40,14 @@
#define HPGL_PEN_NUMBER_MIN 1 #define HPGL_PEN_NUMBER_MIN 1
#define HPGL_PEN_NUMBER_MAX 16 #define HPGL_PEN_NUMBER_MAX 16
#define HPGL_PEN_OVERLAP_MIN 0 #define HPGL_PEN_OVERLAP_MIN 0
#define HPGL_PEN_OVERLAP_MAX 50 // Unit = mil #define HPGL_PEN_OVERLAP_MAX 50 // Unit = mil
/** /**
* Default line thickness in PCnew units used to draw or plot items having a * Default line thickness in internal units used to draw or plot items using a
* default thickness line value (Frame references) (i.e. = 0 ). * default thickness line value (Frame references)
* 0 = single pixel line width.
*/ */
int g_DrawDefaultLineThickness = 6*IU_PER_MILS; int g_DrawDefaultLineThickness = (0.15*IU_PER_MM);
using namespace PCBPLOTPARAMS_T; using namespace PCBPLOTPARAMS_T;
...@@ -114,7 +113,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS() ...@@ -114,7 +113,7 @@ PCB_PLOT_PARAMS::PCB_PLOT_PARAMS()
m_textMode = PLOTTEXTMODE_DEFAULT; m_textMode = PLOTTEXTMODE_DEFAULT;
// This parameter controls if the NPTH pads will be plotted or not // This parameter controls if the NPTH pads will be plotted or not
// it is are "local" parameters // it is a "local" parameter
m_skipNPTH_Pads = false; m_skipNPTH_Pads = false;
} }
......
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