KiCad PCB EDA Suite
3d_cache_wrapper.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-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include <common.h>
26 #include <pgm_base.h>
27 #include "3d_cache_wrapper.h"
28 
29 static wxCriticalSection lock3D_wrapper;
30 
32 {
33  return;
34 }
35 
36 
38 {
39  return;
40 }
41 
42 
43 S3D_CACHE* PROJECT::Get3DCacheManager( bool updateProjDir )
44 {
45  wxCriticalSectionLocker lock( lock3D_wrapper );
47  S3D_CACHE* cache = dynamic_cast<S3D_CACHE*>( cw );
48 
49  // check that we get the expected type of object or NULL
50  wxASSERT( !cw || cache );
51 
52  if( !cw )
53  {
54  cw = new CACHE_WRAPPER;
55  cache = dynamic_cast<S3D_CACHE*>( cw );
56 
57  wxFileName cfgpath;
58  cfgpath.AssignDir( GetKicadConfigPath() );
59  cfgpath.AppendDir( wxT( "3d" ) );
60  cache->SetProgramBase( &Pgm() );
61  cache->Set3DConfigDir( cfgpath.GetFullPath() );
62  SetElem( ELEM_3DCACHE, cw );
63  updateProjDir = true;
64  }
65 
66  if( updateProjDir )
67  cache->SetProjectDir( GetProjectPath() );
68 
69  return cache;
70 }
static S3D_CACHE * cache
Definition: export_vrml.cpp:60
virtual ~CACHE_WRAPPER()
void SetProgramBase(PGM_BASE *aBase)
Function SetProgramBase sets the filename resolver's pointer to the application's PGM_BASE instance; ...
Definition: 3d_cache.cpp:726
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:65
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:195
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:207
bool SetProjectDir(const wxString &aProjDir)
Function SetProjectDir sets the current project's working directory; this affects the model search pa...
Definition: 3d_cache.cpp:700
wxString GetKicadConfigPath()
Function GetKicadConfigPath.
Definition: common.cpp:317
see class PGM_BASE
static wxCriticalSection lock3D_wrapper
bool Set3DConfigDir(const wxString &aConfigDir)
Function Set3DConfigDir Sets the configuration directory to be used by the model manager for storing ...
Definition: 3d_cache.cpp:542
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:101
The common library.