AlgorithmSelector.h 3.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 *	(c) LSIIT, UMR CNRS/UdS
 *	Authors: O. Gnevaux, F. Larue.
 *
 *	See licence.txt for additional information.
 */


#ifndef ALGORITHMSELECTOR_H
#define ALGORITHMSELECTOR_H




#include <Interfaces.h>
#include <QtWidgets>
#include <QVector>
#include "UIParam.h"
19
#include "UIContext.h"
20 21 22 23




24
class UIMultiProgressDialog;
25 26 27 28 29 30 31 32 33
namespace Ui {
    class AlgorithmSelector;
}


class AlgorithmSelector : public QWidget
{
    Q_OBJECT

34
public:
35 36 37 38 39 40 41
    struct ToolDescriptor
    {
        ToolInterface   *plugin;
        UIParamSet      *param;
        int             id;
    };

42
private:
43 44 45 46 47 48 49 50
    Ui::AlgorithmSelector	            *m_ui;
    QButtonGroup                        *m_CategoryButtonGroup;

    int                                 m_SelectedCategory;
    ToolDescriptor                      *m_SelectedTool;
    UIParamSet                          *m_SelectedToolParam;
    QString                             m_ActionId;

51
    QMap<QString,ToolDescriptor>        m_ToolsByName;
52 53 54
    QVector< QVector<ToolDescriptor> >  m_ToolsByCategory;
    QVector< int >                      m_LastUsedInCategory;

55 56 57
    UIContext                           m_ToolContext;
    UIMultiProgressDialog               *m_CurrentToolProgress;

58 59 60 61 62

public:
    AlgorithmSelector( QWidget *parent = NULL );
    ~AlgorithmSelector();

63 64 65 66
    void                            populateTools( ToolInterface *tool );
    void                            releaseAllTools();
    void                            finalizeTools();
    inline QString                  currentToolName() const                     { return m_SelectedTool->plugin->name( m_SelectedTool->id ); }
67
    inline int                      currentCategoryId() const                   { return m_SelectedCategory; }
68 69
    inline QList<ToolDescriptor>    allTools() const                            { return m_ToolsByName.values(); }
    inline const ToolDescriptor*    getToolByName( const QString& name ) const  { auto found = m_ToolsByName.find(name); return (found==m_ToolsByName.end())? NULL : &*found; }
70 71

protected:
72
    void	                        changeEvent(QEvent *e);
73 74

private slots:
75 76
    void                            selectCategory( int categoryId );
    void                            selectTool( int n );
77 78
    void                            createProgressBars( int n );
    void                            deleteProgressBars();
79 80

public slots:
81
    void                            selectTool( int categoryId, const QString& toolName );
82 83 84 85 86 87 88
    void                            emitApplySignal();
    void                            emitActionSignal();
    void                            applyCurrentToolOn( const QList<GenericUIData*> &items,
                                                        UIMainWindow *mainwin,
                                                        GLViewer *glviewer,
                                                        UIProject *project );
    inline void                     emitLog( const QString& msg )               { emit logEmitted(msg); }
89 90

signals:
91 92 93
    void                            askItemsToApplyToolOn();
    void                            toolExecutionFinished( bool );
    void                            logEmitted( const QString& msg );
94 95 96 97 98 99
};




#endif // ALGORITHMSELECTOR_H