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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 
51 
52 
53 #include "DataControlPlugin.hh"
54 
55 #include <ACG/QtWidgets/QtMaterialDialog.hh>
56 
57 #include "Menu.hh"
58 
59 #include <ObjectTypes/Light/LightWidget.hh>
60 
61 //******************************************************************************
62 
67 
68  QItemSelectionModel* selection = view_->selectionModel();
69 
70  if (selection == 0) return;
71 
72  // Get all selected rows
73  QModelIndexList indexList = selection->selectedRows();
74 
75 
76  QMessageBox msgBox;
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);
80 
81  QString text;
82 
83  for ( int i = 0 ; i < indexList.size() ; ++i)
84  text += model_->itemName( indexList[i] ) + "\n";
85 
86  msgBox.setDetailedText(text);
87 
88  if ( msgBox.exec() == QMessageBox::No)
89  return;
90 
91  for ( int i = 0 ; i < indexList.size() ; ++i) {
92 
93  int id = model_->itemId( indexList[i] );
94 
95 
96  if ( id != -1 )
97  emit deleteObject( id );
98  }
99 
100  emit updateView();
101 }
102 
103 
104 //******************************************************************************
105 
110  QItemSelectionModel* selection = view_->selectionModel();
111 
112  // Get all selected rows
113  QModelIndexList indexList = selection->selectedRows ( 0 );
114 
115  //get the object
116  int id = model_->itemId( indexList[0] );
117  unGroupObject(id);
118 }
119 
120 
121 //******************************************************************************
122 
127  QItemSelectionModel* selection = view_->selectionModel();
128 
129  if (selection == 0) return;
130 
131  // Get all selected rows
132  QModelIndexList indexList = selection->selectedRows();
133 
134  for ( int i = 0 ; i < indexList.size() ; ++i) {
135 
136  int id = model_->itemId( indexList[i] );
137 
138  if ( id > 0){
139 
140  int newObject;
141 
142  emit copyObject( id, newObject );
143  }
144 
145  }
146 
147  emit updateView();
148 }
149 
150 
151 //******************************************************************************
152 
157 
158  QItemSelectionModel* selection = view_->selectionModel();
159 
160  // Get all selected rows
161  QModelIndexList indexList = selection->selectedRows ( 0 );
162 
163 
164  //get object ids
165  IdList ids;
166  for (int i = 0; i < indexList.size(); ++i)
167  ids.push_back( model_->itemId(indexList[i]) );
168 
169 
170  //group all objects
171  groupObjects(ids);
172  emit objectsGrouped(ids);
173 
174 }
175 
176 
177 //******************************************************************************
178 
184  popupIndex_ = view_->indexAt(_pos);
185 
186  if (!popupIndex_.isValid())
187  return;
188 
190 
191 
192  QItemSelectionModel* selection = view_->selectionModel();
193 
194  // Get all selected rows
195  QModelIndexList indexList = selection->selectedRows ( 0 );
196  int selectedRows = indexList.size();
197 
198  Menu menu(0);
199  QAction* action;
200  QIcon icon;
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() ));
206  menu.addSeparator();
207  menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
208  }else
209  // check if the item is a group item
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() ));
215  menu.addSeparator();
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);
219  menu.addSeparator();
220  action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
221  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
222  action->setIcon(icon);
223  } else {
224 
225  //show object name and id in first entry of the menu
226  int id = model_->itemId( indexList[0] );
227  BaseObject* item = 0;
228  if ( id != -1 && PluginFunctions::getObject(id,item) ) {
229  QAction* header = menu.addAction(tr("Object ")+QString::number(id)+": "+item->name());
230  header->setIcon( typeIcon(item->dataType()) );
231  }
232 
233  menu.addSeparator();
234 
235  if(item->dataType() == DATA_LIGHT) {
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);
242  action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
243  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
244  action->setIcon(icon);
245  menu.addSeparator();
246 
247  LightObject* light = 0;
248  if ( item->id() != -1 && PluginFunctions::getObject( item->id(), light ) ) {
249  if (light != 0 && !light->lightSource()->enabled()) {
250 
251  action = menu.addAction(tr("Switch On"),this,SLOT ( slotSwitchLight() ));
252  icon = typeIcon(DATA_LIGHT);
253  }
254  }
255  if (light == 0 || light->lightSource()->enabled())
256  {
257  action = menu.addAction(tr("Switch Off"),this,SLOT ( slotSwitchLight() ));
258  icon = QIcon (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"LightOff.png");
259  }
260  action->setIcon(icon);
261 
262  action = menu.addAction(tr("Edit Light"),this,SLOT ( slotEditLight() ));
263  icon = typeIcon(DATA_LIGHT);
264  action->setIcon(icon);
265 
266  } else {
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);
270 
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);
274 
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);
278 
279  action = menu.addAction(tr("Material Properties"),this,SLOT ( slotMaterialProperties() ));
280  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
281  action->setIcon(icon);
282 
283  action = menu.addAction(tr("Copy Material Properties to Targeted Objects"), this, SLOT ( slotCopyMaterialToTargeted() ));
284  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-copyToTargets-material.png");
285  action->setIcon(icon);
286 
287  action = menu.addAction(tr("Copy Material Properties to Clipboard"), this, SLOT ( slotCopyMaterialToClipboard() ));
288  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-copy-material.png");
289  action->setIcon(icon);
290 
291  action = menu.addAction(tr("Paste Material Properties from Clipboard"), this, SLOT ( slotPasteMaterialFromClipboard() ));
292  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-paste-material.png");
293  action->setIcon(icon);
294 
295  menu.addAction(tr("Group"),this,SLOT ( slotGroup() ));
296 
297  menu.addSeparator();
298  action = menu.addAction(tr("Remove"),this,SLOT ( slotPopupRemove() ));
299  icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
300  action->setIcon(icon);
301  }
302  }
303 
304 
305 
306  menu.exec(view_->mapToGlobal( _pos) );
307 
308 }
309 
310 
311 //******************************************************************************
312 
318 
319  headerPopupType_ = viewHeader_->logicalIndexAt( _pos );
320 
321  QMenu menu(0);
322 
323  QIcon icon;
324 
325  //get all used types
326  QVector<DataType> types;
327 
329  o_it != PluginFunctions::objectsEnd(); ++o_it)
330  if ( !types.contains( o_it->dataType() ) )
331  types.push_back( o_it->dataType() );
332 
333  QAction* action;
334 
335  switch (headerPopupType_) {
336 // case 0 :
337 // std::cerr << "0";
338 // break;
339  //Show / Hide
340  case 1 :
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() );
344 
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() ) );
349  }
350 
351  menu.addSeparator();
352  action = menu.addAction(tr("Hide all"),this,SLOT ( hideAll() ));
353  action->setData( QVariant() );
354 
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() ) );
359  }
360 
361  break;
362  // Source
363  case 2 :
364  action = menu.addAction(tr("Select all"),this,SLOT ( setAllSource() ));
365  action->setData( QVariant() );
366 
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() ) );
371  }
372 
373  menu.addSeparator();
374  action = menu.addAction(tr("Deselect all"),this,SLOT ( clearAllSource() ));
375  action->setData( QVariant() );
376 
377  if (types.count() > 1)
378  for (int i=0; i < types.count(); i++){
379  action = menu.addAction(icon, tr("Deselect all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( clearAllSource() ));
380  action->setData( QVariant( types[i].value() ) );
381  }
382 
383  break;
384  // Target
385  case 3 :
386  action = menu.addAction(tr("Select all"),this,SLOT ( setAllTarget() ));
387  action->setData( QVariant() );
388 
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() ) );
393  }
394 
395  menu.addSeparator();
396  action = menu.addAction(tr("Deselect all"),this,SLOT ( clearAllTarget() ));
397  action->setData( QVariant() );
398 
399  if (types.count() > 1)
400  for (int i=0; i < types.count(); i++){
401  action = menu.addAction(icon, tr("Deselect all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( clearAllTarget() ));
402  action->setData( QVariant( types[i].value() ) );
403  }
404 
405  break;
406  default :
407 // std::cerr << "def";
408  break;
409  }
410 
411  menu.exec(viewHeader_->mapToGlobal( _pos ) );
412 }
413 
414 
415 //******************************************************************************
416 
421  QItemSelectionModel* selection = view_->selectionModel();
422 
423  // Get all selected rows
424  QModelIndexList indexList = selection->selectedRows ( 0 );
425  int selectedRows = indexList.size();
426  if (selectedRows == 1){
427  int id = model_->itemId( indexList[0]);
428  BaseObject* item = 0;
429 
430  if ( id != -1 && PluginFunctions::getObject(id,item) ){
431 
432  bool ok;
433  QString newName = QInputDialog::getText(0, tr("Rename"),
434  tr("Enter a new name:"), QLineEdit::Normal,
435  item->name(), &ok);
436  if (ok && !newName.isEmpty()){
437  item->setName(newName);
438  view_->resizeColumnToContents(0);
439  }
440  }
441  }
442 }
443 
444 
445 //******************************************************************************
446 
451  BaseObject* item = 0;
452 
453  //check if it was called from object contextMenu or from the toolBox
454  QAction* action = dynamic_cast< QAction* > ( sender() );
455 
456  if ( action ){
457  bool ok = false;
458 
459  int id = action->data().toInt(&ok);
460 
461  if ( ok && id > 0 )
463  }
464 
465  if ( item == 0 ){
466  // the slot was called from toolbox
467  QItemSelectionModel* selection = view_->selectionModel();
468 
469  // Get all selected rows
470  QModelIndexList indexList = selection->selectedRows ( 0 );
471  int selectedRows = indexList.size();
472  if (selectedRows == 1){
473  int id = model_->itemId( indexList[0] );
474 
475  if ( id > 0 )
477  }
478  }
479 
480  if ( item != 0 ){
481 
482  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
483  const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
484 
486  o_it != PluginFunctions::objectsEnd(); ++o_it) {
487 
488  MaterialNode * const materialNode = o_it->materialNode();
489  if (materialNode) {
490  materialNode->material() = sourceMaterial;
491  }
492  }
493 
494  emit updateView();
495  }
496 }
497 
499  BaseObject* item = 0;
500 
501  //check if it was called from object contextMenu or from the toolBox
502  QAction* action = dynamic_cast< QAction* > ( sender() );
503 
504  if ( action ){
505  bool ok = false;
506 
507  int id = action->data().toInt(&ok);
508 
509  if ( ok && id > 0 )
511  }
512 
513  if ( item == 0 ){
514  // the slot was called from toolbox
515  QItemSelectionModel* selection = view_->selectionModel();
516 
517  // Get all selected rows
518  QModelIndexList indexList = selection->selectedRows ( 0 );
519  int selectedRows = indexList.size();
520  if (selectedRows == 1){
521  int id = model_->itemId( indexList[0] );
522 
523  if ( id > 0 )
525  }
526  }
527 
528  if ( item != 0 ){
529 
530  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
531  const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
532 
533  const QString materialJson = sourceMaterial.serializeToJson();
534  QApplication::clipboard()->setText(materialJson);
535  }
536 }
537 
539  BaseObject* item = 0;
540 
541  //check if it was called from object contextMenu or from the toolBox
542  QAction* action = dynamic_cast< QAction* > ( sender() );
543 
544  if ( action ){
545  bool ok = false;
546 
547  int id = action->data().toInt(&ok);
548 
549  if ( ok && id > 0 )
551  }
552 
553  if ( item == 0 ){
554  // the slot was called from toolbox
555  QItemSelectionModel* selection = view_->selectionModel();
556 
557  // Get all selected rows
558  QModelIndexList indexList = selection->selectedRows ( 0 );
559  int selectedRows = indexList.size();
560  if (selectedRows == 1){
561  int id = model_->itemId( indexList[0] );
562 
563  if ( id > 0 )
565  }
566  }
567 
568  if ( item != 0 ){
569 
570  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
571  ACG::SceneGraph::Material &destMaterial = itemData->materialNode()->material();
572 
573  destMaterial.deserializeFromJson(QApplication::clipboard()->text());
574 
575  emit updateView();
576  }
577 }
578 
580 
581  BaseObject* item = 0;
582 
583  //check if it was called from object contextMenu or from the toolBox
584  QAction* action = dynamic_cast< QAction* > ( sender() );
585 
586  if ( action ){
587  bool ok = false;
588 
589  int id = action->data().toInt(&ok);
590 
591  if ( ok && id > 0 )
593  }
594 
595  if ( item == 0 ){
596  // the slot was called from toolbox
597  QItemSelectionModel* selection = view_->selectionModel();
598 
599  // Get all selected rows
600  QModelIndexList indexList = selection->selectedRows ( 0 );
601  int selectedRows = indexList.size();
602  if (selectedRows == 1){
603  int id = model_->itemId( indexList[0] );
604 
605  if ( id > 0 )
607  }
608  }
609 
610  if ( item != 0 ){
611 
612  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
613 
615 
616  dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
617 
618  connect(dialog, SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
620 
621  dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png"));
622 
623  dialog->show();
624 
625  }
626 }
627 
628 
629 //******************************************************************************
630 
632  emit updateView();
633 }
634 
635 //******************************************************************************
636 
641 
642  QItemSelectionModel* selection = view_->selectionModel();
643 
644  // Get all selected rows
645  QModelIndexList indexList = selection->selectedRows ( 0 );
646  int selectedRows = indexList.size();
647  if (selectedRows == 1) {
648 
649  LightObject* light = 0;
650  int id = model_->itemId( indexList[0]);
651 
652  if (id == -1 || !PluginFunctions::getObject( id, light ) )
653  return;
654 
655  if(light == 0) return;
656 
657  light->lightSource()->enabled() ?
658  light->lightSource()->disable() :
659  light->lightSource()->enable();
660 
661  emit updatedObject(id, UPDATE_ALL);
662  }
663 }
664 
665 //******************************************************************************
666 
671 
672  QItemSelectionModel* selection = view_->selectionModel();
673 
674  // Get all selected rows
675  QModelIndexList indexList = selection->selectedRows ( 0 );
676  int selectedRows = indexList.size();
677  if (selectedRows == 1) {
678 
679  LightObject* light = 0;
680  int id = model_->itemId( indexList[0]);
681 
682  if (id == -1 || !PluginFunctions::getObject( id, light ) )
683  return;
684 
685  if(light == 0) return;
686 
687  LightWidget* widget = new LightWidget( light->lightNode() );
688  widget->setWindowFlags(Qt::WindowStaysOnTopHint);
689  widget->show();
690  }
691 }
692 
693 //******************************************************************************
694 
699  QItemSelectionModel* selection = view_->selectionModel();
700 
701  // Get all selected rows
702  QModelIndexList indexList = selection->selectedRows ( 0 );
703  int selectedRows = indexList.size();
704  if (selectedRows == 1){
705  BaseObject* item = 0;
706  int id = model_->itemId( indexList[0]);
707 
708  if (id == -1 || !PluginFunctions::getObject( id, item) )
709  return;
710 
711  if ( item->isGroup() ) {
712  //zoom to all objects in this group
713  QList< BaseObject* > children = item->getLeafs();
714 
715  //compute boundingBox
716  bool firstRound = true;
717  ACG::Vec3d bbmin(FLT_MAX,FLT_MAX,FLT_MAX);
718  ACG::Vec3d bbmax(FLT_MIN,FLT_MIN,FLT_MIN);
719 
720  for (int i=0; i < children.size(); i++){
721  BaseObjectData* child = dynamic_cast< BaseObjectData* > (children[i]);
722  if (child){
723 
724  if ( !child->visible() ){
725  child->show();
726  }
727 
728  ACG::Vec3d cur_min;
729  ACG::Vec3d cur_max;
730 
731  child->getBoundingBox(cur_min, cur_max);
732 
733  if (firstRound){
734  bbmin = cur_min;
735  bbmax = cur_max;
736  firstRound = false;
737  }else{
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]);
744  }
745 
746  }
747  }
748  //zoom to objects
749  ACG::Vec3d bbcenter = (bbmax + bbmin) * 0.5;
750 
751  double bbradius = (bbmax - bbmin).norm();
752 
753  ACG::Vec3d eye = bbcenter + (PluginFunctions::eyePos() - bbcenter).normalize() * bbradius ;
754 
755  PluginFunctions::flyTo(eye, bbcenter );
756 
757  }else{
758  //zoom to object
759  BaseObjectData* obj = dynamic_cast< BaseObjectData* >(item);
760 
761  if (obj){
762 
763  if ( !obj->visible() )
764  obj->show();
765 
766  ACG::Vec3d bbmin;
767  ACG::Vec3d bbmax;
768 
769  obj->getBoundingBox(bbmin, bbmax);
770 
771  if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
772  std::cerr << "Error while computing bounding box!";
773  return;
774  }
775 
776  ACG::Vec3d bbcenter = (bbmax + bbmin) * 0.5;
777 
778  double bbradius = (bbmax - bbmin).norm();
779 
780  ACG::Vec3d eye = bbcenter + (PluginFunctions::eyePos() - bbcenter).normalize() * bbradius ;
781 
782  PluginFunctions::flyTo(eye, bbcenter );
783  }
784  }
785  }
786 }
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:552
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:579
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:450
void enable()
enable LightSource
Definition: LightNode.cc:137
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:535
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
LightNode * lightNode()
Get the scenegraph Node.
Definition: LightObject.cc:229
int headerPopupType_
Defines the section of the Popup.
void slotZoomTo()
Called by the popup menu to zoom to an object.
Definition: Popup.cc:698
ACG::SceneGraph::Material & material()
Get material object reference.
bool getObject(int _identifier, BSplineCurveObject *&_object)
LightSource * lightSource()
Definition: LightObject.cc:328
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
Definition: Popup.cc:640
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
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.
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
Definition: Types.cc:263
void showAll()
Shows all objects.
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
virtual bool visible()
return visiblity
int id() const
Definition: BaseObject.cc:201
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.
Definition: Popup.cc:631
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:317
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).
#define DATA_LIGHT
Definition: Light.hh:64
void disable()
disable LightSource
Definition: LightNode.cc:140
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.
Definition: Popup.cc:538
void clearAllTarget()
Unselect all objects.
Definition: Menu.hh:53
void slotGroup()
Called by the popup menu to group items.
Definition: Popup.cc:156
QTreeView * view_
Tree view.
bool isGroup() const
Check if object is a group.
Definition: BaseObject.cc:630
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
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 ) ...
Definition: BaseObject.cc:578
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:183
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.
Definition: BaseObject.cc:741
void slotRename()
Called by the popup menu to rename items.
Definition: Popup.cc:420
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:518
void slotUngroup()
Called by the popup menu to ungroup items.
Definition: Popup.cc:109
void slotCopy()
Called by the popup menu to copy items.
Definition: Popup.cc:126
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void slotEditLight()
Called by the popup menu in order to edit lights.
Definition: Popup.cc:670
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.
Definition: Types.cc:223
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Definition: Popup.cc:66
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:498
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 "." )
Definition: BaseObject.cc:734
bool enabled() const
Get light source status.
Definition: LightNode.cc:143