diff --git a/Applications/DataExplorer/DataView/ElementTreeModel.cpp b/Applications/DataExplorer/DataView/ElementTreeModel.cpp index c6ee22c0257202a0b518d92965b306f1eebf9c45..4594364b1f1d23e2bcf18f5ee41489b16a1a526d 100644 --- a/Applications/DataExplorer/DataView/ElementTreeModel.cpp +++ b/Applications/DataExplorer/DataView/ElementTreeModel.cpp @@ -43,6 +43,8 @@ ElementTreeModel::~ElementTreeModel() void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, const unsigned elem_index) { + beginResetModel(); + _mesh_source = grid; this->clearView(); @@ -95,17 +97,20 @@ void ElementTreeModel::setElement(vtkUnstructuredGridAlgorithm const*const grid, TreeItem* nodeItem = new TreeItem(nodeData, nodeListItem); nodeListItem->appendChild(nodeItem); } - reset(); + endResetModel(); } void ElementTreeModel::clearView() { + beginResetModel(); _rootItem->removeChildren(0, _rootItem->childCount()); - reset(); + endResetModel(); } void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) { + beginResetModel(); + this->clearView(); QList<QVariant> mesh_name; @@ -180,7 +185,5 @@ void ElementTreeModel::setMesh(MeshLib::Mesh const& mesh) _rootItem->appendChild(vec_item); } - reset(); - + endResetModel(); } - diff --git a/Applications/DataExplorer/DataView/GeoTreeModel.cpp b/Applications/DataExplorer/DataView/GeoTreeModel.cpp index 8f93ca384a27d9016d3b9a6a0a9ca4e57fbb8d32..0c2a4b42d2faea14608f30e53b636fbbd614a01a 100644 --- a/Applications/DataExplorer/DataView/GeoTreeModel.cpp +++ b/Applications/DataExplorer/DataView/GeoTreeModel.cpp @@ -39,6 +39,8 @@ GeoTreeModel::~GeoTreeModel() void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVec) { + beginResetModel(); + const std::vector<GeoLib::Point*>* points = pointVec.getVector(); QList<QVariant> geoData; @@ -74,11 +76,13 @@ void GeoTreeModel::addPointList(QString geoName, GeoLib::PointVec const& pointVe INFO("Geometry \"%s\" built. %d points added.", geoName.toStdString().c_str(), nPoints); - reset(); + endResetModel(); } void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& polylineVec) { + beginResetModel(); + int nLists = _rootItem->childCount(); TreeItem* geo(NULL); for (int i = 0; i < nLists; i++) @@ -100,7 +104,8 @@ void GeoTreeModel::addPolylineList(QString geoName, GeoLib::PolylineVec const& p GeoObjectListItem* plyList = new GeoObjectListItem(plyData, geo, lines, GeoLib::GEOTYPE::POLYLINE); geo->appendChild(plyList); this->addChildren(plyList, polylineVec, 0, lines->size()); - reset(); + + endResetModel(); } void GeoTreeModel::appendPolylines(const std::string &name, GeoLib::PolylineVec const& polylineVec) @@ -114,10 +119,11 @@ void GeoTreeModel::appendPolylines(const std::string &name, GeoLib::PolylineVec static_cast<GeoObjectListItem*>(_lists[i]->child(j)); if (GeoLib::GEOTYPE::POLYLINE == parent->getType()) { + beginResetModel(); this->addChildren(parent, polylineVec, parent->childCount(), polylineVec.getVector()->size()); - reset(); + endResetModel(); parent->vtkSource()->Modified(); return; } @@ -166,6 +172,8 @@ void GeoTreeModel::addChildren(GeoObjectListItem* plyList, void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& surfaceVec) { + beginResetModel(); + int nLists = _rootItem->childCount(); TreeItem* geo(NULL); for (int i = 0; i < nLists; i++) @@ -188,7 +196,7 @@ void GeoTreeModel::addSurfaceList(QString geoName, GeoLib::SurfaceVec const& sur geo->appendChild(sfcList); this->addChildren(sfcList, surfaceVec, 0, surfaces->size()); - reset(); + endResetModel(); } void GeoTreeModel::appendSurfaces(const std::string &name, GeoLib::SurfaceVec const& surfaceVec) @@ -204,11 +212,12 @@ void GeoTreeModel::appendSurfaces(const std::string &name, GeoLib::SurfaceVec co static_cast<GeoObjectListItem*>(_lists[i]->child(j)); if (GeoLib::GEOTYPE::SURFACE == parent->getType()) { + beginResetModel(); this->addChildren(parent, surfaceVec, parent->childCount(), surfaceVec.getVector()->size()); parent->vtkSource()->Modified(); - reset(); + endResetModel(); return; } } diff --git a/Applications/DataExplorer/DataView/MshModel.cpp b/Applications/DataExplorer/DataView/MshModel.cpp index 224c8adf5427b5d84cf72a09d677e7713afc3bd4..8c32762e268ac34adfd7a737fba1bdd0ff7df61b 100644 --- a/Applications/DataExplorer/DataView/MshModel.cpp +++ b/Applications/DataExplorer/DataView/MshModel.cpp @@ -65,6 +65,8 @@ void MshModel::addMesh(MeshLib::Mesh* mesh) void MshModel::addMeshObject(const MeshLib::Mesh* mesh) { + beginResetModel(); + INFO("name: %s", mesh->getName().c_str()); QVariant const display_name (QString::fromStdString(mesh->getName())); QList<QVariant> meshData; @@ -84,7 +86,7 @@ void MshModel::addMeshObject(const MeshLib::Mesh* mesh) newMesh->appendChild(new TreeItem(elemData, newMesh)); } - reset(); + endResetModel(); emit meshAdded(this, this->index(_rootItem->childCount() - 1, 0, QModelIndex())); } @@ -134,9 +136,10 @@ bool MshModel::removeMesh(const std::string &name) TreeItem* item = _rootItem->child(i); if (item->data(0).toString().toStdString().compare(name) == 0) { + beginResetModel(); emit meshRemoved(this, this->index(i, 0, QModelIndex())); _rootItem->removeChildren(i,1); - reset(); + endResetModel(); return _project.removeMesh(name); } } @@ -201,4 +204,3 @@ vtkUnstructuredGridAlgorithm* MshModel::vtkSource(const std::string &name) const INFO("MshModel::vtkSource(): No entry found with name \"%s\".", name.c_str()); return nullptr; } - diff --git a/Applications/DataExplorer/DataView/StationTreeModel.cpp b/Applications/DataExplorer/DataView/StationTreeModel.cpp index 0dc9b0193df7fff517998f14cec84b81db3cfc18..1f413d956971a88d85513a87b36fff4eba7cffec 100644 --- a/Applications/DataExplorer/DataView/StationTreeModel.cpp +++ b/Applications/DataExplorer/DataView/StationTreeModel.cpp @@ -123,6 +123,8 @@ void StationTreeModel::setNameForItem(const std::string& stn_vec_name, */ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib::Point*>* stations) { + beginResetModel(); + QList<QVariant> grpName; if (listName.compare("") == 0) // if no name is given a default name is assigned { @@ -150,7 +152,7 @@ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib qDebug() << "List" << listName << "loaded, " << stations->size() << "items added."; - reset(); + endResetModel(); } /** @@ -181,4 +183,3 @@ void StationTreeModel::removeStationList(const std::string &name) if ( name.compare( _lists[i]->data(0).toString().toStdString() ) == 0 ) removeStationList(createIndex(_lists[i]->row(), 0, _lists[i])); } - diff --git a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp index 9795d6ea9d9d4d63263b330101b8f1b248b55d79..965140afa17d263f900bd30b016d32d58b709410 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPipeline.cpp @@ -277,6 +277,8 @@ void VtkVisPipeline::addPipelineItem(MshModel* model, const QModelIndex &idx) QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, const QModelIndex &parent) { + beginResetModel(); + item->Initialize(_renderer); TreeItem* parentItem = item->parentItem(); parentItem->appendChild(item); @@ -299,7 +301,7 @@ QModelIndex VtkVisPipeline::addPipelineItem(VtkVisPipelineItem* item, const QMod if (dynamic_cast<vtkImageAlgorithm*>(item->algorithm())) static_cast<vtkImageActor*>(item->actor())->InterpolateOff(); - reset(); + endResetModel(); emit vtkVisPipelineChanged(); emit itemSelected(newIndex);