2012-12-18 00:51:25 +00:00
|
|
|
/*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
2012-12-18 00:51:25 +00:00
|
|
|
*/
|
2008-05-19 05:34:31 +00:00
|
|
|
|
|
|
|
|
#include "AppConfig.h"
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2014-04-17 14:31:35 +09:00
|
|
|
#include "../system/FreestyleConfig.h"
|
2008-05-19 05:34:31 +00:00
|
|
|
#include "../system/StringUtils.h"
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2008-05-19 05:34:31 +00:00
|
|
|
using namespace std;
|
|
|
|
|
|
2008-09-29 15:50:50 +00:00
|
|
|
extern "C" {
|
2014-11-23 14:37:13 +01:00
|
|
|
#include "BKE_appdir.h"
|
2008-09-29 15:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2008-09-09 18:03:44 +00:00
|
|
|
namespace Config {
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2013-03-07 23:17:23 +00:00
|
|
|
Path *Path::_pInstance = 0;
|
2012-12-18 00:51:25 +00:00
|
|
|
Path::Path()
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
// get the root directory
|
|
|
|
|
// soc
|
|
|
|
|
setRootDir(BKE_appdir_folder_id(BLENDER_SYSTEM_SCRIPTS, NULL));
|
2008-05-25 17:34:21 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
_pInstance = this;
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void Path::setRootDir(const string &iRootDir)
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
_ProjectDir = iRootDir + string(DIR_SEP.c_str()) + "freestyle";
|
|
|
|
|
_ModelsPath = "";
|
|
|
|
|
_PatternsPath = _ProjectDir + string(DIR_SEP.c_str()) + "data" + string(DIR_SEP.c_str()) +
|
|
|
|
|
"textures" + string(DIR_SEP.c_str()) + "variation_patterns" +
|
|
|
|
|
string(DIR_SEP.c_str());
|
|
|
|
|
_BrushesPath = _ProjectDir + string(DIR_SEP.c_str()) + "data" + string(DIR_SEP.c_str()) +
|
|
|
|
|
"textures" + string(DIR_SEP.c_str()) + "brushes" + string(DIR_SEP.c_str());
|
|
|
|
|
_PythonPath = _ProjectDir + string(DIR_SEP.c_str()) + "modules" + string(DIR_SEP.c_str());
|
|
|
|
|
if (getenv("PYTHONPATH")) {
|
|
|
|
|
_PythonPath += string(PATH_SEP.c_str()) + string(getenv("PYTHONPATH"));
|
|
|
|
|
}
|
|
|
|
|
_EnvMapDir = _ProjectDir + string(DIR_SEP.c_str()) + "data" + string(DIR_SEP.c_str()) +
|
|
|
|
|
"env_map" + string(DIR_SEP.c_str());
|
|
|
|
|
_MapsDir = _ProjectDir + string(DIR_SEP.c_str()) + "data" + string(DIR_SEP.c_str()) + "maps" +
|
|
|
|
|
string(DIR_SEP.c_str());
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void Path::setHomeDir(const string &iHomeDir)
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
_HomeDir = iHomeDir;
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
|
|
|
|
Path::~Path()
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
_pInstance = 0;
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2013-03-07 23:17:23 +00:00
|
|
|
Path *Path::getInstance()
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return _pInstance;
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2012-12-18 00:51:25 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
string Path::getEnvVar(const string &iEnvVarName)
|
2012-12-18 00:51:25 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
string value;
|
|
|
|
|
if (!getenv(iEnvVarName.c_str())) {
|
|
|
|
|
cerr << "Warning: You may want to set the $" << iEnvVarName
|
|
|
|
|
<< " environment variable to use Freestyle." << endl
|
|
|
|
|
<< " Otherwise, the current directory will be used instead." << endl;
|
|
|
|
|
value = ".";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
value = getenv(iEnvVarName.c_str());
|
|
|
|
|
}
|
|
|
|
|
return value;
|
2008-09-09 18:03:44 +00:00
|
|
|
}
|
2008-05-19 05:34:31 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
} // namespace Config
|
2013-04-09 00:46:49 +00:00
|
|
|
|
|
|
|
|
} /* namespace Freestyle */
|