Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/GrayscaleStyleConfigurator.cpp @ 1640:52b8b96cb55f
cleaning namespaces
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 10 Nov 2020 16:55:22 +0100 |
parents | 8563ea5d8ae4 |
children | 9ac2a65d4172 |
rev | line source |
---|---|
814 | 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:
1209
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
814 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
814 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
814 | 20 **/ |
21 | |
22 | |
23 #include "GrayscaleStyleConfigurator.h" | |
24 | |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
25 #include "FloatTextureSceneLayer.h" |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
26 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1300
diff
changeset
|
27 #include <OrthancException.h> |
814 | 28 |
29 namespace OrthancStone | |
30 { | |
1179
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
31 GrayscaleStyleConfigurator::GrayscaleStyleConfigurator() : |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
32 revision_(0), |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
33 linearInterpolation_(false), |
1212 | 34 hasWindowingOverride_(false), |
1571 | 35 windowing_(ImageWindowing_Custom), |
1179
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
36 customWindowWidth_(0), |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
37 customWindowCenter_(0), |
1212 | 38 hasInversionOverride_(false), |
1179
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
39 inverted_(false), |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
40 applyLog_(false) |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
41 { |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
42 } |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
43 |
836 | 44 void GrayscaleStyleConfigurator::SetWindowing(ImageWindowing windowing) |
45 { | |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
46 hasWindowingOverride_ = true; |
836 | 47 windowing_ = windowing; |
48 revision_++; | |
49 } | |
50 | |
913
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
51 void GrayscaleStyleConfigurator::SetCustomWindowing(float windowCenter, float windowWidth) |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
52 { |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
53 SetWindowing(ImageWindowing_Custom); |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
54 customWindowCenter_ = windowCenter; |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
55 customWindowWidth_ = windowWidth; |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
56 } |
836 | 57 |
1061
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
58 void GrayscaleStyleConfigurator::GetCustomWindowing(float& windowCenter, float& windowWidth) const |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
59 { |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
60 windowCenter = customWindowCenter_; |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
61 windowWidth = customWindowWidth_; |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
62 } |
914
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
63 |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
64 void GrayscaleStyleConfigurator::SetInverted(bool inverted) |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
65 { |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
66 hasInversionOverride_ = true; |
914
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
67 inverted_ = inverted; |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
68 revision_++; |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
69 } |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
70 |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
71 void GrayscaleStyleConfigurator::SetLinearInterpolation(bool enabled) |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
72 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
73 linearInterpolation_ = enabled; |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
74 revision_++; |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
75 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
76 |
1163 | 77 void GrayscaleStyleConfigurator::SetApplyLog(bool apply) |
78 { | |
79 applyLog_ = apply; | |
80 revision_++; | |
81 } | |
82 | |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
83 TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromImage( |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
84 const Orthanc::ImageAccessor& image) const |
814 | 85 { |
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
87 } | |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
88 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
89 TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromDicom( |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
90 const Orthanc::ImageAccessor& frame, |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
91 const DicomInstanceParameters& parameters) const |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
92 { |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
93 std::unique_ptr<TextureBaseSceneLayer> layer(parameters.CreateTexture(frame)); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
94 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
95 if (layer.get() == NULL || |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
96 layer->GetTexture().GetFormat() != Orthanc::PixelFormat_Float32) |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
97 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
98 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
99 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
100 else |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
101 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
102 return layer.release(); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
103 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
104 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
105 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
106 void GrayscaleStyleConfigurator::ApplyStyle(ISceneLayer& layer) const |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
107 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
108 FloatTextureSceneLayer& l = dynamic_cast<FloatTextureSceneLayer&>(layer); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
109 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
110 l.SetLinearInterpolation(linearInterpolation_); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
111 |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
112 if (hasWindowingOverride_) |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
113 { |
913
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
114 if (windowing_ != ImageWindowing_Custom) |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
115 { |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
116 l.SetWindowing(windowing_); |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
117 } |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
118 else |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
119 { |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
120 l.SetCustomWindowing(customWindowCenter_, customWindowWidth_); |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
121 } |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
122 } |
1163 | 123 |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
124 if (hasInversionOverride_) |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
125 { |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
126 l.SetInverted(inverted_); |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
127 } |
1212 | 128 |
1163 | 129 l.SetApplyLog(applyLog_); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
130 } |
814 | 131 } |