From 7690496cf526e88c40389eb8e56766e61880c2b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Mon, 26 Dec 2022 18:07:16 +0100 Subject: [PATCH] Load XISF::ReadImageProperties --- imageinfo.cpp | 33 +++++++++++++++++++++++++++++++++ imageinfo.h | 3 ++- loadrunable.cpp | 12 ++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/imageinfo.cpp b/imageinfo.cpp index dc3c34d..ef4fe20 100644 --- a/imageinfo.cpp +++ b/imageinfo.cpp @@ -5,6 +5,7 @@ #include #include #include "pcl/FITSHeaderKeyword.h" +#include "pcl/Property.h" static const QVector noEditableKey = {"SIMPLE", "BITPIX", "NAXIS", "NAXIS1", "NAXIS2", "NAXIS3", "EXTEND", "BZERO", "BSCALE"}; @@ -43,6 +44,38 @@ FITSRecord::FITSRecord(const pcl::FITSHeaderKeyword &record) value = string; } +FITSRecord::FITSRecord(const pcl::Property &property) +{ + key = property.Identifier().c_str(); + + const pcl::Variant &pclval = property.Value(); + switch(pclval.Type()) + { + case pcl::VariantType::Bool: + value = pclval.ToBool(); + break; + case pcl::VariantType::Int8: + case pcl::VariantType::Int16: + case pcl::VariantType::Int32: + case pcl::VariantType::Int64: + value = pclval.ToInt64(); + break; + case pcl::VariantType::UInt8: + case pcl::VariantType::UInt16: + case pcl::VariantType::UInt32: + case pcl::VariantType::UInt64: + value = pclval.ToUInt64(); + break; + case pcl::VariantType::Float: + case pcl::VariantType::Double: + value = pclval.ToDouble(); + break; + default: + value = pclval.ToIsoString().c_str(); + break; + } +} + QByteArray FITSRecord::valueToByteArray() const { if(value.type() == QVariant::Bool) diff --git a/imageinfo.h b/imageinfo.h index eebe0cd..1c66c83 100644 --- a/imageinfo.h +++ b/imageinfo.h @@ -6,7 +6,7 @@ #include #include -namespace pcl { class FITSHeaderKeyword; } +namespace pcl { class FITSHeaderKeyword; class Property; } struct FITSRecord { @@ -17,6 +17,7 @@ struct FITSRecord FITSRecord(){} FITSRecord(const QByteArray &key, const QVariant &value, const QByteArray &comment); FITSRecord(const pcl::FITSHeaderKeyword &record); + FITSRecord(const pcl::Property &property); QByteArray valueToByteArray() const; }; diff --git a/loadrunable.cpp b/loadrunable.cpp index ef4aea6..9f0b8f2 100644 --- a/loadrunable.cpp +++ b/loadrunable.cpp @@ -349,6 +349,12 @@ bool loadXISF(const QString &path, ImageInfoData &info, RawImage **image) { info.fitsHeader.append(fits); } + auto imageproperties = xisf.ReadImageProperties(); + for(auto prop : imageproperties) + { + info.fitsHeader.append(prop); + } + info.wcs = std::make_shared(xisf.ImageInfo().width, xisf.ImageInfo().height, info.fitsHeader); info.info.append({QObject::tr("Width"), QString::number(xisf.ImageInfo().width)}); info.info.append({QObject::tr("Height"), QString::number(xisf.ImageInfo().height)}); @@ -534,6 +540,12 @@ bool readXISFHeader(const QString &path, ImageInfoData &info) { info.fitsHeader.append(fits); } + + auto imageproperties = xisf.ReadImageProperties(); + for(auto prop : imageproperties) + { + info.fitsHeader.append(prop); + } info.wcs = std::make_shared(xisf.ImageInfo().width, xisf.ImageInfo().height, info.fitsHeader); if(!info.wcs->valid())info.wcs.reset(); }