| 325 | } |
| 326 | |
| 327 | void DatapickerImageView::drawBackground(QPainter* painter, const QRectF& rect) { |
| 328 | painter->save(); |
| 329 | |
| 330 | QRectF scene_rect = sceneRect(); |
| 331 | if (!scene_rect.contains(rect)) |
| 332 | painter->fillRect(rect, Qt::lightGray); |
| 333 | |
| 334 | // canvas |
| 335 | if (m_image->isLoaded) { |
| 336 | if (m_image->plotImageType() == DatapickerImage::PlotImageType::OriginalImage) { |
| 337 | const QImage& todraw = m_image->originalPlotImage.scaled(scene_rect.width(), scene_rect.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
| 338 | painter->drawImage(scene_rect.topLeft(), todraw); |
| 339 | } else if (m_image->plotImageType() == DatapickerImage::PlotImageType::ProcessedImage) { |
| 340 | const QImage& todraw = m_image->processedPlotImage.scaled(scene_rect.width(), scene_rect.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
| 341 | painter->drawImage(scene_rect.topLeft(), todraw); |
| 342 | } else { |
| 343 | painter->fillRect(scene_rect, Qt::white); |
| 344 | } |
| 345 | } else { |
| 346 | painter->setBrush(QBrush(Qt::gray)); |
| 347 | painter->drawRect(scene_rect); |
| 348 | } |
| 349 | |
| 350 | invalidateScene(rect, QGraphicsScene::BackgroundLayer); |
| 351 | painter->restore(); |
| 352 | } |
| 353 | |
| 354 | // ############################################################################## |
| 355 | // #################################### Events ############################### |