7 #include "ImportExport.h"
8 #include "libCZI_DimCoordinate.h"
9 #include "libCZI_Pixels.h"
22 struct SubBlockStatistics;
45 this->sec = this->min = this->hour = this->mday = this->mon = this->year = 0;
47 this->offsetHours = (std::numeric_limits<int>::min)();
48 this->offsetMinutes = (std::numeric_limits<int>::min)();
61 if (this->offsetHours <= -24 || this->offsetHours >= 24 || this->offsetMinutes >= 60 || this->offsetMinutes < 0)
202 this->name_valid = this->title_valid = this->userName_valid = this->description_valid =
203 this->comment_valid = this->keywords_valid = this->rating_valid = this->creationDateTime_valid =
false;
208 if (str ==
nullptr || *str == L
'\0')
210 (this->*strMember).clear();
211 this->*validMember =
false;
215 this->*strMember = str;
216 this->*validMember =
true;
225 ScalingInfo() : scaleX(std::numeric_limits<double>::quiet_NaN()), scaleY(std::numeric_limits<double>::quiet_NaN()), scaleZ(std::numeric_limits<double>::quiet_NaN()) {}
233 bool IsScaleXValid()
const {
return !std::isnan(this->scaleX) && !std::isinf(this->scaleX); }
238 bool IsScaleYValid()
const {
return !std::isnan(this->scaleY) && !std::isinf(this->scaleY); }
243 bool IsScaleZValid()
const {
return !std::isnan(this->scaleZ) && !std::isinf(this->scaleZ); }
256 case 'x':
case'X':
return this->IsScaleXValid();
257 case 'y':
case'Y':
return this->IsScaleYValid();
258 case 'z':
case'Z':
return this->IsScaleZValid();
259 default:
throw std::invalid_argument(
"invalid dimension");
274 case 'x':
case'X':
return this->scaleX;
275 case 'y':
case'Y':
return this->scaleY;
276 case 'z':
case'Z':
return this->scaleZ;
277 default:
throw std::invalid_argument(
"invalid dimension");
304 default:
throw std::invalid_argument(
"invalid dimension");
361 FromSpecimenToObjective,
362 FromObjectiveToSpecimen,
486 LookUpTableExplicit = 2,
487 LookUpTableWellKnown = 3
503 double Get(
int index)
const
507 case 0:
return this->a;
508 case 1:
return this->b;
509 case 2:
return this->c;
510 case 3:
return this->d;
511 default:
return std::numeric_limits<double>::quiet_NaN();
530 virtual void EnumChannels(std::function<
bool(
int chIndex)> func)
const = 0;
606 virtual bool TryGetSplineData(std::vector<libCZI::IDisplaySettings::SplineData>* data)
const = 0;
662 this->isEnabled =
false;
664 this->blackPoint = 0;
665 this->whitePoint = 1;
752 std::vector<DimensionIndex> vec;
753 this->EnumDimensions([&](
DimensionIndex i)->
bool {vec.push_back(i);
return true; });
764 virtual std::wstring
Name()
const = 0;
773 virtual bool TryGetAttribute(
const wchar_t* attributeName, std::wstring* attribValue)
const = 0;
778 virtual void EnumAttributes(
const std::function<
bool(
const std::wstring& attribName,
const std::wstring& attribValue)>& enumFunc)
const = 0;
830 virtual void EnumChildren(
const std::function<
bool(std::shared_ptr<IXmlNodeRead>)>& enumChildren) = 0;
890 virtual std::shared_ptr<libCZI::ICziMultiDimensionDocumentInfo>
GetDocumentInfo() = 0;
960 virtual std::shared_ptr<IXmlNodeRw>
GetChildNode(
const char* path) = 0;
979 virtual void SetAttribute(
const wchar_t* name,
const wchar_t* value) = 0;
1102 virtual std::string
GetXml(
bool withIndent =
false) = 0;
1172 this->SetString(
string);
1180 this->type = Type::Int32;
1181 this->int32Value = v;
1189 this->type = Type::Double;
1190 this->doubleValue = v;
1198 this->type = Type::Float;
1199 this->floatValue = v;
1207 this->type = Type::Boolean;
1208 this->boolValue = v;
1216 this->type = Type::String;
1217 this->stringValue = v;
1223 this->ThrowIfTypeIsUnequalTo(Type::Int32);
1224 return this->int32Value;
1230 this->ThrowIfTypeIsUnequalTo(Type::Double);
1231 return this->doubleValue;
1237 this->ThrowIfTypeIsUnequalTo(Type::Float);
1238 return this->floatValue;
1244 this->ThrowIfTypeIsUnequalTo(Type::Boolean);
1245 return this->boolValue;
1251 this->ThrowIfTypeIsUnequalTo(Type::String);
1252 return this->stringValue;
1266 std::int32_t int32Value;
1272 std::string stringValue;
1274 void ThrowIfTypeIsUnequalTo(Type typeToCheck)
const
1276 if (this->type != typeToCheck)
1278 throw std::runtime_error(
"Unexpected type encountered.");
1290 bool writePixelType{
false };
1292 bool writeIdAttribute{
false };
1294 bool writeNameAttribute{
false };
The display-settings for a channel.
Definition: libCZI_Metadata.h:550
virtual void GetBlackWhitePoint(float *pBlack, float *pWhite) const =0
virtual bool TryGetGamma(float *gamma) const =0
virtual bool TryGetTintingColorRgb8(libCZI::Rgb8Color *pColor) const =0
virtual bool GetIsEnabled() const =0
virtual IDisplaySettings::GradationCurveMode GetGradationCurveMode() const =0
static void Clone(const IChannelDisplaySetting *disp, ChannelDisplaySettingsPOD &pod)
virtual float GetWeight() const =0
virtual bool TryGetSplineData(std::vector< libCZI::IDisplaySettings::SplineData > *data) const =0
virtual bool TryGetSplineControlPoints(std::vector< libCZI::IDisplaySettings::SplineControlPoint > *ctrlPts) const =0
The top-level interface for the CZI-metadata object.
Definition: libCZI_Metadata.h:695
virtual std::shared_ptr< IDimensionInfo > GetDimensionInfo(DimensionIndex dim)=0
virtual std::shared_ptr< IDimensionZInfo > GetDimensionZInfo()=0
virtual std::shared_ptr< IDimensionTInfo > GetDimensionTInfo()=0
virtual libCZI::ScalingInfoEx GetScalingInfoEx() const =0
virtual std::shared_ptr< IDimensionsChannelsInfo > GetDimensionChannelsInfo()=0
virtual std::shared_ptr< IDisplaySettings > GetDisplaySettings() const =0
virtual void EnumDimensions(const std::function< bool(DimensionIndex)> &enumDimensions)=0
virtual libCZI::ScalingInfo GetScalingInfo() const =0
std::vector< DimensionIndex > GetDimensions()
Definition: libCZI_Metadata.h:750
virtual GeneralDocumentInfo GetGeneralDocumentInfo() const =0
Base class for information about the dimension.
Definition: libCZI_Metadata.h:311
virtual void GetInterval(int *start, int *end) const =0
virtual DimensionIndex GetDimension() const =0
virtual void GetIntervalIsExplicitlyStated(bool *startExplicitlyStated, bool *endExplicitlyStated) const =0
This structure defines the information for the "T-dimension". It resembles the ZEN-metadata-structure...
Definition: libCZI_Metadata.h:417
virtual bool TryGetOffsetsList(std::vector< double > *offsets)=0
virtual bool TryGetIntervalDefinition(double *offset, double *increment)=0
virtual bool TryGetStartTime(XmlDateTime *dateTime)=0
This structure defines the information for the "Z-dimension". It resembles the ZEN-metadata-structure...
Definition: libCZI_Metadata.h:334
ZaxisDirection
Definition: libCZI_Metadata.h:360
virtual bool TryGetPositionList(std::vector< double > *positions)=0
virtual bool TryGetZAxisDirection(ZaxisDirection *zAxisDirection)=0
virtual bool TryGetXyzHandedness(XyzHandedness *xyzHandedness)=0
virtual bool TryGetIntervalDefinition(double *offset, double *increment)=0
virtual bool TryZDriveSpeed(double *zdrivespeed)=0
virtual bool TryGetZDriveMode(ZDriveMode *zdrivemode)=0
ZDriveMode
Definition: libCZI_Metadata.h:371
XyzHandedness
Definition: libCZI_Metadata.h:344
virtual bool TryGetReferencePosition(double *d)=0
Information about the set of channels.
Definition: libCZI_Metadata2.h:354
The display settings.
Definition: libCZI_Metadata.h:445
static void Clone(const IDisplaySettings *disp, DisplaySettingsPOD &pod)
TintingMode
Definition: libCZI_Metadata.h:483
@ None
None - which gives the "original color", i.e. in case of RGB the RGB-value is directly used,...
virtual std::shared_ptr< libCZI::IChannelDisplaySetting > GetChannelDisplaySettings(int chIndex) const =0
GradationCurveMode
Values that represent the gradation curve modes.
Definition: libCZI_Metadata.h:471
@ Linear
The gradation curve is a straight line (from white point to black point).
virtual void EnumChannels(std::function< bool(int chIndex)> func) const =0
This interface provides read-only access to an XML-node.
Definition: libCZI_Metadata.h:760
bool TryGetValueAsUInt32(std::uint32_t *p)
bool TryGetValueAsBool(bool *p)
bool TryGetValueAsDouble(double *p)
virtual std::shared_ptr< IXmlNodeRead > GetChildNodeReadonly(const char *path)=0
bool TryGetValueAsUInt64(std::uint64_t *p)
virtual std::wstring Name() const =0
virtual bool TryGetAttribute(const wchar_t *attributeName, std::wstring *attribValue) const =0
virtual bool TryGetValue(std::wstring *value) const =0
virtual void EnumChildren(const std::function< bool(std::shared_ptr< IXmlNodeRead >)> &enumChildren)=0
bool TryGetValueAsInt32(std::int32_t *p)
bool TryGetValueAsInt64(std::int64_t *p)
bool TryGetValueAsFloat(float *p)
virtual void EnumAttributes(const std::function< bool(const std::wstring &attribName, const std::wstring &attribValue)> &enumFunc) const =0
This interface combines read- and write-access for an XML-node.
Definition: libCZI_Metadata.h:1087
This interface provides write access to an XML-node.
Definition: libCZI_Metadata.h:899
std::shared_ptr< IXmlNodeRw > GetChildNode(const std::string &path)
Definition: libCZI_Metadata.h:1082
virtual void SetValueI32(int value)=0
virtual std::shared_ptr< IXmlNodeRw > GetOrCreateChildNode(const char *path)=0
virtual bool RemoveChild(const char *name)=0
virtual void SetValueBool(bool value)=0
virtual void SetValueUI64(unsigned long long value)=0
virtual void SetAttribute(const wchar_t *name, const wchar_t *value)=0
virtual std::shared_ptr< IXmlNodeRw > GetChildNode(const char *path)=0
void SetValue(const std::wstring &str)
Definition: libCZI_Metadata.h:1054
virtual void SetValue(const wchar_t *str)=0
std::shared_ptr< IXmlNodeRw > GetOrCreateChildNode(const std::string &path)
Definition: libCZI_Metadata.h:1077
virtual void RemoveChildren()=0
Removes all children of this node.
virtual void SetValueDbl(double value)=0
virtual void SetValueFlt(float value)=0
virtual void SetValueUI32(unsigned int value)=0
virtual void SetValueI64(long long value)=0
virtual bool RemoveAttribute(const char *name)=0
virtual void SetValue(const char *str)=0
virtual void RemoveAttributes()=0
Removes all attributes of this node.
void SetValue(const std::string &str)
Definition: libCZI_Metadata.h:1049
virtual void SetAttribute(const char *name, const char *value)=0
virtual std::shared_ptr< IXmlNodeRw > AppendChildNode(const char *name)=0
External interfaces, classes, functions and structs are found in the namespace "libCZI".
Definition: libCZI.h:31
DimensionIndex
Values that represent dimension indexes.
Definition: libCZI_DimCoordinate.h:17
@ None
No camera processing was used.
PixelType
An enum representing a pixel-type.
Definition: libCZI_Pixels.h:114
@ Invalid
Invalid pixel type.
Definition: libCZI_Metadata.h:619
bool isEnabled
A boolean indicating whether the corresponding channel is 'active' in the multi-channel-composition.
Definition: libCZI_Metadata.h:621
static LIBCZI_API IChannelDisplaySetting * CreateIChannelDisplaySetting(const ChannelDisplaySettingsPOD &pod)
IDisplaySettings::TintingMode tintingMode
The tinting mode.
Definition: libCZI_Metadata.h:627
IDisplaySettings::GradationCurveMode gradationCurveMode
The gradation curve mode.
Definition: libCZI_Metadata.h:639
LIBCZI_API void Clear()
Definition: libCZI_Metadata.h:660
static LIBCZI_API std::shared_ptr< IChannelDisplaySetting > CreateIChannelDisplaySettingSp(const ChannelDisplaySettingsPOD &pod)
float blackPoint
The (normalized) black point value.
Definition: libCZI_Metadata.h:633
float whitePoint
The (normalized) white point value.
Definition: libCZI_Metadata.h:636
float gamma
The value for gamma (only valid if gradation curve mode == Gamma).
Definition: libCZI_Metadata.h:642
libCZI::Rgb8Color tintingColor
The tinting color (only valid if tinting mode == Color).
Definition: libCZI_Metadata.h:630
float weight
The weight of the channel (for multi-channel-composition).
Definition: libCZI_Metadata.h:624
std::vector< libCZI::IDisplaySettings::SplineControlPoint > splineCtrlPoints
The spline control points (only valid if gradation curve mode == Spline).
Definition: libCZI_Metadata.h:645
Variant for CustomValue.
Definition: libCZI_Metadata.h:1109
CustomValueVariant()
Default constructor - setting the variant to 'invalid'.
Definition: libCZI_Metadata.h:1123
std::int32_t GetAsInt32OrThrow() const
Returns integer value if ValueType is int, otherwise throws a RuntimeError.
Definition: libCZI_Metadata.h:1221
Type GetType() const
Returns ValueType.
Definition: libCZI_Metadata.h:1256
CustomValueVariant(std::int32_t v)
Definition: libCZI_Metadata.h:1130
CustomValueVariant(bool v)
Definition: libCZI_Metadata.h:1154
void SetFloat(float v)
Definition: libCZI_Metadata.h:1196
void SetBool(bool v)
Definition: libCZI_Metadata.h:1205
float GetAsFloatOrThrow() const
Returns float value if ValueType is 'Float', otherwise throws a RuntimeError.
Definition: libCZI_Metadata.h:1235
std::string GetAsStringOrThrow() const
Returns string value if ValueType is string, otherwise throws a RuntimeError.
Definition: libCZI_Metadata.h:1249
double GetAsDoubleOrThrow() const
Returns double value if ValueType is double, otherwise throws a RuntimeError.
Definition: libCZI_Metadata.h:1228
bool GetAsBoolOrThrow() const
Returns boolean value if ValueType is boolean, otherwise throws a RuntimeError.
Definition: libCZI_Metadata.h:1242
void SetString(const std::string &v)
Definition: libCZI_Metadata.h:1214
void SetInt32(std::int32_t v)
Definition: libCZI_Metadata.h:1178
CustomValueVariant(double v)
Definition: libCZI_Metadata.h:1138
void SetDouble(double v)
Definition: libCZI_Metadata.h:1187
Type
Values that represent the type represented by this variant.
Definition: libCZI_Metadata.h:1113
CustomValueVariant(const std::string &v)
Definition: libCZI_Metadata.h:1162
CustomValueVariant(float v)
Definition: libCZI_Metadata.h:1146
CustomValueVariant(const char *string)
Definition: libCZI_Metadata.h:1170
Definition: libCZI_Metadata.h:675
std::map< int, ChannelDisplaySettingsPOD > channelDisplaySettings
The channel display settings. Key is the channel index, and value is the POD-channel-display-data str...
Definition: libCZI_Metadata.h:677
static LIBCZI_API libCZI::IDisplaySettings * CreateIDisplaySetting(const DisplaySettingsPOD &pod)
static LIBCZI_API std::shared_ptr< libCZI::IDisplaySettings > CreateIDisplaySettingSp(const DisplaySettingsPOD &pod)
General document information - corresponding to Information/Document.
Definition: libCZI_Metadata.h:100
LIBCZI_API void SetKeywords(const wchar_t *sz)
Definition: libCZI_Metadata.h:173
LIBCZI_API void SetTitle(const wchar_t *sz)
Definition: libCZI_Metadata.h:133
LIBCZI_API void SetUserName(const std::wstring &str)
Definition: libCZI_Metadata.h:148
int rating
An integer specifying a "five-star-rating" (should be between 0 and 5).
Definition: libCZI_Metadata.h:116
std::wstring userName
Name of the user who created the document.
Definition: libCZI_Metadata.h:108
LIBCZI_API void SetCreationDate(const std::wstring &str)
Definition: libCZI_Metadata.h:192
bool comment_valid
Whether the field comment is valid.
Definition: libCZI_Metadata.h:111
LIBCZI_API GeneralDocumentInfo()
Default constructor - all fields are intially marked "invalid".
Definition: libCZI_Metadata.h:102
LIBCZI_API void SetUserName(const wchar_t *sz)
Definition: libCZI_Metadata.h:143
bool rating_valid
Whether the field rating is valid.
Definition: libCZI_Metadata.h:115
std::wstring comment
A text with comments on the document.
Definition: libCZI_Metadata.h:112
LIBCZI_API void SetCreationDate(const wchar_t *sz)
Definition: libCZI_Metadata.h:187
bool userName_valid
Whether the field userName is valid.
Definition: libCZI_Metadata.h:107
std::wstring creationDateTime
The creation date of the document (formatted as xml-datatype "dateTime").
Definition: libCZI_Metadata.h:118
LIBCZI_API void SetTitle(const std::wstring &str)
Definition: libCZI_Metadata.h:138
LIBCZI_API void SetRating(int rating)
Definition: libCZI_Metadata.h:182
LIBCZI_API void SetName(const std::wstring &str)
Definition: libCZI_Metadata.h:128
bool creationDateTime_valid
Whether the field creationDateTime is valid.
Definition: libCZI_Metadata.h:117
LIBCZI_API void Clear()
Sets all fields to "invalid".
Definition: libCZI_Metadata.h:200
LIBCZI_API void SetCreationDate(const XmlDateTime *dateTime)
Definition: libCZI_Metadata.h:197
std::wstring title
Title of the document.
Definition: libCZI_Metadata.h:106
LIBCZI_API void SetComment(const wchar_t *sz)
Definition: libCZI_Metadata.h:163
LIBCZI_API void SetDescription(const std::wstring &str)
Definition: libCZI_Metadata.h:158
LIBCZI_API void SetKeywords(const std::wstring &str)
Definition: libCZI_Metadata.h:178
std::wstring description
A text describing the document.
Definition: libCZI_Metadata.h:110
bool name_valid
Whether the field name is valid.
Definition: libCZI_Metadata.h:103
bool keywords_valid
Whether the field keywords is valid.
Definition: libCZI_Metadata.h:113
LIBCZI_API void SetDescription(const wchar_t *sz)
Definition: libCZI_Metadata.h:153
std::wstring keywords
List of keywords (should be separated by semicolons)
Definition: libCZI_Metadata.h:114
LIBCZI_API void SetComment(const std::wstring &str)
Definition: libCZI_Metadata.h:168
LIBCZI_API void SetName(const wchar_t *sz)
Definition: libCZI_Metadata.h:123
bool title_valid
Whether the field title is valid.
Definition: libCZI_Metadata.h:105
bool description_valid
Whether the field description is valid.
Definition: libCZI_Metadata.h:109
std::wstring name
Name of the document.
Definition: libCZI_Metadata.h:104
The coefficients of a cubic spline defined by .
Definition: libCZI_Metadata.h:492
double d
The constant.
Definition: libCZI_Metadata.h:496
double c
The coefficient of the linear term.
Definition: libCZI_Metadata.h:495
double a
The coefficient of the cube.
Definition: libCZI_Metadata.h:493
double b
The coefficient of the square.
Definition: libCZI_Metadata.h:494
double Get(int index) const
Definition: libCZI_Metadata.h:503
The (normalized) control points of a spline.
Definition: libCZI_Metadata.h:449
SplineControlPoint(double x, double y)
Definition: libCZI_Metadata.h:456
double x
The normalized x-coordinate of a spline control point.
Definition: libCZI_Metadata.h:450
bool operator!=(const SplineControlPoint &rhs) const
Definition: libCZI_Metadata.h:466
double y
The normalized y-coordinate of a spline control point.
Definition: libCZI_Metadata.h:451
bool operator==(const SplineControlPoint &rhs) const
Definition: libCZI_Metadata.h:461
The definition of the (piecewise) spline. The spline starts at xPos which is the normalized position ...
Definition: libCZI_Metadata.h:518
CubicSplineCoefficients coefficients
The spline coefficients for this piece.
Definition: libCZI_Metadata.h:523
double xPos
The (normalized) position for which this spline definition is valid.
Definition: libCZI_Metadata.h:520
A structure representing an R-G-B-color triple (as bytes).
Definition: libCZI_Pixels.h:98
Definition: libCZI_Metadata.h:285
std::wstring defaultUnitFormatY
The default unit-format for Y.
Definition: libCZI_Metadata.h:287
LIBCZI_API std::wstring GetDefaultUnitFormat(char d) const
Definition: libCZI_Metadata.h:297
std::wstring defaultUnitFormatX
The default unit-format for X.
Definition: libCZI_Metadata.h:286
std::wstring defaultUnitFormatZ
The default unit-format for Z.
Definition: libCZI_Metadata.h:288
Scaling information - gives the size of a pixel.
Definition: libCZI_Metadata.h:223
double scaleY
The length of a pixel in y-direction in the unit meters. If unknown/invalid, this value is numeric_li...
Definition: libCZI_Metadata.h:227
double scaleZ
The length of a pixel in y-direction in the unit meters. If unknown/invalid, this value is numeric_li...
Definition: libCZI_Metadata.h:228
ScalingInfo()
Default constructor - sets all members to invalid.
Definition: libCZI_Metadata.h:225
bool IsScaleZValid() const
Definition: libCZI_Metadata.h:243
bool IsScaleValid(char d) const
Definition: libCZI_Metadata.h:252
bool IsScaleXValid() const
Definition: libCZI_Metadata.h:233
double scaleX
The length of a pixel in x-direction in the unit meters. If unknown/invalid, this value is numeric_li...
Definition: libCZI_Metadata.h:226
double GetScale(char d) const
Definition: libCZI_Metadata.h:270
bool IsScaleYValid() const
Definition: libCZI_Metadata.h:238
Statistics about all sub-blocks found in a CZI-document.
Definition: libCZI.h:437
This structure specifies the information in an XSD-DateTime field (cf. https://www....
Definition: libCZI_Metadata.h:26
std::string ToXmlString() const
bool isUTC
True if this object is specifying the time-date in UTC.
Definition: libCZI_Metadata.h:34
int year
year [-9999 - 9999]
Definition: libCZI_Metadata.h:32
int hour
hours since midnight - [0, 23]
Definition: libCZI_Metadata.h:29
int offsetMinutes
The minutes of the timezone-offset. If greater than 60 or negative, it indicates an invalid timezone-...
Definition: libCZI_Metadata.h:40
void Clear()
Clears this object to its blank/initial state.
Definition: libCZI_Metadata.h:43
std::wstring ToXmlWstring() const
int offsetHours
The hours of the timezone-offset. If greater than 24 or less than -24, it indicates an invalid timezo...
Definition: libCZI_Metadata.h:37
int mon
months since January - [0, 11]
Definition: libCZI_Metadata.h:31
bool HasTimeZoneOffset() const
Definition: libCZI_Metadata.h:54
int min
minutes after the hour - [0, 59]
Definition: libCZI_Metadata.h:28
static bool TryParse(const char *sz, XmlDateTime *ptrDateTime)
int sec
Seconds after the minute - [0, 60] including leap second.
Definition: libCZI_Metadata.h:27
int mday
day of the month - [1, 31]
Definition: libCZI_Metadata.h:30
static bool TryParse(const wchar_t *szw, XmlDateTime *ptrDateTime)