Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataControlPlugin.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 #include "DataControlPlugin.hh"
51 
52 #if QT_VERSION >= 0x050000
53 #else
54  #include <QtGui>
55 #endif
56 
57 #include <ACG/QtWidgets/QtMaterialDialog.hh>
58 
59 #include <queue>
60 
61 //******************************************************************************
62 
63 const ACG::Vec4f base_color (0.0f,0.0f,0.5f,1.0f);
64 const ACG::Vec4f source_color (0.5f,0.0f,0.0f,1.0f);
65 const ACG::Vec4f target_color (0.0f,0.5f,0.2f,1.0f);
66 
67 //******************************************************************************
68 
69 
70 
72  tool_(0),
73  toolIcon_(0),
74  MeshDialogLayout_(0),
75  objectList_(0),
76  locked(false),
77  model_(0),
78  view_(0),
79  viewHeader_(0),
80  onlyDown_(0),
81  onlyUp_(0),
82  columnFromGUI_(-1),
83  headerPopupType_(0),
84  targetAction_(0),
85  sourceAction_(0),
86  removeAction_(0),
87  advancedSettingsBtn_(0)
88 {
89 
90 }
91 
92 
97 
98  //set the slot descriptions
100 
101  if ( ! OpenFlipper::Options::gui())
102  return;
103 
104  QMenu* contextMenu = new QMenu("Object");
105 
106  //Target Objects
107  QIcon icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-hide-object.png");
108  QAction* hideAction = new QAction(icon, tr("&Hide"), this);
109  hideAction->setStatusTip(tr("Hide object"));
110  connect(hideAction, SIGNAL(triggered()), this, SLOT(slotContextMenuHide()) );
111  contextMenu->addAction(hideAction);
112 
113  //Target Objects
114  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-target-object.png");
115  targetAction_ = new QAction(icon, tr("&Target"), this);
116  targetAction_->setCheckable(true);
117  targetAction_->setStatusTip(tr("Set object as target"));
118  connect(targetAction_, SIGNAL(triggered()), this, SLOT(slotContextMenuTarget()) );
119  contextMenu->addAction(targetAction_);
120 
121  //Source Objects
122  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-source-object.png");
123  sourceAction_ = new QAction(icon, tr("&Source"), this);
124  sourceAction_->setCheckable(true);
125  sourceAction_->setStatusTip(tr("Set object as source"));
126  connect(sourceAction_, SIGNAL(triggered()), this, SLOT(slotContextMenuSource()) );
127  contextMenu->addAction(sourceAction_);
128 
129  contextMenu->addSeparator();
130 
131  //Remove Objects
132  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-delete-item.png");
133  removeAction_ = new QAction(icon, tr("&Remove"), this);
134  removeAction_->setCheckable(false);
135  removeAction_->setStatusTip(tr("Remove object"));
136  connect(removeAction_, SIGNAL(triggered()), this, SLOT(slotContextMenuRemove()) );
137  contextMenu->addAction(removeAction_);
138 
139  emit addContextMenuItem(contextMenu->menuAction() , DATA_ALL , CONTEXTOBJECTMENU);
140 
141  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-material.png");
142  QAction* material = new QAction(icon, tr("Material Properties"), 0);
143  connect (material, SIGNAL( triggered() ), this, SLOT ( slotMaterialProperties() ));
144  emit addContextMenuItem(material , DATA_ALL , CONTEXTOBJECTMENU);
145 
146  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-copyToTargets-material.png");
147  QAction* copyMaterial = new QAction(icon, tr("Copy Material Properties to Targeted Objects"), 0);
148  connect (copyMaterial, SIGNAL( triggered() ), this, SLOT ( slotCopyMaterialToTargeted() ));
149  emit addContextMenuItem(copyMaterial , DATA_ALL , CONTEXTOBJECTMENU);
150 
151  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-copy-material.png");
152  QAction* copyMaterialToClipboard = new QAction(icon, tr("Copy Material Properties to Clipboard"), 0);
153  connect (copyMaterialToClipboard, SIGNAL( triggered() ), this, SLOT ( slotCopyMaterialToClipboard() ));
154  emit addContextMenuItem(copyMaterialToClipboard , DATA_ALL , CONTEXTOBJECTMENU);
155 
156  icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-paste-material.png");
157  QAction* pasteMaterialFromClipboard = new QAction(icon, tr("Paste Material Properties from Clipboard"), 0);
158  connect (pasteMaterialFromClipboard, SIGNAL( triggered() ), this, SLOT ( slotPasteMaterialFromClipboard() ));
159  emit addContextMenuItem(pasteMaterialFromClipboard , DATA_ALL , CONTEXTOBJECTMENU);
160 
163 
164  connect(tool_->lightSources, SIGNAL(toggled(bool)), this, SLOT(slotShowLightSources(bool)));
165  //update light visibility, if layout was changed
166  connect(model_, SIGNAL(layoutChanged ()), this, SLOT(slotShowLightSources()) );
167  connect(model_, SIGNAL(rowsRemoved(const QModelIndex& , int , int )), this, SLOT(slotShowLightSources()));
168 }
169 
170 
171 //******************************************************************************
172 
173 void DataControlPlugin::initializePlugin()
174 {
175  if ( ! OpenFlipper::Options::gui())
176  return;
177 
179  connect( tool_ , SIGNAL( keyEvent( QKeyEvent* ) ),
180  this , SLOT(slotKeyEvent ( QKeyEvent* ) ));
181  QSize size(300, 300);
182  tool_->resize(size);
183 
184  model_ = new TreeModel( );
185 
186  view_ = tool_->treeView;
187 
188  tool_->treeView->setModel(model_);
189 
190  view_->QTreeView::resizeColumnToContents(1);
191  view_->QTreeView::resizeColumnToContents(2);
192  view_->QTreeView::resizeColumnToContents(3);
193 
194 
195  connect( model_,SIGNAL(dataChangedInside(int,int,const QVariant&) ),
196  this, SLOT( slotDataChanged(int,int,const QVariant&)) );
197 
198  connect( model_,SIGNAL( moveBaseObject(int,int) ),
199  this, SLOT( slotMoveBaseObject(int,int) ) );
200 
201  connect( view_,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
202  this,SLOT(slotCustomContextMenuRequested ( const QPoint & ) ));
203 
204  connect( tool_->notSelected, SIGNAL(toggled ( bool ) ),
205  this, SLOT (slotBoundingBoxChange ( ) ));
206  connect( tool_->sourceSelected, SIGNAL(toggled ( bool ) ),
207  this, SLOT (slotBoundingBoxChange ( ) ));
208  connect( tool_->targetSelected, SIGNAL(toggled ( bool ) ),
209  this, SLOT (slotBoundingBoxChange ( ) ));
210 
211 
212  viewHeader_ = tool_->treeView->header();
213  viewHeader_->setContextMenuPolicy(Qt::CustomContextMenu);
214 
215  // connect the slot for the context menu
216  connect( viewHeader_, SIGNAL(customContextMenuRequested ( const QPoint & ) ),
217  this, SLOT(slotHeaderCustomContextMenuRequested ( const QPoint & ) ));
218 
219  toolIcon_ = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-toolbox.png");
220 
221  QWidget *headerAreaWidget = new QWidget();
222  advancedSettingsBtn_ = new QToolButton();
223  advancedSettingsBtn_->setAutoRaise(true);
224  advancedSettingsBtn_->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"preferences.png"));
225  advancedSettingsBtn_->setIconSize(QSize(16, 16));
226  advancedSettingsBtn_->setPopupMode(QToolButton::InstantPopup);
227  advancedSettingsBtn_->setToolTip(tr("Advanced Settings"));
228  QHBoxLayout *hl = new QHBoxLayout;
229  hl->addWidget(advancedSettingsBtn_);
230  hl->addStretch(1);
231  hl->setContentsMargins(8, 0, 0, 0);
232  headerAreaWidget->setLayout(hl);
233 
234  QMenu *menu = new QMenu();
235  menu->addAction(tool_->lightSources);
236  menu->addAction(tool_->notSelected);
237  menu->addAction(tool_->sourceSelected);
238  menu->addAction(tool_->targetSelected);
239  advancedSettingsBtn_->setMenu(menu);
240 
241  emit addToolbox("Data Control", tool_, toolIcon_, headerAreaWidget);
242 }
243 
244 
245 //******************************************************************************
246 
251 {
252  if ( ! OpenFlipper::Options::gui())
253  return;
254 
255  BaseObjectData* obj = 0;
256 
257  if ( PluginFunctions::getObject( _identifier, obj) )
258  updateBoundingBox (obj);
259 
260  BaseObject* object = 0;
261  if ( !PluginFunctions::getObject( _identifier, object) )
262  return;
263 
264  //check for changes
265  int column = columnFromGUI_;//if GUI has set the column, use this information
266  if (column == -1)//otherwise, try to get the column
267  {
268  TreeItem* item = model_->getItem(_identifier);
269  if ( !item )
270  return;
271 
272  if (item->source() != object->source())
273  column = 2;
274  else if (item->target() != object->target())
275  column = 3;
276  else
277  return;//could not decide, which column needs a update, discard
278  }
279 
280 
281  model_->objectChanged( _identifier );
282 
283  //block scenegraph reset and redraw in core
284  OpenFlipper::Options::blockSceneGraphUpdates();
285  OpenFlipper::Options::redrawDisabled(true);
286 
287  // if we are allowed to propagate down
288  if ( onlyUp_ == 0 ){
289 
290  onlyDown_++;
291 
292  if ( object->isGroup() )
293  propagateDownwards(object, column); // 2: source 3: target
294 
295  onlyDown_--;
296  }
297 
298  // if we are allowed to propagate up
299  if ( onlyDown_ == 0 ){
300 
301  onlyUp_++;
302 
303  propagateUpwards(object->parent(), column); // 2: source 3: target
304 
305  onlyUp_--;
306  }
307 
308  OpenFlipper::Options::unblockSceneGraphUpdates();
309  OpenFlipper::Options::redrawDisabled(false);
310  emit updateView();
311 }
312 
313 
314 //******************************************************************************
315 
321 
322  if ( ! OpenFlipper::Options::gui())
323  return;
324 
325  // if onlyUp_ > 0 --> _identifier is a group and the selection
326  // does not have to be applied
327  if (onlyUp_ == 0){
328  //inform the model
329  model_->objectChanged( _identifier );
330  }
331 
332  //check for changes in the tree
333  BaseObject* obj = 0;
334 
335  //block scenegraph reset and redraw in core
336  OpenFlipper::Options::blockSceneGraphUpdates();
337  OpenFlipper::Options::redrawDisabled(true);
338 
339  if ( PluginFunctions::getObject( _identifier, obj) ){
340 
341  // if we are allowed to propagate up
342  if ( onlyDown_ == 0 ){
343 
344  onlyUp_++;
345 
346  propagateUpwards(obj->parent(), 1); // 1 = visibilty
347 
348  onlyUp_--;
349 
350  }
351 
352  // if we are allowed to propagate down
353  if ( onlyUp_ == 0 ){
354 
355  onlyDown_++;
356 
357  if ( obj->isGroup() )
358  propagateDownwards(obj, 1); // 1 = visibilty
359 
360  onlyDown_--;
361  }
362  }
363 
364  OpenFlipper::Options::unblockSceneGraphUpdates();
365  OpenFlipper::Options::redrawDisabled(false);
366 
367  BaseObjectData* object = 0;
368 
369  if ( PluginFunctions::getObject( _identifier, object) )
370  updateBoundingBox (object);
371 
372  emit updateView();
373 
374 }
375 
376 
377 //******************************************************************************
378 
384 
385  if ( ! OpenFlipper::Options::gui())
386  return;
387 
388  model_->objectChanged( _identifier );
389 }
390 
391 
392 //******************************************************************************
393 
399 
400  if ( ! OpenFlipper::Options::gui())
401  return;
402 
403  BaseObject* obj = 0;
404 
405  if ( PluginFunctions::getObject(_id, obj) ) {
406  model_->objectAdded(obj);
407 
408  // Only if the added object was a light source, we will traverse the objects!
409  if ( obj->dataType() == DATA_LIGHT)
410  slotShowLightSources(tool_->lightSources->isChecked());
411 
412  view_->resizeColumnToContents(0);
413  }
414 }
415 
416 
417 //******************************************************************************
418 
424  fileOpened(_id);
425 }
426 
427 //******************************************************************************
428 
434 
435  if ( ! OpenFlipper::Options::gui())
436  return;
437 
438  model_->objectDeleted(_id);
439 }
440 
441 //******************************************************************************
442 
447 void DataControlPlugin::slotKeyEvent( QKeyEvent* _event )
448 {
449 
450  if ( _event->modifiers() == Qt::ControlModifier ) {
451  switch (_event->key()) {
452  case Qt::Key_A :
453  setAllTarget();
454  return;
455  default:
456  return;
457  }
458  }
459 
460  switch (_event->key()) {
461  case Qt::Key_Delete :
462  slotPopupRemove();
463  return;
464  default:
465  return;
466  }
467 
468 }
469 
470 
471 //******************************************************************************
472 
479 void DataControlPlugin::slotDataChanged ( int _id, int _column, const QVariant& _value)
480 {
481 
482  //get the corresponding baseObject
483  BaseObject* obj = 0;
484  if ( !PluginFunctions::getObject( _id, obj) )
485  return;
486 
487  switch ( _column ) {
488  // Name
489  case 0:
490  obj->setName( _value.toString() );
491  break;
492 
493  // show/hide
494  case 1:
495  obj->visible( _value.toBool() );
496  break;
497 
498  // source
499  case 2:
500  columnFromGUI_ = 2;//set information, which information will be changed
501  obj->source( _value.toBool() );
502  columnFromGUI_ = -1;
503  break;
504 
505  // target
506  case 3:
507  columnFromGUI_ = 3;//set information, which information will be changed
508  obj->target( _value.toBool() );
509  columnFromGUI_ = -1;
510  break;
511 
512  default:
513  break;
514  }
515 }
516 
517 
518 //******************************************************************************
519 
525 void DataControlPlugin::slotMoveBaseObject(int _id, int _newParentId){
526 
527  BaseObject* obj = 0;
528 
529  if ( !PluginFunctions::getObject(_id, obj) )
530  return;
531 
532  BaseObject* parent = 0;
533 
534  if ( !PluginFunctions::getObject(_newParentId, parent) )
535  return;
536 
537  BaseObject* oldParent = obj->parent();
538 
539  //set new parent
540  obj->setParent( parent );
541 
542  //if oldParent is an empty group -> delete it
543  if ( oldParent != PluginFunctions::objectRoot() && oldParent->childCount() == 0 )
544  emit deleteObject( oldParent->id() );
545 }
546 
547 
548 //******************************************************************************
549 
551 
552  int rows = model_->rowCount();
553 
554  for(int i = 0; i < rows; ++i) {
555  TreeItem* item = model_->getItem(model_->index(i,0));
556  if(item->dataType() == DATA_LIGHT) {
557  view_->setRowHidden(i, model_->parent(model_->index(i,0)), !_state);
558  }else{
559  //always show, if it is not a light
560  view_->setRowHidden(i, model_->parent(model_->index(i,0)), false);
561  }
562  }
563 }
564 
565 
567 {
568  slotShowLightSources( tool_->lightSources->isChecked() );
569 }
570 //******************************************************************************
571 
577 
578  if ( _ini.section_exists( "BoundingBox" ) && OpenFlipper::Options::gui() )
579  {
580  bool value;
581  if (_ini.get_entry(value, "BoundingBox","notSelected"))
582  tool_->notSelected->setChecked (value);
583  if (_ini.get_entry(value, "BoundingBox","sourceSelected"))
584  tool_->sourceSelected->setChecked (value);
585  if (_ini.get_entry(value, "BoundingBox","targetSelected"))
586  tool_->targetSelected->setChecked (value);
587  }
588 
589  if ( !_ini.section_exists( "Groups" ) )
590  return;
591 
592  // Names of all groups
593  QStringList groupNames;
594 
595  // names of the primary groups
596  QStringList rootGroup;
597 
598  // Get the list of group names to the file
599  _ini.get_entry(groupNames,"Groups","groups");
600 
601  // Get the primary group names to the file
602  _ini.get_entry(rootGroup,"Groups","rootGroup");
603 
604  //list of groups
605  QVector< BaseObject* > groups;
606 
607  // Go over one level of the groups
608  while ( rootGroup.size() > 0 ) {
609  QString current = rootGroup[0];
610  rootGroup.removeFirst();
611 
612  QStringList groupChildren;
613  QStringList elementChildren;
614 
615  _ini.get_entry(elementChildren ,current,"children");
616  _ini.get_entry(groupChildren ,current,"subgroups");
617 
618  // if we get a parent item, scan the tree for it or use the root node otherwise
619  BaseObject* parentItem;
620  QString parentName;
621  if ( _ini.get_entry(parentName,current,"parent") ) {
622  parentItem = PluginFunctions::objectRoot()->childExists(parentName);
623  if ( parentItem == 0 )
624  parentItem = PluginFunctions::objectRoot();
625  } else
626  parentItem = PluginFunctions::objectRoot();
627 
628  rootGroup << groupChildren;
629 
630  // check if this group already exists
631  BaseObject* group = PluginFunctions::objectRoot()->childExists( current );
632 
633  // group does not exist
634  if ( !group ) {
635 
636  int groupId = addEmptyGroup(current, parentItem->id());
637  PluginFunctions::getObject(groupId, group);
638 
639  // in the groups vector we only need the lowest groups
640  // because they are used recursively
641  int p = groups.indexOf( group->parent() );
642  if ( p > -1 )
643  groups.remove( p );
644 
645  groups.push_back( group );
646  }
647 
648  // process children
649  for ( int i = 0 ; i < elementChildren.size() ; ++i ) {
650  BaseObject* childItem = PluginFunctions::objectRoot()->childExists( elementChildren[i] );
651  if ( childItem ) {
652  childItem->setParent(group);
653  }
654  }
655  }
656 }
657 
658 
659 //******************************************************************************
660 
666 
667  std::queue< BaseObject* > children;
668  children.push( PluginFunctions::objectRoot() );
669 
670  std::vector< BaseObject* > groups;
671 
672  // Get all groups from the tree
673  while ( ! children.empty() ) {
674  BaseObject* item = children.front();
675  children.pop();
676 
677  for ( int i = 0 ; i < item->childCount(); ++i )
678  if ( item->child(i)->dataType(DATA_GROUP))
679  children.push( item->child(i) );
680 
681  if ( item->dataType(DATA_GROUP) && (item != PluginFunctions::objectRoot() ) )
682  groups.push_back(item);
683  }
684 
685  // Names of all groups
686  QStringList groupNames;
687 
688  // names of the primary groups
689  QStringList rootGroup;
690 
691  for ( uint i = 0 ; i < groups.size() ; ++i ) {
692  groupNames.push_back( groups[i]->name() );
693 
694  _ini.add_entry(groups[i]->name(),"groupname",groups[i]->name());
695 
696  // write the name of the parent
697  if ( ( groups[i]->parent() != 0 ) && ( groups[i]->parent() != PluginFunctions::objectRoot() ) )
698  _ini.add_entry(groups[i]->name(),"parent",groups[i]->parent()->name());
699 
700  if ( groups[i]->parent() == PluginFunctions::objectRoot() )
701  rootGroup.push_back( groups[i]->name() );
702 
703  // Write a list of this groups children
704  QStringList groupchildren;
705  QStringList elementchildren;
706  for ( int j = 0 ; j < groups[i]->childCount(); ++j ) {
707  if ( groups[i]->child(j)->dataType(DATA_GROUP) )
708  groupchildren.push_back( groups[i]->child(j)->name() );
709  else
710  elementchildren.push_back( groups[i]->child(j)->name() );
711  }
712 
713  _ini.add_entry(groups[i]->name(),"subgroups",groupchildren);
714  _ini.add_entry(groups[i]->name(),"children",elementchildren);
715  }
716 
717  // Write the list of group names to the file
718  _ini.add_entry("Groups","groups",groupNames);
719 
720  // Write the primary group names to the file
721  _ini.add_entry("Groups","rootGroup",rootGroup);
722 
723  if ( OpenFlipper::Options::gui() ) {
724 
725  _ini.add_entry("BoundingBox","notSelected",tool_->notSelected->isChecked ());
726  _ini.add_entry("BoundingBox","sourceSelected",tool_->sourceSelected->isChecked ());
727  _ini.add_entry("BoundingBox","targetSelected",tool_->targetSelected->isChecked ());
728  }
729 
730 }
731 
732 
733 //******************************************************************************
734 
741 
742 
743  if ( _obj == PluginFunctions::objectRoot() || (!_obj->isGroup()) )
744  return;
745 
746  QList< BaseObject* > children = _obj->getLeafs();
747  bool changed = false;
748  bool value = false;
749 
750 
751  switch ( _column ){
752 
753  case 1: //VISIBILTY
754 
755  for (int i=0; i < children.size(); i++)
756  value |= children[i]->visible();
757 
758  _obj->visible( value );
759 
760  changed = true;
761 
762  break;
763 
764  case 2: //SOURCE
765 
766  for (int i=0; i < children.size(); i++){
767  value |= children[i]->source();
768  }
769 
770  if (_obj->source() != value){
771  _obj->source( value );
772  changed = true;
773  }
774  break;
775 
776  case 3: //TARGET
777 
778  for (int i=0; i < children.size(); i++){
779  value |= children[i]->target();
780  }
781 
782  if (_obj->target() != value){
783  _obj->target( value );
784  changed = true;
785  }
786 
787  break;
788 
789  default:
790  break;
791  }
792 
793  if ( changed )
794  propagateUpwards( _obj->parent(), _column );
795 }
796 
797 //******************************************************************************
798 
805 
806  for (int i=0; i < _obj->childCount(); i++){
807 
808  BaseObject* current = _obj->child(i);
809 
810  switch ( _column ){
811 
812  case 1: //VISIBILTY
813 
814  if ( current->visible() != _obj->visible() ){
815 
816  current->visible( _obj->visible() );
817  }
818  break;
819 
820  case 2: //SOURCE
821 
822  if ( current->source() != _obj->source() ){
823  current->source( _obj->source() );
824  }
825  break;
826 
827  case 3: //TARGET
828 
829  if ( current->target() != _obj->target() ){
830  current->target( _obj->target() );
831  }
832 
833  break;
834 
835  default:
836  break;
837  }
838 
839  if ( current->isGroup() ){
840  propagateDownwards(current, _column);
841 
842  }
843  }
844 }
845 
846 //******************************************************************************
847 
851 {
852  for (PluginFunctions::ObjectIterator o_it; o_it != PluginFunctions::objectsEnd(); ++o_it) {
853  updateBoundingBox (o_it);
854  }
855 
856  emit updateView();
857 }
858 
859 //******************************************************************************
860 
866 {
867  if (tool_->notSelected->isChecked () ||
868  (_obj->source () && tool_->sourceSelected->isChecked ()) ||
869  (_obj->target () && tool_->targetSelected->isChecked ()))
870  {
872 
873  ACG::Vec4f color = base_color;
874 
875  if (_obj->source () && tool_->sourceSelected->isChecked ())
876  color += source_color;
877 
878  if (_obj->target () && tool_->targetSelected->isChecked ())
879  color += target_color;
880 
881  _obj->boundingBoxNode()->set_base_color (color);
882  }
883  else
885 
886 }
887 
888 //******************************************************************************
894  _ini.add_entry("BoundingBox","notSelected",tool_->notSelected->isChecked ());
895  _ini.add_entry("BoundingBox","sourceSelected",tool_->sourceSelected->isChecked ());
896  _ini.add_entry("BoundingBox","targetSelected",tool_->targetSelected->isChecked ());
897 }
898 
901  advancedSettingsBtn_->setVisible(reduced);
902 }
903 
904 void DataControlPlugin::slotObjectUpdated( int _identifier, const UpdateType& _type )
905 {
906  if ( ! OpenFlipper::Options::gui() || !_type.contains(UPDATE_GEOMETRY))
907  return;
908 
909  BaseObjectData* obj = 0;
910 
911  if ( PluginFunctions::getObject( _identifier, obj) )
912  {
913  updateBoundingBox (obj);
914  model_->objectChanged(obj->id());
915  }
916 }
917 
918 #if QT_VERSION < 0x050000
919 Q_EXPORT_PLUGIN2( datacontrolplugin , DataControlPlugin );
920 #endif
921 
void updateBoundingBox(BaseObjectData *_obj)
Updates bounding box.
bool target()
target
Definition: TreeItem.cc:135
void setViewObjectMarker(ViewObjectMarker *_marker)
void slotObjectPropertiesChanged(int _identifier)
Update the model if properties of an object changed.
BaseObject * parent()
Get the parent item ( 0 if rootitem )
Definition: BaseObject.cc:477
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
Definition: TreeModel.cc:436
DataType dataType()
dataType
Definition: TreeItem.cc:102
void slotCopyMaterialToTargeted()
Called by the popup menu to copy material properties.
Definition: Popup.cc:448
void addedEmptyObject(int _id)
Update the model if an empty object has been added.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
Definition: UpdateType.cc:111
TreeModel * model_
The Treemodel organizing the data.
QTreeView * view_
Tree view.
Update type class.
Definition: UpdateType.hh:70
void slotContextMenuSource()
Source Selection.
Draw node & children.
Definition: BaseNode.hh:368
bool getObject(int _identifier, BSplineCurveObject *&_object)
void set_base_color(const Vec4f &_c)
set the base color
Definition: MeshNode2T.cc:404
const DataType DATA_GROUP(1)
Items used for Grouping.
void slotCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeView.
Definition: Popup.cc:181
QModelIndex parent(const QModelIndex &_index) const
Get the parent ModelIndex.
Definition: TreeModel.cc:322
void fileOpened(int _id)
Update the model if a file has been opened.
void slotHeaderCustomContextMenuRequested(const QPoint &_pos)
Display a custom context window for the TreeViews header.
Definition: Popup.cc:315
QAction * targetAction_
Hide an object.
virtual bool visible()
return if object is visible
Definition: BaseObject.cc:350
void slotMoveBaseObject(int _id, int _newParentId)
Gets called when an object was moved via drag n drop.
bool isGroup() const
Check if object is a group.
Definition: BaseObject.cc:630
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
QAction * sourceAction_
Hide an object.
void slotKeyEvent(QKeyEvent *_event)
a key event occurred
int columnFromGUI_
Gets called when the data in the table has changed.
QModelIndex index(int _row, int _column, const QModelIndex &_parent=QModelIndex()) const
Get the ModelIndex at given row,column.
Definition: TreeModel.cc:295
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
Definition: INIFile.cc:439
bool source()
Definition: BaseObject.cc:302
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
Definition: INIFile.cc:263
Hide this node, but draw children.
Definition: MeshNode2T.cc:370
QToolButton * advancedSettingsBtn_
Hide an object.
void objectChanged(int _id)
The object with the given id has been changed. Check if model also has to be changed.
Definition: TreeModel.cc:363
void set_status(StatusMode _s)
Set the status of this node.
Definition: MeshNode2T.cc:379
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
int onlyUp_
Gets called when the data in the table has changed.
DataControlPlugin()
Constructor.
int rowCount(const QModelIndex &_parent=QModelIndex()) const
get the number of rows
Definition: TreeModel.cc:344
void slotVisibilityChanged(int _identifier)
Update the model if the visibility of an object changed.
void slotPasteMaterialFromClipboard()
Called by the popup menu to paste material properties from clipboard.
Definition: Popup.cc:536
void slotCopyMaterialToClipboard()
Called by the popup menu to copy material properties to clipboard.
Definition: Popup.cc:496
QAction * removeAction_
Hide an object.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void setParent(BaseObject *_parent)
Set the parent pointer.
Definition: BaseObject.cc:488
BaseObject * childExists(int _objectId)
Check if the element exists in the subtree of this element.
Definition: BaseObject.cc:527
void slotMaterialProperties()
Called by the popup menu to set material properties.
Definition: Popup.cc:577
BaseObject *& objectRoot()
Get the root of the object structure.
DefaultObjectMarker objectMarker
Default marker to visualize "source" and "target" object flags.
int addEmptyGroup(QString _groupName="", int _parentGroupId=0)
Create new empty group.
QString name()
Name of the Plugin.
BoundingBoxNode * boundingBoxNode()
get a pointer to the bounding box node
void loadIniFileOptionsLast(INIFile &_ini)
Load Groups from ini file.
void slotContextMenuTarget()
Target Selection.
bool source()
source
Definition: TreeItem.cc:147
QList< BaseObject * > getLeafs()
get all leafes of the tree below this object ( These will be all visible objects ) ...
Definition: BaseObject.cc:578
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void slotDataChanged(int _id, int _column, const QVariant &_value)
Gets called when the data in the table has changed.
void setDefaultViewObjectMarker(ViewObjectMarker *_marker)
void setAllTarget()
Makes all available objects target.
#define DATA_LIGHT
Definition: Light.hh:64
QHeaderView * viewHeader_
Pointer to the header to the view widget.
void slotPopupRemove()
Called by the popup menu to remove an object/group.
Definition: Popup.cc:67
DatacontrolToolboxWidget * tool_
Widget for Toolbox.
void propagateDownwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
The Menu will be shown when an object was picked.
void saveIniFileOptions(INIFile &_ini)
Save groups to ini file.
void showReducedUi(bool reduced)
int onlyDown_
Gets called when the data in the table has changed.
int childCount() const
get the number of children
Definition: BaseObject.cc:522
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
Definition: INIFile.cc:233
void slotShowLightSources()
Index where a popup has been opened.
void objectDeleted(int _id)
The object with the given id has been deleted. delete it from the internal tree.
Definition: TreeModel.cc:471
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
Definition: BaseObject.cc:734
void slotObjectSelectionChanged(int _identifier)
update drawing of objects when the active object changed
void saveOnExit(INIFile &_ini)
Save settings before application is closed.
BaseObject * child(int row)
return a child
Definition: BaseObject.cc:517
void slotContextMenuHide()
Hide an object.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
Definition: TreeModel.cc:518
bool target()
Definition: BaseObject.cc:284
void slotBoundingBoxChange()
Bounding box selection changed.
void objectDeleted(int _id)
an object was deleted. delete it internally
void propagateUpwards(BaseObject *_obj, int _column)
Recursively update a column up to the root of the tree.
int id() const
Definition: BaseObject.cc:201
void slotContextMenuRemove()
Remove Selected Item.
void pluginsInitialized()
Plugin initialization.