diff --git a/Code/Mantid/Build/CMake/CommonSetup.cmake b/Code/Mantid/Build/CMake/CommonSetup.cmake index 86835de4f1c6484059739b24859d26897cf2a5f2..8bf9015b3105d05e70247036fadf18ad407d8cab 100644 --- a/Code/Mantid/Build/CMake/CommonSetup.cmake +++ b/Code/Mantid/Build/CMake/CommonSetup.cmake @@ -79,6 +79,7 @@ set ( CMAKE_INCLUDE_PATH ${MAIN_CMAKE_INCLUDE_PATH} ) set ( MtdVersion_WC_LAST_CHANGED_REV 0 ) set ( MtdVersion_WC_LAST_CHANGED_DATE Unknown ) set ( NOT_GIT_REPO "Not" ) +set ( Compatible_ParaView_Version "3.14" ) find_package ( Git ) if ( GIT_FOUND ) diff --git a/Code/Mantid/Framework/Kernel/CMakeLists.txt b/Code/Mantid/Framework/Kernel/CMakeLists.txt index 59285a41410f758ab06fb1e2331299800d5cf22d..7885be6d701ddf403520b0a00ed212982dbb4a13 100644 --- a/Code/Mantid/Framework/Kernel/CMakeLists.txt +++ b/Code/Mantid/Framework/Kernel/CMakeLists.txt @@ -52,6 +52,7 @@ set ( SRC_FILES src/NDRandomNumberGenerator.cpp src/NeutronAtom.cpp src/NexusTestHelper.cpp + src/ParaViewVersion.cpp src/ProgressBase.cpp src/ProgressText.cpp src/Property.cpp @@ -173,6 +174,7 @@ set ( INC_FILES inc/MantidKernel/NeutronAtom.h inc/MantidKernel/NexusTestHelper.h inc/MantidKernel/NullValidator.h + inc/MantidKernel/ParaViewVersion.h inc/MantidKernel/PhysicalConstants.h inc/MantidKernel/ProgressBase.h inc/MantidKernel/ProgressText.h @@ -354,6 +356,9 @@ if ( NOT NOT_GIT_REPO OR NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/MantidVersio configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/../../Build/CMake/PatchVersionNumber.cmake.in ${CMAKE_CURRENT_SOURCE_DIR}/../../Build/CMake/PatchVersionNumber.cmake ) + configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/src/ParaViewVersion.cpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/src/ParaViewVersion.cpp + ) endif () ########################################################################### diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/ParaViewVersion.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ParaViewVersion.h new file mode 100644 index 0000000000000000000000000000000000000000..a58813d1c80a15afd4e7b84df0e33f314e4e9b1b --- /dev/null +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/ParaViewVersion.h @@ -0,0 +1,48 @@ +#ifndef MANTID_KERNEL_PARAVIEW_VERSION_H_ +#define MANTID_KERNEL_PARAVIEW_VERSION_H_ + +//---------------------------------------------------------------------- +// Includes +//---------------------------------------------------------------------- +#include "MantidKernel/DllConfig.h" +#include <string> + +namespace Mantid +{ +namespace Kernel +{ +/** Class containing static methods to return the ParaView version number. + + Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory + + This file is part of Mantid. + + Mantid 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 3 of the License, or + (at your option) any later version. + + Mantid 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, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>. + Code Documentation is available at: <http://doxygen.mantidproject.org> + */ +class MANTID_KERNEL_DLL ParaViewVersion +{ +public: + static std::string targetVersion(); ///< The version number major.minor + +private: + ParaViewVersion(); ///< Private, unimplemented constructor. Not a class that can be instantiated. +}; + +} // namespace Kernel +} // namespace Mantid + +#endif /* MANTID_KERNEL_PARAVIEW_VERSION_H_ */ diff --git a/Code/Mantid/Framework/Kernel/src/.gitignore b/Code/Mantid/Framework/Kernel/src/.gitignore index fd0beea5aa734c1b77964818d91f88fb03526f3f..a81090024ef71de4610f7855f174c0f0bad1fa85 100644 --- a/Code/Mantid/Framework/Kernel/src/.gitignore +++ b/Code/Mantid/Framework/Kernel/src/.gitignore @@ -1 +1,2 @@ MantidVersion.cpp +ParaViewVersion.cpp \ No newline at end of file diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index ffbc88c2dc40d3fd46078faa01f5928838706c25..135a714b5743eec66d031c108bbe5393a5878033 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -3,6 +3,7 @@ //---------------------------------------------------------------------- #include "MantidKernel/ConfigService.h" #include "MantidKernel/MantidVersion.h" +#include "MantidKernel/ParaViewVersion.h" #include "MantidKernel/Strings.h" #include "MantidKernel/Logger.h" #include "MantidKernel/FilterChannel.h" @@ -1709,13 +1710,39 @@ bool ConfigServiceImpl::quickParaViewCheck() const } std::vector<std::string> args; args.push_back("-V"); - Poco::Pipe outPipe; - Poco::ProcessHandle ph = Poco::Process::launch(cmd, args, 0, &outPipe, &outPipe); + Poco::Pipe outPipe, errorPipe; + Poco::ProcessHandle ph = Poco::Process::launch(cmd, args, 0, &outPipe, &errorPipe); const int rc = ph.wait(); if(rc == 1) { - isAvailable = true; - this->g_log.notice("ParaView is available"); + Poco::PipeInputStream stdErr(errorPipe); + std::stringstream errStream; + Poco::StreamCopier::copyStream(stdErr, errStream); + std::string givenVersion = errStream.str(); + boost::smatch match; + + boost::regex expression("(\\d+)\\.(\\d+)"); + double givenVersionNumber; + if(boost::regex_search(givenVersion, match, expression)) + { + Strings::convert(match[0], givenVersionNumber); + } + + double targetVersionNumber; + Strings::convert(ParaViewVersion::targetVersion(), targetVersionNumber); + if (givenVersionNumber == targetVersionNumber) + { + isAvailable = true; + this->g_log.notice("ParaView is available"); + } + else + { + std::stringstream messageStream; + messageStream << "The compatible version of ParaView is " << targetVersionNumber << " but the installed version is " << givenVersionNumber; + + this->g_log.notice(messageStream.str()); + this->g_log.notice("ParaView is not available"); + } } else { diff --git a/Code/Mantid/Framework/Kernel/src/ParaViewVersion.cpp.in b/Code/Mantid/Framework/Kernel/src/ParaViewVersion.cpp.in new file mode 100644 index 0000000000000000000000000000000000000000..d8ce1fa6ab060f3f6dbdaeacfb178ea450646915 --- /dev/null +++ b/Code/Mantid/Framework/Kernel/src/ParaViewVersion.cpp.in @@ -0,0 +1,17 @@ +//---------------------------------------------------------------------- +// Includes +//---------------------------------------------------------------------- +#include "MantidKernel/ParaViewVersion.h" + +namespace Mantid +{ +namespace Kernel +{ + +std::string ParaViewVersion::targetVersion() +{ + return "@Compatible_ParaView_Version@"; +} + +} // namespace Kernel +} // namespace Mantid