Gui::Sequencer Class Reference

FreeCAD's progress bar for long operations To see how to use the progress bar have a look at the following examples:. More...

#include <ProgressBar.h>

Inheritance diagram for Gui::Sequencer:
Base::SequencerBase

List of all members.

Public Member Functions

QProgressBar * getProgressBar (QWidget *parent=0)
 Returns an instance of the progress bar.
bool isBlocking () const
 Returns true if the running sequencer is blocking any user input.
void pause ()
 This restores the last overridden cursor and release the keyboard while the progress bar is running.
void resume ()
 This sets the wait cursor again and grabs the keyboard.

Static Public Member Functions

static Sequencerinstance ()
 Returns the sequencer object.

Protected Member Functions

void nextStep (bool canAbort)
 Increase the progress bar.
void resetData ()
 Resets the sequencer.
 Sequencer ()
 Construction.
void setProgress (size_t)
 Sets the progress indicator to a certain position.
void setText (const char *pszTxt)
 Puts text to the status bar.
void showRemainingTime ()
void startStep ()
 Starts the progress bar.
 ~Sequencer ()
 Destruction.

Friends

class ProgressBar

Detailed Description

FreeCAD's progress bar for long operations To see how to use the progress bar have a look at the following examples:.

 unsigned long steps = ...
 Base::SequencerLauncher seq("Starting progress bar", 0);

 for (unsigned long i=0; i<steps;i++)
 {
   seq.next();
   // do one step of your algorithm
 }

The example below shows how to use two nested progresses.

 void function1()
 {
   unsigned long steps = ...
   Base::SequencerLauncger seq("Starting progress bar", 0);

   for (unsigned long i=0; i<steps;i++)
   {
     seq.next();
     // do one step of your algorithm
   }

 }
 
 void function2()
 {
   unsigned long steps = ...
   Base::SequencerLauncher seq("Starting progress bar", 0);

   for (unsigned long i=0; i<steps;i++)
   {
     seq.next();
     // do one step of your algorithm calling function1
     function1();
   }
 }

If the total number of steps cannot be determined before, use 0 instead of to show just a busy indicator instead of percentage steps.

Author:
Werner Mayer

Definition at line 88 of file ProgressBar.h.


Constructor & Destructor Documentation

Sequencer::Sequencer (  )  [protected]

Construction.

Definition at line 89 of file ProgressBar.cpp.

References Gui::SequencerPrivate::bar, Gui::SequencerPrivate::guiThread, and Gui::SequencerPrivate::waitCursor.

Referenced by instance().

Sequencer::~Sequencer (  )  [protected]

Destruction.

Definition at line 97 of file ProgressBar.cpp.


Member Function Documentation

QProgressBar * Sequencer::getProgressBar ( QWidget *  parent = 0  ) 

Returns an instance of the progress bar.

It creates one if needed.

Definition at line 325 of file ProgressBar.cpp.

References Gui::SequencerPrivate::bar, and ProgressBar.

Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().

Sequencer * Sequencer::instance ( void   )  [static]

Returns the sequencer object.

Definition at line 78 of file ProgressBar.cpp.

References Sequencer().

Referenced by Gui::MainWindow::MainWindow(), WebGui::BrowserView::onLoadProgress(), and WebGui::BrowserView::onLoadStarted().

bool Sequencer::isBlocking (  )  const [virtual]

Returns true if the running sequencer is blocking any user input.

This might be only of interest of the GUI where the progress bar or dialog is used from a thread. If started from a thread this method should return false, otherwise true. The default implementation always returns true.

Reimplemented from Base::SequencerBase.

Definition at line 320 of file ProgressBar.cpp.

References Gui::SequencerPrivate::guiThread.

void Sequencer::nextStep ( bool  canAbort  )  [protected, virtual]
void Sequencer::pause (  )  [virtual]

This restores the last overridden cursor and release the keyboard while the progress bar is running.

This is useful e.g. if a modal dialog appears while a long operation is performed to indicate that the user can click on the dialog. Every pause() must eventually be followed by a corresponding resume().

Reimplemented from Base::SequencerBase.

Definition at line 102 of file ProgressBar.cpp.

References Gui::SequencerPrivate::bar, Gui::WaitCursor::restoreCursor(), and Gui::SequencerPrivate::waitCursor.

Referenced by nextStep().

void Sequencer::resetData (  )  [protected, virtual]
void Sequencer::resume (  )  [virtual]

This sets the wait cursor again and grabs the keyboard.

See also:
pause()

Reimplemented from Base::SequencerBase.

Definition at line 115 of file ProgressBar.cpp.

References Gui::SequencerPrivate::bar, Gui::WaitCursor::setWaitCursor(), and Gui::SequencerPrivate::waitCursor.

Referenced by nextStep().

void Sequencer::setProgress ( size_t  step  )  [protected, virtual]

Sets the progress indicator to a certain position.

Reimplemented from Base::SequencerBase.

Definition at line 184 of file ProgressBar.cpp.

References Gui::SequencerPrivate::bar.

void Sequencer::setText ( const char *  pszTxt  )  [protected, virtual]

Puts text to the status bar.

Reimplemented from Base::SequencerBase.

Definition at line 302 of file ProgressBar.cpp.

References Gui::SequencerPrivate::bar, Gui::getMainWindow(), Gui::MainWindow::showMessage(), and Gui::SequencerPrivate::text.

void Sequencer::showRemainingTime (  )  [protected]
void Sequencer::startStep (  )  [protected, virtual]

Friends And Related Function Documentation

friend class ProgressBar [friend]

Definition at line 133 of file ProgressBar.h.

Referenced by getProgressBar().


The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:02:02 2011 for FreeCAD by  doxygen 1.6.1