51 #include <QHBoxLayout> 52 #include <QPushButton> 54 #include <QMouseEvent> 57 #include <OpenFlipper/widgets/glWidget/simpleViewer.hh> 58 #include <OpenFlipper/widgets/glWidget/QtBaseViewer.hh> 60 #include "objectPickDialog.hh" 61 #include "TreeModelObjectSelection.hh" 76 QHBoxLayout *hL =
new QHBoxLayout;
77 QHBoxLayout *bL =
new QHBoxLayout;
78 QVBoxLayout *vL =
new QVBoxLayout;
82 treeView_ =
new QTreeView;
83 treeView_->setModel (model_);
84 treeView_->resizeColumnToContents (0);
85 treeView_->setSelectionMode (QAbstractItemView::SingleSelection);
86 treeView_->setSelectionBehavior (QAbstractItemView::SelectRows);
91 okButton_ =
new QPushButton (tr(
"OK"));
92 cancelButton_ =
new QPushButton (tr(
"Cancel"));
94 connect (okButton_, SIGNAL (pressed()),
this, SLOT (accept()));
95 connect (cancelButton_, SIGNAL (pressed()),
this, SLOT (reject()));
97 hL->addWidget (viewer_);
98 hL->setStretchFactor (viewer_, 1);
99 hL->addWidget (treeView_);
102 bL->addWidget (okButton_);
103 bL->addWidget (cancelButton_);
112 setWindowTitle(tr(
"Click on object or select from list..."));
114 connect (treeView_, SIGNAL (activated(
const QModelIndex& )),
115 this, SLOT (activated(
const QModelIndex&)));
116 connect (viewer_->
viewer(), SIGNAL (signalMouseEventClick(QMouseEvent*,
bool)),
117 this, SLOT (slotMouseEventClick(QMouseEvent*,
bool)));
123 if (!_flags.empty ())
126 foreach (QString flag, _flags)
127 if (o_it->flag (flag))
137 if (!_types.empty ())
139 if (!_types.contains (
typeName (o_it->dataType())))
143 if (o_it->isGroup() && !_withGroups)
162 o_it->setFlag(
"vsi_objectId_selected",
false);
170 void ObjectPickDialog::activated(
const QModelIndex & _index)
172 if (_index.isValid()) {
184 void ObjectPickDialog::slotMouseEventClick(QMouseEvent * _event,
bool )
186 unsigned int nodeIdx, targetIdx;
194 if (!obj->
flag (
"vsi_objectId_disabled"))
221 obj2->
setFlag (
"vsi_objectId_selected",
false);
223 setForGroup (obj2,
"vsi_objectId_selected",
false);
225 obj->
setFlag (
"vsi_objectId_selected",
true);
227 setForGroup (obj,
"vsi_objectId_selected",
true);
237 void ObjectPickDialog::setForGroup(
BaseObject *_obj, QString _flag,
bool _enabled)
240 if (o_it->id () == _obj->
id ())
242 if (o_it->isInGroup (_obj->
id ()))
244 o_it->setFlag(_flag, _enabled);
246 setForGroup (o_it, _flag, _enabled);
BaseObject *& objectRoot()
Get the root of the object structure.
bool pick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Viewer::ViewerProperties & properties()
Viewer properties.
bool getObject(int _identifier, BSplineCurveObject *&_object)
DLLEXPORT BaseObjectIterator baseObjectsEnd()
Return Iterator to Object End.
void objectMarker(ViewObjectMarker *_marker)
set object marker for viewer
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
bool getPickedObject(const unsigned int _node_idx, BaseObjectData *&_object)
Get the picked mesh.
~ObjectPickDialog()
Destructor.
unsigned int selectedId()
Current selected object.
bool isGroup() const
Check if object is a group.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
Core Data Iterator used to iterate over all objects (Including groups)
pick any of the prior targets (should be implemented for all nodes)
virtual void updateGL()
Redraw scene. Triggers paint event for updating the view (cf. drawNow()).
void setFlag(QString _flag, bool _set)
glViewer * viewer()
Viewer.
ObjectPickDialog(QStringList _flags, QStringList _types, bool _withGroups)
Constructor.
QModelIndex getModelIndex(TreeItemObjectSelection *_object, int _column)
Return the ModelIndex corresponding to a given TreeItemObjectSelection and Column.