From fa3ab03d479ca2d437a26d7a5cc619635b5c57ad Mon Sep 17 00:00:00 2001 From: Roman Tolchenov <roman.tolchenov@stfc.ac.uk> Date: Wed, 23 Feb 2011 11:13:15 +0000 Subject: [PATCH] A correction to progress reporting in Load algorithm. re #2494 --- .../Framework/API/inc/MantidAPI/Algorithm.h | 8 ++++---- .../API/inc/MantidAPI/AlgorithmProxy.h | 4 ++-- .../Framework/API/inc/MantidAPI/IAlgorithm.h | 4 ++-- .../Framework/API/src/AlgorithmProxy.cpp | 4 ++-- .../Mantid/Framework/DataHandling/src/Load.cpp | 6 +++--- .../DataHandling/src/LoadRawHelper.cpp | 2 +- .../DataHandling/src/SetScalingPSD.cpp | 8 +++++--- .../src/Mantid/FitPropertyBrowser.cpp | 18 +++++++++--------- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h b/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h index fdcf7db4fa9..46e930ef0f4 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/Algorithm.h @@ -235,9 +235,9 @@ public: void setOptionalMessage(const std::string optionalMessage) { m_OptionalMessage = optionalMessage;} ///setting the child start progress - void setChildStartProgress(const double startProgress){m_startChildProgress=startProgress;} + void setChildStartProgress(const double startProgress)const{m_startChildProgress=startProgress;} /// setting the child end progress - void setChildEndProgress(const double endProgress){m_endChildProgress=endProgress;} + void setChildEndProgress(const double endProgress)const{m_endChildProgress=endProgress;} protected: @@ -340,8 +340,8 @@ private: bool m_running; ///< Algorithm is running bool m_rethrow; ///< Algorithm should rethrow exceptions while executing - double m_startChildProgress; ///< Keeps value for algorithm's progress at start of an sub-algorithm - double m_endChildProgress; ///< Keeps value for algorithm's progress at sub-algorithm's finish + mutable double m_startChildProgress; ///< Keeps value for algorithm's progress at start of an sub-algorithm + mutable double m_endChildProgress; ///< Keeps value for algorithm's progress at sub-algorithm's finish AlgorithmID m_algorithmID; ///< Algorithm ID for managed algorithms diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h index 3074a6b88fb..4b90cf15c3a 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmProxy.h @@ -107,9 +107,9 @@ namespace Mantid bool isLogging() const { return m_isLoggingEnabled; } ///setting the child start progress - void setChildStartProgress(const double startProgress); + void setChildStartProgress(const double startProgress)const; /// setting the child end progress - void setChildEndProgress(const double endProgress); + void setChildEndProgress(const double endProgress)const; private: diff --git a/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h b/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h index 2779491451c..52304c83685 100644 --- a/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h +++ b/Code/Mantid/Framework/API/inc/MantidAPI/IAlgorithm.h @@ -126,9 +126,9 @@ public: ///returns the status of logging, True = enabled virtual bool isLogging() const = 0; ///setting the child start progress - virtual void setChildStartProgress(const double startProgress)=0; + virtual void setChildStartProgress(const double startProgress)const = 0; /// setting the child end progress - virtual void setChildEndProgress(const double endProgress)=0; + virtual void setChildEndProgress(const double endProgress)const = 0; }; typedef boost::shared_ptr<IAlgorithm> IAlgorithm_sptr; diff --git a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp index ceb47f7f172..1a2526a0c49 100644 --- a/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp +++ b/Code/Mantid/Framework/API/src/AlgorithmProxy.cpp @@ -214,12 +214,12 @@ bool AlgorithmProxy::executeAsyncImpl(const Poco::Void & dummy) return m_isExecuted; } ///setting the child start progress - void AlgorithmProxy::setChildStartProgress(const double startProgress) + void AlgorithmProxy::setChildStartProgress(const double startProgress)const { m_alg->setChildStartProgress(startProgress); } /// setting the child end progress - void AlgorithmProxy::setChildEndProgress(const double endProgress) + void AlgorithmProxy::setChildEndProgress(const double endProgress)const { m_alg->setChildEndProgress(endProgress); } diff --git a/Code/Mantid/Framework/DataHandling/src/Load.cpp b/Code/Mantid/Framework/DataHandling/src/Load.cpp index 460c46d010f..14dfa8dc461 100644 --- a/Code/Mantid/Framework/DataHandling/src/Load.cpp +++ b/Code/Mantid/Framework/DataHandling/src/Load.cpp @@ -236,7 +236,7 @@ namespace Mantid { throw std::invalid_argument("Cannot find loader, LoaderName property has not been set."); } - IDataFileChecker_sptr loader = createLoader(loaderName); + IDataFileChecker_sptr loader = createLoader(loaderName,0,1); g_log.information() << "Using " << loaderName << " version " << loader->version() << ".\n"; ///get the list properties for the concrete loader load algorithm const std::vector<Kernel::Property*> & loader_props = loader->getProperties(); @@ -298,8 +298,8 @@ namespace Mantid if (startProgress >= 0. && endProgress > startProgress && endProgress <= 1.) { loader->addObserver(m_progressObserver); - loader->setChildStartProgress(startProgress); - loader->setChildEndProgress(endProgress); + setChildStartProgress(startProgress); + setChildEndProgress(endProgress); } return loader; } diff --git a/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp b/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp index b430e732677..f0c34164ae7 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadRawHelper.cpp @@ -36,7 +36,7 @@ namespace Mantid LoadRawHelper::LoadRawHelper() : isisRaw(new ISISRAW2), m_list(false),m_spec_list(),m_spec_min(0), - m_spec_max(EMPTY_INT()),m_specTimeRegimes(),m_bmspeclist(false) + m_spec_max(EMPTY_INT()),m_specTimeRegimes(),m_prog(0),m_bmspeclist(false) { } diff --git a/Code/Mantid/Framework/DataHandling/src/SetScalingPSD.cpp b/Code/Mantid/Framework/DataHandling/src/SetScalingPSD.cpp index f4c44b94191..32fdd3bc687 100644 --- a/Code/Mantid/Framework/DataHandling/src/SetScalingPSD.cpp +++ b/Code/Mantid/Framework/DataHandling/src/SetScalingPSD.cpp @@ -309,7 +309,8 @@ void SetScalingPSD::movePos(API::MatrixWorkspace_sptr& WS, std::map<int,Geometry double scale,maxScale=-1e6,minScale=1e6,aveScale=0.0; int scaleCount=0; //progress 50% here inside the for loop - double prog=0.5; + //double prog=0.5; + Progress prog(this,0.5,1.0,m_vectDet.size()); // loop over detector (IComps) for(size_t id=0;id<m_vectDet.size();id++) { @@ -351,8 +352,9 @@ void SetScalingPSD::movePos(API::MatrixWorkspace_sptr& WS, std::map<int,Geometry pmap.addV3D(comp.get(),"sca",V3D(1.0,it->second,1.0)); } // - prog+= double(1)/m_vectDet.size(); - progress(prog); + //prog+= double(1)/m_vectDet.size(); + //progress(prog); + prog.report(); } g_log.debug() << "Range of scaling factors is " << minScale << " to " << maxScale << "\n" << "Average abs scaling fraction is " << aveScale/scaleCount << "\n"; diff --git a/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp b/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp index d704e423db0..b0bfde8566b 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/FitPropertyBrowser.cpp @@ -1345,10 +1345,10 @@ void FitPropertyBrowser::getFitResults() if (ws) { - try + Mantid::API::TableRow row = ws->getFirstRow(); + do { - Mantid::API::TableRow row = ws->getFirstRow(); - do + try { std::string name; double value; @@ -1360,13 +1360,13 @@ void FitPropertyBrowser::getFitResults() } compositeFunction()->setParameter(name,value); } - while(row.next()); - updateParameters(); - } - catch(...) - { - // do nothing + catch(...) + { + // do nothing + } } + while(row.next()); + updateParameters(); } } } -- GitLab