From 6776791b32b1ecabcc0121ec225f30c54d2e15b4 Mon Sep 17 00:00:00 2001 From: Peter Peterson <petersonpf@ornl.gov> Date: Wed, 14 Dec 2011 12:01:31 -0500 Subject: [PATCH] Set PV_PLUGIN_PATH in ConfigService. Refs #4264. When running mantid you know where the plugins are supposed to exist relative to the MantidPlot executable. Just set the environment variable. --- .../Kernel/inc/MantidKernel/ConfigService.h | 7 ++++-- .../Framework/Kernel/src/ConfigService.cpp | 23 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h index d96d32f79e7..f64cfe3b502 100644 --- a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ConfigService.h @@ -155,9 +155,9 @@ namespace Mantid /// Returns the system's temp directory std::string getTempDir(); //Return the executable path - std::string getDirectoryOfExecutable(); + std::string getDirectoryOfExecutable() const; //Return the full path to the executable - std::string getPathToExecutable(); + std::string getPathToExecutable() const; //Check if the path is on a network drive bool isNetworkDrive(const std::string & path); //@} @@ -236,6 +236,9 @@ namespace Mantid /// Returns true if the path is in the data search list bool isInDataSearchList(const std::string & path) const; + /// Set the PV_PLUGIN_PATH to point at this version of Mantid. + void setParaViewPluginPath() const; + // Forward declaration of inner class template <class T> class WrappedObject; diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index ef89c0d1687..8165be71797 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -310,9 +310,10 @@ ConfigServiceImpl::ConfigServiceImpl() : g_log.information() << "Properties file(s) loaded: " << propertiesFilesList << std::endl; g_log.information() << "Logging to: " << m_logFilePath << std::endl; + this->setParaViewPluginPath(); + // Make sure the log path is shown somewhere. //std::cout << "Logging to: " << m_logFilePath << std::endl; - } /** Private Destructor @@ -1236,7 +1237,7 @@ std::string ConfigServiceImpl::getTempDir() * @returns A string containing the path of the directory * containing the executable, including a trailing slash */ -std::string ConfigServiceImpl::getDirectoryOfExecutable() +std::string ConfigServiceImpl::getDirectoryOfExecutable() const { return Poco::Path(getPathToExecutable()).parent().toString(); } @@ -1245,7 +1246,7 @@ std::string ConfigServiceImpl::getDirectoryOfExecutable() * Get the full path to the executing program (i.e. whatever Mantid is embedded in) * @returns A string containing the full path the the executable */ -std::string ConfigServiceImpl::getPathToExecutable() +std::string ConfigServiceImpl::getPathToExecutable() const { std::string execpath(""); const size_t LEN(1024); @@ -1344,7 +1345,21 @@ bool ConfigServiceImpl::isNetworkDrive(const std::string & path) #endif } - +/** + * Set the environment variable for the PV_PLUGIN_PATH based on where Mantid is. + */ +void ConfigServiceImpl::setParaViewPluginPath() const +{ + std::string mantid_loc = this->getDirectoryOfExecutable(); + Poco::File pv_plugin(mantid_loc + "/pvplugins"); + if (!pv_plugin.exists() || !pv_plugin.isDirectory()) + { + g_log.warning("ParaView plugin directory \"" + pv_plugin.path() + "\" does not exist"); + return; + } + g_log.debug("Setting PV_PLUGIN_PATH = \"" + pv_plugin.path() + "\""); + Poco::Environment::set("PV_PLUGIN_PATH", pv_plugin.path()); +} /** * Gets the directory that we consider to be the directory containing the Mantid.properties file. -- GitLab