annotate Framework/Radiography/RadiographyLayer.cpp @ 1131:4663f158c748

RadiographyWidget is now notified when a layer is removed from the scene
author Alain Mazy <alain@mazy.be>
date Wed, 06 Nov 2019 10:46:46 +0100
parents 35e798b16b65
children d7e06542304c 69177b10e2b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
439
b70e9be013e4 preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 410
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "RadiographyLayer.h"
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <Core/OrthancException.h>
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 namespace OrthancStone
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 static double Square(double x)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 return x * x;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
35 RadiographyLayer::Geometry::Geometry() :
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
36 hasCrop_(false),
629
Alain Mazy <alain@mazy.be>
parents: 620
diff changeset
37 flipVertical_(false),
Alain Mazy <alain@mazy.be>
parents: 620
diff changeset
38 flipHorizontal_(false),
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
39 panX_(0),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
40 panY_(0),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
41 angle_(0),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
42 resizeable_(false),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
43 pixelSpacingX_(1),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
44 pixelSpacingY_(1)
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
45 {
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
46
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
47 }
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
48
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
49 void RadiographyLayer::Geometry::GetCrop(unsigned int &x, unsigned int &y, unsigned int &width, unsigned int &height) const
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
50 {
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
51 if (!hasCrop_)
436
04711a2e12cd fix crop + export photometric interpretation correctly
am@osimis.io
parents: 432
diff changeset
52 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); // you should probably use RadiographyLayer::GetCrop() or at least call HasCrop() before
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
53
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
54 x = cropX_;
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
55 y = cropY_;
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
56 width = cropWidth_;
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
57 height = cropHeight_;
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
58 }
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
59
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 void RadiographyLayer::UpdateTransform()
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
62 transform_ = AffineTransform2D::CreateScaling(geometry_.GetScalingX(), geometry_.GetScalingY());
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 double centerX, centerY;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 GetCenter(centerX, centerY);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 transform_ = AffineTransform2D::Combine(
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
68 AffineTransform2D::CreateOffset(geometry_.GetPanX() + centerX, geometry_.GetPanY() + centerY),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
69 AffineTransform2D::CreateRotation(geometry_.GetAngle()),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
70 AffineTransform2D::CreateOffset(-centerX, -centerY),
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
71 transform_);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 transformInverse_ = AffineTransform2D::Invert(transform_);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 void RadiographyLayer::AddToExtent(Extent2D& extent,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 double x,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 double y) const
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
81 GetTransform().Apply(x, y);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 extent.AddPoint(x, y);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 bool RadiographyLayer::Contains(double x,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 double y) const
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
88 GetTransformInverse().Apply(x, y);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
89
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 unsigned int cropX, cropY, cropWidth, cropHeight;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 GetCrop(cropX, cropY, cropWidth, cropHeight);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return (x >= cropX && x <= cropX + cropWidth &&
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 y >= cropY && y <= cropY + cropHeight);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 void RadiographyLayer::DrawBorders(CairoContext& context,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 double zoom)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 {
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
101 if (GetControlPointCount() < 3 )
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
102 return;
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 cairo_t* cr = context.GetObject();
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 cairo_set_line_width(cr, 2.0 / zoom);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
106
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
107 ControlPoint cp;
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
108 GetControlPoint(cp, 0);
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
109 cairo_move_to(cr, cp.x, cp.y);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
111 for (size_t i = 0; i < GetControlPointCount(); i++)
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
112 {
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
113 GetControlPoint(cp, i);
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
114 cairo_line_to(cr, cp.x, cp.y);
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
115 }
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
117 cairo_close_path(cr);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 cairo_stroke(cr);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
122 RadiographyLayer::RadiographyLayer(MessageBroker& broker, const RadiographyScene& scene) :
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
123 IObservable(broker),
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 index_(0),
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 hasSize_(false),
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 width_(0),
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 height_(0),
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
128 prefferedPhotometricDisplayMode_(RadiographyPhotometricDisplayMode_Default),
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
129 scene_(scene)
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 UpdateTransform();
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
134 void RadiographyLayer::ResetCrop()
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
135 {
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
136 geometry_.ResetCrop();
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
137 UpdateTransform();
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
138 }
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
140 void RadiographyLayer::SetPreferredPhotomotricDisplayMode(RadiographyPhotometricDisplayMode prefferedPhotometricDisplayMode)
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
141 {
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
142 prefferedPhotometricDisplayMode_ = prefferedPhotometricDisplayMode;
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
143
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
144 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
145 }
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
146
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 void RadiographyLayer::SetCrop(unsigned int x,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 unsigned int y,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 unsigned int width,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 unsigned int height)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 if (!hasSize_)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
156
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 if (x + width > width_ ||
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 y + height > height_)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
163 geometry_.SetCrop(x, y, width, height);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 UpdateTransform();
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
165
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
166 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
169 void RadiographyLayer::SetGeometry(const Geometry& geometry)
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
170 {
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
171 geometry_ = geometry;
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
172
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
173 if (hasSize_)
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
174 {
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
175 UpdateTransform();
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
176 }
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
177
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
178 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
179 }
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
180
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
181
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 void RadiographyLayer::GetCrop(unsigned int& x,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 unsigned int& y,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 unsigned int& width,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 unsigned int& height) const
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 {
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
187 if (GetGeometry().HasCrop())
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 {
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
189 GetGeometry().GetCrop(x, y, width, height);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
191 else
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 x = 0;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 y = 0;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 width = width_;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 height = height_;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
200
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 void RadiographyLayer::SetAngle(double angle)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 {
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
203 geometry_.SetAngle(angle);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 UpdateTransform();
503
77e0eb83ff63 layers are now Observable and emitting LayerEdited messages
amazy
parents: 480
diff changeset
205
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
206 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208
629
Alain Mazy <alain@mazy.be>
parents: 620
diff changeset
209 void RadiographyLayer::SetFlipVertical(bool flip)
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
210 {
629
Alain Mazy <alain@mazy.be>
parents: 620
diff changeset
211 geometry_.SetFlipVertical(flip);
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
212 UpdateTransform();
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
213
659
68b5688241d5 Fixed broken previous merge
Benjamin Golinvaux <bgo@osimis.io>
parents: 658
diff changeset
214 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
215 }
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
216
629
Alain Mazy <alain@mazy.be>
parents: 620
diff changeset
217 void RadiographyLayer::SetFlipHorizontal(bool flip)
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
218 {
629
Alain Mazy <alain@mazy.be>
parents: 620
diff changeset
219 geometry_.SetFlipHorizontal(flip);
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
220 UpdateTransform();
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
221
659
68b5688241d5 Fixed broken previous merge
Benjamin Golinvaux <bgo@osimis.io>
parents: 658
diff changeset
222 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
620
fd9b9d993fc7 added flip to RadiographyLayer
Alain Mazy <alain@mazy.be>
parents: 503
diff changeset
223 }
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 void RadiographyLayer::SetSize(unsigned int width,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 unsigned int height)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 hasSize_ = true;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 width_ = width;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 height_ = height;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 UpdateTransform();
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
233 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 Extent2D RadiographyLayer::GetExtent() const
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 Extent2D extent;
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
240
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 unsigned int x, y, width, height;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 GetCrop(x, y, width, height);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 double dx = static_cast<double>(x);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 double dy = static_cast<double>(y);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 double dwidth = static_cast<double>(width);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 double dheight = static_cast<double>(height);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 AddToExtent(extent, dx, dy);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 AddToExtent(extent, dx + dwidth, dy);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 AddToExtent(extent, dx, dy + dheight);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 AddToExtent(extent, dx + dwidth, dy + dheight);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
253
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 return extent;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 bool RadiographyLayer::GetPixel(unsigned int& imageX,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 unsigned int& imageY,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 double sceneX,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 double sceneY) const
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 if (width_ == 0 ||
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 height_ == 0)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 return false;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 else
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
270 GetTransformInverse().Apply(sceneX, sceneY);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
271
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 int x = static_cast<int>(std::floor(sceneX));
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 int y = static_cast<int>(std::floor(sceneY));
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 if (x < 0)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 imageX = 0;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 else if (x >= static_cast<int>(width_))
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 imageX = width_;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 else
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 imageX = static_cast<unsigned int>(x);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 if (y < 0)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 imageY = 0;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 else if (y >= static_cast<int>(height_))
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 imageY = height_;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 else
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 imageY = static_cast<unsigned int>(y);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 return true;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 void RadiographyLayer::SetPan(double x,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 double y)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 {
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
309 geometry_.SetPan(x, y);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 UpdateTransform();
623
42dadae61fa9 renamed IObservable::EmitMessage() as BroadcastMessage()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 503
diff changeset
311 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 void RadiographyLayer::SetPixelSpacing(double x,
1118
35e798b16b65 RadiographyDicomLayer: allow replacing low res image by high res image
Alain Mazy <alain@mazy.be>
parents: 1112
diff changeset
316 double y,
35e798b16b65 RadiographyDicomLayer: allow replacing low res image by high res image
Alain Mazy <alain@mazy.be>
parents: 1112
diff changeset
317 bool emitLayerEditedEvent)
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 {
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
319 geometry_.SetPixelSpacing(x, y);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 UpdateTransform();
1118
35e798b16b65 RadiographyDicomLayer: allow replacing low res image by high res image
Alain Mazy <alain@mazy.be>
parents: 1112
diff changeset
321 if (emitLayerEditedEvent)
35e798b16b65 RadiographyDicomLayer: allow replacing low res image by high res image
Alain Mazy <alain@mazy.be>
parents: 1112
diff changeset
322 {
35e798b16b65 RadiographyDicomLayer: allow replacing low res image by high res image
Alain Mazy <alain@mazy.be>
parents: 1112
diff changeset
323 BroadcastMessage(RadiographyLayer::LayerEditedMessage(*this));
35e798b16b65 RadiographyDicomLayer: allow replacing low res image by high res image
Alain Mazy <alain@mazy.be>
parents: 1112
diff changeset
324 }
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 void RadiographyLayer::GetCenter(double& centerX,
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 double& centerY) const
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 centerX = static_cast<double>(width_) / 2.0;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 centerY = static_cast<double>(height_) / 2.0;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
333 GetTransform().Apply(centerX, centerY);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 }
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
335
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
336
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
337
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
338 size_t RadiographyLayer::GetControlPointCount() const {return 4;}
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
339
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
340 void RadiographyLayer::GetControlPoint(ControlPoint& cpScene /* out in scene coordinates */,
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
341 size_t index) const
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 {
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 unsigned int cropX, cropY, cropWidth, cropHeight;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 GetCrop(cropX, cropY, cropWidth, cropHeight);
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
346 ControlPoint cp;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
347 switch (index)
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
348 {
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
349 case RadiographyControlPointType_TopLeftCorner:
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
350 cp = ControlPoint(cropX, cropY, RadiographyControlPointType_TopLeftCorner);
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
351 break;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
352
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
353 case RadiographyControlPointType_TopRightCorner:
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
354 cp = ControlPoint(cropX + cropWidth, cropY, RadiographyControlPointType_TopRightCorner);
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
355 break;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
356
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
357 case RadiographyControlPointType_BottomLeftCorner:
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
358 cp = ControlPoint(cropX, cropY + cropHeight, RadiographyControlPointType_BottomLeftCorner);
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
359 break;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
360
739
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
361 case RadiographyControlPointType_BottomRightCorner:
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
362 cp = ControlPoint(cropX + cropWidth, cropY + cropHeight, RadiographyControlPointType_BottomRightCorner);
be9c1530d40a deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 659
diff changeset
363 break;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
364
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
365 default:
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
366 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
367 }
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
368
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
369 // transforms image coordinates into scene coordinates
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
370 GetTransform().Apply(cp.x, cp.y);
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
371 cpScene = cp;
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
372 }
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
373
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
374 bool RadiographyLayer::LookupControlPoint(ControlPoint& cpScene /* out */,
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
375 double x,
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
376 double y,
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
377 double zoom,
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
378 double viewportDistance) const
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
379 {
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 double threshold = Square(viewportDistance / zoom);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
381
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
382 for (size_t i = 0; i < GetControlPointCount(); i++)
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 {
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
384 ControlPoint cp;
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
385 GetControlPoint(cp, i);
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386
476
a95090305dd4 Introduced ControlPoint instead of Corner in the trackers and layers + drawing mask from the ControlPoints
am@osimis.io
parents: 440
diff changeset
387 double d = Square(cp.x - x) + Square(cp.y - y);
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
388
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 if (d <= threshold)
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 {
480
2f6ecb5037ea added mouse tracker for Layer Mask. Everything seems ok
am@osimis.io
parents: 476
diff changeset
391 cpScene = cp;
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 return true;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394 }
430
b85f635f1eb5 added serialization for RadiographyScene
am@osimis.io
parents: 410
diff changeset
395
410
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 return false;
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 }
6decc0ba9da5 rename RadiographyScene::Layer as RadiographyLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 }