Mercurial > hg > orthanc-stone
changeset 605:7a7e36c52d62
Merged am-dev into default
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 29 Apr 2019 15:24:59 +0200 |
parents | 86dfde451f4c (current diff) 8432926e9db9 (diff) |
children | d9c0a66304cb |
files | Framework/Radiography/RadiographyScene.cpp |
diffstat | 6 files changed, 155 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/Qt/QCairoWidget.cpp Mon Apr 29 15:24:47 2019 +0200 +++ b/Applications/Qt/QCairoWidget.cpp Mon Apr 29 15:24:59 2019 +0200 @@ -200,7 +200,7 @@ if (event) { - surface_.SetSize(event->size().width(), event->size().height()); + surface_.SetSize(event->size().width(), event->size().height(), true); image_.reset(new QImage(reinterpret_cast<uchar*>(surface_.GetBuffer()), event->size().width(),
--- a/Framework/Radiography/RadiographyScene.cpp Mon Apr 29 15:24:47 2019 +0200 +++ b/Framework/Radiography/RadiographyScene.cpp Mon Apr 29 15:24:59 2019 +0200 @@ -362,7 +362,7 @@ layer.SetPreferredPhotomotricDisplayMode(preferredPhotometricDisplayMode); return layer; - } + } RadiographyLayer& RadiographyScene::LoadDicomFrame(OrthancApiClient& orthanc, const std::string& instance, @@ -628,41 +628,18 @@ } - void RadiographyScene::ExportToCreateDicomRequest(Json::Value& createDicomRequestContent, - const Json::Value& dicomTags, - const std::string& parentOrthancId, - double pixelSpacingX, - double pixelSpacingY, - bool invert, - ImageInterpolation interpolation, - bool usePam) + Orthanc::Image* RadiographyScene::ExportToCreateDicomRequestAndImage(Json::Value& createDicomRequestContent, + const Json::Value& dicomTags, + const std::string& parentOrthancId, + double pixelSpacingX, + double pixelSpacingY, + bool invert, + ImageInterpolation interpolation) { LOG(INFO) << "Exporting RadiographyScene to DICOM"; - VLOG(1) << "Exporting RadiographyScene to: export to image"; std::auto_ptr<Orthanc::Image> rendered(ExportToImage(pixelSpacingX, pixelSpacingY, interpolation)); // note: we don't invert the image in the pixels data because we'll set the PhotometricDisplayMode correctly in the DICOM tags - std::string base64; - - { - std::string content; - - if (usePam) - { - VLOG(1) << "Exporting RadiographyScene: convert to PAM"; - Orthanc::PamWriter writer; - writer.WriteToMemory(content, *rendered); - } - else - { - Orthanc::PngWriter writer; - writer.WriteToMemory(content, *rendered); - } - - VLOG(1) << "Exporting RadiographyScene: encoding to base64"; - Orthanc::Toolbox::EncodeBase64(base64, content); - } - createDicomRequestContent["Tags"] = dicomTags; PhotometricDisplayMode photometricMode = GetPreferredPhotomotricDisplayMode(); @@ -695,17 +672,56 @@ boost::lexical_cast<std::string>(boost::math::iround(width)); } + if (!parentOrthancId.empty()) + { + createDicomRequestContent["Parent"] = parentOrthancId; + } + + return rendered.release(); + } + + + void RadiographyScene::ExportToCreateDicomRequest(Json::Value& createDicomRequestContent, + const Json::Value& dicomTags, + const std::string& parentOrthancId, + double pixelSpacingX, + double pixelSpacingY, + bool invert, + ImageInterpolation interpolation, + bool usePam) + { + LOG(INFO) << "Exporting RadiographyScene to DICOM"; + VLOG(1) << "Exporting RadiographyScene to: export to image"; + + std::auto_ptr<Orthanc::Image> rendered(ExportToCreateDicomRequestAndImage(createDicomRequestContent, dicomTags, parentOrthancId, pixelSpacingX, pixelSpacingY, invert, interpolation)); + + // convert the image into base64 for inclusing in the createDicomRequest + std::string base64; + + { + std::string content; + + if (usePam) + { + VLOG(1) << "Exporting RadiographyScene: convert to PAM"; + Orthanc::PamWriter writer; + writer.WriteToMemory(content, *rendered); + } + else + { + Orthanc::PngWriter writer; + writer.WriteToMemory(content, *rendered); + } + + VLOG(1) << "Exporting RadiographyScene: encoding to base64"; + Orthanc::Toolbox::EncodeBase64(base64, content); + } // This is Data URI scheme: https://en.wikipedia.org/wiki/Data_URI_scheme createDicomRequestContent["Content"] = ("data:" + std::string(usePam ? Orthanc::MIME_PAM : Orthanc::MIME_PNG) + ";base64," + base64); - if (!parentOrthancId.empty()) - { - createDicomRequestContent["Parent"] = parentOrthancId; - } - VLOG(1) << "Exporting RadiographyScene: create-dicom request is ready"; }
--- a/Framework/Radiography/RadiographyScene.h Mon Apr 29 15:24:47 2019 +0200 +++ b/Framework/Radiography/RadiographyScene.h Mon Apr 29 15:24:59 2019 +0200 @@ -310,6 +310,14 @@ ImageInterpolation interpolation, bool usePam); + Orthanc::Image* ExportToCreateDicomRequestAndImage(Json::Value& createDicomRequestContent, + const Json::Value& dicomTags, + const std::string& parentOrthancId, + double pixelSpacingX, + double pixelSpacingY, + bool invert, + ImageInterpolation interpolation); + Orthanc::Image* ExportToImage(double pixelSpacingX, double pixelSpacingY, ImageInterpolation interpolation)
--- a/Framework/Toolbox/DicomFrameConverter.h Mon Apr 29 15:24:47 2019 +0200 +++ b/Framework/Toolbox/DicomFrameConverter.h Mon Apr 29 15:24:59 2019 +0200 @@ -13,7 +13,7 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ @@ -63,13 +63,61 @@ { // TODO: check whether this dtor is called or not // An MSVC warning explains that declaring an - // std::auto_ptr with a forward-declared type - // prevents its dtor from being called. Does not + // std::auto_ptr with a forward-declared type + // prevents its dtor from being called. Does not // seem an issue here (only POD types inside), but - // definitely something to keep an eye on. + // definitely something to keep an eye on. (void)0; } + // AM: this is required to serialize/deserialize it + DicomFrameConverter( + bool isSigned, + bool isColor, + bool hasRescale, + double rescaleIntercept, + double rescaleSlope, + bool hasDefaultWindow, + double defaultWindowCenter, + double defaultWindowWidth, + Orthanc::PhotometricInterpretation photometric, + Orthanc::PixelFormat expectedPixelFormat + ): + isSigned_(isSigned), + isColor_(isColor), + hasRescale_(hasRescale), + rescaleIntercept_(rescaleIntercept), + rescaleSlope_(rescaleSlope), + hasDefaultWindow_(hasDefaultWindow), + defaultWindowCenter_(defaultWindowCenter), + defaultWindowWidth_(defaultWindowWidth), + photometric_(photometric), + expectedPixelFormat_(expectedPixelFormat) + {} + + void GetParameters(bool& isSigned, + bool& isColor, + bool& hasRescale, + double& rescaleIntercept, + double& rescaleSlope, + bool& hasDefaultWindow, + double& defaultWindowCenter, + double& defaultWindowWidth, + Orthanc::PhotometricInterpretation& photometric, + Orthanc::PixelFormat& expectedPixelFormat) const + { + isSigned = isSigned_; + isColor = isColor_; + hasRescale = hasRescale_; + rescaleIntercept = rescaleIntercept_; + rescaleSlope = rescaleSlope_; + hasDefaultWindow = hasDefaultWindow_; + defaultWindowCenter = defaultWindowCenter_; + defaultWindowWidth = defaultWindowWidth_; + photometric = photometric_; + expectedPixelFormat = expectedPixelFormat_; + } + Orthanc::PixelFormat GetExpectedPixelFormat() const { return expectedPixelFormat_; @@ -103,7 +151,7 @@ { return rescaleIntercept_; } - + double GetRescaleSlope() const { return rescaleSlope_;
--- a/Resources/CodeGeneration/stonegentool.py Mon Apr 29 15:24:47 2019 +0200 +++ b/Resources/CodeGeneration/stonegentool.py Mon Apr 29 15:24:59 2019 +0200 @@ -76,7 +76,7 @@ def CanonToCpp(canonicalTypename): # C++: prefix map vector and string with std::map, std::vector and # std::string - # replace int32 by int32_t + # replace int32... by int32_t... # replace float32 by float # replace float64 by double retVal = canonicalTypename @@ -84,7 +84,9 @@ retVal = retVal.replace("vector", "std::vector") retVal = retVal.replace("set", "std::set") retVal = retVal.replace("string", "std::string") + #uint32 and uint64 are handled by int32 and uint32 (because search and replace are done as partial words) retVal = retVal.replace("int32", "int32_t") + retVal = retVal.replace("int64", "int64_t") retVal = retVal.replace("float32", "float") retVal = retVal.replace("float64", "double") retVal = retVal.replace("json", "Json::Value") @@ -93,14 +95,16 @@ def CanonToTs(canonicalTypename): # TS: replace vector with Array and map with Map # string remains string - # replace int32 by number - # replace float32 by number - # replace float64 by number + # replace int32... by number + # replace float32... by number retVal = canonicalTypename retVal = retVal.replace("map", "Map") retVal = retVal.replace("vector", "Array") retVal = retVal.replace("set", "Set") + retVal = retVal.replace("uint32", "number") + retVal = retVal.replace("uint64", "number") retVal = retVal.replace("int32", "number") + retVal = retVal.replace("int64", "number") retVal = retVal.replace("float32", "number") retVal = retVal.replace("float64", "number") retVal = retVal.replace("bool", "boolean")
--- a/Resources/CodeGeneration/template.in.h.j2 Mon Apr 29 15:24:47 2019 +0200 +++ b/Resources/CodeGeneration/template.in.h.j2 Mon Apr 29 15:24:59 2019 +0200 @@ -38,6 +38,39 @@ return result; } + inline void _StoneDeserializeValue(int64_t& destValue, const Json::Value& jsonValue) + { + destValue = jsonValue.asInt64(); + } + + inline Json::Value _StoneSerializeValue(int64_t value) + { + Json::Value result(value); + return result; + } + + inline void _StoneDeserializeValue(uint32_t& destValue, const Json::Value& jsonValue) + { + destValue = jsonValue.asUInt(); + } + + inline Json::Value _StoneSerializeValue(uint32_t value) + { + Json::Value result(value); + return result; + } + + inline void _StoneDeserializeValue(uint64_t& destValue, const Json::Value& jsonValue) + { + destValue = jsonValue.asUInt64(); + } + + inline Json::Value _StoneSerializeValue(uint64_t value) + { + Json::Value result(value); + return result; + } + inline void _StoneDeserializeValue(Json::Value& destValue, const Json::Value& jsonValue) { destValue = jsonValue;