WQtNavGLWidget.cpp 2.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// 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.
//
// OpenWalnut is distributed in the hope that it will be useful,
// 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
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

25
#include <string>
26
#include <iostream>
27

28 29 30
#include <QtGui/QDockWidget>
#include <QtGui/QSlider>
#include <QtGui/QVBoxLayout>
31
#include <QtGui/QKeyEvent>
32 33 34

#include "WQtNavGLWidget.h"

35 36
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, std::string sliderTitle )
    : QDockWidget( title, parent )
37
{
38
    m_sliderTitle = QString( sliderTitle.c_str() );
39

40 41 42 43 44 45 46 47 48 49
    setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
    setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );

    QSlider *slider = new QSlider( Qt::Horizontal );
    slider->setMaximum( maxValue );
    slider->setValue( maxValue / 2 );
    QWidget* panel = new QWidget( this );

    QVBoxLayout* layout = new QVBoxLayout();

50 51
    m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC ) );
    m_glWidget->initialize();
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

    layout->addWidget( m_glWidget.get() );
    layout->addWidget( slider );

    panel->setLayout( layout );

    setWidget( panel );

    connect( slider, SIGNAL( valueChanged( int ) ), this, SLOT( sliderValueChanged( int ) ) );
}

WQtNavGLWidget::~WQtNavGLWidget()
{
}

67 68 69 70 71 72 73 74
void WQtNavGLWidget::closeEvent( QCloseEvent* event )
{
    // forward events
    m_glWidget->close();

    event->accept();
}

75
void WQtNavGLWidget::setSliderTitle( std::string title )
76
{
77
    m_sliderTitle = QString( title.c_str() );
78 79
}

80
boost::shared_ptr<WQtGLWidget>WQtNavGLWidget::getGLWidget()
81
{
82
    return m_glWidget;
83 84 85 86
}

void WQtNavGLWidget::sliderValueChanged( int value )
{
87
    emit navSliderValueChanged( m_sliderTitle, value );
88 89
}