Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,24 @@ Data1DEntity *MildredWidget::addData1D(const QString &tag)
return entity;
}

// Remove data entity with the supplied data
bool MildredWidget::removeData1D(const QString &tag)
{
// Check for existing tag
auto it = std::find_if(dataEntities_.begin(), dataEntities_.end(), [tag](const auto &d) { return tag == d.first; });
if (it == dataEntities_.end())
{
qDebug() << QString("Data with tag '%1' does not exist, so it can't be removed from the plot.\n").arg(it->first);
return false;
}
auto &[entityTag, entity] = *it;

entity->setParent(static_cast<Qt3DCore::QNode *>(nullptr));
dataEntities_.erase(it);

return true;
}

/*
* Grouping
*/
Expand Down
2 changes: 2 additions & 0 deletions src/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ class MildredWidget : public QWidget
public:
// Add new data entity for supplied data
Data1DEntity *addData1D(const QString &tag);
// Remove data entity with the supplied data
bool removeData1D(const QString &tag);

/*
* Grouping
Expand Down
Loading