comparison Framework/Scene2D/LookupTableStyleConfigurator.cpp @ 1083:f72d1ab42932 broker

integration mainline->broker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Oct 2019 13:14:05 +0200
parents 287ec78f63b4
children 177e7d431cd1 2d8ab34c8c91
comparison
equal deleted inserted replaced
1079:e6d2ff8f1ab4 1083:f72d1ab42932
23 23
24 #include <Core/OrthancException.h> 24 #include <Core/OrthancException.h>
25 25
26 namespace OrthancStone 26 namespace OrthancStone
27 { 27 {
28 static void StringToVector(std::vector<uint8_t>& target,
29 const std::string& source)
30 {
31 target.resize(source.size());
32
33 for (size_t i = 0; i < source.size(); i++)
34 {
35 target[i] = source[i];
36 }
37 }
38
28 LookupTableStyleConfigurator::LookupTableStyleConfigurator() : 39 LookupTableStyleConfigurator::LookupTableStyleConfigurator() :
29 revision_(0), 40 revision_(0),
30 hasLut_(false), 41 hasLut_(false),
31 hasRange_(false) 42 hasRange_(false)
32 { 43 {
33 } 44 }
34 45
35
36 void LookupTableStyleConfigurator::SetLookupTable(Orthanc::EmbeddedResources::FileResourceId resource) 46 void LookupTableStyleConfigurator::SetLookupTable(Orthanc::EmbeddedResources::FileResourceId resource)
37 { 47 {
38 hasLut_ = true; 48 hasLut_ = true;
39 Orthanc::EmbeddedResources::GetFileResource(lut_, resource); 49 std::string tmp;
50 Orthanc::EmbeddedResources::GetFileResource(tmp, resource);
51 SetLookupTable(tmp);
40 } 52 }
41 53
54 void LookupTableStyleConfigurator::SetLookupTable(const std::vector<uint8_t>& lut)
55 {
56 hasLut_ = true;
57 lut_ = lut;
58 revision_++;
59 }
42 60
43 void LookupTableStyleConfigurator::SetLookupTable(const std::string& lut) 61 void LookupTableStyleConfigurator::SetLookupTable(const std::string& lut)
44 { 62 {
45 hasLut_ = true; 63 std::vector<uint8_t> tmp;
46 lut_ = lut; 64 StringToVector(tmp, lut);
65 SetLookupTable(tmp);
47 } 66 }
48
49 67
50 void LookupTableStyleConfigurator::SetRange(float minValue, 68 void LookupTableStyleConfigurator::SetRange(float minValue,
51 float maxValue) 69 float maxValue)
52 { 70 {
53 if (minValue > maxValue) 71 if (minValue > maxValue)
54 { 72 {
55 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 73 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
56 } 74 }
57 else 75 else
58 { 76 {
77 if ((!hasRange_) || (minValue_ != minValue) || (maxValue_ != maxValue))
78 revision_++;
59 hasRange_ = true; 79 hasRange_ = true;
60 minValue_ = minValue; 80 minValue_ = minValue;
61 maxValue_ = maxValue; 81 maxValue_ = maxValue;
62 } 82 }
63 } 83 }
64 84
65
66 TextureBaseSceneLayer* LookupTableStyleConfigurator::CreateTextureFromImage(const Orthanc::ImageAccessor& image) const 85 TextureBaseSceneLayer* LookupTableStyleConfigurator::CreateTextureFromImage(const Orthanc::ImageAccessor& image) const
67 { 86 {
68 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); 87 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
69 } 88 }
70
71 89
72 void LookupTableStyleConfigurator::ApplyStyle(ISceneLayer& layer) const 90 void LookupTableStyleConfigurator::ApplyStyle(ISceneLayer& layer) const
73 { 91 {
74 LookupTableTextureSceneLayer& l = dynamic_cast<LookupTableTextureSceneLayer&>(layer); 92 LookupTableTextureSceneLayer& l = dynamic_cast<LookupTableTextureSceneLayer&>(layer);
75 93