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/config.h>
28 #include <wx/stdpaths.h>
29 
30 #include <kiface_i.h>
31 #include <pgm_base.h>
32 #include <systemdirsappend.h>
33 
34 #include <common.h>
35 
38 static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
39 {
40  SEARCH_STACK bases;
41 
42  SystemDirsAppend( &bases );
43  aDst->Clear();
44 
45  for( unsigned i = 0; i < bases.GetCount(); ++i )
46  {
47  wxFileName fn( bases[i], wxEmptyString );
48 
49  // Add schematic library file path to search path list.
50  // we must add <kicad path>/library and <kicad path>/library/doc
51  if( aId == KIWAY::FACE_SCH )
52  {
53  // Add schematic doc file path (library/doc) to search path list.
54 
55  fn.AppendDir( wxT( "library" ) );
56  aDst->AddPaths( fn.GetPath() );
57 
58  fn.AppendDir( wxT( "doc" ) );
59  aDst->AddPaths( fn.GetPath() );
60 
61  fn.RemoveLastDir();
62  fn.RemoveLastDir(); // "../../" up twice, removing library/doc/
63  }
64 
65  // Add PCB library file path to search path list.
66  if( aId == KIWAY::FACE_PCB || aId == KIWAY::FACE_CVPCB )
67  {
68  fn.AppendDir( wxT( "modules" ) );
69  aDst->AddPaths( fn.GetPath() );
70 
71  // Add 3D module library file path to search path list.
72  fn.AppendDir( wxT( "packages3d" ) );
73  aDst->AddPaths( fn.GetPath() );
74 
75  fn.RemoveLastDir();
76  fn.RemoveLastDir(); // "../../" up twice, remove modules/packages3d
77  }
78 
79  // Add KiCad template file path to search path list.
80  fn.AppendDir( wxT( "template" ) );
81  aDst->AddPaths( fn.GetPath() );
82  }
83 
84 #ifndef __WXMAC__
85  aDst->AddPaths( wxT( "/usr/local/share" ) );
86 #endif
87 
88 #if 1 && defined(DEBUG)
89  aDst->Show( "kiface" );
90 #endif
91 }
92 
93 
94 bool KIFACE_I::start_common( int aCtlBits )
95 {
96  m_start_flags = aCtlBits;
97  m_bm.Init();
99 
100  return true;
101 }
102 
103 
105 {
106  m_bm.End();
107 }
108 
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:94
void Init()
Definition: bin_mod.cpp:36
System directories search utilities.
Class 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:104
pcbnew DSO
Definition: kiway.h:266
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:61
FACE_T
Known KIFACE implementations.
Definition: kiway.h:263
eeschema DSO
Definition: kiway.h:265
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:38
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