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(0),
74 mCombineProperty2(0),
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(0, "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;
387 PluginFunctions::getPickedObject(node_idx, object);
388
389 if (object->id() == objectID_ && !currentlySelectedIndices.empty())
390 {
391 OMPropertyVisualizer<MeshT>* viz = dynamic_cast<OMPropertyVisualizer<MeshT>*>(propertyVisualizers[currentlySelectedIndices.first().row()] );
392 unsigned int primitiveId = viz->getClosestPrimitiveId(face_idx, hit_point);
393 mPickWidget.pickedHandle->setText(tr("%1").arg(primitiveId));
394 mPickWidget.pickedValue->setText(viz->getPropertyText(primitiveId));
395 }
396 }
397 }
398 }
399
400 template<typename MeshT>
401 bool OMPropertyModel<MeshT>::isVectorType(const TypeInfoWrapper& typeInfo) const
402 {
403 return (typeInfo == proptype_Vec3f) || (typeInfo == proptype_Vec3d);
404 }
405
406 template<typename MeshT>
407 void OMPropertyModel<MeshT>::gatherProperties( MeshT* mesh,
408 typename MeshT::prop_iterator props_first,
409 typename MeshT::prop_iterator props_last,
410 PropertyInfo::ENTITY_FILTER filter)
411 {
412 for (typename MeshT::prop_iterator pit = props_first; pit != props_last; ++pit) {
413 OpenMesh::BaseProperty*const baseProp = *pit;
414 if (baseProp && isSupported(baseProp) && isNew(baseProp, filter))
415 addPropertyVisualizer(baseProp, mesh, filter);
416 }
417 }
418
419 template<typename MeshT>
420 void OMPropertyModel<MeshT>::gatherProperties()
421 {
422 beginResetModel();
423 if (mesh_) {
424 gatherProperties(mesh_, mesh_->fprops_begin(), mesh_->fprops_end(), PropertyInfo::EF_FACE);
425 gatherProperties(mesh_, mesh_->eprops_begin(), mesh_->eprops_end(), PropertyInfo::EF_EDGE);
426 gatherProperties(mesh_, mesh_->hprops_begin(), mesh_->hprops_end(), PropertyInfo::EF_HALFEDGE);
427 gatherProperties(mesh_, mesh_->vprops_begin(), mesh_->vprops_end(), PropertyInfo::EF_VERTEX);
428 }
429 endResetModel();
430 }
431
432
440 template<typename MeshT>
441 bool OMPropertyModel<MeshT>::isSupported(OpenMesh::BaseProperty* const baseProp) const
442 {
443 TypeInfoWrapper bp_type = typeid(*baseProp);
444 TypeInfoWrapperSet::const_iterator propIt = supportedPropertyTypes.find(bp_type);
445 return propIt != supportedPropertyTypes.end();
446 }
447
458 template<typename MeshT>
459 bool OMPropertyModel<MeshT>::isSupported(QString friendlyName) const
460 {
461 for (TypeInfoWrapperSet::const_iterator it = supportedPropertyTypes.begin();
462 it != supportedPropertyTypes.end();
463 ++it )
464 {
465 if (friendlyName.toStdString().compare(it->getName()) == 0)
466 return true;
467 }
468 return false;
469 }
470
479 template<typename MeshT>
480 bool OMPropertyModel<MeshT>::isNew(OpenMesh::BaseProperty* const baseProp, PropertyInfo::ENTITY_FILTER filter)
481 {
482 for (unsigned int i = 0; i < propertyVisualizers.size(); ++i)
483 {
484 const PropertyInfo& propInfo = propertyVisualizers[i]->getPropertyInfo();
485 if (propInfo == PropertyInfo(baseProp->name(), getSupportedTypeInfoWrapper(baseProp) , filter))
486 return false;
487 }
488 return true;
489 }
490
498 template<typename MeshT>
499 TypeInfoWrapper OMPropertyModel<MeshT>::getSupportedTypeInfoWrapper(OpenMesh::BaseProperty* const baseProp)
500 {
501 TypeInfoWrapper bp_type = typeid(*baseProp);
502 TypeInfoWrapperSet::const_iterator propIt = supportedPropertyTypes.find(bp_type);
503 return *propIt;
504 }
505
513 template<typename MeshT>
514 TypeInfoWrapper OMPropertyModel<MeshT>::getSupportedTypeInfoWrapper(QString friendlyName)
515 {
516 for (TypeInfoWrapperSet::const_iterator it = supportedPropertyTypes.begin();
517 it != supportedPropertyTypes.end();
518 ++it )
519 {
520 if (friendlyName.toStdString().compare(it->getName()) == 0)
521 return *it;
522 }
523 throw std::exception();
524 }
525
526
537 template<typename MeshT>
538 void OMPropertyModel<MeshT>::addPropertyVisualizer(OpenMesh::BaseProperty* const baseProp, MeshT* mesh, PropertyInfo::ENTITY_FILTER filter)
539 {
540 PropertyInfo propInfo = PropertyInfo(baseProp->name(), getSupportedTypeInfoWrapper(baseProp) , filter);
541 if (propInfo.typeinfo() == proptype_bool)
542 propertyVisualizers.push_back(new OMPropertyVisualizerBoolean<MeshT>(mesh, objectID_, propInfo));
543 else if (propInfo.typeinfo() == proptype_int)
544 propertyVisualizers.push_back(new OMPropertyVisualizerInteger<MeshT, int>(mesh, objectID_, propInfo, false));
545 else if (propInfo.typeinfo() == proptype_uint)
546 propertyVisualizers.push_back(new OMPropertyVisualizerInteger<MeshT, unsigned int>(mesh, objectID_, propInfo, true));
547 else if (propInfo.typeinfo() == proptype_uint8_t)
548 propertyVisualizers.push_back(new OMPropertyVisualizerInteger<MeshT, uint8_t>(mesh, objectID_, propInfo, true));
549 else if (propInfo.typeinfo() == proptype_double)
550 propertyVisualizers.push_back(new OMPropertyVisualizerDouble<MeshT>(mesh, objectID_, propInfo));
551 else if ((propInfo.typeinfo() == proptype_Vec3d) || (propInfo.typeinfo() == proptype_Vec3f))
552 propertyVisualizers.push_back(new OMPropertyVisualizerVector<MeshT>(mesh, objectID_, propInfo));
553 else if ((propInfo.typeinfo() == proptype_Vec2d))
554 propertyVisualizers.push_back(new OMPropertyVisualizerVector2<MeshT, ACG::Vec2d>(mesh, objectID_, propInfo));
555 else if ((propInfo.typeinfo() == proptype_Vec2f))
556 propertyVisualizers.push_back(new OMPropertyVisualizerVector2<MeshT, ACG::Vec2f>(mesh, objectID_, propInfo));
557 #ifdef ENABLE_SKELETON_SUPPORT
558 else if (propInfo.typeinfo() == proptype_SkinWeights)
559 propertyVisualizers.push_back(new OMPropertyVisualizerSkinWeights<MeshT>(mesh, objectID_, propInfo));
560 #endif
561 connectLogs(propertyVisualizers.back());
562 }
563
574 template<typename MeshT>
575 void OMPropertyModel<MeshT>:: addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
576 {
577
578 QString dtype = friendlyTypeName;
579 QString pname = propName;
580
581 MeshT* mesh = mesh_;
582
583 if ( filter == PropertyInfo::EF_VERTEX )
584 {
585 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
586 {
587 OpenMesh::VPropHandleT< TriMesh::Point > prop;
588 mesh->add_property(prop, pname.toStdString());
589 }
590 else if (dtype == tr("Vec2d"))
591 {
592 OpenMesh::VPropHandleT< ACG::Vec2d > prop;
593 mesh->add_property(prop, pname.toStdString());
594 }
595 else if (dtype == tr("Vec2f"))
596 {
597 OpenMesh::VPropHandleT< ACG::Vec2f > prop;
598 mesh->add_property(prop, pname.toStdString());
599 }
600 else if ( dtype == tr("double") )
601 {
602 OpenMesh::VPropHandleT< double > prop;
603 mesh->add_property(prop, pname.toStdString());
604 }
605 else if ( dtype == tr("unsigned int") )
606 {
607 OpenMesh::VPropHandleT< unsigned int > prop;
608 mesh->add_property(prop, pname.toStdString());
609 }
610 else if ( dtype == tr("uint8_t") )
611 {
612 OpenMesh::VPropHandleT< uint8_t > prop;
613 mesh->add_property(prop, pname.toStdString());
614 }
615 else if ( dtype == tr("int") )
616 {
617 OpenMesh::VPropHandleT< int > prop;
618 mesh->add_property(prop, pname.toStdString());
619 }
620 else if ( dtype == tr("bool") )
621 {
622 OpenMesh::VPropHandleT< bool > prop;
623 mesh->add_property(prop, pname.toStdString());
624 }
625 //please update the doc if you write "skin weights"-property support
626
627 #ifdef ENABLE_SKELETON_SUPPORT
628 else if ( dtype == tr("SkinWeights") )
629 {
630 OpenMesh::VPropHandleT< BaseSkin::SkinWeights > prop;
631 mesh->add_property(prop, pname.toStdString());
632 }
633 #endif
634 }
635 else if ( filter == PropertyInfo::EF_EDGE )
636 {
637 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
638 {
639 OpenMesh::EPropHandleT< TriMesh::Point > prop;
640 mesh->add_property(prop, pname.toStdString());
641 }
642 else if ( dtype == tr("Vec2d") )
643 {
644 OpenMesh::EPropHandleT< ACG::Vec2d > prop;
645 mesh->add_property(prop, pname.toStdString());
646 }
647 else if ( dtype == tr("Vec2f") )
648 {
649 OpenMesh::EPropHandleT< ACG::Vec2f > prop;
650 mesh->add_property(prop, pname.toStdString());
651 }
652 else if ( dtype == tr("double") )
653 {
654 OpenMesh::EPropHandleT< double > prop;
655 mesh->add_property(prop, pname.toStdString());
656 }
657 else if ( dtype == tr("unsgined int") )
658 {
659 OpenMesh::EPropHandleT< unsigned int > prop;
660 mesh->add_property(prop, pname.toStdString());
661 }
662 else if ( dtype == tr("uint8_t") )
663 {
664 OpenMesh::EPropHandleT< uint8_t > prop;
665 mesh->add_property(prop, pname.toStdString());
666 }
667 else if ( dtype == tr("int") )
668 {
669 OpenMesh::EPropHandleT< int > prop;
670 mesh->add_property(prop, pname.toStdString());
671 }
672 else if ( dtype == tr("bool") )
673 {
674 OpenMesh::EPropHandleT< bool > prop;
675 mesh->add_property(prop, pname.toStdString());
676 }
677 }
678 else if ( filter == PropertyInfo::EF_FACE )
679 {
680 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
681 {
682 OpenMesh::FPropHandleT< TriMesh::Point > prop;
683 mesh->add_property(prop, pname.toStdString());
684 }
685 else if ( dtype == tr("Vec2d") )
686 {
687 OpenMesh::FPropHandleT< ACG::Vec2d > prop;
688 mesh->add_property(prop, pname.toStdString());
689 }
690 else if ( dtype == tr("Vec2f") )
691 {
692 OpenMesh::FPropHandleT< ACG::Vec2f > prop;
693 mesh->add_property(prop, pname.toStdString());
694 }
695 else if ( dtype == tr("double") )
696 {
697 OpenMesh::FPropHandleT< double > prop;
698 mesh->add_property(prop, pname.toStdString());
699 }
700 else if ( dtype == tr("unsigned int") )
701 {
702 OpenMesh::FPropHandleT< unsigned int > prop;
703 mesh->add_property(prop, pname.toStdString());
704 }
705 else if ( dtype == tr("uint8_t") )
706 {
707 OpenMesh::FPropHandleT< uint8_t > prop;
708 mesh->add_property(prop, pname.toStdString());
709 }
710 else if ( dtype == tr("int") )
711 {
712 OpenMesh::FPropHandleT< int > prop;
713 mesh->add_property(prop, pname.toStdString());
714 }
715 else if ( dtype == tr("bool") )
716 {
717 OpenMesh::FPropHandleT< bool > prop;
718 mesh->add_property(prop, pname.toStdString());
719 }
720 }
721 else if ( filter == PropertyInfo::EF_HALFEDGE )
722 {
723 if ( (dtype == tr("Vec3d")) || (dtype == tr("Vec3f")) )
724 {
725 OpenMesh::HPropHandleT< TriMesh::Point > prop;
726 mesh->add_property(prop, pname.toStdString());
727 }
728 else if ( dtype == tr("double") )
729 {
730 OpenMesh::HPropHandleT< double > prop;
731 mesh->add_property(prop, pname.toStdString());
732 }
733 else if ( dtype == tr("unsigned int") )
734 {
735 OpenMesh::HPropHandleT< unsigned int > prop;
736 mesh->add_property(prop, pname.toStdString());
737 }
738 else if ( dtype == tr("uint8_t") )
739 {
740 OpenMesh::HPropHandleT< uint8_t > prop;
741 mesh->add_property(prop, pname.toStdString());
742 }
743 else if ( dtype == tr("int") )
744 {
745 OpenMesh::HPropHandleT< int > prop;
746 mesh->add_property(prop, pname.toStdString());
747 }
748 else if ( dtype == tr("bool") )
749 {
750 OpenMesh::HPropHandleT< bool > prop;
751 mesh->add_property(prop, pname.toStdString());
752 }
753 }
754
755 }
756
757
758 template<typename MeshT>
759 void OMPropertyModel<MeshT>::initializeSupportedPropertyTypes()
760 {
761
762
763 supportedPropertyTypes.insert(proptype_bool);
764 supportedPropertyTypes.insert(proptype_int);
765 supportedPropertyTypes.insert(proptype_uint);
766 supportedPropertyTypes.insert(proptype_uint8_t);
767 supportedPropertyTypes.insert(proptype_double);
768 supportedPropertyTypes.insert(proptype_Vec3d);
769 supportedPropertyTypes.insert(proptype_Vec3f);
770 supportedPropertyTypes.insert(proptype_Vec2d);
771 supportedPropertyTypes.insert(proptype_Vec2f);
772
773 #ifdef ENABLE_SKELETON_SUPPORT
774 supportedPropertyTypes.insert(proptype_SkinWeights);
775 #endif
776
777 //#ifdef ENABLE_SKELETON_SUPPORT
778 // //template <typename MeshT>
779 // //const typename OMPropertyModel<MeshT>::TypeInfoWrapperSet OMPropertyModel<MeshT>::supportedPropertyTypes =
780 // // (OpenFlipper::Options::nogui() ? typename OMPropertyModel<MeshT>::TypeInfoWrapperSet() : typename OMPropertyModel<MeshT>::TypeInfoWrapperSet(propertyTypes, propertyTypes + 7));
781 // supportedPropertyTypes = typename OMPropertyModel<MeshT>::TypeInfoWrapperSet();
782 //#else
783 // //const typename OMPropertyModel<MeshT>::TypeInfoWrapperSet OMPropertyModel<MeshT>::supportedPropertyTypes =
784 // // (OpenFlipper::Options::nogui() ? typename OMPropertyModel<MeshT>::TypeInfoWrapperSet() : typename OMPropertyModel<MeshT>::TypeInfoWrapperSet(propertyTypes, propertyTypes + 6));
785 // supportedPropertyTypes = typename OMPropertyModel<MeshT>::TypeInfoWrapperSet();
786 //#endif
787
788 }
OMPropertyVisualizerVectorFieldDifference
Definition: OMPropertyVisualizerVectorFieldDifference.hh:60
OMPropertyVisualizer::getClosestPrimitiveId
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
Definition: OMPropertyVisualizerT_impl.hh:200
OMPropertyVisualizerInteger
Definition: OMPropertyVisualizerInteger.hh:56
OMPropertyModel::addProperty
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
Definition: OMPropertyModelT_impl.hh:575
OpenMesh::EPropHandleT
Definition: Property.hh:510
NewNameMessageBox
Asks the user how to proceed after a name clash.
Definition: Utils.hh:170
SingleObjectPropertyModel::connectLogs
void connectLogs(PropertyVisualizer *propViz)
Connects the PropertyVisualizer log signals with the log slot.
Definition: SingleObjectPropertyModel.cc:162
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:478
PropertyVisualizer::getPropertyInfo
const PropertyInfo & getPropertyInfo() const
Returns the PropertyInfo.
Definition: PropertyVisualizer.hh:129
SingleObjectPropertyModel::getPropertyVisualizer
PropertyVisualizer * getPropertyVisualizer(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Returns a PropertyVisualizer.
Definition: SingleObjectPropertyModel.cc:315
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:480
BaseObject::id
int id() const
Definition: BaseObject.cc:190
PluginFunctions::getPickedObject
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
Definition: PluginFunctions.cc:259
OMPropertyModel::pickProperty
virtual void pickProperty()
Toggle picking on and off.
Definition: OMPropertyModelT_impl.hh:340
OMPropertyModel::getSaveFilenameFilter
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.
Definition: OMPropertyModelT_impl.hh:150
OMPropertyVisualizerVector2
Definition: OMPropertyVisualizerVector2.hh:60
PropertyVisualizer::setPropertyFromText
virtual void setPropertyFromText(unsigned int index, QString text)=0
Returns the value of a property in text form.
LOGERR
Definition: LoggingInterface.hh:96
OMPropertyModel::isSupported
bool isSupported(OpenMesh::BaseProperty *const baseProp) const
Checks if visualizing this property is supported.
Definition: OMPropertyModelT_impl.hh:441
OpenMesh::BaseProperty::name
const std::string & name() const
Return the name of the property.
Definition: BaseProperty.hh:120
TypeInfoWrapper
Wraps the information of a type.
Definition: Utils.hh:73
OMPropertyVisualizerBoolean
Definition: OMPropertyVisualizerBoolean.hh:54
OMPropertyModelSubclass
Added for signal/slot support.
Definition: OMPropertyModelSubclass.hh:56
OMPropertyVisualizerVector
Definition: OMPropertyVisualizerVector.hh:60
OMPropertyModel::combinable
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2)
Checks if two properties are combinable.
Definition: OMPropertyModelT_impl.hh:201
SingleObjectPropertyModel::updateWidget
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
Definition: SingleObjectPropertyModel.cc:142
OMPropertyModel::updateWidget
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
Definition: OMPropertyModelT_impl.hh:107
OMPropertyModel::pickModeChanged
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
Definition: OMPropertyModelT_impl.hh:357
OMPropertyModel::getLoadFilenameFilter
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
Definition: OMPropertyModelT_impl.hh:138
OMPropertyModel::gatherProperties
void gatherProperties()
Searches for all properties and creates the visualizers.
Definition: OMPropertyModelT_impl.hh:420
OMPropertyModel::addPropertyVisualizer
void addPropertyVisualizer(OpenMesh::BaseProperty *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
Definition: OMPropertyModelT_impl.hh:538
SingleObjectPropertyModel::gatherProperties
virtual void gatherProperties()
Searches for properties and creates PropertyVisualizers.
Definition: SingleObjectPropertyModel.hh:110
OMPropertyModel::resetPicking
void resetPicking()
Disables picking.
Definition: OMPropertyModelT_impl.hh:327
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
PropertyVisualizer
This class vizualizes a property.
Definition: PropertyVisualizer.hh:77
OMPropertyModel::mouseEvent
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
Definition: OMPropertyModelT_impl.hh:376
OpenMesh::HPropHandleT
Definition: Property.hh:496
SingleObjectPropertyModel::isPropertyFree
bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Checks if the property name is still available.
Definition: SingleObjectPropertyModel.cc:326
SingleObjectPropertyModel::saveProperty
void saveProperty(unsigned int propId)
Saves property.
Definition: SingleObjectPropertyModel.cc:253
OpenMesh::VectorT
Definition: Vector11T.hh:83
OMPropertyModel::getSupportedTypeInfoWrapper
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenMesh::BaseProperty *const baseProp)
Returns the TypeInfoWrapper for the property if it is supported.
Definition: OMPropertyModelT_impl.hh:499
OMPropertyModel
Definition: OMPropertyModel.hh:56
OMPropertyModel::saveProperty
virtual void saveProperty()
Saves the currently slected properties.
Definition: OMPropertyModelT_impl.hh:212
ACG::SceneGraph::PICK_FACE
picks faces (should be implemented for all nodes)
Definition: PickTarget.hh:78
OMPropertyModel::combine
virtual void combine()
Combines two properties.
Definition: OMPropertyModelT_impl.hh:179
OpenMesh::BaseProperty
Definition: BaseProperty.hh:60
PluginFunctions::actionMode
Viewer::ActionMode actionMode()
Get the current Action mode.
Definition: PluginFunctions.cc:586
OMPropertyModel::parseHeader
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
Definition: OMPropertyModelT_impl.hh:221
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:109
BaseObjectData
Definition: BaseObjectData.hh:102
OMPropertyVisualizerDouble
Definition: OMPropertyVisualizerDouble.hh:59
OMPropertyVisualizer
Definition: OMPropertyVisualizer.hh:55
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
OpenMesh::FPropHandleT
Definition: Property.hh:524
PluginFunctions::pickMode
const std::string pickMode()
Get the current Picking mode.
Definition: PluginFunctions.cc:575
OpenMesh::VPropHandleT
Definition: Property.hh:482
OMPropertyVisualizer::getPropertyText
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.
Definition: OMPropertyVisualizerT_impl.hh:142