| 174 | } |
| 175 | |
| 176 | void Plot2DWidget::showGoToDialog() |
| 177 | { |
| 178 | Plot2DGoToDialog goto_dialog(this, |
| 179 | canvas_->getMapper().getDim(DIM::X).getDimNameShort(), |
| 180 | canvas_->getMapper().getDim(DIM::Y).getDimNameShort()); |
| 181 | //set range |
| 182 | const auto& area = canvas()->getVisibleArea().getAreaXY(); |
| 183 | goto_dialog.setRange(area); |
| 184 | |
| 185 | auto all_area_xy = canvas_->getMapper().mapRange(canvas_->getDataRange()); |
| 186 | goto_dialog.setMinMaxOfRange(all_area_xy); |
| 187 | // feature numbers only for consensus&feature maps |
| 188 | goto_dialog.enableFeatureNumber(canvas()->getCurrentLayer().type == LayerDataBase::DT_FEATURE || canvas()->getCurrentLayer().type == LayerDataBase::DT_CONSENSUS); |
| 189 | // execute |
| 190 | if (goto_dialog.exec()) |
| 191 | { |
| 192 | if (goto_dialog.showRange()) |
| 193 | { |
| 194 | canvas()->setVisibleArea(goto_dialog.getRange()); |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | String feature_id = goto_dialog.getFeatureNumber(); |
| 199 | //try to convert to UInt64 id |
| 200 | UniqueIdInterface uid; |
| 201 | uid.setUniqueId(feature_id); |
| 202 | |
| 203 | Size feature_index(-1); // TODO : not use -1 |
| 204 | auto* lf = dynamic_cast<LayerDataFeature*>(&canvas()->getCurrentLayer()); |
| 205 | auto* lc = dynamic_cast<LayerDataConsensus*>(&canvas()->getCurrentLayer()); |
| 206 | if (lf) |
| 207 | { |
| 208 | feature_index = lf->getFeatureMap()->uniqueIdToIndex(uid.getUniqueId()); |
| 209 | } |
| 210 | else if (lc) |
| 211 | { |
| 212 | feature_index = lc->getConsensusMap()->uniqueIdToIndex(uid.getUniqueId()); |
| 213 | } |
| 214 | if (feature_index == Size(-1)) // UID does not exist |
| 215 | { |
| 216 | try |
| 217 | { |
| 218 | feature_index = feature_id.toInt(); // normal feature index as stored in map |
| 219 | } |
| 220 | catch (...) // we might still deal with a UID, so toInt() will throw as the number is too big |
| 221 | { |
| 222 | feature_index = Size(-1); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | //check if the feature index exists |
| 227 | if ((lf && feature_index >= lf->getFeatureMap()->size()) || (lc && feature_index >= lc->getConsensusMap()->size())) |
| 228 | { |
| 229 | QMessageBox::warning(this, "Invalid feature number", "Feature number too large/UniqueID not found.\nPlease select a valid feature!"); |
| 230 | return; |
| 231 | } |
| 232 | // display feature with a margin |
| 233 | RangeAllType range; |
nothing calls this directly
no test coverage detected