MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / updateForFieldOfView

Method updateForFieldOfView

ASAP/ScaleBar.cpp:21–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21void ScaleBar::updateForFieldOfView(const QRectF& fieldOfView) {
22 QWidget* parent = this->parentWidget();
23 if (parent) {
24 float parentWidth = parent->width();
25 float FOVWidth = fieldOfView.width();
26 QString label;
27 float imagePixelsPerScreenPixel = FOVWidth / parentWidth;
28 if (this->_resolution > 0) {
29 float micronsPerScreenPixel = imagePixelsPerScreenPixel * this->_resolution;
30 unsigned int increment = 1000;
31 for (int i = 10000; i > 0; i -= increment) {
32 if (i <= 1000) {
33 increment = 250;
34 }
35 if (i <= 250) {
36 increment = 25;
37 }
38 if (i / micronsPerScreenPixel < 300) {
39 _currentWidth = i / micronsPerScreenPixel;
40 updateGeometry();
41 if (i >= 1000) {
42 _currentLabel = QString::number(i / 1000) + " mm";
43 }
44 else {
45 _currentLabel = QString::number(i) + " um";
46 }
47 break;
48 }
49 }
50 }
51 else {
52 unsigned int increment = 1000;
53 for (int i = 10000; i > 0; i -= increment) {
54 if (i <= 1000) {
55 increment = 250;
56 }
57 if (i <= 250) {
58 increment = 25;
59 }
60 if (i / imagePixelsPerScreenPixel < 300) {
61 _currentWidth = i / imagePixelsPerScreenPixel;
62 updateGeometry();
63 _currentLabel = QString::number(i) + " pixels";
64 break;
65 }
66 }
67 }
68 }
69}
70
71void ScaleBar::paintEvent(QPaintEvent *event) {
72 QPainter painter(this);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected