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  o_it != PluginFunctions::objectsEnd(); ++o_it)
326  if ( !types.contains( o_it->dataType() ) )
327  types.push_back( o_it->dataType() );
328 
329  QAction* action;
330 
331  switch (headerPopupType_) {
332 // case 0 :
333 // std::cerr << "0";
334 // break;
335  //Show / Hide
336  case 1 :
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() );
340 
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() ) );
345  }
346 
347  menu.addSeparator();
348  action = menu.addAction(tr("Hide all"),this,SLOT ( hideAll() ));
349  action->setData( QVariant() );
350 
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() ) );
355  }
356 
357  break;
358  // Source
359  case 2 :
360  action = menu.addAction(tr("Select all"),this,SLOT ( setAllSource() ));
361  action->setData( QVariant() );
362 
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() ) );
367  }
368 
369  menu.addSeparator();
370  action = menu.addAction(tr("Deselect all"),this,SLOT ( clearAllSource() ));
371  action->setData( QVariant() );
372 
373  if (types.count() > 1)
374  for (int i=0; i < types.count(); i++){
375  action = menu.addAction(icon, tr("Deselect all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( clearAllSource() ));
376  action->setData( QVariant( types[i].value() ) );
377  }
378 
379  break;
380  // Target
381  case 3 :
382  action = menu.addAction(tr("Select all"),this,SLOT ( setAllTarget() ));
383  action->setData( QVariant() );
384 
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() ) );
389  }
390 
391  menu.addSeparator();
392  action = menu.addAction(tr("Deselect all"),this,SLOT ( clearAllTarget() ));
393  action->setData( QVariant() );
394 
395  if (types.count() > 1)
396  for (int i=0; i < types.count(); i++){
397  action = menu.addAction(icon, tr("Deselect all of type '") + dataTypeName(types[i]) + "'",this,SLOT ( clearAllTarget() ));
398  action->setData( QVariant( types[i].value() ) );
399  }
400 
401  break;
402  default :
403 // std::cerr << "def";
404  break;
405  }
406 
407  menu.exec(viewHeader_->mapToGlobal( _pos ) );
408 }
409 
410 
411 //******************************************************************************
412 
417  QItemSelectionModel* selection = view_->selectionModel();
418 
419  // Get all selected rows
420  QModelIndexList indexList = selection->selectedRows ( 0 );
421  int selectedRows = indexList.size();
422  if (selectedRows == 1){
423  int id = model_->itemId( indexList[0]);
424  BaseObject* item = 0;
425 
426  if ( id != -1 && PluginFunctions::getObject(id,item) ){
427 
428  bool ok;
429  QString newName = QInputDialog::getText(0, tr("Rename"),
430  tr("Enter a new name:"), QLineEdit::Normal,
431  item->name(), &ok);
432  if (ok && !newName.isEmpty()){
433  item->setName(newName);
434  view_->resizeColumnToContents(0);
435  }
436  }
437  }
438 }
439 
440 
441 //******************************************************************************
442 
447  BaseObject* item = 0;
448 
449  //check if it was called from object contextMenu or from the toolBox
450  QAction* action = dynamic_cast< QAction* > ( sender() );
451 
452  if ( action ){
453  bool ok = false;
454 
455  int id = action->data().toInt(&ok);
456 
457  if ( ok && id > 0 )
459  }
460 
461  if ( item == 0 ){
462  // the slot was called from toolbox
463  QItemSelectionModel* selection = view_->selectionModel();
464 
465  // Get all selected rows
466  QModelIndexList indexList = selection->selectedRows ( 0 );
467  int selectedRows = indexList.size();
468  if (selectedRows == 1){
469  int id = model_->itemId( indexList[0] );
470 
471  if ( id > 0 )
473  }
474  }
475 
476  if ( item != 0 ){
477 
478  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
479  const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
480 
482  o_it != PluginFunctions::objectsEnd(); ++o_it) {
483 
484  MaterialNode * const materialNode = o_it->materialNode();
485  if (materialNode) {
486  materialNode->material() = sourceMaterial;
487  }
488  }
489 
490  emit updateView();
491  }
492 }
493 
495  BaseObject* item = 0;
496 
497  //check if it was called from object contextMenu or from the toolBox
498  QAction* action = dynamic_cast< QAction* > ( sender() );
499 
500  if ( action ){
501  bool ok = false;
502 
503  int id = action->data().toInt(&ok);
504 
505  if ( ok && id > 0 )
507  }
508 
509  if ( item == 0 ){
510  // the slot was called from toolbox
511  QItemSelectionModel* selection = view_->selectionModel();
512 
513  // Get all selected rows
514  QModelIndexList indexList = selection->selectedRows ( 0 );
515  int selectedRows = indexList.size();
516  if (selectedRows == 1){
517  int id = model_->itemId( indexList[0] );
518 
519  if ( id > 0 )
521  }
522  }
523 
524  if ( item != 0 ){
525 
526  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
527  const ACG::SceneGraph::Material &sourceMaterial = itemData->materialNode()->material();
528 
529  const QString materialJson = sourceMaterial.serializeToJson();
530  QApplication::clipboard()->setText(materialJson);
531  }
532 }
533 
535  BaseObject* item = 0;
536 
537  //check if it was called from object contextMenu or from the toolBox
538  QAction* action = dynamic_cast< QAction* > ( sender() );
539 
540  if ( action ){
541  bool ok = false;
542 
543  int id = action->data().toInt(&ok);
544 
545  if ( ok && id > 0 )
547  }
548 
549  if ( item == 0 ){
550  // the slot was called from toolbox
551  QItemSelectionModel* selection = view_->selectionModel();
552 
553  // Get all selected rows
554  QModelIndexList indexList = selection->selectedRows ( 0 );
555  int selectedRows = indexList.size();
556  if (selectedRows == 1){
557  int id = model_->itemId( indexList[0] );
558 
559  if ( id > 0 )
561  }
562  }
563 
564  if ( item != 0 ){
565 
566  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
567  ACG::SceneGraph::Material &destMaterial = itemData->materialNode()->material();
568 
569  destMaterial.deserializeFromJson(QApplication::clipboard()->text());
570 
571  emit updateView();
572  }
573 }
574 
576 
577  BaseObject* item = 0;
578 
579  //check if it was called from object contextMenu or from the toolBox
580  QAction* action = dynamic_cast< QAction* > ( sender() );
581 
582  if ( action ){
583  bool ok = false;
584 
585  int id = action->data().toInt(&ok);
586 
587  if ( ok && id > 0 )
589  }
590 
591  if ( item == 0 ){
592  // the slot was called from toolbox
593  QItemSelectionModel* selection = view_->selectionModel();
594 
595  // Get all selected rows
596  QModelIndexList indexList = selection->selectedRows ( 0 );
597  int selectedRows = indexList.size();
598  if (selectedRows == 1){
599  int id = model_->itemId( indexList[0] );
600 
601  if ( id > 0 )
603  }
604  }
605 
606  if ( item != 0 ){
607 
608  BaseObjectData* itemData = dynamic_cast< BaseObjectData* > (item);
609 
611 
612  dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
613 
614  connect(dialog, SIGNAL(signalNodeChanged(ACG::SceneGraph::BaseNode*)),
616 
617  dialog->setWindowIcon( QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png"));
618 
619  dialog->show();
620 
621  }
622 }
623 
624 
625 //******************************************************************************
626 
628  emit updateView();
629 }
630 
631 //******************************************************************************
632 
637 
638  QItemSelectionModel* selection = view_->selectionModel();
639 
640  // Get all selected rows
641  QModelIndexList indexList = selection->selectedRows ( 0 );
642  int selectedRows = indexList.size();
643  if (selectedRows == 1) {
644 
645  LightObject* light = 0;
646  int id = model_->itemId( indexList[0]);
647 
648  if (id == -1 || !PluginFunctions::getObject( id, light ) )
649  return;
650 
651  if(light == 0) return;
652 
653  light->lightSource()->enabled() ?
654  light->lightSource()->disable() :
655  light->lightSource()->enable();
656 
657  emit updatedObject(id, UPDATE_ALL);
658  }
659 }
660 
661 //******************************************************************************
662 
667 
668  QItemSelectionModel* selection = view_->selectionModel();
669 
670  // Get all selected rows
671  QModelIndexList indexList = selection->selectedRows ( 0 );
672  int selectedRows = indexList.size();
673  if (selectedRows == 1) {
674 
675  LightObject* light = 0;
676  int id = model_->itemId( indexList[0]);
677 
678  if (id == -1 || !PluginFunctions::getObject( id, light ) )
679  return;
680 
681  if(light == 0) return;
682 
683  LightWidget* widget = new LightWidget( light->lightNode() );
684  widget->setWindowFlags(Qt::WindowStaysOnTopHint);
685  widget->show();
686  }
687 }
688 
689 //******************************************************************************
690 
695  QItemSelectionModel* selection = view_->selectionModel();
696 
697  // Get all selected rows
698  QModelIndexList indexList = selection->selectedRows ( 0 );
699  int selectedRows = indexList.size();
700  if (selectedRows == 1){
701  BaseObject* item = 0;
702  int id = model_->itemId( indexList[0]);
703 
704  if (id == -1 || !PluginFunctions::getObject( id, item) )
705  return;
706 
707  if ( item->isGroup() ) {
708  //zoom to all objects in this group
709  QList< BaseObject* > children = item->getLeafs();
710 
711  //compute boundingBox
712  bool firstRound = true;
713  ACG::Vec3d bbmin(FLT_MAX,FLT_MAX,FLT_MAX);
714  ACG::Vec3d bbmax(FLT_MIN,FLT_MIN,FLT_MIN);
715 
716  for (int i=0; i < children.size(); i++){
717  BaseObjectData* child = dynamic_cast< BaseObjectData* > (children[i]);
718  if (child){
719 
720  if ( !child->visible() ){
721  child->show();
722  }
723 
724  ACG::Vec3d cur_min;
725  ACG::Vec3d cur_max;
726 
727  child->getBoundingBox(cur_min, cur_max);
728 
729  if (firstRound){
730  bbmin = cur_min;
731  bbmax = cur_max;
732  firstRound = false;
733  }else{
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]);
740  }
741 
742  }
743  }
744  //zoom to objects
745  ACG::Vec3d bbcenter = (bbmax + bbmin) * 0.5;
746 
747  double bbradius = (bbmax - bbmin).norm();
748 
749  ACG::Vec3d eye = bbcenter + (PluginFunctions::eyePos() - bbcenter).normalize() * bbradius ;
750 
751  PluginFunctions::flyTo(eye, bbcenter );
752 
753  }else{
754  //zoom to object
755  BaseObjectData* obj = dynamic_cast< BaseObjectData* >(item);
756 
757  if (obj){
758 
759  if ( !obj->visible() )
760  obj->show();
761 
762  ACG::Vec3d bbmin;
763  ACG::Vec3d bbmax;
764 
765  obj->getBoundingBox(bbmin, bbmax);
766 
767  if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2])){
768  std::cerr << "Error while computing bounding box!";
769  return;
770  }
771 
772  ACG::Vec3d bbcenter = (bbmax + bbmin) * 0.5;
773 
774  double bbradius = (bbmax - bbmin).norm();
775 
776  ACG::Vec3d eye = bbcenter + (PluginFunctions::eyePos() - bbcenter).normalize() * bbradius ;
777 
778  PluginFunctions::flyTo(eye, bbcenter );
779  }
780  }
781  }
782 }
virtual void show()
Sets the whole Scenegraph subtree of this node to visible.
void hideAll()
Hides all objects.
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:575
bool isGroup() const
Check if object is a group.
Definition: BaseObject.cc:619
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void setAllSource()
Makes all available objects source.
void slotGroup()
Called by the popup menu to group items.
Definition: Popup.cc:152
void slotRename()
Called by the popup menu to rename items.
Definition: Popup.cc:416
QModelIndex popupIndex_
Index where a popup has been opened.
QHeaderView * viewHeader_
Pointer to the header to the view widget.
TreeModel * model_
The Treemodel organizing the data.
void showAll()
Shows all objects.
LightSource * lightSource()
Definition: LightObject.cc:326
MaterialNode * materialNode()
get a pointer to the materialnode
int id() const
Definition: BaseObject.cc:190
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:525
void enable()
enable LightSource
Definition: LightNode.cc:131
void setAllTarget()
Makes all available objects target.
void slotNodeChanged(ACG::SceneGraph::BaseNode *_node)
Called when the material properties were changed inside the material dialog.
Definition: Popup.cc:627
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:508
bool dataType(DataType _type) const
Definition: BaseObject.cc:221
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:446
void slotEditLight()
Called by the popup menu in order to edit lights.
Definition: Popup.cc:666
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
Definition: Popup.cc:534
const QStringList ALL_OBJECTS
Iterable object range.
void slotSwitchLight()
Called by the popup menu in order to turn lights on/off.
Definition: Popup.cc:636
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:542
void slotCopy()
Called by the popup menu to copy items.
Definition: Popup.cc:122
int headerPopupType_
Defines the section of the Popup.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
Definition: BaseObject.cc:730
int groupObjects(IdList _objectIDs, QString _groupName="")
Group given Objects together.
DLLEXPORT QIcon & typeIcon(DataType _id)
Get an QIcon associated with the given DataType.
Definition: Types.cc:212
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
void disable()
disable LightSource
Definition: LightNode.cc:134
void clearAllSource()
remove source selection from all objects
void slotUngroup()
Called by the popup menu to ungroup items.
Definition: Popup.cc:105
void getBoundingBox(ACG::Vec3d &bbmin, ACG::Vec3d &bbmax)
get the bounding box of the object
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Definition: Popup.cc:62
QTreeView * view_
Tree view.
#define DATA_LIGHT
Definition: Light.hh:58
bool enabled() const
Get light source status.
Definition: LightNode.cc:137
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:313
void flyTo(const ACG::Vec3d &_position, const ACG::Vec3d &_center, double _time)
Fly to point and viewing direction (animated).
void clearAllTarget()
Unselect all objects.
LightNode * lightNode()
Get the scenegraph Node.
Definition: LightObject.cc:227
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
QList< BaseObject *> getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
Definition: BaseObject.cc:567
ACG::SceneGraph::Material & material()
Get material object reference.
void slotZoomTo()
Called by the popup menu to zoom to an object.
Definition: Popup.cc:694
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObject.cc:723
virtual bool visible()
return visiblity
Definition: Menu.hh:45
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:179
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:494
DLLEXPORT QString dataTypeName(DataType _id)
Get DataType Human readable name ( this name might change. Use the typeName instead! ) ...
Definition: Types.cc:252