UIParamFunction.h 2.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
/*
 *	(c) LSIIT, UMR CNRS/UdS
 *	Authors: O. Gnevaux, F. Larue.
 *
 *	See licence.txt for additional information.
 */


#ifndef UIPARAMFUNCTION_H
#define UIPARAMFUNCTION_H


13
14


15
16
17
18
19
20
#include "UIParam.h"
#include "FunctionGraphWidget.h"


class UIParamFunction : public UIParam
{
21
    FunctionGraphWidget*    m_FuncWidget;
22
23

public:
24
25
26
27
28
29
30
31
    inline                  UIParamFunction( const QString& id,
                                             const QString& name,
                                             const QString& description );

    inline void             Value( QVector<float> &funcSamples ) const  { m_FuncWidget->getFunction(funcSamples); }

    inline const QWidget*   Widget() const                              { return m_Widget; }
    inline QWidget*         Widget()                                    { return m_Widget; }
32

33
34
35
36
37
38
39
40
41
42
43
44
45
    inline void             ArrangeInLayout( QGridLayout *l, int line );
    inline void             ConnectModificationSignal();
};


inline UIParamFunction::UIParamFunction( const QString& id,
                        const QString& name,
                        const QString& description ) : UIParam(id,name,description)
{
    const int BUTTON_COUNT = 6;

    QGridLayout *l = new QGridLayout();
    l->setSpacing( 2 );
46

47
48
49
50
    m_Widget = new QWidget();
    m_Widget->setLayout( l );
    if( !m_Description.isNull() && !m_Description.isEmpty() )
        m_Widget->setToolTip( m_Description );
51
        
52
53
54
55
56
57
    m_FuncWidget = new FunctionGraphWidget( name );
    l->addWidget( m_FuncWidget, 0,0, 1,BUTTON_COUNT+1 );

    const char *buttonLabels[BUTTON_COUNT] = { "Lin", "Box", "Gauss", "Sigmo", "Pow", "V" };
    QPushButton *buttons[BUTTON_COUNT];
    for( int i=0; i<BUTTON_COUNT; ++i )
58
    {
59
60
61
62
63
        buttons[i] = new QPushButton( buttonLabels[i] );
        int w = QFontMetrics(m_Widget->font()).width(buttons[i]->text()) + 8;
        buttons[i]->setMinimumWidth( w );
        buttons[i]->setMaximumWidth( w );
        l->addWidget( buttons[i], 1,i );
64
    }
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

    QObject::connect( buttons[0], SIGNAL(clicked()), m_FuncWidget, SLOT(setLinear     ()) );
    QObject::connect( buttons[1], SIGNAL(clicked()), m_FuncWidget, SLOT(setBox        ()) );
    QObject::connect( buttons[2], SIGNAL(clicked()), m_FuncWidget, SLOT(setGaussian   ()) );
    QObject::connect( buttons[3], SIGNAL(clicked()), m_FuncWidget, SLOT(setSigmoid    ()) );
    QObject::connect( buttons[4], SIGNAL(clicked()), m_FuncWidget, SLOT(setPower      ()) );
    QObject::connect( buttons[5], SIGNAL(clicked()), m_FuncWidget, SLOT(setGemanMcLure()) );
}

inline void UIParamFunction::ArrangeInLayout( QGridLayout *l, int line )
{
    l->addWidget( m_Widget, line,0, 1,2 );
}

inline void UIParamFunction::ConnectModificationSignal()
{
    QObject::connect( m_FuncWidget, SIGNAL(functionModified()), this, SLOT(triggerParameterUpdate()) );
}


85
86
87


#endif // UIPARAMFUNCTION_H