Commit 06ba3fd0 authored by schurade's avatar schurade

[ADD] first work on dynamic creation of widgets for the dataset browser tab widget

parent 642d9803
......@@ -12,6 +12,9 @@ SET( QT_LIBS ${QT_QTCORE_LIBRARY}
# add here all classes that inherit from QObject
SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WQtDatasetBrowser.h
WQtDSBWidget.h
WQtNumberEdit.h
)
QT4_WRAP_CPP(GUI_QT4_MOC_SRCS ${GUI_QT4_MOC_HDRS} )
......
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "WQtNumberEdit.h"
#include "WQtDSBWidget.h"
WQtDSBWidget::WQtDSBWidget( std::string name, QWidget* parent )
: QWidget( parent ),
m_name( name.c_str() )
{
m_layout = new QGridLayout();
}
WQtDSBWidget::~WQtDSBWidget()
{
}
QPushButton* WQtDSBWidget::addPushButton( std::string label )
{
int row = m_layout->rowCount();
QPushButton* button = new QPushButton();
button->setText( QString( label.c_str() ) );
m_layout->addWidget( button, row, 0 );
setLayout( m_layout );
return button;
}
QCheckBox* WQtDSBWidget::addCheckBox( std::string label, bool isChecked )
{
int row = m_layout->rowCount();
QLabel* qlabel = new QLabel( label.c_str() );
QCheckBox* checkBox = new QCheckBox();
checkBox->setChecked( isChecked );
m_layout->addWidget( qlabel, row, 0 );
m_layout->addWidget( checkBox, row, 1 );
setLayout( m_layout );
return checkBox;
}
QLineEdit* WQtDSBWidget::addLineEdit( std::string label, std::string text )
{
int row = m_layout->rowCount();
QLabel* qlabel = new QLabel( label.c_str() );
QLineEdit* lineEdit = new QLineEdit();
lineEdit->setText( QString( text.c_str() ) );
m_layout->addWidget( qlabel, row, 0 );
m_layout->addWidget( lineEdit, row, 1 );
setLayout( m_layout );
return lineEdit;
}
QSlider* WQtDSBWidget::addSliderInt( std::string label, int value, int min, int max )
{
int row = m_layout->rowCount();
QLabel* qlabel = new QLabel( label.c_str() );
QSlider* slider = new QSlider( Qt::Horizontal );
slider->setMinimum( min );
slider->setMaximum( max );
slider->setValue( value );
WQtNumberEdit* numberEdit = new WQtNumberEdit();
m_layout->addWidget( qlabel, row, 0 );
m_layout->addWidget( slider, row, 1 );
m_layout->addWidget( numberEdit, row+1, 1 );
setLayout( m_layout );
connect( slider, SIGNAL( valueChanged( int ) ), numberEdit, SLOT( setInt( int ) ) );
connect( numberEdit, SIGNAL( signalNumber( int ) ), slider, SLOT( setValue( int ) ) );
return slider;
}
QString WQtDSBWidget::getName()
{
return m_name;
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#ifndef WQTDSBWIDGET_H
#define WQTDSBWIDGET_H
#include <string>
#include <QtGui/QCheckBox>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QSlider>
#include <QtGui/QWidget>
#include <QtGui/QLCDNumber>
/**
* TODO(schurade): Document this!
*/
class WQtDSBWidget : public QWidget
{
Q_OBJECT
public:
/**
* default constructor
*/
explicit WQtDSBWidget( std::string name, QWidget* parent = 0 );
/**
* destructor
*/
virtual ~WQtDSBWidget();
/**
*
*/
QPushButton* addPushButton( std::string label = "button" );
/**
*
*/
QCheckBox* addCheckBox( std::string label = "checkbox:", bool isChecked = false );
/**
*
*/
QLineEdit* addLineEdit( std::string label = "edit text:", std::string text = "" );
/**
*
*/
QSlider* addSliderInt( std::string label = "", int value = 0, int min = 0, int max = 100 );
/**
*
*/
QString getName();
protected:
private:
QGridLayout* m_layout;
QString m_name;
};
#endif // WQTDSBWIDGET_H
......@@ -24,6 +24,10 @@
#include <string>
#include <QtCore/QList>
#include "../../common/WLogger.h"
#include "WQtDatasetBrowser.h"
WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
......@@ -35,16 +39,17 @@ WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
m_treeWidget->setHeaderLabel( QString( "Dataset Browser" ) );
m_tabWidget = new QTabWidget( m_panel );
m_tab1 = new QWidget();
m_tab2 = new QWidget();
m_tab3 = new QWidget();
m_tabWidget->addTab( m_tab1, QString( "tab1" ) );
m_tabWidget->addTab( m_tab2, QString( "tab2" ) );
m_tabWidget->addTab( m_tab3, QString( "tab3" ) );
m_layout = new QVBoxLayout();
WQtDSBWidget* tab1 = new WQtDSBWidget( "settings" );
tab1->addPushButton( "button1" );
tab1->addPushButton( "button2" );
tab1->addCheckBox( "box1:", true );
tab1->addCheckBox( "box2:", false );
tab1->addLineEdit( "text:", "some text" );
tab1->addSliderInt( "slider:" , 50, 0, 100 );
addTabWidgetContent( tab1 );
m_layout->addWidget( m_treeWidget );
m_layout->addWidget( m_tabWidget );
......@@ -53,6 +58,8 @@ WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
this->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setWidget( m_panel );
connectSlots();
}
WQtDatasetBrowser::~WQtDatasetBrowser()
......@@ -60,6 +67,12 @@ WQtDatasetBrowser::~WQtDatasetBrowser()
}
void WQtDatasetBrowser::connectSlots()
{
connect( m_treeWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( selectTreeItem() ) );
}
WQtSubjectTreeItem* WQtDatasetBrowser::addSubject( std::string name )
{
WQtSubjectTreeItem* subject = new WQtSubjectTreeItem( m_treeWidget );
......@@ -74,3 +87,14 @@ WQtDatasetTreeItem* WQtDatasetBrowser::addDataset( int subjectId, std::string na
WQtSubjectTreeItem* subject = ( WQtSubjectTreeItem* )m_treeWidget->topLevelItem( subjectId );
return subject->addDatasetItem( name );
}
void WQtDatasetBrowser::selectTreeItem()
{
WLogger::getLogger()->addLogMessage( "tree item clicked: " );
WLogger::getLogger()->addLogMessage( std::string( m_treeWidget->selectedItems().at( 0 )->text( 0 ).toAscii() ) );
}
void WQtDatasetBrowser::addTabWidgetContent( WQtDSBWidget* content )
{
m_tabWidget->addTab( content, content->getName() );
}
......@@ -33,12 +33,15 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
#include "WQtDSBWidget.h"
#include "WQtSubjectTreeItem.h"
/**
* TODO(schurade): Document this!
*/
class WQtDatasetBrowser : public QDockWidget
{
Q_OBJECT
public:
/**
* Default constructor.
......@@ -54,6 +57,11 @@ public:
*/
virtual ~WQtDatasetBrowser();
/**
*
*/
void addTabWidgetContent( WQtDSBWidget* content );
/**
*
*/
......@@ -64,6 +72,11 @@ public:
*/
WQtDatasetTreeItem* addDataset( int subjectId, std::string name );
/**
*
*/
void connectSlots();
protected:
......@@ -76,6 +89,12 @@ private:
QWidget* m_tab3;
QWidget* m_panel;
QVBoxLayout* m_layout;
private slots:
/**
*
*/
void selectTreeItem();
};
#endif // WQTDATASETBROWSER_H
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#include "WQtNumberEdit.h"
WQtNumberEdit::WQtNumberEdit( QWidget* parent )
: QLineEdit( parent )
{
connect( this, SIGNAL( returnPressed() ), this, SLOT( numberChanged() ) );
}
WQtNumberEdit::~WQtNumberEdit()
{
}
void WQtNumberEdit::setInt( int number )
{
setText( QString::number( number ) );
}
void WQtNumberEdit::numberChanged()
{
bool ok;
int number = text().toInt( &ok, 10 );
if ( ok )
{
emit signalNumber( number );
}
else
{
setText( QString::number( 0 ) );
emit signalNumber( 0 );
}
}
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------
#ifndef WQTNUMBEREDIT_H
#define WQTNUMBEREDIT_H
#include <QtGui/QLineEdit>
/**
* TODO(schurade): Document this!
*/
class WQtNumberEdit : public QLineEdit
{
Q_OBJECT
public:
/**
* default constructor
*/
explicit WQtNumberEdit( QWidget* parent = 0 );
/**
* destructor
*/
virtual ~WQtNumberEdit();
public slots:
void setInt( int number );
void numberChanged();
signals:
void signalNumber( int );
protected:
private:
};
#endif // WQTNUMBEREDIT_H
......@@ -91,8 +91,6 @@ void WNavigationSliceModule::threadMain()
int8_t > >( ds->getValueSet() );
int8_t* source = const_cast< int8_t* > ( vs->rawData() );
std::cout << "hier gehts los" << std::endl;
osg::ref_ptr< osg::Image > ima = new osg::Image;
ima->allocateImage( 160, 200, 160, GL_LUMINANCE, GL_UNSIGNED_BYTE );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment