Commit 4664c21e authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Progress bar mechanism added for the tool plugins.

parent e1118465
......@@ -9,6 +9,7 @@
#include "GLViewer.h"
#include "AlgorithmSelector.h"
#include "ui_AlgorithmSelector.h"
#include "UIMultiProgressDialog.h"
#include <QLabel>
......@@ -250,7 +251,7 @@ void AlgorithmSelector::applyCurrentToolOn( const QList<GenericUIData*> &items,
QVector<QString> acceptedTypes;
m_SelectedTool->plugin->acceptedDataTypes( m_SelectedTool->id, acceptedTypes );
QVector< QList<GenericUIData*> > sortedItems;
sortedItems.resize( acceptedTypes.size() );
......@@ -259,11 +260,27 @@ void AlgorithmSelector::applyCurrentToolOn( const QList<GenericUIData*> &items,
if( m->GetTypeString() == acceptedTypes[k] )
sortedItems[k].push_back( m );
unsigned int nProgressBars = m_SelectedTool->plugin->needProgressBars( m_SelectedTool->id );
UIMultiProgressDialog *progressDlg = NULL;
if( nProgressBars > 0 )
{
progressDlg = new UIMultiProgressDialog( nProgressBars, mainwin );
connect( m_SelectedTool->plugin, SIGNAL(notifyProgressBar(unsigned int,QString,int)), progressDlg, SLOT(setBar(unsigned int,QString,int)) );
connect( m_SelectedTool->plugin, SIGNAL(notifyProgressValue(unsigned int,int)), progressDlg, SLOT(setProgress(unsigned int,int)) );
}
bool executionOk;
if( m_ActionId.isNull() )
executionOk = m_SelectedTool->plugin->exec( m_SelectedTool->id, sortedItems, *m_SelectedToolParam, ctx );
else
executionOk = m_SelectedTool->plugin->execAction( m_SelectedTool->id, m_ActionId, sortedItems, *m_SelectedToolParam, ctx );
if( progressDlg )
{
progressDlg->close();
progressDlg->deleteLater();
}
emit toolExecutionFinished( executionOk );
}
}
......@@ -20,9 +20,12 @@
#include "Context.h"
class ToolInterface
class ToolInterface : public QObject
{
Q_OBJECT
public:
inline ToolInterface() : QObject() {}
virtual ~ToolInterface() {}
/** In the case of a plugin containing more than one tool, this function returns a list
......@@ -39,6 +42,8 @@ public:
virtual void acceptedDataTypes( int id, QVector<QString> &types ) const = 0;
/** Widget that will be used by the user to provide some options for the tool execution. */
virtual void parameters( int id, UIParamSet &params ) = 0;
/** Specify the number of progress bar to show. If 0, no progress bar is shown */
virtual unsigned int needProgressBars( int id ) const { return 0; }
/** Core function that effectively performs the tool execution. Data to be processed are
* given to the function through the vector *items*. Each cell of this vector contains
* a list of BaseManageable, whose concrete type is the one given by the corresponding
......@@ -52,6 +57,19 @@ public:
virtual bool execAction( int id, const QString &actId, QVector< QList<GenericUIData*> > &items, UIParamSet &params, Context &context ) { return true; }
inline void logMsg( const QString& msg ) {}
inline void setProgressBar( const QString& label,
int maxValue ) { emit notifyProgressBar( 0, label, maxValue ); }
inline void setProgressBar( unsigned int n,
const QString& label,
int maxValue ) { emit notifyProgressBar( n, label, maxValue ); }
inline void reportProgress( int value ) { emit notifyProgressValue( 0, value ); }
inline void reportProgress( unsigned int n, int value ) { emit notifyProgressValue( n, value ); }
signals:
void notifyProgressBar( unsigned int n, const QString& label, int maxValue );
void notifyProgressValue( unsigned int n, int value );
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment