# HG changeset patch # User Alain Mazy # Date 1556544299 -7200 # Node ID 7a7e36c52d62767643a822464f7347bf79808b32 # Parent 86dfde451f4c6adf874b77fbef7b56d93fc3effa# Parent 8432926e9db90d6fac9f18d8c86cb33118afcb33 Merged am-dev into default diff -r 86dfde451f4c -r 7a7e36c52d62 Applications/Qt/QCairoWidget.cpp --- 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(surface_.GetBuffer()), event->size().width(), diff -r 86dfde451f4c -r 7a7e36c52d62 Framework/Radiography/RadiographyScene.cpp --- 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 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(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 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"; } diff -r 86dfde451f4c -r 7a7e36c52d62 Framework/Radiography/RadiographyScene.h --- 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) diff -r 86dfde451f4c -r 7a7e36c52d62 Framework/Toolbox/DicomFrameConverter.h --- 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 . **/ @@ -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_; diff -r 86dfde451f4c -r 7a7e36c52d62 Resources/CodeGeneration/stonegentool.py --- 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") diff -r 86dfde451f4c -r 7a7e36c52d62 Resources/CodeGeneration/template.in.h.j2 --- 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;