44 #define OVM_PROPERTY_MODEL_CC 46 template <
typename MeshT>
55 bCombine.setText(tr(
"Combine"));
57 connect(&bCombine, SIGNAL(clicked()),
58 this, SLOT(slotCombine()));
59 widgets->layout()->addWidget(&bCombine);
61 widgets->layout()->addWidget(&mLoadSaveWidget);
63 connect(mLoadSaveWidget.save_property , SIGNAL(clicked()),
64 this, SLOT(slotSaveProperty()));
66 connect(mLoadSaveWidget.load_property , SIGNAL(clicked()),
67 this, SLOT(slotLoadProperty()));
69 widgets->layout()->addWidget(&mPickWidget);
70 connect(mPickWidget.pickButton, SIGNAL(clicked()),
71 this, SLOT(slotPickProperty()));
73 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
74 mPickWidget.pickButton->setIcon( QIcon(iconPath +
"color-picker.png") );
79 initializeSupportedPropertyTypes();
82 #undef INITIALIZE_PROPTYPES 84 template <
typename MeshT>
89 if (selectedIndices.size() == 2)
91 if (
combinable(propertyVisualizers[selectedIndices[0].row()], propertyVisualizers[selectedIndices[1].row()]))
95 mCombineProperty1 = &propertyVisualizers[selectedIndices[0].row()]->getPropertyInfo();
96 mCombineProperty2 = &propertyVisualizers[selectedIndices[1].row()]->getPropertyInfo();
106 if (selectedIndices.size() == 1)
112 if (mPickWidget.pickButton->isChecked())
118 template <
typename MeshT>
131 template <
typename MeshT>
134 if ( mPickWidget.pickButton->isChecked() ){
147 template <
typename MeshT>
150 pickModeActive = (_mode == PROP_VIS);
154 lastPickMode = _mode;
157 mPickWidget.pickButton->setChecked(pickModeActive);
166 template <
typename MeshT>
169 if (!pickModeActive)
return;
170 if (currentlySelectedIndices.size() < 1)
return;
172 if (_event->type() == QEvent::MouseButtonPress)
199 if (object->
id() == objectID_)
204 mPickWidget.pickedHandle->setText(tr(
"%1").arg(entityId));
212 template <
typename MeshT>
215 QStringList headerParts = header.split(tr(
", "), QString::SkipEmptyParts );
216 int headerVersion = headerParts[0].toUInt();
217 if (headerVersion == 1)
219 n = headerParts[1].toUInt();
220 unsigned int nExpected = 0;
222 PropertyInfo::ENTITY_FILTER filter = (PropertyInfo::ENTITY_FILTER)headerParts[2].toInt();
225 case PropertyInfo::EF_CELL:
226 nExpected = mesh_->n_cells();
228 case PropertyInfo::EF_FACE:
229 nExpected = mesh_->n_faces();
231 case PropertyInfo::EF_HALFFACE:
232 nExpected = mesh_->n_halffaces();
234 case PropertyInfo::EF_EDGE:
235 nExpected = mesh_->n_edges();
237 case PropertyInfo::EF_HALFEDGE:
238 nExpected = mesh_->n_halfedges();
240 case PropertyInfo::EF_VERTEX:
241 nExpected = mesh_->n_vertices();
250 std::cerr <<
"unexpected number of entities" << std::endl;
254 QString friendlyName = headerParts[3];
258 std::cerr <<
"unsupported property type " << friendlyName.toStdString() << std::endl;
265 QString propName = QInputDialog::getText(0,
"Property Name",
"Please enter name.",QLineEdit::Normal,headerParts[4]);
266 if (propName ==
"")
return false;
268 bool replace =
false;
275 propName = QInputDialog::getText(0,
"New Property Name",
"Please enter new name.");
276 else if (msgBox->cancel)
278 else if (msgBox->replace)
297 std::cerr <<
"unsupported header format" << std::endl;
303 template<
typename MeshT>
307 filter = tr(
"Vertex Property (*.vprop)");
308 filter += tr(
";; HalfEdge Property (*.hprop)");
309 filter += tr(
";; Edge Property (*.eprop)");
310 filter += tr(
";; Halfface Property (*.hfprop)");
311 filter += tr(
";; Face Property (*.fprop)");
312 filter += tr(
";; Cell Property (*.cprop)");
313 filter += tr(
";; All Files (*)");
317 template<
typename MeshT>
325 filter = tr(
"Vertex Property (*.vprop)");
327 filter = tr(
"HalfEdge Property (*.hprop)");
329 filter = tr(
"Edge Property (*.eprop)");
331 filter = tr(
"Face Property (*.fprop)");
333 filter += tr(
";; All Files (*)");
348 template<
typename MeshT>
362 template<
typename MeshT>
370 template<
typename MeshT>
373 for (QModelIndexList::const_iterator it = currentlySelectedIndices.begin(), it_end = currentlySelectedIndices.end();
374 it != it_end; ++it) {
392 template<
typename MeshT>
400 return (isVectorType(typeInfo1) && isVectorType(typeInfo2)) && (propInfo1.entityType() == propInfo2.entityType());
403 template<
typename MeshT>
405 typename MeshT::Properties::const_iterator props_first,
406 typename MeshT::Properties::const_iterator props_last,
407 PropertyInfo::ENTITY_FILTER filter)
409 for (
typename MeshT::Properties::const_iterator pit = props_first; pit != props_last; ++pit) {
417 template<
typename MeshT>
422 gatherProperties(mesh_, mesh_->face_props_begin(), mesh_->face_props_end(), PropertyInfo::EF_FACE);
423 gatherProperties(mesh_, mesh_->edge_props_begin(), mesh_->edge_props_end(), PropertyInfo::EF_EDGE);
424 gatherProperties(mesh_, mesh_->halfedge_props_begin(), mesh_->halfedge_props_end(), PropertyInfo::EF_HALFEDGE);
425 gatherProperties(mesh_, mesh_->vertex_props_begin(), mesh_->vertex_props_end(), PropertyInfo::EF_VERTEX);
426 gatherProperties(mesh_, mesh_->halfface_props_begin(), mesh_->halfface_props_end(), PropertyInfo::EF_HALFFACE);
427 gatherProperties(mesh_, mesh_->cell_props_begin(), mesh_->cell_props_end(), PropertyInfo::EF_CELL);
440 template<
typename MeshT>
444 TypeInfoWrapperSet::const_iterator propIt = supportedPropertyTypes.find(bp_type);
445 return propIt != supportedPropertyTypes.end();
458 template<
typename MeshT>
461 for (TypeInfoWrapperSet::const_iterator it = supportedPropertyTypes.begin();
462 it != supportedPropertyTypes.end();
465 if (friendlyName.toStdString().compare(it->getName()) == 0)
479 template<
typename MeshT>
482 for (
unsigned int i = 0; i < propertyVisualizers.size(); ++i)
484 const PropertyInfo& propInfo = propertyVisualizers[i]->getPropertyInfo();
499 template<
typename MeshT>
503 TypeInfoWrapperSet::const_iterator propIt = supportedPropertyTypes.find(bp_type);
504 if (propIt != supportedPropertyTypes.end())
508 std::cerr <<
"error" << std::endl;
521 template<
typename MeshT>
525 for (TypeInfoWrapperSet::const_iterator it = supportedPropertyTypes.begin();
526 it != supportedPropertyTypes.end();
529 if ((friendlyName.toStdString().compare(it->getName()) == 0) && isEntityType(*it, filter))
532 throw std::exception();
535 template<
typename MeshT>
538 return isBoolType(propInfo.typeinfo());
541 template<
typename MeshT>
544 return typeInfo == proptype_Cell_bool ||
545 typeInfo == proptype_Face_bool ||
546 typeInfo == proptype_HalfFace_bool ||
547 typeInfo == proptype_Edge_bool ||
548 typeInfo == proptype_HalfEdge_bool ||
549 typeInfo == proptype_Vertex_bool;
552 template<
typename MeshT>
555 return isIntType(propInfo.typeinfo());
558 template<
typename MeshT>
561 return typeInfo == proptype_Cell_int ||
562 typeInfo == proptype_Face_int ||
563 typeInfo == proptype_HalfFace_int ||
564 typeInfo == proptype_Edge_int ||
565 typeInfo == proptype_HalfEdge_int ||
566 typeInfo == proptype_Vertex_int;
569 template<
typename MeshT>
572 return isDoubleType(propInfo.typeinfo());
575 template<
typename MeshT>
578 return typeInfo == proptype_Cell_double ||
579 typeInfo == proptype_Face_double ||
580 typeInfo == proptype_HalfFace_double ||
581 typeInfo == proptype_Edge_double ||
582 typeInfo == proptype_HalfEdge_double ||
583 typeInfo == proptype_Vertex_double;
586 template<
typename MeshT>
589 return isUnsignedIntType(propInfo.typeinfo());
592 template<
typename MeshT>
595 return typeInfo == proptype_Cell_uint ||
596 typeInfo == proptype_Face_uint ||
597 typeInfo == proptype_HalfFace_uint ||
598 typeInfo == proptype_Edge_uint ||
599 typeInfo == proptype_HalfEdge_uint ||
600 typeInfo == proptype_Vertex_uint;
603 template<
typename MeshT>
606 return isVec3dType(propInfo.typeinfo());
609 template<
typename MeshT>
612 return typeInfo == proptype_Cell_Vec3d ||
613 typeInfo == proptype_Face_Vec3d ||
614 typeInfo == proptype_HalfFace_Vec3d ||
615 typeInfo == proptype_Edge_Vec3d ||
616 typeInfo == proptype_HalfEdge_Vec3d ||
617 typeInfo == proptype_Vertex_Vec3d;
620 template<
typename MeshT>
623 return isVec3fType(propInfo.typeinfo());
626 template<
typename MeshT>
629 return typeInfo == proptype_Cell_Vec3f ||
630 typeInfo == proptype_Face_Vec3f ||
631 typeInfo == proptype_HalfFace_Vec3f ||
632 typeInfo == proptype_Edge_Vec3f ||
633 typeInfo == proptype_HalfEdge_Vec3f ||
634 typeInfo == proptype_Vertex_Vec3f;
637 template<
typename MeshT>
640 return isVec3fType(propInfo) || isVec3dType(propInfo);
643 template<
typename MeshT>
646 return isVec3fType(typeInfo) || isVec3dType(typeInfo);
649 template<
typename MeshT>
653 if (entity_type & PropertyInfo::EF_CELL)
655 result |= (typeInfo == proptype_Cell_bool)
656 || (typeInfo == proptype_Cell_int)
657 || (typeInfo == proptype_Cell_double)
658 || (typeInfo == proptype_Cell_uint)
659 || (typeInfo == proptype_Cell_Vec3d)
660 || (typeInfo == proptype_Cell_Vec3f);
662 if (entity_type & PropertyInfo::EF_FACE)
664 result |= (typeInfo == proptype_Face_bool)
665 || (typeInfo == proptype_Face_int)
666 || (typeInfo == proptype_Face_double)
667 || (typeInfo == proptype_Face_uint)
668 || (typeInfo == proptype_Face_Vec3d)
669 || (typeInfo == proptype_Face_Vec3f);
671 if (entity_type & PropertyInfo::EF_HALFFACE)
673 result |= (typeInfo == proptype_HalfFace_bool)
674 || (typeInfo == proptype_HalfFace_int)
675 || (typeInfo == proptype_HalfFace_double)
676 || (typeInfo == proptype_HalfFace_uint)
677 || (typeInfo == proptype_HalfFace_Vec3d)
678 || (typeInfo == proptype_HalfFace_Vec3f);
680 if (entity_type & PropertyInfo::EF_EDGE)
682 result |= (typeInfo == proptype_Edge_bool)
683 || (typeInfo == proptype_Edge_int)
684 || (typeInfo == proptype_Edge_double)
685 || (typeInfo == proptype_Edge_uint)
686 || (typeInfo == proptype_Edge_Vec3d)
687 || (typeInfo == proptype_Edge_Vec3f);
689 if (entity_type & PropertyInfo::EF_HALFEDGE)
691 result |= (typeInfo == proptype_HalfEdge_bool)
692 || (typeInfo == proptype_HalfEdge_int)
693 || (typeInfo == proptype_HalfEdge_double)
694 || (typeInfo == proptype_HalfEdge_uint)
695 || (typeInfo == proptype_HalfEdge_Vec3d)
696 || (typeInfo == proptype_HalfEdge_Vec3f);
698 if (entity_type & PropertyInfo::EF_VERTEX)
700 result |= (typeInfo == proptype_Vertex_bool)
701 || (typeInfo == proptype_Vertex_int)
702 || (typeInfo == proptype_Vertex_double)
703 || (typeInfo == proptype_Vertex_uint)
704 || (typeInfo == proptype_Vertex_Vec3d)
705 || (typeInfo == proptype_Vertex_Vec3f);
721 template<
typename MeshT>
725 if (isBoolType(propInfo))
727 else if (isIntType(propInfo))
729 else if (isUnsignedIntType(propInfo))
731 else if (isDoubleType(propInfo))
733 else if (isVectorType(propInfo))
748 template<
typename MeshT>
752 QString dtype = friendlyTypeName;
753 std::string pname = propName.toStdString();
757 if ( filter == PropertyInfo::EF_VERTEX )
759 if ( (dtype == tr(
"Vec3d")) || (dtype == tr(
"Vec3f")) )
762 mesh->set_persistent(prop,
true);
764 else if ( dtype == tr(
"double") )
767 mesh->set_persistent(prop,
true);
769 else if ( dtype == tr(
"unsigned int") )
772 mesh->set_persistent(prop,
true);
774 else if ( dtype == tr(
"int") )
777 mesh->set_persistent(prop,
true);
779 else if ( dtype == tr(
"bool") )
782 mesh->set_persistent(prop,
true);
785 else if ( filter == PropertyInfo::EF_EDGE )
787 if ( (dtype == tr(
"Vec3d")) || (dtype == tr(
"Vec3f")) )
790 mesh->set_persistent(prop,
true);
792 else if ( dtype == tr(
"double") )
795 mesh->set_persistent(prop,
true);
797 else if ( dtype == tr(
"unsgined int") )
800 mesh->set_persistent(prop,
true);
802 else if ( dtype == tr(
"int") )
805 mesh->set_persistent(prop,
true);
807 else if ( dtype == tr(
"bool") )
810 mesh->set_persistent(prop,
true);
813 else if ( filter == PropertyInfo::EF_FACE )
815 if ( (dtype == tr(
"Vec3d")) || (dtype == tr(
"Vec3f")) )
818 mesh->set_persistent(prop,
true);
820 else if ( dtype == tr(
"double") )
823 mesh->set_persistent(prop,
true);
825 else if ( dtype == tr(
"unsigned int") )
828 mesh->set_persistent(prop,
true);
830 else if ( dtype == tr(
"int") )
833 mesh->set_persistent(prop,
true);
835 else if ( dtype == tr(
"bool") )
838 mesh->set_persistent(prop,
true);
841 else if ( filter == PropertyInfo::EF_HALFEDGE )
843 if ( (dtype == tr(
"Vec3d")) || (dtype == tr(
"Vec3f")) )
846 mesh->set_persistent(prop,
true);
848 else if ( dtype == tr(
"double") )
851 mesh->set_persistent(prop,
true);
853 else if ( dtype == tr(
"unsigned int") )
856 mesh->set_persistent(prop,
true);
858 else if ( dtype == tr(
"int") )
861 mesh->set_persistent(prop,
true);
863 else if ( dtype == tr(
"bool") )
866 mesh->set_persistent(prop,
true);
869 else if ( filter == PropertyInfo::EF_HALFFACE )
871 if ( (dtype == tr(
"Vec3d")) || (dtype == tr(
"Vec3f")) )
874 mesh->set_persistent(prop,
true);
876 else if ( dtype == tr(
"double") )
879 mesh->set_persistent(prop,
true);
881 else if ( dtype == tr(
"unsigned int") )
884 mesh->set_persistent(prop,
true);
886 else if ( dtype == tr(
"int") )
889 mesh->set_persistent(prop,
true);
891 else if ( dtype == tr(
"bool") )
894 mesh->set_persistent(prop,
true);
897 else if ( filter == PropertyInfo::EF_CELL )
899 if ( (dtype == tr(
"Vec3d")) || (dtype == tr(
"Vec3f")) )
902 mesh->set_persistent(prop,
true);
904 else if ( dtype == tr(
"double") )
907 mesh->set_persistent(prop,
true);
909 else if ( dtype == tr(
"unsigned int") )
912 mesh->set_persistent(prop,
true);
914 else if ( dtype == tr(
"int") )
917 mesh->set_persistent(prop,
true);
919 else if ( dtype == tr(
"bool") )
922 mesh->set_persistent(prop,
true);
928 template <
typename MeshT>
932 #define INSERT_PROPTYPES(primitive) \ 933 supportedPropertyTypes.insert(proptype_##primitive##_bool); \ 934 supportedPropertyTypes.insert(proptype_##primitive##_int); \ 935 supportedPropertyTypes.insert(proptype_##primitive##_uint); \ 936 supportedPropertyTypes.insert(proptype_##primitive##_double); \ 937 supportedPropertyTypes.insert(proptype_##primitive##_Vec3d); \ 938 supportedPropertyTypes.insert(proptype_##primitive##_Vec3f); \ 940 INSERT_PROPTYPES(Cell)
941 INSERT_PROPTYPES(Face)
942 INSERT_PROPTYPES(HalfFace)
943 INSERT_PROPTYPES(Edge)
944 INSERT_PROPTYPES(HalfEdge)
945 INSERT_PROPTYPES(Vertex)
947 #undef INITIALIZE_PROPTYPES virtual void saveProperty()
Saves the currently slected properties.
Asks the user how to proceed after a name clash.
void connectLogs(PropertyVisualizer *propViz)
Connects the PropertyVisualizer log signals with the log slot.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
const PropertyInfo & getPropertyInfo() const
Returns the PropertyInfo.
virtual QString getPropertyText(unsigned int index)=0
Returns the value of a property in text form.
PropertyVisualizer * getPropertyVisualizer(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Returns a PropertyVisualizer.
unsigned int getClosestPrimitiveId(unsigned int _face, ACG::Vec3d &_hitPoint)
Returns the ID of the closest primitive.
virtual void mouseEvent(QMouseEvent *_event)
Handles mouse events for picking.
bool getPickedObject(const size_t _node_idx, BaseObjectData *&_object)
Get the picked mesh.
void addPropertyVisualizer(OpenVolumeMesh::BaseProperty *const baseProp, MeshT *mesh, PropertyInfo::ENTITY_FILTER filter)
Adds a new PropertyVisualizer.
virtual QString getLoadFilenameFilter()
Returns the filename filter for loading.
virtual void pickProperty()
Toggle picking on and off.
void gatherProperties()
Searches for all properties and creates the visualizers.
Wraps the information of a type.
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
bool isPropertyFree(QString propName, PropertyInfo::ENTITY_FILTER filter, TypeInfoWrapper typeInfo)
Checks if a property name is still available for an entity type and a property type.
picks edges (may not be implemented for all nodes)
TypeInfoWrapper getSupportedTypeInfoWrapper(OpenVolumeMesh::BaseProperty *const baseProp) const
Returns the TypeInfoWrapper for the property if it is supported.
This class vizualizes a property.
bool isNew(OpenVolumeMesh::BaseProperty *const baseProp, PropertyInfo::ENTITY_FILTER filter) const
Checks if we already created a PropertyVisualizer for this property.
void resetPicking()
Disables picking.
PickTarget
What target to use for picking.
picks faces (may not be implemented for all nodes)
virtual bool parseHeader(QString header, PropertyVisualizer *&propVis, unsigned int &n)
Parses the property file header.
void saveProperty(unsigned int propId)
Saves property.
bool combinable(PropertyVisualizer *propertyVisualizer1, PropertyVisualizer *propertyVisualizer2) const
Checks if two properties are combinable.
picks faces (should be implemented for all nodes)
Viewer::ActionMode actionMode()
Get the current Action mode.
virtual void updateWidget(const QModelIndexList &selectedIndices)
Updates the widget.
bool isSupported(OpenVolumeMesh::BaseProperty *const baseProp) const
Checks if visualizing this property is supported.
Cellection of information about a property.
void addProperty(QString propName, QString friendlyTypeName, PropertyInfo::ENTITY_FILTER filter)
Adds a new property to the mesh.
picks verices (may not be implemented for all nodes)
virtual void pickModeChanged(const std::string &_mode)
Handles changing of pick mode.
virtual void combine()
Combines two properties.
const std::string pickMode()
Get the current Picking mode.
virtual QString getSaveFilenameFilter(unsigned int propId)
Returns the filename filter for saving.