SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
levelinfo.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4#pragma once
5#include "slideio/core/slideio_core_def.hpp"
6#include <opencv2/core.hpp>
7#include <iostream>
8
9#if defined(_MSC_VER)
10#pragma warning( push )
11#pragma warning(disable: 4251)
12#endif
13
14namespace slideio
15{
16 class SLIDEIO_CORE_EXPORTS LevelInfo
17 {
18 public:
19 friend std::ostream& operator<<(std::ostream& os, const slideio::LevelInfo& levelInfo)
20 {
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;
26 return os;
27 }
28 public:
29 LevelInfo() = default;
30
31 LevelInfo(int level, const cv::Size& size, double scale, double magnification, const cv::Size& tileSize)
32 : m_level(level), m_size(size), m_scale(scale), m_magnification(magnification), m_tileSize(tileSize) {}
33
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;
40 }
41
42 LevelInfo& operator=(const LevelInfo& other) {
43 if (this != &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;
49 }
50 return *this;
51 }
52
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 fabs(m_scale - other.m_scale) < 1.e-2 &&
58 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;
61 }
62
63 int getLevel() const { return m_level; }
64 void setLevel(int level) { m_level = level; }
65
66 cv::Size getSize() const { return m_size; }
67 void setSize(const cv::Size& size) { m_size = size; }
68
69 double getScale() const { return m_scale; }
70 void setScale(double scale) { m_scale = scale; }
71
72 double getMagnification() const { return m_magnification; }
73 void setMagnification(double magnification) { m_magnification = magnification; }
74
75 cv::Size getTileSize() const { return m_tileSize; }
76 void setTileSize(const cv::Size& tileSize) { m_tileSize = tileSize; }
77
78 std::string toString() const {
79 std::stringstream ss;
80 ss << *this;
81 return ss.str();
82 }
83
84 private:
85 int m_level = 0;
86 cv::Size m_size;
87 double m_scale = 0.0;
88 double m_magnification = 0.0;
89 cv::Size m_tileSize;
90 };
91}
92
93#if defined(_MSC_VER)
94#pragma warning( pop )
95#endif
Definition: exceptions.hpp:12