| 329 | } |
| 330 | |
| 331 | void PathologyViewer::initializeGUIComponents(unsigned int level) { |
| 332 | // Initialize the minimap |
| 333 | std::vector<unsigned long long> overviewDimensions = _img->getLevelDimensions(level); |
| 334 | unsigned int size = overviewDimensions[0] * overviewDimensions[1] * _img->getSamplesPerPixel(); |
| 335 | unsigned char* overview = new unsigned char[size]; |
| 336 | _img->getRawRegion<unsigned char>(0, 0, overviewDimensions[0], overviewDimensions[1], level, overview); |
| 337 | QImage ovImg; |
| 338 | if (_img->getColorType() == pathology::ColorType::RGBA) { |
| 339 | ovImg = QImage(overview, overviewDimensions[0], overviewDimensions[1], overviewDimensions[0] * 4, QImage::Format_RGBA8888).convertToFormat(QImage::Format_RGB888); |
| 340 | } |
| 341 | else if (_img->getColorType() == pathology::ColorType::RGB) { |
| 342 | ovImg = QImage(overview, overviewDimensions[0], overviewDimensions[1], overviewDimensions[0] * 3, QImage::Format_RGB888); |
| 343 | } |
| 344 | QPixmap ovPixMap = QPixmap(QPixmap::fromImage(ovImg)); |
| 345 | delete[] overview; |
| 346 | if (_map) { |
| 347 | _map->deleteLater(); |
| 348 | _map = NULL; |
| 349 | } |
| 350 | _map = new MiniMap(ovPixMap, this); |
| 351 | if (_scaleBar) { |
| 352 | _scaleBar->deleteLater(); |
| 353 | _scaleBar = NULL; |
| 354 | } |
| 355 | std::vector<double> spacing = _img->getSpacing(); |
| 356 | if (!spacing.empty()) { |
| 357 | _scaleBar = new ScaleBar(spacing[0], this); |
| 358 | } |
| 359 | else { |
| 360 | _scaleBar = new ScaleBar(-1, this); |
| 361 | } |
| 362 | if (this->layout()) { |
| 363 | delete this->layout(); |
| 364 | } |
| 365 | QHBoxLayout * Hlayout = new QHBoxLayout(this); |
| 366 | QVBoxLayout * Vlayout = new QVBoxLayout(); |
| 367 | QVBoxLayout * Vlayout2 = new QVBoxLayout(); |
| 368 | Vlayout2->addStretch(4); |
| 369 | Hlayout->addLayout(Vlayout2); |
| 370 | Hlayout->addStretch(4); |
| 371 | Hlayout->setContentsMargins(30, 30, 30, 30); |
| 372 | Hlayout->addLayout(Vlayout, 1); |
| 373 | Vlayout->addStretch(4); |
| 374 | if (_map) { |
| 375 | Vlayout->addWidget(_map, 1); |
| 376 | } |
| 377 | if (_scaleBar) { |
| 378 | Vlayout2->addWidget(_scaleBar); |
| 379 | } |
| 380 | _map->setTileManager(_manager); |
| 381 | QObject::connect(this, SIGNAL(updateBBox(const QRectF&)), _map, SLOT(updateFieldOfView(const QRectF&))); |
| 382 | QObject::connect(_manager, SIGNAL(coverageUpdated()), _map, SLOT(onCoverageUpdated())); |
| 383 | QObject::connect(_map, SIGNAL(positionClicked(QPointF)), this, SLOT(moveTo(const QPointF&))); |
| 384 | QObject::connect(this, SIGNAL(fieldOfViewChanged(const QRectF&, const unsigned int)), _scaleBar, SLOT(updateForFieldOfView(const QRectF&))); |
| 385 | if (this->window()) { |
| 386 | _settings->beginGroup("ASAP"); |
| 387 | QMenu* viewMenu = this->window()->findChild<QMenu*>("menuView"); |
| 388 | if (viewMenu) { |
nothing calls this directly
no test coverage detected