43#include "MultiObjectPropertyModel.hh"
45#include "PropertyModelFactory.hh"
46#include "OpenMesh/OMPropertyModel.hh"
48#ifdef ENABLE_OPENVOLUMEMESH
49#include "OpenVolumeMesh/OVMPropertyModelT.hh"
54MultiObjectPropertyModel::MultiObjectPropertyModel(
const QStringList& res, QObject *parent) :
55 PropertyModel(parent), restriction(res), datatypes(supportedDataTypes()), widget(0)
57 QVBoxLayout* layout =
new QVBoxLayout();
58 widget =
new QWidget();
59 widget->setLayout(layout);
62MultiObjectPropertyModel::~MultiObjectPropertyModel()
64 for (
size_t i = 0; i < propWidgets.size(); ++i)
66 delete propWidgets[i];
71QVariant MultiObjectPropertyModel::data(
const QModelIndex & index,
int role)
const
75 return QVariant(propNames[index.row()]);
81int MultiObjectPropertyModel::rowCount(
const QModelIndex & parent)
const
83 return propNames.size();
86QVariant MultiObjectPropertyModel::headerData(
int section, Qt::Orientation orientation,
int role)
const
91QModelIndex MultiObjectPropertyModel::index(
int row,
int column,
const QModelIndex &parent)
const
94 return createIndex(row, column);
101 for (
ObjectIterator o_it(restriction, datatypes); o_it != objectsEnd(); ++o_it)
105 if (model == 0)
continue;
115 if (selectedIndices.size() < 1)
return;
117 for (
ObjectIterator o_it(restriction, datatypes); o_it != objectsEnd(); ++o_it)
121 if (model == 0)
continue;
124 QModelIndexList indexList;
125 QWidgetList widgetList;
127 for (
int i = 0; i < selectedIndices.size(); ++i)
129 const QString name = selectedIndices[i].data().toString();
133 if (!idx.isValid())
continue;
136 indexList.append(idx);
137 widgetList.append(propWidgets[selectedIndices[i].row()]);
150 if (selectedIndices.size() < 1)
return;
152 for (
ObjectIterator o_it(restriction, datatypes); o_it != objectsEnd(); ++o_it)
155 if (model == 0)
continue;
157 QModelIndexList indexList;
159 for (
int i = 0; i < selectedIndices.size(); ++i)
161 const QString name = selectedIndices[i].data().toString();
165 if (!idx.isValid())
continue;
168 indexList.append(idx);
183 if (selectedIndices.size() < 1)
return;
185 for (
ObjectIterator o_it(restriction, datatypes); o_it != objectsEnd(); ++o_it)
188 if (model == 0)
continue;
190 QModelIndexList indexList;
192 for (
int i = 0; i < selectedIndices.size(); ++i)
194 const QString name = selectedIndices[i].data().toString();
198 if (!idx.isValid())
continue;
201 indexList.append(idx);
218 for (
size_t i = 0; i < propWidgets.size(); ++i)
220 delete propWidgets[i];
225 for (
ObjectIterator o_it(restriction, datatypes); o_it != objectsEnd(); ++o_it)
228 if (model == 0)
continue;
231 for (
int i = 0; i < model->rowCount(); ++i)
233 const QModelIndex idx = model->index(i, 0);
234 const QString name = idx.data().toString();
237 if (std::find(propNames.begin(), propNames.end(), name) == propNames.end())
240 QWidget* widget = createWidgetForType(info.typeinfo());
241 setRange(info, widget);
243 propNames.push_back(name);
244 propInfos.push_back(info);
245 propWidgets.push_back(widget);
256 if (selectedIndices.size() < 1)
return;
258 for (
ObjectIterator o_it(restriction, datatypes); o_it != objectsEnd(); ++o_it)
261 if (model == 0)
continue;
263 QModelIndexList indexList;
265 for (
int i = 0; i < selectedIndices.size(); ++i)
267 const QString name = selectedIndices[i].data().toString();
271 if (!idx.isValid())
continue;
274 indexList.append(idx);
277 model->
clear(indexList);
293 QLayout* layout = widget->layout();
295 for (
unsigned int i = 0; i < propWidgets.size(); ++i)
297 propWidgets[i]->hide();
300 for (
int i = 0; i < selectedIndices.size(); ++i)
302 const int row = selectedIndices[i].row();
303 QWidget* w = propWidgets[row];
304 layout->addWidget(w);
308 widget->setLayout(layout);
318 return propInfos[index.row()];
321QWidget* MultiObjectPropertyModel::createWidgetForType(
const TypeInfoWrapper& info)
const
343 #ifdef ENABLE_SKELETON_SUPPORT
352 #if defined(ENABLE_HEXAHEDRALMESH_SUPPORT)
371 return new QWidget();
374template <
typename ItemHandle,
typename PropHandle,
typename T>
375void range3_om(
const OpenMesh::BaseKernel* mesh,
unsigned int n,
const std::string& name, T& min, T& max)
378 mesh->get_property_handle(ph, name);
379 if (!ph.is_valid())
return;
381 for (
unsigned int i = 0; i < n; ++i)
383 const ItemHandle ih(i);
384 min = std::min(min, mesh->property(ph, ih));
385 max = std::max(max, mesh->property(ph, ih));
389template <
typename ItemHandle,
typename Property,
typename T>
390void range3_ovm(Property& prop,
unsigned int n, T& min, T& max)
392 for (
unsigned int i = 0; i < n; ++i)
394 const ItemHandle ih(i);
395 min = std::min(min, prop[ih]);
396 max = std::max(max, prop[ih]);
400template <
typename Mesh,
typename T>
403 if (mesh == 0)
return;
405 if (info.isVertexProp())
406 range3_om<OpenMesh::VertexHandle, OpenMesh::VPropHandleT<T>, T>
407 (mesh, mesh->n_vertices(), info.propName(), min, max);
408 if (info.isHalfedgeProp())
410 (mesh, mesh->n_halfedges(), info.propName(), min, max);
411 if (info.isEdgeProp())
413 (mesh, mesh->n_edges(), info.propName(), min, max);
414 if (info.isFaceProp())
416 (mesh, mesh->n_faces(), info.propName(), min, max);
419#if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT)
420template <
typename Mesh,
typename T>
423 if (mesh == 0)
return;
425 if (info.isCellProp() && mesh->template cell_property_exists<T>(info.propName())) {
427 range3_ovm<OpenVolumeMesh::CellHandle, OpenVolumeMesh::CellPropertyT<T>, T>
428 (prop, mesh->n_cells(), min, max);
430 if (info.isEdgeProp() && mesh->template edge_property_exists<T>(info.propName())) {
432 range3_ovm<OpenVolumeMesh::EdgeHandle, OpenVolumeMesh::EdgePropertyT<T>, T>
433 (prop, mesh->n_edges(), min, max);
435 if (info.isFaceProp() && mesh->template face_property_exists<T>(info.propName())) {
437 range3_ovm<OpenVolumeMesh::FaceHandle, OpenVolumeMesh::FacePropertyT<T>, T>
438 (prop, mesh->n_faces(), min, max);
440 if (info.isHalfedgeProp() && mesh->template halfedge_property_exists<T>(info.propName())) {
442 range3_ovm<OpenVolumeMesh::HalfEdgeHandle, OpenVolumeMesh::HalfEdgePropertyT<T>, T>
443 (prop, mesh->n_halfedges(), min, max);
445 if (info.isHalffaceProp() && mesh->template halfface_property_exists<T>(info.propName())) {
447 range3_ovm<OpenVolumeMesh::HalfFaceHandle, OpenVolumeMesh::HalfFacePropertyT<T>, T>
448 (prop, mesh->n_halffaces(), min, max);
450 if (info.isVertexProp() && mesh->template vertex_property_exists<T>(info.propName())) {
452 range3_ovm<OpenVolumeMesh::VertexHandle, OpenVolumeMesh::VertexPropertyT<T>, T>
453 (prop, mesh->n_vertices(), min, max);
464 range2_om(
triMesh(obj->
id()), info, min, max);
466 range2_om(
polyMesh(obj->
id()), info, min, max);
468 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT
473 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
479void MultiObjectPropertyModel::setRange(
const PropertyInfo& info, QWidget* widget)
const
485 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
491 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
497 double min = +DBL_MAX;
498 double max = -DBL_MAX;
502 range1<double>(*o_it, info, min, max);
506 w->doubleFixedRange->toggle();
507 w->doubleFixedRangeMin->setValue(min);
508 w->doubleFixedRangeMax->setValue(max);
518 range1<int>(*o_it, info, min, max);
522 w->intFixedRange->toggle();
523 w->intFixedRangeMin->setValue(min);
524 w->intFixedRangeMax->setValue(max);
#define DATA_HEXAHEDRAL_MESH
#define DATA_POLYHEDRAL_MESH
#define DATA_TRIANGLE_MESH
bool dataType(DataType _type) const
virtual QWidget * getWidget() override
Returns the widget.
virtual void duplicateProperty(QModelIndexList selectedIndices) override
Duplicates the selected properties.
virtual void objectUpdated() override
Revisualizes visualized properties.
virtual void removeProperty(QModelIndexList selectedIndices) override
Removes the selected properties.
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const override
Returns the property info for the property with the given index.
virtual void clear(QModelIndexList selectedIndices) override
Clears the selected property visualization.
virtual void updateWidget(const QModelIndexList &selectedIndices) override
Updates the widget.
virtual void connectLogs(PropertyVisualizer *propViz) override
Connects the PropertyVisualizer log signals with the log slot.
virtual void gatherProperties() override
Searches for properties and creates PropertyVisualizers.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList()) override
Visualizes the selected properties.
virtual void hideWidget() override
Hides the widget.
Cellection of information about a property.
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const =0
Returns the property info for the property with the given index.
virtual void objectUpdated()=0
Revisualizes visualized properties.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList())=0
Visualizes the selected properties.
virtual void removeProperty(QModelIndexList selectedIndices)=0
Removes the selected properties.
virtual void gatherProperties()=0
Searches for properties and creates PropertyVisualizers.
QModelIndex indexFromFancyPropName(const QString &propName) const
Returns the index of the property with the given name.
virtual void clear(QModelIndexList selectedIndices)=0
Clears the selected property visualization.
virtual void duplicateProperty(QModelIndexList selectedIndices)=0
Duplicates the selected properties.
This class vizualizes a property.
Wraps the information of a type.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
Handle for a edge entity.
Handle for a face entity.
Handle for a halfedge entity.