diff --git a/Code/Mantid/API/inc/MantidAPI/FrameworkManager.h b/Code/Mantid/API/inc/MantidAPI/FrameworkManager.h index b391edd23c85187bc1b04adff1128d8380bdb6b5..da00e39af772f36fed13e804ce0585c760e7f738 100644 --- a/Code/Mantid/API/inc/MantidAPI/FrameworkManager.h +++ b/Code/Mantid/API/inc/MantidAPI/FrameworkManager.h @@ -56,7 +56,7 @@ namespace Mantid { public: /// Creates all of the required services - void initialize(); + //void initialize(); /// Clears all memory associated with the AlgorithmManager void clear(); diff --git a/Code/Mantid/API/src/FrameworkManager.cpp b/Code/Mantid/API/src/FrameworkManager.cpp index cafd6a567e78ddafcb41ed03f52d33f51eea79e3..95802ae3206f4c99c4b83b0664eb54a1108073cb 100644 --- a/Code/Mantid/API/src/FrameworkManager.cpp +++ b/Code/Mantid/API/src/FrameworkManager.cpp @@ -24,8 +24,13 @@ namespace API /// Default constructor FrameworkManagerImpl::FrameworkManagerImpl() : g_log(Kernel::Logger::get("FrameworkManager")) { - std::cerr << "Framework Manager created." << std::endl; - g_log.debug() << "FrameworkManager created." << std::endl; + std::string pluginDir = Kernel::ConfigService::Instance().getString("plugins.directory"); + if (pluginDir.length() > 0) + { + Mantid::Kernel::LibraryManager::Instance().OpenAllLibraries(pluginDir, false); + } + std::cerr << "Framework Manager created." << std::endl; + g_log.debug() << "FrameworkManager created." << std::endl; } /// Destructor @@ -35,17 +40,6 @@ FrameworkManagerImpl::~FrameworkManagerImpl() // g_log.debug() << "FrameworkManager destroyed." << std::endl; } -/// Creates all of the required services -void FrameworkManagerImpl::initialize() -{ - std::string pluginDir = Kernel::ConfigService::Instance().getString("plugins.directory"); - if (pluginDir.length() > 0) - { - Mantid::Kernel::LibraryManager::Instance().OpenAllLibraries(pluginDir, false); - } - return; -} - /** At the moment clears all memory associated with AlgorithmManager. * May do more in the future */ diff --git a/Code/Mantid/API/test/FrameworkManagerTest.h b/Code/Mantid/API/test/FrameworkManagerTest.h index cd5bfb212a36d45a94fc9862f395e3e58be8310d..8de675c592e70bf104b397e636ae028326d0e9bf 100644 --- a/Code/Mantid/API/test/FrameworkManagerTest.h +++ b/Code/Mantid/API/test/FrameworkManagerTest.h @@ -35,11 +35,11 @@ class FrameworkManagerTest : public CxxTest::TestSuite { public: - void testInitialize() - { - // Not really much to test - TS_ASSERT_THROWS_NOTHING( FrameworkManager::Instance().initialize() ) - } + //void testInitialize() + //{ + // // Not really much to test + // TS_ASSERT_THROWS_NOTHING( FrameworkManager::Instance().initialize() ) + //} void testcreateAlgorithm() { diff --git a/Code/Mantid/DataHandling/test/LoadInstrumentFromRawTest.h b/Code/Mantid/DataHandling/test/LoadInstrumentFromRawTest.h index 459f39110bb192d54fd63e9ac5b5abb041d15dbe..0860a8ba680df5cb6d196dbd445f2c4e7e154ab9 100644 --- a/Code/Mantid/DataHandling/test/LoadInstrumentFromRawTest.h +++ b/Code/Mantid/DataHandling/test/LoadInstrumentFromRawTest.h @@ -28,7 +28,7 @@ public: LoadInstrumentFromRawTest() { //initialise framework manager to allow logging - Mantid::API::FrameworkManager::Instance().initialize(); + //Mantid::API::FrameworkManager::Instance().initialize(); } void testInit() { diff --git a/Code/Mantid/DataHandling/test/LoadInstrumentTest.h b/Code/Mantid/DataHandling/test/LoadInstrumentTest.h index 2e069d6804ac8347d81d15a7910256b455bbcdc5..9ebb2680727f3f809e74049b7eb5c73351afb9c7 100644 --- a/Code/Mantid/DataHandling/test/LoadInstrumentTest.h +++ b/Code/Mantid/DataHandling/test/LoadInstrumentTest.h @@ -28,7 +28,7 @@ public: LoadInstrumentTest() { //initialise framework manager to allow logging - Mantid::API::FrameworkManager::Instance().initialize(); + //Mantid::API::FrameworkManager::Instance().initialize(); } void testInit() { diff --git a/Code/Mantid/DataHandling/test/LoadLogTest.h b/Code/Mantid/DataHandling/test/LoadLogTest.h index 6e1a6e109eeb12329aae5302769b1fd7d99f50d0..3c2fe1314f44d04d0a3a84a1d46527749bdd3ddb 100644 --- a/Code/Mantid/DataHandling/test/LoadLogTest.h +++ b/Code/Mantid/DataHandling/test/LoadLogTest.h @@ -28,7 +28,7 @@ public: LoadLogTest() { //initialise framework manager to allow logging - Mantid::API::FrameworkManager::Instance().initialize(); + //Mantid::API::FrameworkManager::Instance().initialize(); } void testInit() { diff --git a/Code/Mantid/DataHandling/test/LoadRawTest.h b/Code/Mantid/DataHandling/test/LoadRawTest.h index cf7e2d51c715298b79169070da23c0bc48de963b..eccc82e7379a63738fd3c3243ff9c33565ff4b8a 100644 --- a/Code/Mantid/DataHandling/test/LoadRawTest.h +++ b/Code/Mantid/DataHandling/test/LoadRawTest.h @@ -24,7 +24,7 @@ public: LoadRawTest() { //initialise framework manager to allow logging - Mantid::API::FrameworkManager::Instance().initialize(); + //Mantid::API::FrameworkManager::Instance().initialize(); // Path to test input file assumes Test directory checked out from SVN inputFile = "../../../../Test/Data/HET15869.RAW"; } diff --git a/Code/Mantid/DataHandling/test/MarkDeadDetectorsTest.h b/Code/Mantid/DataHandling/test/MarkDeadDetectorsTest.h index ded5384643c750af78507a2e3cc2a9745be4d90b..2cc2ac136fd35fe33926cf7f932517adf4f212ab 100644 --- a/Code/Mantid/DataHandling/test/MarkDeadDetectorsTest.h +++ b/Code/Mantid/DataHandling/test/MarkDeadDetectorsTest.h @@ -23,7 +23,7 @@ class MarkDeadDetectorsTest : public CxxTest::TestSuite public: MarkDeadDetectorsTest() { - FrameworkManager::Instance().initialize(); + //FrameworkManager::Instance().initialize(); // Set up a small workspace for testing Workspace_sptr space = WorkspaceFactory::Instance().create("Workspace2D",5,6,5); diff --git a/Code/Mantid/Kernel/Kernel.vcproj b/Code/Mantid/Kernel/Kernel.vcproj index b7da818b7fd2d33ef431036435128000b81fe545..7efbc0ef3835409c173c7337b53642450a8737cd 100644 --- a/Code/Mantid/Kernel/Kernel.vcproj +++ b/Code/Mantid/Kernel/Kernel.vcproj @@ -126,7 +126,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="PocoFoundation.lib PocoUtil.lib" + AdditionalDependencies="PocoFoundation.lib PocoUtil.lib libboost_signals-vc80-mt-1_34_1.lib" OutputFile="$(OutDir)\$(SolutionName)$(ProjectName).dll" AdditionalLibraryDirectories="../../Third_Party/lib/win32" /> @@ -208,6 +208,10 @@ RelativePath=".\src\PropertyWithValue.cpp" > </File> + <File + RelativePath=".\src\SignalChannel.cpp" + > + </File> <File RelativePath=".\src\SingletonHolder.cpp" > @@ -374,6 +378,14 @@ RelativePath=".\test\PropertyWithValueTest.h" > </File> + <File + RelativePath=".\inc\MantidKernel\Signal.h" + > + </File> + <File + RelativePath=".\inc\MantidKernel\SignalChannel.h" + > + </File> <File RelativePath=".\inc\MantidKernel\SingletonHolder.h" > diff --git a/Code/Mantid/Kernel/inc/MantidKernel/SignalChannel.h b/Code/Mantid/Kernel/inc/MantidKernel/SignalChannel.h new file mode 100644 index 0000000000000000000000000000000000000000..8150733550238766f50a6f9eb4ceb400e3233d8f --- /dev/null +++ b/Code/Mantid/Kernel/inc/MantidKernel/SignalChannel.h @@ -0,0 +1,74 @@ +// +// SignalChannel.h +// +// +// Definition of the SignalChannel class. A small extension to the POCO logging. +// +// Copyright © 2007 STFC Rutherford Appleton Laboratories +// +// 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> +// + + +#ifndef Foundation_SignalChannel_INCLUDED +#define Foundation_SignalChannel_INCLUDED + +#include "MantidKernel/System.h" + +#include "Poco/Foundation.h" +#include "Poco/Channel.h" +//#include "Poco/Mutex.h" +#include "boost/signal.hpp" + +#include <vector> + + +namespace Poco { + +/** + class SignalChannel passes log messages to slots, connected to it. + +**/ +class DLLExport SignalChannel: public Channel + /// This channel sends a message through boost::signal. +{ +public: + + typedef boost::signal<void (const Message& msg)> signal_t; + + /// Creates the SignalChannel. + SignalChannel(); + + /// Connects a slot to the channel. + void connect(void(const Message& msg)); + + /// Sends the given Message. + void log(const Message& msg); + + signal_t& sig(){return _sig;} + +private: + //mutable FastMutex _mutex; + signal_t _sig; +}; + + +} // namespace Poco + + +#endif // Foundation_SignalChannel_INCLUDED diff --git a/Code/Mantid/Kernel/src/ConfigService.cpp b/Code/Mantid/Kernel/src/ConfigService.cpp index 64f3d0b79efb9b23ad11b46772586f107c51ff7a..af86ac678c74b306c6a0ab96440bf6b04b628570 100644 --- a/Code/Mantid/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Kernel/src/ConfigService.cpp @@ -5,6 +5,7 @@ #include "MantidKernel/Support.h" #include "MantidKernel/Logger.h" #include "MantidKernel/FilterChannel.h" +#include "MantidKernel/SignalChannel.h" #include "Poco/Util/LoggingConfigurator.h" #include "Poco/Util/SystemConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h" @@ -24,11 +25,14 @@ namespace Kernel //getting at system details m_pSysConfig = new WrappedObject<Poco::Util::SystemConfiguration>; m_pConf = 0; + + //Register the FilterChannel with the Poco logging factory + Poco::LoggingFactory::defaultFactory().registerChannelClass("FilterChannel",new Poco::Instantiator<Poco::FilterChannel, Poco::Channel>); - //Register the FilterChannel with the Poco logging factory - Poco::LoggingFactory::defaultFactory().registerChannelClass("FilterChannel",new Poco::Instantiator<Poco::FilterChannel, Poco::Channel>); + //Register the SignalChannel with the Poco logging factory + Poco::LoggingFactory::defaultFactory().registerChannelClass("SignalChannel",new Poco::Instantiator<Poco::SignalChannel, Poco::Channel>); - //attempt to load the default properties filename + //attempt to load the default properties filename loadConfig("Mantid.properties"); g_log.debug() << "ConfigService created." << std::endl; } diff --git a/Code/Mantid/Kernel/src/SignalChannel.cpp b/Code/Mantid/Kernel/src/SignalChannel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ee4bbdb5559a09afaf98af056be07250258def62 --- /dev/null +++ b/Code/Mantid/Kernel/src/SignalChannel.cpp @@ -0,0 +1,46 @@ + +#include "MantidKernel/SignalChannel.h" + +#include "Poco/LoggingRegistry.h" +#include "Poco/Message.h" +//#include "boost/bind.hpp" + +#include <iostream> + +namespace Poco { + + /// Connects a function (slot) to a SignalChannel with name chName. + /// chName must be defined in Mantid.properies file. A slot is a + /// function of the type: void slot(const Message& msg). + /// Returns true if the connection was successful. + bool DLLExport connectSignal(const std::string& chName, void(*slt)(const Message& msg)) + { + try + { + SignalChannel *pChannel = dynamic_cast<SignalChannel*>(Poco::LoggingRegistry::defaultRegistry().channelForName(chName)); + if (!pChannel) return false; + pChannel->connect(slt); + } + catch(...) + { + return false; + } + return true; + } + + SignalChannel::SignalChannel():Channel() + { + } + + void SignalChannel::log(const Message& msg) + { + _sig(msg); + } + + /// Connects a slot to the channel. + void SignalChannel::connect(void(*slt)(const Message& msg)) + { + _sig.connect(slt); + } + +} // namespace Poco diff --git a/Code/Mantid/Main/Main.vcproj b/Code/Mantid/Main/Main.vcproj index 64d6397a627f5a1f60bcc068cace301ef68a7ffb..8acc63dd9b52dbe64b1eeec2e89c22df50374735 100644 --- a/Code/Mantid/Main/Main.vcproj +++ b/Code/Mantid/Main/Main.vcproj @@ -123,7 +123,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="$(SolutionName)API.lib $(SolutionName)Kernel.lib $(SolutionName)Geometry.lib $(SolutionName)DataObjects.lib" + AdditionalDependencies="$(SolutionName)API.lib $(SolutionName)Kernel.lib $(SolutionName)Geometry.lib $(SolutionName)DataObjects.lib $(SolutionName)UserAlgorithms.lib" OutputFile="$(OutDir)\$(SolutionName)$(ProjectName).exe" AdditionalLibraryDirectories="..\Release;..\..\Third_Party\lib\win32" /> diff --git a/Code/Mantid/PythonAPI/inc/MantidPythonAPI/PythonInterface.h b/Code/Mantid/PythonAPI/inc/MantidPythonAPI/PythonInterface.h index ea31b911527194e1572033ef78bf302fa2f71117..f22e6d98c0fd2a8085151541156e7906462fc9bd 100644 --- a/Code/Mantid/PythonAPI/inc/MantidPythonAPI/PythonInterface.h +++ b/Code/Mantid/PythonAPI/inc/MantidPythonAPI/PythonInterface.h @@ -51,8 +51,6 @@ public: PythonInterface(); ~PythonInterface(); - void InitialiseFrameworkManager(); - //Algorithms API::IAlgorithm* CreateAlgorithm(const std::string&); std::vector<std::string> GetAlgorithmNames(); diff --git a/Code/Mantid/PythonAPI/src/PythonInterface.cpp b/Code/Mantid/PythonAPI/src/PythonInterface.cpp index f86600abaee10373f96242d9e786e822adab30b1..54a807d72b5047cffaea1e7f64152eb0ca07ea87 100644 --- a/Code/Mantid/PythonAPI/src/PythonInterface.cpp +++ b/Code/Mantid/PythonAPI/src/PythonInterface.cpp @@ -23,6 +23,7 @@ namespace PythonAPI ///Constructor PythonInterface::PythonInterface() { + FrameworkManager::Instance(); } ///Destructor @@ -30,12 +31,6 @@ PythonInterface::~PythonInterface() { } -///Initialises the FrameworkManager. -void PythonInterface::InitialiseFrameworkManager() -{ - FrameworkManager::Instance().initialize(); -} - /** * Creates a specified algorithm. * \param algName :: The name of the algorithm to execute. diff --git a/Code/Mantid/PythonAPI/src/PythonWrapper.cpp b/Code/Mantid/PythonAPI/src/PythonWrapper.cpp index 3827368ee712ede5823f7684c5c5a2ef4fecddf2..5dcc5332e55e8abeb06073a6dfa4309a5eb4f7a8 100644 --- a/Code/Mantid/PythonAPI/src/PythonWrapper.cpp +++ b/Code/Mantid/PythonAPI/src/PythonWrapper.cpp @@ -128,7 +128,7 @@ BOOST_PYTHON_MODULE(libMantidPythonAPI) //Mantid stuff class_< Mantid::PythonAPI::PythonInterface >("PythonInterface", init< >()) .def(init< const Mantid::PythonAPI::PythonInterface& >()) - .def("InitialiseFrameworkManager", &Mantid::PythonAPI::PythonInterface::InitialiseFrameworkManager) +// .def("InitialiseFrameworkManager", &Mantid::PythonAPI::PythonInterface::InitialiseFrameworkManager) .def("CreateAlgorithm", &Mantid::PythonAPI::PythonInterface::CreateAlgorithm, return_value_policy< manage_new_object>()) .def("GetAlgorithmNames", &Mantid::PythonAPI::PythonInterface::GetAlgorithmNames) .def("LoadIsisRawFile", &Mantid::PythonAPI::PythonInterface::LoadIsisRawFile) diff --git a/Code/Mantid/PythonAPI/test/PythonAPITests.h b/Code/Mantid/PythonAPI/test/PythonAPITests.h index 156fb5ddffcd44d26e2a00c6e879d8a5a1111655..58d26818e97032d64887160c827e22167086954d 100644 --- a/Code/Mantid/PythonAPI/test/PythonAPITests.h +++ b/Code/Mantid/PythonAPI/test/PythonAPITests.h @@ -23,10 +23,10 @@ public: inter = new PythonInterface(); } - void testFrameworkInitialise() - { - TS_ASSERT_THROWS_NOTHING(inter->InitialiseFrameworkManager()); - } + //void testFrameworkInitialise() + //{ + // TS_ASSERT_THROWS_NOTHING(inter->InitialiseFrameworkManager()); + //} void testCreateAlgorithm() { diff --git a/Code/Mantid/UserAlgorithms/PropertyAlgorithm.cpp b/Code/Mantid/UserAlgorithms/PropertyAlgorithm.cpp index c1d0226d2aebafb133bdb64973bda6cb1da58c56..001dc653d554cb6adc644bf150234b45e97060b9 100644 --- a/Code/Mantid/UserAlgorithms/PropertyAlgorithm.cpp +++ b/Code/Mantid/UserAlgorithms/PropertyAlgorithm.cpp @@ -7,7 +7,8 @@ namespace Mantid namespace Algorithms { -DECLARE_ALGORITHM(PropertyAlgorithm); +//DECLARE_ALGORITHM(PropertyAlgorithm); +DECLARE_NAMESPACED_ALGORITHM(Mantid::Algorithms,PropertyAlgorithm) using namespace Kernel; diff --git a/Code/Mantid/UserAlgorithms/UserAlgorithms.vcproj b/Code/Mantid/UserAlgorithms/UserAlgorithms.vcproj index db5ecc1b1179072fe4426768fc8e8afb31c94bc4..83f3eb9d7f1a54eb18cb3a05e12daf07413f620c 100644 --- a/Code/Mantid/UserAlgorithms/UserAlgorithms.vcproj +++ b/Code/Mantid/UserAlgorithms/UserAlgorithms.vcproj @@ -113,7 +113,7 @@ Optimization="3" AdditionalIncludeDirectories="inc;../API/inc;../Geometry/inc;../Kernel/inc;../DataObjects/inc;../../Third_Party/include" PreprocessorDefinitions="WIN32;_WINDOWS;POCO_DLL;WINVER=0x0500;IN_MANTID_ALGORITHMS=1;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE" - RuntimeLibrary="3" + RuntimeLibrary="2" DisableSpecificWarnings="4996" /> <Tool diff --git a/Code/Mantid/release/Mantid.properties b/Code/Mantid/release/Mantid.properties index 1c07cde4030f64682ebfd93f15e0ddcb09009bef..846be7749cf136e6fc2521555ec0475cf6b4c42c 100644 --- a/Code/Mantid/release/Mantid.properties +++ b/Code/Mantid/release/Mantid.properties @@ -15,3 +15,6 @@ logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s logging.formatters.f1.class = PatternFormatter logging.formatters.f1.pattern = %s-[%p] %t logging.formatters.f1.times = UTC; + +logging.loggers.root.channel.channel3 = signalChannel +logging.channels.signalChannel.class = SignalChannel diff --git a/Code/qtiplot/qtiplot/qtiplot.pro b/Code/qtiplot/qtiplot/qtiplot.pro index 09c77e6ab76c835e7f95f3e5ebdb721d3af7b4d6..8491ffd150774a5312c6b32ff0afdaf05f5edd49 100644 --- a/Code/qtiplot/qtiplot/qtiplot.pro +++ b/Code/qtiplot/qtiplot/qtiplot.pro @@ -94,6 +94,7 @@ win32:LIBS += ../../Mantid/Bin/Shared/MantidKernel.lib win32:LIBS += ../../Third_Party/lib/win32/PocoUtil.lib win32:LIBS += ../../Third_Party/lib/win32/PocoXML.lib win32:LIBS += ../../Third_Party/lib/win32/PocoFoundation.lib +win32:LIBS += ../../Third_Party/lib/win32/libboost_signals-vc80-mt-1_34_1.lib ############################################################################# ###################### END OF USER-SERVICEABLE PART ######################### @@ -308,7 +309,9 @@ HEADERS += src/ApplicationWindow.h \ src/Mantid/ExecuteAlgorithm.h \ src/Mantid/ImportWorkspaceDlg.h \ src/Mantid/WorkspaceMatrix.h \ - src/Mantid/WorkspaceMatrixModel.h + src/Mantid/WorkspaceMatrixModel.h \ + src/Mantid/AbstractMantidLog.h \ + src/Mantid/MantidLog.h ###################### FORMS ############################################## @@ -437,7 +440,9 @@ SOURCES += src/ApplicationWindow.cpp \ src/Mantid/ExecuteAlgorithm.cpp \ src/Mantid/ImportWorkspaceDlg.cpp \ src/Mantid/WorkspaceMatrix.cpp \ - src/Mantid/WorkspaceMatrixModel.cpp + src/Mantid/WorkspaceMatrixModel.cpp \ + src/Mantid/AbstractMantidLog.cpp \ + src/Mantid/MantidLog.cpp ############################################################### ##################### Compression (zlib123) ################### diff --git a/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp b/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp index 09f76f09fa420116be9cac7a95ef7ab4cc3aa0e5..92c91516cabaa2fb823ef1d13795b36a4e4308aa 100644 --- a/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp +++ b/Code/qtiplot/qtiplot/src/ApplicationWindow.cpp @@ -15214,6 +15214,7 @@ void ApplicationWindow::manageMantidWorkspaces() WorkspaceMgr* dlg = new WorkspaceMgr(this); dlg->setModal(true); dlg->exec(); + delete dlg; } //Mantid diff --git a/Code/qtiplot/qtiplot/src/Mantid/AbstractMantidLog.cpp b/Code/qtiplot/qtiplot/src/Mantid/AbstractMantidLog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..91253db8d7f70d070ef22094afd02019938b3124 --- /dev/null +++ b/Code/qtiplot/qtiplot/src/Mantid/AbstractMantidLog.cpp @@ -0,0 +1,31 @@ +#include "AbstractMantidLog.h" + +#include "MantidKernel/SignalChannel.h" +#include "Poco/LoggingRegistry.h" +#include "boost/bind.hpp" + +#include <QMessageBox> + +void AbstractMantidLog::connect() +{ + try + { + Poco::SignalChannel *pChannel = dynamic_cast<Poco::SignalChannel*>(Poco::LoggingRegistry::defaultRegistry().channelForName("signalChannel")); + if (!pChannel) + { + QMessageBox::warning(0,"MantidLog","Channel is of wrong type"); + return; + } + pChannel->sig().connect(boost::bind(&AbstractMantidLog::log,this,_1)); + } + catch(...) + { + QMessageBox::warning(0,"MantidLog","Channel signalChannel not found"); + return; + } +} + +void AbstractMantidLog::log(const Poco::Message& msg) +{ +} + diff --git a/Code/qtiplot/qtiplot/src/Mantid/AbstractMantidLog.h b/Code/qtiplot/qtiplot/src/Mantid/AbstractMantidLog.h new file mode 100644 index 0000000000000000000000000000000000000000..28efe3c8b85b361d68b7ad4d63e41f1ca88348de --- /dev/null +++ b/Code/qtiplot/qtiplot/src/Mantid/AbstractMantidLog.h @@ -0,0 +1,42 @@ +#ifndef ABSTRACT_MANTIDLOG_H +#define ABSTRACT_MANTIDLOG_H + +#ifndef QT_NO_KEYWORDS +#define QT_NO_KEYWORDS +#define DEFINE_SLOTS_AGAIN +#endif + +#include <QObject> +#include "Poco/Message.h" + +/** + + class AbstractMantidLog connects to Mantid's SignalChannel + Method log() receives the message from SignalChannel + +*/ +class AbstractMantidLog : public QObject +{ + //Q_OBJECT + +public: + + /// Makes connection to SignalChannel. + /// Channel's name must be signalChannel + void connect(); + +protected:// Q_SLOTS: + + /// Receives message from SignalChannel. + /// Does nothing, must be overriden in a child class + virtual void log(const Poco::Message& msg); +}; + +#ifdef DEFINE_SLOTS_AGAIN +#undef QT_NO_KEYWORDS +//#define slots // this is not very nice, a Qt's include file should do it +//#include <qobjectdefs.h> +#undef DEFINE_SLOTS_AGAIN +#endif + +#endif /* ABSTRACT_MANTIDLOG_H */ diff --git a/Code/qtiplot/qtiplot/src/Mantid/MantidLog.cpp b/Code/qtiplot/qtiplot/src/Mantid/MantidLog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7797bfdb027f5217f65de669955e520d4c2a17c --- /dev/null +++ b/Code/qtiplot/qtiplot/src/Mantid/MantidLog.cpp @@ -0,0 +1,12 @@ +#include "../ApplicationWindow.h" +#include "MantidLog.h" + +/// Posts message text to QtiPlot Result Log +void MantidLog::log(const Poco::Message& msg) +{ + QString str = msg.getText().c_str(); + s_appWin->updateLog(str+"\n"); +} + +boost::shared_ptr<MantidLog> MantidLog::s_Instance; +ApplicationWindow* MantidLog::s_appWin = 0; diff --git a/Code/qtiplot/qtiplot/src/Mantid/MantidLog.h b/Code/qtiplot/qtiplot/src/Mantid/MantidLog.h new file mode 100644 index 0000000000000000000000000000000000000000..946b12454b0aa9c33b1530a8877f654306a8cb88 --- /dev/null +++ b/Code/qtiplot/qtiplot/src/Mantid/MantidLog.h @@ -0,0 +1,42 @@ +#ifndef MANTIDLOG_H +#define MANTIDLOG_H + +#include "AbstractMantidLog.h" +#include <boost/shared_ptr.hpp> + +class ApplicationWindow; + +class MantidLog: public AbstractMantidLog +{ + //Q_OBJECT + +public: + + static void connect(ApplicationWindow* w) + { + if (!s_Instance) + { + s_Instance.reset(new MantidLog); + s_appWin = w; + s_Instance->AbstractMantidLog::connect(); + } + if (w) s_appWin = w; + } + static long count() + { + return s_Instance.use_count(); + } + +protected:// slots: + + void log(const Poco::Message& msg); + +private: + + static boost::shared_ptr<MantidLog> s_Instance; + static ApplicationWindow* s_appWin; + +}; + + +#endif /* MANTIDLOG_H */ diff --git a/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.cpp b/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.cpp index eb7fc370cd85bf755120c414749fa217c107b85a..dbdbeb615b8e68060e8a59a460af37054d85c30b 100644 --- a/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.cpp +++ b/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.cpp @@ -1,8 +1,3 @@ -#include <vector> -#include <string> -#include <stdexcept> -#include <QMessageBox> -#include <QListWidgetItem> #include "WorkspaceMatrix.h" #include "WorkspaceMgr.h" @@ -13,6 +8,13 @@ #include "ExecuteAlgorithm.h" #include "MantidKernel/Property.h" +#include "MantidLog.h" + +#include <vector> +#include <string> +#include <stdexcept> +#include <QMessageBox> +#include <QListWidgetItem> WorkspaceMgr::WorkspaceMgr(QWidget *parent) : QDialog(parent) { @@ -22,16 +24,26 @@ WorkspaceMgr::WorkspaceMgr(QWidget *parent) : QDialog(parent) setupActions(); m_interface = new Mantid::PythonAPI::PythonInterface; - m_interface->InitialiseFrameworkManager(); getWorkspaces(); getAlgorithms(); + + /// Make connection to Mantid's SignalChannel + if (parent->isA("ApplicationWindow")) + { + MantidLog::connect(static_cast<ApplicationWindow*>(parent)); + } + else + { + QMessageBox::warning(this,"Workspace Manager","Main window is not an ApplicationWindow"); + } + } WorkspaceMgr::~WorkspaceMgr() { - + delete m_interface; } void WorkspaceMgr::setupActions() diff --git a/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.h b/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.h index 16064a78b01364d17c5ff9d3d6dbad9899aea7ae..6566c5231ba6ce62fea0bdb1c0feee99a87ed207 100644 --- a/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.h +++ b/Code/qtiplot/qtiplot/src/Mantid/WorkspaceMgr.h @@ -11,7 +11,6 @@ #include "MantidAPI/IAlgorithm.h" #include "MantidAPI/Algorithm.h" - class WorkspaceMgr : public QDialog, private Ui::Dialog { Q_OBJECT diff --git a/Code/qtiplot/qtiplot/src/main.cpp b/Code/qtiplot/qtiplot/src/main.cpp index c383c3c6b06ad102df5a9e0415c1379fc468d66e..256ae1f95a7bc138f5d66f93277f814a74fdb7e9 100644 --- a/Code/qtiplot/qtiplot/src/main.cpp +++ b/Code/qtiplot/qtiplot/src/main.cpp @@ -118,10 +118,21 @@ If you want to contribute code, please read the notes on \ref style "coding styl - For indentations, tabs are preferred because they allow everyone to choose the indentation depth for him/herself. */ +#include <QDir> + int main( int argc, char ** argv ) { QApplication app( argc, argv ); + QString path = argv[0]; + int i = path.lastIndexOf('/'); + if (i < 0) i = path.lastIndexOf('\\'); + if (i>=0) + { + path.remove(i,1000); + QDir::setCurrent(path); + } + QStringList args = app.arguments(); args.removeFirst(); // remove application name