WQtNavGLWidget.h 3.58 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 <map>
29
#include <string>
30

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

34
#include "../../common/WPropertyVariable.h"
35
#include "../../graphicsEngine/WGEGroupNode.h"
36
#include "controlPanel/WPropertyIntWidget.h"
37

38
#include "WQtGLWidget.h"
39

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

47
public:
48
    /**
49
     * default constructor
50
     *
51 52 53
     * \param title Title will be displayed above the widget
     * \param parent The widget that manages this widget
     * \param sliderTitle Name of the slider corresponding to the property it manipulates
54
     * \param shareWidget this widget will share OpenGL display lists and texture objects with shareWidget
ebaum's avatar
ebaum committed
55
     */
56
    explicit WQtNavGLWidget( QString title, QWidget* parent, std::string sliderTitle="pos", const QGLWidget * shareWidget = 0 );
ebaum's avatar
ebaum committed
57

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

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

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

77 78 79 80 81
    /**
     * Sets the property to control by the slider.
     *
     * \param prop the property
     */
82 83 84 85 86 87 88 89
    void setSliderProperty( boost::shared_ptr< WPropertyBase > prop );

    /**
     * Remove the property to control by the slider.
     *
     * \param prop the property
     */
    void removeSliderProperty( boost::shared_ptr< WPropertyBase > prop );
90

91
protected:
92 93 94 95 96 97 98 99 100

private slots:
    /**
     * If the dock widget changes its visibility.
     *
     * \param visible if true, the dock is visible
     */
    void handleVisibilityChange( bool visible );

101
private:
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
102 103 104 105

    /**
     * The slider's title.
     */
106
    QString m_sliderTitle;
107

108 109 110
    /**
     * My GL widget.
     */
111
    boost::shared_ptr<WQtGLWidget> m_glWidget;
112

113 114 115 116 117
    /**
     * the scene which is displayed by the GL widget
     */
    osg::ref_ptr< WGEGroupNode > m_scene;

118 119 120 121 122
    /**
     * Update slider if property changed.
     */
    void handleChangedPropertyValue();

Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
123
    /**
124
     * Layout of this widget.
Sebastian Eichelbaum's avatar
[DOC]  
Sebastian Eichelbaum committed
125
     */
126
    QVBoxLayout* m_layout;
127 128 129 130 131 132

    /**
     * Map holding the widgets for module properties added automatically. So they can be removed again automatically
     * if the module is removed.
     */
    std::map< boost::shared_ptr< WPropertyBase >, WPropertyIntWidget* > propertyWidgetMap;
133
};
134

135
#endif  // WQTNAVGLWIDGET_H