|
||||
File indexing completed on 2025-01-18 10:04:16
0001 // Copyright (c) 2017-2021 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _Message_LazyProgressScope_HeaderFiler 0015 #define _Message_LazyProgressScope_HeaderFiler 0016 0017 #include <Message_ProgressScope.hxx> 0018 0019 //! Progress scope with lazy updates and abort fetches. 0020 //! 0021 //! Although Message_ProgressIndicator implementation is encouraged to spare GUI updates, 0022 //! even optimized implementation might show a noticeable overhead on a very small update step (e.g. per triangle). 0023 //! 0024 //! The class splits initial (displayed) number of overall steps into larger chunks specified in constructor, 0025 //! so that displayed progress is updated at larger steps. 0026 class Message_LazyProgressScope : protected Message_ProgressScope 0027 { 0028 public: 0029 0030 //! Main constructor. 0031 //! @param theRange [in] progress range to scope 0032 //! @param theName [in] name of this scope 0033 //! @param theMax [in] number of steps within this scope 0034 //! @param thePatchStep [in] number of steps to update progress 0035 //! @param theIsInf [in] infinite flag 0036 Message_LazyProgressScope (const Message_ProgressRange& theRange, 0037 const char* theName, 0038 const Standard_Real theMax, 0039 const Standard_Real thePatchStep, 0040 const Standard_Boolean theIsInf = Standard_False) 0041 : Message_ProgressScope (theRange, theName, theMax, theIsInf), 0042 myPatchStep (thePatchStep), 0043 myPatchProgress (0.0), 0044 myIsLazyAborted (Standard_False) {} 0045 0046 //! Increment progress with 1. 0047 void Next() 0048 { 0049 if (++myPatchProgress < myPatchStep) 0050 { 0051 return; 0052 } 0053 0054 myPatchProgress = 0.0; 0055 Message_ProgressScope::Next (myPatchStep); 0056 IsAborted(); 0057 } 0058 0059 //! Return TRUE if progress has been aborted - return the cached state lazily updated. 0060 Standard_Boolean More() const 0061 { 0062 return !myIsLazyAborted; 0063 } 0064 0065 //! Return TRUE if progress has been aborted - fetches actual value from the Progress. 0066 Standard_Boolean IsAborted() 0067 { 0068 myIsLazyAborted = myIsLazyAborted || !Message_ProgressScope::More(); 0069 return myIsLazyAborted; 0070 } 0071 0072 protected: 0073 0074 Standard_Real myPatchStep; 0075 Standard_Real myPatchProgress; 0076 Standard_Boolean myIsLazyAborted; 0077 0078 }; 0079 0080 #endif // _Message_LazyProgressScope_HeaderFiler
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |