Commit 8d9fe712 authored by finetjul's avatar finetjul
Browse files

ENH: Support shared CLI modules.

To be able to read volumes(slicer:0x263f5c0#vtkMRMLScalarVolumeNode1), the
CLI modules need to load MRMLImageIOPlugin, it is done automatically by ITK
by scanning plugins in the directory retrieved from the environment

git-svn-id: 3bd1e089-480b-0410-8dfb-8563597acbee
parent f1c79ef5
......@@ -65,6 +65,7 @@
// VTK includes
#include "vtkSmartPointer.h"
#include <vtksys/SystemTools.hxx>
// Slicer includes
#include "vtkSlicerVersionConfigure.h" // For Slicer3_VERSION_{MINOR, MAJOR}, Slicer3_VERSION_FULL
......@@ -95,6 +96,8 @@ public:
/// Given the program name, attempt to return the corresponding binary directory
void discoverSlicerBinDirectory();
void discoverITKFactoriesDirectory();
/// Parse arguments
bool parseArguments();
......@@ -116,6 +119,7 @@ public:
/// SlicerBin doesn't contain Debug/Release/... (see IntDir)
QString SlicerBin;
QString SlicerHome;
QString ITKFactoriesDir;
/// On windows platform, after the method 'discoverSlicerBinDirectory' has been called,
/// IntDir should be set to either Debug,
/// Release, RelWithDebInfo, MinSizeRel or any other custom build type.
......@@ -237,6 +241,30 @@ void qSlicerCoreApplicationPrivate::discoverSlicerBinDirectory()
void qSlicerCoreApplicationPrivate::discoverITKFactoriesDirectory()
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QDir itkFactoriesDir (this->SlicerHome);;
if (!this->IntDir.isEmpty())
QString relativeAutoLoadPath = env.value("ITK_AUTOLOAD_PATH");
if (relativeAutoLoadPath.isEmpty())
this->ITKFactoriesDir = itkFactoriesDir.absolutePath();
if (!itkFactoriesDir.exists())
qWarning() << "ITK_AUTOLOAD_PATH doesn't exists:"<< this->ITKFactoriesDir;
env.insert("ITK_AUTOLOAD_PATH", this->ITKFactoriesDir);
bool qSlicerCoreApplicationPrivate::parseArguments()
......@@ -292,6 +320,15 @@ qSlicerCoreApplication::qSlicerCoreApplication(int &_argc, char **_argv):Supercl
// in order to be used in the constructor of qSlicerApplication (to initialize the
// QCoreApplication::addLibraryPath (to handle the iconengines plugin) )
// Qt can't set environment variables for child processes that are not QProcess.
// As the command line modules are not QProcess and need ITK_AUTOLOAD_PATH to
// be able to read Slicer volumes, we need to change the current process env.
QString setEnv = QString("Slicer3_HOME=") + d->SlicerHome;
setEnv = QString("ITK_AUTOLOAD_PATH=") + d->ITKFactoriesDir;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment