43 #include "MultiObjectPropertyModel.hh" 45 #include "PropertyModelFactory.hh" 46 #include "OpenMesh/OMPropertyModel.hh" 48 #ifdef ENABLE_OPENVOLUMEMESH 49 #include "OpenVolumeMesh/OVMPropertyModelT.hh" 54 MultiObjectPropertyModel::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);
62 MultiObjectPropertyModel::~MultiObjectPropertyModel()
64 for (
size_t i = 0; i < propWidgets.size(); ++i)
66 delete propWidgets[i];
71 QVariant MultiObjectPropertyModel::data(
const QModelIndex & index,
int role)
const 75 return QVariant(propNames[index.row()]);
77 return QVariant::Invalid;
81 int MultiObjectPropertyModel::rowCount(
const QModelIndex & parent)
const 83 return propNames.size();
86 QVariant MultiObjectPropertyModel::headerData(
int section, Qt::Orientation orientation,
int role)
const 88 return QVariant::Invalid;
99 if (model == 0)
continue;
109 if (selectedIndices.size() < 1)
return;
115 if (model == 0)
continue;
118 QModelIndexList indexList;
119 QWidgetList widgetList;
121 for (
int i = 0; i < selectedIndices.size(); ++i)
123 const QString
name = selectedIndices[i].data().toString();
127 if (!idx.isValid())
continue;
130 indexList.append(idx);
131 widgetList.append(propWidgets[selectedIndices[i].row()]);
144 if (selectedIndices.size() < 1)
return;
149 if (model == 0)
continue;
151 QModelIndexList indexList;
153 for (
int i = 0; i < selectedIndices.size(); ++i)
155 const QString
name = selectedIndices[i].data().toString();
159 if (!idx.isValid())
continue;
162 indexList.append(idx);
177 if (selectedIndices.size() < 1)
return;
182 if (model == 0)
continue;
184 QModelIndexList indexList;
186 for (
int i = 0; i < selectedIndices.size(); ++i)
188 const QString
name = selectedIndices[i].data().toString();
192 if (!idx.isValid())
continue;
195 indexList.append(idx);
212 for (
size_t i = 0; i < propWidgets.size(); ++i)
214 delete propWidgets[i];
222 if (model == 0)
continue;
225 for (
int i = 0; i < model->rowCount(); ++i)
227 const QModelIndex idx = model->index(i, 0);
228 const QString
name = idx.data().toString();
231 if (std::find(propNames.begin(), propNames.end(),
name) == propNames.end())
234 QWidget* widget = createWidgetForType(info.typeinfo());
235 setRange(info, widget);
237 propNames.push_back(name);
238 propInfos.push_back(info);
239 propWidgets.push_back(widget);
250 if (selectedIndices.size() < 1)
return;
255 if (model == 0)
continue;
257 QModelIndexList indexList;
259 for (
int i = 0; i < selectedIndices.size(); ++i)
261 const QString
name = selectedIndices[i].data().toString();
265 if (!idx.isValid())
continue;
268 indexList.append(idx);
271 model->
clear(indexList);
287 QLayout* layout = widget->layout();
289 for (
unsigned int i = 0; i < propWidgets.size(); ++i)
291 propWidgets[i]->hide();
294 for (
int i = 0; i < selectedIndices.size(); ++i)
296 const int row = selectedIndices[i].row();
297 QWidget* w = propWidgets[row];
298 layout->addWidget(w);
302 widget->setLayout(layout);
312 return propInfos[index.row()];
315 QWidget* MultiObjectPropertyModel::createWidgetForType(
const TypeInfoWrapper& info)
const 321 return new BooleanWidget();
323 return new IntegerWidget();
325 return new IntegerWidget();
327 return new DoubleWidget();
329 return new VectorWidget;
331 return new VectorWidget;
333 return new VectorWidget;
335 return new VectorWidget;
337 #ifdef ENABLE_SKELETON_SUPPORT 339 return new SkinWeightsWidget;
346 #if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) 348 return new BooleanWidget();
350 return new IntegerWidget();
352 return new IntegerWidget();
354 return new DoubleWidget();
356 return new VectorWidget();
358 return new VectorWidget();
365 return new QWidget();
368 template <
typename ItemHandle,
typename PropHandle,
typename T>
373 if (!ph.is_valid())
return;
375 for (
unsigned int i = 0; i < n; ++i)
377 const ItemHandle ih(i);
378 min = std::min(min, mesh->
property(ph, ih));
379 max = std::max(max, mesh->
property(ph, ih));
383 template <
typename ItemHandle,
typename Property,
typename T>
384 void range3_ovm(Property& prop,
unsigned int n, T& min, T& max)
386 for (
unsigned int i = 0; i < n; ++i)
388 const ItemHandle ih(i);
389 min = std::min(min, prop[ih]);
390 max = std::max(max, prop[ih]);
394 template <
typename Mesh,
typename T>
397 if (mesh == 0)
return;
399 if (info.isVertexProp())
401 (mesh, mesh->n_vertices(), info.propName(), min, max);
402 if (info.isHalfedgeProp())
404 (mesh, mesh->n_halfedges(), info.propName(), min, max);
405 if (info.isEdgeProp())
407 (mesh, mesh->n_edges(), info.propName(), min, max);
408 if (info.isFaceProp())
410 (mesh, mesh->n_faces(), info.propName(), min, max);
413 #if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT) 414 template <
typename Mesh,
typename T>
417 if (mesh == 0)
return;
419 if (info.isCellProp() && mesh->template cell_property_exists<T>(info.propName())) {
421 range3_ovm<OpenVolumeMesh::CellHandle, OpenVolumeMesh::CellPropertyT<T>, T>
422 (prop, mesh->n_cells(), min, max);
424 if (info.isEdgeProp() && mesh->template edge_property_exists<T>(info.propName())) {
426 range3_ovm<OpenVolumeMesh::EdgeHandle, OpenVolumeMesh::EdgePropertyT<T>, T>
427 (prop, mesh->n_edges(), min, max);
429 if (info.isFaceProp() && mesh->template face_property_exists<T>(info.propName())) {
431 range3_ovm<OpenVolumeMesh::FaceHandle, OpenVolumeMesh::FacePropertyT<T>, T>
432 (prop, mesh->n_faces(), min, max);
434 if (info.isHalfedgeProp() && mesh->template halfedge_property_exists<T>(info.propName())) {
436 range3_ovm<OpenVolumeMesh::HalfEdgeHandle, OpenVolumeMesh::HalfEdgePropertyT<T>, T>
437 (prop, mesh->n_halfedges(), min, max);
439 if (info.isHalffaceProp() && mesh->template halfface_property_exists<T>(info.propName())) {
441 range3_ovm<OpenVolumeMesh::HalfFaceHandle, OpenVolumeMesh::HalfFacePropertyT<T>, T>
442 (prop, mesh->n_halffaces(), min, max);
444 if (info.isVertexProp() && mesh->template vertex_property_exists<T>(info.propName())) {
446 range3_ovm<OpenVolumeMesh::VertexHandle, OpenVolumeMesh::VertexPropertyT<T>, T>
447 (prop, mesh->n_vertices(), min, max);
452 template <
typename T>
458 range2_om(
triMesh(obj->
id()), info, min, max);
460 range2_om(
polyMesh(obj->
id()), info, min, max);
462 #ifdef ENABLE_POLYHEDRALMESH_SUPPORT 467 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 473 void MultiObjectPropertyModel::setRange(
const PropertyInfo& info, QWidget* widget)
const 479 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 485 #ifdef ENABLE_HEXAHEDRALMESH_SUPPORT 491 double min = +DBL_MAX;
492 double max = -DBL_MAX;
496 range1<double>(*o_it, info, min, max);
499 DoubleWidget* w =
static_cast<DoubleWidget*
>(widget);
500 w->doubleFixedRange->toggle();
501 w->doubleFixedRangeMin->setValue(min);
502 w->doubleFixedRangeMax->setValue(max);
512 range1<int>(*o_it, info, min, max);
515 IntegerWidget* w =
static_cast<IntegerWidget*
>(widget);
516 w->intFixedRange->toggle();
517 w->intFixedRangeMin->setValue(min);
518 w->intFixedRangeMax->setValue(max);
Handle for a edge entity.
virtual void objectUpdated() override
Revisualizes visualized properties.
Handle for a face entity.
#define DATA_POLYHEDRAL_MESH
virtual void duplicateProperty(QModelIndexList selectedIndices) override
Duplicates the selected properties.
#define DATA_TRIANGLE_MESH
virtual void removeProperty(QModelIndexList selectedIndices)=0
Removes the selected properties.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList()) override
Visualizes the selected properties.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
Wraps the information of a type.
virtual void clear(QModelIndexList selectedIndices) override
Clears the selected property visualization.
Handle for a halfedge entity.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
#define DATA_HEXAHEDRAL_MESH
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
virtual QWidget * getWidget() override
Returns the widget.
Handle for a vertex entity.
bool get_property_handle(VPropHandleT< T > &_ph, const std::string &_name) const
virtual void clear(QModelIndexList selectedIndices)=0
Clears the selected property visualization.
bool dataType(DataType _type) const
virtual void gatherProperties() override
Searches for properties and creates PropertyVisualizers.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const =0
Returns the property info for the property with the given index.
virtual void visualize(QModelIndexList selectedIndices, QWidgetList widgets=QWidgetList())=0
Visualizes the selected properties.
virtual void objectUpdated()=0
Revisualizes visualized properties.
Cellection of information about a property.
virtual void hideWidget() override
Hides the widget.
QString name()
Return a name for the plugin.
virtual void removeProperty(QModelIndexList selectedIndices) override
Removes the selected properties.
This class vizualizes a property.
PropertyT< T > & property(VPropHandleT< T > _ph)
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const override
Returns the property info for the property with the given index.
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
virtual void connectLogs(PropertyVisualizer *propViz) override
Connects the PropertyVisualizer log signals with the log slot.
virtual void duplicateProperty(QModelIndexList selectedIndices)=0
Duplicates the selected properties.
virtual void updateWidget(const QModelIndexList &selectedIndices) override
Updates the widget.
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.