libCZI
Reading CZI documents made easy
libCZI_Metadata.h
1 //******************************************************************************
2 //
3 // libCZI is a reader for the CZI fileformat written in C++
4 // Copyright (C) 2017 Zeiss Microscopy GmbH
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 //
19 // To obtain a commercial version please contact Zeiss Microscopy GmbH.
20 //
21 //******************************************************************************
22 
23 #pragma once
24 
25 #include "libCZI_DimCoordinate.h"
26 #include "libCZI_Pixels.h"
27 #include <limits>
28 #include <string>
29 #include <vector>
30 #include <functional>
31 #include <memory>
32 
33 namespace libCZI
34 {
37  {
39  std::wstring name;
40  std::wstring title;
41  std::wstring userName;
42  std::wstring description;
43  std::wstring comment;
44  std::wstring keywords;
45  int rating;
46  std::wstring creationDateTime;
47  };
48 
50  struct ScalingInfo
51  {
52  ScalingInfo() : scaleX(std::numeric_limits<double>::quiet_NaN()), scaleY(std::numeric_limits<double>::quiet_NaN()), scaleZ(std::numeric_limits<double>::quiet_NaN()) {}
53  double scaleX;
54  double scaleY;
55  double scaleZ;
56  };
57 
60  {
61  public:
62 
65  virtual DimensionIndex GetDimension() const = 0;
66 
70  virtual void GetInterval(int* start, int* end) const = 0;
71 
72  virtual ~IDimensionInfo() {}
73  };
74 
76 
79  {
80  public:
83  {
84  double x;
85  double y;
86  };
87 
89  enum class GradationCurveMode
90  {
91  Linear,
92  Gamma,
93  Spline
94  };
95 
98  {
99  double a;
100  double b;
101  double c;
102  double d;
103 
109  double Get(int index) const
110  {
111  switch (index)
112  {
113  case 0:return this->a;
114  case 1:return this->b;
115  case 2:return this->c;
116  case 3:return this->d;
117  }
118 
119  return std::numeric_limits<double>::quiet_NaN();
120  }
121  };
122 
124  struct SplineData
125  {
127  double xPos;
128 
131  };
132 
137  virtual void EnumChannels(std::function<bool(int chIndex)> func) const = 0;
138 
145  virtual std::shared_ptr<libCZI::IChannelDisplaySetting> GetChannelDisplaySettings(int chIndex) const = 0;
146 
147  virtual ~IDisplaySettings() {}
148  };
149 
152  {
153  public:
154 
158  virtual bool GetIsEnabled() const = 0;
159 
163  virtual float GetWeight() const = 0;
164 
171  virtual bool TryGetTintingColorRgb8(libCZI::Rgb8Color* pColor) const = 0;
172 
177  virtual void GetBlackWhitePoint(float* pBlack, float* pWhite) const = 0;
178 
183 
189  virtual bool TryGetGamma(float* gamma)const = 0;
190 
202  virtual bool TryGetSplineControlPoints(std::vector<libCZI::IDisplaySettings::SplineControlPoint>* ctrlPts) const = 0;
203 
209  virtual bool TryGetSplineData(std::vector<libCZI::IDisplaySettings::SplineData>* data) const = 0;
210 
211  virtual ~IChannelDisplaySetting() {}
212  };
213 
216  {
217  public:
218 
221  virtual GeneralDocumentInfo GetGeneralDocumentInfo() const = 0;
222 
225  virtual libCZI::ScalingInfo GetScalingInfo() const = 0;
226 
231  virtual void EnumDimensions(std::function<bool(DimensionIndex)> enumDimensions) = 0;
232 
238  virtual std::shared_ptr<IDimensionInfo> GetDimensionInfo(DimensionIndex dim) = 0;
239 
244  virtual std::shared_ptr<IDisplaySettings> GetDisplaySettings() const = 0;
245 
246  virtual ~ICziMultiDimensionDocumentInfo() {}
247 
250  std::vector<DimensionIndex> GetDimensions()
251  {
252  std::vector<DimensionIndex> vec;
253  this->EnumDimensions([&](DimensionIndex i)->bool {vec.push_back(i); return true; });
254  return vec;
255  }
256  };
257 
260  {
261  public:
265  virtual std::string GetXml() = 0;
266 
270  virtual std::shared_ptr<libCZI::ICziMultiDimensionDocumentInfo> GetDocumentInfo() = 0;
271 
272  virtual ~ICziMetadata() {}
273  };
274 }
275 
276 
virtual std::shared_ptr< libCZI::ICziMultiDimensionDocumentInfo > GetDocumentInfo()=0
virtual IDisplaySettings::GradationCurveMode GetGradationCurveMode() const =0
std::wstring userName
Name of the user who created the document.
Definition: libCZI_Metadata.h:41
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:55
virtual std::shared_ptr< IDimensionInfo > GetDimensionInfo(DimensionIndex dim)=0
Representation of the CZI-metadata.
Definition: libCZI_Metadata.h:259
std::vector< DimensionIndex > GetDimensions()
Definition: libCZI_Metadata.h:250
double b
The coefficient of the square.
Definition: libCZI_Metadata.h:100
virtual std::shared_ptr< IDisplaySettings > GetDisplaySettings() const =0
virtual std::shared_ptr< libCZI::IChannelDisplaySetting > GetChannelDisplaySettings(int chIndex) const =0
The defintion of the (piecewise) spline. The spline starts at xPos which is the normalized position (...
Definition: libCZI_Metadata.h:124
The gradation curve is a straight line (from white point to black point).
virtual void EnumDimensions(std::function< bool(DimensionIndex)> enumDimensions)=0
double y
The normalized y-coordinate of a spline control point.
Definition: libCZI_Metadata.h:85
double c
The coefficient of the linear term.
Definition: libCZI_Metadata.h:101
virtual GeneralDocumentInfo GetGeneralDocumentInfo() const =0
double x
The normalized x-coordinate of a spline control point.
Definition: libCZI_Metadata.h:84
std::wstring description
A text describing the document.
Definition: libCZI_Metadata.h:42
std::wstring comment
A text with comments on the document.
Definition: libCZI_Metadata.h:43
double a
The coefficient of the cube.
Definition: libCZI_Metadata.h:99
The display settings.
Definition: libCZI_Metadata.h:78
double Get(int index) const
Definition: libCZI_Metadata.h:109
double xPos
The (normalized) position for which this spline definition is valid.
Definition: libCZI_Metadata.h:127
std::wstring title
Title of the document.
Definition: libCZI_Metadata.h:40
Scaling information - gives the size of a pixel.
Definition: libCZI_Metadata.h:50
Base class for information about the dimension. (not yet implemented)
Definition: libCZI_Metadata.h:59
double d
The constant.
Definition: libCZI_Metadata.h:102
CubicSplineCoefficients coefficients
The spline coefficients for this piece.
Definition: libCZI_Metadata.h:130
A structure representing an R-G-B-color triple (as bytes).
Definition: libCZI_Pixels.h:110
The coefficients of a cubic spline defined by .
Definition: libCZI_Metadata.h:97
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:54
virtual void GetInterval(int *start, int *end) const =0
virtual bool GetIsEnabled() const =0
The gradation curve is defined by piecewise splines.
virtual bool TryGetSplineControlPoints(std::vector< libCZI::IDisplaySettings::SplineControlPoint > *ctrlPts) const =0
std::wstring name
Name of the document.
Definition: libCZI_Metadata.h:39
std::wstring keywords
List of keywords (should be separated by semicolons)
Definition: libCZI_Metadata.h:44
virtual bool TryGetTintingColorRgb8(libCZI::Rgb8Color *pColor) const =0
virtual DimensionIndex GetDimension() const =0
virtual libCZI::ScalingInfo GetScalingInfo() const =0
virtual void EnumChannels(std::function< bool(int chIndex)> func) const =0
virtual std::string GetXml()=0
virtual bool TryGetGamma(float *gamma) const =0
int rating
An integer specifying a "five-star-rating" (should be between 0 and 5).
Definition: libCZI_Metadata.h:45
virtual bool TryGetSplineData(std::vector< libCZI::IDisplaySettings::SplineData > *data) const =0
External interfaces, classes, functions and structs are found in the namespace "libCZI".
Definition: libCZI.h:44
The top-level interface for the CZI-metadata object.
Definition: libCZI_Metadata.h:215
DimensionIndex
Values that represent dimension indexes.
Definition: libCZI_DimCoordinate.h:34
The gradation curve is defined by a gamma.
The (normalized) control points of a spline.
Definition: libCZI_Metadata.h:82
The display-settings for a channel.
Definition: libCZI_Metadata.h:151
General document information - corresponding to Information/Document.
Definition: libCZI_Metadata.h:36
virtual void GetBlackWhitePoint(float *pBlack, float *pWhite) const =0
virtual float GetWeight() const =0
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:53
std::wstring creationDateTime
The creation date of the document (formatted as xml-datatype "dateTime").
Definition: libCZI_Metadata.h:46
GradationCurveMode
Values that represent the gradation curve modes.
Definition: libCZI_Metadata.h:89