~cern-kicad/kicad/kicad-pns-tom

« back to all changes in this revision

Viewing changes to eeschema/eeschema_config.cpp

  • Committer: Maciej Suminski
  • Date: 2013-08-02 13:57:24 UTC
  • mfrom: (4024.1.238 kicad)
  • mto: This revision was merged to the branch mainline in revision 4221.
  • Revision ID: maciej.suminski@cern.ch-20130802135724-gix6orezshkukodv
Upstream merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <hotkeys.h>
40
40
#include <sch_sheet.h>
41
41
#include <class_libentry.h>
 
42
#include <worksheet_shape_builder.h>
42
43
 
43
44
#include <dialog_hotkeys_editor.h>
44
45
 
139
140
    switch( id )
140
141
    {
141
142
    case ID_CONFIG_SAVE:
142
 
        schFrame->SaveProjectFile();
 
143
        schFrame->SaveProjectSettings( false );
143
144
        break;
144
145
 
145
146
    case ID_CONFIG_READ:
207
208
    switch( id )
208
209
    {
209
210
    case ID_CONFIG_SAVE:
210
 
        SaveProjectFile();
 
211
        SaveProjectSettings( false );
211
212
        break;
212
213
 
213
214
    case ID_CONFIG_READ:
303
304
 
304
305
    GetScreen()->SetGrid( grid_list[ (size_t) dlg.GetGridSelection() ].m_Size );
305
306
 
 
307
    int sep, firstId;
 
308
    dlg.GetRefIdSeparator( sep, firstId);
 
309
    if( sep != (int)LIB_COMPONENT::GetSubpartIdSeparator() ||
 
310
        firstId != (int)LIB_COMPONENT::GetSubpartFirstId() )
 
311
    {
 
312
        LIB_COMPONENT::SetSubpartIdNotation( sep, firstId );
 
313
        SaveProjectSettings( true );
 
314
    }
 
315
 
306
316
    SetDefaultBusThickness( dlg.GetBusWidth() );
307
317
    SetDefaultLineThickness( dlg.GetLineWidth() );
308
318
    SetDefaultLabelSize( dlg.GetTextSize() );
344
354
}
345
355
 
346
356
 
347
 
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParameters()
 
357
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
348
358
{
349
359
    if( !m_projectFileParams.empty() )
350
360
        return m_projectFileParams;
351
361
 
 
362
    m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
 
363
                                        &BASE_SCREEN::m_PageLayoutDescrFileName ) );
 
364
 
 
365
    m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ),
 
366
                                        LIB_COMPONENT::SubpartIdSeparatorPtr(),
 
367
                                        IsGOST() ? '.' : 0, 0, 126 ) );
 
368
    m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ),
 
369
                                        LIB_COMPONENT::SubpartFirstIdPtr(),
 
370
                                        IsGOST() ? '1' : 'A', '1', 'z' ) );
 
371
 
352
372
    m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
353
373
                                                           &m_userLibraryPath ) );
354
374
    m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
395
415
    wxGetApp().RemoveLibraryPath( m_userLibraryPath );
396
416
 
397
417
    if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
398
 
                                       GetProjectFileParameters(),
 
418
                                       GetProjectFileParametersList(),
399
419
                                       !aForceReread ) )
400
420
    {
401
421
        m_componentLibFiles = liblist_tmp;
402
422
        IsRead = false;
403
423
    }
404
424
 
 
425
    // Verify some values, because the config file can be edited by hand,
 
426
    // and have bad values:
 
427
    LIB_COMPONENT::SetSubpartIdNotation( LIB_COMPONENT::GetSubpartIdSeparator(),
 
428
                                         LIB_COMPONENT::GetSubpartFirstId() );
 
429
 
 
430
    // Load the page layout decr file, from the filename stored in
 
431
    // BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
 
432
    // If empty, the default descr is loaded
 
433
    WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
 
434
    pglayout.SetPageLayout(BASE_SCREEN::m_PageLayoutDescrFileName);
 
435
 
 
436
    // Load libraries.
405
437
    // User library path takes precedent over default library search paths.
406
438
    wxGetApp().InsertLibraryPath( m_userLibraryPath, 1 );
407
439
 
418
450
}
419
451
 
420
452
 
421
 
void SCH_EDIT_FRAME::SaveProjectFile()
 
453
void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
422
454
{
423
455
    wxFileName fn;
424
456
 
428
460
    if( !IsWritable( fn ) )
429
461
        return;
430
462
 
431
 
    wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
 
463
    if( aAskForSave )
 
464
    {
 
465
        wxFileDialog dlg( this, _( "Save Project File" ),
 
466
                          fn.GetPath(), fn.GetFullName(),
 
467
                          ProjectFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR );
 
468
 
 
469
        if( dlg.ShowModal() == wxID_CANCEL )
 
470
            return;
 
471
 
 
472
        wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
 
473
                                       GetProjectFileParametersList() );
 
474
    }
 
475
    else
 
476
        wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP,
 
477
                                       GetProjectFileParametersList() );
432
478
}
433
479
 
434
480
static const wxString DefaultBusWidthEntry( wxT( "DefaultBusWidth" ) );