53 #include "DataControlPlugin.hh" 55 #include <ACG/QtWidgets/QtMaterialDialog.hh> 59 #include <ObjectTypes/Light/LightWidget.hh> 68 QItemSelectionModel* selection =
view_->selectionModel();
70 if (selection == 0)
return;
73 QModelIndexList indexList = selection->selectedRows();
77 msgBox.setText(tr(
"Do you really want to remove the selected objects?"));
78 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
79 msgBox.setDefaultButton(QMessageBox::Yes);
83 for (
int i = 0 ; i < indexList.size() ; ++i)
86 msgBox.setDetailedText(text);
88 if ( msgBox.exec() == QMessageBox::No)
91 for (
int i = 0 ; i < indexList.size() ; ++i) {
97 emit deleteObject(
id );
110 QItemSelectionModel* selection =
view_->selectionModel();
113 QModelIndexList indexList = selection->selectedRows ( 0 );
127 QItemSelectionModel* selection =
view_->selectionModel();
129 if (selection == 0)
return;
132 QModelIndexList indexList = selection->selectedRows();
134 for (
int i = 0 ; i < indexList.size() ; ++i) {
142 emit copyObject(
id, newObject );
158 QItemSelectionModel* selection =
view_->selectionModel();
161 QModelIndexList indexList = selection->selectedRows ( 0 );
166 for (
int i = 0; i < indexList.size(); ++i)
172 emit objectsGrouped(ids);
192 QItemSelectionModel* selection =
view_->selectionModel();
195 QModelIndexList indexList = selection->selectedRows ( 0 );
196 int selectedRows = indexList.size();
201 if ( selectedRows > 1 ) {
202 action = menu.addAction(
"Copy",
this,SLOT (
slotCopy() ));
203 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
204 action->setIcon(icon);
205 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
210 if ( item->isGroup() ) {
211 action = menu.addAction(tr(
"Zoom to objects"),
this,SLOT (
slotZoomTo() ));
212 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
213 action->setIcon(icon);
214 menu.addAction(tr(
"Ungroup"),
this,SLOT (
slotUngroup() ));
216 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
217 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
218 action->setIcon(icon);
221 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
222 action->setIcon(icon);
229 QAction* header = menu.addAction(tr(
"Object ")+QString::number(
id)+
": "+item->
name());
236 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
237 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
238 action->setIcon(icon);
239 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
240 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
241 action->setIcon(icon);
243 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
244 action->setIcon(icon);
251 action = menu.addAction(tr(
"Switch On"),
this,SLOT (
slotSwitchLight() ));
257 action = menu.addAction(tr(
"Switch Off"),
this,SLOT (
slotSwitchLight() ));
258 icon = QIcon (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"LightOff.png");
260 action->setIcon(icon);
262 action = menu.addAction(tr(
"Edit Light"),
this,SLOT (
slotEditLight() ));
264 action->setIcon(icon);
267 action = menu.addAction(tr(
"Zoom to object"),
this,SLOT (
slotZoomTo() ));
268 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
269 action->setIcon(icon);
271 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
272 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
273 action->setIcon(icon);
275 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
276 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
277 action->setIcon(icon);
280 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png");
281 action->setIcon(icon);
284 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copyToTargets-material.png");
285 action->setIcon(icon);
288 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copy-material.png");
289 action->setIcon(icon);
292 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-paste-material.png");
293 action->setIcon(icon);
295 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
299 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
300 action->setIcon(icon);
306 menu.exec(
view_->mapToGlobal( _pos) );
326 QVector<DataType> types;
330 if ( !types.contains( o_it->dataType() ) )
331 types.push_back( o_it->dataType() );
341 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
342 action = menu.addAction(icon,tr(
"Show all"),
this,SLOT (
showAll() ));
343 action->setData( QVariant() );
345 if (types.count() > 1)
346 for (
int i=0; i < types.count(); i++){
347 action = menu.addAction(icon, tr(
"Show all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
showAll() ));
348 action->setData( QVariant( types[i].value() ) );
352 action = menu.addAction(tr(
"Hide all"),
this,SLOT (
hideAll() ));
353 action->setData( QVariant() );
355 if (types.count() > 1)
356 for (
int i=0; i < types.count(); i++){
357 action = menu.addAction(tr(
"Hide all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
hideAll() ));
358 action->setData( QVariant( types[i].value() ) );
364 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllSource() ));
365 action->setData( QVariant() );
367 if (types.count() > 1)
368 for (
int i=0; i < types.count(); i++){
369 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllSource() ));
370 action->setData( QVariant( types[i].value() ) );
374 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllSource() ));
375 action->setData( QVariant() );
377 if (types.count() > 1)
378 for (
int i=0; i < types.count(); i++){
380 action->setData( QVariant( types[i].value() ) );
386 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllTarget() ));
387 action->setData( QVariant() );
389 if (types.count() > 1)
390 for (
int i=0; i < types.count(); i++){
391 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllTarget() ));
392 action->setData( QVariant( types[i].value() ) );
396 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllTarget() ));
397 action->setData( QVariant() );
399 if (types.count() > 1)
400 for (
int i=0; i < types.count(); i++){
402 action->setData( QVariant( types[i].value() ) );
421 QItemSelectionModel* selection =
view_->selectionModel();
424 QModelIndexList indexList = selection->selectedRows ( 0 );
425 int selectedRows = indexList.size();
426 if (selectedRows == 1){
433 QString newName = QInputDialog::getText(0, tr(
"Rename"),
436 if (ok && !newName.isEmpty()){
438 view_->resizeColumnToContents(0);
454 QAction* action =
dynamic_cast< QAction*
> ( sender() );
459 int id = action->data().toInt(&ok);
467 QItemSelectionModel* selection =
view_->selectionModel();
470 QModelIndexList indexList = selection->selectedRows ( 0 );
471 int selectedRows = indexList.size();
472 if (selectedRows == 1){
488 MaterialNode *
const materialNode = o_it->materialNode();
490 materialNode->
material() = sourceMaterial;
502 QAction* action =
dynamic_cast< QAction*
> ( sender() );
507 int id = action->data().toInt(&ok);
515 QItemSelectionModel* selection =
view_->selectionModel();
518 QModelIndexList indexList = selection->selectedRows ( 0 );
519 int selectedRows = indexList.size();
520 if (selectedRows == 1){
533 const QString materialJson = sourceMaterial.serializeToJson();
534 QApplication::clipboard()->setText(materialJson);
542 QAction* action =
dynamic_cast< QAction*
> ( sender() );
547 int id = action->data().toInt(&ok);
555 QItemSelectionModel* selection =
view_->selectionModel();
558 QModelIndexList indexList = selection->selectedRows ( 0 );
559 int selectedRows = indexList.size();
560 if (selectedRows == 1){
573 destMaterial.deserializeFromJson(QApplication::clipboard()->text());
584 QAction* action =
dynamic_cast< QAction*
> ( sender() );
589 int id = action->data().toInt(&ok);
597 QItemSelectionModel* selection =
view_->selectionModel();
600 QModelIndexList indexList = selection->selectedRows ( 0 );
601 int selectedRows = indexList.size();
602 if (selectedRows == 1){
616 dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
621 dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png"));
642 QItemSelectionModel* selection =
view_->selectionModel();
645 QModelIndexList indexList = selection->selectedRows ( 0 );
646 int selectedRows = indexList.size();
647 if (selectedRows == 1) {
655 if(light == 0)
return;
672 QItemSelectionModel* selection =
view_->selectionModel();
675 QModelIndexList indexList = selection->selectedRows ( 0 );
676 int selectedRows = indexList.size();
677 if (selectedRows == 1) {
685 if(light == 0)
return;
688 widget->setWindowFlags(Qt::WindowStaysOnTopHint);
699 QItemSelectionModel* selection =
view_->selectionModel();
702 QModelIndexList indexList = selection->selectedRows ( 0 );
703 int selectedRows = indexList.size();
704 if (selectedRows == 1){
713 QList< BaseObject* > children = item->
getLeafs();
716 bool firstRound =
true;
720 for (
int i=0; i < children.size(); i++){
738 bbmin[0] = std::min( bbmin[0], cur_min[0]);
739 bbmin[1] = std::min( bbmin[1], cur_min[1]);
740 bbmin[2] = std::min( bbmin[2], cur_min[2]);
741 bbmax[0] = std::max( bbmax[0], cur_max[0]);
742 bbmax[1] = std::max( bbmax[0], cur_max[1]);
743 bbmax[2] = std::max( bbmax[0], cur_max[2]);
751 double bbradius = (bbmax - bbmin).norm();
771 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
772 std::cerr <<
"Error while computing bounding box!";
778 double bbradius = (bbmax - bbmin).norm();
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
void slotMaterialProperties()
Called by the popup menu to set material properties.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
void enable()
enable LightSource
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
Add normals to mesh item (vertices/faces)
LightNode * lightNode()
Get the scenegraph Node.
int headerPopupType_
Defines the section of the Popup.
void slotZoomTo()
Called by the popup menu to zoom to an object.
ACG::SceneGraph::Material & material()
Get material object reference.
bool getObject(int _identifier, BSplineCurveObject *&_object)
LightSource * lightSource()
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
bool dataType(DataType _type) const
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void getBoundingBox(ACG::Vec3d &bbmin, ACG::Vec3d &bbmax)
get the bounding box of the object
TreeModel * model_
The Treemodel organizing the data.
bool unGroupObject(int _id)
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
void showAll()
Shows all objects.
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
virtual bool visible()
return visiblity
const QStringList ALL_OBJECTS
Iterable object range.
void clearAllSource()
remove source selection from all objects
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
MaterialNode * materialNode()
get a pointer to the materialnode
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
void disable()
disable LightSource
void setAllSource()
Makes all available objects source.
void setAllTarget()
Makes all available objects target.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
void clearAllTarget()
Unselect all objects.
void slotGroup()
Called by the popup menu to group items.
QTreeView * view_
Tree view.
bool isGroup() const
Check if object is a group.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
QModelIndex popupIndex_
Index where a popup has been opened.
QList< BaseObject * > getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
QHeaderView * viewHeader_
Pointer to the header to the view widget.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
void slotRename()
Called by the popup menu to rename items.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
void slotUngroup()
Called by the popup menu to ungroup items.
void slotCopy()
Called by the popup menu to copy items.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void slotEditLight()
Called by the popup menu in order to edit lights.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
void hideAll()
Hides all objects.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
void slotPopupRemove()
Called by the popup menu to remove an object/group.
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
bool enabled() const
Get light source status.