Mercurial > hg > orthanc-stone
diff Framework/Scene2D/LookupTableStyleConfigurator.cpp @ 1080:287ec78f63b4
GenericToolbox (fast c-string --> double or integer) + refactoring to be able
to set structures lut into configurator + fixed missing revision bump in
configurator + UT
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 21 Oct 2019 16:01:29 +0200 |
parents | aead999345e0 |
children | 177e7d431cd1 2d8ab34c8c91 |
line wrap: on
line diff
--- a/Framework/Scene2D/LookupTableStyleConfigurator.cpp Wed Oct 16 15:43:21 2019 +0200 +++ b/Framework/Scene2D/LookupTableStyleConfigurator.cpp Mon Oct 21 16:01:29 2019 +0200 @@ -25,6 +25,17 @@ namespace OrthancStone { + static void StringToVector(std::vector<uint8_t>& target, + const std::string& source) + { + target.resize(source.size()); + + for (size_t i = 0; i < source.size(); i++) + { + target[i] = source[i]; + } + } + LookupTableStyleConfigurator::LookupTableStyleConfigurator() : revision_(0), hasLut_(false), @@ -32,21 +43,28 @@ { } - void LookupTableStyleConfigurator::SetLookupTable(Orthanc::EmbeddedResources::FileResourceId resource) { hasLut_ = true; - Orthanc::EmbeddedResources::GetFileResource(lut_, resource); + std::string tmp; + Orthanc::EmbeddedResources::GetFileResource(tmp, resource); + SetLookupTable(tmp); } + void LookupTableStyleConfigurator::SetLookupTable(const std::vector<uint8_t>& lut) + { + hasLut_ = true; + lut_ = lut; + revision_++; + } void LookupTableStyleConfigurator::SetLookupTable(const std::string& lut) { - hasLut_ = true; - lut_ = lut; + std::vector<uint8_t> tmp; + StringToVector(tmp, lut); + SetLookupTable(tmp); } - void LookupTableStyleConfigurator::SetRange(float minValue, float maxValue) { @@ -56,19 +74,19 @@ } else { + if ((!hasRange_) || (minValue_ != minValue) || (maxValue_ != maxValue)) + revision_++; hasRange_ = true; minValue_ = minValue; maxValue_ = maxValue; } } - TextureBaseSceneLayer* LookupTableStyleConfigurator::CreateTextureFromImage(const Orthanc::ImageAccessor& image) const { throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); } - void LookupTableStyleConfigurator::ApplyStyle(ISceneLayer& layer) const { LookupTableTextureSceneLayer& l = dynamic_cast<LookupTableTextureSceneLayer&>(layer);