| 1262 | } |
| 1263 | |
| 1264 | void ModelViewerWidget::UploadImageData(const bool selection_mode) { |
| 1265 | makeCurrent(); |
| 1266 | |
| 1267 | std::vector<LinePainter::Data> line_data; |
| 1268 | line_data.reserve(8 * reg_image_ids.size()); |
| 1269 | |
| 1270 | // Thicker overlay lines (image-center indicators for spherical cameras). |
| 1271 | std::vector<LinePainter::Data> axis_line_data; |
| 1272 | |
| 1273 | std::vector<TrianglePainter::Data> triangle_data; |
| 1274 | triangle_data.reserve(2 * reg_image_ids.size()); |
| 1275 | |
| 1276 | const frame_t selected_frame_id = selected_image_id_ == kInvalidImageId |
| 1277 | ? kInvalidFrameId |
| 1278 | : images[selected_image_id_].FrameId(); |
| 1279 | |
| 1280 | for (const image_t image_id : reg_image_ids) { |
| 1281 | const Image& image = images[image_id]; |
| 1282 | const Camera& camera = cameras[image.CameraId()]; |
| 1283 | |
| 1284 | RGBAColor plane_color; |
| 1285 | RGBAColor frame_color; |
| 1286 | if (selection_mode) { |
| 1287 | const size_t index = selection_buffer_.size(); |
| 1288 | selection_buffer_.push_back( |
| 1289 | std::make_pair(image_id, SelectionType::kImage)); |
| 1290 | plane_color = frame_color = IndexToRGB(index); |
| 1291 | } else { |
| 1292 | if (image_id == selected_image_id_) { |
| 1293 | plane_color = kSelectedImagePlaneColor; |
| 1294 | frame_color = kSelectedImageFrameColor; |
| 1295 | } else if (selected_frame_id != kInvalidFrameId && |
| 1296 | image.FrameId() == selected_frame_id) { |
| 1297 | plane_color = kSelectedFramePlaneColor; |
| 1298 | frame_color = kSelectedFrameFrameColor; |
| 1299 | } else { |
| 1300 | Eigen::Vector4f plane_colorf; |
| 1301 | Eigen::Vector4f frame_colorf; |
| 1302 | image_colormap_->ComputeColor(image, &plane_colorf, &frame_colorf); |
| 1303 | plane_color = FloatColorToUint8(plane_colorf); |
| 1304 | frame_color = FloatColorToUint8(frame_colorf); |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | // Lines are not colored with the indexed color in selection mode, so do not |
| 1309 | // show them, so they do not block the selection process |
| 1310 | BuildCameraModel(image.CamFromWorld(), |
| 1311 | camera, |
| 1312 | image_size_, |
| 1313 | plane_color, |
| 1314 | frame_color, |
| 1315 | model_origin_, |
| 1316 | model_scale_, |
| 1317 | options_->render->show_camera_orientation, |
| 1318 | &triangle_data, |
| 1319 | selection_mode ? nullptr : &line_data, |
| 1320 | selection_mode ? nullptr : &axis_line_data); |
| 1321 | } |
nothing calls this directly
no test coverage detected