annotate OrthancStone/Sources/Scene2D/InfoPanelSceneLayer.cpp @ 1596:4fb8fdf03314

removed annoying whitespace
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Oct 2020 17:51:42 +0100
parents 244ad1e4e76a
children 8563ea5d8ae4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1270
2d8ab34c8c91 upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 584
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
1596
4fb8fdf03314 removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 *
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "InfoPanelSceneLayer.h"
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1325
diff changeset
24 #include <Images/Image.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1325
diff changeset
25 #include <OrthancException.h>
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace OrthancStone
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 InfoPanelSceneLayer::InfoPanelSceneLayer(const Orthanc::ImageAccessor& texture,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 BitmapAnchor anchor,
1325
be17fed8c7c5 Added flag in InfoPanelSceneLayer to
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
31 bool isLinearInterpolation,
be17fed8c7c5 Added flag in InfoPanelSceneLayer to
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
32 bool applySceneRotation) :
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 texture_(Orthanc::Image::Clone(texture)),
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 anchor_(anchor),
1325
be17fed8c7c5 Added flag in InfoPanelSceneLayer to
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
35 isLinearInterpolation_(isLinearInterpolation),
be17fed8c7c5 Added flag in InfoPanelSceneLayer to
Benjamin Golinvaux <bgo@osimis.io>
parents: 1270
diff changeset
36 applySceneRotation_(applySceneRotation)
584
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 if (texture_->GetFormat() != Orthanc::PixelFormat_RGBA32 &&
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 texture_->GetFormat() != Orthanc::PixelFormat_RGB24)
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 void InfoPanelSceneLayer::ComputeAnchorLocation(int& x,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 int& y,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 BitmapAnchor anchor,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 unsigned int textureWidth,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 unsigned int textureHeight,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 unsigned int canvasWidth,
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 unsigned int canvasHeight)
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 int tw = static_cast<int>(textureWidth);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 int th = static_cast<int>(textureHeight);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 int cw = static_cast<int>(canvasWidth);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 int ch = static_cast<int>(canvasHeight);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 switch (anchor)
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 case BitmapAnchor_TopLeft:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 case BitmapAnchor_CenterLeft:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 case BitmapAnchor_BottomLeft:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 x = 0;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 break;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 case BitmapAnchor_TopCenter:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 case BitmapAnchor_Center:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 case BitmapAnchor_BottomCenter:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 x = (cw - tw) / 2;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 break;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 case BitmapAnchor_TopRight:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 case BitmapAnchor_CenterRight:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 case BitmapAnchor_BottomRight:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 x = cw - tw;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 break;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 default:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 switch (anchor)
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 case BitmapAnchor_TopLeft:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 case BitmapAnchor_TopCenter:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 case BitmapAnchor_TopRight:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 y = 0;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 break;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 case BitmapAnchor_CenterLeft:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 case BitmapAnchor_Center:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 case BitmapAnchor_CenterRight:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 y = (ch - th) / 2;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 break;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 case BitmapAnchor_BottomLeft:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 case BitmapAnchor_BottomCenter:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 case BitmapAnchor_BottomRight:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 y = ch - th;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 break;
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 default:
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
434ceeb0bcab layers: InfoPanel, Polyline, Texture
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }