File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,24 @@ Data1DEntity *MildredWidget::addData1D(const QString &tag)
204204 return entity;
205205}
206206
207+ // Remove data entity with the supplied data
208+ bool MildredWidget::removeData1D (const QString &tag)
209+ {
210+ // Check for existing tag
211+ auto it = std::find_if (dataEntities_.begin (), dataEntities_.end (), [tag](const auto &d) { return tag == d.first ; });
212+ if (it == dataEntities_.end ())
213+ {
214+ qDebug () << QString (" Data with tag '%1' does not exist, so it can't be removed from the plot.\n " ).arg (it->first );
215+ return false ;
216+ }
217+ auto &[entityTag, entity] = *it;
218+
219+ entity->setParent (static_cast <Qt3DCore::QNode *>(nullptr ));
220+ dataEntities_.erase (it);
221+
222+ return true ;
223+ }
224+
207225/*
208226 * Grouping
209227 */
Original file line number Diff line number Diff line change @@ -206,6 +206,8 @@ class MildredWidget : public QWidget
206206 public:
207207 // Add new data entity for supplied data
208208 Data1DEntity *addData1D (const QString &tag);
209+ // Remove data entity with the supplied data
210+ bool removeData1D (const QString &tag);
209211
210212 /*
211213 * Grouping
You can’t perform that action at this time.
0 commit comments