47 #include "DataControlPlugin.hh" 49 #include <ACG/QtWidgets/QtMaterialDialog.hh> 53 #include <ObjectTypes/Light/LightWidget.hh> 55 #include <ACG/Scenegraph/MaterialNode.hh> 64 QItemSelectionModel* selection =
view_->selectionModel();
66 if (selection == 0)
return;
69 QModelIndexList indexList = selection->selectedRows();
73 msgBox.setText(tr(
"Do you really want to remove the selected objects?"));
74 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
75 msgBox.setDefaultButton(QMessageBox::Yes);
79 for (
int i = 0 ; i < indexList.size() ; ++i)
82 msgBox.setDetailedText(text);
84 if ( msgBox.exec() == QMessageBox::No)
87 for (
int i = 0 ; i < indexList.size() ; ++i) {
93 emit deleteObject(
id );
106 QItemSelectionModel* selection =
view_->selectionModel();
109 QModelIndexList indexList = selection->selectedRows ( 0 );
123 QItemSelectionModel* selection =
view_->selectionModel();
125 if (selection == 0)
return;
128 QModelIndexList indexList = selection->selectedRows();
130 for (
int i = 0 ; i < indexList.size() ; ++i) {
138 emit copyObject(
id, newObject );
154 QItemSelectionModel* selection =
view_->selectionModel();
157 QModelIndexList indexList = selection->selectedRows ( 0 );
162 for (
int i = 0; i < indexList.size(); ++i)
168 emit objectsGrouped(ids);
188 QItemSelectionModel* selection =
view_->selectionModel();
191 QModelIndexList indexList = selection->selectedRows ( 0 );
192 int selectedRows = indexList.size();
197 if ( selectedRows > 1 ) {
198 action = menu.addAction(
"Copy",
this,SLOT (
slotCopy() ));
199 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
200 action->setIcon(icon);
201 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
206 if ( item->isGroup() ) {
207 action = menu.addAction(tr(
"Zoom to objects"),
this,SLOT (
slotZoomTo() ));
208 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
209 action->setIcon(icon);
210 menu.addAction(tr(
"Ungroup"),
this,SLOT (
slotUngroup() ));
212 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
213 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
214 action->setIcon(icon);
217 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
218 action->setIcon(icon);
225 QAction* header = menu.addAction(tr(
"Object ")+QString::number(
id)+
": "+item->
name());
232 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
233 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
234 action->setIcon(icon);
235 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
236 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
237 action->setIcon(icon);
239 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
240 action->setIcon(icon);
247 action = menu.addAction(tr(
"Switch On"),
this,SLOT (
slotSwitchLight() ));
253 action = menu.addAction(tr(
"Switch Off"),
this,SLOT (
slotSwitchLight() ));
254 icon = QIcon (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"LightOff.png");
256 action->setIcon(icon);
258 action = menu.addAction(tr(
"Edit Light"),
this,SLOT (
slotEditLight() ));
260 action->setIcon(icon);
263 action = menu.addAction(tr(
"Zoom to object"),
this,SLOT (
slotZoomTo() ));
264 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
265 action->setIcon(icon);
267 action = menu.addAction(tr(
"Copy"),
this,SLOT (
slotCopy() ));
268 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-copy.png");
269 action->setIcon(icon);
271 action = menu.addAction(tr(
"Rename"),
this,SLOT (
slotRename() ));
272 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"edit-rename.png");
273 action->setIcon(icon);
276 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png");
277 action->setIcon(icon);
280 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copyToTargets-material.png");
281 action->setIcon(icon);
284 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-copy-material.png");
285 action->setIcon(icon);
288 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-paste-material.png");
289 action->setIcon(icon);
291 menu.addAction(tr(
"Group"),
this,SLOT (
slotGroup() ));
295 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-delete-item.png");
296 action->setIcon(icon);
302 menu.exec(
view_->mapToGlobal( _pos) );
322 QVector<DataType> types;
326 if ( !types.contains( o_it->dataType() ) )
327 types.push_back( o_it->dataType() );
337 icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"drawModes.png");
338 action = menu.addAction(icon,tr(
"Show all"),
this,SLOT (
showAll() ));
339 action->setData( QVariant() );
341 if (types.count() > 1)
342 for (
int i=0; i < types.count(); i++){
343 action = menu.addAction(icon, tr(
"Show all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
showAll() ));
344 action->setData( QVariant( types[i].value() ) );
348 action = menu.addAction(tr(
"Hide all"),
this,SLOT (
hideAll() ));
349 action->setData( QVariant() );
351 if (types.count() > 1)
352 for (
int i=0; i < types.count(); i++){
353 action = menu.addAction(tr(
"Hide all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
hideAll() ));
354 action->setData( QVariant( types[i].value() ) );
360 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllSource() ));
361 action->setData( QVariant() );
363 if (types.count() > 1)
364 for (
int i=0; i < types.count(); i++){
365 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllSource() ));
366 action->setData( QVariant( types[i].value() ) );
370 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllSource() ));
371 action->setData( QVariant() );
373 if (types.count() > 1)
374 for (
int i=0; i < types.count(); i++){
376 action->setData( QVariant( types[i].value() ) );
382 action = menu.addAction(tr(
"Select all"),
this,SLOT (
setAllTarget() ));
383 action->setData( QVariant() );
385 if (types.count() > 1)
386 for (
int i=0; i < types.count(); i++){
387 action = menu.addAction(icon, tr(
"Select all of type '") +
dataTypeName(types[i]) +
"'",
this,SLOT (
setAllTarget() ));
388 action->setData( QVariant( types[i].value() ) );
392 action = menu.addAction(tr(
"Deselect all"),
this,SLOT (
clearAllTarget() ));
393 action->setData( QVariant() );
395 if (types.count() > 1)
396 for (
int i=0; i < types.count(); i++){
398 action->setData( QVariant( types[i].value() ) );
417 QItemSelectionModel* selection =
view_->selectionModel();
420 QModelIndexList indexList = selection->selectedRows ( 0 );
421 int selectedRows = indexList.size();
422 if (selectedRows == 1){
429 QString newName = QInputDialog::getText(0, tr(
"Rename"),
430 tr(
"Enter a new name:"), QLineEdit::Normal,
432 if (ok && !newName.isEmpty()){
434 view_->resizeColumnToContents(0);
450 QAction* action =
dynamic_cast< QAction*
> ( sender() );
455 int id = action->data().toInt(&ok);
463 QItemSelectionModel* selection =
view_->selectionModel();
466 QModelIndexList indexList = selection->selectedRows ( 0 );
467 int selectedRows = indexList.size();
468 if (selectedRows == 1){
484 MaterialNode *
const materialNode = o_it->materialNode();
486 materialNode->
material() = sourceMaterial;
498 QAction* action =
dynamic_cast< QAction*
> ( sender() );
503 int id = action->data().toInt(&ok);
511 QItemSelectionModel* selection =
view_->selectionModel();
514 QModelIndexList indexList = selection->selectedRows ( 0 );
515 int selectedRows = indexList.size();
516 if (selectedRows == 1){
529 const QString materialJson = sourceMaterial.serializeToJson();
530 QApplication::clipboard()->setText(materialJson);
538 QAction* action =
dynamic_cast< QAction*
> ( sender() );
543 int id = action->data().toInt(&ok);
551 QItemSelectionModel* selection =
view_->selectionModel();
554 QModelIndexList indexList = selection->selectedRows ( 0 );
555 int selectedRows = indexList.size();
556 if (selectedRows == 1){
569 destMaterial.deserializeFromJson(QApplication::clipboard()->text());
580 QAction* action =
dynamic_cast< QAction*
> ( sender() );
585 int id = action->data().toInt(&ok);
593 QItemSelectionModel* selection =
view_->selectionModel();
596 QModelIndexList indexList = selection->selectedRows ( 0 );
597 int selectedRows = indexList.size();
598 if (selectedRows == 1){
612 dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
617 dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"datacontrol-material.png"));
638 QItemSelectionModel* selection =
view_->selectionModel();
641 QModelIndexList indexList = selection->selectedRows ( 0 );
642 int selectedRows = indexList.size();
643 if (selectedRows == 1) {
651 if(light == 0)
return;
668 QItemSelectionModel* selection =
view_->selectionModel();
671 QModelIndexList indexList = selection->selectedRows ( 0 );
672 int selectedRows = indexList.size();
673 if (selectedRows == 1) {
681 if(light == 0)
return;
684 widget->setWindowFlags(Qt::WindowStaysOnTopHint);
695 QItemSelectionModel* selection =
view_->selectionModel();
698 QModelIndexList indexList = selection->selectedRows ( 0 );
699 int selectedRows = indexList.size();
700 if (selectedRows == 1){
709 QList< BaseObject* > children = item->
getLeafs();
712 bool firstRound =
true;
716 for (
int i=0; i < children.size(); i++){
734 bbmin[0] = std::min( bbmin[0], cur_min[0]);
735 bbmin[1] = std::min( bbmin[1], cur_min[1]);
736 bbmin[2] = std::min( bbmin[2], cur_min[2]);
737 bbmax[0] = std::max( bbmax[0], cur_max[0]);
738 bbmax[1] = std::max( bbmax[0], cur_max[1]);
739 bbmax[2] = std::max( bbmax[0], cur_max[2]);
747 double bbradius = (bbmax - bbmin).norm();
767 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
768 std::cerr <<
"Error while computing bounding box!";
774 double bbradius = (bbmax - bbmin).norm();
void hideAll()
Hides all objects.
LightSource * lightSource()
void disable()
disable LightSource
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
QList< BaseObject *> getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
void showAll()
Shows all objects.
bool enabled() const
Get light source status.
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QHeaderView * viewHeader_
Pointer to the header to the view widget.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
QModelIndex popupIndex_
Index where a popup has been opened.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
bool unGroupObject(int _id)
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
void clearAllTarget()
Unselect all objects.
const QStringList ALL_OBJECTS
Iterable object range.
void slotCopy()
Called by the popup menu to copy items.
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
void setAllTarget()
Makes all available objects target.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
bool dataType(DataType _type) const
std::vector< int > IdList
Standard Type for id Lists used for scripting.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TreeModel * model_
The Treemodel organizing the data.
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
QTreeView * view_
Tree view.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
void setAllSource()
Makes all available objects source.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
void slotUngroup()
Called by the popup menu to ungroup items.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
void slotGroup()
Called by the popup menu to group items.
void enable()
enable LightSource
const QStringList TARGET_OBJECTS("target")
Iterable object range.
MaterialNode * materialNode()
get a pointer to the materialnode
bool isGroup() const
Check if object is a group.
void slotZoomTo()
Called by the popup menu to zoom to an object.
void clearAllSource()
remove source selection from all objects
void slotMaterialProperties()
Called by the popup menu to set material properties.
int headerPopupType_
Defines the section of the Popup.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
void getBoundingBox(ACG::Vec3d &bbmin, ACG::Vec3d &bbmax)
get the bounding box of the object
void slotEditLight()
Called by the popup menu in order to edit lights.
LightNode * lightNode()
Get the scenegraph Node.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
ACG::SceneGraph::Material & material()
Get material object reference.
virtual bool visible() override
return visiblity
void slotRename()
Called by the popup menu to rename items.
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
void slotPopupRemove()
Called by the popup menu to remove an object/group.