Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Deprecated/Radiography/RadiographyWidget.cpp @ 1556:8898f8f755c8
typo
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Aug 2020 11:58:47 +0200 |
parents | 244ad1e4e76a |
children |
rev | line source |
---|---|
413 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1258
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
413 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #include "RadiographyWidget.h" | |
23 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1398
diff
changeset
|
24 #include <OrthancException.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1398
diff
changeset
|
25 #include <Images/Image.h> |
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1398
diff
changeset
|
26 #include <Images/ImageProcessing.h> |
413 | 27 |
492 | 28 #include "RadiographyMaskLayer.h" |
413 | 29 |
30 namespace OrthancStone | |
31 { | |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
32 |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
33 bool RadiographyWidget::IsInvertedInternal() const |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
34 { |
516
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
35 // MONOCHROME1 images must be inverted and the user can invert the |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
36 // image, too -> XOR the two |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
37 return (scene_->GetPreferredPhotomotricDisplayMode() == |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
38 RadiographyPhotometricDisplayMode_Monochrome1) ^ invert_; |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
39 } |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
40 |
516
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
41 void RadiographyWidget::RenderBackground( |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
42 Orthanc::ImageAccessor& image, float minValue, float maxValue) |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
43 { |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
44 // wipe background before rendering |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
45 float backgroundValue = minValue; |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
46 |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
47 switch (scene_->GetPreferredPhotomotricDisplayMode()) |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
48 { |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
49 case RadiographyPhotometricDisplayMode_Monochrome1: |
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
50 case RadiographyPhotometricDisplayMode_Default: |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
51 if (IsInvertedInternal()) |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
52 backgroundValue = maxValue; |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
53 else |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
54 backgroundValue = minValue; |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
55 break; |
739
be9c1530d40a
deprecating enum SliceImageQuality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
726
diff
changeset
|
56 case RadiographyPhotometricDisplayMode_Monochrome2: |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
57 if (IsInvertedInternal()) |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
58 backgroundValue = minValue; |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
59 else |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
60 backgroundValue = maxValue; |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
61 break; |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
62 default: |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
63 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
64 } |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
65 |
516
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
66 Orthanc::ImageProcessing::Set(image, static_cast<int64_t>(backgroundValue)); |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
67 } |
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
68 |
413 | 69 bool RadiographyWidget::RenderInternal(unsigned int width, |
70 unsigned int height, | |
71 ImageInterpolation interpolation) | |
72 { | |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
73 if (floatBuffer_.get() == NULL || |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
74 floatBuffer_->GetWidth() != width || |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
75 floatBuffer_->GetHeight() != height) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
76 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
77 floatBuffer_.reset(new Orthanc::Image( |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
78 Orthanc::PixelFormat_Float32, width, height, false)); |
1258
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
79 |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
80 if (floatBuffer_.get() == NULL) |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
81 { |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory, "RadiographyWidget::RenderInternal: unable to allocate float buffer"); |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
83 } |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
84 } |
413 | 85 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
86 if (cairoBuffer_.get() == NULL || |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
87 cairoBuffer_->GetWidth() != width || |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
88 cairoBuffer_->GetHeight() != height) |
413 | 89 { |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
90 cairoBuffer_.reset(new CairoSurface(width, height, false /* no alpha */)); |
1258
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
91 |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
92 if (cairoBuffer_.get() == NULL) |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
93 { |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
94 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory, "RadiographyWidget::RenderInternal: unable to allocate cairo buffer"); |
9c20ae049669
more logs to debug exceptions in Render
Alain Mazy <alain@mazy.be>
parents:
1256
diff
changeset
|
95 } |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
96 } |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
97 |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
98 RenderBackground(*floatBuffer_, 0.0, 65535.0); |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
99 |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
100 scene_->Render(*floatBuffer_, GetView().GetMatrix(), interpolation, true); |
413 | 101 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
102 // Conversion from Float32 to BGRA32 (cairo). Very similar to |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
103 // GrayscaleFrameRenderer => TODO MERGE? |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
104 Orthanc::ImageAccessor target; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
105 cairoBuffer_->GetWriteableAccessor(target); |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
106 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
107 bool invert = IsInvertedInternal(); |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
108 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
109 for (unsigned int y = 0; y < height; y++) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
110 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
111 const float* p = reinterpret_cast<const float*>(floatBuffer_->GetConstRow(y)); |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
112 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
113 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
114 for (unsigned int x = 0; x < width; x++, p++, q += 4) |
413 | 115 { |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
116 uint8_t v = 0; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
117 if (*p >= 65535.0) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
118 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
119 v = 255; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
120 } |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
121 else if (*p <= 0.0) |
413 | 122 { |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
123 v = 0; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
124 } |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
125 else |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
126 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
127 v = static_cast<uint8_t>(*p / 256.0); |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
128 } |
413 | 129 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
130 if (invert) |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
131 { |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
132 v = 255 - v; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
133 } |
413 | 134 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
135 q[0] = v; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
136 q[1] = v; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
137 q[2] = v; |
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
138 q[3] = 255; |
413 | 139 } |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
140 } |
413 | 141 |
1196
a5f2a6b04a31
RadiographyScene: windowing is now only applied to the Dicom layer
Alain Mazy <alain@mazy.be>
parents:
1131
diff
changeset
|
142 return true; |
413 | 143 } |
144 | |
145 | |
146 bool RadiographyWidget::RenderScene(CairoContext& context, | |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
561
diff
changeset
|
147 const Deprecated::ViewportGeometry& view) |
413 | 148 { |
149 cairo_t* cr = context.GetObject(); | |
150 | |
151 if (RenderInternal(context.GetWidth(), context.GetHeight(), interpolation_)) | |
152 { | |
153 // https://www.cairographics.org/FAQ/#paint_from_a_surface | |
154 cairo_save(cr); | |
155 cairo_identity_matrix(cr); | |
156 cairo_set_source_surface(cr, cairoBuffer_->GetObject(), 0, 0); | |
157 cairo_paint(cr); | |
158 cairo_restore(cr); | |
159 } | |
160 else | |
161 { | |
162 // https://www.cairographics.org/FAQ/#clear_a_surface | |
163 context.SetSourceColor(0, 0, 0); | |
164 cairo_paint(cr); | |
165 } | |
166 | |
167 if (hasSelection_) | |
168 { | |
516
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
169 scene_->DrawBorder( |
11fa6f00e33c
Dummy changes (warnings, dummy dtor to check proper deletion, line wrapping) +
Benjamin Golinvaux <bgo@osimis.io>
parents:
492
diff
changeset
|
170 context, static_cast<unsigned int>(selectedLayer_), view.GetZoom()); |
413 | 171 } |
172 | |
173 return true; | |
174 } | |
175 | |
176 | |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
739
diff
changeset
|
177 RadiographyWidget::RadiographyWidget(boost::shared_ptr<RadiographyScene> scene, |
413 | 178 const std::string& name) : |
179 WorldSceneWidget(name), | |
180 invert_(false), | |
181 interpolation_(ImageInterpolation_Nearest), | |
182 hasSelection_(false), | |
183 selectedLayer_(0) // Dummy initialization | |
184 { | |
428
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
185 SetScene(scene); |
413 | 186 } |
187 | |
188 | |
189 void RadiographyWidget::Select(size_t layer) | |
190 { | |
191 hasSelection_ = true; | |
192 selectedLayer_ = layer; | |
1220
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
193 |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
194 NotifyContentChanged(); |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
195 BroadcastMessage(SelectionChangedMessage(*this)); |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
196 } |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
197 |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
198 void RadiographyWidget::Unselect() |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
199 { |
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
200 hasSelection_ = false; |
1256 | 201 |
202 NotifyContentChanged(); | |
1220
9ee6b28f53e8
RadiographyTextLayer: support multiple fonts
Alain Mazy <alain@mazy.be>
parents:
1199
diff
changeset
|
203 BroadcastMessage(SelectionChangedMessage(*this)); |
413 | 204 } |
205 | |
1237 | 206 bool RadiographyWidget::LookupSelectedLayer(size_t& layer) const |
413 | 207 { |
208 if (hasSelection_) | |
209 { | |
210 layer = selectedLayer_; | |
211 return true; | |
212 } | |
213 else | |
214 { | |
215 return false; | |
216 } | |
217 } | |
218 | |
219 | |
220 void RadiographyWidget::OnGeometryChanged(const RadiographyScene::GeometryChangedMessage& message) | |
221 { | |
1112
d33ae2b0db9d
less logs + allow changing the size of the RadiographyLayer (to replace a low res image by a high res image)
Alain Mazy <alain@mazy.be>
parents:
739
diff
changeset
|
222 // LOG(INFO) << "Scene geometry has changed"; |
413 | 223 FitContent(); |
224 } | |
225 | |
226 | |
227 void RadiographyWidget::OnContentChanged(const RadiographyScene::ContentChangedMessage& message) | |
228 { | |
1112
d33ae2b0db9d
less logs + allow changing the size of the RadiographyLayer (to replace a low res image by a high res image)
Alain Mazy <alain@mazy.be>
parents:
739
diff
changeset
|
229 // LOG(INFO) << "Scene content has changed"; |
413 | 230 NotifyContentChanged(); |
231 } | |
232 | |
1131
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
233 void RadiographyWidget::OnLayerRemoved(const RadiographyScene::LayerRemovedMessage& message) |
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
234 { |
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
235 size_t removedLayerIndex = message.GetLayerIndex(); |
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
236 if (hasSelection_ && selectedLayer_ == removedLayerIndex) |
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
237 { |
1199
922d2e61aa5d
RadiograpyScene: can now remove any layer + new key wrappers for Delete/Backspace
Alain Mazy <alain@mazy.be>
parents:
1196
diff
changeset
|
238 Unselect(); |
1131
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
239 } |
1199
922d2e61aa5d
RadiograpyScene: can now remove any layer + new key wrappers for Delete/Backspace
Alain Mazy <alain@mazy.be>
parents:
1196
diff
changeset
|
240 NotifyContentChanged(); |
1131
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
241 } |
413 | 242 |
243 void RadiographyWidget::SetInvert(bool invert) | |
244 { | |
245 if (invert_ != invert) | |
246 { | |
247 invert_ = invert; | |
248 NotifyContentChanged(); | |
249 } | |
250 } | |
251 | |
252 | |
1131
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
253 void RadiographyWidget::SwitchInvert() |
413 | 254 { |
255 invert_ = !invert_; | |
256 NotifyContentChanged(); | |
257 } | |
258 | |
259 | |
260 void RadiographyWidget::SetInterpolation(ImageInterpolation interpolation) | |
261 { | |
262 if (interpolation_ != interpolation) | |
263 { | |
264 interpolation_ = interpolation; | |
265 NotifyContentChanged(); | |
266 } | |
267 } | |
428
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
268 |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
269 void RadiographyWidget::SetScene(boost::shared_ptr<RadiographyScene> scene) |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
270 { |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
271 scene_ = scene; |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
272 |
1066
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
739
diff
changeset
|
273 Register<RadiographyScene::GeometryChangedMessage>(*scene_, &RadiographyWidget::OnGeometryChanged); |
b537002f83a9
removing broker from deprecated classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
739
diff
changeset
|
274 Register<RadiographyScene::ContentChangedMessage>(*scene_, &RadiographyWidget::OnContentChanged); |
1139 | 275 Register<RadiographyScene::LayerRemovedMessage>(*scene_, &RadiographyWidget::OnLayerRemoved); |
1131
4663f158c748
RadiographyWidget is now notified when a layer is removed from the scene
Alain Mazy <alain@mazy.be>
parents:
1112
diff
changeset
|
276 |
1238
e257b91fae2c
RadiographyWidget: clear selection when changing scene
Alain Mazy <alain@mazy.be>
parents:
1237
diff
changeset
|
277 Unselect(); |
e257b91fae2c
RadiographyWidget: clear selection when changing scene
Alain Mazy <alain@mazy.be>
parents:
1237
diff
changeset
|
278 |
432
4eb96c6b4e96
improved handling of MONOCHROME1, background and invertion
am@osimis.io
parents:
428
diff
changeset
|
279 NotifyContentChanged(); |
428
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
280 |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
281 // force redraw |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
282 FitContent(); |
751fb354149e
ability to change the scene of the RadiographyWidget
am@osimis.io
parents:
413
diff
changeset
|
283 } |
413 | 284 } |