Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 651:b63dfd7e2780 single-point
Updates for SparseOneDimensionalModel in new API
author | Chris Cannam |
---|---|
date | Thu, 21 Mar 2019 13:34:34 +0000 |
parents | 284cb118368e |
children | 4f53620962d9 |
comparison
equal
deleted
inserted
replaced
650:ed9cb577eb7c | 651:b63dfd7e2780 |
---|---|
1133 } | 1133 } |
1134 | 1134 |
1135 if (layer) { | 1135 if (layer) { |
1136 | 1136 |
1137 Model *model = layer->getModel(); | 1137 Model *model = layer->getModel(); |
1138 SparseOneDimensionalModel *sodm = dynamic_cast<SparseOneDimensionalModel *> | 1138 SparseOneDimensionalModel *sodm = |
1139 (model); | 1139 dynamic_cast<SparseOneDimensionalModel *>(model); |
1140 | 1140 |
1141 if (sodm) { | 1141 if (sodm) { |
1142 SparseOneDimensionalModel::Point point(frame, ""); | 1142 Event point(frame, ""); |
1143 | 1143 Event prevPoint(0); |
1144 SparseOneDimensionalModel::Point prevPoint(0); | |
1145 bool havePrevPoint = false; | 1144 bool havePrevPoint = false; |
1146 | 1145 |
1147 SparseOneDimensionalModel::EditCommand *command = | 1146 ChangeEventsCommand *command = |
1148 new SparseOneDimensionalModel::EditCommand(sodm, tr("Add Point")); | 1147 new ChangeEventsCommand(sodm, tr("Add Point")); |
1149 | 1148 |
1150 if (m_labeller) { | 1149 if (m_labeller) { |
1151 | 1150 |
1152 if (m_labeller->requiresPrevPoint()) { | 1151 if (m_labeller->requiresPrevPoint()) { |
1153 | 1152 |
1154 SparseOneDimensionalModel::PointList prevPoints = | 1153 if (sodm->getNearestEventMatching |
1155 sodm->getPreviousPoints(frame); | 1154 (frame, |
1156 | 1155 [](Event) { return true; }, |
1157 if (!prevPoints.empty()) { | 1156 EventSeries::Backward, |
1158 prevPoint = *prevPoints.begin(); | 1157 prevPoint)) { |
1159 havePrevPoint = true; | 1158 havePrevPoint = true; |
1160 } | 1159 } |
1161 } | 1160 } |
1162 | 1161 |
1163 m_labeller->setSampleRate(sodm->getSampleRate()); | 1162 m_labeller->setSampleRate(sodm->getSampleRate()); |
1164 | 1163 |
1165 if (m_labeller->actingOnPrevEvent() && havePrevPoint) { | 1164 Labeller::Relabelling relabelling = m_labeller->label |
1166 command->deletePoint(prevPoint); | |
1167 } | |
1168 /*!!! to be updated after we have switched SODM to new API | |
1169 m_labeller->label<SparseOneDimensionalModel::Point> | |
1170 (point, havePrevPoint ? &prevPoint : nullptr); | 1165 (point, havePrevPoint ? &prevPoint : nullptr); |
1171 */ | 1166 |
1172 if (m_labeller->actingOnPrevEvent() && havePrevPoint) { | 1167 if (relabelling.first == Labeller::AppliesToPreviousEvent) { |
1173 command->addPoint(prevPoint); | 1168 command->remove(prevPoint); |
1169 command->add(relabelling.second); | |
1170 } else { | |
1171 point = relabelling.second; | |
1174 } | 1172 } |
1175 } | 1173 } |
1176 | 1174 |
1177 command->addPoint(point); | 1175 command->add(point); |
1178 | 1176 |
1179 command->setName(tr("Add Point at %1 s") | 1177 command->setName(tr("Add Point at %1 s") |
1180 .arg(RealTime::frame2RealTime | 1178 .arg(RealTime::frame2RealTime |
1181 (frame, | 1179 (frame, |
1182 sodm->getSampleRate()) | 1180 sodm->getSampleRate()) |