Developer Documentation

OMPropertyModelT_impl.hh
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 #define OM_PROPERTY_MODEL_CC
45
46 #include "OMPropertyModel.hh"
47
48 #include "OMPropertyVisualizerBoolean.hh"
49 #include "OMPropertyVisualizerDouble.hh"
50 #include "OMPropertyVisualizerInteger.hh"
51 #include "OMPropertyVisualizerVector.hh"
52 #include "OMPropertyVisualizerVector2.hh"
53 #include "OMPropertyVisualizerVectorFieldDifference.hh"
54
55 #ifdef ENABLE_SKELETON_SUPPORT
56 #include "OMPropertyVisualizerSkinWeights.hh"
57 #endif
58
59 #include "../Utils.hh"
60
61 #include <vector>
62
63 #include <QInputDialog>
64 #include <QTextStream>
65
66 #define PROP_VIS "PropertyVisualization"
67
68 template<typename MeshT>
69 OMPropertyModel<MeshT>::OMPropertyModel(MeshT* mesh, int objectID, QObject *parent)
70 : OMPropertyModelSubclass(parent),
71 mesh_(mesh),
72 objectID_(objectID),
73 mCombineProperty1(nullptr),
74 mCombineProperty2(nullptr),
75 pickModeActive(false)
76 {
77 gatherProperties();
78 bCombine.setText(tr("Combine"));
79 bCombine.hide();
80 connect(&bCombine, SIGNAL(clicked()),
81 this, SLOT(slotCombine()));
82 widgets->layout()->addWidget(&bCombine);
83 widgets->layout()->addWidget(&mLoadSaveWidget);
84
85 connect(mLoadSaveWidget.save_property , SIGNAL(clicked()),
86 this, SLOT(slotSaveProperty()));
87
88 connect(mLoadSaveWidget.load_property , SIGNAL(clicked()),
89 this, SLOT(slotLoadProperty()));
90
91 widgets->layout()->addWidget(&mPickWidget);
92 connect(mPickWidget.pickButton, SIGNAL(clicked()),
93 this, SLOT(slotPickProperty()));
94 mPickWidget.hide();
95 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
96 mPickWidget.pickButton->setIcon( QIcon(iconPath + "color-picker.png") );
97
98
99 lastPickMode = PluginFunctions::pickMode();
100 lastActionMode = PluginFunctions::actionMode();
101
102 initializeSupportedPropertyTypes();
103
104 }
105
106 template<typename MeshT>
107 void OMPropertyModel<MeshT>::updateWidget(const QModelIndexList& selectedIndices)
108 {
109 SingleObjectPropertyModel::updateWidget(selectedIndices);
110
111 if (selectedIndices.size() == 2)
112 {
113 if (combinable(propertyVisualizers[selectedIndices[0].row()], propertyVisualizers[selectedIndices[1].row()]))
114 {
115
116 bCombine.show();
117 mCombineProperty1 = &propertyVisualizers[selectedIndices[0].row()]->getPropertyInfo();
118 mCombineProperty2 = &propertyVisualizers[selectedIndices[1].row()]->getPropertyInfo();
119 }
120 else
121 bCombine.hide();
122 }
123 else
124 bCombine.hide();
125
126 if (selectedIndices.size() == 1)
127 mPickWidget.show();
128 else
129 {
130 mPickWidget.hide();
131 //reset Picking, just if picking was enabled
132 if (mPickWidget.pickButton->isChecked())
133 resetPicking();
134 }
135 }
136
137 template<typename MeshT>
138 QString OMPropertyModel<MeshT>::getLoadFilenameFilter()
139 {
140 QString filter;
141 filter = tr("Vertex Property (*.vprop)");
142 filter += tr(";; HalfEdge Property (*.hprop)");
143 filter += tr(";; Edge Property (*.eprop)");
144 filter += tr(";; Face Property (*.fprop)");
145 filter += tr(";; All Files (*)");
146 return filter;
147 }
148
149 template<typename MeshT>
150 QString OMPropertyModel<MeshT>::getSaveFilenameFilter(unsigned int propId)
151 {
152 PropertyVisualizer* propViz = propertyVisualizers[propId];
153
154 QString filter;
155
156 if (propViz->getPropertyInfo().isVertexProp())
157 filter = tr("Vertex Property (*.vprop)");
158 else if (propViz->getPropertyInfo().isHalfedgeProp())
159 filter = tr("HalfEdge Property (*.hprop)");
160 else if (propViz->getPropertyInfo().isEdgeProp())
161 filter = tr("Edge Property (*.eprop)");
162 else if (propViz->getPropertyInfo().isFaceProp())
163 filter = tr("Face Property (*.fprop)");
164
165 filter += tr(";; All Files (*)");
166
167 return filter;
168 }
169
178 template<typename MeshT>
179 void OMPropertyModel<MeshT>::combine()
180 {
181 beginResetModel();
182 if (isVectorType(mCombineProperty1->typeinfo()))
183 propertyVisualizers.push_back(new OMPropertyVisualizerVectorFieldDifference<MeshT>(mesh_, objectID_, *mCombineProperty1, *mCombineProperty2));
184 endResetModel();
185 }
186
200 template<typename MeshT>
201 bool OMPropertyModel<MeshT>::combinable(PropertyVisualizer* propertyVisualizer1, PropertyVisualizer* propertyVisualizer2)
202 {
203 const PropertyInfo& propInfo1 = propertyVisualizer1->getPropertyInfo();
204 const PropertyInfo& propInfo2 = propertyVisualizer2->getPropertyInfo();
205 TypeInfoWrapper typeInfo1 = propInfo1.typeinfo();
206 TypeInfoWrapper typeInfo2 = propInfo2.typeinfo();
207
208 return (isVectorType(typeInfo1) && isVectorType(typeInfo2)) && (propInfo1.entityType() == propInfo2.entityType());
209 }
210
211 template<typename MeshT>
212 void OMPropertyModel<MeshT>::saveProperty()
213 {
214 for (QModelIndexList::const_iterator it = currentlySelectedIndices.begin(), it_end = currentlySelectedIndices.end();
215 it != it_end; ++it) {
216 SingleObjectPropertyModel::saveProperty(it->row());
217 }
218 }
219
220 template<typename MeshT>
221 bool OMPropertyModel<MeshT>::parseHeader(QString header, PropertyVisualizer*& propVis, unsigned int &n)
222 {
223 QStringList headerParts = header.split(tr(", "), QString::SkipEmptyParts );
224 int headerVersion = headerParts[0].toUInt();
225 if (headerVersion == 1)
226 {
227 n = headerParts[1].toUInt();
228 unsigned int nExpected = 0;
229
230 PropertyInfo::ENTITY_FILTER filter = (PropertyInfo::ENTITY_FILTER)headerParts[2].toInt();
231 switch (filter)
232 {
233 case PropertyInfo::EF_FACE:
234 nExpected = mesh_->n_faces();
235 break;
236 case PropertyInfo::EF_EDGE:
237 nExpected = mesh_->n_edges();
238 break;
239 case PropertyInfo::EF_HALFEDGE:
240 nExpected = mesh_->n_halfedges();
241 break;
242 case PropertyInfo::EF_VERTEX:
243 nExpected = mesh_->n_vertices();
244 break;
245 default:
246 nExpected = -1;
247 break;
248 }
249
250 if (n != nExpected)
251 {
252 emit log(LOGERR, "Could not load property: unexpected number of entities");
253 return false;
254 }
255
256 QString friendlyName = headerParts[3];
257
258 if (!isSupported(friendlyName))
259 {
260 emit log(LOGERR, tr("Could not load property: unsupported property type %1").arg(friendlyName));
261 return false;
262 }
263
264 TypeInfoWrapper typeInfo = getSupportedTypeInfoWrapper(friendlyName);
265
266 QString propName = QInputDialog::getText(nullptr, "Property Name", "Please enter name.",QLineEdit::Normal,headerParts[4]);
267 if (propName == "") return false;
268
269 bool replace = false;
270 if (!(isPropertyFree(propName, filter, typeInfo) || replace))
271 {
272 NewNameMessageBox* msgBox = new NewNameMessageBox(propName);
273 msgBox->exec();
274
275 if (msgBox->rename)
276 propName = QInputDialog::getText(0, "New Property Name", "Please enter new name.");
277 else if (msgBox->cancel)
278 return false;
279 else if (msgBox->replace)
280 replace = true;
281
282 delete msgBox;
283 }
284
285 if (!replace)
286 {
287 addProperty(propName, friendlyName, filter);
288 gatherProperties();
289 }
290
291 propVis = getPropertyVisualizer(propName, filter, typeInfo);
292
293 return true;
294
295 }
296 else
297 {
298 emit log(LOGERR, "Could not load property: unsupported header format");
299 return false;
300 }
301 }
302
303
304 template<typename MeshT>
305 void OMPropertyModel<MeshT>::setPropertyFromFile(QTextStream& file_stream, unsigned int n, PropertyVisualizer* propVis)
306 {
307 #ifdef ENABLE_SKELETON_SUPPORT
308 if (propVis->getPropertyInfo().typeinfo() == proptype_SkinWeights)
309 {
310 for (unsigned int i = 0; i < n; ++i)
311 {
312 QString propertyText = "";
313 QString tmp;
314 while ((tmp = file_stream.readLine()) != "")
315 propertyText = propertyText + tmp;
316 propVis->setPropertyFromText(i, propertyText);
317 }
318 }
319 else
320 #endif
321 {
322 SingleObjectPropertyModel::setPropertyFromFile(file_stream, n, propVis);
323 }
324 }
325
326 template<typename MeshT>
327 void OMPropertyModel<MeshT>:: resetPicking()
328 {
329 PluginFunctions::pickMode(lastPickMode);
330 PluginFunctions::actionMode(lastActionMode);
331 }
332
333
339 template<typename MeshT>
340 void OMPropertyModel<MeshT>::pickProperty()
341 {
342 if ( mPickWidget.pickButton->isChecked() ){
343
344 lastPickMode = PluginFunctions::pickMode();
345 lastActionMode = PluginFunctions::actionMode();
346
347 PluginFunctions::pickMode(PROP_VIS);
348 PluginFunctions::actionMode(Viewer::PickingMode);
349
350 } else {
351 resetPicking();
352 }
353 }
354
355
356 template<typename MeshT>
357 void OMPropertyModel<MeshT>::pickModeChanged(const std::string& _mode)
358 {
359 pickModeActive = (_mode == PROP_VIS);
360
361 if (!pickModeActive)
362 {
363 lastPickMode = _mode;
364 }
365
366 mPickWidget.pickButton->setChecked(pickModeActive);
367 }
368
375 template<typename MeshT>
376 void OMPropertyModel<MeshT>::mouseEvent(QMouseEvent* _event)
377 {
378 if (!pickModeActive) return;
379
380 if (_event->type() == QEvent::MouseButtonPress)
381 {
382 size_t node_idx, face_idx;
383 ACG::Vec3d hit_point;
384
385 if (PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_FACE, _event->pos(),node_idx, face_idx, &hit_point)) {
386 BaseObjectData* object = nullptr;
387
388 if (PluginFunctions::getPickedObject(node_idx, object))
389 {
390 if (object->id() == objectID_ && !currentlySelectedIndices.empty())
391 {
392 OMPropertyVisualizer<MeshT>* viz = dynamic_cast<OMPropertyVisualizer<MeshT>*>(propertyVisualizers[currentlySelectedIndices.first().row()] );
393 unsigned int primitiveId = viz->getClosestPrimitiveId(face_idx, hit_point);
394 mPickWidget.pickedHandle->setText(tr("%1").arg(primitiveId));
395 mPickWidget.pickedValue->setText(viz->getPropertyText(primitiveId));
396 }
397 }
398 }
399 }
400 }
401
402 template<typename MeshT>
403 bool OMPropertyModel<MeshT>::isVectorType(const TypeInfoWrapper& typeInfo) const
404 {
405 return (typeInfo == proptype_Vec3f) || (typeInfo == proptype_Vec3d);
406 }
407
408 template<typename MeshT>
409 void OMPropertyModel<MeshT>::gatherProperties( MeshT* mesh,
410 typename MeshT::prop_iterator props_first,
411 typename MeshT::prop_iterator props_last,
412 PropertyInfo::ENTITY_FILTER filter)
413 {
414 for (typename MeshT::prop_iterator pit = props_first; pit != props_last; ++pit) {
415 OpenMesh::BaseProperty*const baseProp = *pit;
416 if (baseProp && isSupported(baseProp) && isNew(baseProp, filter))
417 addPropertyVisualizer(baseProp, mesh, filter);
418 }
419 }
420
421 template<typename MeshT>
422 void OMPropertyModel<MeshT>::gatherProperties()
423 {
424 beginResetModel();
425 if (mesh_) {
426 gatherProperties(mesh_, mesh_->fprops_begin(), mesh_->fprops_end(), PropertyInfo::EF_FACE);
427 gatherProperties(mesh_, mesh_->eprops_begin(), mesh_->eprops_end(), PropertyInfo::EF_EDGE);
428 gatherProperties(mesh_, mesh_->hprops_begin(), mesh_->hprops_end(), PropertyInfo::EF_HALFEDGE);
429 gatherProperties(mesh_, mesh_->vprops_begin(), mesh_->vprops_end(), PropertyInfo::EF_VERTEX);
430 }
431 endResetModel();
432 }
433
434
442 template<typename MeshT>
443 bool OMPropertyModel<MeshT>::isSupported(OpenMesh::BaseProperty* const baseProp) const
444 {
445 TypeInfoWrapper bp_type = typeid(*baseProp);
446 TypeInfoWrapperSet::const_iterator propIt = supportedPropertyTypes.find(bp_type);
447 return propIt != supportedPropertyTypes.end();
448 }
449
460 template<typename MeshT>
461 bool OMPropertyModel<MeshT>::isSupported(QString friendlyName) const
462 {
463 for (TypeInfoWrapperSet::const_iterator it = supportedPropertyTypes.begin();
464 it != supportedPropertyTypes.end();
465 ++it )
466 {
467 if (friendlyName.toStdString().compare(it->getName()) == 0)
468 return true;
469 }
470 return false;
471 }
472
481 template<typename MeshT>
482 bool OMPropertyModel<MeshT>::isNew(OpenMesh::BaseProperty* const baseProp, PropertyInfo::ENTITY_FILTER filter)
483 {
484 for (unsigned int i = 0; i < propertyVisualizers.size(); ++i)
485 {
486 const PropertyInfo& propInfo = propertyVisualizers[i]->getPropertyInfo();
487 if (propInfo == PropertyInfo(baseProp->name(), getSupportedTypeInfoWrapper(baseProp) , filter))
488 return false;
489 }
490 return true;
491 }
492
500 template<typename MeshT>
501 TypeInfoWrapper OMPropertyModel<MeshT>::getSupportedTypeInfoWrapper(OpenMesh::BaseProperty* const baseProp)
502 {
503 TypeInfoWrapper bp_type = typeid(*baseProp);
504 TypeInfoWrapperSet::const_iterator propIt = supportedPropertyTypes.find(bp_type);
505 return *propIt;
506 }
507
515 template<typename MeshT>
516 TypeInfoWrapper OMPropertyModel<MeshT>::getSupportedTypeInfoWrapper(QString friendlyName)
517 {
518 for (TypeInfoWrapperSet::const_iterator it = supportedPropertyTypes.begin();
519 it != supportedPropertyTypes.end();
520 ++it )
521 {
522 if (friendlyName.toStdString().compare(it->getName()) == 0)
523 return *it;
524 }
525 throw std::exception();
526 }
527
528
539 template<typename MeshT>
540 void OMPropertyModel<MeshT>::addPropertyVisualizer(OpenMesh::BaseProperty* const baseProp, MeshT* mesh, PropertyInfo::ENTITY_FILTER filter)
541 {
542 PropertyInfo propInfo = PropertyInfo(baseProp->name(), getSupportedTypeInfoWrapper(baseProp) , filter);
543 if (propInfo.typeinfo() == proptype_bool)
544 propertyVisualizers.push_back(new OMPropertyVisualizerBoolean<MeshT>(mesh, objectID_, propInfo));
545 else if (propInfo.typeinfo() == proptype_int)
546 propertyVisualizers.push_back(new OMPropertyVisualizerInteger<MeshT, int>(mesh, objectID_, propInfo, false));
547 else if (propInfo.typeinfo() == proptype_uint)
548 propertyVisualizers.push_back(new OMPropertyVisualizerInteger<MeshT, unsigned int>(mesh, objectID_, propInfo, true));
549 else if (propInfo.typeinfo() == proptype_uint8_t)
550 propertyVisualizers.push_back(new OMPropertyVisualizerInteger<MeshT, uint8_t>(mesh, objectID_, propInfo, true));
551 else if (propInfo.typeinfo() == proptype_double)
552 propertyVisualizers.push_back(new OMPropertyVisualizerDouble<MeshT>(mesh, objectID_, propInfo));
553 else if ((propInfo.typeinfo() == proptype_Vec3d) || (propInfo.typeinfo() == proptype_Vec3f))
554 propertyVisualizers.push_back(new OMPropertyVisualizerVector<MeshT>(mesh, objectID_, propInfo));
555 else if ((propInfo.typeinfo() == proptype_Vec2d))
556 propertyVisualizers.push_back(new OMPropertyVisualizerVector2<MeshT, ACG::Vec2d>(mesh, objectID_, propInfo));
557 else if ((propInfo.typeinfo() == proptype_Vec2f))
558 propertyVisualizers.push_back(new OMPropertyVisualizerVector2<MeshT, ACG::Vec2f>(mesh, objectID_, propInfo));
559 #ifdef ENABLE_SKELETON_SUPPORT
560 else if (propInfo.typeinfo() == proptype_SkinWeights)
561 propertyVisualizers.push_back(new OMPropertyVisualizerSkinWeights<MeshT>(mesh, objectID_, propInfo));
562 #endif
563 connectLogs(propertyVisualizers.back());
564 }
565
576 template<typename MeshT>
577 void OMPropertyModel<MeshT>:: addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
578 {
579
580 QString dtype = friendlyTypeName;
581 QString pname = propName;
582
583 MeshT* mesh = mesh_;
584
585 if ( filter == PropertyInfo::EF_VERTEX )
586 {
587 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
588 {
589 OpenMesh::VPropHandleT< TriMesh::Point > prop;
590 mesh->add_property(prop, pname.toStdString());
591 }
592 else if (dtype == tr("Vec2d"))
593 {
594 OpenMesh::VPropHandleT< ACG::Vec2d > prop;
595 mesh->add_property(prop, pname.toStdString());
596 }
597 else if (dtype == tr("Vec2f"))
598 {
599 OpenMesh::VPropHandleT< ACG::Vec2f > prop;
600 mesh->add_property(prop, pname.toStdString());
601 }
602 else if ( dtype == tr("double") )
603 {
604 OpenMesh::VPropHandleT< double > prop;
605 mesh->add_property(prop, pname.toStdString());
606 }
607 else if ( dtype == tr("unsigned int") )
608 {
609 OpenMesh::VPropHandleT< unsigned int > prop;
610 mesh->add_property(prop, pname.toStdString());
611 }
612 else if ( dtype == tr("uint8_t") )
613 {
614 OpenMesh::VPropHandleT< uint8_t > prop;
615 mesh->add_property(prop, pname.toStdString());
616 }
617 else if ( dtype == tr("int") )
618 {
619 OpenMesh::VPropHandleT< int > prop;
620 mesh->add_property(prop, pname.toStdString());
621 }
622 else if ( dtype == tr("bool") )
623 {
624 OpenMesh::VPropHandleT< bool > prop;
625 mesh->add_property(prop, pname.toStdString());
626 }
627 //please update the doc if you write "skin weights"-property support
628
629 #ifdef ENABLE_SKELETON_SUPPORT
630 else if ( dtype == tr("SkinWeights") )
631 {
632 OpenMesh::VPropHandleT< BaseSkin::SkinWeights > prop;
633 mesh->add_property(prop, pname.toStdString());
634 }
635 #endif
636 }
637 else if ( filter == PropertyInfo::EF_EDGE )
638 {
639 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
640 {
641 OpenMesh::EPropHandleT< TriMesh::Point > prop;
642 mesh->add_property(prop, pname.toStdString());
643 }
644 else if ( dtype == tr("Vec2d") )
645 {
646 OpenMesh::EPropHandleT< ACG::Vec2d > prop;
647 mesh->add_property(prop, pname.toStdString());
648 }
649 else if ( dtype == tr("Vec2f") )
650 {
651 OpenMesh::EPropHandleT< ACG::Vec2f > prop;
652 mesh->add_property(prop, pname.toStdString());
653 }
654 else if ( dtype == tr("double") )
655 {
656 OpenMesh::EPropHandleT< double > prop;
657 mesh->add_property(prop, pname.toStdString());
658 }
659 else if ( dtype == tr("unsgined int") )
660 {
661 OpenMesh::EPropHandleT< unsigned int > prop;
662 mesh->add_property(prop, pname.toStdString());
663 }
664 else if ( dtype == tr("uint8_t") )
665 {
666 OpenMesh::EPropHandleT< uint8_t > prop;
667 mesh->add_property(prop, pname.toStdString());
668 }
669 else if ( dtype == tr("int") )
670 {
671 OpenMesh::EPropHandleT< int > prop;
672 mesh->add_property(prop, pname.toStdString());
673 }
674 else if ( dtype == tr("bool") )
675 {
676 OpenMesh::EPropHandleT< bool > prop;
677 mesh->add_property(prop, pname.toStdString());
678 }
679 }
680 else if ( filter == PropertyInfo::EF_FACE )
681 {
682 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
683 {
684 OpenMesh::FPropHandleT< TriMesh::Point > prop;
685 mesh->add_property(prop, pname.toStdString());
686 }
687 else if ( dtype == tr("Vec2d") )
688 {
689 OpenMesh::FPropHandleT< ACG::Vec2d > prop;
690 mesh->add_property(prop, pname.toStdString());
691 }
692 else if ( dtype == tr("Vec2f") )
693 {
694 OpenMesh::FPropHandleT< ACG::Vec2f > prop;
695 mesh->add_property(prop, pname.toStdString());
696 }
697 else if ( dtype == tr("double") )
698 {
699 OpenMesh::FPropHandleT< double > prop;
700 mesh->add_property(prop, pname.toStdString());
701 }
702 else if ( dtype == tr("unsigned int") )
703 {
704 OpenMesh::FPropHandleT< unsigned int > prop;
705 mesh->add_property(prop, pname.toStdString());
706 }
707 else if ( dtype == tr("uint8_t") )
708 {
709 OpenMesh::FPropHandleT< uint8_t > prop;
710 mesh->add_property(prop, pname.toStdString());
711 }
712 else if ( dtype == tr("int") )
713 {
714 OpenMesh::FPropHandleT< int > prop;
715 mesh->add_property(prop, pname.toStdString());
716 }
717 else if ( dtype == tr("bool") )
718 {
719 OpenMesh::FPropHandleT< bool > prop;
720 mesh->add_property(prop, pname.toStdString());
721 }
722 }
723 else if ( filter == PropertyInfo::EF_HALFEDGE )
724 {
725 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
726 {
727 OpenMesh::HPropHandleT< TriMesh::Point > prop;
728 mesh->add_property(prop, pname.toStdString());
729 }
730 else if ( dtype == tr("double") )
731 {
732 OpenMesh::HPropHandleT< double > prop;
733 mesh->add_property(prop, pname.toStdString());
734 }
735 else if ( dtype == tr("unsigned int") )
736 {
737 OpenMesh::HPropHandleT< unsigned int > prop;
738 mesh->add_property(prop, pname.toStdString());
739 }
740 else if ( dtype == tr("uint8_t") )
741 {
742 OpenMesh::HPropHandleT< uint8_t > prop;
743 mesh->add_property(prop, pname.toStdString());
744 }
745 else if ( dtype == tr("int") )
746 {
747 OpenMesh::HPropHandleT< int > prop;
748 mesh->add_property(prop, pname.toStdString());
749 }
750 else if ( dtype == tr("bool") )
751 {
752 OpenMesh::HPropHandleT< bool > prop;
753 mesh->add_property(prop, pname.toStdString());
754 }
755 }
756
757 }
758
759
760 template<typename MeshT>
761 void OMPropertyModel<MeshT>::initializeSupportedPropertyTypes()
762 {
763
764
765 supportedPropertyTypes.insert(proptype_bool);
766 supportedPropertyTypes.insert(proptype_int);
767 supportedPropertyTypes.insert(proptype_uint);
768 supportedPropertyTypes.insert(proptype_uint8_t);
769 supportedPropertyTypes.insert(proptype_double);
770 supportedPropertyTypes.insert(proptype_Vec3d);
771 supportedPropertyTypes.insert(proptype_Vec3f);
772 supportedPropertyTypes.insert(proptype_Vec2d);
773 supportedPropertyTypes.insert(proptype_Vec2f);
774
775 #ifdef ENABLE_SKELETON_SUPPORT
776 supportedPropertyTypes.insert(proptype_SkinWeights);
777 #endif
778
779 //#ifdef ENABLE_SKELETON_SUPPORT
780 // //template <typename MeshT>
781 // //const typename OMPropertyModel<MeshT>::TypeInfoWrapperSet OMPropertyModel<MeshT>::supportedPropertyTypes =
782 // // (OpenFlipper::Options::nogui() ? typename OMPropertyModel<MeshT>::TypeInfoWrapperSet() : typename OMPropertyModel<MeshT>::TypeInfoWrapperSet(propertyTypes, propertyTypes + 7));
783 // supportedPropertyTypes = typename OMPropertyModel<MeshT>::TypeInfoWrapperSet();
784 //#else
785 // //const typename OMPropertyModel<MeshT>::TypeInfoWrapperSet OMPropertyModel<MeshT>::supportedPropertyTypes =
786 // // (OpenFlipper::Options::nogui() ? typename OMPropertyModel<MeshT>::TypeInfoWrapperSet() : typename OMPropertyModel<MeshT>::TypeInfoWrapperSet(propertyTypes, propertyTypes + 6));
787 // supportedPropertyTypes = typename OMPropertyModel<MeshT>::TypeInfoWrapperSet();
788 //#endif
789
790 }
PluginFunctions::scenegraphPick
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
Definition: PluginFunctions.cc:480
LOGERR
Definition: LoggingInterface.hh:96
OpenMesh::VPropHandleT
Definition: Property.hh:484
OMPropertyModel::isSupported
bool isSupported(OpenMesh::BaseProperty *const baseProp) const
Checks if visualizing this property is supported.
Definition: OMPropertyModelT_impl.hh:443
OMPropertyModel::setPropertyFromFile
virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis)
Sets the property values from a given file.
Definition: OMPropertyModelT_impl.hh:305
OMPropertyVisualizer::getClosestPrimitiveId
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
Definition: OMPropertyVisualizerT_impl.hh:210
TypeInfoWrapper
Wraps the information of a type.
Definition: Utils.hh:73
ACG::SceneGraph::PICK_FACE
picks faces (should be implemented for all nodes)
Definition: PickTarget.hh:78
OMPropertyModel::saveProperty
virtual void saveProperty()
Saves the currently slected properties.
Definition: OMPropertyModelT_impl.hh:212
OMPropertyModel::getLoadFilenameFilter
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
Definition: OMPropertyModelT_impl.hh:138
OpenMesh::HPropHandleT
Definition: Property.hh:499
SingleObjectPropertyModel::isPropertyFree
bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Checks if the property name is still available.
Definition: SingleObjectPropertyModel.cc:326
OpenMesh::EPropHandleT
Definition: Property.hh:514
OMPropertyModel::isNew
bool isNew(OpenMesh::BaseProperty *const baseProp, PropertyInfo::ENTITY_FILTER filter)
Checks if we already created a PropertyVisualizer for this property.
Definition: OMPropertyModelT_impl.hh:482
OMPropertyVisualizerVector2
Definition: OMPropertyVisualizerVector2.hh:60
OMPropertyModelSubclass
Added for signal/slot support.
Definition: OMPropertyModelSubclass.hh:56
OpenMesh::VectorT
Definition: Vector11T.hh:83
SingleObjectPropertyModel::connectLogs
void connectLogs(PropertyVisualizer *propViz) override
Connects the PropertyVisualizer log signals with the log slot.
Definition: SingleObjectPropertyModel.cc:162
OpenMesh::BaseProperty
Definition: BaseProperty.hh:60
OMPropertyVisualizerDouble
Definition: OMPropertyVisualizerDouble.hh:59
OMPropertyVisualizerBoolean
Definition: OMPropertyVisualizerBoolean.hh:54
BaseObject::id
int id() const
Definition: BaseObject.cc:190
OMPropertyVisualizerVectorFieldDifference
Definition: OMPropertyVisualizerVectorFieldDifference.hh:60
OMPropertyModel::parseHeader
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
Definition: OMPropertyModelT_impl.hh:221
OMPropertyModel::pickModeChanged
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
Definition: OMPropertyModelT_impl.hh:357
SingleObjectPropertyModel::saveProperty
void saveProperty(unsigned int propId)
Saves property.
Definition: SingleObjectPropertyModel.cc:253
OMPropertyVisualizer
Definition: OMPropertyVisualizer.hh:55
SingleObjectPropertyModel::gatherProperties
virtual void gatherProperties() override
Searches for properties and creates PropertyVisualizers.
Definition: SingleObjectPropertyModel.hh:110
NewNameMessageBox
Asks the user how to proceed after a name clash.
Definition: Utils.hh:170
PluginFunctions::actionMode
Viewer::ActionMode actionMode()
Get the current Action mode.
Definition: PluginFunctions.cc:588
OMPropertyVisualizerInteger
Definition: OMPropertyVisualizerInteger.hh:56
OMPropertyModel::resetPicking
void resetPicking()
Disables picking.
Definition: OMPropertyModelT_impl.hh:327
OMPropertyModel::getSaveFilenameFilter
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
Definition: OMPropertyModelT_impl.hh:150
OMPropertyModel::addPropertyVisualizer
void addPropertyVisualizer(OpenMesh::BaseProperty *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
Definition: OMPropertyModelT_impl.hh:540
PropertyVisualizer::getPropertyInfo
const PropertyInfo & getPropertyInfo() const
Returns the PropertyInfo.
Definition: PropertyVisualizer.hh:129
OMPropertyModel::getSupportedTypeInfoWrapper
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty *const baseProp)
Returns the TypeInfoWrapper for the property if it is supported.
Definition: OMPropertyModelT_impl.hh:501
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:109
OpenMesh::BaseProperty::name
const std::string & name() const
Return the name of the property.
Definition: BaseProperty.hh:120
OMPropertyModel::addProperty
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
Definition: OMPropertyModelT_impl.hh:577
BaseObjectData
Definition: BaseObjectData.hh:102
PluginFunctions::pickMode
const std::string pickMode()
Get the current Picking mode.
Definition: PluginFunctions.cc:577
PropertyVisualizer
This class vizualizes a property.
Definition: PropertyVisualizer.hh:77
SingleObjectPropertyModel::getPropertyVisualizer
PropertyVisualizer * getPropertyVisualizer(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Returns a PropertyVisualizer.
Definition: SingleObjectPropertyModel.cc:315
OMPropertyModel::updateWidget
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
Definition: OMPropertyModelT_impl.hh:107
OMPropertyModel::gatherProperties
void gatherProperties()
Searches for all properties and creates the visualizers.
Definition: OMPropertyModelT_impl.hh:422
OMPropertyModel::pickProperty
virtual void pickProperty()
Toggle picking on and off.
Definition: OMPropertyModelT_impl.hh:340
SingleObjectPropertyModel::updateWidget
virtual void updateWidget(const QModelIndexList &selectedIndices) override
Updates the widget.
Definition: SingleObjectPropertyModel.cc:142
SingleObjectPropertyModel::setPropertyFromFile
virtual void setPropertyFromFile(QTextStream &file_stream, unsigned int n, PropertyVisualizer *propVis)
Sets the property values from a given file.
Definition: SingleObjectPropertyModel.cc:306
OMPropertyModel::combine
virtual void combine()
Combines two properties.
Definition: OMPropertyModelT_impl.hh:179
OMPropertyModel
Definition: OMPropertyModel.hh:56
OMPropertyModel::mouseEvent
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
Definition: OMPropertyModelT_impl.hh:376
OpenMesh::FPropHandleT
Definition: Property.hh:529
OMPropertyModel::combinable
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2)
Checks if two properties are combinable.
Definition: OMPropertyModelT_impl.hh:201
PropertyVisualizer::setPropertyFromText
virtual void setPropertyFromText(unsigned int index, QString text)=0
Returns the value of a property in text form.
PluginFunctions::getPickedObject
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
Definition: PluginFunctions.cc:261
OMPropertyVisualizerVector
Definition: OMPropertyVisualizerVector.hh:60
OMPropertyVisualizer::getPropertyText
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.
Definition: OMPropertyVisualizerT_impl.hh:142