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