WQtNavGLWidget.h 3.48 KB
Newer Older
1 2
//---------------------------------------------------------------------------
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5 6
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
7
//
wiebel's avatar
wiebel committed
8
// This file is part of OpenWalnut.
9
//
wiebel's avatar
wiebel committed
10
// OpenWalnut is free software: you can redistribute it and/or modify
11 12 13 14
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
wiebel's avatar
wiebel committed
15
// OpenWalnut is distributed in the hope that it will be useful,
16 17 18 19 20
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
wiebel's avatar
wiebel committed
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 23 24
//
//---------------------------------------------------------------------------

25 26
#ifndef WQTNAVGLWIDGET_H
#define WQTNAVGLWIDGET_H
27

28
#include <string>
29

30
#include <QtGui/QDockWidget>
31
#include <QtGui/QSlider>
32

33
#include "../../common/WPropertyVariable.h"
34
#include "../../graphicsEngine/WGEGroupNode.h"
35

36
#include "WQtGLWidget.h"
37

38
/**
39
 * container widget to hold as GL widget and a slider
40
 */
41
class WQtNavGLWidget : public QDockWidget
42
{
43
    Q_OBJECT
ebaum's avatar
ebaum committed
44

45
public:
46
    /**
47
     * default constructor
48
     *
49 50 51 52
     * \param title Title will be displayed above the widget
     * \param parent The widget that manages this widget
     * \param maxValue Maximum value for the corresponding nav slice slider
     * \param sliderTitle Name of the slider corresponding to the property it manipulates
ebaum's avatar
ebaum committed
53
     */
Sebastian Eichelbaum's avatar
[STYLE]  
Sebastian Eichelbaum committed
54
    explicit WQtNavGLWidget( QString title, QWidget* parent, int maxValue = 100, std::string sliderTitle="pos" );
ebaum's avatar
ebaum committed
55

56
    /**
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
57
     * destructor.
58
     */
59
    virtual ~WQtNavGLWidget();
60

61
    /**
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
62 63
     * Gets the contained GL widget instance.
     *
64 65
     * \return pointer to GL widget
     */
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
66
    boost::shared_ptr< WQtGLWidget > getGLWidget();
ebaum's avatar
ebaum committed
67

68
    /**
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
69
     * Set the title of the slider used in this nav widget
70
     *
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
71
     * \param title the title
ebaum's avatar
ebaum committed
72
     */
73
    void setSliderTitle( std::string title );
ebaum's avatar
ebaum committed
74

75 76 77 78 79 80 81
    /**
     * Sets the property to control by the slider.
     *
     * \param prop the property
     */
    void setSliderProperty( WPropInt prop );

82
protected:
83 84 85 86 87 88 89 90

    /**
     * Event handler for close events.
     *
     * \param event the event description.
     */
    virtual void closeEvent( QCloseEvent* event );

91
private:
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
92

93 94 95 96 97
    /**
     * The property which is controlled by the slider
     */
    WPropInt m_sliderProp;

Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
98 99 100
    /**
     * The slider's title.
     */
101
    QString m_sliderTitle;
102

103 104
    QSlider *m_slider; //!< A pointer to the slider widget.

105 106 107
    /**
     * My GL widget.
     */
108
    boost::shared_ptr<WQtGLWidget> m_glWidget;
109

110 111 112 113 114
    /**
     * the scene which is displayed by the GL widget
     */
    osg::ref_ptr< WGEGroupNode > m_scene;

115 116 117 118 119
    /**
     * Update slider if property changed.
     */
    void handleChangedPropertyValue();

120
private slots:
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
121 122 123 124 125 126

    /**
     * Slot getting called whenever the slider gets moved.
     *
     * \param value the new value of the slider.
     */
127
    void sliderValueChanged( int value );
128 129

signals:
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
130 131 132 133 134 135 136

    /**
     * Signals a value change event inside the slider.
     *
     * \param name name of the slider.
     * \param value value of the slider.
     */
137
    void navSliderValueChanged( QString name, int value );
138
};
139

140
#endif  // WQTNAVGLWIDGET_H