Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remove function for Data1D. #73

Merged
merged 1 commit into from
Jan 22, 2025
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