5#include "slideio/core/slideio_core_def.hpp"
6#include "slideio/base/slideio_structs.hpp"
10#pragma warning( push )
11#pragma warning(disable: 4251)
16 class SLIDEIO_CORE_EXPORTS LevelInfo
19 friend std::ostream& operator<<(std::ostream& os,
const slideio::LevelInfo& levelInfo)
21 os <<
"Level: " << levelInfo.getLevel() << std::endl;
22 os <<
"Size: " << levelInfo.getSize().width <<
"x" << levelInfo.getSize().height << std::endl;
23 os <<
"Scale: " << levelInfo.getScale() << std::endl;
24 os <<
"Magnification: " << levelInfo.getMagnification() << std::endl;
25 os <<
"Tile Size: " << levelInfo.getTileSize().width <<
"x" << levelInfo.getTileSize().height << std::endl;
29 LevelInfo() =
default;
31 LevelInfo(
int level,
const Size& size,
double scale,
double magnification,
const Size& tileSize)
32 : m_level(level), m_size(size), m_scale(scale), m_magnification(magnification), m_tileSize(tileSize) {}
34 LevelInfo(
const LevelInfo& other) {
35 m_level = other.m_level;
36 m_size = other.m_size;
37 m_scale = other.m_scale;
38 m_magnification = other.m_magnification;
39 m_tileSize = other.m_tileSize;
42 LevelInfo& operator=(
const LevelInfo& other) {
44 m_level = other.m_level;
45 m_size = other.m_size;
46 m_scale = other.m_scale;
47 m_magnification = other.m_magnification;
48 m_tileSize = other.m_tileSize;
53 bool operator==(
const LevelInfo& other)
const {
54 return m_level == other.m_level &&
55 m_size.width == other.m_size.width &&
56 m_size.height == other.m_size.height &&
57 std::fabs(m_scale - other.m_scale) < 1.e-2 &&
58 std::fabs(m_magnification - other.m_magnification) < 1.e-2 &&
59 m_tileSize.width == other.m_tileSize.width &&
60 m_tileSize.height == other.m_tileSize.height;
63 void updateTileCount()
const {
64 if (getTileSize().width > 0 && getTileSize().height > 0) {
65 const int tilesX = (getSize().width - 1) / getTileSize().width + 1;
66 const int tilesY = (getSize().height - 1) / getTileSize().height + 1;
67 m_tileCount = tilesX * tilesY;
74 int getLevel()
const {
return m_level; }
75 void setLevel(
int level) { m_level = level; }
77 Size getSize()
const {
return m_size; }
78 void setSize(
const Size& size) { m_size = size; }
80 double getScale()
const {
return m_scale; }
81 void setScale(
double scale) { m_scale = scale; }
83 double getMagnification()
const {
return m_magnification; }
84 void setMagnification(
double magnification) { m_magnification = magnification; }
86 Size getTileSize()
const {
return m_tileSize; }
87 void setTileSize(
const Size& tileSize) { m_tileSize = tileSize; }
89 int getTileCount()
const {
95 std::string toString()
const;
97 Rect getTileRect(
int tileIndex)
const {
99 const int tileCount = getTileCount();
101 const int tilesX = (m_size.width - 1) / m_tileSize.width + 1;
102 const int tilesY = (m_size.height - 1) / m_tileSize.height + 1;
103 const int tileY = tileIndex / tilesX;
104 const int tileX = tileIndex % tilesX;
105 tileRect.x = tileX * m_tileSize.width;
106 tileRect.y = tileY * m_tileSize.height;
107 tileRect.width = m_tileSize.width;
108 tileRect.height = m_tileSize.height;
113 tileRect.width = m_size.width;
114 tileRect.height = m_size.height;
122 double m_scale = 0.0;
123 double m_magnification = 0.0;
125 mutable int m_tileCount = 0;
130#pragma warning( pop )
Definition: exceptions.hpp:15