diff --git a/PluginLib/CMakeLists.txt b/PluginLib/CMakeLists.txt index 8d3969c25765cd6572d29f891abeb0d1f0d240c3..4744e38b9099207774a9eb1f0b34edad83ee8dcf 100644 --- a/PluginLib/CMakeLists.txt +++ b/PluginLib/CMakeLists.txt @@ -44,6 +44,7 @@ set (directories ../common/bsp ../INIFile ../widgets/glWidget + ../publicWidgets/objectSelectionWidget ) # generate dllexport macros on windows diff --git a/publicWidgets/objectSelectionWidget/SelectionObjectMarker.cc b/publicWidgets/objectSelectionWidget/SelectionObjectMarker.cc new file mode 100644 index 0000000000000000000000000000000000000000..98803b0f50e399dde5413009fa78326f06f0403e --- /dev/null +++ b/publicWidgets/objectSelectionWidget/SelectionObjectMarker.cc @@ -0,0 +1,78 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +#include <OpenFlipper/common/Types.hh> +#include <OpenFlipper/common/BaseObjectData.hh> +#include "SelectionObjectMarker.hh" + +//****************************************************************************** + +const ACG::Vec4f disabled_color (0.4,0.4,0.4,1.0); +const ACG::Vec4f selected_color (0.0,1.0,0.0,0.5); + +//****************************************************************************** + +bool SelectionObjectMarker::stencilRefForObject(BaseObjectData * _obj, GLuint & _reference) +{ + if (_obj->flag("vsi_objectId_disabled")) + { + _reference = 1; + return true; + } + else if (_obj->flag("vsi_objectId_selected")) + { + _reference = 2; + return true; + } + + return false; +} + +bool SelectionObjectMarker::blendForStencilRefNumber(GLuint _reference, GLenum & _src, GLenum & _dst, ACG::Vec4f & _color) +{ + switch (_reference) + { + case 1: + _src = GL_ZERO; + _dst = GL_SRC_COLOR; + _color = disabled_color; + return true; + case 2: + _src = GL_SRC_ALPHA; + _dst = GL_ONE_MINUS_SRC_ALPHA; + _color = selected_color; + return true; + default: + return false; + } + return false; +} + diff --git a/publicWidgets/objectSelectionWidget/SelectionObjectMarker.hh b/publicWidgets/objectSelectionWidget/SelectionObjectMarker.hh new file mode 100644 index 0000000000000000000000000000000000000000..4d212f095a18fdd55841f926e39d97410e65e216 --- /dev/null +++ b/publicWidgets/objectSelectionWidget/SelectionObjectMarker.hh @@ -0,0 +1,50 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + + +#ifndef SELECTIONOBJECTMARKER_HH +#define SELECTIONOBJECTMARKER_HH + +#include <OpenFlipper/common/Types.hh> +#include <OpenFlipper/common/ViewObjectMarker.hh> + +/** Object marker to visualize objectPickDialog selection +*/ +class SelectionObjectMarker : public ViewObjectMarker +{ + public: + + bool stencilRefForObject (BaseObjectData *_obj, GLuint &_reference); + + bool blendForStencilRefNumber (GLuint _reference, GLenum &_src, GLenum &_dst, ACG::Vec4f &_color); +}; + +#endif diff --git a/publicWidgets/objectSelectionWidget/TreeItemObjectSelection.cc b/publicWidgets/objectSelectionWidget/TreeItemObjectSelection.cc new file mode 100644 index 0000000000000000000000000000000000000000..1d5095f5cad216cd33046e3209fac8dfc61e5f05 --- /dev/null +++ b/publicWidgets/objectSelectionWidget/TreeItemObjectSelection.cc @@ -0,0 +1,279 @@ + + +#include "TreeItemObjectSelection.hh" + +//-------------------------------------------------------------------------------- + +TreeItemObjectSelection::TreeItemObjectSelection(int _id, QString _name, DataType _type, TreeItemObjectSelection* _parent) : + id_(_id), + dataType_(_type), + name_(_name), + parentItem_(_parent) +{ +} + + +// =============================================================================== +// Static Members +// =============================================================================== + +int TreeItemObjectSelection::id() { + return id_; +} + +//-------------------------------------------------------------------------------- + +bool TreeItemObjectSelection::dataType(DataType _type) { + if ( _type == DATA_ALL ) { + return true; + } + + return ( dataType_ & _type); +} + +//-------------------------------------------------------------------------------- + +DataType TreeItemObjectSelection::dataType() { + return dataType_; +} + +//-------------------------------------------------------------------------------- + +int TreeItemObjectSelection::group() { + // Skip root node + if ( parent() == 0 ) + return -1; + + // Dont count root node as a group + if ( parent()->parent() == 0 ) + return -1; + + // Only consider groups + if ( !parent()->dataType(DATA_GROUP) ) + return -1; + + // Get the group id + return ( parent()->id() ); +} + +//-------------------------------------------------------------------------------- + +bool TreeItemObjectSelection::isGroup() { + return ( dataType(DATA_GROUP) ); +} + +// =============================================================================== +// Dynamic Members +// =============================================================================== + +bool TreeItemObjectSelection::visible() { + return visible_; +} + +//-------------------------------------------------------------------------------- + +void TreeItemObjectSelection::visible(bool _visible) { + visible_ = _visible; +} + +//-------------------------------------------------------------------------------- + +QString TreeItemObjectSelection::name() { + return name_; +} + +//-------------------------------------------------------------------------------- + +void TreeItemObjectSelection::name(QString _name ) { + name_ = _name; +} + +// =============================================================================== +// Tree Structure +// =============================================================================== + +TreeItemObjectSelection* TreeItemObjectSelection::next() { + // Visit child item of this node + if ( childItems_.size() > 0 ) { + return childItems_[0]; + } + + // No Child Item so visit the next child of the parentItem_ + if ( parentItem_ ) { + + TreeItemObjectSelection* parentPointer = parentItem_; + TreeItemObjectSelection* thisPointer = this; + + // while we are not at the root node + while ( parentPointer ) { + + // If there is an unvisited child of the parent, return this one + if ( parentPointer->childCount() > ( thisPointer->row() + 1) ) { + return parentPointer->childItems_[ thisPointer->row() + 1 ]; + } + + // Go to the next level + thisPointer = parentPointer; + parentPointer = parentPointer->parentItem_; + + } + + return thisPointer; + } + + return this; + +} + +//-------------------------------------------------------------------------------- + +int TreeItemObjectSelection::level() { + int level = 0; + TreeItemObjectSelection* current = this; + + // Go up and count the levels to the root node + while ( current->parent() != 0 ) { + level++; + current = current->parent(); + } + + return level; +} + +//-------------------------------------------------------------------------------- + +int TreeItemObjectSelection::row() const +{ + if (parentItem_) + return parentItem_->childItems_.indexOf(const_cast<TreeItemObjectSelection*>(this)); + + return 0; +} + +//-------------------------------------------------------------------------------- + +TreeItemObjectSelection* TreeItemObjectSelection::parent() +{ + return parentItem_; +} + +//-------------------------------------------------------------------------------- + +void TreeItemObjectSelection::setParent(TreeItemObjectSelection* _parent) { + parentItem_ = _parent; +} + +//-------------------------------------------------------------------------------- + +void TreeItemObjectSelection::appendChild(TreeItemObjectSelection *item) +{ + childItems_.append(item); +} + +//-------------------------------------------------------------------------------- + +TreeItemObjectSelection *TreeItemObjectSelection::child(int row) +{ + return childItems_.value(row); +} + +//-------------------------------------------------------------------------------- + +int TreeItemObjectSelection::childCount() const +{ + return childItems_.count(); +} + +//-------------------------------------------------------------------------------- + +TreeItemObjectSelection* TreeItemObjectSelection::childExists(int _objectId) { + + // Check if this object has the requested id + if ( id_ == _objectId ) + return this; + + // search in children + for ( int i = 0 ; i < childItems_.size(); ++i ) { + TreeItemObjectSelection* tmp = childItems_[i]->childExists(_objectId); + if ( tmp != 0) + return tmp; + } + + return 0; +} + +//-------------------------------------------------------------------------------- + +TreeItemObjectSelection* TreeItemObjectSelection::childExists(QString _name) { + + // Check if this object has the requested id + if ( name() == _name ) + return this; + + // search in children + for ( int i = 0 ; i < childItems_.size(); ++i ) { + TreeItemObjectSelection* tmp = childItems_[i]->childExists(_name); + if ( tmp != 0) + return tmp; + } + + return 0; +} + +//-------------------------------------------------------------------------------- + +void TreeItemObjectSelection::removeChild( TreeItemObjectSelection* _item ) { + + bool found = false; + QList<TreeItemObjectSelection*>::iterator i; + for (i = childItems_.begin(); i != childItems_.end(); ++i) { + if ( *i == _item ) { + found = true; + break; + } + } + + if ( !found ) { + std::cerr << "TreeItemObjectSelection: Illegal remove request" << std::endl; + return; + } + + childItems_.erase(i); +} + +//-------------------------------------------------------------------------------- + +QList< TreeItemObjectSelection* > TreeItemObjectSelection::getLeafs() { + + QList< TreeItemObjectSelection* > items; + + for ( int i = 0 ; i < childItems_.size(); ++i ) { + items = items + childItems_[i]->getLeafs(); + } + + // If we are a leave... + if ( childCount() == 0 ) + items.push_back(this); + + return items; +} + +//-------------------------------------------------------------------------------- + +void TreeItemObjectSelection::deleteSubtree() { + + // call function for all children of this node + for ( int i = 0 ; i < childItems_.size(); ++i) { + + // remove the subtree recursively + childItems_[i]->deleteSubtree(); + + // delete child + delete childItems_[i]; + } + + // clear the array + childItems_.clear(); +} + +//============================================================================= diff --git a/publicWidgets/objectSelectionWidget/TreeItemObjectSelection.hh b/publicWidgets/objectSelectionWidget/TreeItemObjectSelection.hh new file mode 100644 index 0000000000000000000000000000000000000000..ca79ae4b25ffd40a306ba164b034591ad074796f --- /dev/null +++ b/publicWidgets/objectSelectionWidget/TreeItemObjectSelection.hh @@ -0,0 +1,117 @@ +#ifndef TREEITEM_HH +#define TREEITEM_HH + +#include <QString> +#include <QList> +#include <vector> + +#include <OpenFlipper/common/Types.hh> + +class TreeItemObjectSelection { + + public : + + TreeItemObjectSelection(int _id, QString _name, DataType _type, TreeItemObjectSelection* _parent); + + // static members + public: + /// id + int id(); + + /// dataType + DataType dataType(); + bool dataType(DataType _type); + + /// group + int group(); + bool isGroup(); + + private: + int id_; + DataType dataType_; + + // dynamic members + public: + + /// visible + bool visible(); + void visible(bool _visible); + + /// name + QString name( ); + void name( QString _name ); + + private: + bool visible_; + QString name_; + + // tree traversal + public: + + /** Get the next item of the tree (Preorder traversal of the tree) + */ + TreeItemObjectSelection* next(); + + /** level of the current object ( root node has level 0) + */ + int level(); + + private: + /// Parent item or 0 if rootnode + TreeItemObjectSelection *parentItem_; + + /// Children of this node + QList<TreeItemObjectSelection*> childItems_; + + public: + //=========================================================================== + /** @name Tree : Parent nodes + * @{ */ + //=========================================================================== + + /// get the row of this item from the parent + int row() const; + + /// Get the parent item ( 0 if rootitem ) + TreeItemObjectSelection *parent(); + + /// Set the parent pointer + void setParent(TreeItemObjectSelection* _parent); + + /** @} */ + + //=========================================================================== + /** @name Tree : Children + * @{ */ + //=========================================================================== + + /// Check if the element exists in the subtree of this element + TreeItemObjectSelection* childExists(int _objectId); + + /// Check if the element exists in the subtree of this element + TreeItemObjectSelection* childExists(QString _name); + + /// add a child to this node + void appendChild(TreeItemObjectSelection *child); + + /// return a child + TreeItemObjectSelection *child(int row); + + /// get the number of children + int childCount() const; + + /// Remove a child from this object + void removeChild( TreeItemObjectSelection* _item ); + + /// get all leafes of the tree below this object ( These will be all visible objects ) + QList< TreeItemObjectSelection* > getLeafs(); + + /// delete the whole subtree below this item ( The item itself is not touched ) + void deleteSubtree(); + +}; + + +//============================================================================= +#endif // TREEITEM_HH defined +//============================================================================= diff --git a/publicWidgets/objectSelectionWidget/TreeModelObjectSelection.cc b/publicWidgets/objectSelectionWidget/TreeModelObjectSelection.cc new file mode 100644 index 0000000000000000000000000000000000000000..8a2f4490ea9461b699a40e6ef070111b1e532975 --- /dev/null +++ b/publicWidgets/objectSelectionWidget/TreeModelObjectSelection.cc @@ -0,0 +1,596 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +#include <QtGui> +#include <QBrush> + +#include "TreeModelObjectSelection.hh" + +#include <iostream> + + +#include <OpenFlipper/common/Types.hh> +#include "../OpenFlipper/BasePlugin/PluginFunctions.hh" + + +//****************************************************************************** + +/** \brief Constructor + * + * @param _parent parent Object + */ +TreeModelObjectSelection::TreeModelObjectSelection( QObject *_parent) : QAbstractItemModel(_parent) +{ + rootItem_ = new TreeItemObjectSelection( -1, "ROOT", DATA_UNKNOWN, 0); +} + + +//****************************************************************************** + +/** \brief Destructor + * + */ +TreeModelObjectSelection::~TreeModelObjectSelection() +{ + +} + + +//****************************************************************************** + +/** \brief Return the number of columns + * + * @param unused + * @return return always 2 + */ +int TreeModelObjectSelection::columnCount(const QModelIndex &/*_parent*/) const +{ + // Id, Name -> 2 + return (2); +} + + +//****************************************************************************** + +/** \brief Returns the data stored under the given role for the item referred to by the index + * + * @param index a ModelIndex that defines the item in the tree + * @param role defines the kind of data requested + * @return requested data + */ +QVariant TreeModelObjectSelection::data(const QModelIndex &index, int role) const +{ + + // Skip invalid requests + if (!index.isValid()) + return QVariant(); + + // Get the corresponding tree item + TreeItemObjectSelection *item = static_cast<TreeItemObjectSelection*>(index.internalPointer()); + + if ( item == rootItem_ ) { + std::cerr << "Root" << std::endl; + } + + // Set the background color of the objects row + if ( role == Qt::BackgroundRole ) { + if ( !item->visible() ) { + return QVariant (QBrush (QColor (192, 192, 192))); + } + } + + if (role == Qt::DisplayRole) + { + switch (index.column ()) + { + case 0: + return QVariant(item->id()); + case 1: + return QVariant(item->name()); + default: + return QVariant (); + } + } + else + return QVariant (); +} + + +//****************************************************************************** + +/** \brief Returns the item flags for the given index + * + * @param index ModelIndex that defines an item in the tree + * @return flags for the given ModelIndex + */ +Qt::ItemFlags TreeModelObjectSelection::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return 0; + + Qt::ItemFlags flags = 0; + + // Show/Source/Target + if ( index.column() == 0 || index.column() == 1 ) + flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; + else + flags = Qt::ItemIsEnabled; + + // Get the corresponding tree item + TreeItemObjectSelection *item = static_cast<TreeItemObjectSelection*>(index.internalPointer()); + + return flags; +} + + +//****************************************************************************** + +/** \brief Returns the data in the header + * + * @param section the column in the header + * @param orientation header orientation (only horizontal handled) + * @param role the role that defines the type of data + * @return the requested data + */ +QVariant TreeModelObjectSelection::headerData(int section, Qt::Orientation orientation, + int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + + if (section == 0) + return QVariant("ID"); + else if (section == 1) + return QVariant("Name"); + else + return QVariant(); + + } + return QVariant(); +} + + +//****************************************************************************** + +/** \brief Returns the index of the item in the model specified by the given row, column and parent index. + * + * @param row the row + * @param column the column + * @param _parent parent item + * @return corresponding ModelIndex + */ +QModelIndex TreeModelObjectSelection::index(int row, int column, const QModelIndex &_parent) const +{ + TreeItemObjectSelection *parentItem; + + if (!_parent.isValid()) + parentItem = rootItem_; + else + parentItem = static_cast<TreeItemObjectSelection*>(_parent.internalPointer()); + + TreeItemObjectSelection *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); +} + + +//****************************************************************************** + +/** \brief Return index of parent item + * + * @param index a ModelIndex + * @return parent of the given ModelIndex + */ +QModelIndex TreeModelObjectSelection::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + TreeItemObjectSelection *childItem = static_cast<TreeItemObjectSelection*>(index.internalPointer()); + TreeItemObjectSelection *parentItem = childItem->parent(); + + if (parentItem == rootItem_) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); +} + + +//****************************************************************************** + +/** \brief Returns the number of rows under given parent + * + * @param _parent parent Item + * @return number of rows that are children of given parent + */ +int TreeModelObjectSelection::rowCount(const QModelIndex &_parent) const +{ + TreeItemObjectSelection *parentItem; + if (_parent.column() > 0) + return 0; + + if (!_parent.isValid()) + parentItem = rootItem_; + else + parentItem = static_cast<TreeItemObjectSelection*>(_parent.internalPointer()); + + return parentItem->childCount(); +} + + +//****************************************************************************** + +/** \brief The object with the given id has been changed. Update the model. + * + * @param _id id of an object + */ +void TreeModelObjectSelection::objectChanged(int _id) { + + if ( _id != -1 ){ + + BaseObject* obj = 0; + PluginFunctions::getObject(_id, obj); + + TreeItemObjectSelection* item = rootItem_->childExists(_id); + + //if internal and external representation are both valid + if (obj != 0 && item != 0){ + //update the name + if ( obj->name() != item->name() ){ + + item->name( obj->name() ); + + QModelIndex index = getModelIndex(item,0); + if ( index.isValid() ) + emit dataChanged( index, index); + } + + //update visibility + if ( obj->visible() != item->visible() || obj->isGroup() ){ + + item->visible( obj->visible() ); + + QModelIndex index0 = getModelIndex(item,0); + QModelIndex index1 = getModelIndex(item,3); + + if ( index0.isValid() && index1.isValid() ){ + //the whole row has to be updated because of the grey background-color + emit dataChanged( index0, index1); + propagateUpwards(item->parent(), 1, obj->visible() ); + } + + if ( obj->isGroup() ) + propagateDownwards(item, 1 ); + } + + //update parent + if ( obj->parent() == PluginFunctions::objectRoot() && isRoot( item->parent() ) ){ + return; + }else if ( obj->parent() == PluginFunctions::objectRoot() && !isRoot( item->parent() ) ){ + moveItem(item, rootItem_ ); + }else if ( obj->parent()->id() != item->parent()->id() ){ + TreeItemObjectSelection* parent = rootItem_->childExists( obj->parent()->id() ); + + if (parent != 0) + moveItem(item, parent ); + } + } + } +} + + +/** \brief The object with the given id has been added. add it to the internal tree + * + * @param id_ id of the object + */ +void TreeModelObjectSelection::objectAdded(BaseObject* _object){ + + objectAdded (_object, _object->parent()); +} + +/** \brief The object with the given id has been added. add it to the internal tree + * + * @param id_ id of the object + */ +void TreeModelObjectSelection::objectAdded(BaseObject* _object, BaseObject* _parent){ + + if (rootItem_->childExists(_object->id())) + return; + + TreeItemObjectSelection* parent = 0; + //find the parent + if ( _parent == PluginFunctions::objectRoot() ) + parent = rootItem_; + else + parent = rootItem_->childExists( _parent->id() ); + + if (!parent) + { + objectAdded(_parent); + parent = rootItem_->childExists( _parent->id() ); + } + + QModelIndex parentIndex = getModelIndex(parent, 0); + + beginInsertRows(parentIndex, parent->childCount(), parent->childCount()); //insert at the bottom + + TreeItemObjectSelection* item = new TreeItemObjectSelection( _object->id(), _object->name(), _object->dataType(), parent); + + parent->appendChild( item ); + + endInsertRows(); + + objectChanged( _object->id() ); +} + +/** \brief The object with the given id has been deleted. delete it from the internal tree + * + * @param id_ id of the object + */ +void TreeModelObjectSelection::objectDeleted(int _id){ + + TreeItemObjectSelection* item = rootItem_->childExists(_id); + + if ( item != 0 && !isRoot(item) ){ + + QModelIndex itemIndex = getModelIndex(item, 0); + QModelIndex parentIndex = itemIndex.parent(); + + beginRemoveRows( parentIndex, itemIndex.row(), itemIndex.row() ); + + item->parent()->removeChild(item); + item->deleteSubtree(); + + delete item; + + endRemoveRows(); + } +} + +//****************************************************************************** + +/** \brief move the item to a new parent + * + * @param _item the item + * @param _parent new parent + */ +void TreeModelObjectSelection::moveItem(TreeItemObjectSelection* _item, TreeItemObjectSelection* _parent ){ + + QModelIndex itemIndex = getModelIndex(_item, 0); + QModelIndex oldParentIndex = itemIndex.parent(); + QModelIndex newParentIndex = getModelIndex(_parent, 0); + + //delete everything at the old location + beginRemoveRows( oldParentIndex, itemIndex.row(), itemIndex.row() ); + + _item->parent()->removeChild(_item); + + endRemoveRows(); + + //insert it at the new location + beginInsertRows(newParentIndex, _parent->childCount(), _parent->childCount() ); //insert at the bottom + _item->setParent( _parent ); + _parent->appendChild( _item ); + endInsertRows(); + + emit layoutChanged(); +} + +//****************************************************************************** + +/** \brief Return item at given index + * + * @param index a ModelIndex + * @return item at given index + */ +TreeItemObjectSelection* TreeModelObjectSelection::getItem(const QModelIndex &index) const +{ + if (index.isValid()) { + TreeItemObjectSelection *item = static_cast<TreeItemObjectSelection*>(index.internalPointer()); + if (item) return item; + } + return rootItem_; +} + + +//****************************************************************************** + +/** \brief Return item-name at given index + * + * @param index a ModelIndex + * @return name of the item at given index + */ +QString TreeModelObjectSelection::itemName(const QModelIndex &index) const +{ + if (index.isValid()) { + TreeItemObjectSelection *item = static_cast<TreeItemObjectSelection*>(index.internalPointer()); + if (item) + return item->name(); + } + return "not found"; +} + +//****************************************************************************** + +/** \brief Return item-id at given index + * + * @param index a ModelIndex + * @return item-id at given index + */ +int TreeModelObjectSelection::itemId(const QModelIndex &index) const +{ + if (index.isValid()) { + TreeItemObjectSelection *item = static_cast<TreeItemObjectSelection*>(index.internalPointer()); + if (item) + return item->id(); + } + return -1; +} + +//****************************************************************************** + +/** \brief Return index of given item + * + * Warning: Only use this function if you know that all ModelIndices are created + * + * @param _object an object + * @param _column a column + * @return index of object and column + */ +QModelIndex TreeModelObjectSelection::getModelIndex(TreeItemObjectSelection* _object, int _column ){ + + // root item gets an invalid QModelIndex + if ( _object == rootItem_ ) + return QModelIndex(); + + QModelIndex index = createIndex(_object->row(), _column, _object); + + return index; +} + +//****************************************************************************** + +/** \brief Return index of given item + * + * Warning: Only use this function if you know that all ModelIndices are created + * + * @param _id an object id + * @param _column a column + * @return index of object and column + */ +QModelIndex TreeModelObjectSelection::getModelIndex(int _id, int _column ){ + + TreeItemObjectSelection *obj = rootItem_->childExists(_id); + + if (obj) + return getModelIndex (obj, _column); + + return QModelIndex(); +} + + +//****************************************************************************** + +/** \brief Recursively update a column up to the root of the tree + * + * @param _item item to start with + */ +void TreeModelObjectSelection::propagateUpwards(TreeItemObjectSelection* _item, int _column, bool _value ){ + + if ( isRoot(_item) || (!_item->isGroup()) ) + return; + + if (_column == 1){ //visibility + _item->visible( _value ); + + //the whole row has to be updated because of the grey background-color + QModelIndex index0 = getModelIndex(_item,0); + QModelIndex index1 = getModelIndex(_item,3); + + emit dataChanged( index0, index1); + + } else { + + QModelIndex index = getModelIndex(_item,_column); + emit dataChanged(index, index); + } + + propagateUpwards( _item->parent(), _column, _value ); +} + +//****************************************************************************** + +/** \brief Recursively update a column up to the root of the tree + * + * @param _item item to start with + */ +void TreeModelObjectSelection::propagateDownwards(TreeItemObjectSelection* _item, int _column ){ + + for (int i=0; i < _item->childCount(); i++){ + + TreeItemObjectSelection* current = _item->child(i); + + bool changed = false; + + switch ( _column ){ + + case 1: //VISIBILTY + + if ( current->visible() != _item->visible() ){ + + current->visible( _item->visible() ); + changed = true; + } + break; + + default: + break; + } + + if (changed){ + QModelIndex index = getModelIndex(current,_column); + emit dataChanged(index, index); + } + + if ( current->isGroup() ) + propagateDownwards(current, _column); + } +} + +//****************************************************************************** + +/** \brief Set Data at 'index' to 'value' + * + * @param index a ModelIndex defining the positin in the model + * @param value the new value + * @param unused + * @return return if the data was set successfully + */ +bool TreeModelObjectSelection::setData(const QModelIndex &index, const QVariant &value, int /*role*/) +{ + + emit dataChangedInside( itemId(index), index.column(), value ); + + return true; +} + + +//****************************************************************************** + +/** \brief return if an object is equal to the root object + * + * @param _item the item to be checked + * @return is it the root object? + */ +bool TreeModelObjectSelection::isRoot(TreeItemObjectSelection * _item) { + return ( _item == rootItem_ ); +} diff --git a/publicWidgets/objectSelectionWidget/TreeModelObjectSelection.hh b/publicWidgets/objectSelectionWidget/TreeModelObjectSelection.hh new file mode 100644 index 0000000000000000000000000000000000000000..1a55d40406d7a9dce9d7184e498e8142d4d43a80 --- /dev/null +++ b/publicWidgets/objectSelectionWidget/TreeModelObjectSelection.hh @@ -0,0 +1,151 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +#ifndef TREEMODELOBJECTSELECTION_H +#define TREEMODELOBJECTSELECTION_H + +#include <QAbstractItemModel> +#include <QModelIndex> +#include <QVariant> + +#include "TreeItemObjectSelection.hh" + +class TreeModelObjectSelection : public QAbstractItemModel +{ + Q_OBJECT + + signals: + // the connected TreeView changed data + void dataChangedInside(int _id, int _column, const QVariant& _value); + + public: + + /// Constructor + TreeModelObjectSelection(QObject *_parent = 0); + + /// Destructor + ~TreeModelObjectSelection(); + +//=========================================================================== +/** @name inherited from QAbstractItemModel + * @{ */ +//=========================================================================== + +public: + + /// Get the data of the corresponding entry + QVariant data(const QModelIndex &index, int role) const; + + /// return the types of the corresponding entry + Qt::ItemFlags flags(const QModelIndex &index) const; + + /// return the header data of the model + QVariant headerData(int section, + Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + + /// Get the ModelIndex at given row,column + QModelIndex index(int row, int column, + const QModelIndex &parent = QModelIndex()) const; + + /// Get the parent ModelIndex + QModelIndex parent(const QModelIndex &index) const; + + /// get the number of rows + int rowCount(const QModelIndex &parent = QModelIndex()) const; + + /// get the number of columns + int columnCount(const QModelIndex &parent = QModelIndex()) const; + + /// Set the data at the given index + bool setData(const QModelIndex &index, const QVariant &value , int role); + +/** @} */ + +//=========================================================================== +/** @name Internal DataStructure (the TreeItemObjectSelection Tree) + * @{ */ +//=========================================================================== + +public: + + /// Return the ModelIndex corresponding to a given TreeItemObjectSelection and Column + QModelIndex getModelIndex(TreeItemObjectSelection* _object, int _column ); + + /// Return the ModelIndex corresponding to a given object id and Column + QModelIndex getModelIndex(int _id, int _column ); + + /// Check if the given item is the root item + bool isRoot(TreeItemObjectSelection* _item); + + /// Get the name of a given object + bool getObjectName(TreeItemObjectSelection* _object , QString& _name); + + /// Get the TreeItemObjectSelection corresponding to a given ModelIndex + TreeItemObjectSelection *getItem(const QModelIndex &index) const; + + /// Get the name of a TreeItemObjectSelection corresponding to a given ModelIndex + QString itemName(const QModelIndex &index) const; + + /// Get the id of a TreeItemObjectSelection corresponding to a given ModelIndex + int itemId(const QModelIndex &index) const; + + + /// The object with the given id has been changed. Check if model also has to be changed + void objectChanged(int id_); + + /// The object with the given id has been added. add it to the internal tree + void objectAdded(BaseObject* _object); + + /// The object with the given id has been added. add it to the internal tree + void objectAdded(BaseObject* _object, BaseObject* _parent); + + /// The object with the given id has been deleted. delete it from the internal tree + void objectDeleted(int id_); + + /// move the item to a new parent + void moveItem(TreeItemObjectSelection* _item, TreeItemObjectSelection* _parent ); +private: + + /// Rootitem of the tree + TreeItemObjectSelection* rootItem_; + + + void propagateUpwards(TreeItemObjectSelection* _obj, int _column, bool _value ); + void propagateDownwards(TreeItemObjectSelection* _obj, int _column ); + +/** @} */ + + +}; + +#endif + diff --git a/publicWidgets/objectSelectionWidget/objectPickDialog.cc b/publicWidgets/objectSelectionWidget/objectPickDialog.cc new file mode 100644 index 0000000000000000000000000000000000000000..53fe686edfd867f8aafb1467f237d5699f8bebd1 --- /dev/null +++ b/publicWidgets/objectSelectionWidget/objectPickDialog.cc @@ -0,0 +1,235 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +//== INCLUDES ================================================================= +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QPushButton> +#include <QTreeView> +#include <QMouseEvent> + +#include <OpenFlipper/BasePlugin/PluginFunctions.hh> +#include <OpenFlipper/widgets/glWidget/simpleViewer.hh> +#include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> + +#include "objectPickDialog.hh" +#include "TreeModelObjectSelection.hh" +#include "TreeItemObjectSelection.hh" + +//== NAMESPACES =============================================================== + +//============================================================================= +// +// CLASS ObjectPickDialog - IMPLEMENTATION +// +//============================================================================= + +/// Constructor +ObjectPickDialog::ObjectPickDialog(QStringList _flags, QStringList _types, bool _withGroups) : + QDialog (), + selectedId_(0) +{ + QHBoxLayout *hL = new QHBoxLayout; + QHBoxLayout *bL = new QHBoxLayout; + QVBoxLayout *vL = new QVBoxLayout; + + model_ = new TreeModelObjectSelection (); + + treeView_ = new QTreeView; + treeView_->setModel (model_); + treeView_->resizeColumnToContents (0); + treeView_->setSelectionMode (QAbstractItemView::SingleSelection); + treeView_->setSelectionBehavior (QAbstractItemView::SelectRows); + + viewer_ = new SimpleViewer (); + viewer_->properties ().objectMarker (&marker_); + + okButton_ = new QPushButton (tr("OK")); + cancelButton_ = new QPushButton (tr("Cancel")); + + connect (okButton_, SIGNAL (pressed()), this, SLOT (accept())); + connect (cancelButton_, SIGNAL (pressed()), this, SLOT (reject())); + + hL->addWidget (viewer_); + hL->setStretchFactor (viewer_, 1); + hL->addWidget (treeView_); + + bL->addStretch (1); + bL->addWidget (okButton_); + bL->addWidget (cancelButton_); + + vL->addLayout(hL); + vL->addLayout(bL); + + setLayout (vL); + + resize (700, 400); + + setWindowTitle(tr("Click on object or select from list...")); + + connect (treeView_, SIGNAL (activated( const QModelIndex& )), + this, SLOT (activated(const QModelIndex&))); + connect (viewer_->viewer(), SIGNAL (signalMouseEventClick(QMouseEvent*, bool)), + this, SLOT (slotMouseEventClick(QMouseEvent*, bool))); + + for (PluginFunctions::BaseObjectIterator o_it; o_it != PluginFunctions::baseObjectsEnd(); ++o_it) { + + bool ok = true; + + if (!_flags.empty ()) + { + bool found = false; + foreach (QString flag, _flags) + if (o_it->flag (flag)) + { + found = true; + break; + } + + if (!found) + ok = false; + } + + if (!_types.empty ()) + { + if (!_types.contains (typeName (o_it->dataType()))) + ok = false; + } + + if (o_it->isGroup() && !_withGroups) + continue; + + if (ok) + { + if (!_withGroups) + model_->objectAdded(o_it, PluginFunctions::objectRoot()); + else + model_->objectAdded (o_it); + } + } +} + +//------------------------------------------------------------------------------ + +/// Destructor +ObjectPickDialog::~ ObjectPickDialog() +{ + for (PluginFunctions::BaseObjectIterator o_it; o_it != PluginFunctions::baseObjectsEnd(); ++o_it) { + o_it->setFlag("vsi_objectId_selected", false); + } + + delete model_; +} + +//------------------------------------------------------------------------------ + +void ObjectPickDialog::activated(const QModelIndex & _index) +{ + if (_index.isValid()) { + + TreeItemObjectSelection *item = static_cast<TreeItemObjectSelection*>(_index.internalPointer()); + if (item) + { + selectedId (item->id()); + } + } +} + +//------------------------------------------------------------------------------ + +void ObjectPickDialog::slotMouseEventClick(QMouseEvent * _event, bool _double) +{ + unsigned int nodeIdx, targetIdx; + + BaseObjectData *obj; + if (viewer_->viewer()->pick(ACG::SceneGraph::PICK_ANYTHING, _event->pos(), nodeIdx, targetIdx)) + { + if (PluginFunctions::getPickedObject (nodeIdx, obj)) + { + if (!obj->flag ("vsi_objectId_disabled")) + { + selectedId (obj->id()); + } + } + } +} + +//------------------------------------------------------------------------------ + +unsigned int ObjectPickDialog::selectedId() +{ + return selectedId_; +} + +//------------------------------------------------------------------------------ + +void ObjectPickDialog::selectedId(unsigned int _id) +{ + BaseObject *obj = 0, *obj2 = 0; + + if (PluginFunctions::getObject(_id, obj)) + { + if (selectedId_ != _id && PluginFunctions::getObject(selectedId_, obj2)) + { + obj2->setFlag ("vsi_objectId_selected", false); + if (obj2->isGroup()) + setForGroup (obj2, "vsi_objectId_selected", false); + } + obj->setFlag ("vsi_objectId_selected", true); + if (obj->isGroup()) + setForGroup (obj, "vsi_objectId_selected", true); + + selectedId_ = _id; + viewer_->viewer()->updateGL (); + treeView_->setCurrentIndex (model_->getModelIndex(_id, 0)); + } +} + +//------------------------------------------------------------------------------ + +void ObjectPickDialog::setForGroup(BaseObject *_obj, QString _flag, bool _enabled) +{ + for (PluginFunctions::BaseObjectIterator o_it; o_it != PluginFunctions::baseObjectsEnd(); ++o_it) { + if (o_it->id () == _obj->id ()) + continue; + if (o_it->isInGroup (_obj->id ())) + { + o_it->setFlag(_flag, _enabled); + if (o_it->isGroup()) + setForGroup (o_it, _flag, _enabled); + } + } +} + +//------------------------------------------------------------------------------ + + + diff --git a/publicWidgets/objectSelectionWidget/objectPickDialog.hh b/publicWidgets/objectSelectionWidget/objectPickDialog.hh new file mode 100644 index 0000000000000000000000000000000000000000..586c03ff086e7d5ec74497de0bfa2339c9a9fb0b --- /dev/null +++ b/publicWidgets/objectSelectionWidget/objectPickDialog.hh @@ -0,0 +1,98 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +#ifndef VSI_OBJECTPICKDIALOG_HH +#define VSI_OBJECTPICKDIALOG_HH + +//== INCLUDES ================================================================= + +#include <QDialog> +#include <QModelIndex> +#include "SelectionObjectMarker.hh" + +//== FORWARDDECLARATIONS ====================================================== +class QPushButton; +class QTreeView; +class QMouseEvent; + +class TreeModelObjectSelection; + +class SimpleViewer; + +//== NAMESPACES =============================================================== + +//== CLASS DEFINITION ========================================================= + +/** Widget to pick a object + */ + +class ObjectPickDialog : public QDialog { + Q_OBJECT + + public: + /// Constructor + ObjectPickDialog (QStringList _flags, QStringList _types, bool _withGroups); + + /// Destructor + ~ObjectPickDialog (); + + /// Current selected object + unsigned int selectedId (); + + /// Set selected object + void selectedId (unsigned int _id); + + private slots: + void activated (const QModelIndex &_index); + void slotMouseEventClick (QMouseEvent* _event, bool _double); + + private: + void setForGroup (BaseObject *_obj, QString _flag, bool _enabled); + + private: + + SimpleViewer *viewer_; + + QTreeView *treeView_; + QPushButton *okButton_; + QPushButton *cancelButton_; + + TreeModelObjectSelection *model_; + + SelectionObjectMarker marker_; + + unsigned int selectedId_; +}; +//============================================================================= + +//============================================================================= + +#endif diff --git a/publicWidgets/objectSelectionWidget/objectSelectionWidget.cc b/publicWidgets/objectSelectionWidget/objectSelectionWidget.cc new file mode 100644 index 0000000000000000000000000000000000000000..cce9e66857e486aa1b7e0ddab869cce5a02dc2ef --- /dev/null +++ b/publicWidgets/objectSelectionWidget/objectSelectionWidget.cc @@ -0,0 +1,148 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +//== INCLUDES ================================================================= +#include <QHBoxLayout> +#include <QPushButton> +#include <QComboBox> + +#include <OpenFlipper/BasePlugin/PluginFunctions.hh> + +#include "objectSelectionWidget.hh" +#include "objectPickDialog.hh" +#include "TreeModelObjectSelection.hh" + +//== NAMESPACES =============================================================== + +//============================================================================= +// +// CLASS ObjectSelectionWidget - IMPLEMENTATION +// +//============================================================================= + +/// Constructor +ObjectSelectionWidget::ObjectSelectionWidget(QMap< QString, QString > &_hints, QString _typeName, QWidget *_parent) : + QWidget(0), + pickButton_ (0), + combo_ (0) +{ + int n_ok = 0; + + QHBoxLayout *hL = new QHBoxLayout; + + combo_ = new QComboBox (); + pickButton_ = new QPushButton (tr("Pick Object")); + + hL->addWidget (combo_); + hL->setStretchFactor (combo_, 1); + hL->addWidget (pickButton_); + + if (_hints.contains ("flags")) + flags_ = _hints["flags"].split(','); + + if (_hints.contains ("types")) + types_ = _hints["types"].split(','); + + if (flags_.contains("all", Qt::CaseInsensitive)) + flags_.clear (); + + withGroups_ = types_.contains("Group"); + + if (types_.contains("All")) + types_.clear (); + + setLayout (hL); + + connect (pickButton_, SIGNAL (pressed()), this, SLOT (showPickDialog ())); + + for (PluginFunctions::BaseObjectIterator o_it; o_it != PluginFunctions::baseObjectsEnd(); ++o_it) { + + bool ok = true; + + if (!flags_.empty ()) + { + bool found = false; + foreach (QString flag, flags_) + if (o_it->flag (flag)) + { + found = true; + break; + } + + if (!found) + ok = false; + } + + if (!types_.empty ()) + { + if (!types_.contains (typeName (o_it->dataType()))) + ok = false; + } + + if (o_it->isGroup() && !withGroups_) + continue; + + if (ok) + { + combo_->addItem (o_it->name() + " (" + QString::number (o_it->id ()) + ")", QVariant (o_it->id())); + n_ok++; + } + } + + if (n_ok < 2) + { + pickButton_->setEnabled (false); + combo_->setEnabled (false); + } +} + +/// Destructor +ObjectSelectionWidget::~ ObjectSelectionWidget() +{ + for (PluginFunctions::BaseObjectIterator o_it; o_it != PluginFunctions::baseObjectsEnd(); ++o_it) { + o_it->setFlag("vsi_objectId_selected", false); + } +} + +//------------------------------------------------------------------------------ + +void ObjectSelectionWidget::showPickDialog() +{ + ObjectPickDialog d(flags_, types_, withGroups_); + d.selectedId (combo_->itemData (combo_->currentIndex()).toInt ()); + + if (d.exec () == QDialog::Accepted) + combo_->setCurrentIndex (combo_->findData (QVariant (d.selectedId()))); +} + +//------------------------------------------------------------------------------ + + diff --git a/publicWidgets/objectSelectionWidget/objectSelectionWidget.hh b/publicWidgets/objectSelectionWidget/objectSelectionWidget.hh new file mode 100644 index 0000000000000000000000000000000000000000..fde3f2f16de26ccb7cdbd208b0aea9be4588ab21 --- /dev/null +++ b/publicWidgets/objectSelectionWidget/objectSelectionWidget.hh @@ -0,0 +1,77 @@ +//============================================================================= +// +// OpenFlipper +// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen +// www.openflipper.org +// +//----------------------------------------------------------------------------- +// +// License +// +// OpenFlipper 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. +// +// OpenFlipper 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 OpenFlipper. If not, see <http://www.gnu.org/licenses/>. +// +//----------------------------------------------------------------------------- +// +// $Revision: $ +// $Author: $ +// $Date: $ +// +//============================================================================= + +#ifndef OBJECTSELECTIONWIDGET_HH +#define OBJECTSELECTIONWIDGET_HH + +//== INCLUDES ================================================================= +#include <OpenFlipper/common/GlobalDefines.hh> + +#include <QWidget> + +//== FORWARDDECLARATIONS ====================================================== +class QComboBox; +class QPushButton; +class TreeModel; + +//== NAMESPACES =============================================================== + +//== CLASS DEFINITION ========================================================= + +/** Widget to configure object id inputs + */ + +class DLLEXPORT ObjectSelectionWidget : public QWidget { + Q_OBJECT + + public: + /// Constructor + ObjectSelectionWidget (QMap <QString, QString> &_hints, QString _typeName, QWidget *_parent = NULL); + + /// Destructor + ~ObjectSelectionWidget (); + + private slots: + void showPickDialog (); + + private: + QPushButton *pickButton_; + QComboBox *combo_; + + QStringList flags_; + QStringList types_; + bool withGroups_; +}; +//============================================================================= + +//============================================================================= + +#endif