KiCad PCB EDA Suite
kiface_base.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) 2014 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <kiface_base.h>
27 #include <kiway.h>
28 #include <search_stack.h>
29 #include <systemdirsappend.h>
30 
33 static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
34 {
35  SEARCH_STACK bases;
36 
37  SystemDirsAppend( &bases );
38  aDst->Clear();
39 
40  for( unsigned i = 0; i < bases.GetCount(); ++i )
41  {
42  wxFileName fn( bases[i], wxEmptyString );
43 
44  // Add schematic library file path to search path list.
45  // we must add <kicad path>/library and <kicad path>/library/doc
46  if( aId == KIWAY::FACE_SCH )
47  {
48  // Add schematic doc file path (library/doc) to search path list.
49 
50  fn.AppendDir( wxT( "library" ) );
51  aDst->AddPaths( fn.GetPath() );
52 
53  fn.AppendDir( wxT( "doc" ) );
54  aDst->AddPaths( fn.GetPath() );
55 
56  fn.RemoveLastDir();
57  fn.RemoveLastDir(); // "../../" up twice, removing library/doc/
58 
59  fn.AppendDir( wxT( "symbols" ) );
60  aDst->AddPaths( fn.GetPath() );
61 
62  fn.AppendDir( wxT( "doc" ) );
63  aDst->AddPaths( fn.GetPath() );
64 
65  fn.RemoveLastDir();
66  fn.RemoveLastDir(); // "../../" up twice, removing symbols/doc/
67  }
68 
69  // Add PCB library file path to search path list.
70  if( aId == KIWAY::FACE_PCB || aId == KIWAY::FACE_CVPCB )
71  {
72  fn.AppendDir( wxT( "modules" ) );
73  aDst->AddPaths( fn.GetPath() );
74  fn.RemoveLastDir();
75 
76  fn.AppendDir( wxT( "footprints" ) );
77  aDst->AddPaths( fn.GetPath() );
78  fn.RemoveLastDir();
79 
80  // Add 3D module library file path to search path list.
81  fn.AppendDir( wxT( "3dmodels" ) );
82  aDst->AddPaths( fn.GetPath() );
83  fn.RemoveLastDir();
84  }
85 
86  // Add KiCad template file path to search path list.
87  fn.AppendDir( wxT( "template" ) );
88  aDst->AddPaths( fn.GetPath() );
89  }
90 
91 #ifndef __WXMAC__
92  aDst->AddPaths( wxT( "/usr/local/share" ) );
93 #endif
94 }
95 
96 
97 bool KIFACE_BASE::start_common( int aCtlBits )
98 {
99  m_start_flags = aCtlBits;
100  m_bm.Init();
102 
103  return true;
104 }
105 
106 
108 {
109  m_bm.End();
110 }
111 
BIN_MOD m_bm
Definition: kiface_base.h:118
void Init()
Definition: bin_mod.cpp:38
static void setSearchPaths(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
Definition: kiface_base.cpp:33
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
System directories search utilities.
Look for files in a number of paths.
Definition: search_stack.h:41
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_base.h:120
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:97
pcbnew DSO
Definition: kiway.h:269
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Append system places to aSearchStack in a platform specific way and pertinent to KiCad programs.
SEARCH_STACK m_search
Definition: bin_mod.h:60
FACE_T
Known KIFACE implementations.
Definition: kiway.h:266
eeschema DSO
Definition: kiway.h:268
void AddPaths(const wxString &aPaths, int aIndex=-1)
Insert or append path(s).
KIWAY::FACE_T m_id
Definition: kiface_base.h:116
void End()
Definition: bin_mod.cpp:50