| 232 | } |
| 233 | |
| 234 | void PathologyViewer::initialize(std::shared_ptr<MultiResolutionImage> img) { |
| 235 | close(); |
| 236 | setEnabled(true); |
| 237 | _img = img; |
| 238 | unsigned int tileSize = 512; |
| 239 | unsigned int lastLevel = _img->getNumberOfLevels() - 1; |
| 240 | for (int i = lastLevel; i >= 0; --i) { |
| 241 | std::vector<unsigned long long> lastLevelDimensions = _img->getLevelDimensions(i); |
| 242 | if (lastLevelDimensions[0] > tileSize && lastLevelDimensions[1] > tileSize) { |
| 243 | lastLevel = i; |
| 244 | break; |
| 245 | } |
| 246 | } |
| 247 | _cache = new WSITileGraphicsItemCache(); |
| 248 | _cache->setMaxCacheSize(_cacheSize); |
| 249 | _ioThread = new IOThread(this); |
| 250 | _ioThread->setBackgroundImage(img); |
| 251 | _manager = new TileManager(_img, tileSize, lastLevel, _ioThread, _cache, scene()); |
| 252 | setMouseTracking(true); |
| 253 | std::vector<IOWorker*> workers = _ioThread->getWorkers(); |
| 254 | for (int i = 0; i < workers.size(); ++i) { |
| 255 | QObject::connect(workers[i], SIGNAL(tileLoaded(QPixmap*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, ImageSource*, QPixmap*)), _manager, SLOT(onTileLoaded(QPixmap*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, ImageSource*, QPixmap*))); |
| 256 | QObject::connect(workers[i], SIGNAL(foregroundTileRendered(QPixmap*, unsigned int, unsigned int, unsigned int)), _manager, SLOT(onForegroundTileRendered(QPixmap*, unsigned int, unsigned int, unsigned int))); |
| 257 | } |
| 258 | initializeImage(scene(), tileSize, lastLevel); |
| 259 | initializeGUIComponents(lastLevel); |
| 260 | QObject::connect(this, SIGNAL(backgroundChannelChanged(int)), _ioThread, SLOT(onBackgroundChannelChanged(int))); |
| 261 | QObject::connect(_cache, SIGNAL(itemEvicted(WSITileGraphicsItem*)), _manager, SLOT(onTileRemoved(WSITileGraphicsItem*))); |
| 262 | QObject::connect(this, SIGNAL(fieldOfViewChanged(const QRectF, const unsigned int)), this, SLOT(onFieldOfViewChanged(const QRectF, const unsigned int))); |
| 263 | QRectF FOV = this->mapToScene(this->rect()).boundingRect(); |
| 264 | QRectF FOVImage = QRectF(FOV.left() / this->_sceneScale, FOV.top() / this->_sceneScale, FOV.width() / this->_sceneScale, FOV.height() / this->_sceneScale); |
| 265 | emit fieldOfViewChanged(FOVImage, _img->getBestLevelForDownSample((1. / this->_sceneScale) / this->transform().m11())); |
| 266 | } |
| 267 | |
| 268 | void PathologyViewer::onForegroundImageChanged(std::weak_ptr<MultiResolutionImage> for_img, float scale) { |
| 269 | _for_img = for_img; |
no test coverage detected