Skip to content

Commit

Permalink
- Fixed issues with image which have level downsamples larger than 2
Browse files Browse the repository at this point in the history
- Update to latest version of UnitTest++
  • Loading branch information
GeertLitjens committed Nov 5, 2015
1 parent bd59ab2 commit c482137
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ENDIF(WIN32)

INSTALL(TARGETS core
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
LIBRARY DESTINATION bin
ARCHIVE DESTINATION lib
)

Expand Down
20 changes: 19 additions & 1 deletion executables/TestRunner/TestRunner.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "UnitTest++.h"
#include "XmlTestReporter.h"
#include "TestReporterStdout.h"
#include "TestData.h"
#include <iostream>
#include <fstream>

using namespace std;

Expand All @@ -23,5 +26,20 @@ int main(int argc, char* argv[])
std::cout << "Testing only suite " << suite << endl;
}
g_dataPath = argv[1];
return UnitTest::RunAllTests(xmlOutput.c_str(), suite.empty() ? NULL : suite.c_str());
if (xmlOutput.empty()) {
UnitTest::TestReporterStdout reporter;
UnitTest::TestRunner runner(reporter);
runner.RunTestsIf(UnitTest::Test::GetTestList(), suite.empty() ? NULL : suite.c_str(), UnitTest::True(), 0);
}
else {
std::ofstream f(xmlOutput);
if (f.good()) {
UnitTest::XmlTestReporter reporter(f);
UnitTest::TestRunner runner(reporter);
runner.RunTestsIf(UnitTest::Test::GetTestList(), suite.empty() ? NULL : suite.c_str(), UnitTest::True(), 0);
}
else {
std::cout << "Opening of XML file failed!" << endl;
}
}
}
23 changes: 16 additions & 7 deletions workstation/TileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,23 @@ unsigned char TileManager::providesCoverage(unsigned int level, int tile_x, int
}

bool TileManager::isCovered(unsigned int level, int tile_x, int tile_y) {
if (tile_x < 0 || tile_y < 0) {
return providesCoverage(level) == 2;
if (level > 0) {
if (tile_x < 0 || tile_y < 0) {
return providesCoverage(level) == 2;
}
else {
bool covered = true;
unsigned int downsample = _img->getLevelDownsample(level) / _img->getLevelDownsample(level - 1);
for (unsigned int x = 0; x < downsample; ++x) {
for (unsigned int y = 0; y < downsample; ++y) {
covered &= providesCoverage(level - 1, downsample * tile_x + x, downsample * tile_y + y) == 2;
}
}
return covered;
}
}
else {
return (providesCoverage(level - 1, 2 * tile_x, 2 * tile_y) == 2 &&
providesCoverage(level - 1, 2 * tile_x, 2 * tile_y + 1) == 2 &&
providesCoverage(level - 1, 2 * tile_x + 1, 2 * tile_y) == 2 &&
providesCoverage(level - 1, 2 * tile_x + 1, 2 * tile_y + 1) == 2);
return false;
}
}

Expand All @@ -150,7 +159,7 @@ void TileManager::setCoverage(unsigned int level, int tile_x, int tile_y, unsign
if (covers == 2 || covers == 0) {
float rectSize = _tileSize / (_img->getLevelDownsample(_lastRenderLevel) / _img->getLevelDownsample(level));
QPainterPath rect;
rect.addRect(QRectF(tile_x * rectSize, tile_y * rectSize, rectSize, rectSize));
rect.addRect(QRectF(tile_x * rectSize - 1, tile_y * rectSize - 1, rectSize + 1, rectSize + 1));
if (covers == 2) {
_coverageMaps[level] = _coverageMaps[level].united(rect);
}
Expand Down
2 changes: 1 addition & 1 deletion workstation/WSITileGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ WSITileGraphicsItem::WSITileGraphicsItem(QPixmap* item, unsigned int tileX, unsi
if (img) {
_img = img;
}
_physicalSize = _tileSize / static_cast<float>(pow(2, _lastRenderLevel - _itemLevel));
_physicalSize = _tileSize / (_img->getLevelDownsample(_lastRenderLevel) / _img->getLevelDownsample(_itemLevel));
this->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption);
_boundingRect = QRectF(-_physicalSize / 2., -_physicalSize / 2., _physicalSize, _physicalSize);
}
Expand Down

0 comments on commit c482137

Please sign in to comment.