-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscaling.hxx
More file actions
34 lines (29 loc) · 1.02 KB
/
scaling.hxx
File metadata and controls
34 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef SCALING_HXX
#define SCALING_HXX
#include <QScreen>
#include <QGuiApplication>
namespace EWRB {
class Scaler {
private:
const float model_width_ = 1020;
const float model_height_ = 600;
int screen_width_;
int screen_height_;
public:
Scaler() {
const QScreen *screen_ = QGuiApplication::primaryScreen();
const QRect screen_size_ = screen_->geometry();
screen_height_ = screen_size_.height()*0.98;
screen_width_ = (model_width_/model_height_)*screen_height_;
}
float scale_width(float width) const {
return (screen_width_/model_width_)*width;
}
float scale_height(float height) const {
return (screen_height_/model_height_)*height;
}
float screen_width() const {return screen_width_;}
float screen_height() const {return screen_height_;}
};
};
#endif // SCALING_HXX