Developer Documentation
Popup.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 
43 
44 
45 
46 
47 #include "DataControlPlugin.hh"
48 
49 #include <ACG/QtWidgets/QtMaterialDialog.hh>
50 
51 #include "Menu.hh"
52 
53 #include <ObjectTypes/Light/LightWidget.hh>
54 
55 #include <ACG/Scenegraph/MaterialNode.hh>
56 
57 //******************************************************************************
58 
63 
64  QItemSelectionModel* selection = view_->selectionModel();
65 
66  if (selection == 0) return;
67 
68  // Get all selected rows
69  QModelIndexList indexList = selection->selectedRows();
70 
71 
72  QMessageBox msgBox;
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);
76 
77  QString text;
78 
79  for ( int i = 0 ; i < indexList.size() ; ++i)
80  text += model_->itemName( indexList[i] ) + "\n";
81 
82  msgBox.setDetailedText(text);
83 
84  if ( msgBox.exec() == QMessageBox::No)
85  return;
86 
87  for ( int i = 0 ; i < indexList.size() ; ++i) {
88 
89  int id = model_->itemId( indexList[i] );
90 
91 
92  if ( id != -1 )
93  emit deleteObject( id );
94  }
95 
96  emit updateView();
97 }
98 
99 
100 //******************************************************************************
101 
106  QItemSelectionModel* selection = view_->selectionModel();
107 
108  // Get all selected rows
109  QModelIndexList indexList = selection->selectedRows ( 0 );
110 
111  //get the object
112  int id = model_->itemId( indexList[0] );
113  unGroupObject(id);
114 }
115 
116 
117 //******************************************************************************
118 
123  QItemSelectionModel* selection = view_->selectionModel();
124 
125  if (selection == 0) return;
126 
127  // Get all selected rows
128  QModelIndexList indexList = selection->selectedRows();
129 
130  for ( int i = 0 ; i < indexList.size() ; ++i) {
131 
132  int id = model_->itemId( indexList[i] );
133 
134  if ( id > 0){
135 
136  int newObject;
137 
138  emit copyObject( id, newObject );
139  }
140 
141  }
142 
143  emit updateView();
144 }
145 
146 
147 //******************************************************************************
148 
153 
154  QItemSelectionModel* selection = view_->selectionModel();
155 
156  // Get all selected rows
157  QModelIndexList indexList = selection->selectedRows ( 0 );
158 
159 
160  //get object ids
161  IdList ids;
162  for (int i = 0; i < indexList.size(); ++i)
163  ids.push_back( model_->itemId(indexList[i]) );
164 
165 
166  //group all objects
167  groupObjects(ids);
168  emit objectsGrouped(ids);
169 
170 }
171 
172 
173 //******************************************************************************
174 
180  popupIndex_ = view_->indexAt(_pos);
181 
182  if (!popupIndex_.isValid())
183  return;
184 
186 
187 
188  QItemSelectionModel* selection = view_->selectionModel();
189 
190  // Get all selected rows
191  QModelIndexList indexList = selection->selectedRows ( 0 );
192  int selectedRows = indexList.size();
193 
194  Menu menu(0);
195  QAction* action;
196  QIcon icon;
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() ));
202  menu.addSeparator();
203  menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
204  }else
205  // check if the item is a group item
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() ));
211  menu.addSeparator();
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);
215  menu.addSeparator();
216  action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
217  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
218  action->setIcon(icon);
219  } else {
220 
221  //show object name and id in first entry of the menu
222  int id = model_->itemId( indexList[0] );
223  BaseObject* item = 0;
224  if ( id != -1 && PluginFunctions::getObject(id,item) ) {
225  QAction* header = menu.addAction(tr("Object ")+QString::number(id)+": "+item->name());
226  header->setIcon( typeIcon(item->dataType()) );
227  }
228 
229  menu.addSeparator();
230 
231  if(item->dataType() == DATA_LIGHT) {
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);
238  action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
239  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
240  action->setIcon(icon);
241  menu.addSeparator();
242 
243  LightObject* light = 0;
244  if ( item->id() != -1 && PluginFunctions::getObject( item->id(), light ) ) {
245  if (light != 0 && !light->lightSource()->enabled()) {
246 
247  action = menu.addAction(tr("Switch On"),this,SLOT ( slotSwitchLight() ));
248  icon = typeIcon(DATA_LIGHT);
249  }
250  }
251  if (light == 0 || light->lightSource()->enabled())
252  {
253  action = menu.addAction(tr("Switch Off"),this,SLOT ( slotSwitchLight() ));
254  icon = QIcon (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"LightOff.png");
255  }
256  action->setIcon(icon);
257 
258  action = menu.addAction(tr("Edit Light"),this,SLOT ( slotEditLight() ));
259  icon = typeIcon(DATA_LIGHT);
260  action->setIcon(icon);
261 
262  } else {
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);
266 
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);
270 
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);
274 
275  action = menu.addAction(tr("Material Properties"),this,SLOT ( slotMaterialProperties() ));
276  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
277  action->setIcon(icon);
278 
279  action = menu.addAction(tr("Copy Material Properties to Targeted Objects"), this, SLOT ( slotCopyMaterialToTargeted() ));
280  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-copyToTargets-material.png");
281  action->setIcon(icon);
282 
283  action = menu.addAction(tr("Copy Material Properties to Clipboard"), this, SLOT ( slotCopyMaterialToClipboard() ));
284  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-copy-material.png");
285  action->setIcon(icon);
286 
287  action = menu.addAction(tr("Paste Material Properties from Clipboard"), this, SLOT ( slotPasteMaterialFromClipboard() ));
288  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-paste-material.png");
289  action->setIcon(icon);
290 
291  menu.addAction(tr("Group"),this,SLOT ( slotGroup() ));
292 
293  menu.addSeparator();
294  action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
295  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
296  action->setIcon(icon);
297  }
298  }
299 
300 
301 
302  menu.exec(view_->mapToGlobal( _pos) );
303 
304 }
305 
306 
307 //******************************************************************************
308 
314 
315  headerPopupType_ = viewHeader_->logicalIndexAt( _pos );
316 
317  QMenu menu(0);
318 
319  QIcon icon;
320 
321  //get all used types
322  QVector<DataType> types;
323 
325  if ( !types.contains( o_it->dataType() ) )
326  types.push_back( o_it->dataType() );
327 
328  QAction* action;
329 
330  switch (headerPopupType_) {
331 // case 0 :
332 // std::cerr << "0";
333 // break;
334  //Show / Hide
335  case 1 :
336  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"drawModes.png");
337  action = menu.addAction(icon,tr("Show all"),this,SLOT ( showAll() ));
338  action->setData( QVariant() );
339 
340  if (types.count() > 1)
341  for (int i=0; i < types.count(); i++){
342  action = menu.addAction(icon, tr("Show all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( showAll() ));
343  action->setData( QVariant( types[i].value() ) );
344  }
345 
346  menu.addSeparator();
347  action = menu.addAction(tr("Hide all"),this,SLOT ( hideAll() ));
348  action->setData( QVariant() );
349 
350  if (types.count() > 1)
351  for (int i=0; i < types.count(); i++){
352  action = menu.addAction(tr("Hide all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( hideAll() ));
353  action->setData( QVariant( types[i].value() ) );
354  }
355 
356  break;
357  // Source
358  case 2 :
359  action = menu.addAction(tr("Select all"),this,SLOT ( setAllSource() ));
360  action->setData( QVariant() );
361 
362  if (types.count() > 1)
363  for (int i=0; i < types.count(); i++){
364  action = menu.addAction(icon, tr("Select all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( setAllSource() ));
365  action->setData( QVariant( types[i].value() ) );
366  }
367 
368  menu.addSeparator();
369  action = menu.addAction(tr("Deselect all"),this,SLOT ( clearAllSource() ));
370  action->setData( QVariant() );
371 
372  if (types.count() > 1)
373  for (int i=0; i < types.count(); i++){
374  action = menu.addAction(icon, tr("Deselect all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( clearAllSource() ));
375  action->setData( QVariant( types[i].value() ) );
376  }
377 
378  break;
379  // Target
380  case 3 :
381  action = menu.addAction(tr("Select all"),this,SLOT ( setAllTarget() ));
382  action->setData( QVariant() );
383 
384  if (types.count() > 1)
385  for (int i=0; i < types.count(); i++){
386  action = menu.addAction(icon, tr("Select all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( setAllTarget() ));
387  action->setData( QVariant( types[i].value() ) );
388  }
389 
390  menu.addSeparator();
391  action = menu.addAction(tr("Deselect all"),this,SLOT ( clearAllTarget() ));
392  action->setData( QVariant() );
393 
394  if (types.count() > 1)
395  for (int i=0; i < types.count(); i++){
396  action = menu.addAction(icon, tr("Deselect all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( clearAllTarget() ));
397  action->setData( QVariant( types[i].value() ) );
398  }
399 
400  break;
401  default :
402 // std::cerr << "def";
403  break;
404  }
405 
406  menu.exec(viewHeader_->mapToGlobal( _pos ) );
407 }
408 
409 
410 //******************************************************************************
411 
416  QItemSelectionModel* selection = view_->selectionModel();
417 
418  // Get all selected rows
419  QModelIndexList indexList = selection->selectedRows ( 0 );
420  int selectedRows = indexList.size();
421  if (selectedRows == 1){
422  int id = model_->itemId( indexList[0]);
423  BaseObject* item = 0;
424 
425  if ( id != -1 && PluginFunctions::getObject(id,item) ){
426 
427  bool ok;
428  QString newName = QInputDialog::getText(0, tr("Rename"),
429  tr("Enter a new name:"), QLineEdit::Normal,
430  item->name(), &ok);
431  if (ok && !newName.isEmpty()){
432  item->setName(newName);
433  view_->resizeColumnToContents(0);
434  }
435  }
436  }
437 }
438 
439 
440 //******************************************************************************
441 
446  BaseObject* item = 0;
447 
448  //check if it was called from object contextMenu or from the toolBox
449  QAction* action = dynamic_cast< QAction* > ( sender() );
450 
451  if ( action ){
452  bool ok = false;
453 
454  int id = action->data().toInt(&ok);
455 
456  if ( ok && id > 0 )
458  }
459 
460  if ( item == 0 ){
461  // the slot was called from toolbox
462  QItemSelectionModel* selection = view_->selectionModel();
463 
464  // Get all selected rows
465  QModelIndexList indexList = selection->selectedRows ( 0 );
466  int selectedRows = indexList.size();
467  if (selectedRows == 1){
468  int id = model_->itemId( indexList[0] );
469 
470  if ( id > 0 )
472  }
473  }
474 
475  if ( item != 0 ){
476 
477  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
478  const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
479 
481 
482  MaterialNode * const materialNode = o_it->materialNode();
483  if (materialNode) {
484  materialNode->material() = sourceMaterial;
485  }
486  }
487 
488  emit updateView();
489  }
490 }
491 
493  BaseObject* item = 0;
494 
495  //check if it was called from object contextMenu or from the toolBox
496  QAction* action = dynamic_cast< QAction* > ( sender() );
497 
498  if ( action ){
499  bool ok = false;
500 
501  int id = action->data().toInt(&ok);
502 
503  if ( ok && id > 0 )
505  }
506 
507  if ( item == 0 ){
508  // the slot was called from toolbox
509  QItemSelectionModel* selection = view_->selectionModel();
510 
511  // Get all selected rows
512  QModelIndexList indexList = selection->selectedRows ( 0 );
513  int selectedRows = indexList.size();
514  if (selectedRows == 1){
515  int id = model_->itemId( indexList[0] );
516 
517  if ( id > 0 )
519  }
520  }
521 
522  if ( item != 0 ){
523 
524  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
525  const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
526 
527  const QString materialJson = sourceMaterial.serializeToJson();
528  QApplication::clipboard()->setText(materialJson);
529  }
530 }
531 
533  BaseObject* item = 0;
534 
535  //check if it was called from object contextMenu or from the toolBox
536  QAction* action = dynamic_cast< QAction* > ( sender() );
537 
538  if ( action ){
539  bool ok = false;
540 
541  int id = action->data().toInt(&ok);
542 
543  if ( ok && id > 0 )
545  }
546 
547  if ( item == 0 ){
548  // the slot was called from toolbox
549  QItemSelectionModel* selection = view_->selectionModel();
550 
551  // Get all selected rows
552  QModelIndexList indexList = selection->selectedRows ( 0 );
553  int selectedRows = indexList.size();
554  if (selectedRows == 1){
555  int id = model_->itemId( indexList[0] );
556 
557  if ( id > 0 )
559  }
560  }
561 
562  if ( item != 0 ){
563 
564  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
565  ACG::SceneGraph::Material &destMaterial = itemData->materialNode()->material();
566 
567  destMaterial.deserializeFromJson(QApplication::clipboard()->text());
568 
569  emit updateView();
570  }
571 }
572 
574 
575  BaseObject* item = 0;
576 
577  //check if it was called from object contextMenu or from the toolBox
578  QAction* action = dynamic_cast< QAction* > ( sender() );
579 
580  if ( action ){
581  bool ok = false;
582 
583  int id = action->data().toInt(&ok);
584 
585  if ( ok && id > 0 )
587  }
588 
589  if ( item == 0 ){
590  // the slot was called from toolbox
591  QItemSelectionModel* selection = view_->selectionModel();
592 
593  // Get all selected rows
594  QModelIndexList indexList = selection->selectedRows ( 0 );
595  int selectedRows = indexList.size();
596  if (selectedRows == 1){
597  int id = model_->itemId( indexList[0] );
598 
599  if ( id > 0 )
601  }
602  }
603 
604  if ( item != 0 ){
605 
606  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
607 
609 
610  dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
611 
612  connect(dialog, SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
614 
615  dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png"));
616 
617  dialog->show();
618 
619  }
620 }
621 
622 
623 //******************************************************************************
624 
626  emit updateView();
627 }
628 
629 //******************************************************************************
630 
635 
636  QItemSelectionModel* selection = view_->selectionModel();
637 
638  // Get all selected rows
639  QModelIndexList indexList = selection->selectedRows ( 0 );
640  int selectedRows = indexList.size();
641  if (selectedRows == 1) {
642 
643  LightObject* light = 0;
644  int id = model_->itemId( indexList[0]);
645 
646  if (id == -1 || !PluginFunctions::getObject( id, light ) )
647  return;
648 
649  if(light == 0) return;
650 
651  light->lightSource()->enabled() ?
652  light->lightSource()->disable() :
653  light->lightSource()->enable();
654 
655  emit updatedObject(id, UPDATE_ALL);
656  }
657 }
658 
659 //******************************************************************************
660 
665 
666  QItemSelectionModel* selection = view_->selectionModel();
667 
668  // Get all selected rows
669  QModelIndexList indexList = selection->selectedRows ( 0 );
670  int selectedRows = indexList.size();
671  if (selectedRows == 1) {
672 
673  LightObject* light = 0;
674  int id = model_->itemId( indexList[0]);
675 
676  if (id == -1 || !PluginFunctions::getObject( id, light ) )
677  return;
678 
679  if(light == 0) return;
680 
681  LightWidget* widget = new LightWidget( light->lightNode() );
682  widget->setWindowFlags(Qt::WindowStaysOnTopHint);
683  widget->show();
684  }
685 }
686 
687 //******************************************************************************
688 
693  QItemSelectionModel* selection = view_->selectionModel();
694 
695  // Get all selected rows
696  QModelIndexList indexList = selection->selectedRows ( 0 );
697  int selectedRows = indexList.size();
698  if (selectedRows == 1){
699  BaseObject* item = 0;
700  int id = model_->itemId( indexList[0]);
701 
702  if (id == -1 || !PluginFunctions::getObject( id, item) )
703  return;
704 
705  if ( item->isGroup() ) {
706  //zoom to all objects in this group
707  QList< BaseObject* > children = item->getLeafs();
708 
709  //compute boundingBox
710  bool firstRound = true;
711  ACG::Vec3d bbmin(FLT_MAX,FLT_MAX,FLT_MAX);
712  ACG::Vec3d bbmax(FLT_MIN,FLT_MIN,FLT_MIN);
713 
714  for (int i=0; i < children.size(); i++){
715  BaseObjectData* child = dynamic_cast< BaseObjectData* > (children[i]);
716  if (child){
717 
718  if ( !child->visible() ){
719  child->show();
720  }
721 
722  ACG::Vec3d cur_min;
723  ACG::Vec3d cur_max;
724 
725  child->getBoundingBox(cur_min, cur_max);
726 
727  if (firstRound){
728  bbmin = cur_min;
729  bbmax = cur_max;
730  firstRound = false;
731  }else{
732  bbmin[0] = std::min( bbmin[0], cur_min[0]);
733  bbmin[1] = std::min( bbmin[1], cur_min[1]);
734  bbmin[2] = std::min( bbmin[2], cur_min[2]);
735  bbmax[0] = std::max( bbmax[0], cur_max[0]);
736  bbmax[1] = std::max( bbmax[0], cur_max[1]);
737  bbmax[2] = std::max( bbmax[0], cur_max[2]);
738  }
739 
740  }
741  }
742  //zoom to objects
743  ACG::Vec3d bbcenter = (bbmax + bbmin) * 0.5;
744 
745  double bbradius = (bbmax - bbmin).norm();
746 
747  ACG::Vec3d eye = bbcenter + (PluginFunctions::eyePos() - bbcenter).normalize() * bbradius ;
748 
749  PluginFunctions::flyTo(eye, bbcenter );
750 
751  }else{
752  //zoom to object
753  BaseObjectData* obj = dynamic_cast< BaseObjectData* >(item);
754 
755  if (obj){
756 
757  if ( !obj->visible() )
758  obj->show();
759 
760  ACG::Vec3d bbmin;
761  ACG::Vec3d bbmax;
762 
763  obj->getBoundingBox(bbmin, bbmax);
764 
765  if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
766  std::cerr << "Error while computing bounding box!";
767  return;
768  }
769 
770  ACG::Vec3d bbcenter = (bbmax + bbmin) * 0.5;
771 
772  double bbradius = (bbmax - bbmin).norm();
773 
774  ACG::Vec3d eye = bbcenter + (PluginFunctions::eyePos() - bbcenter).normalize() * bbradius ;
775 
776  PluginFunctions::flyTo(eye, bbcenter );
777  }
778  }
779  }
780 }
void hideAll()
Hides all objects.
LightSource * lightSource()
Definition: LightObject.cc:326
void disable()
disable LightSource
Definition: LightNode.cc:134
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
Definition: Types.cc:252
QList< BaseObject *> getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
Definition: BaseObject.cc:567
void showAll()
Shows all objects.
bool enabled() const
Get light source status.
Definition: LightNode.cc:137
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.
Definition: Popup.cc:634
QModelIndex popupIndex_
Index where a popup has been opened.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:445
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
Definition: Popup.cc:625
void clearAllTarget()
Unselect all objects.
const QStringList ALL_OBJECTS
Iterable object range.
void slotCopy()
Called by the popup menu to copy items.
Definition: Popup.cc:122
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:492
void setAllTarget()
Makes all available objects target.
int id() const
Definition: BaseObject.cc:190
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:517
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:313
bool dataType(DataType _type) const
Definition: BaseObject.cc:221
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:181
TreeModel * model_
The Treemodel organizing the data.
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:551
QTreeView * view_
Tree view.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObject.cc:723
void setAllSource()
Makes all available objects source.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
Definition: BaseObject.cc:730
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:179
void slotUngroup()
Called by the popup menu to ungroup items.
Definition: Popup.cc:105
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:534
void slotGroup()
Called by the popup menu to group items.
Definition: Popup.cc:152
void enable()
enable LightSource
Definition: LightNode.cc:131
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.
Definition: BaseObject.cc:619
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType)
Iterable object range.
Definition: Menu.hh:45
void slotZoomTo()
Called by the popup menu to zoom to an object.
Definition: Popup.cc:692
void clearAllSource()
remove source selection from all objects
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:573
#define DATA_LIGHT
Definition: Light.hh:58
int headerPopupType_
Defines the section of the Popup.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
Definition: Popup.cc:532
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.
Definition: Popup.cc:664
LightNode * lightNode()
Get the scenegraph Node.
Definition: LightObject.cc:227
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
Definition: Types.cc:212
ACG::SceneGraph::Material & material()
Get material object reference.
virtual bool visible() override
return visiblity
void slotRename()
Called by the popup menu to rename items.
Definition: Popup.cc:415
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.
Definition: Popup.cc:62