#pragma once //- // =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== //+ // // CLASS: MComputation // // **************************************************************************** #include #include OPENMAYA_MAJOR_NAMESPACE_OPEN // **************************************************************************** // CLASS DECLARATION (MComputation) //! \ingroup OpenMaya //! \brief Interupt monitor for long computations. /*! An MComputation allows long computations to check for user interrupts. It is very simple to use. Create a new MComputation object and call the beginComputation method at the beginning of the computation and call the endComputation method when you finish. Then, during the computation, use the isInterruptRequested method to check if the user has requested that the computation terminate. Example: (of a simple traversal) \code MComputation computation; computation.beginComputation(); for (int i= 1; i<1000; i++) { Computation(); // Some expensive operation if (computation.isInterruptRequested()) break ; } computation.endComputation(); \endcode An alternate form of computation with a progress indicator is supported. In this case, the beginProgressiveComputation method is called along with the progress methods. Example: (of a simple progressive traversal) \code MComputation computation; computation.beginComputation( true ); computation.setProgressRange( 0, 100 ); for (int i= 1; i<1000; i++) { Computation(); // Some expensive operation if (computation.isInterruptRequested()) break ; computation.setProgress( (int)(i/1000.0 * 100.0) ); } computation.endComputation(); \endcode */ class OPENMAYA_EXPORT MComputation { public: MComputation(); virtual ~MComputation(); void beginComputation( bool showProgressBar = false, bool isInterruptable = true, bool useWaitCursor = true ); bool isInterruptRequested(); void endComputation(); MStatus setProgressRange(const int minValue, const int maxValue); int progressMin(MStatus* ReturnStatus = NULL) const; int progressMax(MStatus* ReturnStatus = NULL) const; MStatus setProgress(const int amount); int progress(MStatus* ReturnStatus = NULL) const; MStatus setProgressStatus(const MString&); static const char* className(); protected: // No protected members private: void *f_data; bool useProgressBar; }; OPENMAYA_NAMESPACE_CLOSE