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 "TreeModelObjectSelection.hh" 70 QHBoxLayout *hL =
new QHBoxLayout;
71 QHBoxLayout *bL =
new QHBoxLayout;
72 QVBoxLayout *vL =
new QVBoxLayout;
76 treeView_ =
new QTreeView;
77 treeView_->setModel (model_);
78 treeView_->resizeColumnToContents (0);
79 treeView_->setSelectionMode (QAbstractItemView::SingleSelection);
80 treeView_->setSelectionBehavior (QAbstractItemView::SelectRows);
85 okButton_ =
new QPushButton (tr(
"OK"));
86 cancelButton_ =
new QPushButton (tr(
"Cancel"));
88 connect (okButton_, SIGNAL (pressed()),
this, SLOT (accept()));
89 connect (cancelButton_, SIGNAL (pressed()),
this, SLOT (reject()));
91 hL->addWidget (viewer_);
92 hL->setStretchFactor (viewer_, 1);
93 hL->addWidget (treeView_);
96 bL->addWidget (okButton_);
97 bL->addWidget (cancelButton_);
106 setWindowTitle(tr(
"Click on object or select from list..."));
108 connect (treeView_, SIGNAL (activated(
const QModelIndex& )),
109 this, SLOT (activated(
const QModelIndex&)));
110 connect (viewer_->
viewer(), SIGNAL (signalMouseEventClick(QMouseEvent*,
bool)),
111 this, SLOT (slotMouseEventClick(QMouseEvent*,
bool)));
117 if (!_flags.empty ())
120 foreach (QString flag, _flags)
121 if (o_it->flag (flag))
131 if (!_types.empty ())
133 if (!_types.contains (
typeName (o_it->dataType())))
137 if (o_it->isGroup() && !_withGroups)
153 ObjectPickDialog::~ ObjectPickDialog()
156 o_it->setFlag(
"vsi_objectId_selected",
false);
164 void ObjectPickDialog::activated(
const QModelIndex & _index)
166 if (_index.isValid()) {
178 void ObjectPickDialog::slotMouseEventClick(QMouseEvent * _event,
bool )
180 size_t nodeIdx, targetIdx;
188 if (!obj->
flag (
"vsi_objectId_disabled"))
215 obj2->
setFlag (
"vsi_objectId_selected",
false);
217 setForGroup (obj2,
"vsi_objectId_selected",
false);
219 obj->
setFlag (
"vsi_objectId_selected",
true);
221 setForGroup (obj,
"vsi_objectId_selected",
true);
231 void ObjectPickDialog::setForGroup(
BaseObject *_obj, QString _flag,
bool _enabled)
234 if (o_it->id () == _obj->
id ())
236 if (o_it->isInGroup (_obj->
id ()))
238 o_it->setFlag(_flag, _enabled);
240 setForGroup (o_it, _flag, _enabled);
bool isGroup() const
Check if object is a group.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
DLLEXPORT BaseObjectIterator baseObjectsEnd()
Return Iterator to Object End.
pick any of the prior targets (should be implemented for all nodes)
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
BaseObject *& objectRoot()
Get the root of the object structure.
void setFlag(QString _flag, bool _set)
virtual void updateGL()
Redraw scene. Triggers paint event for updating the view (cf. drawNow()).
unsigned int selectedId()
Current selected object.
void objectMarker(ViewObjectMarker *_marker)
set object marker for viewer
glViewer * viewer()
Viewer.
QModelIndex getModelIndex(TreeItemObjectSelection *_object, int _column)
Return the ModelIndex corresponding to a given TreeItemObjectSelection and Column.
Viewer::ViewerProperties & properties()
Viewer properties.
bool pick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
ObjectPickDialog(QStringList _flags, QStringList _types, bool _withGroups)
Constructor.
Core Data Iterator used to iterate over all objects (Including groups)