Skip to content
Snippets Groups Projects
Commit 7632aac6 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[DE] Update ElementTree bounds. More types.

Update for new signature of the getValueBounds().
Generalize to more types.
Deduplicate creation of the entries.
parent 42c8dd02
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,22 @@
#include "TreeItem.h"
namespace
{
template <typename PropertyType>
QList<QVariant> propertyBounds(PropertyType const& property)
{
auto const bounds = MeshLib::MeshInformation::getValueBounds(property);
if (bounds.has_value())
{
return {"[" + QString::number(bounds->first) + ",",
QString::number(bounds->second) + "]"};
}
// Makeup the same structure of output as in the valid case above.
return {"[empty,", "empty]"};
}
} // namespace
/**
* Constructor.
*/
......@@ -170,35 +186,53 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh)
for (auto [name, property] : mesh.getProperties())
{
QList<QVariant> array_info;
array_info << QString::fromStdString(name) + ": ";
if (auto const vec_bounds = // test if boost::optional is empty
MeshLib::MeshInformation::getValueBounds<int>(*property))
QList<QVariant> array_info{QString::fromStdString(name) + ": "};
if (auto p = dynamic_cast<MeshLib::PropertyVector<double>*>(property))
{
array_info << "[" + QString::number(vec_bounds->first) + ","
<< QString::number(vec_bounds->second) + "]";
array_info.append(propertyBounds(*p));
}
else if (auto const vec_bounds = // test if boost::optional is empty
MeshLib::MeshInformation::getValueBounds<double>(*property))
else if (auto p =
dynamic_cast<MeshLib::PropertyVector<float>*>(property))
{
array_info << "[" + QString::number(vec_bounds->first) + ","
<< QString::number(vec_bounds->second) + "]";
array_info.append(propertyBounds(*p));
}
else
else if (auto p = dynamic_cast<MeshLib::PropertyVector<int>*>(property))
{
// Makeup the same structure of output as in the valid cases above.
array_info << "[error,"
<< "error]";
array_info.append(propertyBounds(*p));
}
if (array_info.size() == 1)
else if (auto p =
dynamic_cast<MeshLib::PropertyVector<unsigned>*>(property))
{
array_info.append(propertyBounds(*p));
}
else if (auto p =
dynamic_cast<MeshLib::PropertyVector<long>*>(property))
{
array_info.append(propertyBounds(*p));
}
else if (auto p = dynamic_cast<MeshLib::PropertyVector<unsigned long>*>(
property))
{
array_info.append(propertyBounds(*p));
}
else if (auto p = dynamic_cast<MeshLib::PropertyVector<std::size_t>*>(
property))
{
array_info.append(propertyBounds(*p));
}
else if (auto p =
dynamic_cast<MeshLib::PropertyVector<char>*>(property))
{
array_info.append(propertyBounds(*p));
}
else
{ // Unhandled property vector type.
array_info << "[ ?"
<< "? ]"
<< "";
}
auto* vec_item = new TreeItem(array_info, _rootItem);
_rootItem->appendChild(vec_item);
_rootItem->appendChild(new TreeItem(array_info, _rootItem));
}
endResetModel();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment