45 #include <QHBoxLayout> 46 #include <QPushButton> 48 #include <QMouseEvent> 51 #include <OpenFlipper/widgets/glWidget/simpleViewer.hh> 52 #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> 54 #include "objectPickDialog.hh" 55 #include "TreeModel.hh" 71 QHBoxLayout *hL =
new QHBoxLayout;
72 QHBoxLayout *bL =
new QHBoxLayout;
73 QVBoxLayout *vL =
new QVBoxLayout;
77 treeView_ =
new QTreeView;
78 treeView_->setModel (model_);
79 treeView_->resizeColumnToContents (0);
80 treeView_->setSelectionMode (QAbstractItemView::SingleSelection);
81 treeView_->setSelectionBehavior (QAbstractItemView::SelectRows);
86 okButton_ =
new QPushButton (tr(
"OK"));
87 cancelButton_ =
new QPushButton (tr(
"Cancel"));
89 connect (okButton_, SIGNAL (pressed()),
this, SLOT (accept()));
90 connect (cancelButton_, SIGNAL (pressed()),
this, SLOT (reject()));
92 hL->addWidget (viewer_);
93 hL->setStretchFactor (viewer_, 1);
94 hL->addWidget (treeView_);
97 bL->addWidget (okButton_);
98 bL->addWidget (cancelButton_);
107 setWindowTitle(tr(
"Click on object or select from list..."));
109 connect (treeView_, SIGNAL (activated(
const QModelIndex& )),
110 this, SLOT (activated(
const QModelIndex&)));
111 connect (viewer_->
viewer(), SIGNAL (signalMouseEventClick(QMouseEvent*,
bool)),
112 this, SLOT (slotMouseEventClick(QMouseEvent*,
bool)));
118 if (!_flags.empty ())
121 foreach (QString flag, _flags)
122 if (o_it->flag (flag))
132 if (!_types.empty ())
134 if (!_types.contains (
typeName (o_it->dataType())))
138 if (o_it->isGroup() && !_withGroups)
154 ObjectPickDialog::~ ObjectPickDialog()
157 o_it->setFlag(
"vsi_objectId_selected",
false);
165 void ObjectPickDialog::activated(
const QModelIndex & _index)
167 if (_index.isValid()) {
179 void ObjectPickDialog::slotMouseEventClick(QMouseEvent * _event,
bool )
181 size_t nodeIdx, targetIdx;
190 if (!obj->
flag (
"vsi_objectId_disabled"))
217 obj2->
setFlag (
"vsi_objectId_selected",
false);
219 setForGroup (obj2,
"vsi_objectId_selected",
false);
221 obj->
setFlag (
"vsi_objectId_selected",
true);
223 setForGroup (obj,
"vsi_objectId_selected",
true);
233 void VSI::ObjectPickDialog::setForGroup(
BaseObject *_obj, QString _flag,
bool _enabled)
236 if (o_it->id () == _obj->
id ())
238 if (o_it->isInGroup (_obj->
id ()))
240 o_it->setFlag(_flag, _enabled);
242 setForGroup (o_it, _flag, _enabled);
void setFlag(QString _flag, bool _set)
QModelIndex getModelIndex(TreeItem *_object, int _column)
Return the ModelIndex corresponding to a given TreeItem and Column.
glViewer * viewer()
Viewer.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
BaseObject *& objectRoot()
Get the root of the object structure.
unsigned int selectedId()
Current selected object.
void objectMarker(ViewObjectMarker *_marker)
set object marker for viewer
pick any of the prior targets (should be implemented for all nodes)
Core Data Iterator used to iterate over all objects (Including groups)
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
bool isGroup() const
Check if object is a group.
virtual void updateGL()
Redraw scene. Triggers paint event for updating the view (cf. drawNow()).
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
DLLEXPORT BaseObjectIterator baseObjectsEnd()
Return Iterator to Object End.
Viewer::ViewerProperties & properties()
Viewer properties.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
ObjectPickDialog(QWidget *parent, QStringList _flags, QStringList _types, bool _withGroups)
Constructor.
bool pick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)