Blender
V5.3
source
blender
freestyle
intern
application
AppConfig.cpp
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#include "
AppConfig.h
"
10
#include <iostream>
11
12
#include "
../system/FreestyleConfig.h
"
13
#include "
../system/StringUtils.h
"
14
15
using namespace
std;
16
17
#include "
BKE_appdir.hh
"
18
19
namespace
Freestyle::Config
{
20
21
Path
*
Path::_pInstance
=
nullptr
;
22
Path::Path
()
23
{
24
// get the root directory
25
// soc
26
const
std::optional<std::string> path = BKE_appdir_folder_id(
blender::BLENDER_SYSTEM_SCRIPTS
,
27
nullptr
);
28
setRootDir
(path.value_or(
blender::BKE_appdir_program_dir
()));
29
30
_pInstance
=
this
;
31
}
32
33
void
Path::setRootDir
(
const
string
&iRootDir)
34
{
35
_ProjectDir
= iRootDir + string(
DIR_SEP
) +
"freestyle"
;
36
_ModelsPath
=
""
;
37
_PatternsPath
=
_ProjectDir
+ string(
DIR_SEP
) +
"data"
+ string(
DIR_SEP
) +
"textures"
+
38
string(
DIR_SEP
) +
"variation_patterns"
+ string(
DIR_SEP
);
39
_BrushesPath
=
_ProjectDir
+ string(
DIR_SEP
) +
"data"
+ string(
DIR_SEP
) +
"textures"
+
40
string(
DIR_SEP
) +
"brushes"
+ string(
DIR_SEP
);
41
_EnvMapDir
=
_ProjectDir
+ string(
DIR_SEP
) +
"data"
+ string(
DIR_SEP
) +
"env_map"
+
42
string(
DIR_SEP
);
43
_MapsDir
=
_ProjectDir
+ string(
DIR_SEP
) +
"data"
+ string(
DIR_SEP
) +
"maps"
+ string(
DIR_SEP
);
44
}
45
46
void
Path::setHomeDir
(
const
string
&iHomeDir)
47
{
48
_HomeDir
= iHomeDir;
49
}
50
51
Path::~Path
()
52
{
53
_pInstance
=
nullptr
;
54
}
55
56
Path
*
Path::getInstance
()
57
{
58
return
_pInstance
;
59
}
60
61
string
Path::getEnvVar
(
const
string
&iEnvVarName)
62
{
63
string
value;
64
if
(!getenv(iEnvVarName.c_str())) {
65
cerr <<
"Warning: You may want to set the $"
<< iEnvVarName
66
<<
" environment variable to use Freestyle."
<< endl
67
<<
" Otherwise, the current directory will be used instead."
<< endl;
68
value =
"."
;
69
}
70
else
{
71
value = getenv(iEnvVarName.c_str());
72
}
73
return
value;
74
}
75
76
}
// namespace Freestyle::Config
AppConfig.h
Configuration file.
BKE_appdir.hh
FreestyleConfig.h
Configuration definitions.
StringUtils.h
String utilities.
Freestyle::Config::Path
Definition
AppConfig.h:25
Freestyle::Config::Path::getEnvVar
static string getEnvVar(const string &iEnvVarName)
Definition
AppConfig.cpp:61
Freestyle::Config::Path::setRootDir
void setRootDir(const string &iRootDir)
Definition
AppConfig.cpp:33
Freestyle::Config::Path::_ProjectDir
string _ProjectDir
Definition
AppConfig.h:28
Freestyle::Config::Path::Path
Path()
Definition
AppConfig.cpp:22
Freestyle::Config::Path::getInstance
static Path * getInstance()
Definition
AppConfig.cpp:56
Freestyle::Config::Path::_HomeDir
string _HomeDir
Definition
AppConfig.h:34
Freestyle::Config::Path::_ModelsPath
string _ModelsPath
Definition
AppConfig.h:29
Freestyle::Config::Path::setHomeDir
void setHomeDir(const string &iHomeDir)
Definition
AppConfig.cpp:46
Freestyle::Config::Path::_EnvMapDir
string _EnvMapDir
Definition
AppConfig.h:32
Freestyle::Config::Path::_PatternsPath
string _PatternsPath
Definition
AppConfig.h:30
Freestyle::Config::Path::_MapsDir
string _MapsDir
Definition
AppConfig.h:33
Freestyle::Config::Path::_pInstance
static Path * _pInstance
Definition
AppConfig.h:27
Freestyle::Config::Path::~Path
virtual ~Path()
Definition
AppConfig.cpp:51
Freestyle::Config::Path::_BrushesPath
string _BrushesPath
Definition
AppConfig.h:31
Freestyle::Config
Definition
AppConfig.cpp:19
blender::BKE_appdir_program_dir
const char * BKE_appdir_program_dir() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
Definition
appdir.cc:1009
blender::BLENDER_SYSTEM_SCRIPTS
@ BLENDER_SYSTEM_SCRIPTS
Definition
BKE_appdir.hh:175
DIR_SEP
#define DIR_SEP
Definition
path.cpp:29
Generated on
for Blender by
doxygen
1.18.0