Commit 09fcbd42 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents 59b337a6 1c74dc86
......@@ -40,44 +40,49 @@ WProperties::~WProperties()
{
}
boost::signals2::signal1< void, std::string >* WProperties::addBool( std::string name, bool value, std::string shortDesc, std::string longDesc )
boost::signals2::signal1< void, std::string >* WProperties::addBool( std::string name, bool value, bool hidden,
std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
}
boost::signals2::signal1< void, std::string >* WProperties::addChar( std::string name, char value, std::string shortDesc, std::string longDesc )
boost::signals2::signal1< void, std::string >* WProperties::addChar( std::string name, char value, bool hidden,
std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
}
boost::signals2::signal1< void, std::string >* WProperties::addInt( std::string name, int value, std::string shortDesc, std::string longDesc )
boost::signals2::signal1< void, std::string >* WProperties::addInt( std::string name, int value, bool hidden,
std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
}
boost::signals2::signal1< void, std::string >* WProperties::addFloat( std::string name, float value, std::string shortDesc, std::string longDesc )
boost::signals2::signal1< void, std::string >* WProperties::addFloat( std::string name, float value, bool hidden,
std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
}
boost::signals2::signal1< void, std::string >* WProperties::addDouble( std::string name, double value, std::string shortDesc, std::string longDesc )
boost::signals2::signal1< void, std::string >* WProperties::addDouble( std::string name, double value, bool hidden,
std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
......@@ -85,17 +90,18 @@ boost::signals2::signal1< void, std::string >* WProperties::addDouble( std::stri
boost::signals2::signal1< void, std::string >*
WProperties::addString( std::string name, std::string value, std::string shortDesc, std::string longDesc )
WProperties::addString( std::string name, std::string value, bool hidden, std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
}
boost::signals2::signal1< void, std::string >* WProperties::addColor( std::string name, WColor value, std::string shortDesc, std::string longDesc )
boost::signals2::signal1< void, std::string >* WProperties::addColor( std::string name, WColor value, bool hidden,
std::string shortDesc, std::string longDesc )
{
WProperty* prop = new WProperty( name, value, shortDesc, longDesc );
WProperty* prop = new WProperty( name, value, hidden, shortDesc, longDesc );
m_propertyList[name] = prop;
m_propertyVector.push_back( prop );
return prop->getSignalValueChanged();
......
......@@ -68,19 +68,19 @@ public:
std::vector< WProperty* >& getPropertyVector();
boost::signals2::signal1< void, std::string >*
addBool( std::string name, bool value = false, std::string shortDesc = "", std::string longDesc = "" );
addBool( std::string name, bool value = false, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signals2::signal1< void, std::string >*
addChar( std::string name, char value = 0, std::string shortDesc = "", std::string longDesc = "" );
addChar( std::string name, char value = 0, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signals2::signal1< void, std::string >*
addInt( std::string name, int value = 0, std::string shortDesc = "", std::string longDesc = "" );
addInt( std::string name, int value = 0, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signals2::signal1< void, std::string >*
addFloat( std::string name, float value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
addFloat( std::string name, float value = 0.0, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signals2::signal1< void, std::string >*
addDouble( std::string name, double value = 0.0, std::string shortDesc = "", std::string longDesc = "" );
addDouble( std::string name, double value = 0.0, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signals2::signal1< void, std::string >*
addString( std::string name, std::string value = "", std::string shortDesc = "", std::string longDesc = "" );
addString( std::string name, std::string value = "", bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
boost::signals2::signal1< void, std::string >*
addColor( std::string name, WColor value, std::string shortDesc = "", std::string longDesc = "" );
addColor( std::string name, WColor value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
std::string getValueString( const std::string prop );
......
......@@ -26,80 +26,80 @@
#include "WProperty.h"
WProperty::WProperty( std::string name, std::string value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, std::string value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_STRING ),
m_name( name ),
m_value( value ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
}
WProperty::WProperty( std::string name, bool value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, bool value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_BOOL ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
setValue( value );
}
WProperty::WProperty( std::string name, char value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, char value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_CHAR ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
setMin( -128 );
setMax( 127 );
setValue( value );
}
WProperty::WProperty( std::string name, int value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, int value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_INT ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
setMin( 0 );
setMax( 255 );
setValue( value );
}
WProperty::WProperty( std::string name, float value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, float value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_FLOAT ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
setMin( 0.0 );
setMax( 100.0 );
setValue( value );
}
WProperty::WProperty( std::string name, double value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, double value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_DOUBLE ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
setMin( 0.0 );
setMax( 100.0 );
setValue( value );
}
WProperty::WProperty( std::string name, WColor value, std::string shortDesc, std::string longDesc )
WProperty::WProperty( std::string name, WColor value, bool hidden, std::string shortDesc, std::string longDesc )
: m_type( P_DOUBLE ),
m_name( name ),
m_shortDesc( shortDesc ),
m_longDesc( longDesc ),
m_isHidden( false )
m_isHidden( hidden )
{
setValue( value );
}
......
......@@ -56,13 +56,13 @@ public:
/**
* constructors
*/
WProperty( std::string name, std::string value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, bool value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, char value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, int value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, float value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, double value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, WColor value, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, std::string value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, bool value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, char value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, int value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, float value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, double value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
WProperty( std::string name, WColor value, bool hidden = false, std::string shortDesc = "", std::string longDesc = "" );
/**
* destructor
......
......@@ -56,7 +56,7 @@ public:
/**
* Constructor.
*
*
* \param argc number of arguments given on command line.
* \param argv arguments given on command line.
*/
......@@ -67,9 +67,9 @@ public:
*/
virtual ~WGUI();
/**
/**
* Returns the init flag.
*
*
* \return Reference to the flag.
*/
virtual const WFlag< bool >& isInitialized() const;
......@@ -83,7 +83,7 @@ public:
/**
* Slot gets called whenever a new module is added.
*
*
* \param module
*/
virtual void slotAddDatasetToBrowser( boost::shared_ptr< WModule > module );
......@@ -93,6 +93,14 @@ public:
*/
virtual void addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId ) = 0;
/**
* adds a module to the dataset browser
*
* \param module
*/
virtual void addModuleToBrowser( boost::shared_ptr< WModule > module ) = 0;
/**
* returns a vector of pointers to the loaded datasets for a given subject
*/
......
......@@ -172,6 +172,12 @@ void WQt4Gui::addDatasetToBrowser( boost::shared_ptr< WModule > module, int subj
m_gui->getDatasetBrowser()->addDataset( module, subjectId );
}
void WQt4Gui::addModuleToBrowser( boost::shared_ptr< WModule > module )
{
m_gui->getDatasetBrowser()->addModule( module );
}
std::vector< boost::shared_ptr< WModule > >WQt4Gui::getDataSetList( int subjectId )
{
return m_gui->getDatasetBrowser()->getDataSetList( subjectId );
......
......@@ -65,13 +65,21 @@ public:
virtual int run();
/**
* TODO(schurade): write something
* adds a dataset to the dataset browser
*
* \param module
* \param subjectId
*/
void addDatasetToBrowser( boost::shared_ptr< WModule > module, int subjectId );
/**
* adds a module to the dataset browser
*
* \param module
*/
void addModuleToBrowser( boost::shared_ptr< WModule > module );
/**
* returns a vector of pointers to the loaded datasets for a given subject
*/
......
......@@ -34,6 +34,7 @@
#include "WQtDatasetBrowser.h"
#include "WQtNumberEdit.h"
#include "WQtCheckBox.h"
#include "WQtModuleHeaderTreeItem.h"
WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
: QDockWidget( parent )
......@@ -69,6 +70,9 @@ WQtDatasetBrowser::WQtDatasetBrowser( QWidget* parent )
this->setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
this->setWidget( m_panel );
WQtModuleHeaderTreeItem* tiModules = new WQtModuleHeaderTreeItem( m_treeWidget );
tiModules->setText( 0, QString( "Modules" ) );
connectSlots();
}
......@@ -97,23 +101,41 @@ WQtSubjectTreeItem* WQtDatasetBrowser::addSubject( std::string name )
WQtDatasetTreeItem* WQtDatasetBrowser::addDataset( boost::shared_ptr< WModule > module, int subjectId )
{
WQtSubjectTreeItem* subject = ( WQtSubjectTreeItem* )m_treeWidget->topLevelItem( subjectId );
WQtSubjectTreeItem* subject = ( WQtSubjectTreeItem* )m_treeWidget->topLevelItem( subjectId + 1 );
subject->setExpanded( true );
emit dataSetBrowserEvent( QString( "textureChanged" ), true );
emit dataSetBrowserEvent( QString( "dataSetAdded" ), true );
return subject->addDatasetItem( module );
}
WQtModuleTreeItem* WQtDatasetBrowser::addModule( boost::shared_ptr< WModule > module )
{
WQtModuleHeaderTreeItem* tiModules = ( WQtModuleHeaderTreeItem* )m_treeWidget->topLevelItem( 0 );
tiModules->setExpanded( true );
return tiModules->addModuleItem( module );
}
void WQtDatasetBrowser::selectTreeItem()
{
// TODO(schurade): qt doc says clear() doesn't delete tabs so this is possibly a memory leak
m_tabWidget->clear();
if ( m_treeWidget->selectedItems().size() == 0 || m_treeWidget->selectedItems().at( 0 )->type() != 1 )
if ( m_treeWidget->selectedItems().size() == 0 || m_treeWidget->selectedItems().at( 0 )->type() == 0 ||
m_treeWidget->selectedItems().at( 0 )->type() == 2 )
{
return;
}
boost::shared_ptr< WModule >module =( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
boost::shared_ptr< WModule >module;
if ( m_treeWidget->selectedItems().at( 0 )->type() == 1 )
{
module = ( ( WQtDatasetTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
}
else
{
module = ( ( WQtModuleTreeItem* ) m_treeWidget->selectedItems().at( 0 ) )->getModule();
}
std::vector < WProperty* >props = module->getProperties()->getPropertyVector();
WQtDSBWidget* tab1 = new WQtDSBWidget( "settings" );
......@@ -227,12 +249,12 @@ std::vector< boost::shared_ptr< WModule > >WQtDatasetBrowser::getDataSetList( in
{
return moduleList;
}
int count = m_treeWidget->invisibleRootItem()->child( subjectId )->childCount();
int count = m_treeWidget->invisibleRootItem()->child( subjectId + 1 )->childCount();
for ( int i = 0 ; i < count ; ++i )
{
moduleList.push_back( ( ( WQtDatasetTreeItem* )
m_treeWidget->invisibleRootItem()->child( subjectId )->child( i ) )->getModule() );
m_treeWidget->invisibleRootItem()->child( subjectId + 1 )->child( i ) )->getModule() );
}
return moduleList;
}
......
......@@ -35,6 +35,7 @@
#include "WQtDSBWidget.h"
#include "WQtSubjectTreeItem.h"
#include "WQtModuleTreeItem.h"
#include "WQtTreeWidget.h"
/**
......@@ -74,6 +75,8 @@ public:
*/
WQtDatasetTreeItem* addDataset( boost::shared_ptr< WModule > module, int subjectId = 0 );
WQtModuleTreeItem* addModule( boost::shared_ptr< WModule > module );
/**
* returns a vector of pointers to the loaded datasets for a given subject
*/
......
......@@ -25,7 +25,7 @@
#include "WQtDatasetTreeItem.h"
WQtDatasetTreeItem::WQtDatasetTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module )
: QTreeWidgetItem( parent, 1 )
: QTreeWidgetItem( parent, 1 ) // initialize with type 1
{
m_module = module;
......
//---------------------------------------------------------------------------
//
// 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 "WQtModuleHeaderTreeItem.h"
WQtModuleHeaderTreeItem::WQtModuleHeaderTreeItem( QTreeWidget * parent ) :
QTreeWidgetItem( parent, 2 )
{
}
WQtModuleHeaderTreeItem::~WQtModuleHeaderTreeItem()
{
}
WQtModuleTreeItem* WQtModuleHeaderTreeItem::addModuleItem( boost::shared_ptr< WModule > module )
{
WQtModuleTreeItem* ds = new WQtModuleTreeItem( this, module );
std::string name = module->getName();
ds->setText( 0, QString( name.c_str() ) );
return ds;
}
//---------------------------------------------------------------------------
//
// 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 WQTMODULEHEADERTREEITEM_H
#define WQTMODULEHEADERTREEITEM_H
#include <string>
#include <QtGui/QTreeWidgetItem>
#include "WQtModuleTreeItem.h"
/**
* TODO(schurade): Document this!
*/
class WQtModuleHeaderTreeItem : public QTreeWidgetItem
{
public:
/**
* TODO(schurade): Document this!
*/
explicit WQtModuleHeaderTreeItem( QTreeWidget * parent );
/**
* TODO(schurade): Document this!
*/
virtual ~WQtModuleHeaderTreeItem();
WQtModuleTreeItem* addModuleItem( boost::shared_ptr< WModule > module );
protected:
private:
};
#endif // WQTMODULEHEADERTREEITEM_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 "WQtModuleTreeItem.h"
WQtModuleTreeItem::WQtModuleTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WModule > module ) :
QTreeWidgetItem( parent, 3 )
{
m_module = module;
if ( module->getProperties()->getValue< bool > ( "active" ) )
{
this->setCheckState( 0, Qt::Checked );
}
else
{
this->setCheckState( 0, Qt::Unchecked );
}
this->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
}
WQtModuleTreeItem::~WQtModuleTreeItem()
{
}
boost::shared_ptr< WModule > WQtModuleTreeItem::getModule()
{
return m_module;
}
//---------------------------------------------------------------------------
//
// 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