xisf/
XISFFormat.rs

1//     ____   ______ __
2//    / __ \ / ____// /
3//   / /_/ // /    / /
4//  / ____// /___ / /___   PixInsight Class Library
5// /_/     \____//_____/   PCL 2.4.29
6// ----------------------------------------------------------------------------
7// Standard XISF File Format Module Version 1.0.13
8// ----------------------------------------------------------------------------
9// XISFFormat.cpp - Released 2022-05-17T17:15:03Z
10// ----------------------------------------------------------------------------
11// This file is part of the standard XISF PixInsight module.
12//
13// Copyright (c) 2003-2022 Pleiades Astrophoto S.L. All Rights Reserved.
14//
15// Redistribution and use in both source and binary forms, with or without
16// modification, is permitted provided that the following conditions are met:
17//
18// 1. All redistributions of source code must retain the above copyright
19//    notice, this list of conditions and the following disclaimer.
20//
21// 2. All redistributions in binary form must reproduce the above copyright
22//    notice, this list of conditions and the following disclaimer in the
23//    documentation and/or other materials provided with the distribution.
24//
25// 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
26//    of their contributors, may be used to endorse or promote products derived
27//    from this software without specific prior written permission. For written
28//    permission, please contact info@pixinsight.com.
29//
30// 4. All products derived from this software, in any form whatsoever, must
31//    reproduce the following acknowledgment in the end-user documentation
32//    and/or other materials provided with the product:
33//
34//    "This product is based on software from the PixInsight project, developed
35//    by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
36//
37//    Alternatively, if that is where third-party acknowledgments normally
38//    appear, this acknowledgment must be reproduced in the product itself.
39//
40// THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
41// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
42// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
44// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45// EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
46// INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
47// DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
50// POSSIBILITY OF SUCH DAMAGE.
51// ----------------------------------------------------------------------------
52
53//#include "XISFFormat.h"
54//#include "XISFInstance.h"
55//#include "XISFPreferencesDialog.h"
56
57// #include <pcl/ErrorHandler.h>
58// #include <pcl/Settings.h>
59
60pub const XISF_SIGNATURE: u32 = 0x58495346; // 'XISF'
61
62struct FormatOptions {
63    pub options: XISFOptions,
64    signature: u32,
65}
66
67struct EmbeddingOverrides {
68    overridePropertyEmbedding: bool,
69    embedProperties: bool, // true
70    overrideICCProfileEmbedding: bool,
71    embedICCProfiles: bool,
72    overrideDisplayFunctionEmbedding: bool,
73    embedDisplayFunctions: bool,
74    overrideRGBWorkingSpaceEmbedding: bool,
75    embedRGBWorkingSpaces: bool,
76    overrideThumbnailEmbedding: bool,
77    embedThumbnails: bool,
78    overrideProcessingHistoriesEmbedding: bool,
79    embedProcessingHistories: bool,
80    overridePreviewRectsEmbedding: bool,
81    embedPreviewRects: bool,
82}
83
84impl EmbeddingOverrides {
85    pub fn new() -> Self {
86        Self {
87            overridePropertyEmbedding: false,
88            embedProperties: true,
89            overrideICCProfileEmbedding: false,
90            embedICCProfiles: false,
91            overrideDisplayFunctionEmbedding: false,
92            embedDisplayFunctions: false,
93            overrideRGBWorkingSpaceEmbedding: false,
94            embedRGBWorkingSpaces: false,
95            overrideThumbnailEmbedding: false,
96            embedThumbnails: false,
97            overrideProcessingHistoriesEmbedding: false,
98            embedProcessingHistories: false,
99            overridePreviewRectsEmbedding: false,
100            embedPreviewRects: false,
101        }
102    }
103}
104
105pub struct XISFFormat {
106    Name: IsoString, // IsoString
107    FileExtensions: StringList,
108
109    MimeTypes: IsoStringList,
110
111    Version: u32,
112
113    Description: String,
114    Implementation: String,
115
116    IconImageSVGFile: String,
117
118    CanReadIncrementally: bool,
119    CanWriteIncrementally: bool,
120    CanStore32Bit: bool,
121    CanStore64Bit: bool,
122    CanStoreFloat: bool,
123    CanStoreDouble: bool,
124    CanStoreComplex: bool,
125    CanStoreDComplex: bool,
126    CanStoreResolution: bool,
127    CanStoreKeywords: bool,
128    CanStoreICCProfiles: bool,
129    CanStoreThumbnails: bool,
130    CanStoreProperties: bool,
131    CanStoreImageProperties: bool,
132    CanStoreRGBWS: bool,
133    CanStoreDisplayFunctions: bool,
134    CanStoreColorFilterArrays: bool,
135    SupportsCompression: bool,
136    SupportsMultipleImages: bool,
137    SupportsViewProperties: bool,
138    CanEditPreferences: bool,
139    UsesFormatSpecificData: bool,
140
141    //Create: FileFormatImplementation,
142    EditPreferences: bool,
143    // static XISFOptions DefaultOptions();
144
145    // static EmbeddingOverrides DefaultEmbeddingOverrides();
146}
147
148impl XISFFormat {
149    pub fn new() -> Self {
150        Self {
151            Name: "XISF".to_string(),
152            FileExtensions: vec![".xisf".to_string()],
153            MimeTypes: vec![],
154            Version: 0x100,
155            Description: todo!(),
156            Implementation: todo!(),
157            IconImageSVGFile: "@module_icons_dir/XISF.svg".to_string(),
158            CanReadIncrementally: true,
159            CanWriteIncrementally: true,
160            CanStore32Bit: true,
161            CanStore64Bit: false,
162            CanStoreFloat: true,
163            CanStoreDouble: true,
164            CanStoreComplex: true,
165            CanStoreDComplex: true,
166            CanStoreResolution: true,
167            CanStoreKeywords: true,
168            CanStoreICCProfiles: true,
169            CanStoreThumbnails: true,
170            CanStoreProperties: true,
171            CanStoreImageProperties: true,
172            CanStoreRGBWS: true,
173            CanStoreDisplayFunctions: true,
174            CanStoreColorFilterArrays: true,
175            SupportsCompression: true,
176            SupportsMultipleImages: true,
177            SupportsViewProperties: true,
178            CanEditPreferences: true,
179            UsesFormatSpecificData: true,
180            EditPreferences: todo!(),
181        }
182    }
183
184    pub fn DefaultOptions() {}
185}
186
187/*
188
189XISFOptions XISFFormat::DefaultOptions()
190{
191   XISFOptions options;
192   bool   b;
193   uint8  u8;
194   uint16 u16;
195
196   b = options.storeFITSKeywords;
197   Settings::Read( "XISFStoreFITSKeywords", b );
198   options.storeFITSKeywords = b;
199
200   b = options.ignoreFITSKeywords;
201   Settings::Read( "XISFIgnoreFITSKeywords", b );
202   options.ignoreFITSKeywords = b;
203
204   b = options.importFITSKeywords;
205   Settings::Read( "XISFImportFITSKeywords", b );
206   options.importFITSKeywords = b;
207
208   b = options.ignoreEmbeddedData;
209   Settings::Read( "XISFIgnoreEmbeddedData", b );
210   options.ignoreEmbeddedData = b;
211
212   b = options.ignoreProperties;
213   Settings::Read( "XISFIgnoreProperties", b );
214   options.ignoreProperties = b;
215
216   b = options.autoMetadata;
217   Settings::Read( "XISFAutoMetadata", b );
218   options.autoMetadata = b;
219
220   u8 = options.compressionCodec;
221   Settings::ReadU( "XISFCompressionCodec", u8 );
222   options.compressionCodec = XISF::block_compression( u8 );
223
224   u8 = options.compressionLevel;
225   Settings::ReadU( "XISFCompressionLevel", u8 );
226   options.compressionLevel = u8;
227
228   u8 = options.checksumAlgorithm;
229   Settings::ReadU( "XISFChecksums", u8 );
230   options.checksumAlgorithm = XISF::block_checksum( u8 );
231
232   u16 = options.blockAlignmentSize;
233   Settings::ReadU( "XISFBlockAlignmentSize", u16 );
234   options.blockAlignmentSize = u16;
235
236   u16 = options.maxInlineBlockSize;
237   Settings::ReadU( "XISFMaxInlineBlockSize", u16 );
238   options.maxInlineBlockSize = u16;
239
240   return options;
241}
242*/
243// ----------------------------------------------------------------------------
244
245use crate::{IsoString, IsoStringList, StringList, XISF::XISFOptions};