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 <config_params.h>
30 #include <kiface_i.h>
31 #include <project.h>
32 
33 #include <cvpcb_mainframe.h>
34 
35 
37 {
38  if( !m_projectFileParams.empty() )
39  return m_projectFileParams;
40 
42 
44  wxT( "EquName" ), &m_EquFilesNames, GROUP_CVP_EQU ) );
45 
46  return m_projectFileParams;
47 }
48 
49 
51 {
52  PROJECT& prj = Prj();
53 
54  m_ModuleLibNames.Clear();
55  m_EquFilesNames.Clear();
56 
57  prj.ConfigLoad( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters() );
58 }
59 
60 
62 {
63  PROJECT& prj = Prj();
64  wxFileName fn = prj.GetProjectFullName();
65 
66  if( !IsWritable( fn ) )
67  {
68  wxMessageBox( _( "Project file \"%s\" is not writable" ), fn.GetFullPath() );
69  return;
70  }
71 
72  wxString pro_name = fn.GetFullPath();
73 
74  prj.ConfigSave( Kiface().KifaceSearch(), GROUP_CVP, GetProjectFileParameters(), pro_name );
75 }
76 
PROJECT holds project specific data.
Definition: project.h:59
wxArrayString m_EquFilesNames
bool IsWritable(const wxFileName &aFileName)
Checks if aFileName can be written.
std::vector< PARAM_CFG * > & GetProjectFileParameters(void)
Function GetProjectFileParameters return project file parameter list for CvPcb.
Definition: cfg.cpp:36
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:385
wxArrayString m_ModuleLibNames
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
std::vector< PARAM_CFG * > m_projectFileParams
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const std::vector< PARAM_CFG * > &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative.
Definition: project.cpp:350
#define GROUP_CVP
Definition: config_params.h:49
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
void SaveProjectFile()
Function SaveProjectFile Saves the CvPcb configuration parameter from the project (....
Definition: cfg.cpp:61
PARAM_CFG is a base class which establishes the interface functions ReadParam and SaveParam,...
Definition: config_params.h:98
#define _(s)
Definition: 3d_actions.cpp:33
void LoadProjectFile()
Function LoadProjectFile reads the CvPcb configuration parameter from the project (....
Definition: cfg.cpp:50
#define GROUP_CVP_EQU
Definition: config_params.h:50
#define GROUP_PCB_LIBS
(and few for component editor).
Definition: config_params.h:45