KiCad PCB EDA Suite
cfg.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #include <fctsys.h>
30 #include <kiface_i.h>
31 #include <fp_lib_table.h>
32 #include <id.h>
33 #include <common.h>
34 #include <gestfich.h>
35 #include <config_params.h>
37 #include <fp_lib_table.h>
38 #include <confirm.h>
39 
40 #include <cvpcb.h>
41 #include <cvpcb_mainframe.h>
43 
44 
46 {
47  if( !m_projectFileParams.empty() )
48  return m_projectFileParams;
49 
51 
53  wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) );
54 
55  return m_projectFileParams;
56 }
57 
58 
60 {
61  PROJECT& prj = Prj();
62 
63  m_ModuleLibNames.Clear();
64  m_EquFilesNames.Clear();
65 
66  prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() );
67 }
68 
69 
71 {
72  PROJECT& prj = Prj();
73  wxFileName fn = prj.GetProjectFullName();
74 
75  if( !IsWritable( fn ) )
76  {
77  wxMessageBox( _( "Project file '%s' is not writable" ), fn.GetFullPath() );
78  return;
79  }
80 
81  wxString pro_name = fn.GetFullPath();
82 
83  prj.ConfigSave( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters(), pro_name );
84 }
85 
A list of parameters type.
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:307
Class PROJECT holds project specific data.
Definition: project.h:52
This file is part of the common library TODO brief description.
wxArrayString m_EquFilesNames
This file is part of the common library.
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
The common library.
bool IsWritable(const wxFileName &aFileName)
Function IsWritable checks if aFileName can be written.
Definition: basicframe.cpp:532
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
wxArrayString m_ModuleLibNames
The common library.
#define GROUP_CVP
Definition: config_params.h:52
Class PARAM_CFG_BASE is a base class which establishes the interface functions ReadParam and SavePara...
Definition: config_params.h:94
PARAM_CFG_ARRAY m_projectFileParams
void SaveProjectFile()
Function SaveProjectFile Saves the CvPcb configuration parameter from the project (...
Definition: cfg.cpp:70
The common library.
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:342
void LoadProjectFile()
Function LoadProjectFile reads the CvPcb configuration parameter from the project (...
Definition: cfg.cpp:59
PARAM_CFG_ARRAY & GetProjectFileParameters(void)
Function GetProjectFileParameters return project file parameter list for CvPcb.
Definition: cfg.cpp:45
#define GROUP_CVP_EQU
Definition: config_params.h:53
#define GROUP_PCB_LIBS
(and few for component editor).
Definition: config_params.h:48