From: eap Date: Wed, 3 Jul 2013 16:09:28 +0000 (+0000) Subject: Compute Progress bar X-Git-Tag: V7_3_0a1~293 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fad96c28703b39afa8a98eb004a4d8921f8eb9ec;p=modules%2Fsmesh.git Compute Progress bar + virtual double GetProgress() const; + double GetProgressByTic() const; + int& GetComputeCost() { return _computeCost; } + int _computeCost; //!< "compute cost" of shapes being Compute()d + int _progressTic; //!< counter of calls from SMESH_Mesh::GetComputeProgress() + double _progress; //!< progress of Compute() [0.,1.] --- diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 63d232027..79a77f827 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -175,7 +175,7 @@ const SMESH_Algo::Features& SMESH_Algo::GetFeatures( const std::string& algoType SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen) { - gen->_mapAlgo[hypId] = this; + //gen->_mapAlgo[hypId] = this; _onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true; _quadraticMesh = _supportSubmeshes = false; @@ -205,28 +205,28 @@ SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen) { _shapeType = (1 << TopAbs_VERTEX); _type = ALGO_0D; - gen->_map0D_Algo[hypId] = this; + //gen->_map0D_Algo[hypId] = this; } SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen) : SMESH_Algo(hypId, studyId, gen) { _shapeType = (1 << TopAbs_EDGE); _type = ALGO_1D; - gen->_map1D_Algo[hypId] = this; + //gen->_map1D_Algo[hypId] = this; } SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen) : SMESH_Algo(hypId, studyId, gen) { _shapeType = (1 << TopAbs_FACE); _type = ALGO_2D; - gen->_map2D_Algo[hypId] = this; + //gen->_map2D_Algo[hypId] = this; } SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen) : SMESH_Algo(hypId, studyId, gen) { _shapeType = (1 << TopAbs_SOLID); _type = ALGO_3D; - gen->_map3D_Algo[hypId] = this; + //gen->_map3D_Algo[hypId] = this; } //============================================================================= @@ -681,6 +681,17 @@ void SMESH_Algo::CancelCompute() _error = COMPERR_CANCELED; } +//================================================================================ +/* + * If possible, returns progress of computation [0.,1.] + */ +//================================================================================ + +double SMESH_Algo::GetProgress() const +{ + return _progress; +} + //================================================================================ /*! * \brief store error and comment and then return ( error == COMPERR_OK ) @@ -728,7 +739,7 @@ SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const //================================================================================ /*! - * \brief initialize compute error + * \brief initialize compute error before call of Compute() */ //================================================================================ @@ -743,6 +754,23 @@ void SMESH_Algo::InitComputeError() _badInputElements.clear(); _computeCanceled = false; + _computeCost = 1; + _progressTic = 0; + _progress = 0.; +} + +//================================================================================ +/*! + * \brief Return compute progress by nb of calls of this method + */ +//================================================================================ + +double SMESH_Algo::GetProgressByTic() const +{ + const_cast( this )->_progressTic++; + double x = 5 * _progressTic; + x = ( x < _computeCost ) ? ( x / _computeCost ) : 1.; + return 0.9 * sin( x * M_PI / 2 ); } //================================================================================ diff --git a/src/SMESH/SMESH_Algo.hxx b/src/SMESH/SMESH_Algo.hxx index 25224689a..8d5d4cf47 100644 --- a/src/SMESH/SMESH_Algo.hxx +++ b/src/SMESH/SMESH_Algo.hxx @@ -169,6 +169,11 @@ class SMESH_EXPORT SMESH_Algo : public SMESH_Hypothesis */ virtual void CancelCompute(); + /*! + * \brief If possible, returns progress of computation [0.,1.] + */ + virtual double GetProgress() const; + /*! * \brief evaluates size of prospective mesh on a shape * \param aMesh - the mesh @@ -224,14 +229,23 @@ class SMESH_EXPORT SMESH_Algo : public SMESH_Hypothesis */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); + /*! * \brief return compute error */ SMESH_ComputeErrorPtr GetComputeError() const; /*! - * \brief initialize compute error + * \brief initialize compute error before call of Compute() */ void InitComputeError(); + /*! + * \brief Return compute progress by nb of calls of this method + */ + double GetProgressByTic() const; + /*! + * Return a storage of "compute cost" of shapes being Compute()d. + */ + int& GetComputeCost() { return _computeCost; } public: // ================================================================== @@ -407,8 +421,12 @@ protected: std::list _badInputElements; //!< to explain COMPERR_BAD_INPUT_MESH volatile bool _computeCanceled; //!< is set to True while computing to stop it + int _computeCost; //!< "compute cost" of shapes being Compute()d + int _progressTic; //!< counter of calls from SMESH_Mesh::GetComputeProgress() + double _progress; //!< progress of Compute() [0.,1.] }; + class SMESH_EXPORT SMESH_0D_Algo: public SMESH_Algo { public: