KiCad PCB EDA Suite
kiface_i.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 <macros.h> // FROM_UTF8()
27 #include <wx/stdpaths.h>
28 
29 #include <kiface_i.h>
30 #include <pgm_base.h>
31 #include <systemdirsappend.h>
32 
33 #include <common.h>
34 
37 static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
38 {
39  SEARCH_STACK bases;
40 
41  SystemDirsAppend( &bases );
42  aDst->Clear();
43 
44  for( unsigned i = 0; i < bases.GetCount(); ++i )
45  {
46  wxFileName fn( bases[i], wxEmptyString );
47 
48  // Add schematic library file path to search path list.
49  // we must add <kicad path>/library and <kicad path>/library/doc
50  if( aId == KIWAY::FACE_SCH )
51  {
52  // Add schematic doc file path (library/doc) to search path list.
53 
54  fn.AppendDir( wxT( "library" ) );
55  aDst->AddPaths( fn.GetPath() );
56 
57  fn.AppendDir( wxT( "doc" ) );
58  aDst->AddPaths( fn.GetPath() );
59 
60  fn.RemoveLastDir();
61  fn.RemoveLastDir(); // "../../" up twice, removing library/doc/
62  }
63 
64  // Add PCB library file path to search path list.
65  if( aId == KIWAY::FACE_PCB || aId == KIWAY::FACE_CVPCB )
66  {
67  fn.AppendDir( wxT( "modules" ) );
68  aDst->AddPaths( fn.GetPath() );
69 
70  // Add 3D module library file path to search path list.
71  fn.AppendDir( wxT( "packages3d" ) );
72  aDst->AddPaths( fn.GetPath() );
73 
74  fn.RemoveLastDir();
75  fn.RemoveLastDir(); // "../../" up twice, remove modules/packages3d
76  }
77 
78  // Add KiCad template file path to search path list.
79  fn.AppendDir( wxT( "template" ) );
80  aDst->AddPaths( fn.GetPath() );
81  }
82 
83 #ifndef __WXMAC__
84  aDst->AddPaths( wxT( "/usr/local/share" ) );
85 #endif
86 }
87 
88 
89 bool KIFACE_I::start_common( int aCtlBits )
90 {
91  m_start_flags = aCtlBits;
92  m_bm.Init();
94 
95  return true;
96 }
97 
98 
100 {
101  m_bm.End();
102 }
103 
KIWAY::FACE_T m_id
Definition: kiface_i.h:130
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:89
void Init()
Definition: bin_mod.cpp:41
System directories search utilities.
SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
BIN_MOD m_bm
Definition: kiface_i.h:132
This file contains miscellaneous commonly used macros and functions.
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:99
pcbnew DSO
Definition: kiway.h:282
void SystemDirsAppend(SEARCH_STACK *aSearchStack)
Function SystemDirsAppend appends system places to aSearchStack in a platform specific way,...
int m_start_flags
flags provided in OnKifaceStart()
Definition: kiface_i.h:134
SEARCH_STACK m_search
Definition: bin_mod.h:67
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
eeschema DSO
Definition: kiway.h:281
see class PGM_BASE
static void setSearchPaths(SEARCH_STACK *aDst, KIWAY::FACE_T aId)
Initialize aDst SEARCH_STACK with KIFACE (DSO) specific settings.
Definition: kiface_i.cpp:37
The common library.
void AddPaths(const wxString &aPaths, int aIndex=-1)
Function AddPaths insert or append path(s)
void End()
Definition: bin_mod.cpp:53