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

ToolInterface modified to provide an onUpdatingParameter() mechanism.

parent d29bc444
......@@ -67,10 +67,13 @@ void AlgorithmSelector::populateTools( ToolInterface *plugin )
tool.plugin = plugin;
tool.id = i;
tool.param = new UIParamSet( "Tool options", this );
plugin->parameters( i, *tool.param );
plugin->setParameters( tool.param );
plugin->declareParameters( i, *tool.param );
tool.param->hide();
//tool.param->setMaximumWidth(360);
connect( tool.param, SIGNAL(parameterUpdated(UIParam*)), tool.plugin, SLOT(updateParameter(UIParam*)) );
foreach( UIParamAction* act, tool.param->GetActions() )
connect( act->Widget(), SIGNAL(clicked(bool)), this, SLOT(emitActionSignal()) );
......
......@@ -25,52 +25,64 @@ class ToolInterface : public QObject
{
Q_OBJECT
UIParamSet *m_Parameters;
public:
inline ToolInterface() : QObject() {}
virtual ~ToolInterface() {}
inline ToolInterface() : QObject(), m_Parameters(NULL) {}
virtual ~ToolInterface() {}
inline void setParameters( UIParamSet *params ) { m_Parameters = params; }
/** Recover the current state of the set of tool parameters. */
inline const UIParamSet& getParameters() const { return *m_Parameters; }
/** In the case of a plugin containing more than one tool, this function returns a list
* of numbers that makes it possible to identify each of them.
*/
virtual void toolIds( QList<int> &ids ) const = 0;
virtual void toolIds( QList<int> &ids ) const = 0;
/** Category to which the tool belongs. */
virtual int category( int id ) const = 0;
virtual int category( int id ) const = 0;
/** Name of the tool, as it will be displayed in the GUI. */
virtual QString name( int id ) const = 0;
virtual QString name( int id ) const = 0;
/** Extended description of the tool, as it will be displayed in the GUI. */
virtual QString description( int id ) const = 0;
virtual QString description( int id ) const = 0;
/** List of all data types that can be processed by the tool. */
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;
virtual void acceptedDataTypes( int id, QVector<QString> &types ) const = 0;
/** Recover parameters describing options of the current tool. */
virtual void declareParameters( int id, UIParamSet &params ) = 0;
/** Function called when the value of a parameter has changed. */
virtual void onUpdatingParameter( UIParam *p ) {}
/** Specify the number of progress bar to show. If 0, no progress bar is shown */
virtual unsigned int needProgressBars( int id ) const { return 0; }
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
* cell in the vector returned by acceptedDataType().
*/
virtual bool exec( int id, UIToolDataSet &dataSet, UIParamSet &params, UIContext &context ) = 0;
virtual bool exec( int id, UIToolDataSet &dataSet, UIParamSet &params, UIContext &context ) = 0;
/** Function called when a ToolParamAction that has been added to the set of parameters
* is clicked. The actId then corresponds to the id of the ToolParamAction object, and
* makes it possible to determine which action has been triggered.
*/
virtual bool execAction( int id, const QString &actId, UIToolDataSet &dataSet, UIParamSet &params, UIContext &context ) { return true; }
virtual bool execAction( int id, const QString &actId, UIToolDataSet &dataSet, UIParamSet &params, UIContext &context ) { return true; }
inline void logMsg( const QString& msg ) {}
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 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 ); }
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 );
void notifyProgressBar( unsigned int n, const QString& label, int maxValue );
void notifyProgressValue( unsigned int n, int value );
public slots:
inline void updateParameter( UIParam* p ) { onUpdatingParameter(p); }
};
......
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